akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

inline li gojo(li x) {
    li res = 1;
    rep(i, 5)res *= x;
    return res;
}

int main() {
    li x;
    cin >> x;
    repp(i, -2000, 2000) {
        repp(j, -2000, 2000) {
            if (gojo(i) - gojo(j) == x) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }


    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
double PI = acos(-1.0);

struct Point{
    double x;
    double y;
    Point(){}
    Point(double _x , double _y){
        x = _x;
        y = _y;
    }
};

int main(){
    double a,b,h,m;
    cin >> a >>b >> h >> m ;
    double ang = 360.0 / 60.0 * m ;
    double ang2 = 360.0 / 12.0 * h + 30.0 / 60.0 * m;
    ang -= ang2;
    double ans = a*a + b*b - 2.0*a*b * cos(PI/180.0 * abs(ang));
    ans = sqrt(ans);
    cout << fixed << setprecision(20) << ans ;
    return 0;
}

Measured memory_bytes: 4260
#include<bits/stdc++.h>
 using namespace std;
 
 int main(){
 	int k;
 	string s;
 	cin >> k >> s;
 	int n = s.size();
 	for(int i=0; i<n && i<k;++i){
 		cout << s[i];
 	}
 	if(n>k) cout << "...";
 	cout << "\n";
 	return 0;
 }

Measured memory_bytes: 3604
a=[]
h,w,k = map(int, input().split())
for i in range(h):
    a.append(input())

row=[format(x, '06b') for x in range(2**h)]
column=[format(x, '06b') for x in range(2**w)]

shacnt=0
ans=0

for r in row:
    for c in column:
        shacnt=0
        for gyou in range(1,h+1):
            for retu in range(1,w+1):
                if r[-gyou]=="1" and c[-retu]=="1" and a[gyou-1][retu-1]=="#":
                    shacnt+=1
        if shacnt==k:
            ans+=1

print(ans)

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int a, b, c, d, e, f, dp[61][3031];

struct Frac {
	LL p, q;
	Frac() { };
	Frac(LL pp, LL qq) { p = pp; q = qq; }
	bool operator< (const Frac & obj) const { return p * obj.q <  obj.p * q; }
	bool operator> (const Frac & obj) const { return p * obj.q >  obj.p * q; }
	bool operator<=(const Frac & obj) const { return p * obj.q <= obj.p * q; }
	bool operator>=(const Frac & obj) const { return p * obj.q >= obj.p * q; }
	bool operator==(const Frac & obj) const { return p * obj.q == obj.p * q; }
	Frac operator+ (const Frac & obj) const { return Frac(p * obj.q + obj.p * q, q * obj.q); }
	Frac operator- (const Frac & obj) const { return Frac(p * obj.q - obj.p * q, q * obj.q); }
	Frac operator* (const Frac & obj) const { return Frac(p * obj.p, q * obj.q); }
	Frac operator/ (const Frac & obj) const { return Frac(p * obj.q, q * obj.p); }
};

int main() {
	cin >> a >> b >> c >> d >> e >> f;
	
	dp[0][0] = 1;
	incII(i, 0, f / 100 + 1) {
	incII(j, 0, f) {
		if(dp[i][j]) {
			dp[i + a][j] = 1;
			dp[i + b][j] = 1;
			dp[i][j + c] = 1;
			dp[i][j + d] = 1;
		}
	}
	}
	
	Frac ans(0, 1);
	pair<int, int> p = MP(a, 0);
	incII(i, 0, f / 100 + 1) {
	incII(j, 0, f) {
		Frac v(100 * j, 100 * i + j);
		int total = 100 * i + j;
		if(dp[i][j] && total <= f && j <= i * e) {
			if(setmax(ans, v)) { p = MP(i, j); }
		}
	}
	}
	
	cout << 100 * p.FI + p.SE << " " << p.SE << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;




int main(void){
    set<int> s;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        s.insert(a);
    }
    if(s.size()==n){
        cout<<"YES";
    }else{
        cout<<"NO";
    }
    
    return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL n,a[200010],b[200010],c[200010],d[200010],H=43984,h[600010],pw[600010];
vector <LL> s;

LL gethash(LL lb,LL ub)
{
	return (h[ub+1]-h[lb]*pw[ub-lb+1]%MOD+MOD)%MOD;
}

int main()
{
	cin>>n;
	rep(i,n) scanf("%lld",&a[i]);
	rep(i,n) scanf("%lld",&b[i]);
	rep(i,n-1)
	{
		c[i]=a[i]^a[i+1];
		d[i]=b[i]^b[i+1];
	}
	c[n-1]=a[0]^a[n-1];
	d[n-1]=b[0]^b[n-1];
	rep(i,n) s.pb(d[i]);
	rep(i,2) rep(j,n-i) s.pb(c[j]);
	pw[0]=1;
	repn(i,600005) pw[i]=pw[i-1]*H%MOD;
	repn(i,s.size()) h[i]=(h[i-1]*H+s[i-1])%MOD;
	LL pat=gethash(0,n-1);
	for(int i=n;i+n-1<s.size();i++) if(gethash(i,i+n-1)==pat) cout<<i-n<<' '<<(a[i-n]^b[0])<<endl;
	return 0;
}

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

//#define int long long
//struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
//const int MOD = 1e9 + 7;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

int dp[101][10001];

inline bool chmax(int &a, int b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

signed main() {
    int n, wei;
    cin >> n >> wei;
    int v[n], w[n];
    rep(i,n) cin >> v[i] >> w[i];
    
    reps(j,1,wei){
        reps(i,1,n){
            dp[i][j] = dp[i-1][j];
            int backidx = j - w[i-1];
            if(backidx >= 0){
                chmax(dp[i][j], dp[i-1][backidx]+v[i-1]);
            }
        }
    }
    cout << dp[n][wei] << endl;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	set<string> words;

	int N;
	cin >> N;
	char c = ' ';
	string s;
	rep(i, 0, N)
	{
		cin >> s;
		if (words.count(s) > 0 || (c != ' '&&s.front() != c))
		{
			cout << "No" << endl;
			return 0;
		}
		words.insert(s);
		c = s.back();
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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;

int main(){
  vector<int> a(3);
  rep(i, 3) cin >> a[i];
  int k; cin >> k;

  sort(all(a));

  int ans = a[0] + a[1] + a[2] * pow(2, k);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc163/abc163_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll N, M;
  cin >> N >> M;

  vector<int> c(M);
  rep(i, M) { cin >> c[i]; }
  ll ans = 0;
  rep(i, M) { ans += c[i]; }

  cout << (N - ans >= 0 ? N - ans : -1) << endl;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin >> a >> b;
    if(a>b){
        swap(a,b);
    }
    string A=to_string(a);
    string ans;
    for(int i=0;i<b;i++){
        ans+=A;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <math.h>
#include <bits/stdc++.h>//一括で読み込み
typedef long long ll;
using namespace std;

template< unsigned mod >
struct RollingHash
{
  vector< unsigned > hashed, power;

  inline unsigned mul(unsigned a, unsigned b) const
  {
    unsigned long long x = (unsigned long long) a * b;
    unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
    asm("divl %4; \n\t" : "=a" (d), "=d" (m) : "d" (xh), "a" (xl), "r" (mod));
    return m;
  }

  RollingHash(const string &s, unsigned base = 10007)
  {
    int sz = (int) s.size();
    hashed.assign(sz+1, 0);
    power.assign(sz+1, 0);
    power[0] = 1;
    for(int i = 0; i < sz; i++)
    {
      power[i+1] = mul(power[i], base);
      hashed[i+1] = mul(hashed[i], base) + s[i];
      if(hashed[i+1] >= mod) hashed[i+1] -= mod;
    }
  }

  unsigned get(int l, int r) const
  {
    unsigned ret = hashed[r] + mod - mul(hashed[l], power[r-l]);
    if(ret >= mod) ret -= mod;
    return ret;
  }

  unsigned connect(unsigned h1, int h2, int h2len) const
  {
    unsigned ret = mul(h1, power[h2len]) + h2;
    if(ret >= mod) ret -= mod;
    return ret;
  }

  int LCP(const RollingHash< mod > &b, int l1, int r1, int l2, int r2)
  {
    int len = min(r1-l1, r2-l2);
    int low = -1, high = len + 1;
    while(high - low > 1)
    {
      int mid = (low+high) / 2;
      if(get(l1, l1+mid) == b.get(l2, l2+mid)) low = mid;
      else high = mid;
    }
    return (low);
  }
};

using RollHash = RollingHash< 1000000007 >;

int main()
{
  string t,p;

  cin >> t;
  cin >> p;
  RollHash rollHashT(t);//文字列tのローリングハッシュをO(字数)で生成
  RollHash rollHashP(p);
  for(int i = 0; i+p.size() <= t.size(); i++)
  {
    if(rollHashT.get(i, i+p.size()) == rollHashP.get(0, p.size()))//ローリングハッシュの累積和から[x,y)のハッシュ値をO(1)で求める
    {
      cout << i << endl;
    }
  }
}



Measured memory_bytes: 11904
#include<map>
#include<iostream>
using namespace std;
int main() {
    int T;
    cin >> T;
    map<string, int> m;
    while (T--) {
        int t;
        cin >> t;
        if (t==0) {
            string s;
            int a;
            cin >> s >> a;
            m[s] = a;
        } else {
            string x;
            cin >> x;
            cout << m[x] << endl;
        }
    }
    return 0;
}


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

int main() {
    int n;
    cin >> n;

    int i = 1;
    while (1) {
        if (i*i <= n)
            i++;
        else {
            cout << (i-1)*(i-1) << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3620
import itertools
s=input()
ans=0
n=len(s)
l=[i for i in range(1,n)]
for i in range(1,n):
    for x in list(itertools.combinations(l, i))[::-1]:
        ss=list(s)
        for xx in x[::-1]:
            ss.insert(xx,'+')
        ans+=eval(''.join(ss))

ans+=int(''.join(s))
print(ans)

Measured memory_bytes: 3064
//Author - Sanket Mundra
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back 
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fin cin
#define PI 3.14159265358979323846
#define M 1000000007;

int main()
{
    
    fastIO;
    ll t,i,j,k,l,r,n,m,ans,sum,mx,mn,cnt;cin>>n>>k;
    ll a[n+1]={0};
    ll b[n+1]={0};
    b[n]=n;
    for(i=1;i<=n;i++) a[i]=(i+a[i-1]);
    for(i=n-1;i>=0;i--) b[i]=(i+b[i+1]);
    /*for(i=0;i<=n;i++)
    	cout<<a[i]<<" ";
    cout<<endl;

    for(i=0;i<=n;i++)
    	cout<<b[i]<<" ";
    cout<<endl;*/

    ans=0;
	for(i=k-1;i<=n;i++)
	{
		ans+=(b[n-i]+1-a[i]);
		ans%=M;
	}
	cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 6772
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String cf = scan.next();
        if(cf.charAt(2) == cf.charAt(3) && cf.charAt(4) == cf.charAt(5)) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21584
/**
 * @author: Mackenzie
**/
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
const int MAX = 1e6;
int main() {
#ifdef LOCALe
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    ll n;
    cin >> n;
    ll mn = 1e9;
    for (ll a = 1; a <= sqrt(n); a++) {
        ll b = n / a;
        if (a * b != n) continue;
        ll cur = max(1 + floor(log10(1.0 * a)), 1 + floor(log10(1.0 * b)));
        if (cur < mn) {
            mn = cur;
            // cout << a << " " << b << " " << cur << endl;
        }
    }
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 512
unittest
{
	assert( [ "4 4 1", "2 1", "1 3", "3 2", "3 4", "4 1" ].parse.expand.solve == "0 1 0 1" );
	assert( [ "5 10 0", "1 2", "1 3", "1 4", "1 5", "3 2", "2 4", "2 5", "4 3", "5 3", "4 5" ].parse.expand.solve == "0 0 0 0 0" );
	assert( [ "10 9 3", "10 1", "6 7", "8 2", "2 5", "8 4", "7 3", "10 9", "6 4", "5 8", "2 6", "7 5", "3 1" ].parse.expand.solve == "1 3 5 4 3 3 3 3 1 0" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nmk = input.front.split.to!( long[] );
	auto abs = new long[ 2 ][ nmk[ 1 ] ];
	foreach( ref ab; abs )
	{
		input.popFront;
		ab = input.front.split.to!( long[] );
		ab[] -= 1;
	}
	auto cds = new long[ 2 ][ nmk[ 2 ] ];
	foreach( ref cd; cds )
	{
		input.popFront;
		cd = input.front.split.to!( long[] );
		cd[] -= 1;
	}
	return tuple( nmk[ 0 ], abs, cds );
}

auto solve( long n, long[ 2 ][] abs, long[ 2 ][] cds )
{
	// 友達集合を構築
	auto fss = new bool[ long ][ n ];
	auto bss = new bool[ long ][ n ];
	auto uft = UnionFindTree( n );
	foreach( ab; abs )
	{
		fss[ ab[ 0 ] ][ ab[ 1 ] ] = true;
		fss[ ab[ 1 ] ][ ab[ 0 ] ] = true;
		uft.unite( ab[ 0 ], ab[ 1 ] );
	}
	foreach( cd; cds )
	{
		bss[ cd[ 0 ] ][ cd[ 1 ] ] = true;
		bss[ cd[ 1 ] ][ cd[ 0 ] ] = true;
	}
	
	// 友達候補を判定
	auto anss = new long[ n ];
	foreach( i, ref ans; anss )
	{
		// 属する友達集合から自分と直接の友達を引いた人数を取得
		ans = uft.weight( i ) - 1 - fss[ i ].length.signed;
		
		// 同じ友達集合に属するブロック対象を引く
		foreach( b; bss[ i ].keys )
		{
			if( uft.same( i, b ) ) ans--;
		}
	}
	return anss.to!( string[] ).join( " " );
}

struct UnionFindTree
{
	long[] ps;
	long[] rs;
	
	this( long n )
	{
		ps.length = n;
		ps[] = -1;
		rs.length = n;
	}
	
	long root( long i )
	{
		if( ps[ i ] < 0 ) return i;
		else              return ps[ i ] = root( ps[ i ] );
	}
	
	auto same( long i, long j )
	{
		return root( i ) == root( j );
	}
	
	void unite( long i, long j )
	{
		i = root( i );
		j = root( j );
		if( i == j ) return;
		if( rs[ i ] < rs[ j ] )
		{
			ps[ j ] += ps[ i ];
			ps[ i ] = j;
		}
		else
		{
			ps[ i ] += ps[ j ];
			ps[ j ] = i;
			if( rs[ i ] == rs[ j ] ) rs[ i ]++;
		}
	}
	
	auto weight( long i )
	{
		return -ps[ root( i ) ];
	}
}


Measured memory_bytes: 62332
#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<complex>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef pair<int,int> pa;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
char s[66];
LL v[66];
bool u[66];
int n,m,p[66],P,c[66],b[66][66],a[66][66];
void ck(){
	FOR(i,1,n) c[i]=0;
	FOR(i,1,n) ++c[p[i]];
	FOR(i,1,n) if (c[i]!=1){
		int gg=1;
		return;
	}
	FOR(i,1,n){
		int too=p[i];
		FOR(j,1,m) b[too][j]=a[i][j];
	}
	FOR(j,1,m){
		LL t=0;
		FOR(i,1,n) t=t*26+b[i][j];
		LL T=0;
		FORD(i,n,1) T=T*26+b[i][j];
		bool ok=0;
		FOR(k,1,j-1) if (v[k]==T){
			ok=1;
			v[k]=-1;
			break;
		}
		if (!ok) v[j]=t; else v[j]=-1;
	}
	int gg=0,w;
	FOR(i,1,m) if (v[i]!=-1){
		w=i;
		++gg;
	}
	if (gg>1) return;
	if (m%2==0){
		puts("YES");
		exit(0);
	}
	FOR(i,1,n/2) if (b[i][w]!=b[n-i+1][w]) return;
	puts("YES");
	exit(0);
}
void dfs(int x){
	if (x>n){
		ck();
		return;
	}
	if (P<n/2){
		++P;
		p[x]=P;
		dfs(x+1);
		--P;
	}
	FOR(i,n/2+1,n){
		if (u[i]) continue;
		u[i]=1;
		p[x]=i;
		dfs(x+1);
		u[i]=0;
	}
}
int main(){
	cin>>n>>m;
	FOR(i,1,n){
		scanf("%s",s+1);
		FOR(j,1,m) a[i][j]=s[j]-'a';
	}
	dfs(1);
	puts("NO");
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main{
	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		int a=s.nextInt();
		int b=s.nextInt();
		if(a >=1 && b>=1 && a<=100 && b<=100){
			System.out.println(a*b + " "+2*(a+b));
		}
	}
}


Measured memory_bytes: 25984
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String input = scan.nextLine();
        
        switch (input) {
            case "SUN":
                System.out.println(7);
                break;
            case "MON":
                System.out.println(6);
                break;
            case "TUE":
                System.out.println(5);
                break;
            case "WED":
                System.out.println(4);
                break;
            case "THU":
                System.out.println(3);
                break;
            case "FRI":
                System.out.println(2);
                break;
            case "SAT":
                System.out.println(1);
                break;
        }
    }
}

Measured memory_bytes: 22740
use std::io;


fn main() {
    let _ = read_one::<usize>();
    let an = read::<u64>();
    let mut ans = an[0];
    for a in an {
        ans = gcd(ans, a);
    }
    println!("{}", ans);
}

#[allow(unused)]
fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

int main() {
  int N;
  cin >> N;
  vector<tuple<string, int, int>> p(N);
  for (int i=0; i < N; i++) {
    cin >> get<0>(p.at(i)) >> get<1>(p.at(i));
    get<1>(p.at(i)) *= -1;
    get<2>(p.at(i)) = i + 1;
  }
  sort(p.begin(),p.end());
  int ans;
  for (int i=0; i < N; i++) {
    tie(ignore, ignore, ans) = p.at(i);
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
//Copyright@3_soon,From Hangzhou No.2 High School Baimahu
//Problem:
//Result:

#include<bits/stdc++.h>
using namespace std;
#define re register
#define LL long long
#define DB double
#define il inline
#define For(x,a,b) for(re int x=a;x<=b;x++)
#define For2(x,a,b) for(re int x=a;x>=b;x--)
#define LFor(x,a,b) for(re LL x=a;x<=b;x++)
#define LFor2(x,a,b) for(re LL x=a;x>=b;x--)
#define Abs(x) ((x>0)? x:-x)
#define mod (LL)998244353
int gi()
{
    int res=0,fh=1;char ch=getchar();
    while((ch>'9'||ch<'0')&&ch!='-') ch=getchar();
    if(ch=='-') fh=-1,ch=getchar();
    while(ch>='0'&&ch<='9')res=res*10+ch-'0',ch=getchar();
    return fh*res;
}
LL gl()
{
    LL res=0,fh=1;char ch=getchar();
    while((ch>'9'||ch<'0')&&ch!='-') ch=getchar();
    if(ch=='-') fh=-1,ch=getchar();
    while(ch>='0'&&ch<='9')res=res*10+ch-'0',ch=getchar();
    return fh*res;
}
LL n,m;
LL fac[1000005],inv[1000005];
il LL C(LL a,LL b){return fac[a]*inv[b]%mod*inv[a-b]%mod;}
il LL ksm(LL b,LL k){LL sum=1;while(k){if(k&1) sum=sum*b%mod;k>>=1;b=b*b%mod;}return sum%mod;}
LL ans;

int main()
{
	n=gl(),m=gl();
	if(n>m) swap(n,m);
	fac[0]=1;
	For(i,1,m)  fac[i]=1ll*i*fac[i-1]%mod;
    inv[m]=ksm(fac[m],mod-2);
    For2(i,m-1,0) inv[i]=1ll*inv[i+1]*(i+1)%mod;
	ans=0;
	For(i,0,n) ans=(ans+(i&1? -1:1)*(C(n,i)*C(m,i)%mod*fac[i]%mod*ksm(n+1,m-i)%mod*ksm(m+1,n-i)%mod)+mod)%mod;
	printf("%lld\n",(ans)%mod);
	return 0;
}


Measured memory_bytes: 10496
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int numOfItems = sc.nextInt();
        int knapSackWeight = sc.nextInt();
        int[] itemValue = new int[numOfItems+1];
        int[] itemWeight = new int[numOfItems+1];
        for(int i =1;i<=numOfItems;i++){
            itemWeight[i] = sc.nextInt();
            itemValue[i] = sc.nextInt();
        }
//        Arrays.sort(itemWeight);
        System.out.println(findMaxValue(numOfItems,knapSackWeight,itemWeight,itemValue));
    }
    public static long findMaxValue(int items, int knapSackWeight, int[] itemWeight, int[] itemValue){
        long[][] T = new long[items+1][knapSackWeight+1];
        for(int i=1;i<=items;i++){
            for(int j=1;j<=knapSackWeight;j++){
                if(itemWeight[i]>j){
                    T[i][j] = T[i-1][j];
                }
                else{
                    T[i][j] = Math.max(T[i-1][j],itemValue[i]+T[i-1][j- itemWeight[i]]);
                }
            }
        }
        return T[items][knapSackWeight];
    }
}


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

double EPS=1e-5;

int main(){
	int n;
	while(cin>>n,n){
		vector<complex<double>> p(n);
		for(int i=0;i<n;i++){
			double x,y;
			cin>>x>>y;
			p[i]=complex<double>(x,y);
		}

		int res=1;
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(abs(p[i]-p[j])>=2) continue;
				complex<double> mid=(p[i]+p[j])/complex<double>(2.0,0.0);
				auto a=(p[i]-p[j]);
				auto v=a*complex<double>(0,1);
				v=v/abs(v);
				double d=abs(mid-p[i]);
				double t=sqrt(1-d*d);
				complex<double> c[2]={mid+t*v,mid-t*v};
				for(int k=0;k<2;k++){
					int kai=0;
					for(int i=0;i<n;i++){
						if(abs(c[k]-p[i])<1+EPS) kai++;
					}
					res=max(res,kai);
				}
			}
		}
		cout<<res<<endl;
	}

}

Measured memory_bytes: 3216
#include <stdio.h>

#define COMP_TRUE 1
#define COMP_FALSE 0

int main(void)
{
	int a, b, c;
	int ret;
	
	a = 0;
	b = 0;
	c = 0;
	ret = COMP_FALSE;
	
	// 数値入力
	scanf("%d%d%d", &a, &b, &c);
	
	// 数値比較
	if(a < b)
	{
		if(b < c)
		{
			ret = COMP_TRUE;
		}
		else
		{
			ret = COMP_FALSE;
		}
	}
	else
	{
		ret = COMP_FALSE;
	}
	
	// 結果出力
	if(ret == COMP_TRUE)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	
	return 0;
}


Measured memory_bytes: 2044
n = int(input())
A = list(map(int, input().split()))

i = -1

for j in range(n-1):
    if A[j] <= A[n-1]:
        i += 1
        A[i], A[j] = A[j], A[i]

A[i+1], A[n-1] = A[n-1], A[i+1]

A[i+1] = '[' + str(A[i+1]) + ']'

print(*A)


Measured memory_bytes: 16384
Q = int(input())
l = []
r = []
for i in range(Q):
    a, b = map(int, input().split())
    l.append(a)
    r.append(b)
    
x =[True]*((10**5)+1)
x[0] = False
x[1] = False
s = [0, 0, 0]

for i in range(4, (10**5)+1, 2):
    x[i] = False

for j in range(3, (10**5)+1):
    if x[j] == False:
        s.append(s[-1])
        continue
    for k in range(2*j, (10**5)+1, j):
        x[k] = False
    if x[(j+1)//2] == True:
        s.append(s[-1]+1)
    else:
        s.append(s[-1])

for i in range(Q):
    print(s[r[i]]-s[l[i]-1])

Measured memory_bytes: 18612
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
const int MAX=1e8;
struct lll
{
    int kaishi,jieshu,biaoji;
}a[110000],b[110000];;
int cmp(lll a,lll b)
{
    return a.jieshu<b.jieshu;
}
int main()
{
    int n;
    int x;
    cin>>n>>x;
    for(int i=0;i<n;i++)
        scanf("%d%d%d",&a[i].kaishi,&a[i].jieshu,&a[i].biaoji);
    sort(a,a+n,cmp);
    int add=1;
    b[0]=a[0];

    for(int i=1;i<n;i++)
    {

        int temp;
        int min1=MAX;
        for(int j=0;j<add;j++)
        {
            if((a[i].kaishi-b[j].jieshu>=0&&a[i].kaishi-b[j].jieshu<min1&&a[i].biaoji==b[j].biaoji)||(a[i].kaishi-b[j].jieshu>0&&a[i].kaishi-b[j].jieshu<min1&&a[i].biaoji!=b[j].biaoji))
            {
                min1=a[i].kaishi-b[j].jieshu;
                temp=j;
            }

        }
            if(min1!=MAX)
                b[temp]=a[i];
            else
                b[add++]=a[i];
    }
    cout<<add<<endl;
    return 0;
}


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

int main()
{
  int N;
  cin >> N;
  string S;
  cin >> S;
  int cnt = 0;
  // O(N)のアルゴリズム
  for (int i = 0; i < N - 2; i++)
  {
    if (S.substr(i, 3) == "ABC")
    {
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>

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

int main(){

    string s;
    int q;
    cin >> s >> q;
    int count;

    for(int i = 0; i < q; i++){
        int n;
        cin >> n;
        if(n == 1) count++;
        else{
            int f;
            string c;
            cin >> f >> c;
            if(f == 1){
                if(count % 2 == 0){
                    s.insert(0, c);
                }else{
                    s.append(c);
                }
            }else{
                if(count % 2 == 0){
                    s.append(c);
                }else{
                    s.insert(0, c);
                }
            }
        }
    }

    if(count % 2 == 0) cout << s << endl;
    else{
      reverse(s.begin(), s.end());
      cout << s << endl;
    }

}


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

int N, M;
int k[15];
// vector<int> s[15]; // 電球i に繋がっているスイッチ
bool s[15][15]; //[i][j] 電球iがスイッチjに繋がっている
bool p[15]; // 電球iが奇数のときに光る

// 与えられた on/off 状況が条件を満たすかどうか
bool f(vector<int> S) {
  for(int i = 0; i < M; i++) {
    int count = 0;
    for(int sw : S) {
      count += s[i][sw];
    }
    if(count % 2 != p[i]) {
      return false;
    }
  }
  return true;
}

int main() {
  cin >> N >> M;
  for(int i = 0; i < M; i++) {
    cin >> k[i];
    for(int j = 0; j < k[i]; j++) {
      int tmp;
      cin >> tmp;
      s[i][tmp-1] = true;
    }
  }
  for(int i = 0; i < M; i++) {
    cin >> p[i];
  }

  int res = 0;
  for (int bit = 0; bit < (1<<N); bit++) {
      vector<int> S;
      for (int i = 0; i < N; i++) {
          if (bit & (1<<i)) {
              S.push_back(i);
          }
      }
      if( f(S) )
        res++;
  }

  cout << res << endl;
}


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

using namespace std;
#define debug(x) { cerr << #x < " = " << x << endl; }
typedef long long ll;

int getGCD(int a, int b, int c){
	return gcd(a, gcd(b, c));
}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int K;
	cin >> K;
	
	int sum = 0;
	for(int i = 1; i <= K; i++){
		for (int j = 1; j <= K; j++){
			for (int k = 1; k <= K; k++){
				sum += getGCD(i, j, k);
			}
		}
	}
	
	cout << sum << "\n";
	
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  char op;
  cin >> A >> op >> B;
  
  if (op == '+') {
    cout << A + B << endl;
  }
  else if (op == '-') {
    cout << A - B << endl;
  }
  
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof a) ;
#define vi vector<int>
#define vit vector<int> :: iterator 
#define all(ans) ans.begin(),ans.end()
//#define sz(a) int(a.size())
#define ub upper_bound
#define lb lower_bound
#define create(Name,N,M,val) vector<vector<int> > Name(N,vector<int>(M,val))
#define ull unsigned long long
#define ll long long 
#define db double 
#define ldb long double
#define fl float
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lrep(i,a,b) for(ll i=a;i<b;i++)
//#define all(c) c.begin(),c.end()
#define tr(c,it) for(typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define mpr make_pair
#define pb push_back
#define fr first
void solve()
{
int n; ll k; cin>>n>>k;
vi a(n+1) , vis(n+1,0) ;
rep(i,1,n+1){
cin>>a[i]; }
int st=1; ll ct=0;
while(!vis[st])
{
ct++;
vis[st]=1;
st=a[st];
}
/*
rep(i,0,ans.size())
cout<<ans[i]<<' ';
cout<<"\n"<<st<<"\n";
*/
if(k>ct)
{
  k-=ct;
	ct=0;
	vis.assign(n+1,0);
	while(!vis[st])
	{
	vis[st]=1;
	ct++; st=a[st];
	}
	k%=ct;
}
else
{
 st=1;
}
  while(k)
  {
   st=a[st];
    k--;
  }
cout<<st;
return;
}
int main()
{
ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
//	cin>>t;
while(t--)
{
solve();
}
return 0;
}

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

int main() {
  string S, ans = "No";
  cin >> S;
  for (int i = 0; i < S.size() - 1; i++) {
    if (S.at(i) == 'A' && S.at(i + 1) == 'C') {
      ans = "Yes";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main()
{
    int n,d,x,a[100],i,t,ans;
    scanf("%d %d %d",&n,&d,&x);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    ans=x;
    for(i=0;i<n;i++)
    {
        t=0;int k=0;
        while(a[i]*t+1<=d)
        {
            k++;
            t++;
        }
        ans=ans+k;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int main(void){
	int dp[17][17];
	int p,q,t; //p:= horizontal q:=vertical
	int x,y;

	while(cin >> q >> p){
		if((p|q) == 0) break;
	memset(dp,0,sizeof(dp));

	cin >> t;
	for(int i=0;i<t;i++){
		cin >> y >> x;
		dp[x][y] = -1; //-1 represents under construction
	}
	if(dp[1][1] != -1){
		dp[1][1] = 1;
	}else{
		dp[1][1] = 0;
	}

	for(int i=1;i<=p;i++){
		for(int j=1;j<=q;j++){
			if(i==1&&j==1)continue;
			if(dp[i][j] != -1){
				if(dp[i][j-1] == -1 && dp[i-1][j] == -1){
					dp[i][j] = 0;
				}else if(dp[i][j-1] == -1){
					dp[i][j] = dp[i-1][j];
				}else if(dp[i-1][j] == -1){
					dp[i][j] = dp[i][j-1];
				}else{
					dp[i][j] = dp[i-1][j] + dp[i][j-1];
				}
			}
			//cout << dp[i][j];
		}
		//cout << endl;
	}
	cout << dp[p][q] << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
 using namespace std;
 #define ll long long
 int main()
 {
     int n,m;
     cin>>n>>m;
     if(n==1)
     {
         n=14;
     }
     if(m==1)
     {
         m=14;
     }
     if(n==m)
       {
         cout<<"Draw";
     }
     else if(n<m)
     {
         cout<<"Bob";
     }
     else
     {
         cout<<"Alice";
     }
     return 0;
 }

Measured memory_bytes: 256
loop do
  n,k = gets.split.map(&:to_i)
  exit if n == 0 and k == 0
  a = k.times.map{gets.to_i}.sort
  bak = -3
  count = []
  chunk = []
  use_white = false
  a.each do |i|
    if i - bak == 1
      count[-1] += 1
      chunk[-1] += 1
    elsif i - bak == 2 and not use_white
      count[-1] += 2
      chunk << 1
      use_white = true
    elsif i - bak == 2 and use_white
      count << chunk.last + 2
      chunk << 1
      use_white = true
    elsif
      count << 1
      chunk << 1
      use_white = false
    end
    bak = i
  end
  result = (a.first == 0) ? count.max : chunk.max
  puts(result)
end

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

int A[128], N;

int main() {

	while ( cin >> N && N ) {

		A[0] = 1;
	
		for ( int i = 1; i <= N; i++ ) {
	
			A[i] = A[i-1];
		
			if ( i >= 2 ) { A[i] += A[i-2]; }
			if ( i >= 3 ) { A[i] += A[i-3]; }
	
		}
		
		cout << ( ( A[N] + 9 ) / 10 + 364 ) / 365 << endl;

	}

}

Measured memory_bytes: 1160
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main(){
        int N,M;
        cin >> N;
        map<string,int> mp;
        string tmp[200];
        for(int i=0 ; i<N ; i++ ){
                cin >> tmp[i];
                mp[tmp[i]]++;
        }cin >> M;
        for(int i=0 ; i<M ; i++ ){
                cin >> tmp[N];
                mp[tmp[N]]--;
        }
        int Max=0;
        for(int i=0 ; i<N ; i++ ){
                if(mp[tmp[i]]>Max)
                        Max=mp[tmp[i]];
        }
        cout << Max<<endl;
        return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	if (a < 40){
		a = 40;
	}
	if (b < 40) {
		b = 40;
	}	
	if (c < 40) {
		c = 40;
	}
	if (d < 40) {
		d = 40;
	}
	if (e < 40) {
		e = 40;
	}
	cout << (a + b + c + d + e) / 5 << endl;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int N, M, Q;
vector<int> a,b,c,d;


int dfs(vector<int> seq){
    if(seq.size() == N+1){
        int tmp = 0;
        for(int i = 0; i < Q; i++){
            if(seq.at(b.at(i)) - seq.at(a.at(i)) == c.at(i)) tmp += d.at(i);
        }
        return tmp;
    }
    
    int last = seq.at(seq.size() - 1);
    int tmp = 0;
    for(int i = last; i <= M; i++){
        seq.push_back(i);
        tmp = max(tmp, dfs(seq));
        seq.pop_back();
    }
    return tmp;
}


int main(void){
    cin >> N >> M >> Q;
    a.resize(Q); b.resize(Q); c.resize(Q); d.resize(Q);
    for(int i = 0; i < Q; i++){
        cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
    }
    vector<int> X = {1};
    
    printf("%d\n", dfs(X));
    
}


Measured memory_bytes: 3696
l=int(input())
A=[int(input()) for _ in range(l)]

def even(n):
    if n==0:
        return 2
    else:
        return n%2
def odd(n):
    return (n+1)%2

DP=[[0]*5 for _ in range(l)]
DP[0]=[A[0],even(A[0]),odd(A[0]),even(A[0]),A[0]]
for i in range(1,l):
    DP[i][0]=DP[i-1][0]+A[i]
    DP[i][1]=min(DP[i-1][:2])+even(A[i])
    DP[i][2]=min(DP[i-1][:3])+odd(A[i])
    DP[i][3]=min(DP[i-1][:4])+even(A[i])
    DP[i][4]=min(DP[i-1])+A[i]
print(min(DP[l-1]))

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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n, k; cin >> n >> k;
	string result = "";
	result += to_string(n % k);
	while (n /= k) {
		result += to_string(n % k);
	}
	cout << result.size();
	
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  int s=0;
  rep(i,5){
    int a; cin >>a;
    s+=a;
  }
  print(15-s);
}


Measured memory_bytes: 3520
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;
#define INF 100000
 
int main(){
    int n, m;
    cin >> n >> m;
    vector<int> cnt(31, 0);
 
    rep(i, n){
        int k;
        cin >> k;
        rep(j, k){
            int a;
            cin >> a;
            cnt[a - 1]++;
        }
    }
    
    int ans = 0;
    rep(i, m){
        if(cnt[i] == n) ans++;
    }
    cout << ans << endl;
 
}

Measured memory_bytes: 256
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
D = LIST()
M = INT()
T = LIST()

D_c = Counter(D)
T_c = Counter(T)

cnt = 0
for k, v in zip(T_c.keys(), T_c.values()):
    if  D_c[k] < v:
        print('NO')
        break
    else:
        cnt += 1

if cnt == len(T_c):
    print('YES')


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

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
#define exit(a, b) return cout << a, b;

#define PB push_back
#define MP make_pair

#define sd(n) scanf("%lld", &n)
#define pdn(n) printf("%lld\n", n);
#define pds(n) printf("%lld ", n);
#define endl '\n'

#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define all(v) v.begin(), v.end() 

using vi = vector<int>;
using vb = vector<bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

#define int long long

const int upper = 1e5 + 20;
const int M = (int) 1e9 + 7;
const int inf = (int) 1e15;
const double eps =  1e-8;

signed main () {
	start_routine();
	speed();
	#ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);	
	// freopen("output.txt", "w", stdout);
	// freopen("errlog.txt", "w", stderr);
	#endif		

	int n; cin >> n;
	int t, a; cin >> t >> a;

	int T = t;
	int A = a;
	
	int h[n + 1];
	int temp[n + 1];

	int index;
	int mn = inf;
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
		temp[i] = 1000LL * T - 6 * h[i] - 1000LL * A;
		temp[i] = abs(temp[i]);

		if (temp[i] < mn) {
			mn = temp[i];
			index = i;
		} 
	}

	cout << index;
 	end_routine();	
}

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

long long ans(long long c,long long d){
  
  if ( c == -1 ){
    return 0;
  }else{
    return c / d + 1;
  }
  
}


int main() {
  
  long long a,b,x;
  cin >> a >> b >> x;
  
  cout << ans(b,x)-ans(a-1,x) << endl;
  
}

Measured memory_bytes: 256
import Control.Monad
import Data.List
main = do
  ts <- replicateM 5 readLn :: IO [Int]
  let (x:ys) = sortOn ((`mod` 11) . (+ 10) . (`mod` 10)) ts
  print $ x + sum (map (\y -> if mod y 10 == 0 then y else (div y 10 + 1)*10 ) ys)

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

int main() {
    long n;
    cin >> n;
    long l = 0, r = n;
    long x = 0;
    string arr[n];
    cout << 0 << endl;
    cin >> arr[0];
    while (x < 25 && arr[0] != "Vacant") {
        long m = (l+r)/2;
        cout << m << endl;
        string s;
        cin >> s;
        if (s == "Vacant") exit(0);
        arr[m] = s;
        if (((m - l) % 2 == 1 && arr[m] == arr[l]) || ((m - l) % 2 == 0 && arr[m] != arr[l])) {
            r = m;
        } else {
            l = m;
        }
        x++;
    }
    return 0;
}


Measured memory_bytes: 1620
fn solve(xss: Vec<Vec<isize>>) -> usize {
    let n = xss.len();

    let mut ans = 0;
    for i in 0..(n - 1) {
        let xi = &xss[i];
        for j in (i + 1)..n {
            let xj = &xss[j];

            let mut acc = 0;
            for k in 0..(xi.len()) {
                acc += (xi[k] - xj[k]).pow(2);
            }

            if (acc - ((acc as f64).sqrt() as isize).pow(2)) == 0 {
                ans += 1;
            }
        }
    }

    ans
}

#[test]
fn solve_test() {
    assert_eq!(solve(vec![vec![1, 2], vec![5, 5], vec![-2, 8]]), 1);
    assert_eq!(
        solve(vec![
            vec![-3, 7, 8, 2],
            vec![-12, 1, 10, 2],
            vec![-2, 8, 9, 3]
        ]),
        2
    );
    assert_eq!(solve(vec![vec![1], vec![2], vec![3], vec![4], vec![5]]), 10);
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let (n, _d) = parse_line!(usize, usize);

    let xss = (0..n).map(|_| parse_vec!(isize)).collect::<Vec<_>>();

    println!("{}", solve(xss));
}


Measured memory_bytes: 4352
<?php

    // AtCoder Beginner Contest 163
    // C - management

    $n = in_int();
    $employees = in_ints();

    $boss = [];
    foreach ($employees as $e) {
        if ( ! isset($boss[$e])) {
            $boss[$e] = [];
        }
        $boss[$e][] = true;
    }

    for ($i = 1; $i <= $n; $i++) {
        if ( ! isset($boss[$i])) {
            out('0');
        } else {
            out(count($boss[$i]));
        }
    }


    // -----------------------------------------------------
    function in() { return trim(fgets(STDIN)); }
    function in_int() { return (int)in(); }
    function in_vals() { return explode(' ', in()); }
    function in_ints() { return array_map('intval', in_vals()); }
    function out($s) { echo $s . PHP_EOL; }
    function yes() { out('Yes'); }
    function no() { out('No'); }


Measured memory_bytes: 108168
#include <stdio.h>

int main(void)
{
 int H,N,i,total=0;
 
 scanf("%d %d",&H,&N);
 
  int A[100001];
  for(i=0;i<N;i++)
  scanf("%d ",&A[i]);
 
 
 //qsort(A,N,sizeof(long int),compa);
 for(i=0;i<N;i++)
 {
  H -= A[i];
  if(H <=0) 
  {
    printf("Yes\n"); 
    return 0;
  }
 }  
  printf("No\n");
 return 0;
}

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

int main()
{
	int N, K;
	scanf("%d%d", &N, &K);
	std::string S;
	std::cin >> S;
	S.erase(std::unique(S.begin(), S.end()), S.end());
	printf("%d\n", std::min(N - (int)S.size() + 2 * K, N - 1));

	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	int a,b,c,x,y,ans=0;
	cin>>a>>b>>c>>x>>y;
	if(a+b>=c*2){
		int dim=min(x,y);
		x-=dim,y-=dim;
		ans+=c*2*dim;
		if(a*x+b*y>c*2*max(x,y)){
			ans+=c*2*max(x,y);
		}
		else{
			ans+=a*x+b*y;
		}
	}
	else{
		ans+=a*x+b*y;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256