akhauriyash/Code-Regression huggingface dataset:
from itertools import product

A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]
bingo = [[0] * 3 for _ in range(3)]
for b in B:
    for i, j in product(range(3), repeat=2):
        if A[i][j] == b:
            bingo[i][j] = 1
            break
flag = False
for i in range(3):
    if sum(bingo[i][j] for j in range(3)) == 3:
        flag = True
for j in range(3):
    if sum(bingo[i][j] for i in range(3)) == 3:
        flag = True
if sum(bingo[i][i] for i in range(3)) == 3 or sum(bingo[i][2-i] for i in range(3)) == 3:
    flag = True
print('Yes' if flag else 'No')

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

int main(void)
{
	double x1,x2,y1,y2;
	scanf("%lf %lf %lf %lf", &x1,&y1,&x2,&y2);
	printf("%lf\n",sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)));
	return 0;
}



Measured memory_bytes: 2756
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;



int main(){
    cin>>N>>M;
    cout<<(N == M ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

bool dp[100100][100];
vector<pii> g[100100];

int main(){
  int v,e,w;
  cin >> v >> e >> w; w*=-1;
  
  vector<int> deg(v,0);
  for(int i=0;i<e;i++){
    int s,t,c;
    cin >> s >> t >> c;
    g[s].push_back(pii(t,c));
    deg[t]++;
  }

  vector<int> to;
  queue<int> q;
  for(int i=0;i<v;i++){
    if(deg[i]==0)q.push(i);
  }

  while(q.size()){
    int x = q.front(); q.pop();
    to.push_back(x);
    for(int i=0;i<(int)g[x].size();i++){
      int u = g[x][i].first;
      deg[u]--;
      if(deg[u]==0)q.push(u);
    }
  }

  memset(dp,0,sizeof(dp));
  for(int i=0;i<v;i++)dp[i][0] = 1;

  int ans = -1;
  for(int i=0;i<v;i++){
    int x = to[i];
    for(int k=0;k<w;k++){
      if(!dp[x][k])continue;

      for(int j=0;j<(int)g[x].size();j++){
	int u = g[x][j].first, cost = k+g[x][j].second;
	if(cost<w){
	  dp[u][cost] = true;
	  ans = max(ans,cost);
	}
      }
    }
  }

  if(ans<0)cout << "NA" << endl;
  else cout << ans - w << endl;
}


Measured memory_bytes: 21788
#include <iostream>

#include <queue>

using namespace std;

int a[101][101];

int n=0;

int found[101];

int ended[101];

int aaa(int i, int time);

int main(){

  for(int i=0; i<101; i++)

    for(int j=0; j<101; j++)

      a[i][j]=0;

  int u, k, v;

  cin>>n;

  for(int i=0; i<n; i++){

    cin>>u>>k;

    for(int j=0; j<k; j++){

      cin>>v;

      a[u][v]=1;

    }

  }

  int time=0;

  for(int i=0; i<101; i++){

    found[i]=0;

    ended[i]=0;

  }

  for(int i=1; i<n+1; i++){

    if(found[i]>0)

      continue;

    time++;

    found[i]=time;

    time=aaa(i, time);

    ended[i]=time;

  } 

  for(int i=1; i<n+1; i++)

    cout<<i<<' '<<found[i]<<' '<<ended[i]<<endl;

}

int aaa(int i, int time){

  for(int k=1; k<n+1; k++){

    if(a[i][k]==1&&found[k]==0){

      time++;

      found[k]=time;

      time=aaa(k, time);

      ended[k]=time;

    } 

  }

  time++;

  return time;

}

Measured memory_bytes: 1204
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1000000007LL;
int main() {
	int N;
	cin >> N;
	if (N == 0) {
		cout << 0 << endl;
		return 0;
	}
	vector<int> bit;
	while (N) {
		if (N > 0) {
			bit.push_back(N % 2);
			N /= 2;
			N *= -1;
		}
		else {
			bit.push_back((-N) % 2);
			N = (-N + 1) / 2;
		}
	}
	for (int i = bit.size() - 1; i >= 0; i--) cout << bit[i];
	cout << endl;
}

Measured memory_bytes: 256
def sum_digits_string(str1):
    sum_digit = 0
    for x in str1:
        if x.isdigit() == True:
            z = int(x)
            sum_digit = sum_digit + z

    return sum_digit
     
n=input()
if sum_digits_string(n)%9==0:
    print("Yes")
else:
    print("No")
  


Measured memory_bytes: 9296
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll n = in();
    vector<ll>v(n), c(n);
    REP(i, n)v[i] = in();
    REP(i, n)c[i] = in();
    ll ans = 0;
    REP(i, n)ans += max(v[i] - c[i], 0LL);
    cout << ans << endl;
}

Measured memory_bytes: 256
/**
 * @brief ユーザ定義リテラル
 * @author えびちゃん
 */

#ifndef H_int_literals
#define H_int_literals

#include <cstddef>
#include <cstdint>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

#endif  /* !defined(H_int_literals) */

#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <utility>

bool pal(std::string const& s) {
  return s == std::string(s.rbegin(), s.rend());
}

int main() {
  char buf[128];
  scanf("%s", buf);
  std::string s = buf;
  size_t n = s.length();

  if (pal(s) && pal(s.substr(0, (n-1)/2)) && pal(s.substr((n+3)/2-1)))
    return puts("Yes"), 0;

  puts("No");
}


Measured memory_bytes: 256
s = input()

for i in range(len(s)):
    if i % 2 == 0:
        if s[i] != "h":
            print("No")
            exit()
    else:
        if s[i] != "i":
            print("No")
            exit()
    if i == len(s) - 1:
        if i % 2 == 1:
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 38512
import numpy as np

N, W = map(int, input().split())
a = [list(map(int,input().split())) for _ in range(N)]
vmax = sum([a[i][1] for i in range(N)])
INF = float('inf')
dp = np.full(vmax+1, INF)
dp[0] = 0

for i in range(N):
  w, v = a[i-1]
  dp[v:] = np.minimum(dp[v:], dp[:-v]+w)
print(max([i for i in range(vmax+1) if dp[i] <= W]))


Measured memory_bytes: 29532
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
    int c[3][3] = {0};

    for(int i = 0; i < 3; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            cin >> c[i][j];
        }
    }

    int max = 0;

    for(int i = 0; i < 3; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            if (max < c[i][j])
            {
                max = c[i][j];
            }
        }
    }
    int a[3] = {0};
    int b[3] = {0};
    bool check = true;

    for(int i = 0; i <= 100; i++)
    {
        for(int j = 0; j <= 100; j++)
        {
            for(int k = 0; k <= 100; k++)
            {
                check = true;

                a[0] = i, a[1] = j, a[2] = k;
                b[0] = c[0][0] - a[0];
                b[1] = c[1][1] - a[1];
                b[2] = c[2][2] - a[2];

                for(int x = 0; x < 3; x++)
                {
                    for(int y = 0; y < 3; y++)
                    {
                        if (c[x][y] != a[x] + b[y])
                        {
                            check = false;
                        }
                    }
                }

                if (check)
                {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
move_list = [0]

for i in range(1,n):
    if h[i-1] >= h[i]:
        move_list.append(move_list[i-1]+1)
    else:
        move_list.append(0)

print(max(move_list))


Measured memory_bytes: 14252
N = int(input())
n = list(input() for i in range(N))
a= 0
b=0
c=0
d=0
for i in n:
    if i == "AC":
        a = a+1
    elif i=="WA":
        b = b+1
    elif i=="TLE":
        c = c+1
    elif i== "RE":
        d = d+1
print("AC x", a)
print("WA x", b)
print("TLE x", c)
print("RE x", d)

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

int main(){
  int k,u=0;
  cin >> k;
  for(int i=1;i<=k;i++){
    u=(u*10+7)%k;
    if(u%k==0){
      cout << i;
      return 0;
    }
  }
  cout << -1;
  return 0;
}


Measured memory_bytes: 3584
//ABC145A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <numeric>
using namespace std;

int main(){
	int r;
	cin >> r;
	int ans = pow(r,2);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    if (b==0) return (int)1;
    int x = p(a, b>>1);
    if (b & 1) return m(x*m(a*x));
    return m(x*x);
}
signed main(){
    fast();
    int a, b, k;
    cin >> k;
    cin >> a >> b;
    int div = b/k;
    if(div*k <= b && div*k >= a){
        puts("OK");
    }
    else puts("NG");
}

Measured memory_bytes: 3596
n, k = map(int, input().split())
arr = list(map(int, input().split()))

MAX = 10**9

dp = [MAX for i in range(n)]
dp[0] = 0

for i in range(n):
    for j in range(i + 1, i + k + 1):
        if j < n:
            dp[j] = min(dp[j], dp[i] + abs(arr[j] - arr[i]))

print(dp[-1])


Measured memory_bytes: 56544
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  vector<int> A(5); cin >> A;
  int v = 10;
  int sum = 0;
  for (int i = 0; i < 5; ++i) {
    int a = A[i] % 10;
    if (a == 0) a = 10;
    v = min(v, a);
    sum += A[i] - a + 10;
  }
  cout << sum + v - 10<< endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   int n;
   cin >> n;
   map<string, int> mp;
   rep(i, 0, n) {
      string s;
      cin >> s;
      mp[s]++;
   }
   int mx = 0;
   for (auto x : mp) {
      chmax(mx, x.second);
   }
   for (auto x : mp) {
      if (x.second == mx) cout << x.first << endl;
   }
   return 0;
}

Measured memory_bytes: 25216
#include <iostream>
#include <string>
#include <cstdlib>

int decode( std::string str )
{
	int s = 0;
	for ( int i = 0; i < str.size(); ++i ) {
		int k = 1;
		if ( str[i] == 'm' || str[i] == 'c' || str[i] == 'x' || str[i] == 'i' ) {
			if ( i != 0 && isdigit(str[i-1]) == true ) {
				k = str[i-1] - '0';
			}
			switch(str[i]) { 
				case 'm':
					s += k * 1000;
					break;
				case 'c':
					s += k * 100;
					break;
				case 'x':
					s += k * 10;
					break;
				case 'i':
					s += k;
					break;
			}
		}
	}
	return s;
}

std::string encode( int a ) {
	std::string str = "";
	char m[5] = "ixcm";

	for ( int i = 0; i < 4; ++i ) {
		int c = a % 10;
		switch(c) {
			case 0:
				break;
			case 1:
				str = m[i] + str;
				break;
			default:
				str = std::to_string(c) + m[i] + str;
				break;
		}
		a /= 10;
	}

	return str;
}

int main()
{
	int n;

	std::cin >> n;

	for ( int i = 0; i < n; ++i ) {
		std::string buf;
		std::cin >> buf;
		int a = decode(buf);
		std::cin >> buf;
		int b = decode(buf);

		int c = a + b;

		std::cout << encode(c) << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3232
def numba_compile(numba_config):
    import os, sys
    if sys.argv[-1] == "ONLINE_JUDGE":
        from numba import njit
        from numba.pycc import CC
        cc = CC("my_module")
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature)(func)
            cc.export(func.__name__, signature)(func)
        cc.compile()
        exit()
    elif os.name == "posix":
        exec(f"from my_module import {','.join(func.__name__ for func, _ in numba_config)}")
        for func, _ in numba_config:
            globals()[func.__name__] = vars()[func.__name__]
    else:
        from numba import njit
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature, cache=True)(func)
        print("compiled!", file=sys.stderr)


import sys
import numpy as np

def solve(N, A, UV):
    G = [[0] * 0 for _ in range(N)]
    for i in range(N-1):
        u, v = UV[i]
        G[u].append(v)
        G[v].append(u)
    L = [A[0]]
    Ans = np.zeros(N, dtype=np.int64)
    stack = np.zeros((202020, 5), dtype=np.int64)  # 頂点、状態、見ている子のインデックス、行った行動*2
    idx_stack = 0
    while idx_stack >= 0:
        v, state, idx_Gv, idx_L, old = stack[idx_stack]
        idx_stack -= 1
        if state == 0:
            Ans[v] = len(L)
        if state == 2:
            if idx_L == -1:
                del L[-1]
            else:
                L[idx_L] = old
        Gv = G[v]
        if len(Gv) == idx_Gv:
            continue
        u = Gv[idx_Gv]
        G[u].remove(v)
        Au = A[u]
        if Au > L[-1]:
            L.append(Au)
            idx_stack += 1
            stack[idx_stack] = (v, 2, idx_Gv + 1, -1, -1)
            idx_stack += 1
            stack[idx_stack] = (u, 0, 0, -1, -1)
            continue
        else:
            idx_L = np.searchsorted(L, Au)
            old = L[idx_L]
            L[idx_L] = Au
            idx_stack += 1
            stack[idx_stack] = (v, 2, idx_Gv + 1, idx_L, old)
            idx_stack += 1
            stack[idx_stack] = (u, 0, 0, -1, -1)
            continue
    return Ans

numba_compile([
    [solve, "i8[:](i8,i8[:],i8[:,:])"]
])

def main():
    input = sys.stdin.buffer.readline
    N = int(input())
    A = np.array(input().split(), dtype=np.int64)
    UV = np.array(sys.stdin.buffer.read().split(), dtype=np.int64).reshape(N-1, 2) - 1
    Ans = solve(N, A, UV)
    print("\n".join(map(str, Ans.tolist())))

main()


Measured memory_bytes: 89032
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

typedef pair<int,int> P;


int main(){
	int n,m;
	int a[100000];
	int b[100000];
	vector<P> v;

	scanf("%d %d", &n,&m);
	for(int i=0;i<m;i++){
		scanf("%d %d", &a[i], &b[i]);
		a[i]--;
		b[i]--;
		v.push_back(make_pair(b[i],a[i]));
	}

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

	int ans = 0;
	int last = -1;
	for(int i=0;i<m;i++){
		if(v[i].second>last){
			last = v[i].first-1;
			ans++;
		}
	}

	printf("%d\n", ans);

	return 0;
}


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

using namespace std;

int main()
{
	int ans = 1;
	int x;
	cin>>x;
	if(x == 1) {
        cout<<1<<endl;
        return 0;
	}
	for(int i=2; i<=sqrt(x); i++) {
		for(int j=2; ;j++) {
			int y = pow(i, j);
			if (y > x)
				break;
			if(y > ans)
				ans = y;
		}
	}
	cout<<ans<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

struct RollingHash{
  ll base, mod;
  vector<ll> hashed, power;
  RollingHash(){ base = 9973ll, mod = 1000000007ll; }
  void init(const int* s, int sz)
  {
    hashed.assign(sz + 1, 0);
    power.assign(sz + 1, 0);
    
    hashed[0] = 0ll;
    power[0] = 1ll;
    
    for(int i = 0; i < sz; i++){
      hashed[i+1] = (hashed[i] + s[i]) * base;
      power[i+1] = power[i] * base;
    }
  }
  ll get(int l, int r)
  {
    return hashed[r] - hashed[l]*power[r-l];
  }
};

int decode(char c, int shift)
{
  int bit = 0;
  if(c == '+') bit = 62;
  else if(c == '/') bit = 63;
  else if('A' <= c && c <= 'Z') bit = c - 'A';
  else if('a' <= c && c <= 'z') bit = c - 'a' + 26;
  else if('0' <= c && c <= '9') bit = c - '0' + 52;
  return (bit >> shift) & 1;
}

void Reverse(int array[101][101], int w, int h)
{
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w/2; j++) swap(array[i][j], array[i][w-1-j]);
  }
}

void Rotate(int array[101][101], int w, int h)
{
  int carray[101][101];
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++) carray[i][j] = array[i][j];
  }
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++) array[i][j] = carray[w-1-j][i];
  }
}

