akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
#ABC138 A

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a = I()
s = input()
if a >= 3200:
    print(s)
else:
    print('red')


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);
int main() {
int n,m;
cin >> n >> m;
vector<vector<int>> x(n,vector<int>(2));
rep(i,n)rep(j,2)cin >> x.at(i).at(j);

sort(x.begin(),x.end());
ll cnt = 0;
ll ans = 0;
rep(i,n){
  for(ll j = 1; j <= x.at(i).at(1); j++){
    
    ans += x.at(i).at(0);
    cnt++;
    if(cnt == m){
      cout << ans << endl;
      return 0;
    }
  }
}
} 

Measured memory_bytes: 8712
//list index out of range エラー表示用
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep1(i, n) for (int i = 0; i < (int)(n); i++)


int main(){
  int N;
  int p;
  cin >> N;
  vector<int> P(N);
  rep1(i, N){
    cin >> p;
    P[i] = p;
  }
  
  int max_a = *max_element(P.begin(),P.end());
  vector<bool> Era(max_a + 1);
  rep1(i, max_a + 1){
    Era[i] = true;
  }

  sort(P.begin(), P.end());
  rep1(i, N-1){
    if(P[i] == P[i+1]){
      Era[P[i]] = false;
    }
  }

  int tem;
  rep1(i, N){
    tem = P[i];
    int c = max_a / tem;
    rep1(i, c-1){
      Era[tem * (i+2)] = false;
    }
    
  }

  int ans = 0;
  rep1(i, N){
    if(Era[P[i]] == true){
      ans += 1;
    }
  }
  
  cout << ans;
  
}



Measured memory_bytes: 4320
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vecll var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl
#define prseq(var, n)    rep(i,n){cout << var[i] << " ";} cout << endl
#define prseql(var, n)   rep(i,n){cout << var[i] << " " << endl;}

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

int main(void) {
  int n;
  cin >> n;
  arr(a,n);
  vec b(n);
  rep(i,n){
    b[i] = a[i];
  }

  sortall(a);

  rep(i,n){
    if(b[i]==a[n-1]){
      prt(a[n-2]);
    } else {
      prt(a[n-1]);
    }
  }

}


Measured memory_bytes: 3968
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rf = lambda: map(float, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

s = rr()
a = re.search(r'C.*F', s)
if a:
    print('Yes')
else:
    print('No')














Measured memory_bytes: 27220
package main

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

const (
	maxBufSize = 1024 * 1024
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, 1)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	out = bufio.NewWriter(os.Stdout)
)

const yes = "YES"
const no = "NO"

func solve(n int64, ds []int64, m int64, ts []int64) bool {
	dMap := make(map[int64]int64, n)
	for _, d := range ds {
		dValue, exists := dMap[d]
		if exists {
			dMap[d] = dValue + 1
		} else {
			dMap[d] = 1
		}
	}
	for _, t := range ts {
		dValue, exists := dMap[t]
		if !exists || dValue == 0 {
			return false
		}
		dMap[t] = dValue - 1
	}
	return true
}

func main() {
	defer out.Flush()

	n := nextInt()
	ds := nextInts(n)
	m := nextInt()
	ts := nextInts(m)
	if solve(n, ds, m, ts) {
		fmt.Fprintln(out, yes)
	} else {
		fmt.Fprintln(out, no)
	}
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextStringAsBytes() []byte {
	sc.Scan()
	return []byte(sc.Text())
}

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int64) []int64 {
	ret := make([]int64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}


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


void solve(long long A, long long B, long long K){
    if(K < A){
        cout << A - K << ' ' << B << endl;
    }else if(K < A + B){
        cout << 0 << ' ' << (B - (K - A)) << endl;
    }else{
        cout << 0 << ' ' << 0 << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long K;
    scanf("%lld",&K);
    solve(A, B, K);
    return 0;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	mod = 10^9+7
	n = parseMap(split(chomp(readline()),""))
	d = readline() |> parseInt
	l = length(n)
	dp = zeros(Int,2,d,l)
	for i in 0:n[1]-1
		dp[1,i%d+1,1] += 1
	end
	dp[2,n[1]%d+1,1] += 1
	for i in 1:l-1
		for j in 1:d
			for k in 0:n[i+1]-1
				dp[1,(j+k)%d+1,i+1] = (dp[1,(j+k)%d+1,i+1]+dp[1,j%d+1,i]+dp[2,j%d+1,i])%mod
			end
			dp[2,(j+n[i+1])%d+1,i+1] = (dp[2,(j+n[i+1])%d+1,i+1]+dp[2,j%d+1,i])%mod
			for k in n[i+1]:9
				dp[1,(j+k)%d+1,i+1] = (dp[1,(j+k)%d+1,i+1]+dp[1,j%d+1,i])%mod
			end
		end
	end
	ans = (dp[1,1,l]+dp[2,1,l]-1)%mod
	println(ans>=0?ans:ans+mod)
end

main()

Measured memory_bytes: 129728
import java.util.Scanner;
 
public class Main {
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int[] c = new int[N];
		int[] t = new int[N];
		int cost = 2000;
		for(int i=0;i<N;i++) {
			c[i] = sc.nextInt();
			t[i] = sc.nextInt();
			if(t[i]<=T) {
				cost = Math.min(cost, c[i]);
			}
		}
		if(cost==2000) {
			System.out.println("TLE");
		}else {
			System.out.println(cost);
		}
		
	}
}

Measured memory_bytes: 27376
using System;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        int H = 0;
        int W = 0;
        List<int> Hnum = new List<int>();
        List<int> Wnum = new List<int>();

        while (true)
        {
            HandW(ref H, ref W);

            if (H == 0 && W == 0)
                break;

            Hnum.Add(H);
            Wnum.Add(W);
        }


        for (int i = 0; i <= Wnum.Count-1; i++)

        {
            for (int i1 = 0; i1 <= Hnum[i]-1; i1++)
            {
                if (i1 % 2 == 0)
                {
                    for (int i2 = 0; i2 <= Wnum[i]-1; i2++)
                    {
                        if (i2 % 2 == 0)
                            Console.Write("#");
                        else
                            Console.Write(".");
                    }
                }
                else
                {
                    for (int i2 = 0; i2 <= Wnum[i]-1; i2++)
                    {
                        if (i2 % 2 == 0)
                            Console.Write(".");
                        else
                            Console.Write("#");
                    }
                }

                Console.WriteLine();
            }

            Console.WriteLine();
        }


    }

    static void HandW(ref int x,ref int y)
    {
      
        string[] str = Console.ReadLine().Split(' ');
        x = int.Parse(str[0]);
        y = int.Parse(str[1]);
  
    }

   
}

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

