akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

long long inv(int a, int p) { return a==1 ? 1 : (1-p*inv(p%a,a))/a+p; }
static const int MODVAL = 1000000007;
struct mint {
  int val;
  mint():val(0){}
  mint(int x):val(x%MODVAL) { if(val<0) val+= MODVAL; }
  mint(size_t x):val(x%MODVAL) {}
  mint(long long x):val(x%MODVAL) { if(val<0) val+= MODVAL; }
  mint& operator+=(mint y) { val+=y.val; if(val>=MODVAL) val-=MODVAL; return *this; }
  mint& operator-=(mint y) { val-=y.val; if(val<0) val+= MODVAL; return *this; }
  mint& operator*=(mint y) { val=(val*(long long)y.val)%MODVAL; return *this; }
  mint& operator/=(mint y) { val=(val*inv(y.val,MODVAL))%MODVAL; return *this; }
};
inline mint operator+(mint x, mint y) { return x+=y; }
inline mint operator-(mint x, mint y) { return x-=y; }
inline mint operator*(mint x, mint y) { return x*=y; }
inline mint operator/(mint x, mint y) { return x/=y; }
mint POW(mint x, long long n) { mint r(1); for(;n;x*=x,n>>=1) if(n&1) r*=x; return r; }
mint FAC(int n) { static vector<mint> FAC_(1,1);
  while(int(FAC_.size())<=n) FAC_.push_back(FAC_.back()*FAC_.size()); return FAC_[n]; }
inline mint CMB(int n, int k) { return k<0||n<k ? 0 : FAC(n) / (FAC(k) * FAC(n-k)); }
inline ostream& operator<<(ostream& os, mint a) { return os << a.val; }

int n;

vector<int> g[200000+5];
struct K {
  mint v;
  int count;
};

map<ll, K> memo;
K solve(int p, int u) {
  ll key = (ll(p) << 32LL) | u;
  if(memo.count(key) == 0) {
    K res;
    res.v = 1;
    res.count = 1;
    vector<int> counts;
    for(int v : g[u]) {
      if(v == p) {
        continue;
      }
      K cur = solve(u, v);
      res.v *= cur.v;
      counts.push_back(cur.count);
      res.count += cur.count;
    }
    int cc = res.count - 1;
    for(int c : counts) {
      res.v *= CMB(cc, c);
      cc -= c;
    }
    memo[key] = res;
  }
  return memo[key];
}

mint ans[200000+10];
void propagate(int p, int u, mint pval, int pcount) {
  mint res = 1;
  vector<int> counts;
  for(int v : g[u]) {
    if(v == p) {
      res *= pval;
      counts.push_back(pcount);
    } else {
      K cur = solve(u, v);
      res *= cur.v;
      counts.push_back(cur.count);
    }
  }
  int cc = n-1;
  for(int c : counts) {
    res *= CMB(cc, c);
    cc -= c;
  }
  ans[u] = res;
  for(int v : g[u]) {
    if(v == p) {
      continue;
    }
    K cur = solve(u, v);
    propagate(u, v, res / cur.v / CMB(n-1, cur.count), n - cur.count);
  }
}

int main(void) {
  scanf("%d", &n);
  REP(i, n-1) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  solve(1000000000, 0);
  propagate(1000000000, 0, 1, 0);

  REP(u, n) {
    printf("%d\n", ans[u].val);
  }
  return 0;
}


Measured memory_bytes: 30312
N, M = map(int, input().rstrip().split())
if N == 0:
    print(-1)
else:
    d = {}
    success_flg = True
    for _ in range(M):
        s, c = map(int, input().rstrip().split())
        if s == 0:
            success_flg = False
            break
        if s > N:
            success_flg = False
            break
        elif s in d.keys() and c != d[s]:
            success_flg = False
            break
        else:
            d[s] = c
    if success_flg:
        tmp_result = '0' * N
        success_flg2 = True
        for s, c in d.items():
            if s == 1 and c == 0 and N != 1:
                success_flg2 = False
                print(-1)
                break
            tmp_result = tmp_result[:s - 1] + str(c) + tmp_result[s:]
        if success_flg2:
            if tmp_result[0] == '0' and N != 1:
                tmp_result = str(1) + tmp_result[1:]
            print(int(tmp_result))
    else:
        print(-1)


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    int a, b;
    cin >> a >> b;
    cout << a - b + 1 << "\n";   
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int d,n;
    cin>>d>>n;
    int tmp=1;
    for(int i=0;i<d;i++){
        tmp*=100;
    }
    if(n==100)cout<<tmp*101<<endl;
    else cout<<tmp*n<<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 a = sc.nextInt();
    int b = sc.nextInt();
    int answer1 = a*b;
    int answer2 = 2*a+2*b;
    System.out.println(answer1 + " " + answer2);
    sc.close();
  }
}



Measured memory_bytes: 26156
N = int(input())
A = []
for _ in range(N):
    a = int(input())
    xy = []
    for __ in range(a):
        xy.append(tuple(map(int,input().split())))
    A.append(xy)

ok = []
for i in range(2**N):
    v = [0] * (N+1)
    n = i
    for j in range(1, N+1):
        v[j] = n % 2
        n >>= 1
    for k, xys in enumerate(A):
        if v[k+1] == 1:
            for xy in xys:
                if xy[1] != v[xy[0]]:
                    break
            else:
                continue
            break
    else:
        ok.append(v)

