akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iterator>
#include<math.h>

using namespace std;
#define int long long
/*                      */    //#undef int
#define INF 1000000009
#define INFL 1000000000000000018ll
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mk(a, b) make_pair(a, b)
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<PA, vector<PA>, greater<PA> >PQG;

int a, b, d[9] = {-1, -1, 0, 1, -1, 1, 1, 0, -1};
char c[110][110];

signed main()
{
    cin >> a >> b;
    for(int i = 1; i <= 100; i++){
        for(int j = 1; j <= 100; j++){
            if(i <= 50){
                c[i][j] = '.';
            }
            else{
                c[i][j] = '#';
            }
        }
    }
    int cnt1 = 0, cnt2 = 0;
    for(int i = 1; i <= 100; i++){
        for(int j = 1; j <= 100; j++){
            if(i <= 49){
                bool flag = false;
                for(int k = 0; k < 8; k++){
                    if(c[i + d[k]][j + d[k + 1]] == '#'){
                        flag = true;
                    }
                }
                if(!flag && cnt1 < b - 1){
                    c[i][j] = '#';
                    cnt1++;
                }
            }
            else if(i >= 52){
                bool flag = false;
                for(int k = 0; k < 8; k++){
                    if(c[i + d[k]][j + d[k + 1]] == '.'){
                        flag = true;
                    }
                }
                if(!flag && cnt2 < a - 1){
                    c[i][j] = '.';
                    cnt2++;
                }
            }
        }
    }
    printf("100 100\n");
    for(int i = 1; i <= 100; i++){
        for(int j = 1; j <= 100; j++){
            printf("%c", c[i][j]);
        }
        printf("\n");
    }

    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int T = sc.nextInt();
      	int sum=0;
      	sc.close();
		for(int i=1;i<T+0.5;i++){
          if(i%A==0){
      			sum+=B;
          }
        }
		System.out.println(sum);
	}
}

Measured memory_bytes: 23636
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using static System.Math;

class Program{
	static string s;

	static void Main(){
		s = Console.ReadLine();
		for (int i = 0;i < s.Length - 1;i++){
			if (s[i] == s[i + 1]){
				Console.WriteLine("{0} {1}",i + 1,i + 2);
				return;
			}
			if (i != s.Length - 2 && s[i] == s[i + 2]){
				Console.WriteLine("{0} {1}",i + 1,i + 3);
				return;
			}
		}
		Console.WriteLine("-1 -1");
	}
}

Measured memory_bytes: 13524
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7

AA = 0
ans = 0
for a in A:
    AA = (AA + pow(a, 2, MOD))%MOD
    ans = (ans + a%MOD)%MOD
inverse2 = pow(2, MOD-2, MOD)
ans = (((pow(ans, 2, MOD) - AA%MOD)%MOD)*inverse2)%MOD
print(ans%MOD)


Measured memory_bytes: 94236
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <iomanip>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define fi first
#define se second
#define ll long long
#define pb push_back
#define int long long
#define vi vector<int>
#define lowbit(x) x&(-x)
#define pii pair<int,int>
#define umap unordered_map
#define uset unordered_set
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);

using namespace std;

const int INF = 0x3f3f3f3f;