using namespace std;

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

int main(int argc, char const *argv[]) {
  // 変数の宣言と入力
  int N, M; std::cin >> N >> M;
  std::vector<pair<long,long>> ab(N);
  for (size_t i = 0; i < N; i++) {
    int a,b;
    std::cin >> a >> b;
    ab[i] = make_pair(a, b);
  }
  sort(ab.begin(), ab.end(), compare_by_b);
  long long counter = 0;
  long long res = 0;
  for (int i = 0; i < N; i++) {
    long long cost = ab[i].first;
    long long num = ab[i].second;
    if (M - num <= 0) {
      res += M*cost;
      break;
    }
    else M -= num; res += num*cost;
  }
  std::cout << res << '\n';
  return 0;
}


Measured memory_bytes: 1792
n,k = gets.chomp.split.map(&:to_i)
xs = gets.chomp.split.map(&:to_i)
ans = xs.inject{|sum,x| sum + x.abs}
(0..n-k).each do |i|
    u = xs[i]
    v = xs[i + k - 1]
    if (u < 0 && v < 0) || (u > 0 && v > 0)
        ans = [ans , [u.abs , v.abs].max ].min
    else
        ans = [ans , 2 * u.abs + v.abs , u.abs + 2 * v.abs].min
    end
end

puts ans



Measured memory_bytes: 12044
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define rep3(i, n) for(int i = n-1; i >= 0; i--)
#define rep4(i, x, n) for(int i = x; i > n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e15;