ans = 0
for a in ok:
    ans = max(ans,sum(a))
print(ans)


Measured memory_bytes: 48732
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int n, k;
int a[100100], b[100100];
vector<int> v;
long long int ans;
int t;

int main(){
	scanf("%d %d", &n, &k);
	for(int i=0; i<n; ++i) scanf("%d %d", &a[i], &b[i]);
	for(int i=29; i>=0; --i){
		if(k>>i&1==1){
//			printf("%d\n", i);
			if(i > 0) v.push_back(t+(1<<i)-1);
			else v.push_back(t+1);
			t += 1<<i;
		}
	}
	v.push_back(t);
	for(int i=0; i<v.size(); ++i){
		long long int tmp = 0;
		for(int j=0; j<n; ++j)
			if((v[i] | a[j]) == v[i])
				tmp += b[j];
//		printf("%d %lld\n", v[i], tmp);
		ans = max(ans, tmp);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define N 20

using namespace std;

int n;
int A[N], ans;
bool isKind[N];

vector < pair<int, bool> > pr[N];

void check(int tot) {
	if(tot < ans) return;
	for(int i = 1; i <= n; ++i) {
		if(!isKind[i]) continue;
		for(int j = 0; j < pr[i].size(); ++j) {
			if(isKind[pr[i][j].first] != pr[i][j].second)
				return;
		}
	}
	ans = max(ans, tot);
}

void dfs(int dep, int tot) {
	if(dep > n) return check(tot);
	isKind[dep] = true;
	dfs(dep + 1, tot + 1);
	isKind[dep] = false;
	dfs(dep + 1, tot);
	return;
}

int main() {
	cin >> n;
	for(int i = 1; i <= n; ++i) {
		cin >> A[i];
		for(int j = 0; j < A[i]; ++j) {
			int x; bool y;
			cin >> x >> y;
			pr[i].push_back(make_pair(x, y));
		}
	}
	
	dfs(1, 0);
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# アキュムレータあり再帰
import sys  # 追加
sys.setrecursionlimit(500*500)

D = 1000000007
n, m = map(int, input().split())
a = [0] * (10**5 + 1)
for i in range(m):
    a[int(input())] += 1

# 初期値
s0 = 1
if (a[1] == 1):
    s1 = 0
else:
    s1 = 1


def calc(l, acc1, acc2):
    # print("calc(l, acc1, acc2):" + str(l) + str(acc1) + str(acc2))
    if (l == 1):
        return acc2
    else:
        oldacc2 = acc2
        acc2 = (acc1 + acc2) % D if a[n - l + 2] == 0 else 0
        acc1 = oldacc2
        return calc(l - 1, acc1, acc2)


print(calc(n, s0, s1))


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

using namespace std;

#define ll  long long
#define ld  double

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

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2005;

typedef pair<int,int>   ii;

struct BIT  {
    #define M   4005

    int t[M];

    int upd(int p)  {
        for(; p < M ; p += p & -p)
            t[p]++;
        return  1;
    }
    int get(int p)  {
        int ans = 0;
        for(; p > 0 ; p -= p & -p)
            ans += t[p];
        return  ans;
    }
}   T1, T2;

int c[N][N][2][2];
int p[N][2];
int f[N][N];

int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int n;  cin >> n;

    for(int i = 1 ; i <= n + n ; ++i)   {
        char c; cin >> c;
        int  x; cin >> x;

        if (c == 'W')   p[x][0] = i;
        if (c == 'B')   p[x][1] = i;
    }
    for(int i = n ; i >= 0 ; --i)   {
        for(int j = 1 ; j <= n ; ++j)   {
            c[i][j][0][0] = T1.get(p[j][0]);
            c[i][j][0][1] = T1.get(p[j][1]);
            c[i][j][1][0] = T2.get(p[j][0]);
            c[i][j][1][1] = T2.get(p[j][1]);
        }
        if (i)  {
            T1.upd(p[i][0]);
            T2.upd(p[i][1]);
        }
    }
    for(int i = 1 ; i <= n + n ; ++i)   {
        int l = max(0,i - n);
        int r = min(n,i);

        for(int c1 = l ; c1 <= r ; ++c1)    {
            int c2 = i - c1;
            int&val = f[c1][c2];
            val = 1e9;

            if (c1) val = min(val,f[c1 - 1][c2] + c[c2][c1][1][0] + c[c1][c1][0][0]);
            if (c2) val = min(val,f[c1][c2 - 1] + c[c1][c2][0][1] + c[c2][c2][1][1]); 
        }
    }
    cout << f[n][n] << endl;
}

Measured memory_bytes: 78720
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
  static InputReader in;
  static PrintWriter out;
  
  static class Solution {
    void solve() throws IOException {
      int n = in.nextInt();
      double[] x = new double[n + 1];
      double[] y = new double[n + 1];
      double dist1  = 0;
      double dist2 = 0;
      double dist3 = 0;
      double distinf = 0;
      
      for (int i = 1; i <= n; i++) {
        x[i] = in.nextDouble();
      }
      for (int i = 1; i <= n; i++) {
        y[i] = in.nextDouble();
      }
      
      for (int i = 1; i <= n; i++) {
        dist1 += Math.abs(x[i] - y[i]);
      }
      
      for (int i = 1; i <= n; i++) {
        dist2 += Math.pow(Math.abs(x[i] - y[i]), 2);
      }
      dist2 = Math.sqrt(dist2);
      
      for (int i = 1; i <= n; i++) {
        dist3 += Math.pow(Math.abs(x[i] - y[i]), 3);
      }
      dist3 = Math.cbrt(dist3);
      
      double max = 0;
      for (int i = 1; i <= n; i++) {
        max = Math.max(max, Math.abs(x[i] - y[i]));
      }
      distinf = max;
      
      out.printf("%.5f\n%.5f\n%.5f\n%.5f\n", dist1, dist2, dist3, distinf);
//      End solve()
    }
//    End Solution
}


  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}


  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;

    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }

    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }

    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken());
    }

    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }

    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }

  }

}