signed main() {
	IOS;
#ifdef xiaofan
	freopen("in.txt","r",stdin);
#endif
	int n,m;
	cin>>n>>m;
	for(int i=m/n;i>=1;i--){
		if(m%i==0){
			if(m/i>=n){
				cout<<i<<endl;
				break;
			}
		}
	}
	
	



#ifdef xiaofan
	cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()


class UnionFind {
private:
	vector<ll> data;
public:
	UnionFind(ll size) : data(size, -1) { }
	bool union_set(ll x, ll y) { //x が入っている集合と y が入っている集合を併合する．
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool find_set(ll x, ll y) { // x と y が同じ集合に入っているかどうかを判定する．
		return root(x) == root(y);
	}
	ll root(ll x) { // x のみが入る集合 {x} を作る．
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	ll size(ll x) { // x が入っている集合の大きさを調べる.
		return -data[root(x)];
	}
};


int main() {
	ll N, M;
	cin >> N >> M;
	vll A(M), B(M);
	rep(i, M) {
		cin >> A[i] >> B[i];
		--A[i], --B[i];
	}

	UnionFind uf(N);
	vll conv(M);	// 便利さ

	ll val = 0;
	ford(i, 0, M - 1) {
		if (uf.find_set(A[i + 1], B[i + 1])) conv[i] = conv[i + 1];
		else {
			conv[i] = conv[i + 1] + uf.size(A[i + 1]) * uf.size(B[i + 1]);
			uf.union_set(A[i + 1], B[i + 1]);
		}
	}

	rep(i, M) cout << N * (N - 1) / 2 - conv[i] << endl;
}


Measured memory_bytes: 4480
N = int(input())
S = input()

ans = [''] * N

def other(s):
  if s == 'S':
    return 'W'
  else:
    return 'S'

def calc(S):
  global ans
  for i, s in enumerate(S[1:], 1):
    if s == 'o':
      if ans[i] == 'S':
        ans[(i+1)%N] = ans[i-1]
      else:
        ans[(i+1)%N] = other(ans[i-1])
    else:
      if ans[i] == 'S':
        ans[(i+1)%N] = other(ans[i-1])
      else:
        ans[(i+1)%N] = ans[i-1]

if S[0] == 'o':
  ans[0] = 'S'
  ans[1] = 'S'
  calc(S)
  if (ans[0], ans[-1]) == ('S', 'S'):
    print(''.join(ans))
    quit()
  ans[0] = 'W'
  calc(S)
  if (ans[0], ans[-1]) == ('W', 'W'):
    print(''.join(ans))
    quit()
  ans[0] = 'S'
  ans[1] = 'W'
  calc(S)
  if (ans[0], ans[-1]) == ('S', 'W'):
    print(''.join(ans))
    quit()
  ans[0] = 'W'
  calc(S)
  if (ans[0], ans[-1]) == ('W', 'S'):
    print(''.join(ans))
    quit()
else:
  ans[0] = 'S'
  ans[1] = 'S'
  calc(S)
  if (ans[0], ans[-1]) == ('S', 'W'):
    print(''.join(ans))
    quit()
  ans[0] = 'W'
  calc(S)
  if (ans[0], ans[-1]) == ('W', 'S'):
    print(''.join(ans))
    quit()
  ans[0] = 'S'
  ans[1] = 'W'
  calc(S)
  if (ans[0], ans[-1]) == ('S', 'S'):
    print(''.join(ans))
    quit()
  ans[0] = 'W'
  calc(S)
  if (ans[0], ans[-1]) == ('W', 'W'):
    print(''.join(ans))
    quit()

print(-1)

Measured memory_bytes: 4340
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	void merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion

int main()
{
	int n, m, res = 0; cin >> n >> m;
	vector<int>  a(m), b(m);
	rep(i, 0, m - 1)cin >> a[i] >> b[i], --a[i], --b[i];

	rep(i, 0, m - 1)
	{
		UnionFind uf(n);
		rep(j, 0, m - 1)
		{
			if (i != j)
			{
				uf.merge(a[j], b[j]);
			}
		}
		bool isConnect = true;
		rep(j, 0, n - 1)rep(k, 0, n - 1)
		{
			if (!uf.issame(j, k))isConnect = false;
		}
		if (!isConnect) ++res;
	}
	cout << res << endl;
}

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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    //A[i]とA[i+1]の差をベクトルとして管理=> diff1
    //A[i]とA[i+2]の差もベクトルとして管理=> diff2
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    vector<int> diff1(N+1);
    vector<int> diff2(N);
    for (int i = 0; i <= N; i++) {
        if (i == 0) diff1[i] = abs(A[i]);
        if (i == N) diff1[i] = abs(A[N-1]);
        else diff1[i] = abs(A[i]-A[i-1]);
    }
    for (int i = 0; i < N; i++) {
        if (i == 0) diff2[i] = abs(A[i+1]);
        if (i == N-1) diff2[i] = abs(A[i-1]);
        else diff2[i] = abs(A[i+1]-A[i-1]);
    }
    ll sum = 0;
    for (int i = 0; i <= N; i++) {
        sum += diff1[i];
    }

    //答え
    for (int i = 0; i < N; i++) {
        ll ans = sum;
        ans -= diff1[i];
        ans -= diff1[i+1];
        ans += diff2[i];
        cout << ans << endl;
    }
}

Measured memory_bytes: 2432
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int len = s.length();
	for (int i = 1; i <= len; i++) {
		if (i % 2 == 1) {
			if (s[i-1] == 'L') {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			if (s[i - 1] == 'R'){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;

}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readInputLine().toInt()
    val ts = readInputLine().split(" ").map { it.toInt() }.toList().toIntArray()
    val m = readInputLine().toInt()
    
    val sum = ts.sum()
    
    for (i in 1..m) {
        val (p, x) = readInputLine().split(" ").map { it.toInt() }
        println(sum - ts[p - 1] + x)
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 37916
///Astalavista Code........~boy_with_no_gf
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define Br cout<<endl
#define int long long
#define pb push_back
#define mp make_pair
#define double long double
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define PT(x) cout << (x) << endl
#define PTT(x) cout << (#x) << " is " << (x) << endl; 
#define debug(x) cout<<"~~"<<#x<<" => "<<x<<endl; 
#define lets_go ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int M = 1e9 + 7;
const int N = 2e6 + 10;
const int IM = 1e15 + 37;
const double PI = 3.1415926535897932384;
inline void PP(int n) { cout << n << " ";}
void IN(vector<int>&arr,int n,int x=0){for(int i=x;i<n+x;i++)cin>>arr[i];}
void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " " ; cout << endl;}
void PVR(vi v) { for (int i = v.size()-1 ; i >=0 ; i--) cout << v[i] << " " ; cout << endl;}
void PVV(vii v) {for (int i = 0 ; i < v.size() ; i++) cout << v[i].first << " " << v[i].second << endl;}
void PA(int v[], int n, int x = 0) { for (int i = x ; i < n + x; i++)cout << v[i] << " " ; cout << endl;}
void IN(int a[], int n, int x = 0) {for (int i = x; i < n + x; i++)cin >> a[i];}
// <=================================================================================================================================
// <=================================================================================================================================


void fun(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int product;
    product=a*c;
    product=max(product,a*d);
    product=max(product,b*c);
    product=max(product,b*d);
    if((b>=0 && a<=0)||(d>=0 && c<=0)){
        product=max(product,0LL);
    }
    cout<<product;
}

signed  main() {
    lets_go

    int t;
    t=1;
    // cin >> t;
    while (t--) {            
         fun();             
    }                        
                            
                            
    return 0;

}


Measured memory_bytes: 3652
dishes = [int(input()) for _ in range(5)]
tuple_ = tuple(n for n in map(lambda num: num % 10, dishes) if n)
print(sum(map(lambda num: num + 10 * (num % 10 != 0) - (num % 10), dishes)) + min(tuple_ if tuple_ else (10,)) - 10)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        int h = sc.nextInt();
        int s = sc.nextInt();
        int d = sc.nextInt();
        int n = sc.nextInt();
        q *= 4;
        h *= 2;

        sc.close();

        int min = Math.min(q, Math.min(h, s));

        if (n % 2 == 0) {
            System.out.println(Math.min((long) min * n, (long) d * n / 2));
        } else {
            System.out.println(Math.min((long) min * n, (long) d * (n - 1) / 2 + min));
        }

    }

}

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

int c[100][100];

int main() {
  int H, W;
  cin >> H >> W;
  int N;
  cin >> N;
  int y = 0, x = 0, dx = 1;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    for (int j = 0; j < a; j++) {
      c[y][x] = i + 1;
      x += dx;
      if (x < 0) {
        ++y;
        x = 0;
        dx = 1;
      } else if (x >= W) {
        ++y; 
        x = W - 1;
        dx = -1;
      }
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << c[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {

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

        String s = sc.nextLine();

        s = s.replaceAll("eraser",  "-");
        s = s.replaceAll("erase",   "-");
        s = s.replaceAll("dreamer", "-");
        s = s.replaceAll("dream",   "-");
        s = s.replaceAll("-", "");

        if (s.length() == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 31812
#include<stdio.h>

int dist(int a, int b, int c, int prev, int head)
{
	int ret = 0;
	if (a == 0 && b == 0 && c == 0) {
		if (prev == head && prev != 0) {
			return 0;
		} else {
			return 1;
		}
	}
	if (a != 0 && prev != 1) {
		if (dist(a-1, b, c, 1, (head == -1 ? 1 : head))) {
			ret = 2;
		}
	}
	if (b != 0 && prev != 2) {
		if (dist(a, b-1, c, 2, (head == -1 ? 2 : head))) {
			ret = 1;
		}
	}
	if (c != 0) {
		if (dist(a, b, c-1, 0, (head == -1 ? 0 : head))) {
			ret = 1;
		}
	}
	return ret;
}

int main()
{
	int a,b,c,ret;
	scanf("%d %d", &a, &b);
	c = 16 - a - b;

	if (dist(a, b, c, -1, -1)) {
		printf("Yay!");
	} else {
		printf(":(");
	}
	return 0;
}

Measured memory_bytes: 128
import sys

sys.setrecursionlimit(100000)

N, M = map(int, input().split(" "))
G = [[] for _ in range(N)]

for _ in range(M):
    x, y = map(int, input().split(" "))
    G[x-1].append(y-1)

dp = [-1] * N
def pathlen(G, dp, v):
    if dp[v] != -1:
        return dp[v]

    plen = 0
    for i in G[v]:
        plen = max(plen, pathlen(G, dp, i)+1)
    dp[v] = plen
    return plen

ans = 0
for i in range(N):
    ans = max(ans, pathlen(G, dp, i))
print(ans)

Measured memory_bytes: 59056
#ifndef _WIN32
#include<iostream>
#endif 

#include<cmath>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long LL;
#define FOR(i,bg,ed) for(int i = (bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
struct cww {
	cww() {
		ios::sync_with_stdio(false);
		cin.tie(0);
		cout << fixed;
		cout << setprecision(10);
	}
}star;
template<typename T>
istream & operator>> (istream &is, vector<T>&v) {
	for (auto &it : v)is >> it;
	return is;
}
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
typedef pair<LL, LL> P;
typedef vector<LL> V;
const int INF = 1e7;
int s, n, t, m;
double p;
string week, nobu;
int ok[114514];
int sum[114514];
const int WEEK = 10080;
const int DAY = 1440;
string ww[] = { "Sun","Mon","Tue","Wed","Thu","Fri","Sat" };
void init() {
	REP(i, 114514) {
		ok[i] = 0;
		sum[i] = 0;
	}
	REP(i, 7)if (week == ww[i] || week == "All") {
		if (nobu == "All" || nobu == "Night") {
			int bg = i*DAY + 0;
			int ed = i*DAY + 360;
			FOR(j, bg, ed)ok[j] = 1;
		}
		if (nobu == "All" || nobu == "Night") {
			int bg = i*DAY + 1080;
			int ed = i*DAY + 1440;
			FOR(j, bg, ed)ok[j] = 1;
		}
		if (nobu == "All" || nobu == "Day") {
			int bg = i*DAY + 360;
			int ed = i*DAY + 1080;
			FOR(j, bg, ed)ok[j] = 1;
		}
	}
	REP(i, WEEK)ok[i + WEEK] = ok[i];
	REP(i, 2 * WEEK)sum[i + 1] = sum[i] + ok[i];
}

int main() {
	while (cin >> s >> n >> t >> week >> nobu >> p >> m,week!="None") {
		int res = 0;
		init();
		REP(i, WEEK) {
			int now = i;
			int ans = 0;
			REP(j, m) {
				if (sum[now + s + 1] - sum[now] == s + 1)ans++;
				now += t;
				now %= WEEK;
			}
			if (ans > res)res = ans;
		}
		p = 1.0-1.0 / p;
		double pp = 1;
		REP(i, n)pp *= p;
		double ppp = 1;
		REP(i, res)ppp *= pp;
		cout << 1 - ppp << endl;
	}
	return 0;
}

Measured memory_bytes: 4132
#include <iostream>

using namespace std;

int main(void)
{
	long long x, y;

	cin >> x >> y;

	long long n = 0;
	long long beki = 1;

	while (true)
	{
		if (x * beki <= y)
		{
			beki *= 2;
			n++;
		}
		else
			break;
	}

	cout << n << endl;

	return 0;
}

Measured memory_bytes: 256
// Author: pankaj_m05 
// Problem: b 
// Created: 21.06.2020 17:32:24

#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0); cin.tie(0);
#define f_in(file) freopen(file, "r", stdin)
#define f_out(file) freopen(file, "w", stdout)
#define sz(a) int((a).size())
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c) c.begin(), c.end()
#define tr(c,i) for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) (c.find(x) != c.end())  // Set and Maps
#define cpresent(c,x) (find(allc,x) != c.end()) // Vectors
using namespace std;

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
typedef long long ll;

const int mod = 1e9 + 7;

void testcase() {
	int n, k;
	cin >> n >> k;
	int a[n];
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a, a + n);
	int ans = 0;
	for (int i = 0; i < k; ++i) {
		ans += a[i];
	}
	cout << ans << '\n';
}

int main(void) { 
	fast
	int t = 1; 
	// cin >> t;
	while (t--) {
		testcase();
	}
	return 0;
}                                          

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>

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

using namespace std;

ll gcd(ll a, ll b) {
    if(a < b)
        return gcd(b,a);
    if(b ==0)
        return a;
    ll x = a%b;
    if(b/2 < x)
        return gcd(b, b-x);
    return gcd(b, x);
}

int main(){
    ll n,m; cin>> n >> m;
    vector<ll> a(n);
    for(ll i = 0; i< n; i++) {
        cin >> a[i];
    }
    ll x = a[0];
    ll y = 0;
    while(x%2==0) {
        x /= 2;
        y++;
    }
    ll shift = 1ll << y;
    for(ll i = 0; i< n; i++) {
        if(a[i]%shift != 0 || a[i]%(shift << 1) == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    for(ll i = 0; i< n; i++) {
        a[i] >>= 1;
    }
    vector<ll> ruiseki(n);
    ruiseki[0] = a[0];
    for(ll i = 1; i< n; i++) {
        ruiseki[i] = ruiseki[i-1]/gcd(ruiseki[i-1], a[i])*a[i];
        if(ruiseki[i] > m) {
            cout << 0 << endl;
            return 0;
        }
    }

    printf("%lld\n", ll(ceil(m/ruiseki[n-1]/2.0)));
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int[] num = new int[30];
		for(char c: s.toCharArray()) {
			num[c-'a']++;
		}
		for(int i : num) {
			if(i > 1) {
				System.out.println("no");
				return;
			}
		}
		System.out.println("yes");
	}
}

Measured memory_bytes: 25172
//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

n = Number(require('fs').readFileSync(config.input, 'ascii').trim());

const SCALE = Math.sqrt(3)/6;

function get_koch(p1, p2) {
  var s = [(2*p1[0]+p2[0])/3, (2*p1[1]+p2[1])/3];
  var t = [(p1[0]+2*p2[0])/3, (p1[1]+2*p2[1])/3];
  var ux = (p1[0]+p2[0])/2 + SCALE*(p1[1]-p2[1]);
  var uy = (p1[1]+p2[1])/2 + SCALE*(p2[0]-p1[0]);
  return [p1, s, [ux, uy], t];
}

line = [[0, 0], [100, 0]];

for (i = 0; i < n; i++) {
  next = [];
  for (j = 0; j < line.length - 1; j++) {
    next = next.concat(get_koch(line[j], line[j+1]));
  }
  next.push(line[line.length-1]);
  line = next;
}

for (i in line)
  console.log(line[i].join(' '));

Measured memory_bytes: 20536
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

int main() {
    long long int a,b;
    cin>>a>>b;
    cout<< (a*b)/__gcd(a,b)<<endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int a, b, x;
	cin >> x >> a >> b;
	int day = a - b;
	if (day >= 0)cout << "delicious" << endl;
	else if (abs(day) <= x)cout << "safe" << endl;
	else cout << "dangerous" << endl;
	return 0;
}



Measured memory_bytes: 3644
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n, m = map(int, input().split())
  ABs = []
  for _ in range(n):
    A, B = map(int, input().split())
    ABs.append((A, B))
  ABs.sort(key= lambda x:x[0])
  payment = 0
  num = 0
  for A, B in ABs:
    payment += A*B
    num += B
    if num >= m:
      print(payment - A * (num - m))
      break
    
    
  
if __name__=='__main__':
  main()



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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using v = vector<T>;
template <class T>
using vv = v<v<T>>;
#define ALL(c) (c).begin(), (c).end()

int main()
{
    v<char> ans;
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); i++)
    {
        switch (S[i])
        {
        case '0':
            ans.push_back('0');
            break;
        case '1':
            ans.push_back('1');
            break;
        case 'B':
            if(ans.size()!=0)
                ans.pop_back();
            break;
        default:
            break;
        }
    }

    for (int i = 0; i < ans.size(); i++)
    {
        cout << ans[i];
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 3600
N, M = map(int, input().split())
s = []
for i in range(M):
    s.append(list(map(int, input().split())))
p = list(map(int, input().split()))

switch = [['0'], ['1']]

for i in range(N-1):
    tmp = []
    for j in switch:
        tmp.append(j+['0'])
        tmp.append(j+['1'])
    switch = tmp #スイッチのonoffのマップ化

ans = 0

for i in switch:
    false = 0
    for j in range(M):
        cnt = 0 #onの個数
        for k in range(s[j][0]):
            if i[s[j][1+k]-1] == '1':
                cnt += 1
        if cnt%2 != p[j]:
            false += 1 #条件に合っていなかったらfalseに加算する
    if false == 0:
        ans += 1 #全て条件を満たしていたらansに加算する
print(ans)

Measured memory_bytes: 3316
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut 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")
    };
}

use std::iter::Iterator;

fn main() {
    input! {
        n: usize,
        choices: [[u32; 3]; n],
    }
    let mut max_happiness_on = vec![vec![0; 3]; n];
    max_happiness_on[0] = choices[0].clone();

    for i in 1..=(n - 1) {
        let ii = i as isize;
        for j in 0..=2 {
            let ij = j as isize;
            max_happiness_on[i][j] = choices[i][j]
                + u32::max(
                    max_happiness_on[(ii - 1) as usize][((ij - 1).rem_euclid(3)) as usize],
                    max_happiness_on[(ii - 1) as usize][((ij - 2).rem_euclid(3)) as usize],
                )
        }
    }
    let max_happiness_on_last_day = max_happiness_on[n - 1].iter().max().unwrap();
    println!("{}", max_happiness_on_last_day)
}


Measured memory_bytes: 14452
#include<bits/stdc++.h>
#define lim 2154
#define ll long long
using namespace std;
ll a[100010];
ll b[100010];
ll p[100010];
map<ll,ll> vis;
map<ll,ll> cnt1;
map<ll,ll> sqr;
map<ll,ll> root;
vector<ll> v;

void sieve()
{
    ll i,j,k,l;
    sqr[1]=1;
    root[1]=1;
    for(i=2;i<=100000;i++)
    {
        if(p[i]) continue;
        sqr[i*i]=1;
        root[i*i]=i;
        v.push_back(i);
//        cout<<v.size()<<' ';
        for(j=i*i;j<=100000;j+=i)
        {
            p[j]=1;
        }
    }
}

ll x,y;
void get1(ll s)
{
    ll i,j,k,l;
    x=y=1;
    for(i=0;i<v.size()&&v[i]<lim;i++)
    {
        k=0;
        ll u=v[i];
        while(s%u==0)
        {
            s/=u;
            k++;
            k%=3;
        }
        l=(3-k)%3;
        while(k--) x*=u;
        while(l--) y*=u;
    }

    if(s!=1)
    {
        if(sqr[s])
        {
            x*=s;
            y*=root[s];
        }
        else
        {
            x*=s;
            y*=s*s;
        }
    }
}

int main()
{
    ll n;
    sieve();
    cin>>n;
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        get1(a[i]);
//        cout<<a[i]<<' '<<x<<' '<<y<<'\n';
        a[i]=x;
        b[i]=y;
        cnt1[x]++;
    }

    for(int i=0;i<n;i++)
    {
        if(vis[a[i]]) continue;
        if(a[i]==1) ans++;
        else ans+=max(cnt1[a[i]],cnt1[b[i]]);
        vis[a[i]]=vis[b[i]]=1;
    }

    cout<<ans;
}



//6
//1 1 2 2 4 4
//ans: 3

//10
//1 1 2 2 4 4 4 4 4 4
//ans: 7

//10
//1 1 2 2 2 2 2 2 4 4


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

vector < pair< long long int ,long long int > > v , v1  ;
vector<long long >ans ;

int main()
{
	int n,m ;
	
	cin>>n>>m;
	
	for(int i=0;i<n;i++)
	{
		long long int l,r ;
		cin>>l>>r;
		
		v.push_back({l,r}) ;
	}
	
	for(int i=0;i<m;i++)
	{
	long long 	int l,r ;
		cin>>l>>r;
		v1.push_back({l,r}) ;
	}
	
	long long min1 = -1 ; 
	
	for(int i=0;i<n;i++)
	{
		min1 = -1 ;
		long long ind ;
		
		for(int j=0;j<m;j++)
		{
			long long temp = abs(v[i].second - v1[j].second) + abs(v[i].first - v1[j].first) ;
			if(min1 == -1)
			{
				min1 = abs(v[i].second - v1[j].second) + abs(v[i].first - v1[j].first) ;
				ind =j ;
			}
			else if(min1 > temp)
			{
				min1 = abs(v[i].second - v1[j].second) + abs(v[i].first - v1[j].first) ;
				ind = j; 
			}
			
		}
		ans.push_back(ind+1) ;
	}
	
	for(int i=0;i<n;i++)
	cout<<ans[i]<<"\n"; 
	
	return  0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s; 
int main(){
    cin>>s;
    if(s.find('F')==std::string::npos)
	{
		printf("No");
		return 0;
	}
    if(s.find('C')<s.rfind('F')) printf("Yes");
    else printf("No");
    return 0;
}

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

int main(void){
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i=0;i<n;++i) cin >> h[i];
    int max = 0, cnt = 0;
    for(int i=0;i<n;++i){
        if(max <= h[i]){
            ++cnt;
            max = h[i];
        }
    }
    cout << cnt << endl;
}


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

double x[55],y[55];

double get_dist(int i, int j){
    return (double)(x[i]-x[j]) * (x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]);
}

pair<double,double> get_o(int i,int j,int k){
    double A[2] = {x[i],y[i]}, B[2]={x[j],y[j]}, C[2]={x[k],y[k]};
    double a = get_dist(k,j), b = get_dist(i,k), c = get_dist(i,j);
    double p = a*(b+c-a), q=b*(c+a-b), r=c*(a+b-c);
    double u[2];
    for(int t=0;t<2;t++){
        u[t] = p*A[t] + q*B[t] + r*C[t];
        u[t] /= (p+q+r);
    }
    return {u[0],u[1]};
}

double get_rad(int ii,int j, int k, pair<double,double> o){
    double r = 0;
    vector<int> v = {ii,j,k};
    for(auto i:v){
        r += (o.first-x[i])*(o.first-x[i]) + (o.second-y[i]) * (o.second-y[i]);
    }
    r /= 3;
    return r;
}

double eps = 1e-6;

signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
    }
    double ans = 1e9;
    // 3点選んでよしなにするやつ
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                pair<double,double> o = get_o(i,j,k);
                double r = get_rad(i,j,k,o);
                x[n]=o.first, y[n]=o.second;
                //cerr << "a"<<endl;
                //cerr << i << " " << j << " " << k << " " << o.first << " " << o.second << " " << r << endl;
                bool pos = true;
                for(int u=0;u<n;u++){
                    double dist = get_dist(u,n);
                    if(dist > r+eps){
                        pos = false;
                        break;
                    } 
                }
                if(pos) ans = min(ans, sqrt(r));
            }
        }
    }

    // 2ten erande yosi!
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            pair<double, double> o;
            o.first = (x[i] + x[j])/2.0;
            o.second = (y[i] + y[j])/2.0;
            x[n] = o.first, y[n] = o.second;
            double r = get_dist(i,n) + get_dist(j,n);
            r /= 2.0;
            bool pos = true;
            for(int k=0;k<n;k++){
                long dist = get_dist(k,n);
                if(dist > r+eps){
                    pos = false;
                    break;
                }
            }
            if(pos) ans = min(ans,sqrt(r));
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int inf=1e9,N=15,mod=998244353;
int h,w,H,W,xs[N][N],a[N][N],ycl[2000];
ll ans,pw[N],c[N][N];
char ch[N][N];
vector<int> v;
void solve(vector<int> v){
	int res[2],re[2]; res[0]=h; res[1]=w; re[0]=H; re[1]=W;
	if(!v.size()){
		ans++; return;
	}
	int ks=v[0]^1;
	//cout<<v.size()<<endl;
	//for(auto i:v)wri(i); puts("nmd"); 
	reverse(v.begin(),v.end());
	ll f=0,g=1,ab=1;
	while(v.size()){
		int cnt=0,dq=v.back();
		while(v.size()&&v.back()==dq){
			cnt++; v.pop_back();
		}
		ab=ab*c[re[dq]][cnt];
		res[dq]-=cnt; re[dq]-=cnt;
		ll G=f*(res[dq^1]?1:0)+g*(res[dq^1]?pw[cnt]:1),
		F=f*(res[dq^1]?1:0)+g*(res[dq^1]?2:1); 
		if(!ks)G=(G+mod-F)%mod; else F=ks=0;
		f=F; g=G;
		//cerr<<f<<" "<<g<<endl;
	}// f 分别表示 上次颜色全相同，上次不相同 
	//cout<<ab<<" f:"<<f<<" fdas "<<g<<" fkjzz\n";
	ans=(ans+ab*(f+g))%mod;
}
void dfs(int x,int y){
	if(!x&&!y){
		solve(v); return;
	}
	if(x){
		v.pb(0); dfs(x-1,y); v.pop_back();
	}
	if(y){
		v.pb(1); dfs(x,y-1); v.pop_back();
	}
	
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	h=read(),w=read();
	For(i,0,h-1){
		scanf("%s",ch[i]);
		For(j,0,w-1)a[i][j]=ch[i][j]=='.';
	}
	For(i,0,N-1)For(j,c[i][0]=1,i)c[i][j]=c[i-1][j-1]+c[i-1][j];
	For(i,1,1023)ycl[i]=ycl[i>>1]+(i&1);
	For(i,pw[0]=1,N-1)pw[i]=pw[i-1]*2;
	For(i,0,(1<<h)-1){
		For(j,0,(1<<w)-1){
			int A[N],B[N];
			mem(A); mem(B);
			For(k,0,h-1)if(i>>k&1){
				For(l,0,w-1)if(j>>l&1){
					A[k]|=1<<a[k][l];
					B[l]|=1<<a[k][l];
				}
			}
			int f=1;
			For(k,0,h-1)if((i>>k&1)&&A[k]<3)f=0;
			For(k,0,w-1)if((j>>k&1)&&B[k]<3)f=0;
			if(f)xs[h-ycl[i]][w-ycl[j]]++;
		}
	}
	ll sum=0;
	For(i,0,h)For(j,0,w)if(xs[i][j]){
		ans=0; H=i; W=j;
		dfs(i,j);
		sum=(sum+ans*xs[i][j])%mod;
		//cout<<i<<" "<<j<<" "<<xs[i][j]<<" "<<ans<<endl;// exit(0);
	}
	cout<<sum<<endl;
}
/*
对于每一行，考虑上次删了哪些列，剩余的位置相同，那些列不能和我全相同。 
*/

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

