akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        long N;

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextLong();
        }
        long result = ((N-1 + 1) * (N-1))/2;

        System.out.println( result);
    }

}


Measured memory_bytes: 21844
object Main extends App {
  @scala.annotation.tailrec
  def loop(chars: Seq[Char]): Int = chars match {
    case Seq() => 0
    case _ :: _ :: xs =>
      val (l, r) = xs.splitAt(xs.length / 2)
      if (l == r) xs.length else loop(xs)
  }

  val sc = new java.util.Scanner(System.in)
  println(loop(sc.next().toCharArray.toList.reverse))
}


Measured memory_bytes: 55320
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
    main(chunk.trim());
});

function main(chunk){
    var lines = chunk.split("\n");
    var w = Number(lines[0]);
    var n = Number(lines[1]);
    var ans = [];
    for(var i=1;i<=w;i++){
        ans.push(i);
    }
    var index = 2;
    for(var i=0;i<n;i++){
        var a = Number(lines[index].split(",")[0])-1;
        var b = Number(lines[index].split(",")[1])-1;
        var tmp = ans[a];
        ans[a] = ans[b];
        ans[b] = tmp;
        index++;
    }
    for(var i=0;i<w;i++){
        console.log(ans[i]);
    }
}

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

using namespace std;

typedef long long ll;

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

	int N;
	cin >> N;

	vector<ll> s(N);
	rep(i, N) cin >> s[i];

	ll ans = 0;

	for(ll C = 1; C <= N - 1; C++){
		ll sm = 0;
		if((N - 1) % C == 0){
			for(ll k = 1; k * C < N - 1 - k * C; k++){
				sm += s[N - 1 - k * C] + s[k * C];
				ans = max(ans, sm);
			}
		}else{
			for(ll k = 1; N - 1 - k * C > C; k++){
				sm += s[N - 1 - k * C] + s[k * C];
				ans = max(ans, sm);
			}
		}
	}

	cout << ans << endl;

}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String b = scan.next();

		if(b.equals("A")) {
			System.out.println("T");
		}else if(b.equals("C")) {
			System.out.println("G");
		}else if(b.equals("G")) {
			System.out.println("C");
		}else if(b.equals("T")) {
			System.out.println("A");
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
#define int long long
#define double long double
 
int gcd(int x, int y){
    if (y == 0)
        return x;
    x = x % y;
    gcd(y, x);
}
 
int check(int i,int ans){
    if(i<2) return ans;
    ans=i*check(i-2,ans);
}
main(){
    int n,k,r,s,p;
    cin>>n>>k>>r>>s>>p;
    string t;
    cin>>t;
    int ans=0;
    int count1=0,count2=0,count3=0;
    rep(i,n){
        if(t[i]=='r'){
            if(t[i-k]=='R'){
                continue;
            }else{
            t[i]='R';
            ans+=p;
            }
        }else if(t[i]=='s'){
            if(t[i-k]=='S'){
                continue;
            }else{
            t[i]='S';
            ans+=r;
            }
        }else{
            if(t[i-k]=='P'){
                continue;
            }else{
            t[i]='P';
            ans+=s;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
IDENTIFICATION  DIVISION.
PROGRAM-ID.     HELLO.

 
DATA DIVISION.
	WORKING-STORAGE SECTION.
        01 X PIC S99.
      
PROCEDURE       DIVISION.
    ACCEPT X.
    
    IF X < 30 THEN 
      DISPLAY 'No'
    ELSE
      DISPLAY 'Yes'
    END-IF.
    
    STOP RUN.

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

bool comp(pair<pair<int,int>,int> a, pair<pair<int,int>,int> b){
    if(a.first.second != b.first.second) return a.first.second < b.first.second;
    return a.first.first < b.first.first;
}

class UnionFind{
private:
    using uint = std::uint_fast64_t;
    std::vector<uint> par;
    std::vector<uint> sizes;
public:
    UnionFind() = delete;
    UnionFind(uint size) : par(size), sizes(size, 1){
        for(uint i = 0; i < size; ++i) par[i] = i;
    }

    uint find(uint x){
        if(x == par[x]) return x;
        return par[x] = find(par[x]);
    }

    bool unite(uint x, uint y){
        x = find(x);
        y = find(y);
        if(x == y) return false;
        
        if(sizes[x] < sizes[y]) std::swap(x, y);
        if(sizes[x] == sizes[y] && x > y) std::swap(x, y);
        sizes[x] += sizes[y];
        sizes[y] = 0;
        par[y] = x;
        return true;
    }
    bool isSame(uint x, uint y ){ return find(par[x]) == find(par[y]);}
    uint getSize(uint x){return sizes[find(par[x])];}
};

struct edge{
    int weight, from, to;

    edge(int w, int f, int t) : weight(w), from(f), to(t) {}
    bool operator <(const edge& e) const {
        return weight < e.weight;
    }
};

std::vector<edge> kruskal(int VertexNum, std::vector<edge>& Edges){
    UnionFind forest(VertexNum);
    std::vector<edge> edges;
    
    sort(Edges.begin(),Edges.end());
    for(const edge& Edge : Edges){
        if(!forest.isSame(Edge.from,Edge.to)){
            forest.unite(Edge.from,Edge.to);
            edges.push_back(Edge);
        }
    }

    return edges;
}

int main(){
    int N;
    cin >> N;
    vector<pair<pair<int,int>,int>> city(N);
    rep(i, N){
        int x, y; cin >> x >> y;
        city[i] = {{x, y}, i};
    }

    vector<edge> edges;

    sort(city.begin(), city.end());
    for(int i = 0; i < N-1; i++){
        auto a = city[i];
        auto b = city[i+1];
        int cost = min(abs(a.first.first - b.first.first), abs(a.first.second - b.first.second));
        edge e(cost, a.second, b.second);
        edges.emplace_back(e);
    }

    sort(city.begin(), city.end(), comp);
    for(int i = 0; i < N-1; i++){
        auto a = city[i];
        auto b = city[i+1];
        int cost = min(abs(a.first.first - b.first.first), abs(a.first.second - b.first.second));
        edge e(cost, a.second, b.second);
        edges.emplace_back(e);
    }

    auto tree = kruskal(N, edges);
    int ans = 0;
    for(auto& e : tree) ans += e.weight;

    cout << ans << endl;
}

Measured memory_bytes: 8688
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int N;
	while(~scanf("%d", &N)) {
		vector<int> a(N);
		for(int i = 0; i < N; ++ i)
			scanf("%d", &a[i]);
		int x = 0;
		vector<bool> v(31);
		rep(i, N) {
			x ^= a[i];
			int y = (a[i] - 1) ^ a[i];
			int k = 0;
			while(y >> k & 1) ++ k;
			v[k] = true;
		}
		int ans = 0;
		for(int k = 30; k >= 1; -- k) if(v[k] && (x >> (k - 1) & 1)) {
			x ^= (1 << k) - 1;
			++ ans;
		}
		printf("%d\n", x != 0 ? -1 : ans);
	}
	return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }

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

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

  int A, B;
  cin >> A >> B;
  
  
  int ans = 0;

  ans = (B+A-3)/(A-1);

  cout << ans << endl;


  return 0;
}



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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int d, t, s;
  cin >> d >> t >> s;
  if(t*s < d) {
    cout << "No\n";
  } else {
    cout << "Yes\n";
  }
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
    #include<cmath> 
     
    #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
    #define SUBL freopen("/home/ajinkya/Desktop/input.txt","r",stdin); freopen("/home/ajinkya/Desktop/output.txt","w",stdout); 
    #define ll long long
    #define ull unsigned long long
    #define FI(i,a,n) for(int i=a; i<=n; i++)
    #define RFI(i,n,a) for(int i=n; i>=a; i--)
    #define FLL(i,a,n) for(ll i=a; i<=n; i++)
    #define RFLL(i,n,a) for(ll i=n; i>=a; i--)
    #define vi vector<int>
    #define vll vector<ll>
    #define all(v) v.begin(),v.end()
    #define pll pair<ll,ll>
    #define pi pair<int, int>
    #define GCD(a,b) __gcd(a,b)
    #define MP make_pair
    #define PB push_back
    #define PF push_front
    #define LB lower_bound
    #define UB upper_bound
    #define debug(x) cout << x << endl
    #define MOD 1000000007
    #define INF LLONG_MAX
    #define PI 3.14159265359
    using namespace std;
     
     
    int main()
    {
        fastio 
        // SUBL
      	int n;
      	cin >> n;
      	double ans=0;
      	double a[n];
      	for(int i=0; i<n; i++) cin >> a[i];
      	sort(a,a+n);
      	// double ans = 0;
      	for(int i=1; i<n; i++) 
      	{
      		a[i] = (a[i]+a[i-1])/2;
      	}
      	cout << a[n-1];
        return 0;
    }         	

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll a,b,c,d,e;
cin>>a>>b>>c>>d>>e;
ll k;
cin>>k;
if(max({a,b,c,d,e})-min({a,b,c,d,e})<=k){
    cout<<"Yay!"<<endl;
}else{
    cout<<":("<<endl;
}
}










Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  vector<pair<ll, ll>> change(m);
  rep(i, m) {
    ll b, c;
    cin >> b >> c;
    change[i].second = b;
    change[i].first = c;
  }
  sort(a.begin(), a.end());
  sort(change.begin(), change.end());
  reverse(change.begin(), change.end());
  ll x = 0;
  rep(i, m) {
    if (x >= n) break;
    FOR(j, x, x+change[i].second) {
      if (x >= n) break;
      if (a[j] >= change[i].first) {
        x += mod;
        break;
      }
      a[j] = change[i].first;
    }
    x += change[i].second;
  }
  ll ans = 0;
  rep(i, n) ans += a[i];
  cout << ans << endl;
}

Measured memory_bytes: 2560
//                                   mdsaqib
#include <bits/stdc++.h>
#define int long long
#define all(c) (c).begin(),(c).end()
#define endl '\n'
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

signed main(){
    fast;
    string s;
    cin >> s;
    for(int i=0;i<3;i++){
        cout << s[i];
    }
}


Measured memory_bytes: 3652
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
k = int(input())
X = list(map(int, input().split()))
for i in range(n):
    if X[i]*2 < abs(k-X[i])*2:
        ans += X[i]*2
    else:
        ans += abs(k-X[i])*2
print(ans)

Measured memory_bytes: 9308
#include<iostream>
#include<vector>

using namespace std;

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

int main() {
  int n;
  while (true) {
    cin >> n;
    if (n == 0) break;
    vector<pair<pair<int, int>, int> > files;
    rep (iii, n) {
      string str;
      cin >> str;
      if (str == "W") {
	vector<pair<pair<int, int>, int> > next;
	int num, sz, pre = -1;
	cin >> num >> sz;
	rep (i, files.size()) {
	  if (pre + 1 != files[i].first.first && sz > 0) {
	    int fsz = min(sz, files[i].first.first - pre - 1);
	    next.push_back(make_pair(make_pair(pre + 1, pre + fsz), num));
	    sz -= fsz;
	  }
	  next.push_back(files[i]);
	  pre = files[i].first.second;
	}
	if (sz > 0) {
	  next.push_back(make_pair(make_pair(pre + 1, pre + sz), num));
	}
	files = next;
      } else if (str == "D") {
	vector<pair<pair<int, int>, int> > next;
	int num;
	cin >> num;
	rep (i, files.size()) {
	  if (num == files[i].second) continue;
	  next.push_back(files[i]);
	}
	files = next;
      } else if (str == "R") {
	int pos;
	cin >> pos;
	int res = -1;
	rep (i, files.size()) {
	  if (files[i].first.first <= pos && pos <= files[i].first.second) {
	    res = files[i].second;
	  }
	}
	cout << res << endl;
      }
    }
    cout << endl;
  }
  return 0;
}

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

int main()
{
  int n, tmp = 0, sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    int pr;
    cin >> pr;
    sum += pr;
    if (pr>tmp) tmp = pr;
  }
  sum-=(tmp/2);
  cout << sum << "\n";
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

class Main {

	@SuppressWarnings("unused")
	public static void main(String[] args) {
		FastScanner in = new FastScanner();
//		int T = in.nextInt();
//		outer: for (int tt = 0; tt < T; tt++) {
//		}
		int n = in.nextInt();
		int a[] = in.readArray(n);
		int dp[] = new int[n + 1];
		Arrays.fill(dp, -1);
		System.out.println(frog1(dp, a, n - 1));
	}

	public static int frog1(int dp[], int a[], int N) {
		if (N == 0)
			return 0;

		if (dp[N] != -1)
			return dp[N];
		int ans = 0, ans1 = Integer.MAX_VALUE, ans2 = Integer.MAX_VALUE;
		if (N - 1 >= 0) {
			ans1 = (Math.abs(a[N] - a[N - 1]) + frog1(dp, a, N - 1));
		}
		if (N - 2 >= 0) {
			ans2 = (Math.abs(a[N] - a[N - 2]) + frog1(dp, a, N - 2));
		}
		ans = Math.min(ans1, ans2);
		dp[N] = ans;
		return ans;

	}

	static void sort(int[] a) {
		ArrayList<Integer> l = new ArrayList<>();
		for (int i : a)
			l.add(i);
		Collections.sort(l);
		for (int i = 0; i < a.length; i++)
			a[i] = l.get(i);
	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}

Measured memory_bytes: 55596
/*
    if you can't see the repay
    Why not just work step by step
    rubbish is relaxed
    to ljq
*/
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
using namespace std;

#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define lc (rt<<1)
#define rc (rt<<11)
#define mid ((l+r)>>1)
#define MOD 1000000007

typedef pair<int,int> pll;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int _inf = 0xc0c0c0c0;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll _INF = 0xc0c0c0c0c0c0c0c0;
const ll mod =  (int)1e9+7;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}
void exgcd(ll a,ll b,ll &x,ll &y,ll &d){if(!b) {d = a;x = 1;y=0;}else{exgcd(b,a%b,y,x,d);y-=x*(a/b);}}//printf("%lld*a + %lld*b = %lld\n", x, y, d);
const int MAX_N = 100025;
int eid,p[MAX_N];
ll dp[MAX_N][2];
struct edge
{
    int v,next;
}e[MAX_N<<2];
void init()
{
    memset(p,-1,sizeof(p));
    eid = 0;
}
void add(int u,int v)
{
    e[eid].v = v;
    e[eid].next =p[u];
    p[u] = eid++;
}
void dfs(int u,int fa)
{
    ll x = 1, y = 1;
    if(e[p[u]].next==-1&&e[p[u]].v == fa)
    {
        dp[u][0] = dp[u][1] = 1;
        return ;
    }
    for(int i = p[u];i+1;i=e[i].next)
    {
        int v = e[i].v;
        if(v==fa) continue;
        dfs(v,u);
        x = (x*((dp[v][0] + dp[v][1])%MOD))%MOD;
        y = (y*(dp[v][0]))%MOD;
    }
    dp[u][0] = x,dp[u][1] = y;
}
int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    int n,a,b;
    init();
    scanf("%d",&n);
    for(int i = 1;i<n;++i)
    {
        scanf("%d%d",&a,&b);
        add(a,b);
        add(b,a);
    }
    dfs(1,0);
    printf("%d\n",(dp[1][0]+dp[1][1])%MOD);
    //fclose(stdin);
    //fclose(stdout);
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


Measured memory_bytes: 11776
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define len(s) s.length()
#define forp(i,a,b) for( i=a;i<=b;i++)
#define rep(i,n)    for( i=0;i<n;i++)
#define ren(i,n)    for( i=n-1;i>=0;i--)
#define forn(i,a,b) for( i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define b(v) v.begin()
#define e(v) v.end()
#define mem(n,m) memset(n,m,sizeof(n))
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define pll pair<long long,long long>
#define vii vector<int>
#define vll vector<long long>
#define gl(cin,s)  getline(cin,s);
#define bitc(n) __builtin_popcountll(n)
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define boost ios_base::sync_with_stdio(0)
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define SIZE 100010
#define SZ 100010

typedef long long  ll;
typedef unsigned long long ull;
typedef long double  ldo;
typedef double  db ;
using namespace std;
int D;
string S;
int dp[10010][2][110];
int func(int which,bool is,int rem)
{
    if(which == S.length()){
        if(rem)
            return 0;
        return 1;
    }
    if(dp[which][is][rem] != -1)
        return dp[which][is][rem];
    int fans = 0;
    if(is){
        for(int i=0;i<10;i++){
            fans = (fans + func(which+1,is,(rem+i)%D))%MOD;
        }
    }
    else{
        for(int i=0;i<=S[which]-'0';i++){
            if(i == S[which]-'0'){
                fans = (fans + func(which+1,false,(rem+i)%D))%MOD;
            }
            else{
                fans = (fans + func(which+1,true,(rem+i)%D))%MOD;
            }
        }
    }
    dp[which][is][rem] = fans;
    return fans;
}
int main()
{
    /* #ifndef ONLINE_JUDGE
    freopen(fi, "r", stdin);
    #endif */
    //freopen("route.in","r",stdin);
    //freopen("route.out","w",stdout);
    //cin.ignore();
    //cin.clear();
    boost;
    //cin.tie(0);
    //cout<<"Case "<<tt<<": ";
    cin>>S>>D;
    mem(dp,-1);
    int total = func(0,false,0) - 1;
    if(total < 0)
        total+=MOD;
    cout<<total<<endl;
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
//aa
//aba
int main(){
  string S; cin>>S;
  ll ssz=S.size();
  for(int i=0; i<ssz-1; i++){
    if(S[i]==S[i+1]){
      cout<<i+1<<" "<<i+2<<endl;
      return 0;
    }
    else if(i<ssz-2 && S[i]==S[i+2]){
      cout<<i+1<<" "<<i+3<<endl;
      return 0;
    }
  }
  cout<<"-1 -1"<<endl;
}

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

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

int main(){
	string a;
	cin>>a;
	int b = 0;
	rep(i, a.size()){
		if(b == 0){
			if((i + 1) % 2 == 0){
				if(a[i] == 'R'){
					b = 1;
				}
			}
			else{
				if(a[i] == 'L'){
					b = 1;
				}
			}
		}
	}
	if(b == 0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

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

int main()
{
    int n;
    vector<string> s;
    s = {"p","p","h","b","h","h","p","h","p","h"};
    cin >> n;
    int x = n%10;
    cout << s[x] << "on" << endl;
}

Measured memory_bytes: 3600
#![allow(unused_imports)]

use itertools::Itertools as _;
use proconio::input;

fn main() {
    input! {
        n: usize
    }

    let sum: usize = (1..=n).filter(|&x| x % 3 != 0 && x % 5 != 0).sum();
    println!("{}", sum);
}


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

int main(){
  string s,ans;
  cin>>s;
  for( int i=0;i<s.size();i++){
    switch(s[i]){
      case '0': ans.push_back(s[i]);break;
      case '1': ans.push_back(s[i]);break;
      case 'B': if(ans.size()>0)ans.pop_back();break;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

	    int n=gi();
	    int a=gi();
	    int b=gi();
	    //String y=gs();

        System.out.println(Math.min(n*a, b));
//        if (()==n.charAt(3))) {
//        	System.out.print("Yes");
//        }else {
//        	System.out.print("No");
//        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
	
	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35476
N = int(input())
R = []

for _ in range(N):
    x, l = map(int, input().split())
    s = x - l
    t = x + l
    R.append((s, t))
    
R.sort(key=lambda r:r[1])

cnt = 1
t0 = R[0][1]

for s, t in R[1:]:
    if t0 <= s:
        cnt += 1
        t0 = t

print(cnt)
        


Measured memory_bytes: 18260
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; ll T;
  cin >> N >> T;
  vector<ll> A(N);
  multiset<ll, greater<ll>> se;
  rep(i, N) {
    cin >> A[i];
    se.insert(A[i]);
  }
  map<ll, int> mp;
  rep(i, N) {
    se.erase(se.find(A[i]));
    mp[*se.begin()-A[i]]++;
  }
  cout << mp.rbegin()->second << "\n";
  return 0;
}


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

const int inf = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3fLL;

template <ll mod>
class modint
{
public:
    constexpr modint(ll value = 0) : _value(value >= 0 ? value % mod : (value % mod) + mod) {}
 
    constexpr modint operator+() const { return *this; }
    constexpr modint operator-() const { return modint(-_value); }
 
    constexpr modint &operator+=(const modint &rhs) {
        if ((_value += rhs._value) >= mod) _value -= mod;
        return *this;
    }
    constexpr modint &operator-=(const modint &rhs) {
        if ((_value += mod - rhs._value) >= mod) _value -= mod;
        return *this;
    }
    constexpr modint &operator*=(const modint &rhs) {
        (_value *= rhs._value) %= mod;
        return *this;
    }
    constexpr modint &operator/=(const modint &rhs) {
        *this *= rhs.inv();
        return *this;
    }
    constexpr modint operator+(const modint &rhs) const { return modint(*this) += rhs; }
    constexpr modint operator-(const modint &rhs) const { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint &rhs) const { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint &rhs) const { return modint(*this) /= rhs; }
 
    constexpr modint operator++() { *this += 1; return *this; }
    constexpr modint operator--() { *this -= 1; return *this; }
    constexpr modint operator++(int) { modint tmp = *this; ++*this; return tmp; }
    constexpr modint operator--(int) { modint tmp = *this; --*this; return tmp; }
 
    constexpr bool operator==(const modint &rhs) const { return _value == rhs._value; }
    constexpr bool operator!=(const modint &rhs) const { return _value != rhs._value; }
 
    constexpr modint inv() const {
        ll a = _value, b = mod, u = 1LL, v = 0LL;
        while (b > 0) {
            ll tmp = a / b;
            a -= tmp * b; swap(a, b);
            u -= tmp * v; swap(u, v);
        }
        return modint(u);
    }
 
    constexpr modint pow(ll n) const {
        modint e = *this, res = 1;
        while (n) {
            if (n & 1) res *= e;
            e *= e, n >>= 1;
        }
        return res;
    }
 
    friend ostream &operator<<(ostream &os, const modint &m) {
        os << m._value;
        return os;
    }
 
    friend istream &operator>>(istream &is, modint &m) {
        ll in;
        is >> in;
        m = modint(in);
        return is;
    }
 
private:
    ll _value;
};
using mint = modint<998244353>;

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

    int n, s; cin >> n >> s;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    vector<mint> dp(s + 1);
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = s; j >= 0; j--) {
            dp[j] *= 2;
            if (j >= a[i]) dp[j] += dp[j - a[i]];
        }
    }
    cout << dp[s] << endl;
    return 0;
}

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    static int64_t a[100000];
    for(int i=0;i<n;++i) cin >> a[i];
    int64_t ans = a[0] - 1, m = 1;
    for(int i=1;i<n;++i){
        if(a[i] > m+1) ans += (a[i]-1) / (m+1);
        else if(a[i] == m+1) ++m;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
 int main()
{
    long long n,m,i,sum=0,p=0,c=0;
    cin>>n>>m;
    long long A[n];
    for(i=1;i<=n;i++)
    {
        cin>>A[i];
        sum+=A[i];
    }
   for(i=1;i<=n;i++)
   {
       p=4*m*A[i];
       if(p>=sum) c++;
   }
   cout<<(c>=m ? "Yes" : "No")<<endl;

 }


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

    int S;

    public void input(){
	Scanner scan = new Scanner(System.in);
	S = scan.nextInt();
        
    }
 


    public void output(){
        System.out.println(S/3600+":"+(S%3600)/60+":"+(S%3600)%60);
    }
 public static void main(String[] args){
     Main p = new Main();
     p.input();
     p.output();
 }
}
  

Measured memory_bytes: 26328
N = int(input())
list_weight = [int(i) for i in input().split()]

list_div = list()
for i in range(N-1):
 s1 = sum(list_weight[:i+1])
 s2 = sum(list_weight[i+1:])
 list_div.append(abs(s2-s1))

print(min(list_div))


Measured memory_bytes: 2940
*d=0;eval"N,_,*A="+`dd`.split*?,;p d[N.times{|i|d[i]&&A.map{|x|d[t=i+[0,2,5,5,4,5,6,3,7,6][x]]=[d[t]||0,d[i]*10+x].max}}]

Measured memory_bytes: 27904
#include <stdio.h>
int main() {
	char a[3][11];
	int n[3];
	scanf("%s%s%s", a[0], a[1], a[2]);

	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; a[i][j] != '\0'; j++)
		{
			n[i] = j;
		}
	}

	if (a[0][n[0]] == a[1][0] && a[1][n[1]] == a[2][0])
	{
		printf("YES");
	}
	else
	{
		printf("NO");
	}
	return 0;
}

Measured memory_bytes: 128
N,M=map(int,input().split())
mi=0
ma=100001
for i in range(M):
  L,R=map(int,input().split())
  if L>mi:
    mi = L
  if R<ma:
    ma = R
if mi > ma:
  print(0)
else:
  print(ma-mi+1)



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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

int n;
int h,w;

void input(){
	cin>>n>>h>>w;
	return;
}

void solve(){
	cout<<(n-h+1)*(n-w+1)<<endl;
	return;
}

int main(){
	input();
	solve();
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

def bfs(i, edges, r):
    if all(r):
        return True
    if r[i]:
        return False
    r[i] = True
    if any([bfs(e, edges, r) for e in edges[i]]):
        return True
    return False

ans = 0
for i in range(m):
    edges = [[] for _ in range(n)]
    for j in range(m):
        if i != j:
            edges[ab[j][0]-1].append(ab[j][1]-1)
            edges[ab[j][1]-1].append(ab[j][0]-1)
    reached = [False for _ in range(n)]
    if not bfs(0, edges, reached):
        ans += 1
print(ans)

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    string s; cin>>s;
    int l = s.size();
    cout<<s[0]<<l-2<<s[l-1]<<endl;
}

Measured memory_bytes: 3520
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <sstream>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;

int n;

class Produce
{
public:
  string name;
  double efficiency;
  Produce(string name,double numerator,double denominator)
  {
    this->name=name;
    efficiency=numerator/denominator;
  }
  bool operator < (const Produce& another) const
  {
    if(efficiency == another.efficiency)
      {
	return name < another.name;
      }
    return (efficiency > another.efficiency);
  }
};

int main(int argc,char const* argv[])
{
  while(1)
    {
      int n;
      cin >> n;
      if(!n)break;
      vector<Produce> Pro;
      for(int i=0;i<n;i++)
	{
	  string l;
	  double p,a,b,c,d,e,f,s,m;
	  cin >> l >> p >> a >> b >> c >>d >>  e >> f >> s >> m;
	  Pro.push_back(Produce(l,(f*s*m-p),(a+b+c+(d+e)*m)));
	}

      sort(Pro.begin(),Pro.end());
      for(int i=0;i<n;i++)
	{
	  cout << Pro[i].name << endl;
	}
      cout << '#' << endl;
    }
  return 0;
}



Measured memory_bytes: 3160
N = int(input())
H = [int(i) for i in input().split()]

ans = 0
count= 0
for i in range(1, N):
    if H[i] <= H[i-1]:
        count += 1
    else:
        ans = max(ans, count)
        count = 0

ans = max(ans, count)
print(ans)

Measured memory_bytes: 14252
import java.util.*;

public class Main {
	String now;
	String[] ptn = {
			"0111111" , "0000110" , "1011011" , "1001111" , "1100110",
			"1101101" , "1111101" , "0100111" , "1111111" , "1101111"};
	public String makeDisplay( String n , int to ) {
		String result = "";
		for ( int i = 0; i < 7; i++ ) {
			if ( n.charAt(i) == ptn[to].charAt(i) ) result += "0";
			else result += "1";
		}
		return result;
	}
	public static void main ( String[] args ) {
		Main m = new Main();
		Scanner sc = new Scanner(System.in);
		while ( !sc.hasNext("-1") ) {
			m.now = "0000000";
			int n = sc.nextInt();
			for ( int i = 0; i < n; i++ ) {
				int num = sc.nextInt();
				System.out.println(m.makeDisplay(m.now, num));
				m.now = m.ptn[num];
			}
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>s;
    rep(i,n-1){
        if(s[i]!=s[i+1])ans++;
    }
    Cout(ans+1);
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long long A,B,C,X,Y,count;
    cin>>A>>B>>C;
    count=0;
    if(A==B&&B==C){
        if(A%2==0){
            cout<<-1<<endl;
            return 0;
        }
        if(A%2==1){
            cout<<count<<endl;
            return 0;
        }
    }
    else{
        while(A%2==0&&B%2==0&&C%2==0){
            X=A;
            Y=B;
            A=Y/2+C/2;
            B=C/2+X/2;
            C=X/2+Y/2;
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>

int main(){
    int a, b, angle;
    double s, l, h;

    scanf("%d %d %d", &a, &b, &angle);
    
    h=b*sin(angle*M_PI/180.0);
    s=a*h/2;
    l=a+b+sqrt((a*a+b*b-2*a*b*cos(angle*M_PI/180.0)));
    printf("%f\n", s);
    printf("%f\n", l);
    printf("%f\n", h);

    return 0;
}


Measured memory_bytes: 2124
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

    int N, K, Q;
    cin >> N >> K >> Q;
    map<int, int> ma;
    vector<int> p(N, K);
    rep(i, Q) {
        int a;
        cin >> a;
        a--;
        p[a]++;
    }

    rep(i, N) { p[i] -= Q; }

    rep(i, N) {
        if (p[i] <= 0)
            cout << "No" << endl;
        else
            cout << "Yes" << endl;
    }
}

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

typedef long int lint;
typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define mod 1000000007
#define INF 100000000
#define fk first
#define sv second

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

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n[4];
  REP(i, 4) cin >> n[i];
  cout << max(n[0] * n[1], n[2] * n[3]) << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

bool ch[101],ans[3][3];

int main() {
	ll a[3][3];
	for(ll i=0;i<3;i++){
		for(ll j=0;j<3;j++){
			cin>>a[i][j];
		}
	}
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		ch[x]=true;
	}
	for(ll i=0;i<3;i++){
		for(ll j=0;j<3;j++){
			if(ch[a[i][j]]){
				ans[i][j]=true;
			}
		}
	}
	bool fin=false;
	for(ll i=0;i<3;i++){
		bool OK=true;
		for(ll j=0;j<3;j++){
			if(ans[i][j]!=true){
				OK=false;
				continue;
			}
		}
		if(OK){
		fin=true;
		}
	}
	for(ll i=0;i<3;i++){
		bool OK=true;
		for(ll j=0;j<3;j++){
			if(ans[j][i]!=true){
				OK=false;
				continue;
			}
		}
		if(OK){
		fin=true;
		}
	}
	if(ans[0][0]&&ans[1][1]&&ans[2][2]){
		fin=true;
	}
	if(ans[0][2]&&ans[1][1]&&ans[2][0]){
		fin=true;
	}
	cout << (fin?"Yes":"No");
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int h, w;
  while(1) {
    cin >> h >> w;
    if(h == 0 && w == 0) break; 

    for(int i=0; i<h; i++) {
      for(int j=0; j<w; j++) {
        if((i+j)%2 == 0) cout << "#";
        else cout << ".";
      }
      cout << "\n";
    }
    cout << "\n";
  }
  return 0;
}



Measured memory_bytes: 3104
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n, k = MAP()
x = LIST()
idx = -1
for i in range(n - 1):
    if x[i] < 0 and x[i + 1] >= 0:
        idx = i + 1
if idx == -1 and x[-1] < 0:
    print(-x[len(x) - k])
elif idx == -1 and x[0] >= 0:
    print(x[k - 1])
elif idx != -1:
    ans = inf
    for i in range(n - k + 1):
        tmp = abs(x[i]) + x[i + k - 1] - x[i]
        ans = min(ans, tmp)
    for i in range(k - 1, n):
        tmp = abs(x[i]) + x[i] - x[i - k + 1]
        ans = min(ans, tmp)
    print(ans)

Measured memory_bytes: 16312
from collections import deque

K=int(input())
if K<=9:
  print(K)
  exit()
q=deque([i for i in range(1,10)])
for _ in range(K-1):
  x=deque.popleft(q)
  a=x%10
  if a!=0 and a!=9:
    deque.append(q,x*10+a-1)
    deque.append(q,x*10+a)
    deque.append(q,x*10+a+1)
  elif a==0:
    deque.append(q,x*10)
    deque.append(q,x*10+1)
  else:
    deque.append(q,x*10+8)
    deque.append(q,x*10+9)
print(deque.popleft(q))

Measured memory_bytes: 74768
fun main(arr: Array<String>) {
    val n = readLine()!!.toInt()
    val blueCards = (1..n).map { readLine()!! }

    val m = readLine()!!.toInt()
    val redCards = (1..m).map { readLine()!! }

    val ans = blueCards.map { w -> blueCards.count { it == w } - redCards.count{ it == w } }.max()!!
    println(Math.max(0, ans))
}

Measured memory_bytes: 36916
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define fast ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define F(i,a,b) for(int i= (int)(a); i<(int)(b);i++)
#define FI(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define what_is(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007
const int N = 1e6+7 ;
string s ;
const int INF = 1e18L + 5 ;

int main(){fast ;
	int n ;
	cin >> n ;
	vector<ll> a(n) ;
	
	ll sm = 0 , sub = INF ;
	int neg = 0 ;
	for(ll& i : a){
		cin >> i ;
		if(i < 0) neg++ ;
		ll k = abs(i) ;
		sm += k ;
		sub = sub < k ? sub : k ;
	}
	if(neg & 1)
		cout << sm - (2*sub) << endl ;
	else
		cout << sm << endl ;		
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"

	"sort"
	"strconv"
)

func solve(in io.Reader, out io.Writer) error {
	sc := bufio.NewScanner(in)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)

	x := make([]int, n)
	y := make([]int, n)
	for i := 0; i < n; i++ {
		x[i] = nextInt(sc)
		y[i] = x[i]
	}

	sort.Ints(y)
	c := y[n/2]

	for i := 0; i < n; i++ {
		if x[i] >= c {
			fmt.Fprintln(out, y[n/2-1])
		} else {
			fmt.Fprintln(out, y[n/2])
		}
	}

	return nil
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	err := solve(os.Stdin, os.Stdout)
	if err != nil {
		log.Fatal(err)
	}
}


Measured memory_bytes: 9216
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        mut p: [usize; 3]
    }
    p.sort();
    println!("{}", p[0] + p[1]);
}


Measured memory_bytes: 4352
/*
ID: thanhvq1
LANG: C++14
PROB: namenum
*/

#pragma GCC optimize ("O2")
#include<bits/stdc++.h>
#include<unistd.h>
using namespace std;
//#define int long long
#define double long double
#define vec vector
#define vi vector<int>
#define FZ(n) memset((n),0,sizeof(n))
#define FMO(n) memset((n),-1,sizeof(n))
#define unset unordered_set
#define ii pair<int, int>
#define vii vector<ii>
#define F first
#define S second
#define PB push_back
#define ALL(x) begin(x),end(x)
#define SZ(x) ((int)(x).size())
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define bitcount(n) __builtin_popcountll(n)
template <typename T,typename U>
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {
  return {l.first+r.first, l.second+r.second};
} 
typedef void (*callback_function)(void); // type for conciseness
const long long ZERO = 0LL;
const long long INF64 = 1e18;
const int INF32 = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0L);
const double EPS = static_cast<double>(1e-9);
typedef long long ll;