Measured memory_bytes: 24904
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>

using namespace std;

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    
    cout << min((a*b), c);
}


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

int main() {
  bool flag=false;
  int a,b;
  cin >> a >> b;
  r(i,1000){
    int c=i*0.08,d=i*0.1;
    if(c==a&&b==d){
      cout<<i<<endl;
      flag=true;
      break;
    }
  }
  if(!flag) cout<<-1<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int func(int n){
    if (n%2 == 0)return n/2;
    return (3*n + 1);
}


int main() {
    int s;
    cin >> s;
    vector<int>a;
    map<int, int>mp;
    a.push_back(s);
    mp[s]++;
    for (int i=1; i<pow(10, 9); i++){
        a.push_back(func(a.at(i-1)));
        if (mp[a.at(i)] == 1){
            cout << i+1 << endl;
            return 0;
        }
        mp[a.at(i)]++;
    }
}

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

int main(){
  int i;
  ll a,mina,allsum,minus,zeros;
  int N;
  cin >> N;
  minus = 0;
  zeros = 0;
  allsum = 0;
  mina = pow(10,9);
  for(i=0;i<N;i++){
    cin >> a;
    if(a < 0) minus ++;
    if(a == 0) zeros++;
    allsum += abs(a);
    mina = min(mina, abs(a));
    //cout << allsum << " " << mina << endl;
  }
  if(minus%2==1 && zeros==0) allsum -= 2*mina;
  cout << allsum << endl;
}

Measured memory_bytes: 256
package main

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

type ByValue []float64

func (s ByValue) Len() int           { return len(s) }
func (s ByValue) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s ByValue) Less(i, j int) bool { return s[i] < s[j] }

func input() string {
	var s string
	_, _ = fmt.Scan(&s)
	return s
}

func inputLn() string {
	var s string
	_, _ = fmt.Scanln(&s)
	return s
}

