akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

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

int main()
{
        //input->compute->output//

        int A, B, C;
        cin >> A >> B >> C;
        if ((A * 100 + B * 10 + C) % 4 == 0)
        {
                cout << "YES" << endl;
        }
        else
        {
                cout << "NO" << endl;
        }

        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mymap make_pair
#define INF 0x3f3f3f3f 
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long int
#define pi 3.14159265358979
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef vector<int>   vi;
typedef vector<pii>   vpii;
typedef vector<vi>    vvi;

int main() {
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
    ll k;
    cin>>k;
    unordered_map<ll, ll>mymap;
    ll r=7,change =0,f=0;
    while(k%2==1)
    {
        change ++;
        if(r%k==0)
        {
            f=1;
            break;
        }
        r=r*10+7;
        if(mymap.find(r)!=mymap.end())
        {
            f=0;
            break;
        }
        else
        mymap[r]=1;
        r=r%k;
    }
    if(f==1)
    cout<<change <<endl;
    else
    cout<<"-1"<<endl;
     return 0;
}


Measured memory_bytes: 42696
#include <stdio.h>

#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[],int n,int left, int mid, int right) {
  int i, j, k;
  int n1 = mid -left;
  int n2 = right - mid;
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  i=0, j=0;
  for(k=left; k<right; k++) {
    cnt++;
    if(L[i]<=R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[],int n,int left,int right) {
  int mid;
  if(left+1 < right) {
    mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int main(void) {
  int A[MAX], n, i;
  cnt = 0;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);

  mergeSort(A, n, 0, n);
  for(i=0;i<n;i++) {
    if(i) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n%d\n",cnt);

  return 0;
}


Measured memory_bytes: 5612
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;

signed main(){
	ios_base::sync_with_stdio(0);
	int a,b;
	cin>>a>>b;
	cout<<max(max(a+a-1,b+b-1),a+b);
	re 0;
}


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

namespace FibonacciSample
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Tuple<string, int, int>[] t = new Tuple<string, int, int>[n];
            for (int i = 0; i < n; i++)
            {
                var line = Console.ReadLine().Split(' ').ToArray();
                t[i] = new Tuple<string, int, int>(line[0], int.Parse(line[1]), i + 1);
            }
            var a=t.OrderBy(v=>v.Item1).ThenByDescending(v => v.Item2);
            foreach(var s in a)
            {
                Console.WriteLine(s.Item3);
            }
        }
    }
}

Measured memory_bytes: 13660
n = gets.chomp.to_i
s = gets.chomp.split.map(&:to_i)
q = gets.chomp.to_i
t = gets.chomp.split.map(&:to_i)

def binary_search(key, n, list)
  left, right = 0, n

  while left < right
    mid = (left + right) / 2
    if list[mid] == key
      return true
    elsif list[mid] < key
      left = mid + 1
    else
      right = mid
    end
  end

  false
end

sum = 0
t.each do |num|
  sum += 1 if binary_search(num, n, s)
end
puts sum

Measured memory_bytes: 18068
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define EPS 1e-10
#define INF 1000000000
#define mp make_pair
#define pb push_back

typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;
typedef long long ll;

int calcAns(int n, int k, int s, int sum, int num, int pos) {
  int rep = 0;//, sum = calcSumAry(datas);

  if (pos > n || num > k || sum > s) {
    return 0;
  }

  if (num == k - 1) {
    if (pos <= s - sum && s - sum <= n) {
      return 1;
    } else {
      return 0;
    }
  }

  for (int i = pos; i <= n; i++) {
    rep += calcAns(n, k, s, sum + i, num + 1, i + 1);
  }
  return rep;
}

int main() {
  int n, k, s;
  while (1) {
    cin >> n >> k >> s;
    if (n == 0 && k == 0 && s == 0) break;
    cout << calcAns(n, k, s, 0, 0, 1) << endl;
  }
}

Measured memory_bytes: 1160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	private static Scanner sc;

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
	}

	private void solve() {
        try {
        	long start = System.currentTimeMillis();
        	int X = sc.nextInt();
        	int Y = sc.nextInt();
        	int Z = sc.nextInt();

            System.out.println("" + Z + " "+ X + " "+ Y);
            long end = System.currentTimeMillis();
            //System.out.println((end - start)  + "ms");

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

	private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }

}


