akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int n;
int c[505], s[505], f[505];
/**********************************************/

int main(){
    cin >> n;

    REP(i, n-1){
        cin >> c[i] >> s[i] >> f[i]; 
    }

    REP(i, n-1){
        LL time = 0;
        FOR(j, i, n-1){
            if(time < s[j]){
                time = s[j] + c[j];
            }else if(time % f[j] == 0){
                time = time + c[j]; 
            }else{
                time = time + f[j] - (time % f[j]) + c[j];
            }
        }
        cout << time << endl;
    }
    cout << "0" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

ll f(ll n, ll x){
  if(n==-1) return 0;
  return n/x + 1;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,x;
  cin >> a >> b >> x;
  
  cout << f(b,x) - f(a-1,x) << endl;
}


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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

//#define _USE_MATH_DEFINES
//#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef int long long i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 1000000007; // 10000000000000007ll;

const double eps = 1e-8;

const i64 MAXN = 1'000'000 + 6;

i64 n;
i64 a[MAXN];

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n;

    set<string> q;
    q.insert("a");
    for (i64 tt = 2; tt <= n; tt++) {
        set<string> nq;

        for (auto t : q) {
            set<char> e;
            char m = 'a';
            for (auto c : t) {
                e.insert(c);
                m = max(m, (char)(c + 1));
            }

            for (auto c : e) {
                nq.insert(t + c);
            }
            nq.insert(t + m);
        }

        q = nq;
    }

    stringstream ss;
    for (auto t : q) {
        ss << t << endl;
    }
    cout << ss.str();


    return 0;
}

Measured memory_bytes: 22532
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#define ll long long
#define rgi register int
#define il inline

using namespace std;

int a;
string s;

il int read()
{
	rgi f = 0, x = 0, ch;
	while(!isdigit(ch = getchar())) f |= ch == '-';
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

int main()
{
	a = read();
	cin >> s;
	if(a >= 3200)
		cout << s;
	else
		cout << "red";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>

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

int main(){

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

    cout << a*b << endl;
    return 0;


}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		String inStr;
		inStr = inp();
		String[] in;
		in = inStr.split(" ");

		int[] e = { Integer.valueOf(in[0]), Integer.valueOf(in[1]), Integer.valueOf(in[2]) };

		for (int i = 0; i < 2; i++)
			for (int j = i + 1; j < 3; j++)
				if (e[i] > e[j]) {
					int tmp = e[i];
					e[i] = e[j];
					e[j] = tmp;
				}

		System.out.println(e[0] + " " + e[1] + " " + e[2]);

	}

	private static String inp() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		return br.readLine();
	}

}