func inputByScanner(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func convListStrToInt(strList []string) []int {
	intList := make([]int, len(strList))
	for k, v := range strList {
		intV, _ := strconv.Atoi(v)
		intList[k] = intV
	}
	return intList
}

func convListStrToFloat(strList []string) []float64 {
	intList := make([]float64, len(strList))
	for k, v := range strList {
		intV, _ := strconv.Atoi(v)
		intList[k] = float64(intV)
	}
	return intList
}

func main() {
	n, _ := strconv.Atoi(inputLn())
	hList := make([]int, n)
	for i := 0; i < n; i++ {
		conved, _ := strconv.Atoi(input())
		hList[i] = conved
	}
	maxCnt := 0
	cnt := 0
	for i := 0; i < n-1; i++ {
		if hList[i+1] <= hList[i] {
			cnt++
			if i == n-2 {
				if maxCnt < cnt {
					maxCnt = cnt
				}
			}
		} else {
			if maxCnt < cnt {
				maxCnt = cnt
			}
			cnt = 0
		}
	}
	fmt.Println(maxCnt)
}


Measured memory_bytes: 5504
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>

using namespace std;


int main(void) {
	long long int k, a, b; cin >> k >> a >> b;

	long long int x = 1;
	bool flag = false;

	if (a + 1 >= b) { cout << x + k << endl; return 0; }
	if (k <= a) { cout << x + k << endl; return 0; }

	k -= a - x;
	x = a;

	if (k % 2 == 1) {
		x += (k / 2)*(b - a)+1;
	}
	else { x += (k / 2)*(b - a); }

	cout << x << endl;

	return 0;
}

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

const int N = 2e5 + 10;
struct E {int v, nt;} e[N << 1];
int n, m, ans, tot, h[N], stk[N], val[N], del[N], ts[N][2];

inline void add(int u, int v) {
	e[++tot] = (E){v, h[u]}, h[u] = tot;
	e[++tot] = (E){u, h[v]}, h[v] = tot;
}

template <class T> inline void in(T &x) {
	x = 0; int f = 0; char ch = getchar();
	for (; ch<'0' || ch>'9';) {if (ch=='-') f=-1; ch = getchar();}
	for (; ch>='0' && ch<='9';) x = x*10 + ch-'0', ch = getchar();
	x = f ? -x : x;
}

inline void read() {
	int ls = 0; char ch = getchar();
	for (; ch<'A' || ch>'B';) ch = getchar();
	for (; ch>='A' && ch<='B';) val[++ls] = ch - 'A', ch = getchar();
}

int main() {
	int u, v; in(n), in(m), read();
	for (int i = 1; i <= m; ++i) in(u), in(v), add(u, v);
	for (u = 1; u <= n; ++u) {
		for (int i = h[u]; i; i = e[i].nt)
			++ts[u][val[e[i].v]];
	}
	queue <int> q;
	for (int i = 1; i <= n; ++i)
		if (!ts[i][0] || !ts[i][1]) del[i] = 1, q.push(i);
	for (; !q.empty();) {
		u = q.front(), q.pop();
		for (int i = h[u]; i; i = e[i].nt) {
			--ts[v = e[i].v][val[u]];
			if (!ts[v][val[u]] && !del[v]) del[v] = 1, q.push(v);
		}
	}
	for (int i = 1; i <= n; ++i) if (!del[i]) {puts("Yes"); return 0;}
	puts("No"); return 0;
}

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

int main()
{
    // input
    int n, m;
    cin >> n >> m;
    vector<vector<int>> s;
    vector<int> k(m);
    rep(i,m){
        cin >> k[i];
        vector<int> tmp(k[i]);
        rep(j,k[i]) cin >> tmp[j];
        s.emplace_back(tmp);
    }
    vector<int> p(m);
    rep(i,m) cin >> p[i];

    // solve
    int cnt=0;
    for(int bit=0; bit<(1<<n); ++bit){
        rep(i,m){
            int tmp=0;
            rep(j,k[i]) if( bit & (1<<(s[i][j]-1)) ) tmp++;
            if(tmp%2!=p[i]) break;
            else if(i+1==m) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

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

    int D=0;

    for(int i=0;i<N-1;i++){
        D=max(D,d[i]);

        if(D<10){
            cout<<"no"<<endl;
            return 0;
        }
        D-=10;
    }
    D=0;
    for(int i=N-1;i>0;i--){
        D=max(D,d[i]);

        if(D<10){
            cout<<"no"<<endl;
            return 0;
        }
        D-=10;
    }

    cout<<"yes"<<endl;
    return 0;

}


Measured memory_bytes: 4272
import java.util.*;

public class Main{
	int n, cnt, cnum, maxlen;
	ArrayList<Character> clist, tlist;
	char[][] c;
	String[] s;
	int[] b;
	
	
	void check(int[] perm){	
		int ten = 1;
		int suma = 0;
		int sumb = 0;
		for(int i=0;i<maxlen;i++){
			sumb = 0;
			for(int j=n-b[i];j<n;j++){
				if(j==n-1) sumb -= perm[clist.indexOf(c[j][i])];
				else sumb += perm[clist.indexOf(c[j][i])];
			}
			suma += sumb*ten;
			ten *= 10;
			if(suma%ten!=0) break;
		}
		if(suma==0) cnt++;
	}
	
	void makeperm(int k, int[] perm, boolean[] flag){
		if(k==cnum){
			check(perm);
		}else{
			for(int i=0;i<10;i++){
				if(flag[i]==true || (i==0 && tlist.contains(clist.get(k))==true)) continue;
				perm[k] = i;
				flag[i] = true;
				makeperm(k+1, perm, flag);
				flag[i] = false;
			}
		}
	}
	
	
	void solve(){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			n = sc.nextInt();
			if(n==0) break;
			s = new String[n];
			for(int i=0;i<n-1;i++) s[i] = sc.next();
			s[n-1] = "xxxxxxxxxx";
			Arrays.sort(s, new Comparator<String>(){
				public int compare(String o1, String o2){
					return o1.length() - o2.length();
				}
			});
			s[n-1] = sc.next();
			
			if(s[n-1].length()<s[n-2].length() || s[n-1].length()>s[n-2].length()+2){
				System.out.println(0);
			}else{
				clist = new ArrayList<Character>();
				tlist = new ArrayList<Character>();
				c = new char[n][];
				maxlen = s[n-1].length();
				b = new int[maxlen];
				
				for(int i=0;i<n;i++){
					char[] tmp = s[i].toCharArray();
					c[i] = new char[tmp.length];
					for(int j=0;j<tmp.length;j++){
						if(j==0 && tmp.length>1 && tlist.contains(tmp[j])==false) tlist.add(tmp[j]);
						if(clist.contains(tmp[j])==false) clist.add(tmp[j]);
						c[i][tmp.length-1-j] = tmp[j];
						b[j]++;
					}
				}
				
				cnum = clist.size();
				cnt = 0;
				makeperm(0, new int[cnum], new boolean[10]);
				System.out.println(cnt);
			}			
		}
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}	
}

Measured memory_bytes: 25160
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

int ans, cnt;
int n, m, q;
vector<int> a, b, c, d;

void dfs(vector<int> A) {
	if (A.size() == n + 1) {
		int now = 0;
		rep(i, q) {
			if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
		}
		ans = max(ans, now);
		/*rep(i, A.size()) {
			cout << A[i] << " ";
		}
		puts("");*/
		return;
	}

	A.push_back(A.back());
	while (A.back() <= m) {
		dfs(A);
		A.back()++;
	}
}

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

	cin >> n >> m >> q;

	a = b = c = d = vector<int>(q);
	rep(i, q) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
	dfs(vector<int>(1, 1));
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3660
n,k = map(int,input().split())

"""
Kが奇数なら, a=b=c=0(mod K)のみ
Kが偶数なら, a=b=c=K/2(mod K)「も」
"""

# n以下のmod Kがrの数の個数
def f(r):
    if r == 0: r = k
    return len(range(r, n + 1, k))

res = 0

# = 0
res += f(0) ** 3

# = k / 2
if k % 2 == 0:
    res += f(k // 2) ** 3

print(res)


Measured memory_bytes: 38384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
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);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll a[100010];
ll n,m,v,p;
int main(){
	scanf("%lld%lld%lld%lld",&n,&m,&v,&p);
	rep(i,0,n)scanf("%lld",a+i);
	sortdown(a,n);
	ll sum=0;
	ll cnt=0;
	ll ans=p-1;
	//[p-1,i)の範囲について、a[i]+m-a[k]の和を考える
	rep(l,p-1,n){
		cnt++;
		if(l!=n-1&&a[l]==a[l+1])continue;
		sum+=a[l]*cnt;
		if(a[l]+m>=a[p-1]){
			ll xxx=m*(p-1);
			ll yyy=((a[l]+m)*(l-(p-1))-sum)+a[l];
			yyy=max(0,yyy);
//			printf("%lld %lld\n",(a[l]+m)*(l-(p-1)),sum);
			ll zzz=m*(n-1-l);
//			printf("%lld %lld %lld %lld\n",l,xxx,yyy,zzz);
			if(xxx+yyy+zzz>=m*(v-1))ans+=cnt;
			cnt=0;
		}else{
			break;
		}
	}
	
	printf("%lld",ans);
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;
int a[100005];
int dp[100005];
int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++) scanf("%d",&a[i]);
	int k=1;
	dp[0]=1;
	for(int i=1;i<=n;i++){
		if(i==a[k]){
			k++;
			dp[i]=0;
			continue;
		}
		dp[i]=(dp[i-1]%mod+dp[i-2]%mod)%mod;
	}
	printf("%d",dp[n]%mod);
	return 0;
}

Measured memory_bytes: 1024
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#define log(args...)
#else
#define log(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); logf(_it, args); }
void logf(istream_iterator<string> it) {
}
template<typename T, typename ... Args>
void logf(istream_iterator<string> it, T a, Args ... args) {
	cout << *it << " = " << a << endl;
	logf(++it, args...);
}
#endif

#define forn(i,k,n) for(ll i=(k); i<(n); i++)

const double PI = acos(-1);
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

void solve() {
	cini(h);
	cini(a);
	int ans = (h + a - 1) / a;
	cout << ans << endl;

}

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



Measured memory_bytes: 256
total_reward = 0
for i in map(int, input().split()):
    if i == 1:
        total_reward+=300000
    elif i ==2 :
        total_reward+= 200000
    elif i ==3 :
        total_reward+= 100000
if total_reward== 600000:
    total_reward = total_reward + 400000
print(total_reward)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[2][n];
    for(int i=0;i<2;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }
    int u=0,ans=0;
    for(int i=0;i<n;i++){
        u+=a[0][i];
        int l=0;
        for(int j=i;j<n;j++){
            l+=a[1][j];
        }
        ans=max(ans,u+l);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    A, B = map(int, input().split())

    ans = [[""] * 100 for _ in range(100)]
    for y in range(100):
        for x in range(100):
            if x < 50:
                ans[y][x] = "#"
            else:
                ans[y][x] = "."
    A -= 1
    B -= 1
    for y in range(1, 100, 2):
        for x in range(1, 100, 2):
            if 10 < x < 40:
                if A > 0:
                    ans[y][x] = "."
                    A -= 1
            if 60 < x < 90:
                if B > 0:
                    ans[y][x] = "#"
                    B -= 1

    print(100, 100)
    for line in ans:
        print("".join(line))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3952
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<iomanip>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{ {-1,0},{1,0},{0,-1},{0,1} };
const int z = 1000000007;
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
int main() {
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    vector<llong> vec(n);
    llong ans = 1;
    llong sh = 1000000000000000000;
    REP(i, n) {
        cin >> vec[i];
        if (vec[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    REP(i, n - 1) {
        ans *= vec[i];
        if (sh / ans < vec[i + 1]) {
            cout << -1 << endl;
            return 0;
        }
    }
    ans *= vec[n - 1];
    cout << ans << endl;
    return 0;
}


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

int main(){
	while(1){
		int n,p,d1,d2,max=0,maxn;
		cin >> n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin >> p >> d1 >> d2;
			if(d1+d2>=max){
				max=d1+d2;
				maxn=p;
			}
		}
		cout << maxn << " " << max << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int N, M;
	bool IsPossible = false;
	cin >> N >> M;

	vector<vector<int>> nodes(N);

	int a, b;
	for (int i = 0; i < M; i++)
	{
		cin >> a >> b;
		a--;
		b--;

		nodes[a].push_back(b);
		nodes[b].push_back(a);
	}
	
	for (int i = 0; i < nodes[0].size(); i++)
	{
		for (int j = 0; j < nodes[nodes[0][i]].size(); j++)
		{
			if (nodes[nodes[0][i]][j] == N - 1)
			{
				IsPossible = true;
				break;
			}
		}

		if (IsPossible)
			break;
	}

	if (IsPossible)
		cout << "POSSIBLE" << endl;
	else
		cout << "IMPOSSIBLE" << endl;

	return 0;
}


Measured memory_bytes: 12016
#pragma GCC optimize("03")
#include <bits/stdc++.h>
#define ll long long 
#define fi first
#define se second

using namespace std;

int h[100100], n, k;
ll dp[100100];

int main() {    
    // ifstream cin("tst.in");
    // ofstream cout("tst.out");
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> h[i];

    for (int i = 1; i <= n; i++)
        dp[i] = 2e9;
    dp[1] = 0;

    for (int i = 2; i <= n; i++)
        for (int j = 1; j <= 2; j++)
            if (i - j > 0)
                dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));

    cout << dp[n];

    return 0;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	int n, m;
	cin >> n >> m;
	char ndp[100][100] = {};
	char mdp[100][100] = {};
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			char a;
			cin >> a;
			ndp[i][j] = a;
		}
	}
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < m; j++) {
			char a;
			cin >> a;
			mdp[i][j] = a;
		}
	}
	for (int i = 0; i <= n - m; i++) {
		for (int j = 0; j <= n - m; j++) {
			for (int k = 0; k < m; k++) {
				int c = 0;
				for (int l = 0; l < m; l++) {
					if (mdp[k][l] != ndp[k + i][l + j]) {
						c = 1;
						break;
					}
				}
				if (c == 1) {
					break;
				}
				if (k == m - 1) {
					cout << "Yes";
					return 0;
				}
			}
		}
	}
	cout << "No";

}

