akhauriyash/Code-Regression huggingface dataset:
/*
 * Click `Run` to execute the snippet below!
 */

import java.io.*;
import java.util.*;

/*
 * To execute Java, please define "static void main" on a class
 * named Solution.
 *
 * If you need more classes, simply define them inline.
 */

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), M = sc.nextInt(), D = sc.nextInt();
    int row[] = new int[N*M], col[] = new int[N*M];
    for(int i = 1; i<=N; i++){
      for(int j = 1; j<=M; j++){
        int k = sc.nextInt();
        k--;
        row[k] = i;
        col[k] = j;
      }
    }
    int O[][] = new int[D][N*M/D+1];
    int P[][] = new int[D][N*M/D+1];
    for(int r = 0; r<D; r++){
      for(int k = 1; k * D + r < N*M; k++){
        int f = (k-1) * D + r;
        int s = k * D + r;
        O[r][k] = Math.abs(row[f] - row[s]) + Math.abs(col[f] - col[s]);
      }
    }
    for(int r = 0; r<D; r++){
      for(int k = 1; k * D + r < N*M; k++){
        P[r][k] = P[r][k-1] + O[r][k]; 
      }
    }
    int Q = sc.nextInt();
    while(Q-->0){
      int l = sc.nextInt(), r = sc.nextInt();
      l--;
      r--;
      System.out.println(P[r%D][r/D] - P[l%D][l/D]);
    }
  }
}


Measured memory_bytes: 62524
#include <bits/stdc++.h>
#include <list>
using namespace std;
typedef long long ll;
const double rate=1.01;
int main()
{
    ll a,qian=100;
    cin>>a;
    ll s=0;
    while(1)
    {
        if(a>qian)
        {
            s++;
            qian=floor(qian*1.01);
        }
        else
        {
            break;
        }
    }
    cout<<s<<endl;
}


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

using namespace std;
using ll = long long;

//cout << std::fixed << std::setprecision(15) << y << endl;

int main() {
    int n = 0;
    cin >> n;
    vector<pair<int,pair<double,double>>> z(n);
    for(int i = 0;i < n;i++){
        int x = 0;
        int y = 0;
        cin >> x >> y;
        z[i].first = i;
        z[i].second.first = x;
        z[i].second.second = y;
    }
    double sum = 0;
    do{
        double tmpSum = 0;
        for(int i = 0;i < n - 1;i++){
            tmpSum += sqrt((z[i].second.first - z[i + 1].second.first) * (z[i].second.first - z[i + 1].second.first) + (z[i].second.second - z[i + 1].second.second) *  (z[i].second.second - z[i + 1].second.second));
        }
        //cout << tmpSum << endl;
        sum += tmpSum;
    }while(next_permutation(z.begin(),z.end()));
    double div = n;
    for(int i = n - 1;i >= 1;i--){
        div *= i;
    }
    cout << std::fixed << std::setprecision(7) << sum / div << endl;
    return 0;
}

Measured memory_bytes: 3852
import numpy as np
from functools import reduce
import math

N, M, X = map(int, input().split())

books = []
moneys = []
for i in range(N):
    C = list(map(int, input().split()))
    moneys.append(C[0])
    books.append(np.array(C[1:]))
moneys = np.array(moneys)
books = np.array(books)

coms = [np.array(list(map(int, bin(i)[2:].rjust(N, "0")))) for i in range(2**N)]

min_val = math.inf
for com in coms[1:]:
    if sum([X]*M <= reduce(lambda a, b: a+b, books[com==1])) == M:
        min_val = min(min_val, sum(moneys[com==1]))
        
if min_val == math.inf:
    print(-1)
else:
    print(min_val)

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