int main(){
    int N;
    string S;
    cin >> N >> S;
    if(N%2 != 0) cout << "No" << endl;
    else{
        int n = N/2;
        bool able = true;
        rep(i, n){
            if(S[i] != S[n+i]) able = false;
        }
        if(able) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

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

int main(){
    int n, x;
    cin >> n >> x;
    if(x == 1 || x == 2*n-1)cout << "No" << endl;
    else{
        cout << "Yes" << endl;
        deque<int> deq;
        deq.push_back(x);
        int m = x;
        for(int i=1;i<n;++i){
            m--;
            if(m <= 0)m += (2*n-1);
            deq.push_front(m);
        }
        m = x;
        for(int i=1;i<n;++i){
            m++;
            if(m > 2*n-1)m -= (2*n-1);
            deq.push_back(m);
        }
        while(!deq.empty()){
            cout << deq.front() << endl;
            deq.pop_front();
        }
    }

    return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef unsigned long long ull;
int b=1e9+7,n,a,c;
ull ans;
map<ull,ull>m;
vector<int>v[100009];
ull dfs(int x){
  ull res=1;
  r(i,v[x].size()) res+=dfs(v[x][i]);
  res*=b;
  ans+=m[res]++;
  return res;
}
signed main(){
  cin>>n;
  r(i,n-1){
    cin>>a>>c;
    v[a].push_back(c);
  }
  dfs(1);
  cout<<ans<<endl;
}


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

#define INF 987654321
#define ll long long

int N, X, Y;
vector<int> g[2020];
int res[2020];

void BFS(int S)
{
	vector<int> dist(2020, -1);
	queue<int> q;
	q.push(S); dist[S] = 0;
	while(!q.empty())
	{
		int n = q.front(); q.pop();

		for(auto next : g[n])
		{
			if (dist[next] != -1) continue;
			q.push(next);
			dist[next] = dist[n] + 1;
		}
	}
	for(int i=1; i<=N; i++)
		if (i != S)
			res[dist[i]]++;
}

int main()
{
	scanf("%d %d %d", &N, &X, &Y);
	for(int i=2; i<=N; i++)
	{
		g[i-1].push_back(i);
		g[i].push_back(i-1);
	}
	g[X].push_back(Y); g[Y].push_back(X);
	for(int i=1; i<=N; i++)
		BFS(i);
	for(int i=1; i<=N-1; i++)
		printf("%d\n", res[i]/2);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#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;
const ld eps = 1e-10;

#define MAX_N 200005

class UnionFind
{
public:
  int par[MAX_N];
  int depth[MAX_N];
  int nGroup[MAX_N];

  UnionFind(int n) {
    init(n);
  }

  void init(int n) {
    for(int i=0; i<n; i++) {
      par[i] = i;
      depth[i] = 0;
      nGroup[i] = 1;
    }
  }

  int root(int x) {
    if(par[x] == x) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }

  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return;

    if(depth[x] < depth[y]) {
      par[x] = y;
      nGroup[y] += nGroup[x];
      nGroup[x] = 0;
    } else {
      par[y] = x;
      nGroup[x] += nGroup[y];
      nGroup[y] = 0;
      if(depth[x] == depth[y])
        depth[x]++;
    }
  }
};
vector<vector<ll>> dist;
void warshall_floyd(int n) {
  rep(i, n) rep(j, n) rep(k, n) {
    dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<string> S(n);
  rep(i, n) cin >> S[i];
  UnionFind uf(2*n);
  dist = vector<vector<ll>>(n, vector<ll>(n, longinf));
  rep(i, n) dist[i][i] = 0;
  rep(i, n) REP(j, i+1, n) {
    if(S[i][j] == '1') {
      dist[i][j] = dist[j][i] = 1;
      uf.unite(i, j+n);
      uf.unite(i+n, j);
    }
  }
  bool ok = true;
  rep(i, n) if(uf.same(i, i+n)) ok = false;
  if(!ok) {
    cout << -1 << "\n";
  } else {
    warshall_floyd(n);
    ll mx = 0;
    rep(i, n) mx = max(*max_element(all(dist[i])), mx);
    cout << mx+1 << "\n";
  }
  return 0;
}


Measured memory_bytes: 3880
n,ans,i = int(input()),0,1
while ans<n:
    ans+=i
    i+=1
#print("{},{}".format(ans,i))
if ans==n:
    for j in range(i-1):
        print(j+1)
else:
    i-=1
    while i>=1:
        if n==0:
            break
        if n>=i:
            print(i)
            n-=i
        i-=1

Measured memory_bytes: 3316
using System;
using System.Collections.Generic;

class UNKO
{
    static void Main()
    {
        string str = Console.ReadLine();
        int x = int.Parse(Console.ReadLine());

        List<string> strs = new List<string>(); //??????????????????????\´???????´???????????????????

        for (int i=0;i < x;i++)
        {
            string[] order = Console.ReadLine().Split(' ');
            int X = int.Parse(order[1]);
            int Y = int.Parse(order[2]);
            
            if(order[0] == "print")
            {
                 string Print = print(X,Y,str);   
                strs.Add(Print);
            }

            if(order[0] == "replace")
            {
                str = replace(X, Y, str, order[3]);
              
            }

            if(order[0] == "reverse")
            {
                str = reverse(X, Y, str);
           
            }
        }

        for (int i=0;i<strs.Count;i++)
        {
            Console.WriteLine("{0}", strs[i]);               
        }
    }


    static string print(int x,int y,string str)  //x???1???????????°???,y???2???????????°???
    {
        string print = str.Substring(x,(y-x)+1);
        return print;
    }

    static string reverse(int x,int y,string str)
    {

        string take = str.Substring(x,(y-x)+1);
        char[] chaan = take.ToCharArray();

        int clength = chaan.GetLength(0);

        char[] revchan = new char[clength];

        for(int i=0;i < clength;i++)
        {
            revchan[i] = chaan[(clength - 1) - i];
        }

        string revstr = new String(revchan);

        string reverse;

        if (y == str.Length)
        {
            if (x == 0)
                reverse = revstr;
            else
                reverse = str.Substring(0, x) + revstr;
        }
        else
        {
            if (x == 0)
                reverse = revstr + str.Substring(y + 1);
            else
                reverse = str.Substring(0,x) + revstr + str.Substring(y + 1);
        }
      

        return reverse;
    }

    static string replace(int x,int y,string str,string change)
    {

        string replace;

        if (y == str.Length)
        {
            if (x == 0)
                replace = change;
            else
                replace = str.Substring(0, x) + change;
        }
        else
        {
            if (x == 0)
                replace = change + str.Substring(y + 1);
            else
            replace = str.Substring(0, x) + change + str.Substring(y + 1);
        }

        return replace;
    }
}

Measured memory_bytes: 9144
#include <stdio.h>

int main(void)
{
	int H, W;
	
	while(true){
	
		scanf("%d %d",&H, &W);
		
		if(H == 0 && W == 0){
			break;
		}
				
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				printf("#");
			}
			printf("\n");
			
		}
		printf("\n");
	}
	
	return 0;
}

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

int D[10005];

int main(){
    int n,avg,x,ans;
    while(1){
        avg=ans=0;
        cin>>n;
        if(!n) break;
        for(int i=0;i<n;i++){
            cin>>x;
            D[i]=x;
            avg+=x;
        }
        avg/=n;
        for(int i=0;i<n;i++) if(D[i]<=avg) ans++;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
long long H,W,k;
char a[100][100];
int main()
{
	cin>>H>>W;
	for(int i=0;i<H;i++)
	{
		for(int j=0;j<W;j++)
		{
			cin>>a[i][j];
		}
	}
	for(int i=0;i<H;i++)
	{
		for(int j=0;j<W;j++)
		{
			if(a[i][j]=='.')
			{
				if(a[i][j+1]=='#')k++;
				if(a[i][j-1]=='#')k++;
				if(a[i-1][j]=='#')k++;
				if(a[i-1][j+1]=='#')k++;
				if(a[i-1][j-1]=='#')k++;
				if(a[i+1][j]=='#')k++;
				if(a[i+1][j-1]=='#')k++;
				if(a[i+1][j+1]=='#')k++;
				cout<<k;k=0;
			}
			else{
				cout<<'#';
			}
		}
		cout<<endl;
		
	}
    return 0;
}

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

int main() {
	int n, k;
	cin >> n >> k;
	int a[n];
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int count = 0;
	// if(n <= k) count = 1;
	// else {
	// 	int add = 0;
	// 	if(n % k == 0) add = 1;
	// 	count = (int)((n - 1) / (k)) + add + 1;
	// }
	for(int i = 0; n > 0; i++) {
		if(i == 0) n -= k;
		else n -= k - 1;
		count++;
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 640
function main(input) {
  var input=input.trim().split("\n");
  var N = Number(input[0].split(" ")[0]);
  var K = Number(input[0].split(" ")[1]);
  var items = input[1].split(" ").map(v=>Number(v));
  var leftSums = [], rightSums=[];
  var leftMinus = [], rightMinus=[];
  for(var i=0;i<N;i++){
    leftSums[i] = items[i] + (leftSums[i-1]||0);
    rightSums[i] = items[N-i-1] + (rightSums[i-1]||0);
    if(!leftMinus[i-1]) leftMinus[i]=[];
    else leftMinus[i] = leftMinus[i-1].concat();
    if(items[i]<0){
      leftMinus[i].push(items[i]);
    }
    if(!rightMinus[i-1]) rightMinus[i]=[];
    else rightMinus[i] = rightMinus[i-1].concat();
    if(items[N-i-1]<0){
      rightMinus[i].push(items[N-i-1]);
    }
  }
  var ans = 0;
  for(var n=0;n<=K;n++){
    for(var i=0;i<=n&&i<=N;i++){
      for(var j=0;j<=n-i&&j<=N-i;j++){
        var leftsum = leftSums[i-1]||0;
        var rightsum = rightSums[j-1]||0;
        var minusItems = (leftMinus[i-1]||[]).concat((rightMinus[j-1]||[]));
        var sum = leftsum+rightsum;
        if(n>i+j){
          minusItems.sort((a,b)=>a-b);
          for(var k=0;k<=n-i-j&&k<=minusItems.length;k++){
            sum -= minusItems[k-1]||0;
          }
        }
        ans = Math.max(ans, sum);
      }
    }
  }
  console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 10908
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define mod 998244353
#define pl(a,b) a=(a+b)%mod;
#define N 310

string s;
ll n;
ll f[N][N][N];
void calcf(){
	rep(i,N)rep(x,N)rep(y,N)f[i][x][y]=0;
	f[0][0][0]=1;
	for(ll i=0;i<=n;i++)for(ll x=0;x<=n;x++)for(ll y=0;y<=n;y++){
		if(i+x+y>n)continue;
		if(i+1<=n){
			pl(f[i+1][x][y],f[i][x][y]);
			if(s[n-1-i]=='0')pl(f[i][x][y+1],f[i][x][y]);
			if(s[n-1-i]=='1')pl(f[i][x+1][y],f[i][x][y]);
		}
		else{
			pl(f[i][x+1][y],f[i][x][y]);
			pl(f[i][x][y+1],f[i][x][y]);
		}
	}
}

bool dp[N][N][N];
void calcdp(){
	ll ans=-1;
	rep(i,N)rep(x,N)rep(y,N)dp[i][x][y]=0;
	dp[0][0][0]=1;
	for(ll i=0;i<=n;i++)for(ll x=0;x<=n;x++)for(ll y=0;y<=n;y++){
		if(n-i+x+y>n)continue;
		if(dp[i][x][y]==0)continue;
		pl(ans,f[n-i][x][y]);
		if(x-1>=0)dp[i][x-1][y]=1;
		if(y-1>=0)dp[i][x][y-1]=1;
		if(i+1<=n){
			dp[i+1][x][y]=1;
			if(s[i]=='0'&&y-1>=0)dp[i+1][x+1][y-1]=1;
			if(s[i]=='1'&&x-1>=0)dp[i+1][x-1][y+1]=1;
		}
		if(i+2<=n){
			rep(r,2){
				bool th=0;
				rep(e,2)if(s[i+e]=='0'+r)th=1;
				if(th){
					if(r==0)dp[i+2][x+1][y]=1;
					if(r==1)dp[i+2][x][y+1]=1;
				}
			}
		}
	}
	cout<<ans<<endl;
}

int main(){
	cin>>s;
	n=s.size();
	calcf();
	calcdp();
}


Measured memory_bytes: 265444
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <ctime>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
#include <fstream>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
class Timer
{
  private:
    double time_limit;
    //unsigned long long int cycle_per_sec = 2500000000; // Topcoder
    unsigned long long int cycle_per_sec = 2777777777; // AtCoder
    unsigned long long int beginCycle;
    unsigned long long int getCycle()
    {
        unsigned int low, high;
        __asm__ volatile("rdtsc"
                         : "=a"(low), "=d"(high));
        return ((unsigned long long int)low) | ((unsigned long long int)high << 32);
    }

  public:
    Timer(double time_limit) : time_limit(time_limit)
    {
        beginCycle = getCycle();
    }

    double elapsedTime()
    {

        return (double)(getCycle() - beginCycle) / cycle_per_sec;
    }
    bool isTLE()
    {
        return elapsedTime() >= time_limit;
    }
};

Timer gtimer(2.85);

int main()
{
    int m, n;
    while (cin >> m >> n && m)
    {
        int wf[2][110][110] = {};
        rep(i, 2) rep(j, 110) rep(k, 110)
            wf[i][j][k] = j == k ? 0 : 1e9;

        for (int i = 0; i < m; i++)
        {
            int a, b, c, t;
            cin >> a >> b >> c >> t;
            --a, --b;
            wf[0][a][b] = min(wf[0][a][b], c);
            wf[1][a][b] = min(wf[1][a][b], t);
            wf[0][b][a] = min(wf[0][a][b], c);
            wf[1][b][a] = min(wf[1][a][b], t);
        }
        rep(i, 2)
        {
            rep(j, 110) rep(k, 110) rep(l, 110)
            {
                wf[i][k][l] = min(wf[i][k][j] + wf[i][j][l], wf[i][k][l]);
            }
        }
        int Q;
        cin >> Q;
        while (Q--)
        {
            int a, b, c;
            cin >> a >> b >> c;
            --a, --b;
            cout << wf[c][a][b] << endl;
        }
    }
    std::cout.flush();
    return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N; cin >> N;
    double D; cin >> D;
    int ans = 0;

    for(int i = 0; i < N; i++){
        double p; cin >> p;
        double q; cin >> q;
        double kyori = p*p+q*q;
        kyori = sqrt(kyori);
        if(kyori <= D) ans ++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3800
let n = stdin.ReadLine() |> float

let rate = 1.08

let ans =
  [ let mutable x = n / rate |> ceil
    while x < (n + 1.) / rate do
      yield x |> int
      x <- x + 1. ]
  |> (fun l ->
        match l with
        | [] -> ":("
        | x :: _ -> sprintf "%d" x)

ans |> stdout.WriteLine

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

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            if(map.containsKey(a)){
                System.out.println("NO");
                return;
            }else{
                map.put(a, a);
            }
        }

        System.out.println("YES");

    }



    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
    }
}


Measured memory_bytes: 53024
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std;
typedef pair<ll,ll> pll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
void A() {
    int n;
    cin>>n;
    int res=max(0,(n+999)/1000*1000-n);
    cout<<res<<endl;
}
void B() {
    int n;
    cin>>n;
    unordered_map<string,int>cnt;
    cnt["AC"]=0;
    cnt["WA"]=0;
    cnt["RE"]=0;
    cnt["TLE"]=0;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        cnt[s]++;
    }
    cout<<"AC x "<<cnt["AC"]<<endl;
    cout<<"WA x "<<cnt["WA"]<<endl;
    cout<<"TLE x "<<cnt["TLE"]<<endl;
    cout<<"RE x "<<cnt["RE"]<<endl;
}
void C() {
    int h,w,k;
    cin>>h>>w>>k;
    vector<vector<char>> grid(h,vector<char>(w,'.'));
    int bl=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>grid[i][j];
            if(grid[i][j]=='#') bl++;
        }
    }
    int res=0;
    for(int i=0;i<(1<<h);i++){

        for(int j=0;j<(1<<w);j++){
            int cnt=bl;
            for(int x=0;x<h;x++){
                for(int y=0;y<w;y++){
                    if(grid[x][y]=='.')  continue;
                    if(i&(1<<x) || j&(1<<y)) cnt--;
                }
            }
            if(cnt==k) res++;
        }
    }
    cout<<res<<endl;
}

void D() {

}
void E(){

}
void F()
{

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


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<vector<ll>> dp(101, vector<ll>(100005, -1)), input;
  
int main()
{
    int n, a, b, w;
    long long int ans;
    cin >> n>>w;
    input.push_back({-1,-1});
    for(int i=0;i<n;i++)
    {
        cin >> a >> b;
        input.push_back({a, b});
    }
    for (int i=0;i<=w;i++) dp[0][i]=0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=w;j++){
           if(j<input[i][0]){
               dp[i][j] = dp[i-1][j];
           } 
           else{
               dp[i][j] = max(dp[i-1][j],dp[i-1][j-input[i][0]]+input[i][1]);
           }
        }
    }
    cout << dp[n][w] << endl;
    return(0);
}

Measured memory_bytes: 80256
#include <stdio.h>

#define FEE_AM 200
#define FEE_PM 300

int main(void) 
{
	char class_name[3];
	int guest_am, guest_pm;

	while (scanf(" %s %d %d", class_name, &guest_am, &guest_pm) != EOF) {
		printf("%s %d %d\n", class_name, guest_am + guest_pm, guest_am * 200 + guest_pm * 300);
	}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  int N;
  cin >> N;

  vector<long long> A(N);
  for(int i = 0;i < N;i++)  cin >> A[i];


  long long sum = 0;
  for(int i = 1;i < N;i++) {
    if(A[i-1] > A[i]) {
      sum += A[i-1]-A[i];
      A[i] = A[i-1];
    }
  }

  cout << sum << endl;

}


Measured memory_bytes: 4836
/**
*    Username : adhoc_king
*    Name : adhoc_king
*    Institute : IIT Bombay
*/

#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
// #include <deque>
// #include <queue>
// #include <array>
// #include <ctime>
// #include <list>
// #include <map>
// #include <set>
// #include <cassert>
// #include <complex>
// #include <sstream>
// #include <forward_list>
// #include <unordered_set>
// #include <unordered_map>

using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define scani(n) scanf("%d",&n);
#define EPS 1e-9
#define FOR(i,n) for(int i=0; i<n; i++)
#define X first
#define Y second
#define arrinput for(int i=0; i<n; i++) cin>>arr[i];
#define arrsum for(int i=0; i<n; i++) sum+=arr[i];
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define forr(i,n) for(int i=n-1; i>=0; i--)
#define all(v) v.begin(), v.end()

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int MOD = 1e9+7;
const int n_ = 1e5+1000;
const long double PI = acos(-1.0);

ll gcd (ll a, ll b) {return ( a ? gcd(b%a, a) : b );}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}