Measured memory_bytes: 256
while true do
  n = gets.to_i
  break if n == 0

  people_num = [ 0, 0, 0, 0, 0, 0, 0, ]
  n.times do 
    age = gets.to_i
    if age < 10 then
      people_num[0] += 1
    elsif age < 20 then
      people_num[1] += 1
    elsif age < 30 then
      people_num[2] += 1
    elsif age < 40 then
      people_num[3] += 1
    elsif age < 50 then
      people_num[4] += 1
    elsif age < 60 then
      people_num[5] += 1
    else
      people_num[6] += 1
    end
  end
  people_num.each do |n|
    puts n
  end
end

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


int main(void){
    int x, a, b;
    scanf("%d%d%d", &x, &a, &b);

    long c = labs(x-a);
    long d = labs(x-b);

    if(c < d){
        printf("A\n");
    }else if(c > d){
        printf("B\n");
    }

    return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll n;
string str;
ll dp[3001][3001];
ll tmp[3001];

int main() {
    cin >> n >> str;
    rep(i,n) dp[0][i] = 1;
    rep(i,str.size()) {
        memset(tmp, 0, sizeof(tmp));
        if (str[i] == '<') {
            rep(j,n-i) {
                tmp[j] = dp[i][j];
                if (j) tmp[j] = (tmp[j]+tmp[j-1])%MOD;
            }
            for (int j = 0; j < n-i-1; j++) {
                dp[i+1][j] = tmp[j];
            }
        } else {
            for (int j = n-i-1; j >= 0; j--) {
                tmp[j] = dp[i][j];
                if (j != 1- n-i-1) tmp[j] = (tmp[j]+tmp[j+1])%MOD;
            }
            for (int j = 0; j < n-i-1; j++) {
                dp[i+1][j] = tmp[j+1];
            }
        }
    }
    cout << dp[n-1][0] << endl;
}



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

int main(){
	string s;
  	int k;
  	cin >> s >> k;
  	set<string> da;
  	int n=s.size();
  	for (int i=0;i<n;i++){
    	for (int j=1;j<=min(k,n-i);j++){
      	string t=s.substr(i,j);
        da.insert(t);
        }
    }
  	auto pos = da.begin();
    for(int i = 0; i < k-1; i++)pos++;
  	cout << *pos << endl;
}

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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int a2=pow(a,2);
    int b2=pow(b,2);
    int c2=pow(c,2);
    float A=pow((a2+b2+c2)*0.5,0.5);
    if (a==A){
        cout<<c*b*0.5<<endl;
    }else if(b==A){
        cout<<a*c*0.5<<endl;
    }else{
        cout<<a*b*0.5<<endl;
    }
return 0;
}



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

