akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main(){
  ll x,y,a,b,c;
  cin >> x>>y>>a>>b>>c;
  
  vector<ll> re(a);
  rep(i,a){
    cin>>re[i];
  }
  vector<ll> gr(b);
  rep(i,b){
    cin>>gr[i];
  }
  vector<ll> mu(c);
  rep(i,c){
    cin>>mu[i];
  }

  sort(all(re));
  reverse(all(re));
  rep(i,x){
    mu.pb(re[i]);
  }
  sort(all(gr));
  reverse(all(gr));
  rep(i,y){
    mu.pb(gr[i]);
  }

  sort(all(mu));
  reverse(all(mu));


  ll ans=0;
  rep(i,x+y){
    ans+=mu[i];
  }


  cout << ans << endl;
}

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

using namespace std;

// 計算量リミット = 10^8

int main() {
    // 入力値
    int N;
    cin >> N;

    vector<int> t(N + 1);
    vector<int> x(N + 1);
    vector<int> y(N + 1);

    t.at(0) = x.at(0) = y.at(0) = 0;
    for (int i = 0; i < N; i++) {
        cin >> t.at(i + 1) >> x.at(i + 1) >> y.at(i + 1);
    }

    bool canAccess = true;
    for (int i = 0; i < N; i++) {
        int dt = t.at(i + 1) - t.at(i);
        int dist = abs(x.at(i + 1) - x.at(i)) + abs(y.at(i + 1) - y.at(i));

        if (dt % 2 != dist % 2) {
            canAccess = false;
        }
        if (dt < dist) {
            canAccess = false;
        }
    }

    string res = canAccess ? "Yes" : "No";

    // 出力値
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1408
n,x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    if a[i] <= x:
        if a[i]+a[i+1] <= x: continue
        else:
            ans += (a[i]+a[i+1])-x
            a[i+1] -= (a[i]+a[i+1])-x
    else:
        ans += a[i]-x + a[i+1]
        a[i], a[i+1] = x, 0
if a[-1] > x: ans += a[-1]-x
print(ans)

Measured memory_bytes: 20036
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
	int x, y;
	scanf("%d%d", &x, &y);
	if(x == 2 && y != 2){
		printf("No\n");
		return 0;
	}
	else{
		if((x==1 || x == 3 || x==5|| x == 7 || x == 8 || x == 10 || x == 12) && (y==1 || y == 3 || y==5||y == 7 || y == 8 || y == 10 || y == 12)){
			printf("Yes\n");
		}
		else if((x == 4 || x == 6|| x == 9 || x == 11) && (y == 4 || y == 6|| y == 9 || y == 11)){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
	}

	return 0;
}

Measured memory_bytes: 128
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    n,x=parseMap(split(readline()))
    l=parseMap(split(readline()))
    ans=1
    d=0
    for i in 1:n
        d+=l[i]
        if d<=x
            ans+=1
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 167892
data = input().split()
N = int(data[0])
K = int(data[1])
h = map(int, input().split())

isGraterThanN = lambda n: lambda value: value >= n
isGraterThanK = isGraterThanN(K)

h_grater_then_k = filter(isGraterThanK, h)
h_grater_then_k = list(h_grater_then_k)

answer = len(h_grater_then_k)
print(answer)


Measured memory_bytes: 11580
use std::cmp::min;

fn main() {
    let mut scan = Scanner::new();
    let n = scan.read::<usize>();
    let k = scan.read::<i64>();
    let mut a = scan.readn::<i64>(n);
    a.sort();
    let mut ret = n;
    let mut total = 0i64;
    for i in (0..n).rev() {
        if total + a[i] < k {
            total += a[i];
        } else {
            ret = min(ret, i);
        }
    }
    println!("{}", ret);
}

use std::io::{BufReader, stdin, Stdin, Read, Bytes};
use std::str::FromStr;

pub struct Scanner {
    buf: Bytes<BufReader<Stdin>>
}

#[allow(dead_code)]
impl Scanner {
    pub fn new() -> Scanner {
        Scanner {
            buf: BufReader::new(stdin()).bytes()
        }
    }

    pub fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.buf.by_ref().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    pub fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    pub fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }

    pub fn char(&mut self) -> char {
        self.read::<String>().chars().next().unwrap()
    }
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
 
int main() {
    string s;
    while(true){
        cin >> s;
        if(s == "-") break;
        int n;
        cin >> n;
        for(int i = 0; i < n; ++i){
            int h;
            cin >> h;
            s = s.substr(h) + s.substr(0, h);
        }
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 3136
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    n = int(input())
    for i in range(8):
        if 2**i > n:
            print(2**(i-1))
            return


if __name__ == '__main__':
    main()


Measured memory_bytes: 62236
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
inline int read()
{
	int x = 0 , f = 1; char ch = getchar();
	while(ch < '0' || ch > '9')	{if(ch == '-')	f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
const int N = 2e5 + 5 , inf = 1e8;
int n , s , t;
namespace Dinic
{
	struct Edge
	{
		int to , cap; Edge *nxt , *pre;
		Edge(int to = 0,int cap = 0,Edge *nxt = NULL) : to(to) , cap(cap) , nxt(nxt) { pre = NULL;}
	} *head[N] , pool[N << 5] , *tail = pool , *cur[N];
	inline void add(int u,int v,int w) { head[u] = new (tail ++) Edge(v,w,head[u]); head[v] = new (tail ++) Edge(u,0,head[v]); head[u] -> pre = head[v]; head[v] -> pre = head[u];}
	int dep[N];
	inline bool bfs()
	{
		for(int i = 0;i <= t;i ++) dep[i] = 0;
		queue<int> q; q.push(s); dep[s] = 1;
		while(!q.empty())
		{
			int x = q.front(); q.pop();
			for(Edge *i = head[x];i;i = i -> nxt)
			{
				int to = i -> to;
				if(i -> cap && !dep[to]) dep[to] = dep[x] + 1 , q.push(to);
			}
		}
		return dep[t];
	}
	int dfs(int x,int want)
	{
		if(x == t || !want) return want;
		int get = 0 , flow;
		for(Edge *&i = cur[x];i;i = i -> nxt)
		{
			int to = i -> to;
			if(dep[to] == dep[x] + 1 && (flow = dfs(to,min(want,i -> cap))))
			{
				i -> cap -= flow; i -> pre -> cap += flow;
				get += flow; want -= flow;
				if(!want) break;
			}
		}
		if(!get) dep[x] = 0;
		return get; 
	}
	inline int dinic()
	{
		int ans = 0;
		while(bfs())
		{
			for(int i = 0;i <= t;i ++) cur[i] = head[i];
			ans += dfs(s,inf);
		}
		return ans;
	}
}
int cnt;
int p[N] , q[N] , id[2][N];
void dfs(int x,int *nxt,int *id)
{
	if(id[x]) return ;
	id[x] = cnt;
	dfs(nxt[x],nxt,id);
}
int main()
{
	int ans = n = read();
	for(int i = 1;i <= n;i ++) p[i] = read() + 1;
	for(int i = 1;i <= n;i ++) q[i] = read() + 1;
	for(int i = 1;i <= n;i ++) if(!id[0][i]) cnt ++ , dfs(i,p,id[0]);
	for(int i = 1;i <= n;i ++) if(!id[1][i]) cnt ++ , dfs(i,q,id[1]);
	s = 0; t = ++ cnt;
	using namespace Dinic;
	for(int i = 1;i <= n;i ++)
	{
		if(p[i] == i && q[i] == i) ans --;
		else if(p[i] == i) add(id[1][i],t,1);
		else if(q[i] == i) add(s,id[0][i],1);
		else if(p[i] != q[i]) add(id[1][i],id[0][i],1);
		else add(id[1][i],id[0][i],1) , add(id[0][i],id[1][i],1);
	}
	printf("%d\n",ans - dinic());
	return 0;
}

Measured memory_bytes: 157440
#include<stdio.h>
#include<math.h>

int main(void){
	int N, x;
	double y;
	do{
		scanf("%d", &N);
	}while(N < 0 || N > 1000000000);

	y = sqrt(N);
	x = (int)y;

	printf("%d\n", x * x);

	return 0;
}

Measured memory_bytes: 128
from statistics import mean
from collections import Counter
n,a,b=map(int,input().split())
v=sorted(list(map(int,input().split())),reverse=True)
avg=mean(v[:a])
print(avg)

p=Counter(v[:a])[v[a-1]]
q=Counter(v)[v[a-1]]

def n_func(n):
    ans=1
    for i in range(1,n+1):ans=(ans*i)
    return ans

def nCr(n,r):
    return (n_func(n)//n_func(r))//n_func(n-r)

if v[0]==v[a-1]:
    print(sum([nCr(q,a+i) for i in range(0,min(b,q)-a+1)]))
else:
    print(nCr(q,p))

Measured memory_bytes: 5404
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            int A = int.Parse(Console.ReadLine());
            int B = int.Parse(Console.ReadLine());
            int C = int.Parse(Console.ReadLine());
            int X = int.Parse(Console.ReadLine());

            int count = 0;
            
            for(int i=0;i<=A;i++)
            {
                int total = X - 500*i;
                if(total<0) {break;}
                int temp1 = Min(total/100,B);
                int temp2 = (total - temp1*100)/50;
                while(temp1>=0)
                {
                    if(temp2>C){break;}
                    count+=1;
                    temp2 += 2;
                    temp1--;

                }                
            }

            Console.WriteLine(count);
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

Measured memory_bytes: 13140
//To debug :  g++ -g file.cpp -o code
//to flush output : fflush(stdout) or cout.flush()
//cout<<setprecision(p)<<fixed<<var
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 INT_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 INT_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<int>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define mt make_tuple
#define PI acos(-1)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 


int main()
{
	
	ll n,k,r,s,p,i,j,point=0,m;
	string st,ans;
	cin>>n>>k;
	cin>>r>>s>>p;
	cin>>st;

	map<char,char>  pl;
	map<char,ll>   pp;
	pl['r'] = 'p';
	pl['p'] = 's';
	pl['s'] = 'r';

	pp['r']=r;
	pp['s']=s;
	pp['p']=p;

	map<pair<char,char>,char>  fp;

	fp[{'r','p'}]='s';
	fp[{'p','r'}]='s';

	fp[{'s','p'}]='r';
	fp[{'p','s'}]='r';

	fp[{'r','s'}]='p';
	fp[{'s','r'}]='p';
	

	for(i=0;i<k;++i)
	{
		for(j=i;j<n;j=j+k)
		{
			if(j<k)
			{
				point+=pp[pl[st[j]]];
				st[j]=pl[st[j]];
			}
			else
			{
				if(pl[st[j]]==st[j-k])
				{
					if((j+k)<n)
					{
						st[j]=fp[{st[j-k],pl[st[j+k]]}];
					}
				}
				else
				{
					point+=pp[pl[st[j]]];
					st[j]=pl[st[j]];
				}
			}
		}
	}


	cout<<point<<"\n";

	return 0;
}

Measured memory_bytes: 512
from itertools import product

h, w, k = map(int, input().split())
mod = 10 ** 9 + 7

dp = [[0] * w for _ in range(h + 1)]
dp[0][0] = 1

pats = [pat for pat in product([1, 0], repeat=w-1)]

for i in range(1, h + 1):
	for j in range(w):
		for pat in pats:
			valid = True
			for e1, e2 in zip(pat, pat[1:]):
				if e1 and e2:
					valid = False

			if not valid:
				continue

			if j - 1 >= 0 and pat[j-1]:
				dp[i][j] += dp[i-1][j-1]

			elif j <= w - 2 and pat[j]:
				dp[i][j] += dp[i-1][j+1]

			else:
				dp[i][j] += dp[i-1][j]

			dp[i][j] %= mod

ans = dp[h][k-1]
print(ans)
#print(*dp, sep="\n")


Measured memory_bytes: 3064
#include<stdio.h>
int main(){
  int A1,A2,A3;
  scanf("%d", &A1);
  scanf("%d", &A2);
  scanf("%d", &A3);

  if(A1+A2+A3>= 22){
    printf("bust");
  }else{
    printf("win");
  }
}

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

n, ma, mb = map(int,input().split())
A = [0]*n
B = [0]*n
C = [0]*n
for i in range(n) :
    A[i], B[i], C[i] = map(int,input().split())

INF = 10**9

# dp[i][ca][cb] := i番目までの(ca, cb)の最小費用
dp = [[[INF]*401 for j in range(401)] for i in range(n+1)]

dp[0][0][0] = 0
for i in range(1, n+1) :
    dp[i][A[i-1]][B[i-1]] = C[i-1]

for i in range(1, n+1) :
    for ca in range(1, 401) :
        for cb in range(1, 401) :
            if not (ca-A[i-1] >= 0 and cb-B[i-1] >= 0) :
                dp[i][ca][cb] = min(dp[i][ca][cb], dp[i-1][ca][cb])
            else :
                dp[i][ca][cb] = min(dp[i][ca][cb], dp[i-1][ca][cb], dp[i-1][ca-A[i-1]][cb-B[i-1]]+C[i-1])

ans = INF

for ca in range(1, 401) :
    for cb in range(1, 401) :
        if mb*ca == ma*cb :
            ans = min(ans, dp[n][ca][cb])

if ans == INF :
    ans = -1

print(ans)


Measured memory_bytes: 97372
#include <iostream>
#include <string>
#include <vector>

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

    std::string s; std::cin >> s;
    const int64_t l = s.size();
    int64_t r = l * (l - 1)  / 2 + 1;
    std::vector<int64_t> v(26);
    for (auto c : s) v[c - 'a']++;

    for (auto a : v) {
        r -= a * (a - 1) / 2;
    }
    std::cout << r << std::endl;
}


Measured memory_bytes: 720
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
  
n,m = map(int,input().split())
chk = factorization(m)
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod) 
  
def comb(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

mod = 10**9+7
ans = 1
for i in chk:
  ans *= comb(i[1]+n-1,i[1],mod)
  ans %= mod
if m == 1:
  ans = 1
print(ans)

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys
from collections import deque

def main():
    input = sys.stdin.readline  
    H,W = map(int,input().split())
    isVisited = [[False]*W for _ in range(H)]
    queue = deque()

    for i in range(H):
        st = input()
        for j in range(W):
            if st[j] == "#":
                queue.append((i,j))

    answer = 0
    a =  [(0,1),(1,0),(-1,0),(0,-1)]
    while True:
        nqueue = deque()
        while queue:
            i,j = queue.popleft()

            if not isVisited[i][j]:
                isVisited[i][j] = True
                for ix,iy in a:
                    if 0<=i+ix<H and 0<=j+iy<W:
                        nqueue.append((i+ix,j+iy))
        
        if nqueue:
            answer += 1
            queue = nqueue
        else:
            break
 
    print(max(answer-1,0))
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 180516
#include<iostream>
#include<stdio.h>//printf("%.*f\n",*********);
#include<vector>//s.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char('a'=32+'A')
                //to_string,string,substr
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(a,n) rep(i,n)cin>>a[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int KETA(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}

bool KIBN(string s) {
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i])return false;
	}
	return true;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	rapid_pleaseAC_fast;

	int x, y;
	cin >> x >> y;
	if (x % y == 0) {
		cout << -1 << rt;
	}
	else {
		cout << x << rt;
	}

	please AC;
}
//参考：---

Measured memory_bytes: 256
import java.io.*;
 
class Main {
    	public static void main(String[] args) throws IOException {
        	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        	String str1; 
		String str2 = br.readLine();
        	int a, b;
		int num = Integer.parseInt(br.readLine());
       		StringBuffer sb1 = new StringBuffer(str2);
        	for (int i = 0; i < num; i++) {
            		String[] order = br.readLine().split(" ");
            		a = Integer.parseInt(order[1]);
            		b = Integer.parseInt(order[2]);
            		if (order[0].equals("print")) {
                		System.out.println(str2.substring(a, b + 1));
            		}else if (order[0].equals("reverse")) {
                		StringBuffer sb2 = new StringBuffer(str2.substring(a, b + 1));
                		str1 = sb2.reverse().toString();
                		str2 = sb1.replace(a, b + 1, str1).toString();
            		}else if (order[0].equals("replace")) {
                		str2 = sb1.replace(a, b + 1, order[3]).toString();
            		}
        	}
    	}
}

Measured memory_bytes: 21368
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define pb push_back
 
#define limit (int) (1000)
#define mod (int) (1e9 + 7)

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
using ld = long double;

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

    int n,k;
    cin >> n >> k;

    lli a[n];
    int n0 = 0,nodd = 0;

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

        n0 += (a[i] == 0);
        nodd += (a[i] < 0);
    }

    sort(a,a+n);

    lli ans = 1;

    if (n == k)
    {
        for (int i = 0; i < n; ++i)
        {
            ans *= a[i];
            ans %= mod;
        }

        if (ans < 0)
            ans += mod;

        cout << ans;

        return 0;    
    }

    if (a[n-1] < 0 && k%2 == 1)
    {
        
        for (int i = n-1; i >= 0 && k > 0; --i)
        {
            ans *= a[i];
            ans %= mod;
            k--;
        }

        if (ans < 0)
            ans += mod;

        cout << ans;
        return 0;
    }

    int si=0,li=n-1;
    lli temp;

    while(k > 1)
    {
        if (a[si]*a[si+1] >= a[li]*a[li-1])
        {
            temp = a[si]*a[si+1];
            temp %= mod;
            ans *= temp;
            si += 2;
            k -= 2;
        } else {
            
            ans *= a[li];
            li--;
            k--;
        }

        ans %= mod;
    }

    if (k == 1)
    {
        if (a[li] >= 0)
        {
            ans *= a[li];
        } else {
            ans *= a[si];
        }

        ans %= mod;
    }

    if (ans < 0)
    {
        ans += mod;
    }

    cout << ans;
    return 0;
}












Measured memory_bytes: 5220
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

lint N;
lint K;
lint A[200010]={};
lint F[200010]={};

bool can(lint T)
{
	lint cnt=0;
	for(int i=0;i<N;i++)
		cnt+=max((lint)0,A[i]-T/F[i]);
	if(cnt<=K)return true;
	return false;
}

int main()
{
	cin >> N >> K;
	for(int i=0;i<N;i++)
		cin >> A[i];
	for(int i=0;i<N;i++)
		cin >> F[i];
	
	sort(A,A+N);
	sort(F,F+N,greater<lint>());

	lint l=0;
	lint r=1e12+10;
	while(r-l>1)
	{
		lint mid=(l+r)/2;
		if(can(mid))r=mid;
		else l=mid;
	}

	if(can(0))cout << 0;
	else cout << r;
	cout << endl;
	return 0;
}



Measured memory_bytes: 3328
#include <atcoder/lazysegtree>
#include <atcoder/modint>
#include <cstdio>

using namespace std;
using namespace atcoder;

using mint = modint998244353;

struct S {
    mint a;
    int size;
};

struct F {
    mint a, b;
};

S op(S l, S r) { return S{l.a + r.a, l.size + r.size}; }

S e() { return S{0, 0}; }

S mapping(F l, S r) { return S{r.a * l.a + r.size * l.b, r.size}; }

F composition(F l, F r) { return F{r.a * l.a, r.b * l.a + l.b}; }

F id() { return F{1, 0}; }

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

    vector<S> a(n);
    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        a[i] = S{x, 1};
    }

    lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);

    for (int i = 0; i < q; i++) {
        int t;
        scanf("%d", &t);
        if (t == 0) {
            int l, r;
            int c, d;
            scanf("%d %d %d %d", &l, &r, &c, &d);
            seg.apply(l, r, F{c, d});
        } else {
            int l, r;
            scanf("%d %d", &l, &r);
            printf("%d\n", seg.prod(l, r).a.val());
        }
    }
}