bool vowel(char ch) {
    if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u') return true;
    else return false;
}

// Union-Find Disjoint Sets Library written in OOP manner, using both path compression and union by rank heuristics
class UnionFind {                                              // OOP style
private:
    vi p, rank, setSize;                       // remember: vi is vector<int>
    int numSets;
public:
    UnionFind(int N) {
        setSize.assign(N, 1); numSets = N; rank.assign(N, 0);
        p.assign(N, 0); for (int i = 0; i < N; i++) p[i] = i; }
    int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
    bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
    void unionSet(int i, int j) { 
        if (!isSameSet(i, j)) { numSets--; 
        int x = findSet(i), y = findSet(j);
        // rank is used to keep the tree short
        if (rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y]; }
        else                   { p[x] = y; setSize[y] += setSize[x];
                                 if (rank[x] == rank[y]) rank[y]++; } } }
    int numDisjointSets() { return numSets; }
    int sizeOfSet(int i) { return setSize[findSet(i)]; }
};

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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    string str;
    cin>>str;
    int a = 0, b = 0;
    for0(i,str.size()) {
        if(str[i] == '0') a++;
        else b++;
    }
    cout<<2*min(a,b);

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <stack>
#include <vector>
using namespace std;
int main(){
    string str;
    cin >> str;

    int sum=0;

    stack<int> slopes;
    stack<pair<int,int> > lakes; //first:位置,//second:面積

    for(int i=0;i<str.length();++i){
        if(str[i]=='\\'){
            slopes.push(i);
        }else if(str[i]=='/' && !slopes.empty()){
            int s=slopes.top();slopes.pop();
            lakes.push(pair<int,int>(s,i-s));
            sum+=i-s;
        }
    }

    //包含関係にある水たまりのうち，小さい方の方が後から出てくる
    vector<bool> islake(str.length(),false); //湖かどうか記憶しておく
    int deeper=0;
    stack<int> output;
    while(!lakes.empty()){
        if(islake[lakes.top().first]){
            output.top()+=lakes.top().second;
        }else{
            for(int i=lakes.top().first;i<lakes.top().first+lakes.top().second;++i){
                islake[i]=true;
            }
            output.push(lakes.top().second);
        }
        lakes.pop();
    }

    //出力するだけ
    cout << sum << endl;
    cout << output.size();
    while(!output.empty()){
        cout << ' ' << output.top();
        output.pop();
    }
    cout << endl;
}


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