int main ()
{
    int n;
    cin>>n;
    set<int> num;
    int ans=0,temp;
    for(int i=0;i<n;i++)
    {
        cin>> temp;
        num.insert(temp);
        if(*begin(num)==temp)
        ans+=1;
    }
    cout<<ans;
}

Measured memory_bytes: 9600
from math import factorial

x, y = map(int, input().split())
fl = True
a = ((2*x - y)/3)
b = ((2*y - x)/3)
if a < 0 or b < 0 or a % 1 != 0 or b % 1 != 0:
  fl = False

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

  

if fl:
  a = int(a)
  b = int(b)
  ans = cmb(a + b,a,mod)
  print(ans)
else:
  print(0)

Measured memory_bytes: 121828
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	ll N;
	cin >> N;
	cout << N * (N - 1) / 2 << endl;

	return 0;
}

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

int main() {

    int N, M;
    cin >> N >> M;

    int A[50], B[50];

    rep(i, M) cin >> A[i] >> B[i];

    int road[50];
    rep(i, N) road[i] = 0;

    rep(i, M) {
        road[A[i]-1] += 1;
        road[B[i]-1] += 1;
    }

    rep(i, N) cout << road[i] << endl;

    return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int D = sc.nextInt();
        int count = 0;
        for (int i = 0 ; i < N ; i++ ) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            if (Math.sqrt(Math.pow(x,2) + Math.pow(y,2)) <= D)
                count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 59628
L, R = map(int, input().split())

x = 2020

if R - L > 2019:
    print(0)

else:
    for i in range(R+1)[L:]:
        for j in range(R+1)[i+1:]:

            mod = i * j % 2019

            x = min(mod, x)

    print(x)


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

using namespace std;
using ll = long long;
using ld = long double;

namespace NyaGadget
{	// DFSライブラリ

	struct DFSedge
	{
		ll vertex;	// 頂点
		DFSedge(ll v) { vertex = v; }
	};

	template <class TE = DFSedge> struct DFS
	{
		using Graph = vector<vector<TE>>;
		Graph graph;

		DFS(ll size) { graph.resize(size); }
		vector<TE>& operator [](int n) { return graph[n]; }

		void CreateEdge(ll v1, ll v2)
		{
			graph[v1].push_back(DFSedge(v2));
			graph[v2].push_back(DFSedge(v1));
		}
	};

}

#define all(collection) (collection).begin(), (collection).end()  // begin to end
#define ceil(a, b) ceil((ld) a / (ld) b);                         // div ceiling
#define each(e, collection) for(auto& e: collection)              // for each
#define rep(i, begin, end) for (ll i = begin; i < end; i++)       // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)      // repeat reverse
#define size(collection) ((ll) (collection).size())               // collection size

using namespace NyaGadget;

/**
@brief 深さ優先探索
@param v 頂点
@param r 根
@param g 処理するグラフ
@param memo 前処理したメモ(加算するべきカウンタの値)
@param ans 出力する答えを格納する配列
@note
 DFSで全てのノードを処理する。
**/
void Solve(ll r, ll v, DFS<>& dfs, vector<ll>& memo, vector<ll>& ans)
{
	if (r != -1)
		ans[v] = ans[r] + memo[v];

	each(e, dfs[v])
	{	// 後戻りしないようにする
		if (e.vertex == r)
			continue;

		Solve(v, e.vertex, dfs, memo, ans);
	}
}

int main(void)
{
	ll n, q; cin >> n >> q;

	ll u, v;
	DFS<> dfs(n);
	rep(i, 0, n - 1)
	{
		cin >> u >> v;
		--u; --v;
		dfs.CreateEdge(u, v);
	}

	vector<ll> p(q), x(q);
	rep(i, 0, q)
	{
		cin >> p[i] >> x[i];
		p[i]--;
	}

	// 頂点xで加算するべきカウンタの値をメモしておく。
	vector<ll> memo(n);
	rep(i, 0, q)
		memo[p[i]] += x[i];

	vector<ll> ans(n);
	ans[0] = memo[0];
	Solve(-1, 0, dfs, memo, ans);

	each (e, ans)
		cout << e << " ";

	return 0;
}


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

int main(){
//    int a, b , c, d, e, k;
//    cin >> a >> b >> c >> d >> e >> k;
    long long N;
    cin >> N;
    long long a[5];
    for(int i=0;i<5;i++){
        cin >> a[i];
    }
    sort(a, a+5);

    long long timeSum = 5;
    if(N%a[0] == 0){
        timeSum += N/a[0] - 1;
    }else{
        timeSum += N/a[0];
    }
    cout << timeSum << endl;
}

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


int main(void){
	string s;
	cin>>s;
	s[3] = '8';
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> answer(Q);
  vector<int> players(N);
  
   for(int i=0;i<Q;i++){
    cin >> answer[i];
    players[(answer[i]-1)]++;
  }  
 
  for(int i=0;i<N;i++){
    players[i] = K - Q + players[i];
    if(players[i] > 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 1408
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val maps = mutableMapOf<String, Long>()
    for (i in 0 until n) {
        val str = readLine()!!.toCharArray().sorted().toString()
        val num = maps[str] ?: 0
        maps[str] = num + 1
    }
    println(maps.values.fold(0L) { acc, l -> acc + (l * (l-1) / 2) })
}


Measured memory_bytes: 83464
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int banned = scan.nextInt();
		
		int scoreR = scan.nextInt();
		int scoreS = scan.nextInt();
		int scoreP = scan.nextInt();
		
		String s = scan.next();
		
		char[] hand = s.toCharArray();
		int cnt = 0;
		for (int i = 0; i < hand.length; i++) {
			switch (hand[i]) {
	        case 'r':
	        	if (i - banned < 0) {
	        		cnt += scoreP;
	        		break;
	        	}
	        	
	        	if (hand[i] == hand[i - banned]) {
	        		hand[i] = 'a';
	        		break;
	        	}
	        	
	        	cnt += scoreP;
	            break;
	        case 's':
	        	if (i - banned < 0) {
	        		cnt += scoreR;
	        		break;
	        	}
	        	
	        	if (hand[i] == hand[i - banned]) {
	        		hand[i] = 'a';
	        		break;
	        	}
	        	
	        	cnt += scoreR;
	            break;
	        case 'p':
	        	if (i - banned < 0) {
	        		cnt += scoreS;
	        		break;
	        	}
	        	
	        	if (hand[i] == hand[i - banned]) {
	        		hand[i] = 'a';
	        		break;
	        	}
	        	
	        	cnt += scoreS;
	            break;
	        }
		}
		
		System.out.println(cnt);
		
		
	}
}

Measured memory_bytes: 27352
const Main = (input) => {
  var arr = input.split('');
  var count = 0;
  for(var i=0, l=arr.length; i<l; i++) {
    if(arr[i] === '1') count++;
  }
  console.log(count);
};

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var nk = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var h = Console.ReadLine().Split(' ').Select(int.Parse);

        var answer = h.Count(x => x >= nk[1]);

        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 17888
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
 
int main() {
  string s;
  cin >> s;
  ll ans = 0;
  for(int mask = 0; mask < (1 << (s.length()-1)); ++mask){
      ll num = s[0] - '0';
      for(int i = 0; i < s.length()-1; ++i){
          if(mask & (1 << i)){
              ans += num;
              num = 0;
          }
          num = num * 10 + (s[i+1] - '0');
      }
      ans += num;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
x,k,d = list(map(int, input().split()))
amari = abs(x) % d
shou = abs(x) // d

amari_ = abs(amari - d)
if k < shou:
  print(abs(x) - d * k)
else:
  if (k - shou) % 2 == 0:
    print(amari)
  else:
    print(amari_)

Measured memory_bytes: 9036
package main

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

func main() {
	N := nextInt()
	As := nextInts(N)

	visited := make(map[int]bool)
	stack := [][]int{{1, 0}}
	for len(stack) > 0 {
		var status []int
		stack, status = stack[:len(stack)-1], stack[len(stack)-1]
		button, count := status[0], status[1]
		if visited[button] {
			continue
		}
		if button == 2 {
			fmt.Println(count)
			return
		}
		visited[button] = true
		stack = append(stack, []int{As[button], count + 1})
	}
	fmt.Println(-1)
}

func nextInts(n int) []int {
	ret := make([]int, n+1)
	for i := 1; i <= n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer(make([]byte, 256), 1e9)
	sc.Split(bufio.ScanWords)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}


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

int main(){
    int n,x;
    cin>>n>>x;
    while(n!=0|x!=0){
        int sum=0;
        for(int i=1; i<=n; ++i){
            for(int j=i+1; j<=n; ++j){
                int k=x-i-j;
                if(k!=i&&k!=j&&k>j&&k<=n)sum++;
            }
        }
        cout<<sum<<endl;
        cin>>n>>x;
    }
    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5])
    {
        cout << "Yes" << endl;
    }
    else 
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,m,n) for (int i = m; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b;}
template<class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b;}
template<class T> void drop(const T &x) { std::cout<<x<<endl; exit(0);}
void debug_out() { std::cout << "\n";}
template<class T, class... Args> void debug_out(const T &x, const Args &... args) { std::cout<<x<< " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

struct InitIO{
  InitIO() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
  }
}init_io;