RollingHash imghash[1000];
RollingHash ptnhash[100];

int main()
{
  int w, h, p;
  int image[1001][1001];
  int pattern[101][101];
  while(cin >> w >> h >> p, w || h || p){
    for(int i = 0; i < h; i++){
      string data; cin >> data;
      for(int j = 0; j < w; j++){
	image[i][j] = decode(data[j/6], 5-j%6);
      }
      imghash[i].init(image[i], w);
    }
    for(int i = 0; i < p; i++){
      string data; cin >> data;
      for(int j = 0; j < p; j++){
	pattern[i][j] = decode(data[j/6], 5-j%6);
      }
      ptnhash[i].init(pattern[i], p);
    }
    int ans = 0;
    map<vector<int>, bool> mp;
    for(int l = 0; l < 8; l++){
      if(l == 4) Reverse(pattern, p, p);
      Rotate(pattern, p, p);
      for(int i = 0; i < p; i++) ptnhash[i].init(pattern[i], p);
      vector<int> vec;
      for(int i = 0; i < p; i++) vec.push_back(ptnhash[i].get(0, p));
      if(mp.count(vec) == 1) continue;
      mp[vec] = true;
       for(int i = 0; i <= h-p; i++){
	for(int j = 0; j <= w-p; j++){
	  bool same = true;
	  for(int k = 0; k < p; k++){
	    if(imghash[i+k].get(j, j+p) != ptnhash[k].get(0, p)){
	      same = false;
	      break;
	    }
	  }
	  if(same) ans++;
	}
      }
    }
    cout << ans << endl;
  }

  return 0;
}

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