int main(){
  int a, b, c, n;
  cin >> n;
  while((n--) && (cin >> a)){
    cin >> b;
    cin >> c;
    a = a * a;
    b = b * b;
    c = c * c;
    if((a + b == c) || (a + c == b) || (b + c == a)) cout << "YES\n";
    else cout << "NO\n";
  }

  return 0;
}

Measured memory_bytes: 2968
// D.

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main(int argc, char *argv[]) {
	int h, w, n, a, col[100][100], x = 0, y = 0, d = 1;
	cin >> h >> w >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		for (int j = 0; j < a; ++j) {
			if (x < 0) {
				x = 0;
				++y;
				d = 1;
			} else if (x >= w) {
				x = w - 1;
				++y;
				d = -1;
			}
			col[y][x] = i + 1;
			x += d;
		}
	}
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (j) {
				cout << " ";
			}
			cout << col[i][j];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
using namespace std;

#define MAX 100002

int n;

int ar[1002][1002];

int main() {
	cin >> n;
	if (n == 1) {
		puts("Yes");
		puts("2");
		cout << 1 << " " << 1 << endl;
		cout << 1 << " " << 1 << endl;
		return 0;
	}
	if (n == 3) {
		puts("Yes");
		cout << 3 << endl;
		cout << 2 << " " << 1 << " " << 2 << endl;
		cout << 2 << " " << 3 << " " << 1 << endl;
		cout << 2 << " " << 2 << " " << 3 << endl;
		return 0;
	}
	ar[0][0] = 1;
	ar[0][1] = 1;
	ar[0][2] = 2;
	ar[1][0] = 3;
	ar[1][1] = 2;
	ar[1][2] = 3;
	int card = 3;
	int val = 3;
	while (val < n) {
		int nex_l = val + 1;
		int nex_r = val +card;
		for (int i = 0; i < card; i++) {
			ar[card - 1][i] = nex_l + i;
		}
		for (int i = 0; i < card; i++) {
			ar[i][card] = nex_l + i;
		}
		card++;
		val = nex_r;
	}
	if (val != n) {
		puts("No");
		return 0;
	}
	puts("Yes");
	cout << card << endl;
	for (int i = 0; i < card; i++) {
		cout << card - 1;
		for (int j = 0; j < card - 1; j++) {
			printf(" %d", ar[j][i]);
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 3200
import sys
import numpy as np

def Ss():
  return sys.stdin.readline().rstrip().split(' ')

def Is():
  ss = Ss()
  return map(int, ss) if len(ss) > 1 else int(ss[0])

money = 1000
n = Is()
prices = [*Is()]

for today, tomorrow in zip(prices, prices[1:] + [0]):
  buyable_stock_count = int(money / today)
  new_money = money + buyable_stock_count * (tomorrow - today)
  if new_money > money:
    money = new_money

print(money)

Measured memory_bytes: 27160
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayLong();
            var A = input[0];
            var B = input[1];
            var C = input[2];
            var D = input[3];
            var lowC = (A - 1) / C;
            var highC = B / C;
            var lowD = (A - 1) / D;
            var highD = B / D;
            var gcd = Gcd(C, D);
            var lcm = C * D / gcd;
            var lowL = (A - 1) / lcm;
            var highL = B / lcm;
            var div = highC - lowC + highD - lowD - (highL - lowL);

            Console.WriteLine(B - (A - 1) - div);
            Console.ReadLine();
        }

        static long Gcd(long a, long b) { if (b == 0) return a; return Gcd(b, a % b); }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

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

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

    long long n;
    cin >> n;
    if (n % 2 == 0) {
        n /= 2;
        long long fac = 5;
        long long count = 0;
        while (n / fac >= 1) {
            count += n / fac;
            fac *= 5;
        }
        cout << count << endl;
    } else {
        cout << 0 << endl;
    }
    

	return 0;
}

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

int n, m, q;
int a[50];
int b[50];
int c[50];
int64_t d[50];
int ans = 0;

void calc(std::vector<int> A)
{
  if (A.size() == n + 1)
  {
    int now = 0;
    for (int i = 0; i < q; ++i)
    {
      if (A[b[i]] - A[a[i]] == c[i])
      {
        now += d[i];
      }
    }
    ans = std::max(ans, now);
    return;
  }

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

int main()
{
  std::cin >> n >> m >> q;
  for (int i = 0; i < q; ++i)
  {
    std::cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  std::vector<int> A(1,1);
  calc(A);
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
    cin >> n;
    for(int i = 1; i < 50000; ++i) {
        if((int)(i*1.08) == n) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}

Measured memory_bytes: 256
import java.io.*;

class Main{
	public static void main (String arg[]){
		int num;
		String buf;
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			
			buf = br.readLine();
			num = Integer.parseInt(buf);
			System.out.print(num*num*num);
			System.out.print("\n");
		} catch(Exception e ) {
		}
	}
}

Measured memory_bytes: 24256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))
ll n,a[200005],mini[800005],maxi[800005];
void built1(ll l,ll r,ll v)
{
     if(l==r)      mini[v] = a[l];
     else
     {
          ll mid = (l+r)/2;
          built1(l,mid,2*v);
          built1(mid+1,r,2*v+1);
          mini[v] = min(mini[2*v],mini[2*v+1]);
     }
}
void built2(ll l,ll r,ll v)
{
     if(l==r)      maxi[v] = a[l];
     else
     {
          ll mid = (l+r)/2;
          built2(l,mid,2*v);
          built2(mid+1,r,2*v+1);
          maxi[v] = max(maxi[2*v],maxi[2*v+1]);
     }
}
int minii(int v, int tl, int tr, int l, int r) {
    if (l > r) 
        return INT_MAX;
    if (l == tl && r == tr) {
        return mini[v];
    }
    int tm = (tl + tr) / 2;
    return min(minii(v*2, tl, tm, l, min(r, tm))
           , minii(v*2+1, tm+1, tr, max(l, tm+1), r));
}
int maxii(int v, int tl, int tr, int l, int r) {
    if (l > r) 
        return INT_MIN;
    if (l == tl && r == tr) {
        return maxi[v];
    }
    int tm = (tl + tr) / 2;
    return max(maxii(v*2, tl, tm, l, min(r, tm))
           , maxii(v*2+1, tm+1, tr, max(l, tm+1), r));
}
int main()
{
     FAST;
    ll k;
    cin>>n>>k;
    for(ll i=0;i<n;i++)    cin>>a[i];
    built1(0,n-1,1);
    built2(0,n-1,1);
    ll ans = n-k+1;
    ll temp = 1;
    ll b[n]={0};
    for(ll i=1;i<n;i++)
    {
         if(a[i]<a[i-1])     b[i] = 1;
         b[i] += b[i-1];
    }
    for(ll i=0;i<n-k+1;i++)
    {
         if(b[i+k-1]-b[i]==0)     
         {
              if(temp==0)  { ans--;continue;}
              temp = 0;
         }
         if(i!=0)
         {
              ll temp1 = minii(1,0,n-1,i-1,i+k-1);
              ll temp2 = maxii(1,0,n-1,i-1,i+k-1);
              if(temp1==a[i-1] && temp2 == a[i+k-1])     ans--;
         }
    }
    cout<<ans;
}

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

namespace BC121A
{
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            //int a = int.Parse(Console.ReadLine());
            // スペース区切りの整数の入力
            string[] input = Console.ReadLine().Split(' ');
            int H = int.Parse(input[0]);
            int W = int.Parse(input[1]);
            string[] input2 = Console.ReadLine().Split(' ');
            int h = int.Parse(input2[0]);
            int w = int.Parse(input2[1]);

            int all = H * W;
            int black = h * W;
            int ans = all - black - w * (H - h);
            // 文字列の入力
            //string s = Console.ReadLine();

            Console.WriteLine(ans);
        }
    }
}


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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;