Measured memory_bytes: 24456
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int ans = 0;
    cin >> n;
    if(n < 3){
        cout << 0 << endl;
        return 0;
    }
    vector<long long> a(n);
    for(int i = 0;i < n ; i++){
        cin >> a[i];
    }
    for(int l = 0;l < a.size();l++){
        for(int m = l;m < a.size();m++){
            for(int o = m; o < a.size();o++){
                if(l == m || m == o || l == o)continue;
                if(a[l] == a[m] ||a[l] == a[o] ||a[m] == a[o])continue;
                if(a[l] + a[m] > a[o] &&a[l] + a[o] > a[m] && a[o] + a[m] > a[l])ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	double d = sqrt(pow(x1-x2, 2) + pow(y1-y2, 2));

		printf("%lf\n", d);

	return 0;


}

Measured memory_bytes: 3212
# -*- coding: utf-8 -*-
A, B = map(int, input().split())
C = 0
if (A < 3) or (B > 20) or (isinstance(A, int) != True) or (isinstance(B, int) != True):
    exit()
for i in range(2):
    if A > B:
        C += A
        A -= 1
        i += 1
    else:
        C += B
        B -= 1
        i += 1
print(C)


Measured memory_bytes: 3060
from itertools import accumulate
from operator import xor

s = tuple(map(lambda c: 1 << (ord(c)-ord('a')),input()))
L = len(s)
dp = dict()
dp[0] = 0

for v in accumulate(s, xor):
  dp[v] = min(dp.get(v,L), min(dp.get(v ^ (1 << i), L) for i in range(26))+1)

print(dp[v] + (v == 0))

Measured memory_bytes: 37928
s = [input() for i in range(1)] 
num = int(s[0])

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
print(num2alpha(num).lower())

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9+7;
int main() {
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
	#endif
	int n;
	cin >> n;
	int a[n+5];
	long long pref = 0LL, ans = 0LL;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		pref += a[i];
	}
	for (int i = 0; i < n; ++i) {
		pref -= a[i];
		ans = (ans + (a[i]%MOD)*(pref%MOD)) % MOD;
		ans = ans % MOD;
	}
	if(ans < 0)
		ans += MOD;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 4420
#include <bits/stdc++.h>
#define rep(k,i,n) for(long long i=k;i<n;++i)
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    ll A,B;
    cin>>A>>B;
    ll ans=0;
    while(1+ans*(A-1)<B){
        ++ans;
    }
    cout<<ans<<endl;
}


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

using namespace std;
using ll = long long;

int main(){
    int n;
    cin>>n;
    vector<vector<int>> a(2,vector<int>(150));
    for(int i=0;i<2;++i){
        for(int j=0;j<n;++j)cin>>a[i][j];
    }
    vector<vector<int>> dp(2,vector<int>(150));
    dp[0][0] = a[0][0];
        for(int j=0;j<n;++j){
            if(j<n-1)dp[0][j+1] = dp[0][j] + a[0][j+1];
            dp[1][j] = max(dp[1][j],dp[0][j] + a[1][j]);
            if(j<n-1)dp[1][j+1] = max(dp[0][j+1],dp[1][j]) + a[1][j+1];
        }
    cout<< dp[1][n-1] << endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n,m,x;
  int r=0,l=0;
  int a;
  cin>>n>>m>>x;
  for(int i=0;i<m;i++){
    cin>>a;
    if(a<x) l++;
    else r++;
  }
  cout<<min(l,r)<<"\n";
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n, m = map(int, input().split())


class UnionFind:
    def __init__(self, n):
        self.p = [-1]*n
        self.r = [1]*n

    def find(self, x):
        if self.p[x] < 0:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def union(self, x, y):
        rx, ry = self.find(x), self.find(y)
        if rx != ry:
            if self.r[rx] > self.r[ry]:
                rx, ry = ry, rx
            if self.r[rx] == self.r[ry]:
                self.r[ry] += 1
            self.p[ry] += self.p[rx]
            self.p[rx] = ry

    def count_members(self, x):
        return -self.p[self.find(x)]


uf = UnionFind(n)
for _ in range(m):
    a, b = map(lambda x: int(x)-1, input().split())
    uf.union(a, b)

print(max(map(lambda i: uf.count_members(i), range(n))))


Measured memory_bytes: 14552
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int A, B; cin >> A >> B;
    F0R(i, max(A, B)) {
        cout << min(A, B);
    }
    cout << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



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

int main(void) {
	int a, b, c;
	string ans;

	cin >> a >> b >> c;

	ans = "No";
	if ((a == b + c) || (b == c + a) || (c == a + b))
		ans = "Yes";

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


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>

#define ll long long
using namespace std;

const int MAXN = 2e5+10;
const int mod = 1e9+7;

ll f[4010][4010],n,a[MAXN],b[MAXN],fac[8010],inv[8010],ans = 0;

ll qp(ll x,int t){
    ll res = 1;
    for(;t;t >>= 1,x = x*x%mod){
	if(t&1) res = x*res%mod;
    }
    return res;
}

ll c(ll x , ll y){
    return fac[x] * inv[x-y]%mod * inv[y]%mod;
}

int main(){
    scanf("%lld",&n);
    for(int i = 1;i <= n;i++){
	scanf("%lld %lld",&a[i],&b[i]);
    }
    fac[0] = fac[1] = 1;
    for(int i = 2;i <= 8000;i++) fac[i] = fac[i-1]*i%mod;
    inv[8000] = qp(fac[8000],mod-2);
    for(int i = 8000-1;i >= 0;i--) inv[i] = inv[i+1]*(i+1) % mod;
    
    for(int i = 1;i <= n;i++){
	f[2000-a[i]][2000-b[i]] ++;
    }
    for(int j = 1;j <= 4000;j++) f[0][j] = (f[0][j] + f[0][j-1])%mod;
    for(int i = 1;i <= 4000;i++){
	f[i][0] = (f[i][0] + f[i-1][0])%mod;
	for(int j = 1;j <= 4000;j++)
	    f[i][j] += (f[i-1][j] + f[i][j-1]) % mod;
    }
    for(int i = 1;i <= n;i++){
	ans += f[a[i]+2000][b[i]+2000];
    }
    for(int i = 1;i <= n;i++){
	ans = ans - c(a[i]+b[i]+a[i]+b[i],a[i]+a[i]);
	ans = (ans%mod+mod)%mod;
    }
    ans = ans * inv[2] % mod;
    printf("%lld\n",(ans+mod)%mod);
    return 0;
}

Measured memory_bytes: 131788
from sys import stdin


def get_result(data):
    K = int(data[0][0])
    S = data[1][0]
    return S if len(S) <= K else S[:K] + "..."


if __name__ == '__main__':
    raw_data = [val.rstrip() for val in stdin.readlines()]
    data = [list(map(str, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)


Measured memory_bytes: 9184
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto hw = readln.split.to!(long[]);
    auto H = hw[0];
    auto W = hw[1];

    if (H == 1 || W == 1) {
        writeln(1);
    } else if((H*W)%2 == 0) {
        writeln(H*W/2);
    } else {
        writeln((H*(W-1)/2 + (H+1)/2));
    }
}

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

int main(void){
    long long a, b, ans = 0ll;
    cin >> a >> b;
    if(a%2==0){
        if((b-a+1)%2==0){
            if(((b-a+1)/2)%2==0) ans = 0;
            else ans = 1;
        }else{
            if(((b-a+1)/2)%2==0) ans = 0;
            else ans = 1;
            ans ^= b;
        }
    }else{
        if((b-a)%2==0){
            if(((b-a)/2)%2==0) ans = 0;
            else ans = 1;
        }else{
            if(((b-a)/2)%2==0) ans = 0;
            else ans = 1;
            ans ^= b;
        }
        ans ^= a;
    }
    cout << ans << endl;
}

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

using std::cin;
using std::cerr;
using std::cout;
using std::endl;
using std::make_pair;
using std::pair;
using std::stack;
using std::string;
using std::unordered_set;
using std::vector;
using std::lower_bound;
using std::upper_bound;

int main(int argc, char* argv[]) {
  int n, r;
  cin >> n >> r;
  if (n <= 10) {
    cout << r + 100 * (10 - n);
  } else {
    cout << r;
  }
  return 0;
}


Measured memory_bytes: 256
h,w,d=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(h)]
q=int(input())
LR=[list(map(int,input().split())) for _ in range(q)]
size=h*w+1

B=[[] for _ in range(size)]
for i in range(h):
    for j in range(w):
        B[A[i][j]]=[i,j]

DP=[0]*size
for i in range(d+1,size):
    x,y=B[i]
    z,w=B[i-d]
    DP[i]=DP[i-d]+abs(x-z)+abs(y-w)

for l,r in LR:
    print(DP[r]-DP[l])

Measured memory_bytes: 42308
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
using namespace std;
using ll = long long;
#define MM = 1000000000;
#define mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
int main(){
    map<int, int> mp;
    int n[4];
    bool flg = true;
    for(int i = 0; i < 4; i++){
        cin >> n[i];
        mp[n[i]]++;
    }
    if(mp[1] != 1 || mp[4] != 1 || mp[7] != 1 || mp[9] != 1){
        flg = false;
    } 
    if(flg) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!long;
    auto A = readln.chomp.to!long;
    auto B = readln.chomp.to!long;
    auto C = readln.chomp.to!long;
    auto D = readln.chomp.to!long;
    auto E = readln.chomp.to!long;

    auto x = min(A, B, C, D, E);
    writeln(4 + (N+x-1)/x);
}

Measured memory_bytes: 256
N, Y = map(int, input().split())

flag = False

for i in range(N + 1) :
    for j in range(N + 1 - i) :
        k = N - i - j
        if 10000 * i + 5000 * j + 1000 * k == Y :
            print(i, j, k)
            flag = True
            break
    if flag == True :
        break

if flag == False :
    print(-1, -1, -1)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
#include<unordered_set>
#define lol(i,n) for(ll i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
int NOEL(){
  cout<<"NO"<<endl;
  return 0;
}
string g(char a,string b){
  string res="";
  res.push_back(a);
  res+=b;
  return res;
}

unordered_map<string,ll> nz;

unordered_map<string,vector<string> >v;
unordered_set<string> vis;
bool done;
void dfs(string x){
  if(vis.find(x)!=vis.end())return;
  vis.insert(x);
  if(nz[x]!=0)done=1;
  for(auto y:v[x]){
    dfs(y);
  }
}
int main(){
    ll n,h;
    cin>>n>>h;
    lol(i,n){
      string a,b,c,d;cin>>a>>b>>c>>d;
      string s,t;
      if(c=="0")s=g('x',a);
      else s=g('y',c);
      nz[s]++;
      if(d=="0")t=g('y',b);
      else t=g('x',d);
      nz[t]--;
      //cout<<s<<" "<<t<<endl;
      v[s].push_back(t);
      v[t].push_back(s);
    }
    for(auto dat:nz){
      string key=dat.first;
      ll cnt=dat.second;
      //cout<<key<<" "<<cnt<<endl;
      //if(cnt>=2||cnt<=-2)return NOEL();
      if(cnt>0&&key[0]!='x')return NOEL();
      if(cnt<0&&key[0]!='y')return NOEL();
      if(vis.find(key)==vis.end()){
	done=0; dfs(key);
	if(done==0)return NOEL();
      }
    }
    cout<<"YES"<<endl;
    return 0;
}


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

int main() {
    typedef pair<string,int> P;
    queue<P> q;
    
    int N;
    cin >> N;
    for(int i = 0;i<N;++i){
        string S;
        int t;
        cin >> S >> t;
        q.push(make_pair(S,t));
    }
    string Sleep;
    cin >> Sleep;
    int sum = 0;
    bool coming = false;
    while(!q.empty()){
        string S;
        int t;
        tie(S,t) = q.front();
//        cout << S << ":" << t << endl;
        if(S == Sleep){
            q.pop();
            coming = true;
        }else if(!coming){
            q.pop();    
        }else{
            sum += t;
            q.pop();
            
//        cout << S << ":" << t << "sum:" << sum << endl;
        }
    }
    cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {
    int N,AC=0,WA=0,TLE=0,RE=0;
    scanf("%d\n",&N);
    for (int i=0;i<N;i++) {
        char M[20];
        scanf("%s",M);
        if (0==strcmp(M,"AC")) {
            AC++;
        }
        else if (0==strcmp(M,"WA")) {
            WA++;
        }
        else if (0==strcmp(M,"TLE")) {
            TLE++;
        }
        else if (0==strcmp(M,"RE")) {
            RE++;
        }
        else {;}
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",AC,WA,TLE,RE);
}

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

#define M 1000000
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  else return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M;}
int h2(int key){ return 1+(key % (M-1)); }

int find(char str[]){
  long long key, i, a;
  key = getKey(str);
  for(i = 0;; i++)
    {
      a = (h1(key) + i * h2(key)) % M;
      if(strcmp(H[a], str) == 0)
	{
	  return 1;
	}
      else if(strlen(H[a]) == 0)
	{
	  return 0;
	}
    }
  return 0;
}

int insert(char str[]){
  long long key, i, a;
  key = getKey(str);
  for(i = 0;; i++)
    {
      a = (h1(key) + i * h2(key)) % M;
      if(strcmp(H[a], str) == 0)
	{
	  return 1;
	}
      else if(strlen(H[a]) == 0)
	{
	  strcpy(H[a], str);
	  return 0;
	}
    }
  return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



Measured memory_bytes: 15464
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define INF   (1e9 + 7)
#define MAX_AB (2000000000)

ll A, B;

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

void solve() {
  ll ans0 = gcd(A, B);
  ll ans1 = A * (B / ans0);


  printf("%lld %lld\n", ans0, ans1);
}

int main() {
  while(scanf("%lld %lld", &A, &B) != EOF){
    solve();
  }

  return 0;
}

Measured memory_bytes: 3156
#include <stdio.h>

int main(void)
{
        char S[10];
        int i,j=0,t=0;

       scanf("%s",&S);
        for(i=0;i<10;i++){
                if(S[i]=='A'|| S[i]=='C'|| S[i]=='G'|| S[i]=='T')
                        j++;
                if(i==9 || (S[i]!='A'&& S[i]!='C'&& S[i]!='G'&& S[i]!='T')){
                        if(j>t)t=j;
                        j=0;
                }
        }

        printf("%d\n",t);

        return 0;
}


Measured memory_bytes: 128
/*


*/
#include <cstdio>
#include <cctype>
#include <bitset>
#include <algorithm>
#define gc() getchar()
#define mod 998244353
typedef long long LL;
const int N=305;

std::bitset<N> A[N],B[N];

inline int read()
{
	int now=0;register char c=gc();
	for(;!isdigit(c);c=gc());
	for(;isdigit(c);now=now*10+c-48,c=gc());
	return now;
}
inline int FP(int x,int k)
{
	int t=1;
	for(; k; k>>=1,x=1ll*x*x%mod)
		if(k&1) t=1ll*t*x%mod;
	return t;
}

int main()
{
	int n=read(),m=read();
	for(int i=1; i<=n; ++i)
		for(int j=1; j<=m; ++j) A[i][j]=read()==1;
	int r=0;
	for(int i=1; i<=n; ++i)
		for(int j=1; j<=m; ++j)
			if(A[i][j])//x>>j&1
			{
				if(B[j][j]) A[i]^=B[j];
				else
				{
					B[j]=A[i];
					++r; break;
				}
			}
	printf("%d\n",(FP(2,n+m-1)+mod-FP(2,n-r+m-1))%mod);

	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val k = sc.nextInt()
    val x = sc.nextInt()
    val left = Math.max(-1000000, x - k + 1)
    val right = Math.min(1000000, x + k - 1)
    println((left..right).joinToString(" "))
}

Measured memory_bytes: 31524
class Union:
  def __init__(s, num):
    s.T = [-1 for i in range(num)]
 
  def root(s, x):
    if s.T[x] < 0: return x, -s.T[x]
    t, k = s.root(s.T[x])
    s.T[x] = t
    return t, k
 
  def merge(s, x, y):
    an, am = s.root(x)
    bn, bm = s.root(y)
    if an == bn: return False
    if am < bm: an, bn  = bn, an
    s.T[an] += s.T[bn]
    s.T[bn] = an
    return True
 
  def size(s, x):
    return s.root(x)[1]

  def same(s, x, y):
    return s.root(x)[0] == s.root(y)[0]

N, M, K = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]
CD = [list(map(int, input().split())) for _ in range(K)]
 
uni = Union(N)
ans = [-1] * N
for a, b in AB:
  a -= 1
  b -= 1
  uni.merge(a, b)
  ans[a] -= 1
  ans[b] -= 1
 
L = [[] for _ in range(N)]
for c, d in CD:
  c -= 1
  d -= 1
  L[c].append(d)
  L[d].append(c)
 
for i in range(N):
  ans[i] += uni.size(i)
  for j in L[i]:
    if uni.same(i, j):
      ans[i] -= 1
 
ans = map(str, ans)
print(" ".join(ans))

Measured memory_bytes: 128344
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  
    vector<double> A(N);
  vector<string> B(N);
  for(int i=0;i<N;i++){
  cin>>A[i]>>B[i];
  }
  double a=0;
  for(int i=0;i<N;i++){
  if(B[i]=="BTC"){
  a+=A[i]*380000.0;
  }
    if(B[i]=="JPY"){
    
    a+=A[i];
    }
  }
  cout<<a<<endl;
  
  }
  


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#define mop 1000000007

using namespace std;

struct desire{
    long long a,b;
};
vector<desire> v;

bool asc(const desire& left, const desire& right){
    return left.b == right.b ? left.a < right.a : left.b < right.b;
}

int main() {
   

    long long n,m;
    cin >> n >> m;
    for (long long i=0;i<m;i++){
        desire p;
        cin >> p.a >> p.b;
        v.push_back(p);
    }
    sort(v.begin(),v.end(),asc);
    long long ans = 0;
    long long tri = 0;
    for (long long i=0;i<v.size();i++){
        if(tri < v[i].a){
            tri = v[i].b - 1;
            ans += 1;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 2420
#include <stdio.h>
#include <math.h>
#define N_MAX 10000

int isPrime(int x)
{
  int i;
  if (x <= 3) {
    return 1;
  } else if (x % 2 == 0) {
    return 0;
  } else {
    for (i = 3; i <= sqrt(x); i = i + 2) {
      if (x % i == 0) {
        return 0;
      }
    }
    return 1;
  }
}

int main(int argc, char *argv[])
{
  int i, j, n, x;
  int answer = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &x);
    answer = answer + isPrime(x);
  }
  printf("%d\n", answer);
  return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> piipi;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

int a[100005];
int cnt[100005];
int main(){
    int n;
    scanf("%d", &n);   
    for(int i=1;i<=n;i++){
        scanf("%d", &a[i]);
        cnt[a[i]]++;
    }
    int rem = 0;
    for(int i=1;i<=100000;i++){
        if(cnt[i] == 0) continue;
        cnt[i] %= 2;
        if(cnt[i] == 0) cnt[i] += 2;
        if(cnt[i] > 1){
            int mn = min(rem, cnt[i]-1);
            cnt[i] -= mn;
            rem -= mn;
            rem += cnt[i]-1;
            cnt[i] = 1;
        }
    }
    int ans = 0;
    for(int i=1;i<=100000;i++){
        if(cnt[i] == 1) ans++;
    }
    if(rem > 0) ans--;
    printf("%d\n", ans);
}

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

int main(){
    int n, m;
    cin >> n >> m;
    if(n >= m){
        cout << 0 << endl;
        return 0;
    }
    vector<int> v;
    for(int i = 0; i < m; i++){
        int x;
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    vector<int> v_dif;
    for(int i = 0; i < m-1; i++){
        v_dif.push_back(v[i+1] - v[i]);
    }
    sort(v_dif.begin(), v_dif.end());
    int ans = 0;
    for(int i = 0; i < m-n; i++){
        ans += v_dif[i];
    }
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 1400
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
 
int main(){
    int a;

    cin >> a;
    cout << (a + pow(a,2) + pow(a,3)) << endl;

    return 0;
}



Measured memory_bytes: 3608
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;
vector<pair<ll, ll>> factrize(ll n)
{
    vector<pair<ll, ll>> res;
    for (ll i = 2; i <= sqrtl(n); i++)
    {
        ll k = i;
        ll cnt = 0;
        while (n % k == 0)
        {
            n /= k;
            cnt++;
        }
        res.emplace_back(k, cnt);
    }
    if (n != 1)
    {
        res.emplace_back(n, 1);
    }
    return res;
}
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n;
cin >> n;
map<ll,ll> mp;
for(int i = 2; i <= n; i++){
    vector<P> res = factrize(i);
    for(auto v: res){
        mp[v.first] += v.second;
    }
}
ll ans = 0;
for(int i = 2; i <= n; i++){
    if(mp[i] >= 74)
        ans++;
}
for(int i = 2; i < n; i++){
    for(int j = i + 1; j <= n; j++){
        if(mp[i] >= 2 && mp[j] >= 24)
            ans++;
        if(mp[i] >= 24 && mp[j] >= 2)
            ans++;
    }
}
for(int i = 2; i < n - 1; i++){
    for(int j = i + 1; j < n; j++){
        for(int k = j + 1; k <= n; k++){

                if (mp[i] >= 2) {
                    if (mp[j] >= 4 && mp[k] >= 4)
                        ans++;
                }
                if (mp[i] >= 4) {
                    if (mp[j] >= 4 && mp[k] >= 2)
                        ans++;
                    if (mp[k] >= 4 && mp[j] >= 2)
                        ans++;
                }
        }
    }
}
for(int i = 2; i <= n; i++){
    for(int j = i + 1; j <= n; j++){
        if(i != j) {
            if (mp[i] >= 14 && mp[j] >= 4)
                ans++;
            if(mp[i] >= 4 && mp[j] >= 14)
                ans++;
        }
    }
}
cout << ans << endl;
}

Measured memory_bytes: 3680
function main()
  
  N = parse(Int, readline())

  dict = Dict("AC" => 0, "WA" => 0, "TLE" => 0, "RE" => 0)
  
  for i in 1:N
    S = chomp(readline())
    dict[S] = get(dict, S, 0) + 1
  end
  
  for i in ["AC", "WA", "TLE", "RE"]
    println(i, " x ", dict[i])
  end
  
end

main()

Measured memory_bytes: 203996
#include <bits/stdc++.h>
#define rep(i,n) for(int i=1;i<=n;++i)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
using namespace std;

int main(){
  int n;
  cin >> n;
  cout << n*800-n/15*200 << endl;
  return 0;
}


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

class Program {
    static string FizzBuzz(int n) {
        if (n % 15 == 0)
            return "FizzBuzz";
        else if (n % 3 == 0)
            return "Fizz";
        else if (n % 5 == 0)
            return "Buzz";
        else
            return n.ToString();
    }

    static void Main() {
        while (true) {
            var l = Console.ReadLine().Split(' ');
            var m = int.Parse(l[0]);
            var n = int.Parse(l[1]);
            if (m == 0)
                break;

            var playersFailed = new bool[m];
            var currentPlayer = 0;

            for (var i = 1; i <= n; i++) {
                var answer = Console.ReadLine();
                var incorrect = false;
                if (answer != FizzBuzz(i)) {
                    playersFailed[currentPlayer] = true;
                    incorrect = true;
                }

                var lives = 0;
                for (int start = currentPlayer, p = (currentPlayer + 1) % m; start != p; p = (p + 1) % m) {
                    if (!playersFailed[p]) {
                        lives++;
                        if (lives == 1)
                            currentPlayer = p;
                        else
                            break;
                    }
                }
                if (lives == 1 && incorrect) {
                    for (i++; i <= n; i++)
                        Console.ReadLine();
                    break;
                }
            }

            var winners = Enumerable.Range(1, m).Where(p => !playersFailed[p - 1]).Select(p => p.ToString());
            Console.WriteLine(string.Join(" ", winners.ToArray()));
        }
    }
}

Measured memory_bytes: 9740
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		sc.close();

		int ans = 0;
		for (int i = 1; i < N; i++) {
			char pre = S.charAt(i-1);
			char post = S.charAt(i);
			if (pre == post) {
				ans++;
			}
		}

		System.out.println(N - ans);
	}
}


Measured memory_bytes: 24404
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please


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

	
	string S;
	cin >> S;

	if (S[0] == '9' || S[1] == '9') co("Yes");
	else co("No");

	Would you please return 0;
}

Measured memory_bytes: 256
(defun app ()
    (let ((s (read-line)))
        (if (and (equal (subseq s 0 1) (subseq s 1 2)) (equal (subseq s 1 2) (subseq s 2 3)))
        (format t "No~%")
        (format t "Yes~%")
        )
    )
)
(app)

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

int top = 0, S[1000];

void push(int x) {
  S[++top] = x;
}

int pop(void) {
  top--;
  return S[top+1];
}

int main(void) {
  int a, b;
  top = 0;
  char s[100];
  while(scanf("%s",s) != EOF) {
    if(s[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    } else if(s[0] == '-') {
      b = pop();
      a = pop();
      push(a - b);
    } else if(s[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    } else {
      push(atoi(s));
    }
  }
  printf("%d\n",pop());

  return 0;
}


Measured memory_bytes: 2096
# -*- coding: utf-8 -*-

N, x = map(int, input().split())
aN = list(map(int, input().split()))

cnt = 0
# 初期値設定
if aN[0] > x:
    cnt += aN[0] - x
    aN[0] -= aN[0] - x

# 2番目以降を一つ前と比べていく
for i in range(1,N):
    if aN[i-1] + aN[i] > x:
        cnt += aN[i-1] + aN[i] - x
        aN[i] -= aN[i-1] + aN[i] - x

print(cnt)

Measured memory_bytes: 14252
for i in 1..3000
    x, y = gets.split
    x = x.to_i;y = y.to_i;
    if x == 0 && y == 0
        break
    end
    if x <= y
        puts "%d %d" %[x, y]
    else
        puts "%d %d" %[y, x]
    end
end


Measured memory_bytes: 6872
#include <bits/stdc++.h>
#define endl '\n';

using namespace std;

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

    int n, red, blue;
    char data[101];

    cin >> n;
    cin >> data;

    red = blue = 0;
    for (int i = 0; i < n; ++i) {
        switch (data[i]) {
            case 'R': red++; break;
            case 'B': blue++; break;
        }
    }

    printf("%s\n", red <= blue ? "No" : "Yes");

    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<vector>
#include<list>
#include<iostream>
#include<utility>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<iterator>
#include<map>
#include<limits>
#include<iomanip>
#include<ctime>
#include<cmath>
 
const int INF=2147483647;
const long long MOD=1e9+7;
 
using namespace std;




int main(){
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n,m;
    cin>>n>>m;
    vector<int> vi(n+1,0);
    for(int i=0; i<m; i++){
        int x,y;
        cin>>x>>y;
        vi[x]++;
        vi[y]++;
    }
    for(int i=1; i<=n; i++){
        cout<<vi[i]<<endl;
    }
   
    
    
    
    return 0;
    
    
}

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

using namespace std;
#define loop for(i=0;i<
int main ()
{
    int i,j,k,c,n,t,sum;
    string s;
    cin>>n>>k;
    if(n*500>=k)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}


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

klist = []
slist = [list() for _ in range(m)]

for i in range(m):
    k,*s = map(int,input().split())
    klist.append(k)
    slist[i] = s

p = list(map(int,input().split()))

ans = 0
for i in range(2**n):
    for j in range(m):
        cnt = 0
        for l in slist[j]:
            if (i >> (l-1))&1 ==1:
                cnt += 1
        if cnt%2 != p[j]:
            break
    else:
        ans += 1

print(ans)


Measured memory_bytes: 9212
#include <stdio.h>

int main(void) {
	int n;
	int *a, *b;
	int left, right, i;

	scanf("%d", &n);
	a = (int*)malloc(sizeof(int)*n);
	b = (int*)malloc(sizeof(int)*n);
	for (i = 0; i < n; i++) scanf("%d", &a[i]);
	left = 0;
	right = n - 1;
	i = n - 1;

	while (left <= right) {
		b[left] = a[i--];
		if (i < 0) break;
		b[right] = a[i--];
		left++;
		right--;
	}

	for (i = 0; i < n; i++) printf("%d ", b[i]);
	printf("\n");

	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}

void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}

graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}

void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}

void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll S;
    cin >> S;
    cout << "0 0 ";
    ll a,b;
    a = S / 1000000000 + 1;
    b = 1000000000 - S % 1000000000;
    if(b == 1000000000){
        a--;
        b = 0;
    }
    cout << "1000000000 1 ";
    cout << b << " " << a << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  int pre=-999;
  for(int i=0;i<n;i++){
    if(pre<=a.at(i)-1){
      pre=a.at(i)-1;
    }else if(pre<=a.at(i)){
      pre=a.at(i);
    }else{
      cout<<"No"<<endl;
      return 0;
    }
  }
    cout<<"Yes"<<endl;
    return 0;
}

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

class Main{
  static class Scnr{
    private final InputStream ins;
    private final byte[] buf=new byte[1024];
    private int ptr=0;
    private int buflen=0;
    Scnr(){
      this(System.in);
    }
    Scnr(InputStream ins){
      this.ins=ins;
    }
    private boolean hasNextByte(){
      if(ptr<buflen){
        return true;
      }
      ptr=0;
      try{
        buflen=ins.read(buf);
      }catch(IOException e){
        e.printStackTrace();
      }
      return buflen>0;
    }
    private int readByte(){
      if(hasNextByte()){
        return buf[ptr++];
      }else{
        return -1;
      }
    }
    private static boolean isChar(int c){
      return '!'<=c&&c<='~';//33~126
    }
    public boolean hasNext(){
      while(hasNextByte()&&!isChar(buf[ptr])){
        ptr++;
      }
      return hasNextByte();
    }
    public String next(){
      if(!hasNext()){
        throw new NoSuchElementException();
      }
      StringBuilder sb=new StringBuilder();
      int b=readByte();
      while(isChar(b)){
        sb.appendCodePoint(b);
        b=readByte();
      }
      return sb.toString();
    }
    public long nextLong(){
      if(!hasNext()){
        throw new NoSuchElementException();
      }
      long res=0;
      int b=readByte();
      boolean minus=false;
      if(b=='-'){
        minus=true;
        b=readByte();
      }
      if(b<'0'||'9'<b){
        throw new NumberFormatException();
      }
      while(true){
        if('0'<=b&&b<='9'){
          res*=10;
          res+=b-'0';
        }else if(b==-1||!isChar(b)){
          return minus?-res:res;
        }else{
          throw new NumberFormatException();
        }
        b=readByte();
      }
    }
    public int nextInt(){
      long nl=nextLong();
      if(nl<Integer.MIN_VALUE||Integer.MAX_VALUE<nl){
        throw new NumberFormatException();
      }
      return (int) nl;
    }
  }
  public static void main(String[] args){
    Scnr sc=new Scnr();
    int n=sc.nextInt();
    int m=sc.nextInt();
    int q=sc.nextInt();
    int[] a=new int[q];
    int[] b=new int[q];
    int[] c=new int[q];
    int[] d=new int[q];
    for(int i=0;i<q;i++){
      a[i]=sc.nextInt()-1;
      b[i]=sc.nextInt()-1;
      c[i]=sc.nextInt();
      d[i]=sc.nextInt();
    }
    int[] ary=new int[n];
    System.out.println(calc(0,ary,n,m,q,a,b,c,d));
  }
  static int calc(int p,int[] ary,int n,int m,int q,int[] a,int[] b,int[] c,int[] d){
    if(p<n){
      int res=0;
      for(ary[p]=(p==0?1:ary[p-1]);ary[p]<=m;ary[p]++){
        res=Math.max(calc(p+1,ary,n,m,q,a,b,c,d),res);
      }
      return res;
    }else{
      int res=0;
      for(int i=0;i<q;i++){
        if(ary[b[i]]-ary[a[i]]==c[i]){
          res=res+d[i];
        }
      }
      return res;
    }
  }
}


Measured memory_bytes: 33784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
using Graph = vector<vector<ll>>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);


