akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
	double A, B, H, M;
	cin >> A >> B >> H >> M;

	double X1 = A * cos(2 * PI * (H * 60 + M) / (double)720);
	double Y1 = A * sin(2 * PI * (H * 60 + M) / (double)720);

	double X2 = B * cos(2 * PI / 60 * M);
	double Y2 = B * sin(2 * PI / 60 * M);


	double ans = sqrt(pow(X1 - X2, 2) + pow(Y1 - Y2, 2));
	printf("%.20lf\n", ans);
  return 0;
}


Measured memory_bytes: 4088
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------


//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    string s;cin>>s;
    sort(all(s));
    map<char,int>m;
    for(int i=0;i<s.length();i++)
        m[s[i]]++;
    for(char i='a';i<='z';i++){
        if(m[i]==0){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 512
import java.util.Scanner;

class Main {
    private static void solve() {
        Scanner scanner = new Scanner(System.in);

        while (scanner.hasNextInt()) {
            int[] a = new int[4];
            int[] b = new int[4];
            a[0] = scanner.nextInt();
            a[1] = scanner.nextInt();
            a[2] = scanner.nextInt();
            a[3] = scanner.nextInt();
            b[0] = scanner.nextInt();
            b[1] = scanner.nextInt();
            b[2] = scanner.nextInt();
            b[3] = scanner.nextInt();
            int hit = 0;
            int blow = 0;
            boolean[] table = new boolean[10];
            for (int i = 0; i < 4; i++) {
                if (a[i] == b[i]) {
                    hit++;
                } else {
                    table[a[i]] = true;
                }
            }
            for (int i = 0; i < 4; i++) {
                if (table[b[i]]) {
                    blow++;
                }
            }
            System.out.println(hit + " " + blow);
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
const int N = (int)(1e6) + 5;
int t[N];
int n;
void U(int i,int v)
{
    for (;i <= n;i += i&(-i))
        t[i] += v;
}
int Q(int i)
{
    int ans = 0;
    for (;i;i -= i&(-i))
        ans += t[i];
    return ans;
}
int get(int l,int r)
{
    return Q(r) - Q(l - 1);
}
char str[N];
deque < int > s[256];
int p[N];
int main(void)
{
    srand(time(0));
    cin>>(str + 1);
    n = strlen(str + 1);
    int mask = 0;
    for (int i = 1;i <= n;++i)
        mask ^= 1 << (str[i] -= 'a');
    if (__builtin_popcount(mask) > 1)
        return puts("-1") * 0;
    for (int i = 1;i <= n;++i)
        s[str[i]].pb(i);
    int l = 0,r = n + 1;
    vector < pii > v;
    for (int k = 0;k < 26;++k)
        while (s[k].size() > 1)
            v.pb(mp(s[k].front(),s[k].back())),s[k].pop_front(),s[k].pop_back();
    sort(all(v),[&](auto a,auto b)
         {
             return (a.se - a.fi) > (b.se - b.fi);
         });
    ll ans = 0;
    int sz = v.size();
    int cnt = n - 1;
    for (auto it : v)
        ans += cnt - (it.se - it.fi) + get(it.fi,it.se),U(it.fi,1),U(it.se,1),cnt -= 2;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 6524
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

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

const int MOD = 1e9 + 7;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> correct(n, 0);
  for(int i = 0; i < q; i++)
  {
    int temp;
    cin >> temp;
    correct[temp - 1]++;
  }
  for(int i = 0; i < n; i++)
  {
    if(k - q + correct[i] <= 0)
    {
      cout << "No" << endl;
    }
    else
    {
      cout << "Yes" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<lint, lint> P;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).rbegin(), (v).rend())
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/

int main() {
	int N, M;
	cin >> N >> M;
	vector<int>X(M);
	rep(i, M) {
		cin >> X[i];
	}
	sort(X);
	vector<int>dif(M - 1);
	for (int i = 0; i < M-1; i++) {
		dif[i] = X[i + 1] - X[i];
	}
	sort(dif);
	int sum = 0;
	rep(i, M - N) {
		sum += dif[i];
	}
	cout << sum << endl;
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    string S, T; cin >> S >> T;
    int A, B; cin >> A >> B;
    string U; cin >> U;
    if(S == U) cout << A-1 << " " << B << endl;
    else cout << A << " " << B-1 << endl;
    return 0;
}

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

using namespace std;

const long long INF = 1e18;
const int N = 1e5;
const int MOD = 1e9 + 7;

const double PI = acos(-1);


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    map<string, int> st;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        st[s]++;
    }
    long long ans = 0;
    for (auto x : st)
        ans += 1ll * x.second * (x.second - 1) / 2;
    cout << ans;
}

Measured memory_bytes: 11264
#include <iostream>
#include <algorithm>
#define LI long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main(){
LI a[100001];
int n; cin>>n;
FOR(i,0,n) cin>>a[i];
sort(a,a+n);
FOR(i,1,n) a[i]+=a[i-1];
int m=-1;
FOR(i,0,n-1) if(3*a[i]<a[i+1]) m=i;
cout<<n-m-1<<endl;
}

Measured memory_bytes: 1024
N, Y = map(int, input().split())
ans = [-1, -1, -1]

for x in range(N + 1):
  for y in range(N + 1 - x):
    z  = N - x - y
    if 10000*x+5000*y+1000*z==Y:
      ans = x, y, z
      break

print(*ans)


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<int, int> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  cout << max({a+b, a-b, a*b}) << endl;
}


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

#define int long long

int x, y, ans;

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> x >> y;
	while (x <= y) {
		x *= 2;
		ans++;
	}
	cout << ans << endl;
}

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

int main() {
    int n, m, a;
    while (cin >> n >> m >> a, (n or m or a)) {
        vector< pair<int, int> > amida[n];

        rep(i, m) {
            int h, p, q;
            cin >> h >> p >> q;
            p--;
            q--;
            amida[p].push_back( { h, q } );
            amida[q].push_back( { h, p } );
        }

        rep(i, n) {
            sort(amida[i].begin(), amida[i].end(), greater< pair<int, int> >());
        }

        int now_h = 1e8;
        bool update = true;
        a--;

        while (update) {
            update = false;
            for (auto t : amida[a]) {
                if (now_h > t.first) {
                    now_h = t.first;
                    a = t.second;
                    update = true;
                    break;
                }
            }
        }

        cout << a + 1 << endl;

    }

    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll n, m; cin >> n >> m;
	ll ans = 0;
	if (n == 1 && m == 1) {
		ans = 1;
	}
	else if (n == 1 && m != 1) {
		ans = m - 2;
	}
	else if (n != 1 && m == 1) {
		ans = n - 2;
	}
	else if (n >= 2 && m >= 2) {
		ans = (m - 2) * (n - 2);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

int main(){fastio
    ll n,q;cin>>n>>q;
    string s;cin>>s;
    string t[q][2];
    rep(i,0,q-1)rep(j,0,1)cin>>t[i][j];
    ll pl=0,pr=n-1;
    for(ll i=q-1;i>=0;i--){
        if(t[i][1][0]=='L'){
            if(s[pl]==t[i][0][0]){
                pl++;
            }
            if(pr+1<=n-1&&s[pr+1]==t[i][0][0]){
                pr++;
            }
        }else{
            if(s[pr]==t[i][0][0]){
                pr--;
            }
            if(pl-1>=0&&s[pl-1]==t[i][0][0]){
                pl--;
            }
        }
        if(pl>pr)break;
    }
    //cout<<pl<<" "<<pr<<endl;
    
    if(pl>pr)cout<<0<<endl;
    else{
        cout<<pr-pl+1<<endl;
    }
    
    return 0;
}






Measured memory_bytes: 22352
n = int(input())
l = [int(li) for li in input().split(' ')]

def is_unique(a, b, c):
    return (a != b) and (a != c) and (b != c)

def is_triangle(a, b, c):
    return (a + b > c) and (b + c > a) and (c + a > b)

cnt = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            a, b, c = l[i], l[j], l[k]
            if is_unique(a, b, c) and is_triangle(a, b, c):
                cnt += 1
print(cnt)


Measured memory_bytes: 9100
# Your code here!
n,a,b=gets.split
n=n.to_i
a=a.to_i
b=b.to_i

ans=0
i=1

n.times{
    j=i.to_s.split("").map(&:to_i)
    sum=j.inject(:+)
    
    if sum>=a && sum<=b
        ans+=i
        
    end
    
    i+=1
}

p ans

Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  vector<int> a(3);
  int k;
  int ans=0;
  cin >> a[0] >> a[1] >> a[2] >> k;
  sort(a.begin(),a.end());
  for(int i=0;i<k;i++){
    a[2] = a[2]*2;
  }
  ans = a[0]+a[1]+a[2];
  cout << ans << endl;
      return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 998244353;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	int x = sqrt(n) + 2;
	while (x * x > n) {
		--x;
	}
	cout << x * x << '\n';
 	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
 string s[3];
 cin>>s[0]>>s[1]>>s[2];
 int a[3];
 a[0]=0;a[1]=0;a[2]=0;
 char p;
 p='a';
 while(a[p-'a']<=s[p-'a'].length())
 {
 //	cout<<p<<a[p-'a']<<" "<<s[p-'a'][a[p-'a']]<<endl;
 	char x=s[p-'a'][a[p-'a']];
 	a[p-'a']++;
 	if(a[p-'a']>s[p-'a'].length())
 	break;
 	else
 	p=x;
 }
 if(p=='a')
 cout<<"A"<<endl;
 else if(p=='b')
 cout<<"B"<<endl;
 else
 cout<<"C"<<endl;
 return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <set>
#include <string>


#ifdef MY_LOCAL
namespace sandbox {
#endif

using namespace std;
int main()
{
	int n;
	cin >> n;

	string ans;
	switch (n % 10)
	{
	case 0:
	case 1:
	case 6:
	case 8:
		ans = "pon";
		break;
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		ans = "hon";
		break;
	case 3:
		ans = "bon";
		break;
	}

	cout << ans << endl;
	return 0;
}

#ifdef MY_LOCAL
}
#endif

Measured memory_bytes: 3624
h, w, k = map(int, input().split())
ans = []
num = 0
for _ in range(h):
    s_ = input()
    s_ = [i for i in range(w) if s_[i] == "#"]
    if not s_:
        ans.append([])
        continue
    l = [0]*w
    for i in s_:
        num += 1
        l[i] = num
    n_ = 0
    for wi in range(w):
        if l[wi] == 0:
            l[wi] = n_
        else:
            n_ = l[wi]
    if s_[0] != 0:
        l[:s_[0]] = [l[s_[0]]]*s_[0]
    ans.append(l)
l = []
for hi in range(h):
    if not ans[hi]:
        if not l: continue
        ans[hi] = l
    elif ans[hi]:
        l = ans[hi].copy()
l = []
for hi in reversed(range(h)):
    if not ans[hi]:
        if not l: continue
        ans[hi] = l
    elif ans[hi]:
        l = ans[hi].copy()
for i in range(h): print(*ans[i])

Measured memory_bytes: 7504
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

vector<vector<int>> arrays;
void dfs(vector<int> a, int n, int m, int next = 1) {
    if (a.size() >= n) {
        arrays.push_back(a);
        return;
    }
    if (next > m) return;

    for (int i = 0; i <= n - a.size(); i++) {
        auto b = a;
        for (int j = 0; j < i; j++) {
            b.push_back(next);
        }
        dfs(b, n, m, next + 1);
    }
}

int getScore(vector<int>& ary, vector<int>& a, vector<int>& b, vector<int>& c,
             vector<int>& d) {
    int score = 0;
    for (int i = 0; i < a.size(); i++) {
        if (ary[b[i] - 1] - ary[a[i] - 1] == c[i]) score += d[i];
    }

    return score;
}

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

    int n, m, q;
    cin >> n >> m >> q;
    vector<int> a(q), b(q), c(q), d(q);
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    dfs({}, n, m);

    int max_score = 0;
    for (auto&& i : arrays) {
        const int score = getScore(i, a, b, c, d);
        max_score = max(score, max_score);
    }

    cout << max_score << endl;
}


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

using namespace std;

using int64 = long long;

constexpr int DEBUG = 0;

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

  // vector<int> xs({1, 1, 1, 2, 2, 2, 3, 3, 3});
  // cout << lower_bound(xs.begin(), xs.end(), 2) - xs.begin() << endl;
  // cout << upper_bound(xs.begin(), xs.end(), 2) - xs.begin() << endl;

  int n;
  int64 len;
  int64 t;
  cin >> n >> len >> t;
  vector<int64> p_xs;
  vector<int64> n_xs;
  for (int i = 0; i < n; i++) {
    int64 x;
    int w;
    cin >> x >> w;
    if (w == 1) {
      p_xs.push_back(x);
    } else {
      n_xs.push_back(x);
    }
  }

  int64 m = t + 1;

  auto count_leq_pos = [&](int64 k) -> int64 {
    int64 a = k - t;
    if (a < 0) return 0;
    return a / len * p_xs.size()
        + (upper_bound(p_xs.begin(), p_xs.end(), a % len) - p_xs.begin());
  };

  auto count_leq_neg = [&](int64 k) -> int64 {
    int64 a = k + t;
    return a / len * n_xs.size()
        + (upper_bound(n_xs.begin(), n_xs.end(), a % len) - n_xs.begin());
  };

  auto solve = [&](int i) -> int64 {
    int64 l = 0;
    int64 u = (2 * m + 1) * len;
    while (u - l >= 2) {
      int64 middle = (l + u) / 2;
      int64 count = count_leq_pos(middle) + count_leq_neg(middle);
      if (count >= m * n + i + 1) {
        u = middle;
      } else {
        l = middle;
      }
    }
    if (DEBUG) cout << "u: " << u << endl;
    return u % len;
  };
  
  for (int i = 0; i < n; i++) {
    cout << solve(i) << endl;
  }
}

Measured memory_bytes: 2164
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

vl Mul(vl a,vl b){
	vl c(a.size());
	for(int i=0;i<c.size();i++) c[i]=b[a[i]];
	return c;
}

vl Pow(vl a,ll k){
	vl b=a;
	for(;k>0;k>>=1){
		if(k&1) b=Mul(a,b);
		a=Mul(a,a);
	}
	return b;
}

ll n,m,k;
vl x,a;

int main(){
	cin>>n;
	x=vl(n);
	for(int i=0;i<n;i++) cin>>x[i];
	cin>>m>>k;
	a=vl(m);
	for(int i=0;i<m;i++) cin>>a[i];
	vl y(n-1),p(n-1);
	for(int i=0;i<n-1;i++){
		y[i]=x[i+1]-x[i];
		p[i]=i;
	}
	for(int i=0;i<m;i++) swap(p[a[i]-2],p[a[i]-1]);
	y=Mul(Pow(p,k-1),y);
	p=Pow(p,k-1);
	cout<<x[0]<<endl;
	ll s=x[0];
	for(int i=0;i<n-1;i++){
		cout<<y[i]+s<<endl;
		s+=y[i];
	}
}

Measured memory_bytes: 8128
#include <bits/stdc++.h>
using namespace std;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define watch(x) cout<<"->"<<#x<<": "<<x<<endl;
#define int long long
const int INF = 1000000000;
const int MOD = 1000000007;
const long long INFLL = 1e18;
const double PI = 2*acos(0.0);
signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int res = 0;
	int cnt = 0;
	int mini = INFLL;
	for(int i=0;i<n;i++)
	{
		if(a[i]==0)
		{
			cnt=0;
			mini=INFLL;
			continue;
		}
		if(a[i]<0)
			++cnt;
		if(a[i]>0)
			res+=a[i],mini=min(mini,a[i]);
		else
			res+=-a[i],mini=min(mini,-a[i]);
	}
	if(mini!=INFLL&&(cnt&1))
		res-=mini,res+=-mini;
	return cout<<res<<endl,0;
}