vector<vector<int>> adj;
vector<int> vis;
vector<long long> P,ans;
void dfs(int u, long long curr){
	if(vis[u]) return;
	vis[u] = 1;
	curr += P[u];
	for(int v:adj[u]){
		dfs(v,curr);
	}
	ans[u] = curr;
}
int main() {
	int N,Q,a,b,p,x;
	cin >> N >> Q;
	adj.resize(N);
	P.assign(N,0);
	vis.assign(N,0);
	ans.resize(N);
	for(int i=1;i<N;i++){
		cin >> a >> b;
		a--; b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	for(int i=0;i<Q;i++){
		cin >> p >> x;
		p--;
		P[p] += x;
	}
	dfs(0,0);
	for(int i=0;i<N;i++){
		cout << ans[i] << ' ';
	}
	cout << '\n';
	return 0;
}

Measured memory_bytes: 26624
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math

    #inf = 10**17
    mod = 10**9 + 7

    max_n = 2*(10**5)
    fac, inv = [1]*(max_n+1), [0]*(max_n+1)
    for i in range(2, max_n+1):
        fac[i] = fac[i-1] * i % mod
    inv[-1] = pow(fac[-1], mod-2, mod)
    for i in range(max_n, 0, -1):
        inv[i-1] = inv[i] * i % mod

    # nCrを求める
    def ncr(n, r):
        return fac[n]*inv[r]*inv[n-r]%mod

    n, k = map(int, input().split())
    res = 0
    # i:空き部屋の数
    for i in range(n):
        if i > k:
            continue
        res += ncr(n, i) * ncr(n-1, i)
        res %= mod
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 45528
use proconio::{input, fastout};
#[fastout]
fn main() {
    input!{
        n: usize,
        m: usize,
        mut ab: [[usize; 2]; n],
    }
    ab.sort_by(|a, b| a[0].cmp(&b[0]));
    let mut drink = 0;
    let mut sum = 0;
    for i in 0..n {
        if drink + ab[i][1] <= m {
            sum += ab[i][0]*ab[i][1];
            drink += ab[i][1];
        } else {
            sum += ab[i][0]*(m - drink);
            break;
        }
    }
    println!("{}", sum);
}


Measured memory_bytes: 10040
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <tuple>

using namespace std;

struct edge {
  int v, w;
};

const int N = 1e5;
vector<edge> g[N];
int low[N], ord[N], k;
long long ws[N];
long long total;
tuple<long long, int, int> ans;

void dfs(int u, int p) {
  low[u] = ord[u] = k++;
  for (edge e : g[u]) {
    if (ord[e.v] == -1) {
      dfs(e.v, u);
      ws[u] += e.w;
      ws[u] += ws[e.v];
      low[u] = min(low[u], low[e.v]);
      if (ord[u] < low[e.v]) {
        long long A = ws[e.v];
        long long B = total - ws[e.v] - e.w;
        ans = min(ans, make_tuple(abs(A - B), u, e.v));
        ans = min(ans, make_tuple(abs(A - B), e.v, u));
      } else {
        ans = min(ans, make_tuple(total - e.w, u, e.v));
        ans = min(ans, make_tuple(total - e.w, e.v, u));
      }
    } else if (e.v != p && ord[u] > ord[e.v]) {
      ws[u] += e.w;
      low[u] = min(low[u], ord[e.v]);
      ans = min(ans, make_tuple(total - e.w, u, e.v));
      ans = min(ans, make_tuple(total - e.w, e.v, u));
    }
  }
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v, w;
    scanf("%d %d %d", &u, &v, &w);
    u--;
    v--;
    g[u].push_back((edge){v, w});
    g[v].push_back((edge){u, w});
    total += w;
  }
  memset(ord, -1, sizeof(ord));
  ans = make_tuple(total, 0, 1);
  dfs(0, -1);
  printf("%d %d\n", get<1>(ans) + 1, get<2>(ans) + 1);
}