long long A[100005];
long long B[100005];
long long C[100005];

int main(){
    int cntB = 0;
    int cntC = 0;

    int N;
    scanf("%d", &N);
    for(int i = 0; i < N; i ++){
        scanf("%lld", &A[i]);
        if(A[i]<0){
            B[cntB++] = A[i];
        }else{
            C[cntC++] = A[i];
        }
    }

    sort(B, B+cntB);
    sort(C, C+cntC);

    if(cntB && cntC){
        long long sum = 0;
        for(int i = 0; i < N; i ++){
            sum += abs(A[i]);
        }
        printf("%lld\n", sum);

        // use B[0] to eat up all C except the last
        for(int i = 0; i < cntC-1; i ++){
            printf("%lld %lld\n", B[0], C[i]);
            B[0] -= C[i];
        }

        // use C[cntC-1] to eat up all B except the first
        for(int i = 1; i < cntB; i ++){
            printf("%lld %lld\n", C[cntC-1], B[i]);
            C[cntC-1] -= B[i];
        }

        // then use B[0] to eat up C[cntC-1]
        printf("%lld %lld\n", C[cntC-1], B[0]);

        return 0;
    }

    if(cntB){
        // all elements are negative
        // use B[N-1] to eat up everything
        long long sum = B[N-1];
        for(int i = 0; i < N-1; i ++){
            sum += abs(B[i]);
        }

        printf("%lld\n", sum);
        for(int i = 0; i < N-1; i ++){
            printf("%lld %lld\n", B[N-1], B[i]);
            B[N-1] -= B[i];
        }

        return 0;
    }

    if(cntC){
        // all elements are negative
        // use C[0] to eat up everything
        long long sum = -C[0];
        for(int i = 1; i < N; i ++){
            sum += abs(C[i]);
        }

        printf("%lld\n", sum);
        for(int i = 1; i < N-1; i ++){
            printf("%lld %lld\n", C[0], C[i]);
            C[0] -= C[i];
        }

        printf("%lld %lld\n", C[N-1], C[0]);
        return 0;
    }

    return 0;
}


