akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
	ll R, G, B, N;
	cin >> R >> G >> B >> N;

	ll res = 0;
	REP(r, N + 1)REP(g, N + 1) {
		ll left = N - r * R - g * G;
		if (left>=0 && left%B == 0) {
			res++;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    a = input().split(" ")
    K = int(a[0])
    S = int(a[1])
    X = Y = Z = count = 0

    for x in range(K + 1):
        for y in range(K + 1):
            xy = x + y
            if S - xy <= K and 0 <= S - xy:
                count += 1
    print(count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
N,M=map(int,input().split())
a=M//2
b=M-a
c=1
d=2*a+1
for i in range(a):
  print(c,d)
  c+=1
  d-=1
e=2*a+2
f=2*M+1
for i in range(b):
  print(e,f)
  e+=1
  f-=1

Measured memory_bytes: 9292
import heapq
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
q = [[(A[0]+B[0]+C[0])*-1, 0, 0, 0]]
heapq.heapify(q)
used = {}
for i in range(K):
    if len(q) == 0:
        break
    a, b, c, d = heapq.heappop(q)
    print(a*(-1))
    if (b+1, c, d) in used:
        pass
    elif b+1 < X:
        heapq.heappush(q, [(A[b+1]+B[c]+C[d])*(-1), b+1, c, d])
        used[(b+1, c, d)] = 1
    if (b, c+1, d) in used:
        pass
    elif c+1 < X:
        heapq.heappush(q, [(A[b]+B[c+1]+C[d])*(-1), b, c+1, d])
        used[(b, c+1, d)] = 1
    if (b, c, d+1) in used:
        pass
    elif d+1 < X:
        heapq.heappush(q, [(A[b]+B[c]+C[d+1])*(-1), b, c, d+1])
        used[(b, c, d+1)] = 1


Measured memory_bytes: 78804
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pi pair<ll,int> 
#define pii pair<int,ll>
 
ll mod = 1e9+7;
ll INF = 1e17;
/*ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}*/
int main()
{
    IOS
    ll n,m;
    cin>>n>>m;
    cout<<((n)*(n-1))/2+((m)*(m-1))/2<<endl;
    return(0);
}


Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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 = 100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

vector<vector<int>> Edge(10005);
vector<bool> seen(10005);

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    long long N,K;cin >> N >> K;
    long long ans = 0;
    //bを固定して考える
    for(long long i = K+1;i<=N;i++){
        //余りは0,1,2…i-1の繰り返し
        long long group = (N+1)/i;
        long long aboveK = group*(i-K);
        //cout << aboveK << " ";
        //余りの部分
        aboveK += max((N-group*i)-K+1,(long long)0);
        ans += aboveK;
        if(K == 0) ans--;
        //cout << ans << endl;
    }
    cout << ans << endl;

}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  ll si = s.size();
  vector<vector<ll>> dp(si,vector<ll>(13));
  for(int i = 0;i < si;i++)for(int j = 0;j < 13;j++)dp[i][j] = 0;
  for(int i = 0;i < 13;i++){
    if(s[0] == '?'){
      if(i <= 9)dp[0][i] = 1;
      else dp[0][i] = 0;
      //cout << "A" << endl;
    }
    else{
      if((int)s[0] - '0' == i)dp[0][i] = 1;
      else dp[0][i] = 0;
    }
  }
  
  ll mod = pow(10,9) + 7;
  for(int i = 1;i < si;i++){
    for(int j = 0;j < 13;j++){
      if(s[i] == '?'){
        //cout << "B" << endl;
        for(int k = 0;k < 10;k++){
          ll nowmod = j*10 + k;
          nowmod %= 13;
          dp[i][nowmod] += dp[i - 1][j];
          dp[i][nowmod] %= mod;
        }
      }
      else{
        ll nowmod2 = j*10 + (int)(s[i] - '0');
        nowmod2 %= 13;
        dp[i][nowmod2] += dp[i - 1][j];
        dp[i][nowmod2] %= mod;
      }
    }
  }
  cout << dp[si - 1][5] << endl;
}

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

using namespace std;

constexpr int N = 100005;

struct Edege{
  int u, v, w;
  bool operator < (const Edege &b) const{
    return w < b.w;
  }
};

struct Node{
  int id, x;
  bool operator < (const Node &b) const {
    return x < b.x;
  }
};

int fa[N], cnt;
Node a[N], b[N];
Edege e[N * 3];

void add(int u, int v, int w){
  e[cnt].u = u;
  e[cnt].v = v;
  e[cnt++].w = w;
}

int findFa(int u){
  if(fa[u] != u){
    fa[u] = findFa(fa[u]);
  }
  return fa[u];
}

int main(){
  int n;
  scanf("%d", &n);
  for(int i = 1; i <= n; ++i){
    fa[i] = i;
  }
  cnt = 1;
  for(int i = 1; i <= n; ++i){
    a[i].id = b[i].id = i;
    scanf("%d%d", &a[i].x, &b[i].x);
  }
  sort(a + 1, a + n + 1);
  for(int i = 2; i <= n; ++i){
    add(a[i].id, a[i - 1].id, a[i].x - a[i - 1].x);
  }
  sort(b + 1, b + n + 1);
  for(int i = 2; i <= n; ++i){
    add(b[i].id, b[i - 1].id, b[i].x - b[i - 1].x);
  }
  sort(e + 1, e + cnt + 1); 
  long long tempAns = 0;
  for(int i = 1; i < cnt; ++i){
    int u = e[i].u, v = e[i].v, w = e[i].w;
    u = findFa(u);
    v = findFa(v);
    if(u != v){
      tempAns += w;
      fa[v] = u;
    }
  }
  cout << tempAns << endl;
  return 0;
}


Measured memory_bytes: 5760
import Control.Monad
import Control.Applicative
import Data.List

main = do
  n <- readLn
  sp <- replicateM n (words <$> getLine)

  mapM_ print $ solve (list2pair 1 sp)

solve :: [(String, Int, Int)] -> [Int]
solve l = ans
  where
    sorted = mysort l
    buf = sortOn snd (solve' 1 sorted)
    ans = map fst buf

list2pair :: Int -> [[String]] -> [(String, Int, Int)]
list2pair _ [] = []
list2pair n ((s:p:_):rest) = (s,read p, n) : list2pair (n+1) rest

mysort :: [(String,Int,Int)] -> [(String,Int,Int)]
mysort l = sortOn fst3 (reverse (sortOn snd3 l))

fst3 :: Ord a => (a,b,c) -> a
fst3 (n,_,_) = n

snd3 :: Ord b => (a,b,c) -> b
snd3 (_,n,_) = n

solve' :: Int -> [(String, Int, Int)] -> [(Int,Int)]
solve' _ [] = []
solve' m ((_,_,n):rest) = (n,m) : solve' (m+1) rest



Measured memory_bytes: 1020
import numpy as np
import sys
input = sys.stdin.buffer.readline

N, K = map(int, input().split())
A = np.array(input().split(), np.int64)

A = np.sort(A)
zero = A[A == 0]
pos = A[A > 0]
neg = A[A < 0]


def f(x):
    """count the number of products , <= x"""
    cnt_tpl = 0
    # zero and ...
    if x >= 0:
        cnt_tpl += len(zero) * N
    # positive and ...
    cnt_tpl += np.searchsorted(A, x // pos, side='right').sum()
    # negative and ...
    cnt_tpl += (N - np.searchsorted(A, (-x - 1) // (-neg), side='right')).sum()
    # a^2
    cnt_tpl -= np.count_nonzero(A * A <= x)
    assert cnt_tpl % 2 == 0
    return cnt_tpl // 2


left = -10 ** 18
right = 10 ** 18
while left + 1 < right:
    x = (left + right) // 2
    if f(x) >= K:
        right = x
    else:
        left = x


print(right)


Measured memory_bytes: 24304
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <limits>

using namespace std;

int main()
{
	int N;
	cin >> N;
	string S;
	cin >> S;

	int size = S.size();
	for (int i = 0; i < size; i++)
	{
		S.at(i) += N;
		if (S.at(i) > 'Z')
		{
			S.at(i) -= 26;
		}
	}

	cout << S << endl;

	return 0;
}

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

#define int long long
#define pb push_back
#define mp make_pair
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a,b,c,d;
    cin>>a>>b>>c>>d;

    int ans=b-a+1;
    int lolc=b/c-(a-1)/c;
    int lold=b/d-(a-1)/d;
    int lolco=b/(c*d/(__gcd(c,d)))-(a-1)/(c*d/(__gcd(c,d)));

    cout<<ans-lolc-lold+lolco;    

    return 0;
}

/*



*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long read()
{
	char ch=getchar();long long x=0,ff=1;
	while(ch<'0'||ch>'9') {if(ch=='-') ff=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}
	return ff*x;
}
void write(long long z)
{
	if(z<0){putchar('-');z=-z;}
	if(z>=10){write(z/10);}
	putchar(z%10+'0');
}
long long n,top;
long long a[100005],zhan[100005];
long long ans[100005],val[100005];
int main()
{
	n=read();
	for(long long i=1;i<=n;++i) 
	{
		a[i]=read();
		val[i]=a[i];
	}
	for(long long i=1;i<=n;++i)
	{
		if(a[i]>a[zhan[top]]) zhan[++top]=i;
		else 
		{
			long long l=0,r=top;
			while(l+1<r)
			{
				long long mid=(l+r)>>1;
				if(a[zhan[mid]]>a[i]) r=mid;
				else l=mid;
			}
			if(a[i]!=a[zhan[r]]) ans[zhan[r]]+=a[i]-a[zhan[r-1]];
		}
	}
	sort(val+1,val+n+1);
	long long now=1;
	for(long long i=1;i<=top;++i) 
	{
		while(now<=n&&val[now]<a[zhan[i]]) now++;
		ans[zhan[i]]+=(a[zhan[i]]-a[zhan[i-1]])*(n-now+1);
	}
	for(long long i=1;i<=n;++i) write(ans[i]),puts("");
	return 0;
}

Measured memory_bytes: 4224
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;

int main(){
    double a,b,c;
    cin>>a>>b>>c;
    double s=a*b*sin((c/180)*3.1415926535897932384626)/2;
    double l=a+b+sqrt(a*a+b*b-2*a*b*cos((c/180)*3.1415926535897932384626));
    double h=s*2/a;
    printf("%lf\n%lf\n%lf\n",s,l,h);
    return 0;
}


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

#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int freq[122];
int main()
{
    fast_io;
    string w;
    cin >> w;
    int n = w.size();
    for(int i = 0; i < n ;i++)
    {
        freq[w[i]]++;
    }
    int cnt = 0;
    for(int i = 0; i < 122; i++)
    {
        if(freq[i] % 2 != 0)
        {
            cnt++;
            break;
        }
    }
    if(cnt > 0)
    {
        cout << "No\n";
    }
    else{
        cout << "Yes\n";
    }
}


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

int main() {
  string s, t;
  cin >> s >> t;
  
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
   
  if (s < t) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;

double pi = acos(-1);

signed main(){
	double  A,B,H,M;
	cin >> A >> B >> H >> M;
	double tyou = 6.0 * M;
	double tan = H * 30 + M / 2.0;
	tyou *= pi / 180.0;
	tan *= pi / 180.0;
	cout << setprecision(20) << abs(polar(A,tyou) - polar(B,tan)) << endl;
}

Measured memory_bytes: 4116
#include <iostream>
#include <vector>
#include <algorithm>
 
#define rep(i, n) for(int i = 0; i < (n); ++i)
 
using namespace std;

const int inf = 1e4;

struct E{
    E(int to, int cap, int rev): to(to), cap(cap), rev(rev){}

    int to, cap, rev;
};

int n, m;
int b[500];
int r[500];
vector<E> g[1002];
bool used[1002];

void add_edge(int from, int to, int cap){
    g[from].push_back(E(to, cap, g[to].size()));
    g[to].push_back(E(from, 0, g[from].size() - 1));
}

int dfs(int v, int t, int f){
    if(v == t){
        return f;
    }
    used[v] = true;
    for(E& e: g[v]){
        if(!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                g[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t){
    int flow = 0;
    while(1){
        fill_n(used, n + m + 2, false);
        int f = dfs(s, t, inf);
        if(!f){
            break;
        }
        flow += f;
    }
    return flow;
}

int gcd(int a, int b){
    return b ? gcd(b, a % b) : a;
}

int main(){
    while(1){
        cin >> n >> m;
        if(!n){
            break;
        }

        rep(i, n + m + 2){
            g[i].clear();
        }

        rep(i, n){
            cin >> b[i];
            add_edge(n + m, i, 1);
        }
        rep(i, m){
            cin >> r[i];
            add_edge(n + i, n + m + 1, 1);
        }
        rep(i, n){
            rep(j, m){
                if(gcd(b[i], r[j]) > 1){
                    add_edge(i, n + j, 1);
                }
            }
        }

        cout << max_flow(n + m, n + m + 1) << endl;
    }
    return 0;
}

Measured memory_bytes: 9136
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int H = sc.nextInt();
        int W = sc.nextInt();

        while (!(H == 0 && W == 0)) {

            for (int i = 0; i < H; i++) {
                if (i % 2 == 0) {
                    int j = 0;
                    while (true) {
                        j++;
                        if (j > W) {
                            break;
                        }
                        System.out.print("#");
                        j++;
                        if (j > W) {
                            break;
                        }
                        System.out.print(".");

                    }
                }
                if (i % 2 == 1) {
                    int j = 0;
                    while (true) {
                        j++;
                        if (j > W) {
                            break;
                        }
                        System.out.print(".");
                        j++;
                        if (j > W) {
                            break;
                        }
                        System.out.print("#");
                    }
                }
                System.out.print("\n");
            }

            System.out.print("\n");

            H = sc.nextInt();
            W = sc.nextInt();

        }

        sc.close();
    }
}


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

using namespace std;

#define ll long long
#define ld long double
#define int ll
#define ff first
#define ss second
#define rsz resize
#define ins insert 
#define mp make_pair
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define ft front() 
#define bk back()
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define deb(x) cout<<#x<<" "<<x<<'\n';
#define rep(i,a,b) for (int i = (a); i < (b); ++i)

const ll mod = 1e9+7; // 998244353;
const ll inf = 1e18; 
const ld pie = acos((ld)-1);

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

vector<int> g[1000001];
int vis[1000001];
int n,m;
vector<int> cur;
int cnt=1;

void dfs(int u){
	vis[u]=1;
	for(auto x:g[u]){
		if(!vis[x]){
			dfs(x);
			cnt++;
		}
	}
}

int32_t main(){
    
	scanf("%lld%lld",&n,&m);
	set<int> st;
	while(m--){
		int x,y;
		scanf("%lld%lld",&x,&y);
		x--;
		y--;
		st.ins(x);
		st.ins(y);
		g[x].pb(y);
		g[y].pb(x);
	}

	int ans=INT_MIN;

	for(int i=0;i<n;++i){
		if(!vis[i]){
			dfs(i);
			ans=max(ans,cnt);
			cnt=1;
			
		}
	}
	
	printf("%lld\n",ans);

	return 0;

	/*STUFF TO LOOK:	
		1. Check the constraints
		2. Corner cases(n==0||n==1)
		3. Variables in loops
		4. Make sure two ints aren’t multiplied to get a long long
		5. Don't use scanf or printf while using ios_base
		6. using the local variable of the same name when global variable was required to be used
	*/
}


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

using namespace std;

typedef long long int64;

int64 lcm(int64 x, int64 y)
{
  int64 ret = x / __gcd(x, y);
  if(1.0 * ret * y > 1e18) return (2e18);
  return (ret * y);
}


int main()
{
  int64 N, M, A[20];
  double P[20];

  cin >> N >> M;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for(int i = 0; i < N; i++) {
    double s;
    cin >> s;
    P[i] = s / 100;
  }

  double ret = 0.0;
  for(int i = 1; i < 1 << N; i++) {
    int64 latte = 1;
    double fact = 1.0;
    for(int j = 0; j < N; j++) {
      if((i >> j) & 1) {
        latte = lcm(latte, A[j]);
        fact *= P[j];
      }
    }
    int st = __builtin_popcount(i);
    if(st & 1) ret += fact * (M / latte);
    else ret -= fact * (M / latte);
  }
  cout << fixed << setprecision(10) << ret << endl;
}

Measured memory_bytes: 3268
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int gcd(int a,int b) {
	return b == 0 ? a : gcd(b, a % b);
}

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

int main(){
	for (int a, b; cin >> a >> b; ) {
		cout << gcd(a, b) << ' ' << lcm(a, b) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------


void _main() {
	int X, A;
	cin >> X >> A;
	cout << (X < A ? 0 : 10) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n, d;
  cin >> n >> d;
  int x[n][d];
  for(int i = 0; i < n; i++){
    for(int j = 0; j < d; j++){
      cin >> x[i][j];
    }
  }

  int count = 0;
  for(int i = 0; i < n; i++){
    for(int j = i + 1; j < n; j++){
      int sum = 0;
      for(int k = 0; k < d; k++){
        sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }
      int k = 0;
      while(k * k < sum) ++k;
      if(k * k == sum) ++count;
    }
  }

  cout << count << endl;

  return 0;
}


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

def main():
    n,k = map(int, input().split())
    L = list(map(int, input().split()))

    L.sort()
    L = L[::-1]
    print(sum(L[:k]))


if __name__ == '__main__':
    main()


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

int main(void){
    int D,N;
    cin >> D >> N;
    int ans = 1;
    if(D == 0){
      if(N == 100){
      	ans = 101;
      }else{
        ans = N;
      }
    }else{
        if(N == 100){
            for(int i = 0;i < D;i++){
            ans *= 100;
            }
          	ans *= 101;
        }else{
            for(int i = 0;i < D;i++){
            ans *= 100;
            }
        	ans *= N;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    string t = s;
    reverse(all(t));
    if (t != s) {
        cout << "No\n";
        return 0;
    }
    int n = sz(s);
    string a(s.begin(), s.begin() + (n - 1) / 2);
    string a0 = a;
    reverse(all(a));
    if (a0 != a) {
        cout << "No\n";
        return 0;
    }
    string b(s.begin() + (n + 3) / 2 - 1, s.end());
    string b0 = b;
    reverse(all(b));
    if (b0 != b) {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
mod = 10**9 + 7

M = [1]

mul = 1
for i in range(1, 4005):
    mul = mul * i % mod
    M.append(mul)

def inv(a, p):
    ans = 1
    pp = p
    p -= 2
    while p > 0:
        if p % 2 == 1:
            ans = (ans * a) % pp
        a = (a * a) % pp
        p //= 2
    return ans % pp

#print(inv(1,13))

I = [1] + [inv(i, mod) for i in range(1, 4005)]

M_I = [1]
mul = 1
for i in range(1, 4005):
    mul = mul * I[i] % mod
    M_I.append(mul)

#print(I[:10])

i = 1
init = M[n-k+1]
#print(init)
init = (init * M_I[n-k+1-i]) % mod
#print(init)
init = (init * M_I[i]) % mod
#print(init)
init = (init * M[k-1]) % mod
#print(init)
init = (init * M_I[k-1-i+1]) % mod
#print(init)
init = (init * M_I[i-1]) % mod
print(init)

for i in range(2, k+1):
    init = (init * (n-k+1-(i-1))) % mod
    init = (init * I[i]) % mod
    init = (init * (k-1-(i-1)+1)) % mod
    init = (init * I[i-1]) % mod
    print(init)

#print((M[4]*M[2]*M_I[3]*M_I[1]*M_I[2]*M_I[0])%mod)

Measured memory_bytes: 43632
#include <stdio.h>

int main(){
    int n,x,t,ans,i,tako;

    scanf("%d %d %d",&n,&x,&t);
    for(i=1;;i++){
        ans = i*t;
        tako = i*x;
        if(tako >= n){
            printf("%d\n",ans);
            break;
        }

    }
    return(0);
    

}

Measured memory_bytes: 1728
N = int(input())
H = list(map(int, input().split()))
ans = 0
tmp = 0
now = -1
for i in range(N-1):
    if H[i] >= H[i + 1]:
        tmp += 1
    else:
        ans = max(ans, tmp)
        tmp = 0

ans=max(ans,tmp)

print(ans)


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, k;
    cin >> n >> k;
    vi p(n);
    rep(i, n) cin >> p[i];
    VSORT(p);
    int sum = 0;
    rep(i, k) sum += p[i];
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<cmath>
#include<map>
using namespace std;
typedef pair< int , int > Pi;
string mas[] = {"ABC","DEF","GHI"},s;
map< char , Pi > mp;
const int dy[] = { 1, 0, -1, 0}, dx[] = { 0, 1, 0 , -1};

bool rec(int now){
  if( now == s.size()) return true;
  for(int i = 0 ; i < 4 ; i++ ){
    int ny = mp[s[now-1]].first + dy[i], nx = mp[s[now-1]].second + dx[i];
    if(nx >= 0 && nx < 3 && ny >= 0 && ny < 3 && mas[ny][nx] == s[now]){
      return rec(now+1);
    }
  }
  return false;
}

int main(){
  for(int i = 0 ; i < 3 ; i++ ){
    for(int j = 0 ; j < 3 ; j++ ) mp[mas[i][j]] = Pi(i,j);
  }

  for(int i = 0 ; i < 1000 ; i++ ){
    bool FLG = true;
    cin >> s;
    if(!rec(1)) continue;
    cout << s << endl;
  }
}

Measured memory_bytes: 1188
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string tostring(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

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

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

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

	int n, a, b;
	cin >> n >> a >> b;

	vector<int> x(n);
	vector<int> dist;
	int cost = 0;

	for (int i = 0; i < n; i++) {
		cin >> x[i];
		if (i) {
			dist.push_back((x[i] - x[i - 1]) * a);
			cost += dist.back();
		}
	}

	sort(all(dist));
	reverse(all(dist));

	int ans = cost;

	each(d, dist) {
		cost -= d;
		cost += b;
		ans = min(ans, cost);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2168
#include<stdio.h>
#include<stdlib.h>
typedef struct{
  int id;
  int parents;
  int left;
  int right;
}Node;
int height(Node *A,int i){
  int tmp = 0, count= 0;
  if(A[i].right!=-1){
    count = height(A,A[i].right);
  }
  if(A[i].left!=-1){
    tmp = height(A,A[i].left);
    if(tmp>count){
      count=tmp;
    }
  }
  return ++count;
}
int depth(Node *A,int id,int count){
  if(A[id].parents!=-1){
    count++;
    depth(A, A[id].parents,count);
  }
  else{
    return count;
  }
}
int main(){
  int i,j;
  int n,id,count=0,sum=0,hei;
  Node *A;
  scanf("%d",&n);
  A=(Node*)malloc(sizeof(Node)*n);
  for(i=0;i<n;i++){//parentsの初期化(-1に)
    A[i].left=-1;
    A[i].right=-1;
    A[i].parents=-1;
  }
  for(i=0;i<n;i++){//入力
    scanf("%d",&id);
    A[id].id=id;
    scanf("%d%d",&A[id].left,&A[id].right);
    A[A[id].left].parents=id;
    A[A[id].right].parents=id;
  }
  for(i=0;i<n;i++){//出力
    printf("node %d: parent = %d, ",i,A[i].parents);
    if(A[i].parents!=-1){//siblingの出力
      if(A[A[i].parents].right!=A[i].id)
	printf("sibling = %d, ",A[A[i].parents].right);
      if(A[A[i].parents].left!=A[i].id)
	printf("sibling = %d, ",A[A[i].parents].left);
    }
    else printf("sibling = -1, ");
    if(A[i].left==-1&&A[i].right==-1)//degreeの出力
      printf("degree = 0, ");
    else if(A[i].left==-1||A[i].right==-1)
      printf("degree = 1, ");
    else
      printf("degree = 2, ");
    printf("depth = %d, ",depth(A,i,count));//depthの出力
    printf("height = %d, ",height(A,i) - 1);//heightの出力
    if(A[i].parents==-1){
      printf("root");
    }else if(A[i].left==-1&&A[i].right==-1){
      printf("leaf");
    }else
      printf("internal node");
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2104
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include<bits/stdc++.h>
#define INF (1ll<<61)
#define MAX 100005
using namespace std;
//char nc()
//{
//	static char buf[100000],*p1=buf,*p2=buf;
//	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
char nc(){return getchar();}
int read()
{
	int x=0,y=1;
	char c=nc();
	while(!isdigit(c))
	{
		if(c=='-')y=-1;
		c=nc();
	}
	while(isdigit(c))
	{
		x=(x<<1)+(x<<3)+(c^48);
		c=nc();
	}
	return x*y;
}
int n,a[MAX];
long long f[17][17][65537],num[65537],u[65537],v[65537];
bool vst[17][17][65537];
long long dp(int l,int r,int state)
{
	if(l>r) return 0;
	if(vst[l][r][state]) return f[l][r][state];
	vst[l][r][state]=true;
	long long re=INF;
	for(int i=l;i<=r;i++)
		re=min(re,dp(l,i-1,state<<1)+dp(i+1,r,state<<1|1)+num[state]*a[i]);
	return f[l][r][state]=re;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	long long ANS=a[1]+a[n];
	n-=2;
	for(int i=1;i<=n;i++)
		a[i]=a[i+1];
	u[1]=v[1]=1;num[1]=2;
	for(int i=2;i<(1<<n);i++)
	{
		u[i]=u[i>>1];v[i]=v[i>>1];
		if(i&1) u[i]+=v[i>>1];
		else v[i]+=u[i>>1];
		num[i]=u[i]+v[i];
	}
	ANS+=dp(1,n,1);
	printf("%lld",ANS);
	return 0;
}


Measured memory_bytes: 18892
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>

int main(){
    
    string s;
    cin >> s;
    int cnt =0;
    for(int i=0;i + 1 < s.length();i++){
        if(s[i] != s[i+1]) {
            s[i] = s[i+1];
            cnt++;
        }
    }

    cout << cnt << endl;
    

    return 0;
}

Measured memory_bytes: 512
N,D = map(int,input().split())
XY = [list(map(int,input().split())) for _ in range(N)]

cnt = 0
for i in range(N):
    x,y = XY[i][0],XY[i][1]
    if x**2 + y**2 <= D**2:
        cnt += 1

print(cnt)


Measured memory_bytes: 45384
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  char s[11], t[11], u[11];
  int a, b;
  scanf("%s%s%d%d%s", s, t, &a, &b, u);
  if (!strcmp(s, u))
    a--;
  else
    b--;
  printf("%d %d\n", a, b);
}

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

int main() {
  int N;
  cin >> N;
  vector<int> cnt(N + 1);
  for(int i = 0; i < N; i++) {
    int p;
    cin >> p;
    cnt[p] = cnt[p - 1] + 1;
  }
  cout << N - *max_element(cnt.begin(), cnt.end()) << endl;
  return 0;
}

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

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::cmp::*;
fn fac(n: usize) -> usize {
    if n == 0 || n == 1 {
        1
    } else {
        n * fac(n - 1)
    }
}
fn main() {
    input! {
        n: usize,
        xy: [(i64,i64);n],
    }

    let mut dis = vec![];

    for i in 0..n - 1 {
        for j in i + 1..n {
            let t = ((max(xy[i].0, xy[j].0) - min(xy[i].0, xy[j].0)).pow(2)
                + (max(xy[i].1, xy[j].1) - min(xy[i].1, xy[j].1)).pow(2))
                as f64;
            dis.push(t.sqrt());
        }
    }

    let ans = ((2 * fac(n - 1)) as f64 * dis.iter().sum::<f64>()) / fac(n) as f64;
    println!("{}", ans);
}


Measured memory_bytes: 4352
import Data.List.Split
main = mapM_ (print . solve) . analyze . map (map read . words) . lines =<< getContents
analyze [] = []
analyze ([n]:cs) = let (xs,ys) = splitAt n cs in xs:analyze ys
solve = uncurry (+) . foldl1 f . map (\[t,a]->(t,a))
f (x,y) (t,a) = (u*t, u*a) where
  u = max ((x+t-1)`div`t) ((y+a-1)`div`a)

Measured memory_bytes: 1788
x,y,a,b,c=map(int,input().split())
lia=list(map(int,input().split()))
lib=list(map(int,input().split()))
lic=list(map(int,input().split()))
lia.sort(reverse=True)
lib.sort(reverse=True)
lic.sort(reverse=True)
ans=lia[:x]+lib[:y]
ans.sort()
cnt=0
now=0
while cnt < x+y and now < c:
  if lic[now] > ans[cnt]:
    ans[cnt]=lic[now]
    now+=1
  cnt+=1
print(sum(ans))


Measured memory_bytes: 23328
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
  ll N,A,B;
  cin >> N >> A >> B;
  ll ans = 0;
  ans += A * (N/(A+B));
  ll alpha = (N % (A+B));
  if(alpha>=A) {
    ans += A;
  } else {
    ans += alpha;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    const maxCapacity = 512*1024  
    buf := make([]byte, maxCapacity)
    scanner.Buffer(buf, maxCapacity)
  
	var n, k, h, cnt int
	scanner.Scan()
	fmt.Sscan(scanner.Text(), &n, &k)

	scanner.Scan()
	for _, v := range strings.Split(scanner.Text(), " ") {
        h, _ = strconv.Atoi(v)
		if h >= k {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 4224
s = ">" + input() + "<"
n = len(s)-1
a = [10**10 for _ in range(n)]

for i in range(n):
	if s[i] == ">" and s[i+1] == "<":
		a[i] = 0

for i in range(1, n):
	if s[i] == "<":
		a[i] = min(a[i], a[i-1]+1)

#print(a)

for i in range(n-1, 0, -1):
	if s[i] == ">":
		if a[i-1] == 10**10:
			a[i-1] = a[i]+1
		else:
			a[i-1] = max(a[i-1], a[i]+1)

#print(a)

print(sum(a))

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M, X, Y;
    cin >> N >> M >> X >> Y;
    ll Amax = X;
    for (int i = 0; i < N; i++)
    {
        ll x;
        cin >> x;
        Amax = max(Amax, x);
    }
    ll Bmin = Y;
    for (int i = 0; i < M; i++)
    {
        ll y;
        cin >> y;
        Bmin = min(Bmin, y);
    }
    if (Amax < Bmin)
    {
        cout << "No War" << endl;
    }
    else
    {
        cout << "War" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();

        int num = r * 100 + g * 10 + b;
        System.out.println((num % 4 == 0)? "YES": "NO");
    }
}

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

char str[1003][1003];
const char mat1[4][5] = 
{
	"aabd",
	"ccbd",
	"efgg",
	"efhh"
};
const char mat2[5][6] = 
{
	"iijjk",
	"paa.k",
	"p..bl",
	"o..bl",
	"onnmm"
};
const char mat3[6][7] =
{
	"aab.cc",
	"d.be..",
	"dffe..",
	"gg.iij",
	"..hl.j",
	"..hlkk"
};	

void put4(int x){
	for(int i = 0 ; i < 4 ; ++i)
		for(int j = 0 ; j < 4 ; ++j)
			str[x + i][x + j] = mat1[i][j];
}

void put5(int x){
	for(int i = 0 ; i < 5 ; ++i)
		for(int j = 0 ; j < 5 ; ++j)
			str[x + i][x + j] = mat2[i][j];
}

void put6(int x){
	for(int i = 0 ; i < 6 ; ++i)
		for(int j = 0 ; j < 6 ; ++j)
			str[x + i][x + j] = mat3[i][j];
}

int main(){
	int N; cin >> N;
	if(N == 2) puts("-1");
	else{
		for(int i = 1 ; i <= N ; ++i)
			for(int j = 1 ; j <= N ; ++j)
				str[i][j] = '.';
		if(N == 7){
			puts("aabbcc.");
			puts("ddeef..");
			puts("gg..fgg");
			puts("..ab..c");
			puts("..ab..c");
			puts("....def");
			puts("....def");
			return 0;
		}
		else if(N % 3 == 0)
			for(int i = 1 ; i <= N ; i += 3)
				str[i][i] = str[i][i + 1] = str[i + 1][i + 2] = str[i + 2][i + 2] = 'a';
		else
			if(N == 8) put4(1) , put4(5);
			else if(N == 10) put5(1) , put5(6);
			else if(N % 6 == 4){
				put4(1);
				for(int i = 5 ; i <= N ; i += 6)
					put6(i);
			}
			else if(N % 6 == 5){
				put5(1);
				for(int i = 6 ; i <= N ; i += 6)
					put6(i);
			}
			else if(N % 6 == 1){
				put4(1); put4(5); put5(9);
				for(int i = 14 ; i <= N ; i += 6)
					put6(i);
			}
			else{
				put4(1); put5(5); put5(10);
				for(int i = 15 ; i <= N ; i += 6)
					put6(i);
			}
		for(int i = 1 ; i <= N ; ++i , putchar('\n'))
			for(int j = 1 ; j <= N ; ++j)
				putchar(str[i][j]);
	}
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_HW = 505;
int a[MAX_HW][MAX_HW];
int ans1[MAX_HW*MAX_HW],ans2[MAX_HW*MAX_HW],ans3[MAX_HW*MAX_HW],ans4[MAX_HW*MAX_HW];

int main()
{
	int H,W;
	cin >> H >> W;
	rep(i,H)
	{
		rep(j,W)
		{
			cin >> a[i][j];
		}
	}

	int idx = 0;
	rep(i,H)
	{
		rep(j,W-1)
		{
			if (a[i][j] % 2 == 1)
			{
				a[i][j]--;
				a[i][j+1]++;
				ans1[idx] = i+1;
				ans2[idx] = j+1;
				ans3[idx] = i+1;
				ans4[idx] = j+2;
				idx++;
			}
		}
		if (i < H-1 && a[i][W-1] % 2 == 1)
		{
			a[i][W-1]--;
			a[i+1][W-1]++;
			ans1[idx] = i+1;
			ans2[idx] = W;
			ans3[idx] = i+2;
			ans4[idx] = W;
			idx++;
		}
	}
	cout << idx << endl;
	rep(i,idx)
	{
		cout << ans1[i] << " " << ans2[i] << " " << ans3[i] << " " << ans4[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 6556
fun main(args: Array<String>) {
    abc140d()
}

fun abc140d() {
    val right = true
    val left = false

    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val people = readLine()!!.toCharArray().map { it == 'R' }

    var point = 0
    var border = 0
    for (i in 1 until n) {
        if (people[i - 1] == people[i]) point++ else border++
    }

    // 操作により、最大で操作回数*2回、borderを減らしpointを増やせる
    point += Math.min(k * 2, border)

    println(point)
}


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

#define ll long long
#define ar array

int main() {

    ios::sync_with_stdio(false);
	
	int ab, bc, ca;
	
	cin >> ab >> bc >> ca;

	cout << (ab*bc)/2 << endl;
	
	

    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()

ANS = []
for i in range(n):
  p = 0
  A = set(s[0:i])
  B = set(s[i:n+1])
  for j in A:
    if j in B:
      p += 1
  ANS.append(p)
  
  
print(max(ANS))


Measured memory_bytes: 2940
N, K = [int(i) for i in input().split()]
mod = 10**9+7
result = 0 
for i in range(K, N+2):
    min_sum = ((i-1) * i) // 2
    max_sum = ((N) * (N+1)) // 2 - ((N-i) * (N-i+1)) // 2
    result += (max_sum - min_sum + 1) % mod
print(result%mod)

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

int main(){
    int a, b, c;
    cin >> a  >> b >> c;
    if(b>=c){
        cout << b+c << endl;
        return 0;
    }
    if(a>=c-b){
        cout << b+c << endl;
        return 0;
    }
    cout << 2*b+a+1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a>=b&&a>=c)
    cout << b+c << endl;
  else if (b>=a&&b>=c)
    cout << a+c << endl;
  else if (c>=a&&c>=b)
    cout << a+b << endl;
}

Measured memory_bytes: 256
X,Y = map(int,input().split())
given = []
for x in range(X):
  given.append(input())
#print(given)
nex = [[-1,0],[1,0],[0,-1],[0,1]]
for i in range(X * Y):
  x = i // Y
  y = i % Y
  if given[x][y] == '#':
    for ex in range(4):
      try:
        if given[x+nex[ex][0]][y+nex[ex][1]] == '#':
          break
      except:
        pass
    else:
      print('No')
      break
else:
  print('Yes')

Measured memory_bytes: 3064
"use strict"
function Main(input) {
  const splited = input.split('\n');
  const n = splited[0];
  const a = splited[1].split(' ');
  let oddFlag = false;
  let count = 0;

  while (true) {
    for(let i = 0; i < n; i++) {
      if (a[i] % 2 !== 0 ) {
        oddFlag = true;
        break;
      }
      a[i] = a[i] / 2;
    }

    if (oddFlag) {
      break;
    }
    count++;
  }

  console.log(count);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#define MAX 100000
#define INFTY (1 << 30)

class Edge {
public:
  int t, w;
  Edge(){}
  Edge(int t, int w): t(t), w(w) {}
};

vector<Edge> G[MAX];
int n, d[MAX];

bool vis[MAX];
int cnt;

void bfs(int s) {
  for ( int i = 0; i < n; i++ ) d[i] = INFTY;
  queue<int> Q;
  Q.push(s);
  d[s] = 0;
  int u;
  while ( !Q.empty() ) {
    u = Q.front(); Q.pop();
    for ( int i = 0; i < G[u].size(); i++ ) {
      Edge e = G[u][i];
      if ( d[e.t] == INFTY ) {
        d[e.t] = d[u] + e.w;
        Q.push(e.t);
      }
    }
  }
}

void solve() {
  bfs(0);
  int maxv = 0;
  int tgt = 0;
  for ( int i = 0; i < n; i++ ) {
    if ( d[i] == INFTY ) continue;
    if ( maxv < d[i] ) {
      maxv = d[i];
      tgt = i;
    }
  }

  bfs(tgt);
  maxv = 0;
  for ( int i = 0; i < n; i++ ) {
    if ( d[i] == INFTY ) continue;
    maxv = max(maxv, d[i]);
  }

  cout << maxv << endl;
}

main() {
  int s, t, w;
  cin >> n;

  for ( int i = 0; i < n-1; i++ ) {
    cin >> s >> t >> w;

    G[s].push_back(Edge(t, w));
    G[t].push_back(Edge(s, w));
  }
  solve();
}


Measured memory_bytes: 9916
#include <stdio.h>

int main(void){
    int not_end=1;
    int a,b,c;
    int weeks;
    int rem;
    int days;

    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);

    weeks=c/(a*7+b);
    rem=c%(a*7+b);

    if(rem>=7*a){
        days=7;
    }else if(rem%a==0){
        days=rem/a;
    }else{
        days=rem/a+1;
    }

    printf("%d\n",weeks*7+days);

    return 0;
}


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

using namespace std;

#define INF (1<<29)
#define INFF 0x7fffffff
#define LINF (1ll<<60)
#define LINFF 0x7fffffffffffffff
#define PI 3.14159265359

#define _fi(n) for(int i = 0;i < n;i++)
#define _fj(n) for(int j = 0;j < n;j++)
#define _fk(n) for(int k = 0;k < n;k++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define prec(x) cout << fixed << setprecision(x)

#define hash sodnf9843bsd
#define ll long long
#define pqueue priority_queue
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll a, ll b){return uniform_int_distribution<ll>(a, b)(rng);}

double dp[3003][3003] = {};

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

    double p[3003] = {};
    int n;cin>>n;
    _fi(n) cin>>p[i];

    dp[0][1] = p[0];
    dp[0][0] = 1.-p[0];

    for(int i = 1;i < n;i++){
        dp[i][0] = dp[i-1][0]*(1.-p[i]);

        for(int j = 1;j <= i+1;j++){
            dp[i][j] = p[i]*dp[i-1][j-1] + (1.-p[i])*dp[i-1][j];
        }
    }

    double ans = 0;
    for(int j = n/2+1;j <= n;j++) ans += dp[n-1][j];

    prec(10);
    cout << ans << endl;

    return 0;
}


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

int main() {
    char C;
    cin >> C;
    string S ="abcdefghijkelmopqrstuvwxyz";
    for(int i=0; i<26; i++){
        if(C == S.at(i)) {
            cout <<S.at(i+1)<<endl;
            break;
        }
        else continue;
    }
}

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

int main(){
	ll a=0,b=0,c=0;
	cin>>a>>b>>c;
	if(a*c<=b){
		cout<<c<<endl;
	}else{
		ll ans = b/a;
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 256
#include <stdio.h>

int main (void)


{


int n;


int x;


int num;


int min=1000001;


int max=-1000001;


long total=0;


scanf("%d",&n);


for(x=0;x<n;x++){


scanf("%d",&num);


if(min>num) min=num;


if(max<num) max=num;


total+=num;


}


printf("%d %d %ld\n",min,max,total);


return 0;


}

Measured memory_bytes: 2728