Measured memory_bytes: 11868
#include <stdio.h>

#define N 10000
#define Q 500
 
int main() 
{
    int i,j,n,q,count=0;
    int S[N],T[Q];
     
    scanf("%d",&n);
    for(i=0; i<n; i++) {
        scanf("%d",&S[i]);
    }
     
    scanf("%d",&q);
    for(i=0; i<q; i++) {
        scanf("%d",&T[i]);
        for(j=0; j<n; j++) {
            if(T[i]==S[j]) {
                count++;
                break;
            }
        }
    }

    printf("%d\n",count);
     
    return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-


def main():
    """Function."""
    n = int(input())
    check = {}

    for i in range(n):
        check[i+1] = int(input())

    check2 = set()
    temp = 1
    check2.add(temp)
    for i in range(n):
        temp = check[temp]
        if temp in check2:
            print(-1)
            break

        check2.add(temp)
        if temp == 2:
            print(i+1)
            break


if __name__ == "__main__":
    main()


Measured memory_bytes: 22240
#include <bits/stdc++.h>
using namespace std;
long long n, w, a[100009], v[100009], dp[109][100009];
int main() {
    cin >> n;
	cin >> w;
    for(int i=1;i<=n;i++){
		cin>>a[i];
    	cin>>v[i];
	}
for(int i=0;i<w;i++)
    dp[0][i] = 0;

for (int i =1;i<= n;i++)
    for(int j =1 ;j<=w ;j++)
        if (a[i] > j )
            dp[i][j]=dp[i-1][j];
        else
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-a[i]] + v[i]);
cout<<dp[n][w];
}