int main(){

  int sum=0;
  string tmp="CODEFESTIVAL2016";
  char in;

  for(int i=0; i<tmp.size();i++){
    cin >> in;
    if(in!=tmp[i])sum++;
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define INF 0x7FFFFFFF
const double EPS = 1e-10;





int x, y, e;
vector<vector<int>>G;//グラフの隣接リスト表現
vector<int>match;//マッチングのペア
vector<bool>used;//同一頂点を始点としたDFSを行わないようにする
//uとvを結ぶ辺をグラフに追加する



void add_edge(int u, int v) {
	G[u].push_back(v);
	G[v].push_back(u);
}
//増加パスをDFSで探す
bool bi_dfs(int v) {
	used[v] = true;
	for (int i = 0; i<(int)G[v].size(); i++) {
		int u = G[v][i], w = match[u];
		if (w < 0) {
			match[v] = u;
			match[u] = v;
			return true;
		}
		else if (used[w] == false) {
			if (bi_dfs(w)) {
				match[v] = u;
				match[u] = v;
				return true;
			}
		}
	}
	return false;
}
//二部グラフの最大マッチングを求める
int bipartitea_matching() {
	int res = 0;
	fill(match.begin(), match.end(), -1);
	for (int v = 0; v<x+y; v++) {
		if (match[v]<0) {//頂点vのマッチングのペアが現時点でない場合
			fill(used.begin(), used.end(), false);
			if (bi_dfs(v)) {
				res++;
			}
		}
	}
	return res;
}

signed main() {
  int n;
  cin >> n;
  vector<int> a,b;
  x=n;
  y=n;
  
	G.resize(x + y);
	match.resize(x + y);
	used.resize(x + y);

  for(int i=0;i<2*n;i++){
    int u, v;
		cin >> u >> v;
    a.push_back(u);
    b.push_back(v);
  }

  for(int i=0;i<n;i++){
    for(int j=n;j<2*n;j++){
      if(a[i]<a[j]&&b[i]<b[j]){
        add_edge(i, j);
      }
    }
  }

	cout << bipartitea_matching() << endl;
	return 0;
}



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

	
int main() {
  int red, green,blue;
  cin >> red >> green >> blue;
  
  
  
  if(((red *100) + (green * 10) + blue) % 4 == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  
  
}


           

Measured memory_bytes: 256
n,w0=map(int,input().split())
v=[]
w=[]
for _ in range(n):
	V,W=map(int,input().split())
	v.append(V)
	w.append(W)

#knapsack
dp=[[0]*(w0+1) for _ in range(n+1)]
#print(dp)
for i in reversed(range(n)):
	for j in range(w0+1):
		if j-w[i]<0:
			dp[i][j]=dp[i+1][j]
		else:
			dp[i][j]=max(dp[i+1][j],dp[i+1][j-w[i]]+v[i])
print(dp[0][w0])


Measured memory_bytes: 24284
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_DISH_MAX		100000									// 最大料理数

// 内部構造体 - 料理情報
typedef struct Dish {
	int miA;													// Aポイント
	int miB;													// Bポイント
} Dish;

// 内部変数
static FILE *szpFpI;											// 入力
static Dish sz1Dish[D_DISH_MAX];								// 料理
static int siDCnt;												// 料理数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
#endif

// ソート関数 - ポイント合計降順
int
fSortFnc(
	const void *pzpVal1			// <I> 値１
	, const void *pzpVal2		// <I> 値２
)
{
	Dish *lzpVal1 = (Dish *)pzpVal1;
	Dish *lzpVal2 = (Dish *)pzpVal2;

	// ポイント合計
	int liSum1 = lzpVal1->miA + lzpVal1->miB;
	int liSum2 = lzpVal2->miA + lzpVal2->miB;

	// ポイント合計降順
	if (liSum1 > liSum2) {
		return -1;
	}
	else if (liSum1 < liSum2) {
		return 1;
	}

	return 0;
}

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 料理数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siDCnt);

	// 料理 - 取得
	for (i = 0; i < siDCnt; i++) {
		fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
		sscanf(lc1Buf, "%d%d", &sz1Dish[i].miA, &sz1Dish[i].miB);
	}

	// 料理 - ソート
	qsort(sz1Dish, siDCnt, sizeof(Dish), fSortFnc);

	// 合計 - 取得
	long long llSum = 0;
	for (i = 0; i < siDCnt; i++) {
		if (i % 2 == 0) {
			llSum += sz1Dish[i].miA;
		}
		else {
			llSum -= sz1Dish[i].miB;
		}
	}

	// 結果 - セット
	sprintf(lc1Out, "%lld\n", llSum);

	// 結果 - 表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



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

#define endl '\n'
#define PI acos(-1.0)

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

int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	
	int n, sum = 0;
	cin >> n;
	
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= n; ++j) {
			for(int k = 1; k <= n; ++k) {
				sum += __gcd(i, __gcd(j, k));
			}
		}
	}
	
	cout << sum << endl;
	
	return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, long long M, std::vector<long long> p, std::vector<long long> x, std::vector<long long> y){
  map<ll, vector<ll>> m;
  for(ll i=0; i<M; i++) {
    m[x[i]].push_back(y[i]);
    m[y[i]].push_back(x[i]);
  }
  queue<ll> q;
  vector<ll> v(N+1, 0);
  ll ans = 0;
  for(ll i=1; i<=N; i++) {
    if(v[i]) continue;
    set<ll> s;
    q.push(i);
    s.insert(i);
    while(!q.empty()) {
      ll c = q.front();
      q.pop();
      v[c] = 1;
      for(auto next : m[c]) {
	if(v[next]) continue;
	q.push(next);
	s.insert(next);
      }
    }
    for(auto c : s) {
      if(s.find(p[c-1])!=s.end())
	ans++;
    }
  }
  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  std::vector<long long> p(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&p[i]);
  }
  std::vector<long long> x(M);
  std::vector<long long> y(M);
  for(int i = 0 ; i < M ; i++){
    scanf("%lld",&x[i]);
    scanf("%lld",&y[i]);
  }
  solve(N, M, std::move(p), std::move(x), std::move(y));
  return 0;
}