Measured memory_bytes: 1024
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 
 
 int main()
 {
   map<string,set<int> > mm;
   map<string,set<int> >::iterator iter;
   string s;
   int num;
   while(cin>>s>>num)
   {
     mm[s].insert(num);
     if(num==0) break;                  
   }
   for(iter=mm.begin();iter!=mm.end();++iter)
   {
     cout<<iter->first<<endl;
     set<int>::iterator iter2;
     for(iter2=(iter->second).begin();iter2!=(iter->second).end();++iter2)
     {
       if(iter2==((*iter).second).begin()) cout<<*iter2;
       else cout<<" "<<*iter2;                                                                     
     }                   
     cout<<endl;                      
   }
   //while(1);
   return 0;
 }

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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

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

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return result;
}

const int N=2e5+1;
int parent[N];
int sz[N];

void make_set(int n) 
{
	for(int i=1;i<=n;i++)
	{
		parent[i]=i;
		sz[i]=1;
	}
}

int find_set(int v) 
{
    if (v==parent[v])
        return v;
    return parent[v]=find_set(parent[v]);
}

void union_sets(int a, int b) 
{
    a=find_set(a);
    b=find_set(b);
    if (a!=b)
    {
        if (sz[a]<sz[b])
            swap(a,b);
        parent[b]=a;
        sz[a]+=sz[b];
    }
}