Measured memory_bytes: 82176
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
 int m,n;
  cin >>n >> m;
  vector<int> a;
  double sum;
  int temp;
  for(int i=0;i<n;i++){
    cin >> temp; 
    a.push_back(temp);
    sum+=temp;
  }
  sort(a.rbegin(),a.rend());
  int counter = 0;
  bool result = true;
  for(auto x : a){
    counter++;
    if(counter>m) break;
    if(x>=1.0*sum/(4*m)) continue;
    else result = false;
  }
  if(result) cout << "Yes";
  else cout << "No";
  
  
}

Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- getl toInt
  unless (n == 0) $ do
    solve <$> replicateM (n `div` 4) (getl toInt) >>= print
    main

solve :: [Int] -> Int
solve = sum

toInt :: String -> Int
toInt = read

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 3976
#include <stdio.h>
int main(){
 
  int e,a,n,m,result;
 
  while(1){
 
    result=0;
    scanf("%d",&e);
    e *= 2;
    if(e == 0) break;
 
    for(n = 2; n < 50; n++){
 
      a=e-n*n;
 
      if(a > 0 && a%n == 0 && a/n%2 == 1) result++;
 
    }
 
    printf("%d\n",result);
 
  }
 
  return 0;
 
}

Measured memory_bytes: 596
h,w,d = map(int,input().split())
c = ('R','Y','G','B')

