akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<math.h>
#define PRN(n) printf("%d\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)

int main(void){
  int n;
  char s[2][11]={"red",""};
  scanf("%d %s",&n,s[1]);
  PRS(s[n/3200]);
  return 0;
}

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

int main(){
	string n;
	cin >> n;
	ll count = 0;
	rep(i,n.size()){
		count += n[i] - '0';
		count %= 9;
	}
	if(count % 9 == 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
    return 0;
}



Measured memory_bytes: 3728
n=int(input())


AC=0
WA=0
TLE=0
RE=0

for i in range(1,n+1):
    str=input()
    if str=='AC':
        AC+=1
    elif str=='WA':
        WA+=1
    elif str=='TLE':
        TLE+=1
    elif str=='RE':
        RE+=1

print("AC x",AC)
print("WA x",WA)
print("TLE x",TLE)
print("RE x",RE)

Measured memory_bytes: 9216
h, w, a, b = [int(i) for i in input().split()]

p = 10 ** 9 + 7

ans = 0
c = h-a-1

def fact(n, p=10**9 + 7):
    f = [1]
    for i in range(1, n+1):
        f.append(f[-1]*i%p)
    return f

def invfact(n, f, p=10**9 + 7):
    inv = [pow(f[n], p-2, p)]
    for i in range(n, 0, -1):
        inv.append(inv[-1]*i%p)
    return inv[::-1]

f = fact(h+w-2)
invf = invfact(h+w-2, f)

def comb(a, b):
    return f[a] * invf[b] * invf[a-b] % p

for x in range(b, w):
    ans = (ans + (comb(c+x, min(x, c)) * comb(a-1+w-x-1, min(a-1, w-x-1)) % p)) % p

print(ans)

Measured memory_bytes: 20524
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

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

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

template <typename T>
void printArr(const T * arr, int s, int fn) {
    for (int i = s; i <= fn; ++ i) cout << arr[i] << " ";
    cout << '\n';
}

template <typename T>
long long minArr(const T * arr, int s, int fn) {
    ll res = 1e16 + 1;
    for (int i = s; i <= fn; ++ i) {
        res = min(res, arr[i]);
    }
    return res;
}

template <typename T>
void printVec(const T * arr) {
    for (int i = 0; i < sz(arr); ++ i) cout << arr[i] << " ";
    cout << '\n';
}

template <class T>
bool uax(T&a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
bool uin (T&a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 1e5 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

double a[N];

int main () {
    to_pray();

    int n;
    cin >> n;

    double ans = 0;

    for (int i = 1; i <= n; ++ i) {
        cin >> a[i];
        ans += (double)(1 / a[i]);
    }

    cout << fixed << setprecision(8) << (1.0 / ans);

    //eprintf("%.18lf seconds\n", (double)clock() / CLOCKS_PER_SEC);

    cout << '\n';
    
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int n, l;
    vector<string> v;
    cin >> n >> l;
    REP(i, n) {
        string tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    sort(ALL(v));
    string res = "";
    REP(i, v.size()) {
        res += v[i];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
from heapq import heapify, heappop, heappush

N, K = map(int, input().split())
V = list(map(int, input().split()))
INF = 10**9

def h(X, cnt):
  S = sum(X)
  heapify(X)
  limit = cnt
  while cnt < K and cnt < 2*limit:
    m = heappop(X)
    if m >= 0:
      break
    S -= m
    cnt += 1
  return S

ans = 0

for i in range(1, min(N, K)+1):
  if i != N:
    for j in range(i+1):
      X = V[:i-j] + V[N-j:]
      ans = max(ans, h(X, i))
  else:
    ans = max(ans, h(V, i))

print(ans)

Measured memory_bytes: 9236
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

/*---------------------------------------------------*/

int n,ma,mb;
int a[45],b[45],c[45];
int dp[45][405][405];

void init(){
  rep(i,45){
    rep(j,405){
      rep(k,405){
	dp[i][j][k]=INF;
      }
    }
  }
}

void DP(){
  dp[0][0][0]=0;
  rep(i,n){
    rep(j,401){
      rep(k,401){
	if(dp[i][j][k]==INF)continue;
	dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
	dp[i+1][j+a[i]][k+b[i]]=min(dp[i][j][k]+c[i],dp[i+1][j+a[i]][k+b[i]]);
      }
    }
  }
}

int main(){
  init();

  cin>>n>>ma>>mb;
  rep(i,n){
    cin>>a[i]>>b[i]>>c[i];
  }

  DP();

  int ans=INF;
  for(int i=1;i<=400;i++){
    for(int j=1;j<=400;j++){
      if(i*mb==j*ma)ans=min(dp[n][i][j],ans);
    }
  }
  
  if(ans==INF)cout<<-1<<endl;
  else cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 29056
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>

using namespace std;

int main() {
	int N, K; cin >> N >> K;
	int* V = new int[N];

	for (int i = 0; i < N; i++) {
		cin >> V[i];
	}

	int valueMax = 0;

	int** table1 = new int* [N + 1];//table1[a][b] : 左からa個取り、そのうちb個戻すときの価値
	int** table2 = new int* [N + 1];//table2[a][b] : 右からa個取り、そのうちb個戻すときの価値
	for (int i = 0; i <= N; i++) {
		table1[i] = new int[N + 1];
		table2[i] = new int[N + 1];
		for (int j = 0; j <= N; j++) {
			table1[i][j] = 0;
			table2[i][j] = 0;
		}
	}
	{
		priority_queue<int, vector<int>, greater<int>> que; // 昇順に出力
		for (int a = 1; a <= N; a++) {
			que.push(V[a - 1]);
			table1[a][0] = table1[a - 1][0] + V[a - 1];
			priority_queue<int, vector<int>, greater<int>> q = que;
			for (int b = 1; b < a + 1; b++) {
				int v = q.top(); q.pop();
				table1[a][b] = table1[a][b - 1] - v;
			}
		}
	}
	{
		priority_queue<int, vector<int>, greater<int>> que; // 昇順に出力
		for (int a = 1; a <= N; a++) {
			que.push(V[N - a]);
			table2[a][0] = table2[a - 1][0] + V[N - a];
			priority_queue<int, vector<int>, greater<int>> q = que;
			for (int b = 1; b < a + 1; b++) {
				int v = q.top(); q.pop();
				table2[a][b] = table2[a][b - 1] - v;
			}
		}
	}

	int valuemax = 0;

	for (int a = 0; a <= N; a++) {
		for (int c = 0; c <= a; c++) {
			for (int b = 0; b <= N - a; b++) {
				for (int d = 0; d <= b; d++) {
					if (a + b + c + d <= K) {
						valuemax = max(valuemax, table1[a][c] + table2[b][d]);
					}
					else {
						break;
					}
				}
			}
		}
	}
	cout << valuemax << endl;

	return 0;
}

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

int n,t;
double dp[3007][3007],a[3007],ans;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lf",&a[i]);
	}
	dp[0][0]=1;
	dp[0][1]=0; 
	for(int i=1;i<=n;i++){
		for(int j=0;j<=n;j++){
			if(j==0){
				dp[i][j]=dp[i-1][j]*(1-a[i]);
			}
			else{
				dp[i][j]=dp[i-1][j]*(1-a[i])+dp[i-1][j-1]*(a[i]);	
			}
		}
	}
	t=n/2+1;
	for(int i=t;i<=n;i++){
		ans+=dp[n][i];
	}
	printf("%.10f\n",ans);
}

Measured memory_bytes: 74184
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

// 深さ優先探索の問題
// TODO #15 深さ優先探索の練習をした後に実装する
// とても参考になる記事
// https://drken1215.hatenablog.com/entry/2020/05/04/190252

type nums struct {
	A int
	B int
	C int
	D int
}

func main() {
	N, M, Q := nextInt(), nextInt(), nextInt()
	nums := make([]nums, Q)
	A := make([]int, 0)
	for i := range nums {
		nums[i].A = nextInt() - 1
		nums[i].B = nextInt() - 1
		nums[i].C = nextInt()
		nums[i].D = nextInt()
	}
	fmt.Println(dfs(A, N, M, nums))
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func dfs(A []int, size int, maxnum int, nums []nums) int {
	if len(A) == size {
		return score(A, nums)
	}
	// Ai <= Ai+1なので、一つ前の項の最高値を次の項のスタートにする
	var prevmax, max int
	if len(A) != 0 {
		prevmax = A[len(A)-1]
	}
	for i := prevmax; i < maxnum; i++ {
		A = append(A, i)
		maxscore := dfs(A, size, maxnum, nums)
		if max < maxscore {
			max = maxscore
		}
		A = A[:len(A)-1]
	}
	return max
}

// 生成した配列が条件に沿った長さになったらさせる処理を関数として外に出している
func score(A []int, nums []nums) int {
	var score int
	for i := 0; i < len(nums); i++ {
		if A[nums[i].B]-A[nums[i].A] == nums[i].C {
			score += nums[i].D
		}
	}
	return score
}


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

mod=10**9+7
n,k=map(int,input().split())
N=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  N[a-1]+=[b-1]
  N[b-1]+=[a-1]
Chk=[0]*n
S=[0]
Chk[0]=1
ans=k
while S:
  ss=S.pop()
  for sss in N[ss]:
    if Chk[sss]>0:
      continue
    else:
      ans=(ans*max(k-Chk[ss],0))%mod
      Chk[ss]+=1
      Chk[sss]=2
      S.append(sss)
print(ans%mod)

Measured memory_bytes: 23552
#include<iostream>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)

int main(void) {
	int a, b; cin >> a >> b;
	int c = a + b;
	if (c >= 10)cout << "error" << endl;
	else cout << a + b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

typedef long long ll;

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

// const int C ;
// const int M = 1000000007;

set<int> S[100010];

ll ans = 0;

int main () {
  int N;
  cin >> N;
  for (auto i = 0; i < N; i++) {
    int a;
    cin >> a;
    a--;
    S[i].insert(a);
  }
  for (auto i = 0; i < N; i++) {
    for (auto x : S[i]) {
      if (S[x].find(i) != S[x].end()) {
        ans++;
      }
    }
  }
  cout << ans/2 << endl;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn int
typedef long long ll;
typedef pair<ll,ll> p;


ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  else return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
  ll g = gcd(a, b);
  return a / g * b;
}

int main()
{
  int n;
  cin >> n;
  vector<ll> v(n, 0);
  for (int i = 0; i < n; i++) cin >> v[i];
  sort(all(v));

  for (int i = 0; i < n-1; i++)
  {
    v[i+1] = lcm(v[i], v[i+1]);
  }
  cout << v[n-1] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	long long int i;
	int s[100000];
	long long int n,a,b;
	scanf("%lld %lld %lld",&n,&a,&b);
	for(i = 0;i<n;i++)
	{
		scanf("%d",&s[i]);
	}
	long long int sum = 0;
	for(i = 1;i<n;i++)
	{
		if((s[i] - s[i-1]) * a > b)
		{
			sum += b;
		}
		else
		{
			sum += (s[i] - s[i-1])*a;
		}
	}
	printf("%lld",sum);
	return 0;
}

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

const long long MOD=1000000007;

int gcm(int x, int y){
  while(y!=0){
    int r=x%y;
    x=y;
    y=r;
  }
  return x;
}

int main(){
  int N; cin >> N;
  int result; cin >> result;
  for(int i=0; i<N-1; i++){
    int a; cin >> a;
    result=gcm(result,a);
  }
  cout << result << endl;
}

Measured memory_bytes: 256
import sys
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, W, *WV = map(int, read().split())
    weight = WV[::2]
    value = WV[1::2]

    w_min = min(weight)
    items = [[] for _ in range(4)]
    for w, v in zip(weight, value):
        items[w - w_min].append(v)

    for i in range(4):
        items[i].sort(reverse=True)

    csums = [0] * 4
    for i in range(4):
        csums[i] = [0]
        csums[i].extend(accumulate(items[i]))

    def rec(i, vec):
        if i == 4:
            ans = 0
            w_total = 0
            for j in range(4):
                w_total += (w_min + j) * vec[j]
            if w_total > W:
                return -1
            for j in range(4):
                ans += csums[j][vec[j]]
            return ans
        ans = 0
        for j in range(len(csums[i])):
            vec.append(j)
            ans = max(ans, rec(i + 1, vec))
            vec.pop()
        return ans

    print(rec(0, []))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9228
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
loc = [int(input()) for i in range(Q)]
for i in range(len(loc)):
    x = loc[i]
    res = INF
    s_w, t_w = bisect.bisect_right(s,x), bisect.bisect_right(t,x)
    d1 = abs(s[s_w]-x) + abs(t[t_w]-s[s_w])
    d2 = abs(t[t_w]-x) + abs(s[s_w]-t[t_w])
    d3 = abs(s[s_w]-x) + abs(t[t_w-1]-s[s_w])
    d4 = abs(t[t_w-1]-x) + abs(t[t_w-1]-s[s_w])
    d5 = abs(s[s_w-1]-x) + abs(t[t_w]-s[s_w-1])
    d6 = abs(t[t_w]-x) + abs(s[s_w-1]-t[t_w])
    d7 = abs(s[s_w-1]-x) + abs(t[t_w-1]-s[s_w-1])
    d8 = abs(t[t_w-1]-x) + abs(s[s_w-1]-t[t_w-1])
    print(min(d1,d2,d3,d4,d5,d6,d7,d8))

Measured memory_bytes: 16152
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF =1001001001;
using P = pair<int,int>;

int main()
{
   int n;
   cin >> n;
   vector<P> a(n);
   vector<P> b(n);
   vector<bool> used(n);
   rep(i,n)
   {
      int x, y;
      cin >> x >> y;
      a[i] = P(x,y);
      used[i] = false;
   }

   rep(i,n)
   {
      int x, y;
      cin >> x >> y;
      b[i] = P(x,y);
   }

  // sort(a.begin(), a.end());
   sort(b.begin(), b.end());
   int ans = 0;
   rep(i,n)
   {
      int x = b[i].first;
      int y = b[i].second;
      int m = -1;
      int index = -1;
      rep(j,n)
      {
         if(used[j]) continue;
         if(x > a[j].first && y > a[j].second)
         {
            if(m < a[j].second)
            {
               index = j;
               m = a[j].second;
            }
         }
      }
      //cout << index << " :";
      if(index != -1)
      {
          ans++;
          used[index] = true;
      }
   }
   cout << ans << endl;
}

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

int main()
{
  int A, B, temp;
  vector<int> i_digit(5);
  int count = 0;

  cin >> A >> B;
  for (int i = A; i <= B; i++)
  {
    temp = i;
    for (int j = 0; j < 5; j++)
    {
      i_digit[j] = temp % 10;
      temp /= 10;
    }
    if (i_digit[4] == i_digit[0] && i_digit[3] == i_digit[1])
      count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
struct card{
    char pattern;
    int value;
  };

struct card* bubbleSort(struct card* );
struct card* selectionSort(struct card*);
int isStable(struct card* , struct card*);

int N;
  
int main(){

  int i,j;
  struct card A[36],B[36],C[36];

  scanf("%d",&N);
  for(i=0;i<N;i++) scanf(" %c%d",&A[i].pattern,&A[i].value);

  for(i=0;i<N;i++){
    B[i]=A[i];
    C[i]=A[i];
  }

  bubbleSort(B);
  
  for(j=0;j<N-1;j++) printf("%c%d ",B[j].pattern,B[j].value);
  printf("%c%d\n",B[N-1].pattern,B[N-1].value);
  
  if(isStable(A,B)==0) printf("Not stable\n");
  else printf("Stable\n");
  
  selectionSort(C);
  
  for(j=0;j<N-1;j++) printf("%c%d ",C[j].pattern,C[j].value);
  printf("%c%d\n",C[N-1].pattern,C[N-1].value);

  if(isStable(A,C)==0) printf("Not stable\n");
  else printf("Stable\n");

  return 0;
}

struct card* bubbleSort(struct card *C){
  int i=0,j;
  struct card tmp;

  for(i=0;i<N;i++){
    for(j=N-1;j>=i+1;j--){
      if(C[j].value < C[j-1].value){
	tmp=C[j];
	C[j]=C[j-1];
	C[j-1]=tmp;
      }
    }
  }
  return C;
}

struct card* selectionSort(struct card *C){
  int i,j,minj=0;
  struct card tmp;

  for(i=0;i<N;i++){
    minj=i;
    for(j=i+1;j<N;j++){
      if(C[j].value < C[minj].value){
	minj=j;
      }
    }
	tmp=C[i];
	C[i]=C[minj];
	C[minj]=tmp;
  } 
  return C;
}

int isStable(struct card *in, struct card *out){

  int i,j,a,b;

  for(i=0;i<N;i++){
    for(j=i+1;j<N;j++){
      for(a=0;a<N;a++){
	for(b=a+1;b<N;b++){
	  if(in[i].value==in[j].value
	     && in[i].pattern == out[b].pattern && in[i].value == out[b].value
	     && in[j].pattern == out[a].pattern && in[j].value == out[a].value)
	    return 0;
	}
      }
    }
  }
  return 1;
}



Measured memory_bytes: 2052
#define _USE_MATH_DEFINES

#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <utility>
#include <ctgmath>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll mod = 1000000007;
const ll inf = 10e17;
const ld eps = 10e-9;

ll solve(void);

int main(void)
{
	while (solve())
	{
	}
	return 0;
}

bool check(const vector<ll>& A, const vector<ll>& F, ll K, ll X)
{
	ll cnt = 0;
	for (ll i = 0; i < A.size(); i++)
	{
		ll a = A[i];
		ll f = F[i];

		if (a * f - X > 0) {
			cnt += a - X/f;
		}
	}

	return cnt <= K;
}

ll solve(void)
{

	ll n, k;
	cin >> n >> k;

	vector<ll> A(n);
	vector<ll> F(n);

	for (auto& a: A)
		cin >> a;

	for (auto& f :F)
		cin >> f;

	sort(A.begin(), A.end(), greater<>());
	sort(F.begin(), F.end());

	ll ok = 10e12;
	ll ng = -1;

	while (abs(ok - ng) > 1)
	{
		ll mid = (ok + ng) / 2;
		(check(A,F,k,mid) ? ok : ng) = mid;
	}
	cout << ok << endl;

	return 0;
}


Measured memory_bytes: 3456
#!/usr/bin/env python
# coding: utf-8

# In[ ]:


MAX_N = 50
n = int(input())
C = [[0] * 26 for _ in range(n)]
for i in range(n):
    S = input()
    for s in S:
        C[i][ord(s) - ord('a')] += 1
res = ''
for i in range(26):
    t = MAX_N + 1
    for j in range(n):
        t = min(t, C[j][i])
    res += chr(i + ord('a')) * t
print(res)



Measured memory_bytes: 9096
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
	#define debug(A,args...) fprintf(stderr,A,##args)
#else
	#define debug(A,args...) 
#endif
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void GG(){puts("No");exit(0);}
	
	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int M=5e6+10;
	ll fac[M],facinv[M],Inv[M];ll C(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,M-1) fac[i]=fac[i-1]*i%MOD;
		facinv[M-1]=invm(fac[M-1]);fd(i,M-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,M-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}
	const int N=1e6+10;
	//------------------FIXED------------------
	vc<int> to[N];int ans=0,S[N];
	void solve(int x,int fa)
	{
		int U=0;for(auto y:to[x]) if(y!=fa) solve(y,x),U|=S[x]&S[y],S[x]|=S[y];
		int c=0;while(S[x]&bin(c) or bin(c)<=U) c++;chmax(ans,c),S[x]=bin(c)|(S[x]-(S[x]&(bin(c+1)-1)));
	}
	void main()
	{
		int n=qread();fo(i,2,n){ int x=qread(),y=qread();to[x].PB(y),to[y].PB(x); }
		solve(1,0);write(ans);
	}
};//����������
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	mine::PRE();//����Ԥ����ģ����
	mine::main();
	debug("\n---------------------Zory---------------------\nTime: %.2lf s",1.0*clock()/CLOCKS_PER_SEC);
}

Measured memory_bytes: 151936
import java.util.*;

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

	int n = sc.nextInt();
	int q = sc.nextInt();

	while(n!=0 && q!=0){

	    int[] allDate = new int[100];

	    for(int i=0; i<n; i++){
		int dateNum = sc.nextInt();
		for(int j=0; j<dateNum; j++){
		    int date = sc.nextInt();
		    allDate[date]++;
		}
	    }

	    int max = 0;
	    int ans = 0;
	    for(int i=0; i<100; i++){
		if(allDate[i]>max && allDate[i]>=q){max = allDate[i]; ans = i;}
	    }

	    System.out.println(ans);

	    n = sc.nextInt();
	    q = sc.nextInt();
	}
    }
}

Measured memory_bytes: 12000
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;


int main()
{
	int sx,sy,tx,ty;
	cin>>sx>>sy>>tx>>ty;
	int dx,dy;
	dx = tx - sx;
	dy = ty - sy;
	rep(i,dy) cout<<"U";
	rep(i,dx) cout<<"R";
	rep(i,dy) cout<<"D";
	rep(i,dx) cout<<"L";
	cout<<"LU";
	rep(i,dy) cout<<"U";
	rep(i,dx) cout<<"R";
	cout<<"RDRD";
	rep(i,dy) cout<<"D";
	rep(i,dx) cout<<"L";
	cout<<"LU"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<set>
#include<vector>
using namespace std;

#define INF 1<<21
#define MAX 100005
#define MOD 10e9+7

int main(){
    int N;
    int a[200005];
    long long x=0,y=0;
    long long ans=0;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>a[i];
        y+=a[i];
    }
    x=a[0];y-=a[0];
    ans=llabs(x-y);
    for(int i=1;i<N-1;i++){
        x+=a[i];
        
        y-=a[i];
        ans=min(ans,llabs(x-y));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
program main
  implicit none
  integer(8) :: n, res, m, i, d, k
  integer(8), allocatable :: a(:)
  read (*, *) n
  allocate (a(n))
  read (*, *) a
  m = 10 ** 9 + 7
  res = 0
  do d = 0, 59
    k = 0
    do i = 1, n
      if (btest(a(i), d)) k = k + 1
    end do
    res = res + mod(mod(k, m) * mod(n - k, m), m) * mod(2 ** d, m)
    res = mod(res, m)
  end do
  write (*, "(i0)") res
end program main


Measured memory_bytes: 3200
import sys

input = sys.stdin.readline


def solve(A, B, C):
    prev_a = -1
    result = 0
    for a in A:
        result += B[a - 1]
        if a - prev_a == 1:
            result += C[prev_a - 1]
        prev_a = a

    return result


if __name__ == '__main__':
    n = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    answer = solve(A, B, C)
    print(answer)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<map>
#include<iomanip>
using namespace std;
typedef unsigned long long ll;
const int maxn = 300005;
const int inf = 1000000007;

int dfs(ll x){
    if(x<=2)return 0;
    return dfs((x-1)>>1) + 1;
}

int main() {
    //freopen("in.cpp","r",stdin);
    ll l=2,r=(1LL<<63)-1+(1LL<<63),ret=-1;
    int x;
    cin>>x;
    while(l<=r){

        ll m=(r>>1) + ((l+1)>>1);
        int tt=dfs(m);
        if(tt<x)l=m+1;
        else if(tt>x)r=m-1;
        else {
            ret=m;
            l=m+1;
        }
    }
    cout<<ret<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf (long long)(1e18)
using namespace std;

string s;
long long n;
vector<vector<long long>> dp;

long long solve();

int main() {
  cin >> s;
  n = s.size();
  cout << solve() << endl;
  return 0;
}

long long solve() {
  reverse(s.begin(), s.end());
  dp.assign(n + 1, vector<long long>(2, inf));
  dp[0][0] = 0;
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < 2; ++j) {
      // j:now ,k : before
      if(j == 0) {
        int pay = s[i] - '0';
        dp[i + 1][j] = min(dp[i + 1][j],
                           min(dp[i][0], dp[i][1]) + pay);
      }
      else {
        int pay = 10 - (s[i] - '0');
        dp[i + 1][j] =
            min(dp[i + 1][j], dp[i][0] + pay + 1);
        dp[i + 1][j] =
            min(dp[i + 1][j], dp[i][1] + pay - 1);
      }
    }
  return min(dp[n][0], dp[n][1]);
}

Measured memory_bytes: 55940
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    ans = 0
    n = I()
    if n%2:
        print(0)
        return
    k = 5
    while k < n:
        ans += (n//k)//2
        k *= 5
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 39024
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

A, B, M = MI()
a = LI()
b = LI()
xyc = LRI(M)

ans = min(a) + min(b)

for i in range(M):
    wari = xyc[i]
    aa = a[wari[0]-1] + b[wari[1]-1] - wari[2]
    ans = min(ans, aa)

print(ans)


Measured memory_bytes: 83152
#include <iostream>
#include <string>
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  string s[3];
  cin >> s[0] >> s[1] >> s[2];
  int p[3] = {0,0,0};
  int i = 0;
  while( 1 ){
    switch( s[i][p[i]] ){
      case 'a': p[i]++; i = 0; break;
      case 'b': p[i]++; i = 1; break;
      case 'c': p[i]++; i = 2; break;
    }
    if( p[i] == s[i].size() ){
      switch( i ){
        case 0: cout << "A" << endl; break;
        case 1: cout << "B" << endl; break;
        case 2: cout << "C" << endl; break;
      }
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>

using namespace std;


struct Edge{ //??°????????????
public:
    int src, dst;
    int weight;
    Edge(int a,int b):src(a),dst(b),weight(1){} //?????????????????????
    void setWeight(double x){
        weight = x;
    }
};
typedef vector<Edge> Edges; //???????????£??\?????????
typedef vector<Edges> Graph; //??°???????????£??\???????????¨???

typedef vector<int> Array; //??´??°?????????
typedef vector<Array> Matrix; //??´??°???????????£??\?????????

const int N = 100;
const int White = 0, Gray = 1, Black =2;

int n;
int tt = 0;
Matrix M(N,Array(N,0));
vector<int> d(N,0), f(N,0);
vector<int> color(N,0);


vector<int> nt(N,0);//???????????????????????????????????§?????????????¨???¶??????

int next(int u){ //???u?????\?¶??????????????????????????????????
    if (nt[u]!= n) {
        for(int i = nt[u];i<n;i++){
            if(M[u][i]){
                nt[u] = i+1;
                return i;
            }
        }
        return -1;
    } else {
        return -1;
    }
}

void dfs_visit(int r){
    for (int i= 0; i<n; i++) {
        nt[i] = 0;
    }
    
    stack<int> S;
    S.push(r);
    color[r] = Gray;
    d[r] = ++tt;
    
    while (!S.empty()) {
        int v = S.top();
        int w = next(v);
        if (w != -1) {
            if (color[w]==White) {
                color[w] = Gray;
                d[w] = ++tt;
                S.push(w);
            }
        } else {
            S.pop();
            color[v] = Black;
            f[v] = ++tt;
        }
    }
    
}

void dfs(){
    for (int i = 0; i<n; i++) {
        color[i] = White;
        nt[i] = 0;
    }
    for (int i = 0; i<n; i++) {
        if (color[i]==White) {
            dfs_visit(i);
        }
    }
    for (int i = 0; i<n; i++) {
        cout << i+1 << " " << d[i] << " " << f[i] << endl;
    }
}


int main(){
    
    int k,v,w;
    
    cin >> n; //??°????????????????????\???
    
    for (int i=0; i<n; i++) { //??????????¬???°?????????????????\??? ???????????\??????????????£??\??????????????£??\?????????????´?
        cin >> w >> k;
        for (int j=0; j<k; j++) {
            cin >> v;
            M[w-1][v-1] = 1; //?????????
        }
    }
    
    dfs();
    
    return 0;
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
#define inf 0x6fffffff
using namespace std;
const int N=5e6+10;
typedef long long ll;
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int main()
{
    string s;cin>>s;
    if(s[0]==s[1]||s[1]==s[2]||s[3]==s[2])puts("Bad");else puts("Good");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

struct UnionFind{
    //iの親番号
    vector<int> par;

    //コンストラクタ
    UnionFind(int N) : par(N){
        for(int i = 0;i < N; i++) par[i] = i;
    }

    //根を見つける
    int root(int x){
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    //2つの木を併合
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
    }

    //所属が同じか
    bool same(int x,int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


int main(){
    fast_io

    int n, m;
    cin>>n>>m;
    vector<int> P(n);
    rep(i,n) cin>>P[i];

    UnionFind tree(n);

    rep(i,m){
        int x, y;
        cin>>x>>y;
        tree.unite(x-1, y-1);
    }
    int cnt=0;
    rep(i,n){
        if(tree.same(i, P[i]-1)){
            cnt++;
        }
    }
    cout<<cnt<<endl;

    return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a > b){
        cout << "a > b" << endl;
    }
    else if(a < b){
        cout << "a < b" << endl;
    }
    else{
        cout << "a == b" << endl;
    }
}



Measured memory_bytes: 3080
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] nString = String.valueOf(n).split("");
        int sum = 0;
        for (int i = 0; i < nString.length; i++) {
            sum += Integer.parseInt(nString[i]);
        }
        
        if (n%sum == 0) System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 35464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll n;
  cin >> n;

  ll ans = 0;

  ll a = 10;

  if (n % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }

  while (1) {
    if (n < a) {
      break;
    }
    ans += (n / a);
    a = a * 5;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        x: usize
    }
    let mut x = x;
    while !is_prime(x) {
        x += 1;
    }
    println!("{}", x);
}

fn is_prime(n: usize) -> bool {
    if n <= 1 {
        return false;
    };
    for i in 2..n / 2 {
        if n % i == 0 {
            return false;
        }
    }
    true
}


Measured memory_bytes: 4352
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
class E { static void Main() { new J(); } }
class J
{
	int F() { return int.Parse(Console.ReadLine()); }
	int[] G() { return Console.ReadLine().Split().Select(_ => int.Parse(_)).ToArray(); }
	int V;
	HashSet<int>[] es, res;
	int[] used;
	public J()
	{
		Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
		var N = F();
		var W = 100;
		V = 2 * W;
		es = new HashSet<int>[V];
		res = new HashSet<int>[V];
		for (var i = 0; i < V; i++) es[i] = new HashSet<int>();
		for (var i = 0; i < V; i++) res[i] = new HashSet<int>();
		for (var i = 0; i < N; i++)
		{
			var I = Console.ReadLine().Split();
			var x = int.Parse(I[0]) - 1;
			var y = int.Parse(I[2]) - 1 + W;
			if (I[1] == "lock") { es[y].Add(x); res[x].Add(y); }
			else { es[x].Add(y); res[y].Add(x); }
		}
		used = new int[V];
		var flag = false;
		for (var i = 0; !flag && i < V; i++) if (used[i] == 0) flag |= DFS(i);
		Console.WriteLine(flag ? 1 : 0);
		Console.Out.Flush();
	}
	bool DFS(int u)
	{
		used[u] = 1;
		foreach (var v in es[u]) if (used[v] == 1 || DFS(v)) return true;
		used[u] = 2;
		return false;
	}
}

Measured memory_bytes: 10104
import java.util.*;

public class Main{
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if((n|m) == 0) break;
			char [][] data = new char[n][m];
			for(int i = 0; i < n; i++){
				String s = sc.next();
				data[i] = s.toCharArray();
			}
			int [][] acc = new int[n][m];
			for(int i = 0; i < n; i++){
				acc[i][m-1] = (data[i][m-1] == '.' ? 1 : 0);
				for(int j = m - 2; j >= 0; j--){
					if(data[i][j] == '.'){
						acc[i][j] = acc[i][j+1] + 1;
					}
					else{
						acc[i][j] = 0;
					}
				}
			}
			
			int ans = 0;
			for(int i = 0; i < n; i++){
				for(int j = 0; j < m; j++){
					int minw = acc[i][j];
					for(int k = 0; i + k < n; k++){
						minw = Math.min(minw, acc[i+k][j]);
						int res = (k + 1) * minw;
						ans = Math.max(ans, res);
					}
				}
			}
			System.out.println(ans);
		}
	}

	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

	public static void main(String[] args) {
		new Main().doit();
	}
}

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

int main(){
  int n, m;
  cin >> n >> m;
  if(n%2){
    int l = 1, r = n;
    for(int i=0; i<m; ++i){
      printf("%d %d\n",l,r);
      ++l;
      --r;
    }
  }else{
    int l=1, r = n-1;
    bool frag = true;
    for(int i=0; i<m; ++i){
      if(frag && r-l <= n/2){
        frag = false;
        ++l;
      }
      printf("%d %d\n",l,r);
      ++l;
      --r;
    }
  }
}

Measured memory_bytes: 3668
n=input()
num=[]
for i in range(4):
    num.append(int(n[i]))
o=["+","+","+"]
op=[1,1,1]
def ans():
    return num[0]+op[0]*num[1]+op[1]*num[2]+op[2]*num[3]
if ans()!=7:
    for i in range(3):
        op[i]=-1
        if ans()==7:
            break
        op[i]=1
if ans()!=7:  
    for i in range(-1,2):
        op[i]=-1
        op[i+1]=-1
        if ans()==7:
            break
        op[i]=1
        op[i+1]=1
if ans()!=7:
    for i in range(3):
        op[i]=-1
for i in range(3):
    if op[i]==-1:
        o[i]="-"
print(n[0]+o[0]+n[1]+o[1]+n[2]+o[2]+n[3]+"=7")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
  cin>>n;
  float a[n];
  for(int i=0;i<n;i++)
  {
  cin>>a[i];}
  for(int i=0;i<n-1;i++)
    for(int j=i;j<n;j++)
    {
    if(a[i]>a[j])
    {float t;
    t=a[i];
    a[i]=a[j];
    a[j]=t;}
    }
  int k=0;int l=1;
  while(k<n-1){
    a[l]=(a[k]+a[l])/2.0;
      k++;l++;
    }
  cout<<a[n-1];
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define xrep(i, a, b) for (int i = int(a); i < int(b); ++i)
int main() {
    int A, B, C;
    cin >> A >> B >> C;

    cout << C << ' '<< A <<  ' ' << B << endl;

    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  if(a+b<24) cout<<a+b<<'\n';
  else cout<<a+b-24<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
inline ll lin() { ll x; scanf("%lld",&x); return x;}
inline char chin() { char x; scanf("%c",&x); return x;}
inline string stin() { string x; cin >> x; return x;}
inline double din() { double x; scanf("%lf",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int k, a, b;
  cin >> k >> a >> b;
  if (a <= b/k*k) cout << "OK" << endl;
  else cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3528
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s;
  cin >> s;
  for(int i = 0; i < s.size()-1; i++) {
    if(s[i] == s[i+1]) {
      cout << "Bad";
      return 0;
    }
  }
  cout << "Good";
  return 0;
}

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

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

    for(int i = 0; i <= 100 / 7; i++){
        for(int j = 0; j <= 100 / 4; j++){
            if(i * 7 + j * 4 == n)
                return cout << "Yes" << endl, 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
S = input()
ans = "-1"
def dfs(n,S,s):
    global ans
    if n == 0:
        s_0 = S[0]
        dfs(n+1,S,s_0)
    else:
        s_1 = s + "+" + S[n]
        s_2 = s + "-" + S[n]
        if n != len(S) - 1:
            dfs(n+1,S,s_1)
            dfs(n+1,S,s_2)
        elif eval(s_1) == 7:
            ans = s_1 + "=7"
        elif eval(s_2) == 7:
            ans = s_2 + "=7"
dfs(0,S,0)
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <cstdlib>
#include <cctype>
using namespace std;

int idx;
string s;
map<string,int> atom;

int Number(){
	string res = "";
	while(isdigit(s[idx])){
		res += s[idx++];
	}
	return atoi(&res[0]);
}

int Atom(){
	string res = "";
	res += s[idx++];
	if(islower(s[idx])){
		res += s[idx++];
	}
	return atom.find(res) != atom.end() ? atom[res] : -1;
}

int Molecule(){
	int res = 0;

	while(idx < s.length() && s[idx] != ')'){
		if(s[idx] == '('){
			idx++;
			int tmp = Molecule();
			if(tmp == -1) return -1;
			idx++;
			res += tmp * Number();
		}
		else{
			int tmp = Atom();
			if(tmp == -1) return -1;
			if(isdigit(s[idx])){
				res += tmp * Number();
			}
			else{
				res += tmp;
			}
		}
	}

	return res;
}

int main(void){
	while(cin>>s,s!="END_OF_FIRST_PART"){
		int w;
		cin>>w;
		atom[s] = w;
	}

	while(cin>>s,s!="0"){
		idx = 0;
		int rst = Molecule();
		if(rst == -1)
			cout<<"UNKNOWN\n";
		else
			cout<<rst<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
const int MOD=1e9+7;


int main() {
    ll n;
    cin >> n;
    ll ans=0;
    if (n%2==0) {
        ll d=5;
        while (n>=d) {
            ans+=(n/d)/2;
            d*=5;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        char[] s = sc.next().toCharArray();
        int max = 0;
        int cnt = 0;
        for (int i = 0; i < s.length; i++) {
            if (s[i] == 'R') {
                cnt++;
                for (int j = i+1; j < s.length; j++) {
                    if (s[j] == 'R')
                        cnt++;
                    else
                        break;
                }
                max = Math.max(cnt, max);
                cnt = 0;
            }
        }

        System.out.println(max);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 32604