Measured memory_bytes: 3456
program sample
    implicit none
  
    integer(8) :: i,j,m,n,l,r,d
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) n
    allocate(x(n))
    read(*,*)x
    m=0
    do i=1,n,2
        if (mod(x(i),2)==1)then
            m=m+1
        end if
    end do
  
    write(*,*) m  
    stop
end program sample
  


  



Measured memory_bytes: 2860
#include <iostream>
#include <vector>
using namespace std;
const long long INF = 1e18;
int main()
{
    int n;
    cin >> n;
    vector<long long> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    long long ans = 1;
    for(int i = 0; i < n; i++){ 
        if(ans <= INF/a[i]){
            ans *= a[i];
        } else {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}
//Saw the solution video


Measured memory_bytes: 4036
#include <iostream>
using namespace std;
int main()
{
    string w;
    cin >> w;
    if(w == "Sunny"){
       cout << "Cloudy" << endl;
    }else if(w == "Cloudy"){
       cout << "Rainy" << endl;
    }else{
       cout << "Sunny" << endl;
    }
    return(0);
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    string a,b,c; cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2] << endl; return 0;
}


Measured memory_bytes: 256
<?php
list($numA, $numB) = explode(' ', trim(fgets(STDIN)));
echo sprintf("%s %s %s", 'a', compare($numA, $numB), 'b'), PHP_EOL;
    
function compare($numA, $numB)
{
    if (max($numA, $numB) == min($numA, $numB)) {
        return "==";
    } else if (max($numA, $numB) == $numA) {
        return ">";
    } else {
        return "<";
    }
}
 

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


int get(int n)
{
    int sum = 0 ;
    while(n)
    {
        sum += n%10 ;
        n/= 10 ;
    }
    return sum ;
}

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

    int sum = 0 ;

    for(int i = 1 ; i <= n ; i++)
    {
        int nm = get(i) ;
       //

       // cout << nm << endl ;
        if(nm >= a && nm <= b)
            sum += i ;
    }
    cout << sum << endl ;
}