void solve(int testCase){

    string s;
    cin >> s;

    if((s[2] == s[3]) && (s[4] == s[5]))printf("Yes\n");
    else printf("No\n");

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


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

typedef vector<int> poly;

const int mod = 998244353, N = 51000;

namespace {
  inline int add(int x, int y) { return (x += y) >= mod ? x - mod : x; }
  inline int sub(int x, int y) { return (x -= y) < 0 ? x + mod : x; }
  inline int mul(int x, int y) { return 1LL * x * y % mod; }
  inline int kissme(int x, int y) {
    int c = 1;
    while(y) {
      if(y & 1) {
	c = mul(c, x);
      }
      x = mul(x, x);
      y >>= 1;
    }
    return c;
  }
}

namespace ntt {
  int rev[N << 1], L, l;

  void pre(int n) {
    for(l = 0; (1 << l) < n; l++);
    L = 1 << l;
    for(int i = 0; i < L; i++) {
      rev[i] = rev[i >> 1] >> 1 | (i & 1) << (l - 1);
    }
  }

  void dft(int *a) {
    for(int i = 0; i < L; i++) {
      if(rev[i] > i) {
	swap(a[i], a[rev[i]]);
      }
    }
    for(int i = 1; i < L; i <<= 1) {
      int wn = kissme(3, (mod - 1) / (i << 1));
      for(int j = 0; j < L; j += i << 1) {
	int *f = a + j, *g = a + i + j;
	for(int k = 0, w = 1; k < i; k++, w = mul(w, wn)) {
	  int u = f[k], v = mul(w, g[k]);
	  f[k] = add(u, v);
	  g[k] = sub(u, v);
	}
      }
    }
  }

  void idft(int *a) {
    reverse(a + 1, a + L);
    int inv = kissme(L, mod - 2);
    dft(a);
    for(int i = 0; i < L; i++) {
      a[i] = mul(a[i], inv);
    }
  }
}

int n;
char a[N], b[N];

poly operator * (poly a, poly b) {
  using namespace ntt;
  pre(a.size() + b.size() - 1);
  a.resize(L), b.resize(L);
  dft(&a[0]), dft(&b[0]);
  for(int i = 0; i < L; i++) {
    a[i] = mul(a[i], b[i]);
  }
  idft(&a[0]);
  a.resize(n);
  return a;
}

int main(void) {
  scanf("%s%s", a, b);
  n = strlen(a);
  int x = 0, y = 0;
  for(int i = 0; i < n; i++) {
    if(a[i] ^ b[i]) {
      x++;
    } else if(a[i] == 49) {
      y++;
    }
  }
  x >>= 1;
  n = y + 1;
  poly f(1, 1), g(n), fac(x + y + 1, 1);
  for(int i = 1; i <= x + y; i++) {
    fac[i] = mul(fac[i - 1], i);
  }
  for(int i = 0; i < n; i++) {
    g[i] = kissme(fac[i + 1], mod - 2);
  }
  for(int k = x; k; k >>= 1, g = g * g) {
    if(k & 1) {
      f = f * g;
    }
  }
  int ans = 0;
  f.resize(n);
  for(int i = 0; i < n; i++) {
    ans = add(ans, f[i]);
  }
  cout << mul(ans, mul(fac[x], mul(fac[y], fac[x + y]))) << endl;
  return 0;
}


Measured memory_bytes: 1148