Measured memory_bytes: 18944
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    set<string>s;
    string t;
    for (int i=0;i<x;i++){
        cin>>t;
        s.insert(t);
    }
    cout<<s.size();
    return 0;
}


Measured memory_bytes: 19204
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val x = readLong()

    val list = mutableListOf<Pair<Long, Long>>()
    for (i in 1..200L) {
        list += Pair(i, i * i * i * i * i)
    }

    val tmpList = list.map { Pair(-it.first, -it.second) } + Pair(0L, 0L) + list
    var ansA = 0L
    var ansB = 0L
    for (a in tmpList) {
        for (b in tmpList) {
            if (a.second - b.second == x) {
                ansA = a.first
                ansB = b.first
                break
            }
        }
    }

    println("$ansA $ansB")
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)

Measured memory_bytes: 36912
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

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

struct buil{
	int n;
	string b;
	double x, y;
	void next(void){
		cin >> b >> x >> y;
		n = 0;
		int i; rep(i, b.size())n = n * 10 + b[i] - '0';
		return;
	}
};

bool nsort(buil qwe, buil rty){ return qwe.n < rty.n; }
buil B[100];
pair<double, string> G[100][100];
double ma = 12354567890.1;

int main(void){
	int i, j, k, n, m;
	for(;;){
		scanf("%d", &n);
		if(!n)break;
		rep(i, n)rep(j, n)G[i][j].first = ma;

		rep(i, n)B[i].next();
		sort(B, B + n, nsort);

		rep(i, n)rep(j, i){
			double tmp = (B[i].x - B[j].x) * (B[i].x - B[j].x) + (B[i].y - B[j].y) * (B[i].y - B[j].y);
			if(tmp <= 2500.0){
				G[i][j].first = sqrt(tmp); G[i][j].second = B[i].b;
				G[j][i].first = sqrt(tmp); G[j][i].second = B[j].b;
			}
		}
		rep(k, n)rep(i, n)rep(j, n)if(G[i][j].first > G[i][k].first + G[k][j].first){
			G[i][j].first = G[i][k].first + G[k][j].first;
			G[i][j].second = G[i][k].second + " " + G[k][j].second;
		}

		scanf("%d", &m);
		for(;m--;){
			scanf("%d %d", &i, &j);
			if(G[i - 1][j - 1].first < ma)cout << G[i - 1][j - 1].second << " " << B[j - 1].b << endl;
			else puts("NA");
		}
	}
	
	return 0;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	ll x;
	cin >> x;
	ll q = x / 500;
	x %= 500;
	ll p = x / 5;
	cout << q * 1000 + p*5;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  long long N,M,A,B,Tac,Tp;
  string S;
  cin >> N >> M;
  Tac=Tp=0;
  vector<int> seen(N,0);
  for (long long i=0;i<M;i++) {
    cin >> A >> S;
	if (seen.at(A-1)>=0 && S=="WA") {seen.at(A-1)++;}
	else if (seen.at(A-1)>=0 && S=="AC") {Tac+=1;Tp+=seen.at(A-1);seen.at(A-1)=-1;}
  }
  
  cout << Tac << " " << Tp << endl;
  
  
}


Measured memory_bytes: 640
n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]
dp=[0]*2**n
mod=10**9+7
dp[0]=1
for i in range(2**n-1):
    cnt=-1
    for j in range(n):
        if (i>>j)&1:
            cnt+=1
    for j in range(n):
        if (i>>j)&1==0:
            if a[cnt+1][j]:
                dp[i|pow(2,j)]+=dp[i]
                dp[i|pow(2,j)]%=mod
print(dp[2**n-1])

Measured memory_bytes: 90420
S = input()
S = list(S)

S_even = S[1::2]
S_odd  = S[0::2]

ans = "Yes"

for i in range(0, len(S_even)):
    if S_even[i] == "R":
        ans = "No"

for i in range(0, len(S_odd)):
    if S_odd[i] == "L":
        ans = "No"
        
print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
  int a,b;
  cin >> a >> b;
  if(b % 2 == 1){
  cout << "No";
  return 0;
  }
  
  if(a * 2 > b){
  cout << "No";
  return 0;
  }
  
  if(a * 4 >= b){
  cout << "Yes";
  return 0;
  }
  cout << "No";
  return 0;
}

Measured memory_bytes: 3620
data = input()