Measured memory_bytes: 256
#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
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
struct point {int x; int y;};
bool operator <(const point& a, const point& b) {return std::tie(a.y, a.x) > std::tie(b.y, b.x);}

int N;
point points[200005];
int UL[200005]; int UR[200005];
int DL[200005]; int DR[200005];
int two[200005];

const int mod = 998244353;

void add(int &ans, int dod) {
    ans = (ans % mod + dod % mod) % mod;
}

int mul(long long a, long long b, long long c, long long d) {
    long long a1 = (two[a] % mod + mod - 1) % mod;
    long long b1 = (two[b] % mod + mod - 1) % mod;
    long long c1 = (two[c] % mod + mod - 1) % mod;
    long long d1 = (two[d] % mod + mod - 1) % mod;
    return (a1 * b1) % mod * c1 % mod * d1 % mod;
}

int mul(long long a, long long b, long long c) {
    long long a1 = (two[a] % mod + mod - 1) % mod;
    long long b1 = (two[b] % mod + mod - 1) % mod;
    long long c1 = (two[c] % mod + mod - 1) % mod;
    return (a1 * b1) % mod * c1 % mod;
}

int mul(long long a, long long b) {
    long long a1 = (two[a] % mod + mod - 1) % mod;
    long long b1 = (two[b] % mod + mod - 1) % mod;
    return (a1 * b1) % mod;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> N;
    for(int i = 1; i <= N; i++)
        cin >> points[i].x >> points[i].y;

    sort(points + 1, points + N + 1);

    ordered_set s;

    int j = 1;
    for(int i = 1; i <= N; i++) {
        while(j <= N && points[i].y == points[j].y)
            s.insert(points[j++].x);
        int ord = s.order_of_key(points[i].x);
        UL[i] = ord;
        UR[i] = s.size() - ord - 1;
    }

    s.clear();
    j = N;
    for(int i = N; i >= 1; i--) {
        while(j >= 1 && points[i].y == points[j].y)
            s.insert(points[j--].x);
        int ord = s.order_of_key(points[i].x);
        DL[i] = ord;
        DR[i] = s.size() - ord - 1;
    }

    two[0] = 1;
    for(int i = 1; i <= N; i++)
        two[i] = (two[i - 1] * 2LL) % mod;

    int ans = 0;
    for(int i = 1; i <= N; i++) {
//        cerr << "(" << points[i].x << ", " << points[i].y << ")" << endl;
//        cerr << UL[i] << " " << UR[i] << endl;
//        cerr << DL[i] << " " << DR[i] << endl;
//        add(ans, ((two[UL[i]] + mod - 1) * 1LL * (two[DR[i]] + mod - 1)) % mod);
        add(ans, mul(UL[i], DR[i]));
        add(ans, mul(DL[i], UR[i]));
        add(ans, mul(UL[i],UR[i], DR[i]));
        add(ans, mul(UR[i],DR[i], DL[i]));
        add(ans, mul(DR[i],DL[i], UL[i]));
        add(ans, mul(DL[i],UL[i], UR[i]));

        add(ans, mul(DL[i], UL[i],DR[i], UR[i]));

        add(ans, two[N - 1]);
//        cerr << " := " << ans << endl << endl;
    }
    cout << ans << endl;
}
//int UL[200005]; int UR[200005];
//int DL[200005]; int DR[200005];

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

int main()
{
   int X,N;
   cin>>X>>N;
   unordered_set<int> s;
   for(int i=0;i<N;++i) {
       int x;cin>>x,s.insert(x);
   }
   int mins=1e9,ans;
   for(int i=-105;i<=105;++i){
       int x=abs(i-X);
       if(!s.count(i)){
           if(mins>x){
               mins=x;
               ans=i;
           }
       }
   }
   cout<<ans<<"\n";
}

Measured memory_bytes: 3640
/*
      author : nishi5451
      created: 11.08.2020 00:41:10
*/

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

int group(int n){
    switch (n){
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12: return 1;
        case 4:
        case 6:
        case 9:
        case 11: return 2;
        case 2: return 3;
    }
}