int main() {
    ll n, d;
    cin >> n;
    set<ll> s;
    rep(i, n){
        cin >> d;
        s.insert(d);
    }
    cout << s.size() << endl;
}


Measured memory_bytes: 3636
import bisect
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

N, Q = map(int, input().split())
S, T, X = [0] * N, [0] * N, [0] * N
work = []

for i in range(N):
	S[i], T[i], X[i] = map(int, input().split())
	work.append((X[i], S[i] - X[i], T[i] - X[i]))

D = [int(input()) for _ in range(Q)]

work.sort()
ans = [-1] * Q
skip = [-1] * Q

for i in range(N):
	left = bisect.bisect_left(D, work[i][1])
	right = bisect.bisect_left(D, work[i][2])
	
	while left < right:
		if skip[left] == -1:
			skip[left] = right
			ans[left] = work[i][0]
			left += 1
		else:
			left = skip[left]					
		
for i in ans:
	print(i)
	

Measured memory_bytes: 106460
n, m = gets.split.map(&:to_i)

graph = Hash.new { |h, k| h[k] = [] }

m.times do
  a, b = gets.split.map(&:to_i)
  graph[a].push(b)
  graph[b].push(a)
end

dist = Array.new(n + 1, -1)
dist[1] = 0

que = []
que.push(1)