int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    IOS

    int n,m;
    cin>>n>>m;

    make_set(n);

    for(int i=0;i<m;i++)
    {
    	int x,y;
    	cin>>x>>y;
    	union_sets(x,y);
    }

    int ans=1;
    for(int i=1;i<=n;i++)
    	ans=max(ans,sz[i]);
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int a,b;
  cin>>a>>b;
  if(a%(b*2+1)==0){
    cout<<a/(b*2+1)<<endl;
  }
  else{
    cout<<a/(b*2+1)+1<<endl;
  }
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: usize = read();
    let b: usize = read();

    let mut i: i64 = 0;
    let mut ans: i64 = 0;
    loop {
        let a1 = (i as f64 * 0.08) as usize;
        let b1 = (i as f64 * 0.1) as usize;
        // println!("{} {}", a1, b1);
        if a1 == a && b1 == b {
            ans = i;
            break;
        }
        i += 1;
        if a1 > a || b1 > b {
            ans = -1;
            break;
        }
    }
    
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	int T;
	cin>>T;
	rep(tt,T){
		int N,D;
		cin>>N>>D;
		if(N%2==0) cout<<N*127-D<<endl;
		else cout<<(N-1)*127+D<<endl;
	}
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	vint v={1,5,10,50,100,500};
	vint w(6);
	rep(i,6) cin>>w[i];
	int a=0;
	rep(i,6){
		a+=v[i]*w[i];
	}
	if(a>=1000){
		cout<<1<<endl;
	}
	else{
		cout<<0<<endl;
	}
}


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