flag = True
if data.count('1') != 1:
    flag = False

if data.count('4') != 1:
    flag = False

if data.count('7') != 1:
    flag = False

if data.count('9') != 1:
    flag = False

if flag:
    print('YES')
else:
    print('NO')



Measured memory_bytes: 3060
line = input()
x1, x2, x3, x4, x5 = line.split(" ")
if x1 == "0":
    print("1")
elif x2 == "0":
    print("2")
elif x3 == "0":
    print("3")
elif x4 == "0":
    print("4")
elif x5 == "0":
    print("5")

Measured memory_bytes: 8932
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;

const string YES = "Yes";
const string NO = "No";

int main(){
    int n;
    cin >> n;

    int cnt = 0;
    rep(i, n){
        int d1, d2;
        cin >> d1 >> d2;
        if(d1 == d2){
            cnt++;
            if(cnt == 3){
                cout << YES << endl;
                return 0;
            }
        }
        else{
            cnt = 0;
        }
    }

    cout << NO << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1ll << 60

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, W, lim;
	ll v, w;
	cin >> num >> W;
	vector<ll> dp(num * 1000 + 1, INF);
	lim = dp[0] = 0;
	rep(i, num) {
		cin >> w >> v;
		for (int j = lim; j >= 0; j--)
			chmin(dp[j + v], dp[j] + w);
		lim += v;
	}
	for (i = dp.size() - 1; i >= 0; i--) {
		if (dp[i] <= W)
			break;
	}
	cout << i << "\n";
	return 0;
}

Measured memory_bytes: 4024
#include <iostream>

int main()
{
	int A, B, C;
	std::cin >> A >> B >> C;
	bool isSame = false;
	int cnt = 0;
	while ((A&1)==0 && (B&1)==0 && (C&1)==0) {
		if (A==B && B==C) { isSame = true; break; }
		int a = B/2 + C/2;
		int b = A/2 + C/2;
		int c = A/2 + B/2;
		A = a; B = b; C = c;
		cnt++;
	}
	if (!isSame) std::cout << cnt << std::endl;
	else std::cout << -1 << std::endl;
	return 0;
}


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

int main() {
	int A, B;
	cin >> A >> B;
	int AB = A+B;
	
	bool a = A%3 == 0;
	bool b = B%3 == 0;
	bool ab = AB%3 == 0;
	
	if(a || b || ab ) cout << "Possible";
	else cout << "Impossible";
	
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt(), b = sc.nextInt();
    sc.close();
    String ans[] = {"Odd", "Even"};
    int an = 0;
    if(a % 2 == 0 || b % 2 == 0)an = 1;
    System.out.println(ans[an]);
  }
}


Measured memory_bytes: 20820
from collections import deque
from copy import copy

n, a, b, c = map(int, input().split())
s = [input().rstrip() for _ in range(n)]

m = {'A': a, 'B': b, 'C': c}
ans = []
for i in range(n):
    if m[s[i][0]] > m[s[i][1]]:
        ans.append(s[i][1])
        m[s[i][0]] -= 1
        m[s[i][1]] += 1
    elif m[s[i][0]] < m[s[i][1]]:
        ans.append(s[i][0])
        m[s[i][0]] += 1
        m[s[i][1]] -= 1
    else:
        if m[s[i][0]] == 0:
            print('No')
            exit()
        if i != n-1:
            if s[i][0] in s[i+1]:
                ans.append(s[i][0])
                m[s[i][0]] += 1
                m[s[i][1]] -= 1
            else:
                ans.append(s[i][1])
                m[s[i][0]] -= 1
                m[s[i][1]] += 1
        else:
            ans.append(s[i][0])

print('Yes')
print('\n'.join(ans))