int main() {
  int n, m;
  ll k;
  cin >> n >> m >> k;
  vector<ll> a(n), b(m);
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i];
  ll sum = 0;
  int cnt = 0, itr1 = 0;
  rep(i, n) {
    if (sum + a[i] <= k) sum += a[i], cnt++, itr1 = i;
    else break;
  }
  int ans = cnt;
  rep(i, m) {
    if (sum + b[i] <= k) sum += b[i], cnt++;
    else {
      while (sum > 0 && itr1 >= 0) {
        sum -= a[itr1--];
        cnt--;
        if (sum + b[i] <= k) break;
      }
      if (sum + b[i] <= k) sum += b[i], cnt++;
      else break;
    }
    chmax(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6356
n, m = map(int,input().split())
h = [0] + list(map(int,input().split()))
ab = [[] for i in range(n+1)]

for i in range(m):
    a,b = map(int,input().split())
    ab[a].append(b)
    ab[b].append(a)

ans = 0
for i in range(1,n+1):
    now = h[i]
    next = 0
    for j in ab[i]:
        next = max(next, h[j])
    if now > next:
        ans += 1

print(ans)

Measured memory_bytes: 29516
A, B, C = map(int, input().split())
K = int(input())
M = max(A, B, C)
if M == A:
    print(M*(2**K) + B + C)
elif M == B:
    print(A + M*(2**K) + C)
else:
    print(A + B + M*(2**K))

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void){
	int i,j,k,len,flg,ilen;
	char s[201];
	cin>>s;
	len=strlen(s);
	if(len%2!=0) len-=1;
	for(i=2;i<len;i+=2){
		ilen=(len-i)/2;
		flg=1;
		for(j=0;j<ilen;j++){
			if(s[j]!=s[ilen+j]){
				flg=0;
				break;
			}
		}
		if(flg==1){
			cout<<len-i<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(void){
  using namespace std;
  char a;
  cin >> a;
  if(a=='a' || a=='i' || a=='u' || a=='e' || a=='o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}
  

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

using namespace std;

long gcd(long a, long b) {
	for (; b; swap(a, b))
		a %= b;
	return a;
}
long lcm(long a, long b) {
	a /= gcd(a, b);
	if (double(a)*b > 1e15)
		throw 0;
	return a * b;
}
long lcm(long a[]) {
	return lcm(lcm(a[0], a[1]), lcm(a[2], a[3]));
}
long a[555][555];
int p[10000];
vector<int> q;
int main() {
	for (int i = 2; i < 100; i++)
		if (!p[i]) for (int j = i * i; j < 10000; j += i)
			p[j] = 1;
	for (int i = 2; i < 10000; i++)
		if (!p[i]) q.push_back(i);
	int N;
	cin >> N;
	int n = min(N * 2, 500);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if ((i + j) % 2) continue;
			a[i][j] = q[(i + j) / 2] * q[(n - 2 + i - j) / 2 + n];
		}
	}
	int s[] = { 0,1,0,-1,0 };
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if ((i + j) % 2 == 0) continue;
			long y[] = { 1,1,1,1 };
			for (int k = 0; k < 4; k++)
				if (i + s[k] >= 0 && i + s[k] < n&&j + s[k + 1] >= 0 && j + s[k + 1] < n)
					y[k] = a[i + s[k]][j + s[k + 1]];
			a[i][j] = lcm(y) + 1;
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++)
			cout << a[i][j] << ' ';
		cout << '\n';
	}
	cout << flush;
	return 0;
}


Measured memory_bytes: 5376