Measured memory_bytes: 3140
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		String s = sc.next();
		sc.close();
		int x = 0;
		int yono = 0;
		for(int i = 0 ; i < n ; i++){
			if(s.charAt(i) == 'I') x++;
			else x--;
			yono = Math.max(yono , x);
		}
		ou.println(yono);
		ou.flush();
    }
}

Measured memory_bytes: 35692
h,w=gets.split.map(&:to_i)
cells=h.times.map{gets.split.map(&:to_i)}

ans=[]
h.times{|y|w.times{|x|
  if cells[y][x].odd?
    cells[y][x]-=1
    if x==w-1
      unless y==h-1
        cells[y+1][x]+=1
        ans << [y,x,y+1,x]
      end
    else
      cells[y][x+1]+=1
      ans << [y,x,y,x+1]
    end
  end
}}

puts ans.size
ans.each{|x|
  puts "%d %d %d %d"%x.map{|x|x+1}
}

Measured memory_bytes: 26492
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

// edit

ll cnt(ll n){
    ll ok = 0;
    ll ng = n + 10;
    
    while(ng - ok > 1){
        ll mid = (ok + ng) / 2;
        
        ll val = mid * (mid + 1) / 2;
        if(val <= n){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    
    return ok;
}

void solve() {
    ll N;
    cin >> N;
    
    map<ll, ll> soi;
    
    for(ll i = 2; i * i <= N; ++i){
        while(N % i == 0){
            N /= i;
            soi[i]++;
        }
    }
    if(N > 1){
        soi[N]++;
    }
    
//    cout << soi << endl;
//    for(auto e : soi) cout << e << endl;
    
    ll ans = 0;
    for(auto e : soi){
        ll tmp = cnt(e.second);
        ans += tmp;
    }
    
    cout << ans << endl;
    
    

    

    

    
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 3192
#include<cstdio>
using namespace std;
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if ((a==b&&b!=c)||(a==c&&c!=b)||(b==c&&c!=a)) puts("Yes");
	else puts("No");
	return 0;
}

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

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

long long int lcm(long long int a,long long int b){
    long long int c;
    c=a/gcd(a,b)*b;
    return c;

}

int main(){
    long long int a,b,c,d;
    cin>>a>>b>>c>>d;
    long long int e,f,g,h,i;
    e=b/c-(a-1)/c;
    f=b/d-(a-1)/d;
    g=lcm(c,d);
    h=b/g-(a-1)/g;
    i=b-a+1-e-f+h;
    cout<<fixed<<setprecision(20)<<i<<endl;
}

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

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

	long N, M;
	cin >> N >> M;

	vector<vector<long>> v(100010);
	priority_queue<long> q;

	long A;
	int B;
	for(long i = 0; i < N; i++) {
		cin >> A >> B;

		v[A].push_back(B);
	}

	long long t = 0;
	pair<int, long> tp;
	for(long D=1; D < M+1; D++) {
		for(auto& vv: v[D])
			q.push(vv);

		if (q.size() > 0) {
			t += q.top();
			q.pop();
		}
	}

	cout << t << endl;

	return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#include <algorithm>
 
int main() {
 
  int long long t=0,i=0,j=0,N;
  int ans=0;
  double sum=0;
  
  cin >> N ;

  vector<int> X(N);

  for ( i = 0; i < N; i++)
  {
    cin >> X[i];
    sum+=X[i];
  }
  
  sum/=N;
  sum=round(sum);
  
  for ( i = 0; i < N; i++)
  {
    ans+=(X[i]-sum)*(X[i]-sum);
  }
  
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	string a;
	int plus=0;
	cin>>a;
	for(int x=0;x<3;x++)
	{
		if(a[x]=='o')
		{
			plus++;
		}
	}
	cout<<700+(plus*100)<<endl;
	return 0;
}

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

int manhattan(int x1, int y1, int x2, int y2){
	return abs(x1 - x2) + abs(y1 - y2);
}

int main(){  
	int N;
	int M;
	cin >> N >> M;
	int sX[N];
	int sY[N];
	int cX[M];
	int cY[M];
	for(int i = 0; i < N; i++){
		cin >> sX[i];
		cin >> sY[i];
	}
	for(int i = 0; i < M; i++){
		cin >> cX[i];
		cin >> cY[i];
	}
	for(int i = 0; i < N; i++){
		int minnum = manhattan(sX[i], sY[i], cX[0], cY[0]);
		int minner = 0;
		for(int j = 0; j < M; j++){
			if(minnum > manhattan(sX[i], sY[i], cX[j], cY[j])){
				minnum = manhattan(sX[i], sY[i], cX[j], cY[j]);
				minner = j;
			}
		}
		cout << minner + 1 << endl;
	}
}

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

int main() {
    int N,K,d,r;
    cin >> N >> K;
    set<int> D;

    rep(i,K) {
        cin >> d;
        D.insert(d);
    }

    rep(i,1e5) {
        if(i < N)
            continue;

        string t = to_string(i);
        bool ok=1;
        rep(j,t.size())
            if(D.count(t.at(j)-'0'))
                ok = 0;
        
        if(ok) {
            r = i;
            break;
        }
    }

    cout << r << endl;
}

Measured memory_bytes: 256
ab1=list(map(int,input().split()))
ab2=list(map(int,input().split()))
ab3=list(map(int,input().split()))
n = [0,0,0,0,0]
n[ab1[0]] = n[ab1[0]] +1
n[ab1[1]] = n[ab1[1]] +1
n[ab2[0]] = n[ab2[0]] +1
n[ab2[1]] = n[ab2[1]] +1
n[ab3[0]] = n[ab3[0]] +1
n[ab3[1]] = n[ab3[1]] +1
if n[1]%2+n[2]%2+n[3]%2+n[4]%2 == 0 or n[1]%2+n[2]%2+n[3]%2+n[4]%2 == 2:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int h, w;
    cin >> h >> w;
    char sky[h][w];
    int forecast[h][w];
    for(int i = 0; i < h; i++) {
        int k = -1;
        for(int j = 0; j < w; j++) {
            cin >> sky[i][j];
            if(sky[i][j] == 'c')
                k = j;
            if(k == -1)
                forecast[i][j] = -1;
            else
                forecast[i][j] = j - k;
        }
    }
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cout << forecast[i][j] ;
            if(j!=w-1)
            cout<<" ";
        }
        cout << endl;
    }
}


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