Measured memory_bytes: 85924
#include<iostream>
using namespace std;
int main(void) {
  int a, b;
  int i;
  char s[12];
  cin>>a>>b;
  cin>>s;
  for(i=0; i<a; i++) {
    if(s[i]=='\0' or '0'>s[i] or s[i]>'9') {
      cout<<"No"<<endl;
      return 0;
    }
  }
  if(s[i]=='\0' or s[i]!='-') {
    cout<<"No"<<endl;
    return 0;
  }
  for(i=i+1; i<=a+b; i++) {
    if(s[i]=='\0' or '0'>s[i] or s[i]>'9') {
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

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

int main(void){
	int q,l,r;
	cin>>q;
	vector<int> count;
	rep(i,100005){
		count.push_back(0);
	}
	reps(i,100005){
		if(sosu(i) && sosu((i+1)/2)){
			count[i]=count[i-1] + 1;
		}else{
			count[i] = count[i-1];
		}
		i++;
		count[i] = count[i-1];
	}
	rep(i,q){
		cin>>l>>r;
		cout<<count[r]-count[l-1]<<endl;
	}
	return 0;
}


Measured memory_bytes: 1144
#include<stdio.h>
     
    int main(){
    	char line[15];
      	int A1,A2,A3;
      
      	fgets(line,sizeof(line),stdin);
      	sscanf(line,"%d %d %d",&A1,&A2,&A3);
      
      	if(A1+A2+A3>=22)printf("bust");
      	else printf("win");
    }

Measured memory_bytes: 384
package main

import (
	"fmt"
)

func main() {
	var H, W, K int
	fmt.Scan(&H, &W, &K)

	a := make([]string, H)
	for i := 0; i < H; i++ {
		fmt.Scan(&a[i])
	}

	c := 0
	cake := make([][]int, H)
	for i := 0; i < H; i++ {
		cake[i] = make([]int, W)
		for j := 0; j < W; j++ {
			if a[i][j] == '#' {
				c++
				cake[i][j] = c
			} else {
				cake[i][j] = 0
			}
		}
	}

	for i := 0; i < H; i++ {
		for j := 1; j < W; j++ {
			if cake[i][j] == 0 {
				cake[i][j] = cake[i][j-1]
			}
		}

		for j := W - 2; j >= 0; j-- {
			if cake[i][j] == 0 {
				cake[i][j] = cake[i][j+1]
			}
		}
	}

	for i := 1; i < H; i++ {
		for j := 0; j < W; j++ {
			if cake[i][j] == 0 {
				cake[i][j] = cake[i-1][j]
			}
		}
	}

	for i := H - 2; i >= 0; i-- {
		for j := 0; j < W; j++ {
			if cake[i][j] == 0 {
				cake[i][j] = cake[i+1][j]
			}
		}
	}

	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			fmt.Print(cake[i][j])
			if j < W-1 {
				fmt.Print(" ")
			}
		}
		fmt.Println("")
	}
}


Measured memory_bytes: 4224
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;

constexpr int MAX_N = 1e5+100;
int dp[MAX_N];

int main(){
    int N;cin>>N;
    REP(i,MAX_N){
        dp[i] = N;
    }
    dp[0] = 0;
    REP(i,N+1){
        for(int pow=1;pow<=i;pow*=6) dp[i] = min(dp[i-pow]+1,dp[i]);
        for(int pow=1;pow<=i;pow*=9) dp[i] = min(dp[i-pow]+1,dp[i]);
    }
    cout << dp[N];
}






Measured memory_bytes: 1148
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define mod 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int n;
ll dp[100010][2];
vector<int> g[100010];
void dfs(int v,int f){
	ll a=1,b=1;
	for(auto to:g[v]){
		if(to!=f){
			dfs(to,v);
			a=(a*((dp[to][0]+dp[to][1])%mod))%mod;
			b=(b*(dp[to][0]))%mod;
		}
	}
	dp[v][0]=a;
	dp[v][1]=b;
}
int main(int argc,char** argv){
	scanf("%d",&n);
	rep(i,n-1){
		int x,y;
		scanf("%d%d",&x,&y);
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs(1,0);
	printf("%d\n",(dp[1][0]+dp[1][1])%mod);
	return 0;
}

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

int main() {
  int k;
  string s;
  cin >> k >> s;
  if(s.size()<=k) {
    cout << s << endl;
  }
  else {
    for(int i=0; i<k; i++) {
      cout << s.at(i);
    }
  cout << "..." << endl;
  }
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {

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

        String x = sc.next();

        if (x.charAt(0) == 'R') {
            if (x.charAt(1) == 'R') {
                if (x.charAt(2) == 'R') {
                    System.out.println(3);
                    return;
                }
                System.out.println(2);
                return;
            }
            System.out.println(1);
            return;
        }

        if (x.charAt(1) == 'R') {
            if (x.charAt(2) == 'R') {
                System.out.println(2);
                return;
            }
            System.out.println(1);
            return;
        }

        if (x.charAt(2) == 'R') {
            System.out.println(1);
            return;
        }

        System.out.println(0);

        sc.close();

        }

    }



Measured memory_bytes: 35616
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		char a;
		cin >> a;
		cout << (a >= 'A' && a <= 'Z' ? 'A' : 'a') << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


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

int main(){
	string s,t ;
	int n ; cin >> n ;
	int a,b ;
	a = b = 0 ;
	for(int i=0;i<n;i++){
		cin >> s >> t ;
		if(s<t) b += 3 ;
		else if(s==t){
			a++ ; b++ ;
		}else a += 3 ;
	}
	cout << a << " " << b << endl ;
}


Measured memory_bytes: 3220
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll n, time, c, t, mn = inf;
    cin >> n >> time;
    rep(i, n){
        cin >> c >> t;
        if(t > time){
            continue;
        }else{
            mn = min(mn, c);
        }
    }
    if(mn == inf){
        cout << "TLE" << endl;
    }else{
        cout << mn << endl;
    }
}

Measured memory_bytes: 256
N,A,B = map(int,input().split())
n = B - A
if n % 2 == 0:
    print(n//2)
else:
    if min(B-1,N-A) == B-1:
        print(A+(B-A-1)//2)
    else:
        print(N-B+1+(-A+B-1)//2)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    string S;
    cin >> S;
    int n = len(S);
    
    int a = 0;
    rep(i,n) a += int(S[i]-'0');
    a%9==0 ? cyes : cno;
    
    

    return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main (){
  ll n,x;
  cin >> n >> x;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  ll ans = 0;
  for(int i=1;i<n;i++){
    if(x<a[i]+a[i-1]){
      ll t = (a[i]+a[i-1])-x;
      a[i]=max(0ll,a[i]-t);
      ans+=t;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
//Author :: Soumyajit Dey (TheCodejit)
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define magic ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std; 


int main(){
	magic;
	int a,b,h;
	cin >> a >> b >> h;
	cout<< (a+b)*h/2;
}


Measured memory_bytes: 256
MOD = 1000000007

def modpow(a, p):
    res = 1
    while p > 0:
        if p % 2 == 1:
            res = res * a % MOD
        p = p // 2
        a = a * a % MOD
    return res

n = int(input())
a = sorted(list(map(int, input().split())))[::-1]

ans = 0

for i, v in enumerate(a):
    ans += modpow(2, 2 * n - i - 1) * v * (modpow(2, i) + i * modpow(2, i - 1))
    ans = ans % MOD

print(ans)


Measured memory_bytes: 91348
package main

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

var scanner = bufio.NewScanner(os.Stdin)
var rdr = bufio.NewReaderSize(os.Stdin, 0x100000)

// SplitSpace 空白で分割設定
func SplitSpace() {
	scanner.Split(bufio.ScanWords)
}

// NextLine 標準入力から１行読み込む
func NextLine() string {
	scanner.Scan()
	return scanner.Text()
}

// NextInt 標準入力から数値を一つ読み込む
func NextInt() int {
	n, _ := strconv.Atoi(NextLine())
	return n
}

// ReadLine 標準入力から長めの1行を読み込む
func ReadLine() string {
	buf := make([]byte, 0, 0x100000)
	for {
		line, isPrefix, err := rdr.ReadLine()
		if err != nil {
			panic(err)
		}
		buf = append(buf, line...)
		if !isPrefix {
			break
		}
	}
	return string(buf)
}

func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//================

func main() {
	SplitSpace()
	h := NextInt()
	res := uint(0)
	for i := 48; i >= 0; i-- {
		if (h & (1 << uint(i))) != 0 {
			for j := i; j >= 0; j-- {
				res |= 1 << uint(j)
			}
			break;
		}
	}
	fmt.Println( res )
}


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

def make_divisors(n):
  divisors = []
  for i in range(1, int(n ** 0.5) + 1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n // i)
  return divisors

a.reverse()
check = [0 for _ in range(N + 1)]
ball = []
for i in range(N):
  if check[N - i] % 2 != a[i]:
    ball.append(N - i)
    div = make_divisors(N - i)
    for d in div:
      check[d] += 1

print(len(ball))
for i in range(len(ball)):
  print(ball[i], end = "")
  if i != len(ball) - 1:
    print(" ", end = "")
  else:
    print()

Measured memory_bytes: 75772
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
using namespace std;
using namespace __gnu_pbds;
using lli = long long int;
 
template<typename key> using ordered_set = tree <key, null_type, less<key>, rb_tree_tag, tree_order_statistics_node_update>;
 
bool pri(int x) {
   for(int i = 2; i * i <= x; i++) {
	  if(x % i == 0)
		 return false;
   }
   return true;
} 
 
int main () {
   IO;
   int x;
   cin >> x;
   for(int i = x; ; i++) {
	  if(pri(i)) {
		 cout << i;
		 break;
	  }
   }
   return 0;
}

Measured memory_bytes: 256
import sys
import itertools
import queue
input = sys.stdin.readline
sys.setrecursionlimit(100000)
# mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n) 


def mat_mul(X, Y, mod):
    m = len(X)
    return [[sum(X[i][k] * Y[k][j] % mod for k in range(m)) % mod for j in range(m)] for i in range(m)]


def mat_pow(M, k, mod):
    m = len(M)
    res = [[1 if i == j else 0 for j in range(m)] for i in range(m)]
    while k > 0:
        if k & 1:
            res = mat_mul(M, res, mod)
        M = mat_mul(M, M, mod)
        k >>= 1

    return res


def main():
    L, A, B, M = read_values()
    res = 0
    D = [(0, 0)]
    for d in range(1, 20):
        l = D[-1][1]
        r = max(0, min((10 ** d - 1 - A) // B + 1, L))
        D.append((l, r))
    
    res = 0
    c = 0
    R = [0, A, 1]
    Mat = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
    for d in range(1, 20):
        num = D[d][1] - D[d][0]

        MM = [[10 ** d, 0, 0], [1, 1, 0], [0, B, 1]]
        Mat = mat_mul(Mat, mat_pow(MM, num, M), M)

    X = sum(R[i] * Mat[i][0] % M for i in range(3)) % M

    print(X)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3952
<?php
// Your code here!
//積が奇数なら Odd と、 偶数なら Even と出力せよ。

    $input = trim(fgets(STDIN));
    $input = explode(" ",$input);
    $total = $input[0]*$input[1];
    
    if($total %2 == 0){
        echo "Even";
    }else{
        echo "Odd";
    }
    





?>


Measured memory_bytes: 16200
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define REPA(x, v) for(auto&& x:v)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(v.rbegin(),v.rend())
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll K;
    cin >> K;
    vector<ll> X(1000005);
    X[0] = 7 % K;
    if(K==1||K==7){
        pr(1);
        return 0;
    }
    Rep(i,1,1000005){
        X[i] = (X[i-1]*10+(7%K))%K;
        if(X[i] == 0){
            pr(i+1);
            return 0;
        }
    }
    pr(-1);
}

Measured memory_bytes: 11168
import numpy as np
import time
import random

H, W, K = map(int, input().split())
s = [np.array(list(input()), dtype=np.int32) for _ in range(H)]

start = time.time()

# 2**(H-1)通り試す
# 事前に各行のcumsumを取っておくと多分はやい
s2 = [np.cumsum(row, dtype=np.int32) for row in s]

mi = 10 ** 9
seed = [0] * 1000 + [1] * 1000
selected = []

# 全部0
ls = [0]*(H-1)
# numは横線の数
num = 1
tmp = 0

s3 = np.zeros((num, W))
s3[0] = s2[0]
cnt = 0
for i in range(H - 1):
    if ls[i] == 0:
        s3[cnt] += s2[i + 1]
    else:
        cnt += 1
        s3[cnt] = s2[i + 1]
s3 = s3.T

hosei = np.zeros(num)
for w in range(W):
    if np.max(s3[:][w] - hosei) > K:
        tmp += 1
        if w != 0:
            hosei = s3[:][w - 1]
        else:
            tmp = 10 ** 9
if mi > tmp:
    mi = tmp


# 全部1
ls = [1]*(H-1)
# numは横線の数
num = H
tmp = num - 1

s3 = np.zeros((num, W))
s3[0] = s2[0]
cnt = 0
for i in range(H - 1):
    if ls[i] == 0:
        s3[cnt] += s2[i + 1]
    else:
        cnt += 1
        s3[cnt] = s2[i + 1]
s3 = s3.T

hosei = np.zeros(num)
for w in range(W):
    if np.max(s3[:][w] - hosei) > K:
        tmp += 1
        if w != 0:
            hosei = s3[:][w - 1]
        else:
            tmp = 10 ** 9
if mi > tmp:
    mi = tmp
    
while time.time() - start < 1.7:
    t = random.sample(seed, k=H - 1)
    if t in selected:
        continue
    selected.append(t)
    ls = t
    # numは横線の数
    num = sum(ls) + 1
    tmp = num - 1
    
    s3 = np.zeros((num, W))
    s3[0] = s2[0]
    cnt = 0
    for i in range(H - 1):
        if ls[i] == 0:
            s3[cnt] += s2[i + 1]
        else:
            cnt += 1
            s3[cnt] = s2[i + 1]
    s3 = s3.T
    
    hosei = np.zeros(num)
    for w in range(W):
        if np.max(s3[:][w] - hosei) > K:
            tmp += 1
            if w != 0:
                hosei = s3[:][w - 1]
            else:
                tmp = 10 ** 9
    if mi > tmp:
        mi = tmp
z = 0
for row in s:
    z += np.sum(row)
if z <= K:
    mi = 0
print(mi)




Measured memory_bytes: 20024
#include <cstdlib>
#include <iostream>


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

  int a, b, c;
  std::cin >> a >> b >> c;
  std::cout << (b - a == c - b ? "YES" : "NO") << std::endl;

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int a,p;
    cin >> a >> p;
    cout << (a*3+p)/2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
long long counter=0;
long long n;
cin>>n;
long long d[2*n]={};
for(long long i=0; i<2*n; i++){
cin>>d[i];}
sort(d,d+2*n);
for(long long i=0; i<2*n; i=i+2){
counter+=d[i];}
cout<<counter<<endl;}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "C"
int cnt[50][256];
string s;
int n;
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    cin>>n;
    FFOR(i, 0, n){
        cin>>s;
        for(char c: s) cnt[i][c]++;
    }
    FFOR(i, 1, n) FOR(c, 'a', 'z') cnt[0][c]=min(cnt[0][c], cnt[i][c]);
    FOR(i, 'a', 'z') FOR(j, 1, cnt[0][i]) putchar(i);
}

Measured memory_bytes: 384
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    ll N, K; scanf("%lld%lld", &N, &K);
    vector<ll> A(N);
    for(int i=0; i<N; i++) scanf("%lld", &A[i]);

    auto f = [&](ll x) {
        ll s1 = 0;
        for(int i=0; i<N; i++) {
            s1 += (A[i] / x) - (A[i] % x == 0);
        }
        return s1 <= K;
    };

    ll ub = (ll)1e9 + 10, lb = 0;
    while(ub - lb > 1) {
        ll mid = (ub + lb) / 2;
        auto pr = f(mid);
        if(pr) ub = mid;
        else lb = mid;
    }

    ll x = ub;
    printf("%lld\n", x);
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

int main()
{
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  cout << h*w-h*b-w*a+a*b << endl;
  return 0;
}


Measured memory_bytes: 384
#if 1

#include <bits/stdc++.h>
using namespace std;

int main ()
{
	long long a,b;
	cin >> a >> b;
	cout << (((a+1) / 2 % 2 ) ^ (a % 2 == 1 ? 0 : a) ^ a ^ ((b+1) / 2 % 2) ^ (b % 2 == 1 ? 0 : b));
}

#endif // 1++

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define msg(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define pri(a) cout << a << endl;

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

  ll n,b,ans=0;
  ll a[3][3];

  rep(i,3){
    rep(j,3){
      cin >> a[i][j];
    }
  }

  cin >> n;
  rep(i,n){
    cin >> b;
    rep(k,3){
      rep(j,3){
        if(b==a[k][j]){
          a[k][j] = 0;
        }
      }
    }
  }

  rep(i,3){
    rep(j,3){
      ans += a[i][j];
    }
    if(ans==0){
      pri("Yes");
      return 0;
    }
    ans = 0;
  }

  rep(i,3){
    rep(j,3){
      ans += a[j][i];
    }
    if(ans==0){
    pri("Yes");
      return 0;
    }
    ans = 0;
  }

  if(a[0][0]+a[1][1]+a[2][2]==0){
    pri("Yes");
    return 0;
  }

  if(a[0][2]+a[1][1]+a[2][0]==0){
    pri("Yes");
    return 0;
  }

  pri("No");
}

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

int main()
{
	char a[4],b[4];
	cin >> a >> b;
	if (a[0] == b[2]&&a[1]==b[1]&&a[2]==b[0])
    {
      cout << "YES";
    }
	else
    {
		cout << "NO";
    }
    return 0;
}


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

int main()
{
    char in;
    cin >> in;
    char out = in + 1;
    cout << out;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<queue>
#define LL long long
#define A_i ((A>>i)&1)
#define B_i ((B>>i)&1)
using namespace std;
inline LL read( )
{
  LL sum=0;char c=getchar( );bool f=0;
  while(c<'0'||c>'9') {if(c=='-') f=1;c=getchar( );}
  while(c>='0'&&c<='9') {sum=sum*10+c-'0';c=getchar( );}
  if(f) return -sum;
  return sum;
}
inline LL query(LL l1,LL r1,LL l2,LL r2)
{
  return r1<l2?r1-l1+1+r2-l2+1:r2-l1+1;
}
int main( )
{
  LL A=read( ),B=read( );
  if(A==B) {puts("1");return 0;}
  int i,j;LL T;
  for(i=60;i>=0;i--)
    if(B_i&&!A_i)
      {
	T=1LL<<i;
	for(j=i-1;j>=0;j--)
	  if((B>>j)&1) break;
	cout<<T-A+query(T,T+(1LL<<(j+1))-1,T+A,(T<<1)-1);
	return 0;
      }
    else 
      B&=~(1LL<<i),A&=~(1LL<<i);
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();

            if((s.Contains('N') && s.Contains('S') == false) || (s.Contains('S') && s.Contains('N') == false)) {
                    Console.WriteLine("No");
                    Console.Out.Flush();
                    return;
            }


            if ((s.Contains('E') && s.Contains('W') == false) || (s.Contains('W') && s.Contains('E') == false)) {
                Console.WriteLine("No");
                Console.Out.Flush();
                return;
            }

            Console.WriteLine("Yes");
            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13268