int main(){
    int x,y;
    cin >> x >> y;
    if(group(x) == group(y)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>


/* ---------- Namespace ---------- */

using namespace std;


/* ---------- Type Abbreviation ---------- */

template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

using ll = long long;
using PL = P<ll, ll>;
using PS = P<string, ll>;

using VI = V<int>;
using VVI = V<VI>;
using VL = V<ll>;
using VVL = V<VL>;
using VS = V<string>;
using VB = V<bool>;
using VVB = V<VB>;
using VPL = V<PL>;
using VPS = V<PS>;

#define fst first
#define snd second


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)


/* ---------- container ---------- */

#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define GSORT(c) sort(ALL(c), greater<decltype((c).front())>())
#define SZ(x) (LL((x).size()))


/* ---------- repetition ---------- */

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// Usual REP runs from 0 to n-1 (R: n to 0)
// Natural REP runs from 1 to n (R: n to 1)


/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};


/* ---------- Debug ---------- */
#define GET_VAR_NAME(variable) #variable

#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

template <typename T>

void testVector(T& v) {
  REP(i, SZ(v)) {
    cout << i << ":" << v << endl;
  }
}


/* ^^^^^^^^^^^^^^^ Settting Part ^^^^^^^^^^^^^^^ */

/* ---------- Variances ---------- */

int A, B, X;

/* ---------- Functions ---------- */


/* ---------- Main Function ---------- */

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

  cin >> A >> B >> X;
  if (X >= A && X <= A + B) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
char ch[21];
char ring[21];
int n,i,j,count=0;
scanf("%s\n%d\n",&ch,&n);
for(i=0;i<n;i++){
scanf("%s\n",&ring);
for(j=0;j<10;j++){
ring[10+j]=ring[j];
}
ring[10+j]='\0';
if(strstr(ring,ch)) count++;
}
printf("%d\n",count);
return 0;
}

Measured memory_bytes: 608
using System;
class Program
{
	static void Main(string[] args)
	{
        int a = int.Parse(Console.ReadLine());
        int a500 = a / 500;
        int b = a % 500;
        int a5 = b / 5;
        Console.WriteLine((a500*1000)+(a5*5));
    }
}

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