#define MOD 1000000007
int fact(int n){
	if(n == 1) return 1;
	else return n*fact(n-1);
}

int N;
ll bucket[1001] = {0};
int main(){
	cin >> N;

	for (int i=2;i<N+1;i++){
		int n = i;
		for(int j=2;j<=i;j++){
			while(n % j == 0){
				n /= j;
				bucket[j]++;
			}
		}
	}
	ll ans = 1;
	for(int i=2;i<N+1;i++){
		// cout << bucket[i] << endl;
		if(bucket[i] != 0)ans = ans *(bucket[i] + 1) % MOD;
	}
	cout << ans % MOD << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}

ll a[55],b[55],c[55],d[55];
ll n,m,q,ans=0;
ll nn[11];
void dfs(ll s,ll x){
    if (x==n){
        ll cc=0;
        for (ll i=0;i<q;i++){
            if (nn[b[i]-1]-nn[a[i]-1]==c[i]){
                cc+=d[i];
            }
        }
        ans=max(cc,ans);
    }else{
        for (ll i=s;i<=m;i++){
            nn[x]=i;
            dfs(i,x+1);
        }
    }
    
}

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


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

#define f(x, y, z) for (int x = (y), __ = (z); x < __; ++x)
#define _rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define mst(x, a) memset(x, a, sizeof(x))

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9 + 7;

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