ans = Array.new(n + 1, -1)

until que.empty?
  v = que.shift

  graph[v].each do |nv|
    next if dist[nv] != -1

    dist[nv] = dist[v] + 1
    ans[nv] = v
    que.push(nv)
  end
end

puts "Yes"
puts ans[2..-1]


Measured memory_bytes: 34760
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x=max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<P>;
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,sz(v))i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(sz(v))o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
template <class T> inline ll suma(const v(T)& a) 
{ ll res(0); for(auto&& x:a) res += x; return res;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
#define dame {puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;
#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
#define fastio ios_base::sync_with_stdio(false);
#define MOD 1000000007
//----------------------------------------------------------------
template <class T>
map< T, int > prime_factor(T n) {
    map< T, int > ret;
    for(T i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}
ll fac(ll n){
  ll ret=1;
  while(n>1){
    ret*=n;
    if(ret>MOD)ret%=MOD;
    n--;
  }
  return ret;
}


void Main(){
  int n,m;
  cin>>n>>m;
  if(abs(n-m)>1){cout<<0<<endl; return;}
  ll ans=0;
  ans = fac(n)*fac(m);
  if(ans>MOD)ans%=MOD;
  if(abs(n-m)==0){
    ans*=2;
    if(ans>MOD)ans%=MOD;
  }
  cout<<ans;
} int main(int argc,char* argv[]){ 
    fastio; fileio; Main();}

Measured memory_bytes: 256