Measured memory_bytes: 22228
// Created by code_sm
//
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
int a,b;
cin>>a>>b;
cout<<a*b;	
}
int main()
{
//code
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
fastio	
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

int main()
{
    long double a, b;
    cin >> a >> b;
    if (a > b)
    {
        cout << "GREATER";
    }
    else if (a < b)
    {
        cout << "LESS";
    }
    else
        cout << "EQUAL";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,d,x[11][11],a,g=0,i,j,k;
	scanf("%d %d", &n, &d);
	for(i=0; i<n; i++)
	{
		for(j=0; j<d; j++)
		scanf("%d", &x[i][j]);
	}
	for(i=0; i<n-1; i++)
	{
		for(j=i+1; j<n; j++)
		{
			a=0;
			for(k=0; k<d; k++)
			a+=(abs(x[i][k]-x[j][k]))*(abs(x[i][k]-x[j][k]));
			for(k=1; k<=a; k++)
			{
				if(k*k>a)
				break;
				if(k*k==a)
				g++;
			}
		}
	}
	printf("%d\n", g);
	
	return 0;
}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 1e3, msz = 1e4, inf = 0x3f3f3f3f;
int n, m, dp[msz + 5], a[nsz + 5], b[nsz + 5];

int main() {
	ios::sync_with_stdio(0);
	cin >> m >> n;
	cont (i, n) {
		cin >> a[i] >> b[i];
	}
	memset(dp, inf, sizeof(dp));
	dp[m] = 0;
	for (int k = m; k >= 0; --k) {
		cont (i, n) {
			int to = max(0, k - a[i]);
			dp[to] = min(dp[to], dp[k] + b[i]);
		}
	}
	cout << dp[0] << ln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
const int N = 1e5 + 5;
ll a[N], b[N];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    ll res = 0;
    for (int i = 0; i < n + 1; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];
    for (int i = n - 1; i >= 0; i--) {
        ll take1 = min(a[i + 1], b[i]);
        res += take1;
        a[i + 1] -= take1;
        b[i] -= take1;
        ll take2 = min(a[i], b[i]);
        res += take2;
        a[i] -= take2;
        b[i] -= take2;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 1792
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Trim().ToCharArray();
            if(s[2] == s[3] && s[4] == s[5]){
                Console.WriteLine("Yes");
            }else{
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11092
import sys
sys.setrecursionlimit(100000)
n , m = map(int,input().split())
g = [i for i in range(n)]
def find(x):
    if g[x] == x:
        return x
    g[x] = find(g[x])
    return g[x]
def union(x,y):
    x = find(x)
    y = find(y)
    if x!=y:
        g[x] = y

for i in range(m):
    xi,yi,zi = map(int,input().split())
    union(xi-1,yi-1)

ans = 0
for i in range(n):
    if find(i) == i:
        ans += 1
print(ans)

Measured memory_bytes: 111008
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
const ll INF = numeric_limits<int>::max() / 2;

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

    int n;cin>>n;
    ll t,mi=INF,dmax=-1,cnt=0;cin>>t;
    vector<ll> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    mi=a[0];
    for(int i=1;i<n;i++){
        if(dmax>a[i]-mi){
            
        }
        else if(dmax==a[i]-mi){
            cnt++;
        }
        else{
            cnt=1;
            dmax=a[i]-mi;
        }
        mi=min(mi,a[i]);
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <map>
#include <stdio.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pie 3.141592653

using namespace std;


int main()
{
	IO;

	string s;
	int n,tot=0,x;
	cin >> n;

	for (int i = 1; i <= n; i++)
	{
		cin >>x;
		if (x % 2 != 0 && i % 2 != 0)
			tot++;

	}

	

	cout << tot;
	return 0;
}


Measured memory_bytes: 3648
package main

import (
  "fmt"
)

func main() {
  var n int 
  fmt.Scan(&n)
  res := 0
  v := make([]int, n)
  c := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&v[i])
  }
  for i := 0; i < n; i++ {
    fmt.Scan(&c[i])
  }
  for i := 0; i < n; i++ {
    if v[i] > c[i] {
      res += v[i] - c[i]
    }
  }
  fmt.Println(res)
}

Measured memory_bytes: 512
#include<stdio.h>
int a[200010], b[200010];
int main() {
	int N, M;
	int A, B;
	int ok = 0;
	scanf("%d%d", &N, &M);
	for (int i = 0; i < M; i++)
	{
		scanf("%d%d", &A, &B);
		if (A == 1) { a[B] = 1; }
		if (B == 1) { a[A] = 1; }
		if (A == N) { b[B] = 1; }
		if (B == N) { b[A] = 1; }
	}

	for (int i = 0; i < N; i++)
	{
		if (a[i] == 1 && b[i] == 1)
		{
			ok = 1;
			break;
		}
	}
	if (ok)
	{
		puts("POSSIBLE");
	}
	else
	{
		puts("IMPOSSIBLE");
	}
	return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
#pragma warning (disable:4996)
int main()
{
	int n, arr[4] = { 0 };
	while (~scanf("%d", &n)) {
		for (int i = 0; i < 4; i++)
		{
			arr[i] = n % 10;
			n /= 10;
		}
		int sum = 0;
		
		if ((arr[0]==arr[1]&&arr[2]==arr[1])||(arr[1]==arr[2]&&arr[2]==arr[3]))printf("Yes\n");
		else printf("No\n");
	}
}

Measured memory_bytes: 128
from collections import defaultdict
import itertools
d = defaultdict(int)
x='MARCH'
for i in range(5):
  d[x[i]]=i+1
x=[0]*5
def sub(a,b):
  return abs(a[0]-b[0])+abs(a[1]-b[1])

H,W,D=map(int,input().split())
A=[list(map(int,input().split())) for i in range(H)]
N=H*W
P=[0]*(N)
for h in range(H):
  for w in range(W):
    P[A[h][w]-1]=(h,w)
X=[]
for d in range(D):
  _=[0]+[sub(P[i%N],P[i-D]) for i in range(d+D,N+D,D)]
  cumsum = list(itertools.accumulate(_))
  X.append(cumsum)

Q=int(input())
for q in range(Q):
  l,r=map(int,input().split())
  l,r=l-1,r-1
  g=l%D
  if l>r:
    r+=N
    ans=X[g][-1]-X[g][l//D]
    ans+=X[g][r//D]-X[g][0]
  else:
    ans=X[g][r//D]-X[g][l//D]
  
  print(ans)

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

using namespace std;

const int N = 1e5 + 5;
vector<pair<int , int> > adj[N];
int col[N];

void dfs (int node , int par , long long s) {
    col[node] = s % 2 == 0;
    for (auto &e : adj[node])
        if (e.first != par)
            dfs(e.first , node , s + e.second);
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.in" , "r" , stdin);
#endif
    int n;
    cin >> n;

    for (int i = 0 ;i < n - 1 ;i++) {
        int u , v , w;
        cin >> u >> v >> w;
        adj[u].push_back({v , w});
        adj[v].push_back({u , w});
    }

    dfs(1 , 1 , 0);

    for (int i = 1 ;i <= n ;i++)
        cout << col[i] << '\n';
}

Measured memory_bytes: 11476
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {

		int N = nextInt();
		int Q = nextInt();
		String S = nextString();
		char[] c = S.toCharArray();
		int[] a = new int[N];
		a[0]=0;
		for(int i=1;i<N;i++){
			if(c[i-1]=='A'&&c[i]=='C'){
				a[i]=1;
			}else{
				a[i]=0;
			}
		}
		int[] b = new int[N];
		b[0]=0;
		for(int i=1;i<N;i++){
			b[i]=b[i-1]+a[i];
		}


		for(int i=0;i<Q;i++){
			int l=nextInt();
			int r=nextInt();
			System.out.println(b[r-1]-b[l-1]);
		}

	}

	public static long[] disassemblyAlph(String s) {
		long[] alph = new long['z' - 'a' + 1];
		Arrays.fill(alph, 0);
		for (int i = 0; i < s.length(); i++) {
			alph[s.charAt(i) - 'a']++;
		}
		return alph;
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}

Measured memory_bytes: 59156
(defn palindrome [s]
  (= s (clojure.string/join (reverse s))))
(let [s (read-line)
      a (subs s 0 (/ (.length s) 2))
      b (subs s (/ (+ (.length s) 1) 2))]
  (if (not (palindrome s))
    (println "No")
    (if (not (palindrome a))
      (println "No")
      (if (not (palindrome b))
        (println "No")
        (println "Yes")))))


Measured memory_bytes: 83040
import java.util.*;

public class Main {
	static int MAX_N = 100000+1;
	static int n;
	static int[] bit = new int[MAX_N];
	
	// [0..i]の区間の和
	static int sum(int i) {
		int s = 0;
		while(i>0) {
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}
	
	static void add(int i, int x) {
		while(i<=n) {
			bit[i] += x;
			i += i & -i;
		}
	}
	
	static public void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int q = sc.nextInt();
		for(int i=0; i<q; i++) {
			int com = sc.nextInt();
			int x = sc.nextInt();
			int y = sc.nextInt();
			if(com==0) {
				add(x, y);
			} else {
				System.out.println(sum(y)-sum(x-1));
			}
		}
		
	}
}



Measured memory_bytes: 103964
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef char keytype;

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

/* a[0], ..., a[n-1] の数の最大公約数 */
int ngcd(int n, int a[])
{
    int i, d;

    d = a[0];
    for (i = 1; i < n && d != 1; i++)
        d = gcd(a[i], d);
    return d;
}

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

//#define N 5
//int p[N + 1];
int nextperm(int p[], int N)  /* 辞書式順序で次の順列 */
{
    int i, j, t;

    i = N - 1;
    p[0] = 0;  /* 番人 */
    while (p[i] >= p[i + 1]) i--;
    if (i == 0) return 0;  /* 完了 */
    j = N;
    while (p[i] >= p[j]) j--;
    t = p[i];  p[i] = p[j];  p[j] = t;
    i++;  j = N;
    while (i < j) {
        t = p[i];  p[i] = p[j];  p[j] = t;  i++;  j--;
    }
    return 1;  /* 未了 */
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

int abs_val(int a, int b){
    if(a > b) return a - b;
    else return b - a;
}

const int inf = 1012345678;
int main(){
    char s1[11], s2[11], s3[11];
    char ans[4];

    scanf("%s %s %s", s1, s2, s3);

    ans[0] = s1[0] - 'a' + 'A';
    ans[1] = s2[0] - 'a' + 'A';
    ans[2] = s3[0] - 'a' + 'A';
    ans[3] = '\0';

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

    return 0;
}


Measured memory_bytes: 1636
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

long q(const long *a, const long *b) {
	return *a - *b;
}

int main(void)
{
	long n, a, b[200000], i, m, s = 0;
	scanf("%ld", &n);
	for (i = 0; i < n; i++) {
		scanf("%ld", &a);
		b[i] = a - i + 1;
	}
	qsort(b, n, 8, q);
	m = b[n / 2];
	for (i = 0; i < n; i++) s += labs(b[i] - m);
	printf("%ld", s);
	return 0;
}

Measured memory_bytes: 3324
import math
def main():
    N, A, B = map(int, input().split())
    v = sorted(map(int, input().split()))[::-1]
    L = []
    for i in range(A, B+1):
        L += [[sum(v[:i]) / i, v[:i]]]
    LMAX = []
    x = L[0][0]
    for i in L:
        if i[0] == x : LMAX += [i]
    ans = 0
    for i in LMAX:
        a = 1
        for j in set(i[1]):
            if i[1].count(j) == 1:
                a *= v.count(j)
            else:
                x = v.count(j)
                y = i[1].count(j)
                a *= (math.factorial(x) // math.factorial(x-y)) // math.factorial(y)
        ans += a
    print(LMAX[0][0])
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	string s;
	cin >> s;
	int i;
	for (i = 1; i < 4; i++)
	{
		if (s[i] == s[i - 1]) break;
	}
	if (i == 4) cout << "Good";
	else cout << "Bad";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <cmath>
#define rep(i,N) for(int i=0; i<N;i++)
using namespace std;

int main(){
    int N;
    cin>>N;
    vector<long int> A(N);
    vector<long int> B(N-1);
    rep(i,N){
        cin>>A.at(i);
    }
    long int ans=0;
    B.at(0)=A.at(N-1);
    for(int i=1;i<N-1;i++){
        B.at(i)=B.at(i-1)+A.at(N-1-i);
        B.at(i)=B.at(i)%1000000007;
    }
    rep(i,N-1){
        ans+=A.at(i)*B.at(N-2-i)%1000000007;
    }
    cout<<ans%1000000007<<endl;



    return 0;
}

Measured memory_bytes: 6424
n = int(input())
a = list(map(int, input().split()))
dict = {}
for i in range(n - 1):
    if a[i] in dict:
        dict[a[i]] += 1
    else:
        dict[a[i]] = 1
for i in range(1, n + 1):
    if i in dict:
        print(dict[i])
    else:
        print(0)

Measured memory_bytes: 33520
#include<iostream>
typedef long long int lli;
using namespace std;
lli g1(lli n,int p){
  if(n==0)return 0;
  return n/p+g1(n/p,p);
}
lli g2(lli n,int p){
  if(n%2==1){
    return g1(n,p)-g2(n-1,p);
  }
  lli res=g1(n/2,p);
  if(p==2)res+=n/2;
  return res;
}

int main(){
  lli n;
  cin>>n;
  lli ans =min(g2(n,2),g2(n,5));
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k)     for(int i = j ; i < k ; ++i)
#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)
#define A    first
#define B    second
#define mp   make_pair
#define pb   emplace_back
#define PII pair<int , int>
#define MEM(i,j)   memset(i , j , sizeof i)
#define ALL(i)     i.begin() , i.end()
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define MAX
#define INF 0x3f3f3f3f

map<string , int> cc;
int n , m;
string s;
int32_t main(){
	IOS;
	cin >> n;
	REP(i , 1 , n + 1) cin >> s , cc[s] ++;
	cin >> m;
	REP(i , 1 , m + 1) cin >> s , cc[s] --;
	int big = 0;
	for(auto to : cc) big = max(big , to.B);
	cout << big << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    bool f[100001]={};
    int c[100002]={};
    int N,L,R;
    //エラトステネスの篩
    for(int i=2;i<=100000;i++){
        if(f[i]==0){
            for(int j=i+i;j<=100000;j+=i){
                f[j]=true;
            }
        }
    }
    //
    for(int i=3;i<=100000;i+=2){
        if(f[i]==0&&f[(i+1)/2]==0)  c[i]++;
    }
    for(int i=3;i<=100000;i++)  c[i]+=c[i-1];
    
    cin >> N;
    while(N--){
        cin >> L >> R;
        cout << c[R]-c[L-1] << "\n";
    }
}


Measured memory_bytes: 1152
r1, c1, r2, c2 = map(int, input().split())
mod = 10 ** 9 + 7

fac = [1]
inv = [1]
for i in range(1, r2 + c2 + 10) :
  fac.append(fac[-1] * i % mod)
  inv.append(pow(fac[-1], mod - 2, mod))

def comb(n, r) :
  return fac[n] * inv[n-r] * inv[r] % mod

def g(x, y) :
  return comb(x + y, y)

ret = g(r2+1, c2+1) - g(r2+1, c1) - g(r1, c2+1) + g(r1, c1)
ret %= mod

print(ret)

Measured memory_bytes: 135792
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
#include <deque>
using namespace std;
using ll = long long;
using itn = int;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    string s;
    cin >> s;

    if (s[0] == s[1] && s[0] != s[2] && s[0] != s[3]){
        if (s[2] == s[3]){
            cout << "Yes" << endl;
            return 0;
        }
}
    if (s[0] == s[2] && s[0] != s[1] && s[0] != s[3]){
        if (s[1] == s[3]){
            cout << "Yes" << endl;
            return 0;}
    }
    if (s[0] == s[3] && s[0] != s[1] && s[0] != s[2]){
        if (s[1] == s[2]){
            cout << "Yes" << endl;
            return 0;}
    }
    if (s[1] == s[2] && s[1] != s[0] && s[1] != s[3]){
        if (s[0] == s[3]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    if (s[1] == s[3] && s[1] != s[0] && s[1] != s[2]){
        if (s[0] == s[2]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    if (s[2] == s[3] && s[2] != s[0] && s[2] != s[1]){
        if (s[0] == s[1]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string> 
#include <math.h>
#include <set>
#include <vector>
#define rep(i,n) for(int i=0; i< (int)(n); ++i)
using namespace std;
using ll=long long;

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

	int h, w, n;
	cin >> h >> w >> n;
	int cnt;
	int ans;

	while(cnt < n){
		cnt = cnt + max(h,w);
		++ans;
	} 
	cout << ans << "\n";

	  

} 


Measured memory_bytes: 256
#include<stdio.h>

int main(void){

  int n=0;
  int d[200]={0};
  int i=0, j=0;
  int num=0;
  int buffer=0;
  int cnt[200]={0};

  //入力part
  scanf("%d", &n);
  
  for(i=0; i<n; i++){
    scanf("%d", d+i);
  }

  //各値が2で何回割れるかpart
  for(i=0; i<n; i++){

    num = d[i];
    while(num % 2 == 0){
      cnt[i]++;
      num = num / 2;
    }

  }

  //cntの要素の中で最小のものを見つけるpart
  for(i=0; i<n-1; i++){
    for(j=i+1; j<n; j++){

      if(cnt[i] > cnt[j]){
	buffer = cnt[i];
	cnt[i] = cnt[j];
	cnt[j] = buffer;
      }

    }
  }

  printf("%d\n", cnt[0]);

  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define N 2000000

struct node {
   int key;
	
   struct node *next;
   struct node *prev;
};

struct node *head = NULL;

struct node *last = NULL;

struct node *current = NULL;

int isEmpty(){
   return head == NULL;
}

int length(){
   int length = 0;
   struct node *current;
	
   for(current = head; current != NULL; current = current->next){
      length++;
   }
	
   return length;
}


void displayForward(void){

  
  struct node *ptr = head;
		
  while(ptr != NULL){
    if(ptr+1!=NULL && ptr != head)
      printf(" ");
    printf("%d",ptr->key);
  
    ptr = ptr->next;
  }
	
}



void insertFirst(int key){

 
   struct node *link = (struct node*) malloc(sizeof(struct node));
   link->key = key;
	
   if(isEmpty()){

      last = link;
   }else {

      head->prev = link;
   }

   link->next = head;

   head = link;
}


struct node* deleteFirst(void){


   struct node *tempLink = head;
	
  
   if(head->next == NULL){
      last = NULL;
   }else {
      head->next->prev = NULL;
   }
	
   head = head->next;
 
   return tempLink;
}



struct node* deleteLast(void){
 
   struct node *tempLink = last;
	

   if(head->next == NULL){
      head = NULL;
   }else {
      last->prev->next = NULL;
   }
	
   last = last->prev;
   return tempLink;
}

struct node* delete(int key){
  
   struct node* current = head;
   struct node* previous = NULL;
   if(head == NULL){
      return NULL;
   }
   while(current->key != key){
      if(current->next == NULL){
         return NULL;
      }else {
         previous = current;
         current = current->next;             
      }
   }
   if(current == head) {
      head = head->next;
   }else {
      current->prev->next = current->next;
   }    

   if(current == last){
      last = current->prev;
   }else {
      current->next->prev = current->prev;
   }	
   return current;
}

	


int main() {

  int i,n,*key;
  static char command[N][12];
  char word[4][12]={"insert","delete","deleteFirst","deleteLast"};
  scanf("%d",&n);
  key=malloc(sizeof(int)*n+1);
  for(i=0;i<n;i++){
    scanf("%s",command[i]);
      if(strcmp(command[i],word[0])==0) 
	scanf("%d",&key[i]);
      
         if(strcmp(command[i],word[1])==0) 
	   scanf("%d",&key[i]);
  }

  for(i=0;i<n;i++){
    if(strcmp(command[i],word[0])==0)
   insertFirst(key[i]);
    if(strcmp(command[i],word[1])==0)
      delete(key[i]);
    if(strcmp(command[i],word[2])==0)
      deleteFirst();
    if(strcmp(command[i],word[3])==0)
    deleteLast();
  }

  displayForward();
  printf("\n");
  
   return 0;
}

Measured memory_bytes: 65688
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
const int N=1e5+5;
int a[N];
int main()
{
   int n=rr;
   ll ans=inf;
   rep(i,0,n)
   a[i]=rr;
   rep(i,0,n)
   {ll sum1=0,sum2=0;
   	 repb(j,0,i)
   	 {
   	 	sum1+=a[j];
		}
		rep(k,i+1,n)
		sum2+=a[k];
		ans=min(abs(sum1-sum2),ans);
   }
   cout<<ans;
   
}




Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

using namespace std;

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef unordered_map<int,int> mp;

const int mod = 1e9+7;
const int least = -1e9;
const int most = 1e9;

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


int32_t main(){
    FAST;
    
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
 
 	int a,b;	cin >> a >> b;

 	int c,d;	cin >> c >> d;

 	int L = a-1 , R = b;

 	int div1 = (R/c + R/d - R/lcm(c,d));
 	int div2 = (L/c + L/d - L/lcm(c,d));

 	//cout << div1 << " " << div2 << endl;

 	int first = R - div1;
 	int secnd = L - div2;

 	//cout << first << " " << secnd << endl;

 	cout << (first - secnd) << endl;
    
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))

tmp = 0
a_filter = []
idx = 0
while idx < len(a) - 1:
    if a[idx] < a[idx+1]:
        a_filter += [a[idx],a[idx+1]]
    idx+=1

ret = 1000
tmp = 0
for i,x in enumerate(a_filter):
    if i % 2:
        ret += tmp*x
    else:
        tmp = ret // x
        ret -= tmp * x
print(ret)

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}


void solve(){
  int a;
  cin >> a;
  cout << std::fixed << std::setprecision(7) << (a/3.d)*(a/3.d)*(a/3.0d) << endl;
}

int main(){
  // FastIO
  //ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

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

signed main(){
    int N, W;
    cin >> N >> W;
    vector<int> v(N), w(N);
    rep(i, N) cin >> v[i] >> w[i];

    vector<int> dp(10001, INF);
    dp[0] = 0;
    rep(i, N){
        for(int j = 10000; j >= 0; j--){
            if(j < v[i] || dp[j - v[i]] == INF){
                continue;
            }
            dp[j] = min(dp[j], dp[j-v[i]] + w[i]);
        }
    }

    int ans = 0;
    rep(i, 10001){
        if(dp[i] <= W){
            ans = i;
        }
    }
    cout << ans << endl;

    return 0;
}



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

int main(){
    int h,w;

    while(1){
        cin>>h>>w;
        if(h==0&&w==0)break;

        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                if((i%2==0&&j%2==0)||(i%2==1&&j%2==1))cout<<"#";
                else cout<<".";
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
  for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
  for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
  return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
  os<<"{ ";for(auto m:M)os<<"("<<m.first<<":"<<m.second<<")";
  return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
//For multiset use less_equal operator but it does support erase operations for multiset
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mp make_pair
// inline void modadd(int &a,int &b){a+=b;if(a>=mod)a-=mod;} 
int main(){
  fio; cout<<fixed<<setprecision(25);	
  string s;
  cin >> s;
  if(s.back() != 's') s.pb('s');
  else{
    s.pb('e');
    s.pb('s');
  }
  cout << s << endl;
  
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i;
        int x;
        for(i=1; ;i++){
            x = sc.nextInt();
            if(x==0){
                break;
            }
            System.out.printf("Case %d: %d\n",i,x);
        }
    }
}


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

int main() {
  ll a, b, x;
  cin >> a >> b >> x;

  if (a == 0)
    cout << b / x + 1 << endl;
  else
    cout << b / x - (a - 1) / x << endl;
}

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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

template <class T1, class T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T1, class T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

int main() {
    string N;
    cin >> N;
    map<char, string> ans = {
        {'0', "pon"}, {'1', "pon"}, {'2', "hon"}, {'3', "bon"}, {'4', "hon"},
        {'5', "hon"}, {'6', "pon"}, {'7', "hon"}, {'8', "pon"}, {'9', "hon"},
    };
    cout << ans[N[N.size() - 1]] << endl;
}

Measured memory_bytes: 3620
from itertools import combinations_with_replacement

N, M, Q = map(int, input().split())
ABCD = [list(map(int, input().split())) for i in range(Q)]
ans = 0

for x in combinations_with_replacement(range(M), N):
    temp = 0
    for i in range(Q):
        if x[ABCD[i][1]-1]+1 == x[ABCD[i][0]-1]+1 + ABCD[i][2]:
            temp += ABCD[i][3]
    if temp > ans:
        ans = temp
print(ans)

Measured memory_bytes: 68208
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll max(ll a, ll b){
	if(a>b)return a;
	else return b;
}

int main(){
    string s,t;
    cin>>s>>t;
    int sl=s.length(),tl=t.length();
    int maxx=0;
    for(int i=0;i<=sl-tl;i++){
    	int x=0;
		for(int j=i;j<tl+i;j++){
    		if(s[j]==t[j-i]){
    			x++;
			}
		}
		maxx=max(maxx,x);
	}
	cout<<tl-maxx<<endl;
}

Measured memory_bytes: 3620
h,w,d=map(int,input().split())
l=[]
for i in range(h):
    l.append(list(map(int,input().split())))
px=[0]*(h*w)
py=[0]*(h*w)
ans=[0]*(h*w)
for i in range(h):
    for j in range(w):
        px[l[i][j]-1]=j
        py[l[i][j]-1]=i
for i in range(d,h*w):
    ans[i]=ans[i-d]+abs(px[i]-px[i-d])+abs(py[i]-py[i-d])
q=int(input())
for i in range(q):
    a,b=map(int,input().split())
    print(ans[b-1]-ans[a-1])

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

int main() {
  int a, b;
  cin >> a >>b;
  if(b%2==0 && b%4==0 && b/4<=a && a<=b/2){
    cout <<"Yes" <<endl;
  }
  else if(b%2==0 && b%4!=0 && b/4+1<=a && a<=b/2){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
    
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define push_back pb
#define int long long int
int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	//cin >> t;
	while (t--)
	{
		int n, ans = 0;
		cin >> n;
		int a[n];
		for (int i = 0; i < n; i++)
		{
			cin >> a[i];
		}
		for (int i = 1; i < n; i++)
		{
			if (a[i] < a[i - 1])
			{
				ans += a[i - 1] - a[i];
				a[i] = a[i - 1];
			}
		}
		cout << ans;

	}
	return 0;
}

Measured memory_bytes: 5224
#include <bits/stdc++.h>
int main(void){
  int a, b, c, x, y, ans;
  std::cin >> a >> b >> c >> x >> y;
  if(x < y){
    int tmp;
    tmp = x; x = y; y = tmp;
    tmp = a; a = b; b = tmp;
  }
  ans = std::min(2 * x * c, 2 * y * c + (x - y) * a);
  ans = std::min(ans, x * a + y * b);
  std::cout << ans << std::endl;
  return 0;
}


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


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 100100100100100100;
int main(){
  ll n,i,ans = inf,now,p;scanf("%lld",&n);
  ll a[n];
  for(i=0;i<n;i++) scanf("%lld",&a[i]);
  now = p = 0;
  for(i=0;i<n;i++){//1st +
    now += a[i];
    if(now == 0){
      now = (i%2==0 ? 1:-1);p++;
    } else if(now<0 && i%2==0){
      p += 1-now;now = 1;
    } else if(now>0 && i%2==1){
      p += now+1;now = -1;
    }
  }
  ans = min(ans,p);
  now = p = 0;
  for(i=0;i<n;i++){//1st -
    now += a[i];
    if(now == 0){
      now = (i%2==1 ? 1:-1);p++;
    } else if(now<0 && i%2==1){
      p += 1-now;now = 1;
    } else if(now>0 && i%2==0){
      p += now+1;now = -1;
    }
  }
  ans = min(ans,p);
  printf("%lld\n",ans);
}

Measured memory_bytes: 1024
#include<stdio.h>
#define type long long int

void swap(type *x, type *y){
    type  tmp;
    tmp = *x; *x = *y; *y = tmp;
}

int partition(type a[], int l, int r){
	int i,j;
	type v;
	v = a[l];
	 i = l;
	 j = r+1;
	 do{
	 	do{ i++;} while(i <= r && a[i] < v);
	 	do{ j--; } while(j >= l && a[j] > v);
	 	if(i > r || j < l){
	 		//printf("over\n");
	 		break;
	 	}
	 	if(i < j){ swap(&a[i], &a[j] ); }
	 }while(j > i);
	 a[l] = a[j]; a[j] = v;
	 return j;
}

void quicksort(type a[], int l, int r){
	int i, j;
	//j = r+1;
	if(l<r){
		i = partition(a, l, r);
		quicksort(a,l, i-1);
		quicksort (a, i+1, r);
	}
}

int main(){
	int X, Y, A, B, C;
	scanf("%d %d %d %d %d", &X, &Y, &A, &B, &C);
	long long int p[A+1];
	long long int q[B+1];
	long long int r[C+X+Y+1];
	int i;
	p[0] = q[0] = r[0] = 1000000001;
	long long int ret = 0;
	for(i = 1; i <= A; i++){
		scanf("%lld", &p[i]);
	}
	for(i = 1; i <= B; i++){
		scanf("%lld", &q[i]);
	}
	for(i = 1; i <= C; i++){
		scanf("%lld", &r[i]);
	}
	quicksort(p, 1, A);
	quicksort(q, 1, B);
	/*for(i = 0; i <= A - X; i++){
		p[i] = 0;
	}
	for(i = 0; i <= B-Y; i++){
		q[i] = 0;
	}*/
	for(i = A - X + 1; i <= A; i++){
		r[C+i - (A-X)] = p[i]; 
	}
	for(i = B - Y + 1; i <= B; i++){
		r[C+X+i - (B-Y)] = q[i]; 
	}
	quicksort(r, 1, C+X+Y);
	for(i = 0; i < X+Y; i++){
		ret += r[C+X+Y - i];
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int x=0,f=1;
	char ch;
	do
	{
		ch=getchar();
		if (ch=='-')
		{
			f=-f;
		}
	}while (ch<'0' || ch>'9');
	do
	{
		x=x*10+ch-'0';
		ch=getchar();
	}while (ch>='0' && ch<='9');
	return x*f;
}
#define ll long long
const int maxn=6010;
const ll Mod=998244353;
int n,k;
ll f[maxn][maxn],inv[maxn],fac[maxn];
void upd(ll &x,ll v)
{
	x=(x+v)%Mod;
}
ll c(int n,int m)
{
	if (m<0 || m>n)
	{
		return 0;
	}
	return fac[n]*inv[m]%Mod*inv[n-m]%Mod;
}
int main()
{
	scanf("%d%d",&n,&k);
	fac[0]=1;
	for (int i=1;i<=n;i++)
	{
		fac[i]=fac[i-1]*i%Mod;
	}
	inv[0]=inv[1]=1;
	for (int i=2;i<=n;i++)
	{
		inv[i]=(Mod-Mod/i)*inv[Mod%i]%Mod;
	}
	for (int i=1;i<=n;i++)
	{
		inv[i]=inv[i]*inv[i-1]%Mod;
	}
	f[0][0]=1;
	for (int i=1;i<=n;i++)
	{
		for (int j=i;j<=i*2;j++)
		{
			upd(f[i][j],f[i-1][j-1]);
			if (j>1)
			{
				upd(f[i][j],f[i-1][j-2]);
			}
		}
	}
	ll ans=0;
	for (int i=0;i<=n;i++)
	{
		ll now=0;
		for (int j=0;j<k-1;j++)
		{
			upd(now,f[i][j]);
		}
		for (int j=0;j<=i;j++)
		{
			if (i-j<=j && k-1-(i-j)*2>=0)
			{
				upd(now,f[j-(i-j)][k-1-(i-j)*2]);
			}
			else if (i-j>j && j*2==k-1)
			{
				upd(now,1);
			}
		}
		upd(ans,now*c(n,i));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 139776
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int temp,n;
	cin>>n;
	vector<int> t(10010,0);
	for(int i=1;i<=100;i++){
		for(int j=1;j<=100;j++){
			for(int k=1;k<=100;k++){
				temp=i*i+j*j+k*k+i*j+j*k+k*i;
				if(temp<t.size())
				t[temp]++;
			}
		}
	}
	for(int i=1;i<=n;i++){
		cout<<t[i]<<endl;
	}
}

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


int main(){
  int n,l;
  cin>>n>>l;
  string s[n];
  rep(i,0,n){
    cin>>s[i];
  }
  sort(s,s+n);
  string ans="";
  rep(i,0,n){
    ans+=s[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256