int N;
string s;
const int MAXN = 3010;
int dp[MAXN][MAXN];

void solve() {
  mst(dp, 0);
  dp[1][1] = 1;
  for (int i = 2; i <= N; i++) {
    if (s[i - 2] == '>') {
      for (int j = i; j >= 1; j--) {
        dp[i][j] = (dp[i][j + 1] + dp[i - 1][j]) % MOD;
      }
    } else {
      for (int j = 1; j <= i; j++) {
        dp[i][j] = (dp[i][j - 1] + dp[i - 1][j - 1]) % MOD;
      }
    }
  }

  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    ans = (ans + dp[N][i]) % MOD;
  }
  printf("%lld\n", ans);
}

int main() {
  cin >> N >> s;
  solve();
}


Measured memory_bytes: 35584
N,C = map(int,(input().split()))
x = [0]*(N+1)
v = [0]*N
for i in range(N):
    x[i],v[i] = map(int,(input().split()))

sumv = [0]*(N+1)
for i in range(1,N+1):
    sumv[i] = sumv[i-1] + v[i-1]
csumv = [0]*(N+1)
for i in range(1,N+1):
    csumv[i] = csumv[i-1] + v[N-i]

sclo = [0]*(N+1)
for i in range(1,N+1):
    sclo[i] = sumv[i] - x[i-1]