from itertools import product
for i in range(h):
  line = []
  for j in range(w):
    x = (i-j)%(2*d) >= d
    y = (i+j)%(2*d) >= d
    line.append(c[2*x+y])
  print(''.join(line))

Measured memory_bytes: 3316
#include <assert.h>
#include <chrono>
#include <cstdio>
#include <iostream>
#include <limits.h>
#include <mutex>
#include <thread>
#include <vector>

int main(){
  int N;
  std::string S;
  scanf("%d",&N);
  std::cin >> S;
  char next[3] = {'A','B','C'};
  int counter = 0;
  int ans = 0;
  for (int i=0; i<N; i++){
    if (S[i]==next[counter]){
      if (counter==2){
        ans++;
      }
      counter = (counter+1)%3;
    } else if (S[i]=='A'){
      counter=1;
    } else {
      counter=0;
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}
int dx[8]={0,-1,-1,-1,0,1,1,1};
int dy[8]={-1,-1,0,1,1,1,0,-1};


int main (){
    int h,w;
    cin >> h >> w;
    vector<vector<char>>maze(h,vector<char>(w));
    vector<vector<int>>ans(h,vector<int>(w,0));
    rep(i,h) rep(j,w) cin >> maze[i][j];
    rep(i,h){
        rep(j,w){
            int x=j;
            int y=i;
            if(maze[i][j]=='#') ans[i][j]=inf;
            else{
                int sum=0;
                rep(k,8){
                    int nx=x+dx[k];
                    int ny=y+dy[k];
                    if(nx<0||nx>=w||ny<0||ny>=h) continue;
                    if(maze[ny][nx]=='#') sum++;
                }
                ans[i][j]=sum;
            }
        }
    }
    rep(i,h){
        rep(j,w){
            if(ans[i][j]==inf){
                cout << '#'; 
            }
            else cout << ans[i][j];
        }
        cout <<endl;
    }

    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <string> 
#include <stdio.h>
using namespace std; 
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define ll long long int
#define REPI(a, b, i, inc) for(ll i = a; i < b; i = i + inc)
#define REP(i, a, b) for(ll i = a; i < b; i++)
#define F first
#define S second
#define pb push_back
#define test ll t; cin>>t; while(t--)
#define testi ll t; cin>>t; REP(tc,1,t+1)
#define vec vector
#define veci vector<ll>
#define pi pair<ll,ll>
#define mp make_pair
#define all(v) v.begin(), v.end()
#define uset unordered_set
#define umap unordered_map

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("op.txt","w",stdout);
    #endif
    int n;
    cin>>n;
	if(n>=30)
      cout<<"Yes";
  else
  	    cout<<"No";

	


	
	return 0;


}

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

int main() {
  int k,s;
  cin>>k>>s;
  int ans=0;
  //(x,y) 0<=x,y<=k and 0<=s-x-y<=k
  for(int i=0;i<k+1;i++){
    for(int j=0;j<k+1;j++){
      if(0<=s-i-j&&s-i-j<=k)ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    private static long MOD = 1_000_000_007;

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

        final boolean answer = IntStream.range(0, n)
                .mapToObj(i -> scanner.nextInt())
                .collect(Collectors.groupingBy(k -> k))
                .entrySet().stream()
                .allMatch(entry -> isPromised(n, entry));

        if (!answer) {
            System.out.println(0);
        } else {
            System.out.println(iterativePow(2, n / 2));
        }
    }

    private static boolean isPromised(final int n, final Map.Entry<Integer, List<Integer>> entry) {
        if (entry.getKey() % 2 == n % 2) {
            return false;
        }

        if (entry.getKey() == 0) {
            return entry.getValue().size() == 1;
        }

        return entry.getValue().size() == 2;
    }

    private static long iterativePow(long a, long b) {
        long tmp = 1;
        while (b > 0) {
            if ((b & 1) == 1) {
                tmp *= a;
                tmp %= MOD;
            }
            a *= a;
            a %= MOD;
            b >>= 1;
        }

        return tmp;
    }
}


Measured memory_bytes: 68568
n=int(input())
s=[int(i) for i in input().split()]
dp=[]
for i in s:
    dp.append(-1)
for i in range(n):
    if i == 0:
        dp[i]=0
    elif i == 1:
        dp[i] = abs(s[i] - s[i-1]) + dp[i-1]
    else:
        dp[i] = min( (abs(s[i] - s[i-1])+dp[i-1]),(abs(s[i] - s[i-2])+dp[i-2]) )
print(dp[-1])

Measured memory_bytes: 13980