Measured memory_bytes: 19364
#include <bits/stdc++.h>
#define fi first
#define se second

typedef long long ll;
typedef std::pair < int, int > pr;

using std::cin;
using std::cout;

inline void up(int &x, int y) { x < y ? x = y : 0; }
inline void down(int &x, int y) { x > y ? x = y : 0; }

int H, W, n, tot, v[100005], x; 
inline int calc(int x, int y) {
    int U = (x - 1) * W;
    if (x & 1) U += y;
    else U += W - y + 1;
    return U;
    
}
int main() {
    std::ios::sync_with_stdio(false), std::cin.tie(0);
    cin >> H >> W >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> x;
        while (x--) v[++tot] = i;
    }
    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) cout << v[calc(i, j)] << ' ';;
        cout << '\n';
    }
    return 0;
}



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

int main(int argc, char const *argv[]) {
  int n,k,ans=0;
  scanf("%d %d",&n,&k);
  for(int i=0;i<n;i++)
  {
    int a;
    scanf("%d",&a);
    if(a>=k)
      ans++;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int n,a;char ch[105];
int main(){
	scanf("%d",&n);
	puts("0");fflush(stdout);scanf("%s",ch);
	if(ch[0]=='V')return 0;
	else a=ch[0]=='F';
	int l=0,r=n;
	while(l<r){
		int mid=(l+r)>>1;
		printf("%d\n",mid);fflush(stdout);
		scanf("%s",ch);if(ch[0]=='V')return 0;
		if((mid-l)%2==0){
			if(a==(ch[0]=='F'))l=mid;
			else r=mid; 
		}else {
			if(a==(ch[0]=='F'))r=mid;
			else l=mid,a=(ch[0]=='F');
		}
	}
}


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

int main()
{
        ll x, a, b;
        cin >> x >> a >> b;
        ll al = abs(x-a);
        ll bl = abs(x-b);
        if (al < bl) cout << "A" << endl;
        else cout << "B" << endl;


}


Measured memory_bytes: 256
from collections import Counter

H, W, N = map(int,input().split())

c = Counter()

for _ in range(N):
    a, b = map(int,input().split())
    a -= 1
    b -= 1
    for dx in range(-1, 2):
        for dy in range(-1, 2):
            na = a + dx
            nb = b + dy
            if not (1 <= na < H-1 and 1 <= nb < W-1): 
                continue
            c[(na, nb)] += 1

ans = [0] * 10
for ci in c.values():
    ans[ci] += 1

ans[0] = (H-2)*(W-2) - sum(ans)

for a in ans:
    print(a)

Measured memory_bytes: 166904
import java.util.*;

class Main{
	public static void main(String args[]){
		int con = 1;
		Scanner scan = new Scanner(System.in);
		while(true){
			int num = scan.nextInt();
			if(num!=0){
				System.out.println("Case " + con + ": " + num);
				con++;
			}
			else{
				break;
			}
		}
	}
}

Measured memory_bytes: 41824
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

int main() {
	int n, m;
	cin >> n >> m;
	vpint a(m);
	rep(i, m) {
		int tmp;
		cin >> a[i].first >> a[i].second >> tmp;
		a[i].first--;
		a[i].second--;
	}
	UnionFind UF(n);
	rep(i, m) {
		UF.connect(a[i].first, a[i].second);
	}
	vint table(n);
	rep(i, n) {
		table[i] = UF.root(i);
	}
	sort(table.begin(), table.end());
	int ans = 1;
	rep(i, n - 1) {
		if (table[i] != table[i + 1]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素



signed main(){
  int x[5];
  for(int i=0;i<5;i++)cin>>x[i];
  for(int i=0;i<5;i++)if(x[i]==0)cout<<i+1<<endl;

}

Measured memory_bytes: 3588
n,c,k = map(int,input().split())
a = sorted([int(input()) for i in range(n)])
#print(a)
#quit()

s = 1
p = 1
w = a[0]+k 
for t in a[1:]:
  if p == c or t > w:
    p = 1
    s += 1
    w = t+k
  else:
    p += 1
print(s)  

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

struct SCC {
  vector<vector<int>> &g;
  vector<vector<int>> rg;
  vector<int> cmp, order, used;
  SCC(vector<vector<int>> &g) : g(g), rg(g.size()), cmp(g.size(),-1), used(g.size()) {
    for(int i = 0; i < g.size(); i++) {
      for(auto e : g[i]) rg[e].push_back(i);
    }
    for(int i = 0; i < g.size(); i++) dfs(i);
    reverse(order.begin(),order.end());
    int c = 0;
    for(auto k : order) if(cmp[k] == -1) rdfs(k,c), c++;
  }
  void dfs(int p) {
    if(used[p]) return;
    used[p] = true;
    for(auto e : g[p]) dfs(e);
    order.push_back(p); 
  }
  void rdfs(int p, int c) {
    if(cmp[p] != -1) return;
    cmp[p] = c;
    for(auto e : rg[p]) rdfs(e,c);
  }
  int operator[](int k) {
    return cmp[k];
  }
};

int main() {
  int v, e;
  cin >> v >> e;
  vector<vector<int>> g(v);
  rep(i,e) {
    int s, t;
    cin >> s >> t;
    g[s].push_back(t);
  }
  SCC scc(g);
  int q;
  cin >> q;
  rep(i,q) {
    int u, v;
    cin >> u >> v;
    cout << (scc[u] == scc[v] ? 1 : 0) << endl;
  }
}


Measured memory_bytes: 4504
#include<vector>
#include<string>
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  string S,T; cin >> S >> T;
  
  reverse(S.begin(),S.end()); reverse(T.begin(),T.end());
  
  int s = (int)S.size(); int t = (int) T.size();
  
  if( t > s){ cout << "UNRESTORABLE" << endl;}
  else{
    
     bool flag = true;
    
    for(int i = 0; i <= s - t; i++){
     
      flag = true;
      
      for(int j = 0; j <= t - 1; j++){
       
        if(S[j+i] != '?' && S[j+i] != T[j]){flag = false;}}
      if(flag){
        for(int j = 0; j <= t - 1; j++){
          S[j+i] = T[j];} break;}}
    
    if(!flag){cout<< "UNRESTORABLE" << endl; return 0;}
     
    for(int i = 0; i < s; i++){
      if(S[i] == '?'){ S[i] = 'a';}}
    
    reverse(S.begin(),S.end());
    
    for(int i = 0;i < s; i++){
      cout<< S[i];}
  }
  
  return 0;}

    
    

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

int main(void){
    int b;
    int ma=0,num=0;
    while(true){
        cin>>b;
        if(b==0)break;
        ma=0;
        num=0;
        for(int i=0;i+1<=(int)sqrt(2*b);i++){
            if(2*b%(i+1)==0){
                if((2*b/(i+1)-i)%2==0){
                    ma=i;
                    num=(2*b/(i+1)-i)/2;
                }
            }
        }
        cout<<num<<" "<<ma+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 3004
n = input().split()
N = int(n[0])
A = int(n[1])
B = int(n[2])

if A > B:
    a = A
    b = B
elif A < B:
    a = B
    b = A
elif A == B:
    a = A
    b = B

if a != b:
    if a+b <= N:
        print(str(b) + ' ' + str(0))
    elif a+b > N:
        print(str(b) + ' ' + str(a - (N-b)))
elif a+b <= N:
    print(str(a) + ' ' + str(0))
elif a+b > N:
    print(str(a) + ' ' + str(a-(N-b)))


Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
    int b1;
    int b2;
    int b3;
     
    scanf ("%d %d %d", &b1, &b2, &b3);
     
    if ((b1 == 1 && b2 == 0 && b3 == 0) || (b1 == 0 && b2 == 1 && b3 == 0) || (b1 == 0 && b2 == 0 && b3 == 0)){
        printf ("Close\n");
    }
     
    else if ((b1 == 1 && b2 == 1 && b3 == 0) || (b1 == 0 && b2 == 0 && b3 == 1)){
        printf ("Open\n");
    }
     
    return 0;
}

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

        Map<Integer, Map<String,Integer>> submit = new TreeMap<>();
        for (int i = 1; i <= N; i++){
            submit.put(i, new HashMap<>());
            submit.get(i).put("AC",0);
            submit.get(i).put("WA",0);
        }

        int M = sc.nextInt();
        int AC = 0;
        int WA = 0;
        for (int i = 0; i < M; i++){
            int p = sc.nextInt();
            String S = sc.next();
            if (submit.get(p).get("AC") == 0) {
                if (S.equals("AC")) {
                    submit.get(p).put("AC", 1);
                    AC++;
                    WA += submit.get(p).get("WA");
                } else {
                    int count = submit.get(p).get("WA");
                    submit.get(p).put("WA", count + 1);
                }
            }
        }
        System.out.print(AC + " " + WA);
    }
}


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

constexpr int mod = 1e9 + 7;
constexpr int32_t inf = 1001001001;
constexpr int64_t infll = 1001001001001001001ll;
constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

// clang-format off
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }

template <typename T> void sort(vector<T> &v) { sort(all(v)); }
template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int n = in();

  cout << (max(n % 10, n / 10) == 9 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define rep2(i,s,t) for(int i = s; i <= t; ++i)
#define rev(i,n) for(int i = n-1; i >= 0; --i)
#define rev1(i,n) for(int i = n; i > 0; --i)
#define rev2(i,s,t) for(int i = s; i >= t; --i)
#define F first
#define S second
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
using vii = vector<vi>;
int main()
{
  string s,t; cin >> s >> t;
  int res = 1e+9;
  rep(i,s.size()) {
    int cnt = 0;
    rep(j,t.size()) {
      if(i+j >= s.size()) goto END;
      if(s[i+j] != t[j]) cnt++;
    }
    chmin(res, cnt);
  }
 END:
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <iomanip>
#include <ios>
using namespace std;
int main(void){
  string s,t;
  cin >> s >> t;
  
  int ns = s.length();
  int nt = t.length();
  
  if(ns > nt)
    cout << "GREATER" << endl;
  else if(ns < nt)
    cout << "LESS" << endl;
  else{
  int i=0;
  while(1){
    if(s[i] == t[i] && i == ns){
      cout << "EQUAL" << endl;
      break;
    }
    else if(s[i] > t[i]){
      cout << "GREATER" << endl;
      break;
    }
    else if(s[i] < t[i]){
      cout << "LESS" << endl;
      break;
    }
    else
      i++;
  }
  }
  
  return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left
n = int(input())
a = [int(input()) for i in range(n)]
dp = [0 for i in range(n)]
dp[0] = a[0]
length = 1
for i in range(1, n):
    if dp[length-1] < a[i]:
        dp[length] = a[i]
        length += 1        
    else:
        dp[bisect_left(dp[:length],a[i])] = a[i]
print(length)


Measured memory_bytes: 10992
#include<iostream>
using namespace std;
int main(){ 
	int i,j,n,m,f=0;
	cin>>n>>m;
	char s[n+5][m+5];
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			cin>>s[i][j];
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){	
			if (s[i][j]=='#'&&s[i][j-1]!='#'&&s[i-1][j]!='#'&&s[i][j+1]!='#'&&s[i+1][j]!='#') 
			f=1; 
		}
	} 
	if(f==0){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	char name[9][16];
	int AM[9],PM[9],sum[9],income[9];
	for(int i=0;i<9;i++){
		scanf("%s %d %d",name[i],&AM[i],&PM[i]);
		sum[i]=AM[i]+PM[i];
		income[i]=200*AM[i]+300*PM[i];
	}
	for(int i=0;i<9;i++)
		printf("%s %d %d\n",name[i],sum[i],income[i]);
	return 0;
}

Measured memory_bytes: 1020
#include <iostream>

using namespace std;
#include <string>

int main() {
	unsigned long long int principle = 100, rate = 1, year = 0, x,z=1;

	cin >> x;
	if (principle == x) {
		cout << year << endl;
	}
	else {
		while (principle < x) {
			year += 1;
			principle += (principle * rate * z) / 100;
		}
		cout << year << endl;
	}
}



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

int main(){
    string s; cin>>s;
    int i=0,cnt=0;
    set<int> dic;
    string bef=" ";
    
    while(i < s.size()){
        string cmp=" ";
        int v=0;
        cmp += s[i];
        v += (int)s[i];
        if(bef == cmp){
            i++;
            if(i == s.size()){
                break;
            }
            cmp += s[i];
            v += (int)s[i];
        }
        bef = cmp;
        dic.insert(v);
        i++;
        cnt++;
    }

    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 644
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[10][40];
int pt[10];
int ge[10];
int sh[10];
int hl[10];
double prob[10];
int val[10][10];
int to[10];

int main(){
	int T;
	scanf("%d",&T);
	for(int i=0;i<=8;i++){
		double ks=1;
		for(int j=0;j<i;j++){
			ks*=(8-j);
			ks/=(j+1);
		}
		for(int j=0;j<8-i;j++)ks*=3;
		for(int j=0;j<8;j++)ks/=4;
		prob[i]=ks;
	}
	while(T--){
		for(int i=0;i<5;i++)scanf("%s",str[i]);
		int num=0;
		for(int i=0;i<4;i++)if(str[i+1][0]=='*')num=i;
		for(int i=0;i<4;i++)for(int j=i+1;j<4;j++){
			if(str[i+1][6+j*5]=='_'){
				to[i]=j;
				to[j]=i;
				continue;
			}
			int l=str[i+1][6+j*5]-'0';
			int r=str[i+1][8+j*5]-'0';
			val[i][j]=l;
			val[j][i]=r;
		}
		double ret=0;
		for(int i=0;i<=8;i++)for(int j=0;j<=8;j++)for(int k=0;k<=8;k++)for(int l=0;l<=8;l++){
			double ks=prob[i]*prob[j]*prob[k]*prob[l];
			val[0][to[0]]=i;
			val[1][to[1]]=j;
			val[2][to[2]]=k;
			val[3][to[3]]=l;
			for(int x=0;x<4;x++)hl[x]=0;
			bool chg=false;
			int rem=4;
			int ue=0;
			do{
				chg=false;
				for(int x=0;x<4;x++)pt[x]=ge[x]=sh[x]=0;
				for(int x=0;x<4;x++)for(int y=x+1;y<4;y++){
					if(hl[x]||hl[y])continue;
					if(val[x][y]>val[y][x])pt[x]+=3;
					else if(val[x][y]<val[y][x])pt[y]+=3;
					else{pt[x]++;pt[y]++;}
					ge[x]+=val[x][y]-val[y][x];
					ge[y]+=val[y][x]-val[x][y];
					sh[x]+=val[x][y];
					sh[y]+=val[y][x];
				}
				for(int x=0;x<4;x++){
					if(hl[x])continue;
					if(x==num)continue;
					if(pt[x]>pt[num]){
						chg=true;ue++;rem--;
						hl[x]=1;continue;
					}
					if(pt[x]<pt[num]){
						chg=true;rem--;
						hl[x]=1;continue;
					}
					if(ge[x]>ge[num]){
						chg=true;ue++;rem--;
						hl[x]=1;continue;
					}
					if(ge[x]<ge[num]){
						chg=true;rem--;
						hl[x]=1;continue;
					}
					if(sh[x]>sh[num]){
						chg=true;ue++;rem--;
						hl[x]=1;continue;
					}
					if(sh[x]<sh[num]){
						chg=true;rem--;
						hl[x]=1;continue;
					}
					
				}
			}while(chg&&rem>1);
			if(ue>=2)continue;
			ret+=ks*min(1.0,(2.0-ue)/rem);
		}
		printf("%.7f\n",ret);
	}
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

ll *dp;
int n;
string s,t;
ll mod=1000000007;
ll solve(int i){
	if(s[i]==t[i]){
		if(i==0) return (dp[i]=3);
		else if(s[i-1]==t[i-1]) return(dp[i]=solve(i-1)*2 % mod);
		else return(dp[i]=solve(i-1)); 
	}
	else {
		if(i==1) return 6;
		else if(s[i-2]==t[i-2]) return(dp[i]=solve(i-2)*2 % mod);
		else return(dp[i]=solve(i-2)*3 % mod); 
	}
	
}


int main(){
	cin >> n >> s >> t;
	int i=0,j=0;
	ll sol=0;
	dp=new ll[n];
	FOR(i,n) dp[i]=0;
	cout << solve(n-1);
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

/**
 2 2
 2 1 2
 1 2
 0 1
 */
int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> f(m); // bulb -> vector<int> (the lights id)
    //cout<<"n:"<<n<<" m:"<<m<<endl;
    for (int i = 0; i < m; ++i) {
        //cout<<"read line:"<<i + 1<<" all("<<m<<")"<<endl;
        int k;
        cin >> k;
        for (int j = 0; j < k; ++j) {
            int l;
            cin >> l;
            f[i].push_back(l);
        }
    }
    vector<int> p(m);
    //cout<<"read p."<<endl;
    for (int i = 0; i < m; ++i) {
        cin >> p[i];
        //cout<<"read:"<<p[i]<<" ";
    }

    int ans = 0;
    for (int i = 0; i < (1 << n); ++i) {
        //cout<<"the case:"<<i<<endl;
        bool ok = true;
        for (int j = 0; j < m; ++j) {
            //cout<<"the bulb:"<<j<<endl;
            int cp = 0;
            for (auto& bi : f[j]) {
                cp += ((i >> (bi - 1)) & 1);
            }
            if ((cp % 2) != p[j]) {
                ok = false;
                break;
            }
        }
        if (ok) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) {if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a, T b) {if(a>b){a=b;return 1;}return 0;}

int n,k;

int main(){
    vector<int> a(3);
    vector<int> b(3);
    
    REP(i,3){
        cin >> a[i] >> b[i];
    }
    vector<int> c(4,0);
    
    REP(i,3){
        c[a[i]-1]++;
        c[b[i]-1]++;
    }
    int cnt=0;
    REP(i,4){
        if(c[i]%2==1){
            cnt++;
        }
    }
    if(cnt==2||cnt==0){
        put("YES");
    }else{
        put("NO");
    }
    return 0;
}


Measured memory_bytes: 256
##入力は以下の形式で標準入力から与えられる。
##N
str = gets.chomp
n = str.to_i

##整数 Xを十進法で表したときの各桁の数字の和を f(X)としたとき、
##Xが f(X)で割り切れる場合、 Xはハーシャッド数です。
##整数 Nが与えられるので、ハーシャッド数かどうか判定してください。

##制約
##1 ≦ N ≦ 10^8
##入力は全て整数

a_v = str.split("").map(&:to_i)
val = 0
a_v.each do |v|
  val += v
end
# p val

##Nがハージャッド数ならば Yes を、そうでなければ No を出力せよ。
if n % val == 0
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
#if __cplusplus>=201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

int chrtoint(char a){
  return a-'A';
}
char inttochr(int a){
  return 'A'+a;
}
void solve(long long N, std::string S){
  string ans="";
  REP(S.size()){
    ans+=inttochr((chrtoint(S[i])+N)%26);
  }
  cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256