scclo = [0]*(N+1)
for i in range(1,N+1):
    scclo[i] = csumv[i] - (C-x[N-i])

#print(sumv,sclo)
#print(csumv,scclo)

# まず反時計に行くとき
max_point = [0]*(N+1)
M = -1
for i in range(N+1):
    M = max(M,sclo[i])
    max_point[N-i] = M

point = [0]*(N+1)
for i in range(N+1):
    point[i] = scclo[i]-(C-x[N-i]) + max_point[i]

ans = max(point)

# まず時計に行くとき
max_point2 = [0]*(N+1)
M2 = -1
for i in range(N+1):
    M2 = max(M2,scclo[i])
    max_point2[N-i] = M2

point2 = [0]*(N+1)
x.insert(0,0)
for i in range(N+1):
    point2[i] = sclo[i]-(x[i]) + max_point2[i]

ans2 = max(point2)

ans3 = max(sclo)
ans4 = max(scclo)
print(max(ans,ans2,ans3,ans4))

Measured memory_bytes: 83480
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
ans = 0
sd = {k:v for k,v in Counter(s).items()}
td = {k:v for k,v in Counter(t).items()}
for key in sd.keys():
    try:
        ans = max(ans,sd[key]-td[key])
    except:
        ans = max(ans,sd[key])
print(ans)


Measured memory_bytes: 3316
using System;
using System.Linq;