void FILEIO() {  freopen("in.txt", "r", stdin);  freopen("out.txt", "w", stdout); }
//void FILEIO() {  freopen("namenum.in", "r", stdin);  freopen("namenum.out", "w", stdout); }

int n, a, b, c, d;
string s;

bool check(int a, int b) { // di duoc tu a den b, khong tinh co nguoi o giua
	FOR(i, a, b) {
		char c1 = s[i], c2 = s[i+1];
		if(c1=='#' and c2=='#') return false;
	}
	return true;
}

void solve() {
	cin >> n >> a >> b >> c >> d; a--, b--, c--, d--;
	cin >> s;
	if(!check(a, c) or !check(b, d)) {cout << "No" << endl; return;}
	// now we can go from a to c, from b to d
	if(c<d) {cout << "Yes" << endl; return;} // lets b goes to d fisrt
	// now d < c
	FOR(i, b-1, d) {
		if(s[i]=='.' and s[i+1]=='.' and s[i+2]=='.') {
			cout << "Yes" << endl; return;
		}
	}
	cout << "No" << endl;
}

//#undef int
signed main() {
//#define int long long
  ios_base::sync_with_stdio(false); cin.tie();
//  FILEIO();
//auto beginProgram = chrono::steady_clock::now();

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

  //auto endProgram = chrono::steady_clock::now();

  return 0;
}


Measured memory_bytes: 592