int main(){
    int n;
    cin>>n;
    long long l[88];
    l[0]=2;
    l[1]=1;
    if(n==1)cout<<1<<endl;
    else{
        for(int i=2;i<=n;i++){
            l[i]=l[i-1]+l[i-2];
        }
        cout<<l[n]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int main()
{ 
    int k,n,a,b,flag=0;
    cin >> k;
    cin >> a >> b;
    if(k!=0)
        n=a/k;
    else
        n=0;
    for(int i=n;i*k<=b;i++)
    {
        if(i*k<=b&&i*k>=a)
            {
                flag = 1;
                break;
            }
    }
    if(flag)
        cout << "OK" << endl;
    else
        cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3620
from collections import deque

N=int(input())
G=[{} for _ in range(N+1)]

for i in range(N-1):
  u,v,w=map(int,input().split())
  G[u][v]=w
  G[v][u]=w
  
for i in range(1,N+1):
  if len(G[i])==1:
    start=i
    break

def bfs(s):
    seen = [0 for i in range(N+1)]
    d = [0 for i in range(N+1)]
    todo = deque([])
    now = s
    seen[now]=1
    todo.append(now)
    while 1:
      if len(todo)==0:break
      a = todo.popleft()
      for b in G[a]:
        if seen[b] == 0:
          seen[b] = 1
          todo.append(b)
          d[b] += d[a] + G[a][b]
    return d

d = bfs(start)
for i in range(1,N+1):
  d_ = d[i]
  if d_ % 2 == 0:print(0)
  else:print(1)

Measured memory_bytes: 49532
def input_from_console():
    a, b, c, k = map(int, input().split())
    return a, b, c, k


def solve(a, b, c, k):
    sum = 0
    if k < a:
        return k
    else:
        k = k - a
        sum = a
    if k < b:
        return sum
    else:
        k = k - b
    sum -= k
    return sum

def main():
    a, b, c, k = input_from_console()
    print(solve(a, b, c, k))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()


Measured memory_bytes: 9204
from sys import stdin


def main():
    K, S = [int(x) for x in stdin.readline().rstrip().split()]
    result = 0
    for X in range(S + 1):
        if K < X:
            break
        for Y in range(S + 1):
            if K < Y:
                break
            Z = S - (X + Y)
            if Z < 0:
                break
            if X <= K and Y <= K and Z <= K:
                result += 1
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
import sys
input = sys.stdin.readline
N, M, X, Y = map(int, input().split())
li_x = list(map(int, input().split()))
li_y = list(map(int, input().split()))
li_x.append(X)
li_y.append(Y)
li_x.sort()
li_y.sort()
if li_x[0] <= li_y[0] <= li_x[-1] or li_x[0] <= li_y[-1] <= li_x[-1]:
    print("War")
else:
    print("No War")

Measured memory_bytes: 3064
res = 0
flag = False
n,k = map(int,input().split())
ab = []
for i in range(n):
	aa,bb = map(int,input().split())
	ab.append([aa,bb])

ab.sort()

for j in range(0,n):
	res = res + ab[j][1]
	if res >= k:
		print(ab[j][0])
		flag = True
	if flag == True:
		break

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

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

const int INF = 1e9;
const int mod = 1e9+7;

int dp[100010];

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

    dp[0] = 0;
    for(int i = 1; i <= n; i++){
        dp[i] = INF;
        int power = 1;
        while(power <= i){
            dp[i] = min(dp[i],dp[i-power]+1);
            power *= 6;
        }
        power = 1;
        while(power <= i){
            dp[i] = min(dp[i],dp[i-power]+1);
            power *= 9;
        }
    }

    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 640
N = int(input())

A = list(map(int,input().split()))


curmin = 1 + 10**9
negatives = 0
cursum = 0

for item in A:
    # find minimum
    # find num of negatives

    curmin = min(curmin, abs(item))

    if item < 0:
        negatives += 1

    cursum += abs(item)

if negatives % 2 == 1:
    cursum -= 2 * curmin

print(cursum)

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

using namespace std;

int main()
{
    int s;
    const int MAX = 1000001;
    vector<int> v(MAX, 0);
    cin >> s;
    v[0] = s;
    int cnt = 0;
    int ans = MAX;
    while(true) {
        cnt++;
        int tmp;
        if (v[cnt - 1] % 2 == 0) {
            tmp = v[cnt - 1] / 2;
        } else {
            tmp = 3 * v[cnt - 1] + 1;
        }
        auto itr = find(v.begin(), v.end(), tmp);
        if (itr != v.end()) {
            ans = cnt + 1;
            break;
        }
        v[cnt] = tmp;
    }

    cout << ans << endl;
    // for (int x : v) {
    //     cout << x << endl;
    // }
}


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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
void debug_out() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H), debug_out(T...);
}
const ll m = 1e9 + 7;
ll mulmod(ll a, ll b, ll m) {
    ll r = a * b - (ll)((long double)a * b / m + .5) * m;
    return r < 0 ? r + m : r;
}
int main() {
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
#define debug(...) 3
    fastIO;
#endif
    int n;
    cin >> n;
    vector<ll> v(n), pre(n);
    forn(i, n)cin >> v[i];
    sort(all(v));
    pre[0] = v[0];
    for(int i = 1; i < n; i++)pre[i] = (pre[i - 1] % m + v[i] % m) % m;
    ll ans = 0;
    for(int i = 0; i < n - 1; i++) {
        ans = (ans % m + mulmod(v[i], (pre[n - 1] - pre[i] + m) % m,m) % m) % m;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

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

    int x;cin>>x;
    if(x==3 || x==5 || x==7){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define For(i,a,b) for(int i=(int)(a);i<=(int)(b);++i)
#define Fill(a,b) memset(&a,b,sizeof(a))
 
const int dr[]={0,0,1,-1};
const int dc[]={1,-1,0,0};
 
char a[30][30];
int visited[30][30];
int dist[30][30];
int bfs(int x , int y , int n , int m)
{
	memset(visited , 0 , sizeof(visited));
	visited[x][y] = 1;
	queue< pair< int , int > > q;
	q.push({x , y});
	dist[x][y] = 0;
	int mx = 0;
	while(!q.empty())
	{
		pair< int , int > fr;
		fr = q.front();
		q.pop();
		int x = fr.first;
		int y = fr.second;
		int nx , ny;
		
		for(int i = 0 ; i < 4 ; i++)
		{
			nx = x + dr[i];
			ny = y + dc[i];
			if(nx > n || ny > m || nx < 1 || ny < 1 || a[nx][ny] == '#')
				continue;
			if(!visited[nx][ny]){
				q.push({nx,ny});
				dist[nx][ny] = dist[x][y] + 1;
				visited[nx][ny] = 1;
				mx = max(mx , dist[nx][ny]);
			}
		}
		
	}
	return mx;
}


int main(){	
	ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
		int rows , cols;
		cin >> rows >> cols;
		for(int i = 1 ; i <= rows ; i++){
			for(int j = 1 ; j <= cols ; j++){
				cin >> a[i][j];
			}
		}
		/*for(int i = 1 ; i <= rows ; i++){
			for(int j = 1 ; j <= cols ; j++){
				cout << a[i][j];
			}
			cout << endl;
		}*/
		int ans = 0;
		for(int i = 1 ; i <= rows ; i++){
			for(int j = 1 ; j <= cols ; j++){
				if(a[i][j] == '.')
					ans = max(ans , bfs(i , j , rows , cols));
			}
		}
		cout << ans << endl;
	
 
	return 0;
}

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

using namespace std;
typedef long long ll;

const ll D = 27;

ll b[D], a[D][D];

int main()
{
    ll n, m, c;
    cin >> n >> m >> c;
    for (ll i = 1; i <= m; i++)
        cin >> b[i];
    for (ll i = 1; i <= n; i++)
        for (ll j = 1; j <= m; j++)
            cin >> a[i][j];

    ll ans = 0;
    for (ll i = 1; i <= n; i++)
    {
        ll sum = c;
        for (ll j = 1; j <= m; j++)
            sum += a[i][j] * b[j];
        ans += sum > 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if(a<b && b<c) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 26228
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
using System.Linq;
class Program
{
      static List<int> s = new List<int>();
       static List<int>[] t;
    static decimal result;
static StringBuilder sb = new StringBuilder();
static int N,M,K;
static long[,] table;
    static void Main()
    {
Read4();
      Read5();
//2^10パターン全部試して正誤を見る。

      for(int k=0;k<Math.Pow(2,N);k++){
        int[] tmpr=new int[K];//押されたスイッチ数
List<int> now=new List<int>();
        int num=k;bool back=false;
        
      for(int j=1;j<=N;j++){if(num%2==1){now.Add(j);}num/=2;}
for(int i=0;i<K;i++){for(int j=0;j<t[i].Count;j++){if(now.Contains(t[i][j])){tmpr[i]++;}}}  

        for(int i=0;i<K;i++){if(tmpr[i]%2!=s[i]){back=true;}}
        if(back==true){continue;}

result++;
      }
                    Console.WriteLine(result.ToString());
}
    


    static void Read1()//1項
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }
 
    static void Read2()//複数項（項目数Ｎ）
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read3()//1行複数項
   {
       string[] tmp = Console.ReadLine().Split(' ');
       for (int i = 0; i < tmp.Length; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read4()//NK１行
    {
        string[] tmp = Console.ReadLine().Split(' ');
       N = int.Parse(tmp[0]);
       K = int.Parse(tmp[1]);
      t=new List<int>[K];
    }
    static void Read5()//N行K項
    {
      for(int i=0;i<K;i++){
        t[i]=new List<int>();
        string[] tmp = Console.ReadLine().Split(' ');
        int num=int.Parse(tmp[0]);
        for(int j=1;j<=num;j++){t[i].Add(int.Parse(tmp[j]));}
             }
              string[] tmp2 = Console.ReadLine().Split(' ');
      for(int i=0;i<K;i++){s.Add(int.Parse(tmp2[i]));}
    }

}


Measured memory_bytes: 13152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,0,n) cin>>a[i];
  int cur[n];
  rep(i,0,n) cur[i]=0;
  int j=0;
  int cnt=0;
  while(j<n){
    if(cur[j]==a[j]) j++;
    else{
      int k=j;
      while(k<n && cur[k]<a[k]){
        cur[k]++;
        k++;
      }
      cnt++;
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  string s;cin>>s;
	string t = "keyence";
	if(s==t){
		cout << "YES" << endl;
		return 0;
	}
	int nw = 0;
	for(int i = 0; s.size() > i; i++){
		for(int j = i; s.size() > j; j++){
			string z  = "";
			for(int k = 0; s.size() > k; k++){
				if(i <= k && k <= j)continue;
				z.push_back(s[k]);
			}
			if(z==t){
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;
}

Measured memory_bytes: 256
// c_abc098.cpp
#include <iostream>
#include <vector>
using namespace std;

#define FOR(i,a,b) for(i = a; i < b; ++i)
#define REP(i,n)   for(i = 0; i < n; ++i)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;


vector<vector<int>> sum;
ll N, M, Q;

void makeSumTable(vector<int> L, vector<int> R)
{
    ll i, j;

    sum = vector<vector<int>> (N + 1, vector<int>(N + 1, 0));

    REP(i, M){
        ++sum[L[i]][R[i]];
    }

    FOR(i, 1, N + 1){
        FOR(j, 1, N + 1){
            sum[i][j] += sum[i - 1][j];
            sum[i][j] += sum[i][j - 1];
            sum[i][j] -= sum[i - 1][j - 1];
        }
    }
}

int getSum(int L, int R){
    int ans = sum[R][R] - sum[R][L - 1] - sum[L - 1][R] + sum[L - 1][L - 1];
    return ans;
}

int main()
{
    ll i;

    cin >> N >> M >> Q;

    vector<int> L(M);
    vector<int> R(M);
    REP(i, M){
        cin >> L[i] >> R[i];
    }

    vector<int> p(Q);
    vector<int> q(Q);
    REP(i, Q){
        cin >> p[i] >> q[i];
    }

    makeSumTable(L, R);

    int ans;
    REP(i, Q){
        ans = getSum(p[i], q[i]);
        cout << ans << endl;
    }
}


Measured memory_bytes: 5120
#include <iostream>
#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 <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int cnt[10][10] = {};

int main() {
  
  int n; cin >> n;
  for(int x = 1; x <= n; x++) {
    int shita = x % 10;
    lint num = x;
    while(num >= 10) {
      num /= 10;
    }
    int ue = num;
    cnt[ue][shita]++;
  }

  lint ans = 0;
  for(int i = 1; i <= 9; i++) 
    for(int j = 1; j <= 9; j++) 
      ans += cnt[i][j] * cnt[j][i];

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


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
#include <vector>
using namespace std;
typedef long long LL;

int main(){
	LL n,a,b;
	cin >> n >> a >> b;
	cout << (n / (a + b)) * a + min(a,(n % (a + b))) << endl;
	return 0;
}

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


using namespace std;

int main(){
    double n, k;
    cin >> n >> k;
    vector<double> v;
    for(int i = 0; i < n; ++i){
        double tmp; cin >> tmp;
        v.push_back((tmp + 1) / 2);
    }
    double ans = 0;
    for(int i = 0; i < k; ++i){
        ans += v[i];
    }
    double cur = ans;
    for(int i = k; i < n; ++i){
        cur = cur - v[i - k] + v[i];
        ans = max(ans, cur);
    }
    cout << std::fixed;
    cout << setprecision(6) << ans;
    return 0;
}


Measured memory_bytes: 2420