namespace T1PBC
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] dist = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            if (Math.Min(dist[0], dist[1]) < dist[2] && dist[2] < Math.Max(dist[0], dist[1]))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 13396
//#include <tourist>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> p;
const ll INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//g++ yarudake.cpp -std=c++17 -I .
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    mcf_graph<ll, ll> g(2 * n + 2);
    vector<vector<char>> m(n, vector<char>(n, '.'));
    rep(i, n)
    {
        rep(j, n)
        {
            ll a;
            cin >> a;
            g.add_edge(i, n + j, 1, INF - a);
        }
    }
    rep(i, n)
    {
        g.add_edge(2 * n, i, k, 0);
        g.add_edge(i + n, 2 * n + 1, k, 0);
    }
    g.add_edge(2*n,2*n+1,n*k,INF);
    pair<ll, ll> ans = g.flow(2 * n, 2 * n + 1,n*k);
    cout << n*k * INF - ans.second << "\n";
    vector<mcf_graph<ll, ll>::edge> v = g.edges();
    rep(i, v.size())
    {
        if (v[i].from == 2 * n || v[i].to == 2 * n + 1 || v[i].flow == 0)
            continue;
        m[v[i].from][v[i].to - n] = 'X';
    }
    rep(i, n)
    {
        rep(j, n)
        {
            cout << m[i][j];
        }
        cout << "\n";
    }
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int k, a, b; cin >> k >> a >> b;
    for (int i = a ; i <= b ; i++) {
        if (i % k == 0) {
            cout << "OK\n";
            return 0;
        }
    }
    cout << "NG\n";

}

Measured memory_bytes: 3692
mycode = r'''
# distutils: language=c++
# cython: language_level=3
# cython: boundscheck=False

from libcpp.string cimport string as Str

# 読み込みはpython側で行う
import sys
readline = sys.stdin.buffer.readline # byte読み込み

cdef Str S = readline()[:-1] 
print(S.count(b'1'))

# ここでは練習のためにわざわざC++のstring型で格納している
# pythonのstrではなくbytes型でないとStrに格納できないので注意しよう
# この問題ではpythonのstrを用いても実行速度が変わらないが、S[i]にアクセスする必要がある場合には100倍ほど定数倍が変化する
# 実装量と相談して上手に使い分けよう
'''

import sys
if sys.argv[-1] == 'ONLINE_JUDGE':  # コンパイル時
    import os
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode


Measured memory_bytes: 10136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll h,n;
	cin>>h>>n;
	ll sum=0;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		sum+=x;
		if(sum>=h){
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	// your code goes here
	return 0;
}

Measured memory_bytes: 3644
# coding:utf-8

import sys


input = sys.stdin.readline
INF = float('inf')


def inpl(): return list(map(int, input().split()))


# 整数(x, y)最大公約数を求める
def gcd(x, y):
    if x % y == 0:
        return y
    else:
        x, y = y, x % y
        return gcd(x, y)


# 整数(x, y)最小公倍数を求める
def lcm(x, y):
    return x * y // gcd(x, y)


def solve(N, M, S, T):
    L = lcm(N, M)
    ln, lm = L // N, L // M

    # 文字列Xのk * D + 1(k = 0 ~ L // D)番目の文字は
    # Sのk * D // ln + 1(k = 0 ~ D // lm)文字目と、
    # Tのk * D // lm + 1(k = 0 ~ D // ln)文字目の
    # 両方で使われる
    D = lcm(ln, lm)

    li_S = []
    for i in range(0, N, D // ln):
        li_S.append(S[i])

    li_T = []
    for i in range(0, M, D // lm):
        li_T.append(T[i])

    # print(li_S, li_T)
    # S, Tの両方で使われる文字が一致しているか判定
    if li_S == li_T:
        return L
    else:
        return -1


N, M = inpl()
S = input()
T = input()
print(solve(N, M, S, T))


Measured memory_bytes: 3828
#include <stdio.h>
int main(void){
    /* 変数宣言，ちゃんと初期化しよう */
    int A = 0;
    // int B = 0;
    int ans = 0;
    /* 変数宣言終わり */
    
    /* 入力を受け付ける部分*/
    
    // %dはdecimalの略．つまり，入力を10進数として扱うよという意味．
    scanf("%d", &A);
    
    /* 入力を受け付ける部分終わり*/
    
    ans = A;
    /* 何か処理*/
    // ans = 
    if(ans % 111 == 0){
      /* 真の場合の処理 */
    }else{
        ans = (ans / 111 + 1 ) * 111;
      /* 偽の場合の処理 */
    }
    
   // for(int i = 0; i < 10; i++){ 
      // i = 0,1,2,3,4,5,6,7,8,9のとき処理される
      
    
    
    /* 何か処理終わり*/
    
    
    /* 出力する部分*/
    
    printf("%d", ans); // %dの部分にansの値が表示される
    
    /* 出力する部分*/
    
    
    
    return 0;
}

Measured memory_bytes: 128