akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
#define EPS (1e-15)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0


struct Segment;
class Point;
typedef Point Vector;
typedef Segment Line;

class Point {
public:
	double x, y;
	Point() {}
	Point(double xx, double yy) {
		x = xx;
		y = yy;
	}
	Point operator + (Point& p) { return Point(x + p.x, y + p.y); }
	Point operator - (Point& p) { return Point(x - p.x, y - p.y); }
	Point operator * (double k) { return Point(x * k, y * k); }
	Point operator / (double k) { return Point(x / k, y / k); }

	double norm() { return x * x + y * y; }
	double abs() { return sqrt(norm()); }
	double dot(Point p) { return x * p.x + y * p.y; }
	double cross(Point& p) { return x * p.y - y * p.x; }
	double distance(Point& p) { return (*this - p).abs(); }

	bool operator == (const Point& p) const {
		return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
	}

	void input() {
		cin >> x >> y;
	}
};

class Segment {
public:
	Point p1, p2;
	void input() {
		p1.input();
		p2.input();
	}
};

double distance(Point p, Line s) {
	Vector a = s.p2 - s.p1;
	Vector b = p - s.p1;
	return a.cross(b) / a.abs();
}

double distanceS(Point p, Segment s) {
	Vector p1p = p - s.p1;
	Vector p2p = p - s.p2;
	Vector p1p2 = s.p2 - s.p1;
	Vector p2p1 = s.p1 - s.p2;
	if (p1p.dot(p1p2) < 0) {
		return p1p.abs();
	}
	else if (p2p.dot(p2p1) < 0) {
		return p2p.abs();
	}
	else {
		return distance(p, s);
	}
}

Point project(Point p, Segment s) {
	Vector hepo = p - s.p1;
	Vector base = s.p2 - s.p1;
	Vector t = base * (hepo.dot(base) / base.norm());
	return s.p1 + t;
}

int ccw(Point p0, Point p1, Point p) {
	Vector p0p1 = p1 - p0;
	Vector p0p;
	p0p = p - p0;
	if (p0p1.cross(p0p) > EPS) {
		return COUNTER_CLOCKWISE;
	}
	else if (p0p1.cross(p0p) < -EPS) {
		return CLOCKWISE;
	}
	else if (p0p1.dot(p0p) < -EPS) {
		return ONLINE_BACK;
	}
	else if (p0p1.norm() < p0p.norm()) {
		return ONLINE_FRONT;
	}
	else {
		return ON_SEGMENT;
	}
}

bool intersection(Segment s1, Segment s2) {
	Point p0 = s1.p1;
	Point p1 = s1.p2;
	Point p2 = s2.p1;
	Point p3 = s2.p2;
	return ccw(p0, p1, p2) * ccw(p0, p1, p3) <= 0 &&
		ccw(p2, p3, p0) * ccw(p2, p3, p1) <= 0;
}
Point getCrossPoint(Segment s1,Segment s2) {
	Point p1 = s1.p1;
	Point p2 = s1.p2;
	Point p3 = s2.p1;
	Point p4 = s2.p2;
	Vector p1_p2 = p2 - p1;
	Vector p1_p3 = p3 - p1;
	Vector p1_p4 = p4 - p1;
	Vector p4_p3 = p3 - p4;
	double d1 = fabs(p1_p2.cross(p1_p4)) / p1_p2.abs();
	double d2 = fabs(p1_p2.cross(p1_p3)) / p1_p2.abs();
	double r = d1 / (d1 + d2);
	Vector p4_p = p4_p3 * r;
	Point p = p4 + p4_p;
	return p;
}

int main() {
	Segment s1, s2;
	Point p;
	int q;
	cin >> q;
	while (q--) {
		s1.input();
		s2.input();
		p = getCrossPoint(s1, s2);
		printf("%.9lf %.9lf\n", p.x, p.y);


	}
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; ++i)
typedef long long ll;
using namespace std;
const int MOD = 1e9 + 7;

struct UnionFind {
    vector<int> par, rnk, cnt;
    UnionFind(int N) : par(N), rnk(N), cnt(N) {
        for (int i = 0; i < N; i++) {
            par[i] = i;
            cnt[i] = 1;
        }
    }

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

    void unite(int x, int y) {
        x = root(x), y = root(y);
        if (x == y)
            return;
        if (rnk[x] < rnk[y])
            swap(x, y);
        if (rnk[x] == rnk[y])
            rnk[x]++;
        par[y] = x;
        cnt[x] += cnt[y];
    }

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

    int rcnt(int x) {
        return cnt[root(x)];
    }
};

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

    UnionFind uf(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        if (b > a)
            swap(a, b);
        uf.unite(a, b);
    }

    int ans = 0;
    rep(i, n) ans = max(ans, uf.rcnt(i));

    cout << ans << endl;

    return 0;
}

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

int main(){
  int w, h, x, y, r;
  cin >> w >> h >> x >> y >> r;

  if ((x - r < 0) || (x + r > w) || (y - r < 0) || (y + r > h)) {
    cout << "No" << endl;
  } else {
    cout <<"Yes" << endl;
  }
}

Measured memory_bytes: 3096
#include<iostream>
#include<algorithm>
using namespace std;
int a[100010],ans;
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	cin>>a[i];
	}
    sort(a+1,a+n+1);
    for(int i=2;i<=n;i++)
    {
    	if(a[i]==a[i-1])
    	{
    		ans++;
		}
	}
	if(ans%2)
	{
		ans++;
	}
	cout<<n-ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define endl            "\n"
#define forn(i,x,n)     for(int i=x; i<n; i++)
#define forit(it, m)    for(decltype(m)::iterator it = m.begin(); it!=m.end(); ++it)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void zeus()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int fast_pow(long long base, long long n, long long M)
{
    if (n == 0)
        return 1;
    if (n == 1)
        return base;
    long long halfn = fast_pow(base, n / 2, M);
    if (n % 2 == 0)
        return ( halfn * halfn ) % M;
    else
        return ( ( ( halfn * halfn ) % M ) * base ) % M;
}

int findMMI_fermat(int n, int M)
{
    return fast_pow(n, M - 2, M);
}

int32_t main() {

    zeus();

    int s,w; cin>>s>>w;

    if(w>=s){
        cout<<"unsafe"<<endl;
    }
    else{
        cout<<"safe"<<endl;
    }
}




Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll a, b; cin >> a >> b;
    if(a+b >= 10) cout << "error" << endl;
    else cout << a+b << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    ll n;
    cin >> n;
    if (n%2==1) cout << 0 << endl;
    else {
        ll p=0,m=10,e=5;
        while(n>=m){
            p+=n/m;
            m*=e;
        }
        cout << p << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#define M 100000
using namespace std;
typedef long long llong;
llong T[M];
int n, k;

int check(llong p) {
	int i = 0;
	for (int j = 0; j < k; j++) {
		llong x = 0;
		for (i; x + T[i] <= p; x += T[i++]) if (i == n)return n;
	}
	return i;
}

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> T[i];
	llong left = 0, right = M * M;
	while (right - left > 1) {
		llong mid = (right + left) / 2;
		if (check(mid) >= n)right = mid;
		else left = mid;
	}
	cout << right << endl;
	return 0;
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, L;
    cin >> N >> L;
    vector<string> S(N);
    string str, result;
    for(int i = 0; i < N; i++){
        cin >> S[i];
    }
    sort(S.begin(), S.end());
    for(int i = 0; i < N; i++){
        result+=S[i];
    }
    cout << result << endl;
}

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

const int INF = 1<<30;

int main(){
    int n, r;
    cin >> n >> r;
    vector<pair<int,int>> v[n];
    for(int i = 0; i < r; i++){
        int s, t, d;
        cin >> s >> t >> d;
        s--, t--;
        v[s].push_back({t, d});
        v[t].push_back({s, d});
    }
    vector<vector<int>> dp(n, vector<int>(n, INF));
    for(int i = 0; i < n; i++){
        priority_queue<pair<int,int>> pq;
        dp[i][i] = 0;
        pq.push({-0, i});
        while(!pq.empty()){
            pair<int,int> p = pq.top();  pq.pop();
            int x = p.second;
            if(dp[i][x] != -p.first)    continue;
            for(pair<int,int> next : v[x]){
                int ni = next.first, ncost = dp[i][x]+next.second;
                if(dp[i][ni] > ncost){
                    dp[i][ni] = ncost;
                    pq.push({-ncost, ni});
                }
            }
        }
    }
    int mad = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            mad = max(mad, dp[i][j]);
        }
    }
    vector<bool> ng(n, 0);
    for(int i = 0; i < n; i++){
        vector<bool> visit(n, 0);
        queue<int> q;
        for(int j = i+1; j < n; j++){
            if(dp[i][j] != mad) continue;
            q.push(j);
            visit[j] = true;    ng[j] = true;
        }
        while(!q.empty()){
            int x = q.front();  q.pop();
            for(pair<int,int> next : v[x]){
                if(visit[next.first]) continue;
                if(dp[i][x]-next.second == dp[i][next.first]){
                    visit[next.first] = true;   ng[next.first] = true;
                    q.push(next.first);
                }
            }
        }
    }
    vector<int> res;
    for(int i = 0; i < n; i++){
        if(!ng[i])  res.push_back(i+1);
    }
    cout << res.size() << endl;
    for(int i : res)    cout << i << endl;
    return 0;
}


Measured memory_bytes: 11840
#include <iostream>
#include <vector>
#include <string>
#include <map>

using namespace std;
typedef long long lint;
const string march = "MARCH";
map<char, int> mp;

lint dfs(int index, int selected, lint cur) {
    if (index == march.size()) {
        if (selected != 3) return 0;
        else return cur;
    }
    lint result = 0;
    result += dfs(index+1, selected+1, cur*mp[march[index]]);
    result += dfs(index+1, selected, cur);
    return result;
}

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        string str;
        cin >> str;
        mp[str[0]]++;
    }
    cout << dfs(0, 0, 1) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class UnionFind {
    int[] roots;
    long[] sameSetCnt;
	
	public UnionFind(int N) {
		this.roots = new int[N];
		this.sameSetCnt = new long[N];
		for(int i = 0; i < N; ++i) {
		    this.roots[i] = i;
		    this.sameSetCnt[i] = 1;
		}
	}
	
	int getRoot(int x) {
		if(this.roots[x] == x) return x;
		else return this.roots[x] = getRoot(this.roots[x]);
	}
	
	boolean isSameSet(int x, int y) {
		return getRoot(x) == getRoot(y);
	}
	
	void unite(int x, int y) {
	    int rx = getRoot(Math.max(x, y));
	    int ry = getRoot(Math.min(x, y));
	    if(rx == ry) return;
	    
	    if(sameSetCnt[rx] < sameSetCnt[ry]) {
	        int tmp = rx;
	        rx = ry;
	        ry = tmp;
	    }
	    
	    sameSetCnt[rx] += sameSetCnt[ry];
	    roots[ry] = rx;
	}
	
	long getSameSetNum(int i) {
	    return sameSetCnt[getRoot(i)];
	}
}

public class Main {
    static Scanner sc = new Scanner(System.in);
    
    public static void main (String[] args) {
        int n = sc.nextInt();
        UnionFind uf = new UnionFind(n);
        int m = sc.nextInt();
        int[] a = new int[m];
        int[] b = new int[m];
        for(int i = 0; i < m; ++i) {
            a[i] = sc.nextInt() - 1;
            b[i] = sc.nextInt() - 1;
        }
        
        long[] ans = new long[m];
        for(int i = m - 1; i >= 0; --i) {
            if(i == m - 1) {
                ans[i] = 1L * n * (n - 1) / 2;
                continue;
            }
            
            if(uf.isSameSet(a[i + 1], b[i + 1])) ans[i] = ans[i + 1];
            else ans[i] = ans[i + 1] - uf.getSameSetNum(a[i + 1]) * uf.getSameSetNum(b[i + 1]);
            
            uf.unite(a[i + 1], b[i + 1]);
        }
        
        for(int i = 0; i < m; ++i) System.out.println(ans[i]);
    }
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define repi(i,a,b) for(int i = (a); i<= (b); i++)
#define repA(i,n) for(int i=n; i>=0; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())

typedef long long ll;
typedef long double ld;
const ll mod = (ll)(1e9+7);//998244353;
const int N = (int)(2e6+5);

void pre() {

}


void solve() {
  int a[3];
  rep(i,3)  cin>>a[i];
  sort(a,a+3);
  set<int> ans;
  rep(i,3)  ans.insert(a[i]);
  if(sz(ans) == 2)  cout<<"Yes";
  else  cout<<"No";
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  #endif
  int t = 1;
  pre();
  //cin>>t;
  rep(i,t)  {
    solve();
    cout<<'\n';
  }
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define met(s) memset(s,0, sizeof(s))
const int mod=100000007;
const int maxn=1000000;
const int inf = 0x3f3f3f3f;
int main()
{
    char str1[10],str2[10];
    scanf("%s",str1);
    scanf("%s",str2);
    int ans=0;
    for(int i=0;i<3;i++)
    {
        if(str1[i]==str2[i]) ans++;
    }
    printf("%d",ans);
    return 0;
}

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for (auto&& ai : a) cin >> ai;
	int i = 0, j = n-1;
	while (i < j)
	{
		b[i++] = a[--n];
		b[j--] = a[--n];
	}
	if (i == j) b[i] = a[0];
	for (auto&& bi : b) cout << bi << " ";
	cout << endl;
	return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
int main(){
      int n,a[100],ans=0;
      cin>>n;
      REP(i,n)cin>>a[i];
      for(int i=0;i<n;i++){
            int minj=i;
            for(int j=i;j<n;j++){
                  if(a[j]<a[minj]){
                        minj=j;
                  }
            }
            if(a[i]!=a[minj]){
                  swap(a[i],a[minj]);
                  ans++;
            }
      }
      REP(i,n){
            cout<<a[i];
            if(i==n-1)cout<<endl;
            else cout<<" ";
      }
      cout<<ans<<endl;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	s += s;		//s.size()分だけオフセットを足したものもsidxに格納するためにsを連結

	vector<vector<ll>> sidx(26, vector <ll> ());
	for (ll ii = 0; ii < s.size(); ++ii){
		ll ch = s[ii] - 'a';
		sidx[ch].push_back(ii);
	}

	ll now = -1;
	ll ans = 0;
	ll n = s.size() / 2;
	for (int ii = 0; ii < t.size(); ++ii){
		ll ch = t[ii] - 'a';
		//tの文字がsに含まれていなかったら諦める
		if (sidx[ch].size() == 0){
			cout << -1 << endl;
			return 0;
		}
		//nowより大きい最小のsidx[ch]を求める
		auto itr = upper_bound(sidx[ch].begin(), sidx[ch].end(), now);
		ll idx = sidx[ch][itr - sidx[ch].begin()];
		//値を更新
		ans += idx - now;
		if (idx < n) {
			now = idx;
		} else {
			now = idx - n;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2804
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int n;  //nは奇数
    cin >> n;
    ll a[n], b[n];
    b[0] = 0;
    rep(i, n) {
        cin >> a[i];

        if(i%2 == 0) {
            b[0] += a[i];
        }
        else {
            b[0] -= a[i];
        }
    }
    
    for(int i = 0; i <= n-2; i++) {
        b[i+1] = 2*a[i] - b[i];
    }

    rep(i, n) {
        cout << b[i] << " ";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 2816
N, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
ans = 0
snack_sum = 0

while ans < N:
    snack_sum += a[ans]
    if snack_sum > x:
        break
    else:
        ans += 1

if ans == N:
    if snack_sum != x:
        print(ans - 1)
        exit()
print(ans)


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

int main() {
    string w;
    cin>>w;
    sort(w.begin(),w.end());
    for (int i = 0; i < w.size(); i+=2) if (w[i]!=w[i+1]) {cout<<"No"<<endl;return 0;}
    cout<<"Yes"<<endl;
}


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

int main(void){
    int N;
    cin >> N;
    vector<int> s(N);
    
    rep(i,N){
        cin >> s[i];
    }
    sort(all(s));
    int ans = 0;
    rep(i,N){
      ans += s[i];
    }
    int j = 0;
    while(ans % 10 == 0 && ans > 0 && j < N){
       while((ans - s[j]) % 10 == 0 && j < N) j++;
       if(j == N) break;
       ans -= s[j];
       j++;
    }
    if(ans % 10 == 0) cout << 0 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
 ll N;
  cin>>N;
  if(N%2==0) {
    cout<<N<<endl;
  }
  else {
    cout<<N*2<<endl;
  }
}

Measured memory_bytes: 3640
<?php
  
$input = explode(" ",fgets(STDIN));
$AliceStart = $input[0];
$AliceEnd = $input[1];
$BobStart = $input[2];
$BobEnd = $input[3];

$result = 0;
for ($i=0; $i<=100; $i++) {
 if (($AliceStart <= $i && $i <= $AliceEnd) && ($BobStart <= $i && $i <= $BobEnd)) {
   //アリスが押して居る　かつ　ボブが押している
   $result++;
 }
}
//押し始めた時間が入ってしまうため -1
if ($result > 0) {
	$result = $result - 1;
}
echo $result;

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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int N, K;
	cin >> N >> K;
	if (K % 2 == 0) {
		int c = K / 2;
		int s = N / c;
		long long int oddsum = s / 2;
		long long int kissum = (s + 1) / 2;
		cout << oddsum * oddsum * oddsum + kissum * kissum * kissum;
	
	}
	else {
		long long int c = N / K;
		cout << c * c * c;
	}
}

Measured memory_bytes: 256
N = int(input())
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))

A = [A1,A2]

ans = 0

for i in range(N):
    count = 0
    for j in range(N):
        if j >= i:
            count += A[1][j]
        else:
            count += A[0][j]
    count += A[0][i]
    ans = max(ans,count)
    
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int tax(int, int);

int main()
{
    int X,Y,S,maximum;
    int j,k;
    while(1)
    {
        maximum=0;
        cin >> X;
        cin >> Y;
        cin >> S;
        if(X==0&&Y==0&&S==0)
            break;
        for(j=1;j<S;j++)
            for(k=j;k<S;k++)
               if(tax(X,j)+tax(X,k)==S)
                  maximum =max(maximum, tax(Y,j)+tax(Y,k));
        cout << maximum << endl;
    }
}

int tax(int x, int p)
{
    int price;
    price=p*(100+x)/100;
    return price;
}


Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  deque<char> d;
  string s;std::cin >> s;
  re(i, s.size()){
    if(s[i]=='1') d.push_back('1');
    else if(s[i]=='0') d.push_back('0');
    else if(!d.empty()) d.pop_back();
  }
  while(!d.empty()){
    std::cout << d.front();
    d.pop_front();
  }
  std::cout  << '\n';
}


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

class program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string[] str = new string[n];
        long[] num = new long[n];

        str = Console.ReadLine().Split(' ');
        for (int i = 0; i < n; i++)
        { 
        num[i] = int.Parse(str[i]);
        }
        long min = num.Min();
        long max = num.Max();
        long sum = num.Sum();


        Console.WriteLine("{0} {1} {2}", min, max, sum);

    }
}

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

int main(){
  int N, K;
  cin >> N >> K;
  int cnt=1;
  for (int i = 0; i < N; i++) {
    if((cnt+K)>2*cnt) cnt=2*cnt;
    else{
      for (int j = i; j < N; j++) {
        cnt=cnt+K;
      }
      cout << cnt << endl;
      return 0;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
from collections import defaultdict

def f(n):
    a,b,c = 0,0,0
    a = n//4
    r = n%4
    b = r//2
    c = r%2
    return (a,b,c)

h,w = map(int,input().split())
a = defaultdict(lambda:0)
for _ in range(h):
    for i in input():
        a[i] += 1
need = []
need.append((h//2)*(w//2))
need.append((h%2)*(w//2)+(w%2)*(h//2))
need.append((h%2)*(w%2))
data = [0]*3
for i in a.values():
    j,k,l = f(i)
    data[0] += j
    data[1] += k
    data[2] += l
if data[0] >= need[0]:
    data[1] += (data[0]-need[0])*2
    if data[1] == need[1] and data[2] == need[2]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

int main()
{
    int A, B, K;
    cin >> A >> B >> K;

    vector<int> ans;
    for (int i = 1; i <= min(A, B); ++i)
    {
        if(A%i ==0 and B%i == 0){
            ans.push_back(i);
        }
    }
    cout << ans[ans.size()-K] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
char str[26];
char b[100][101];
int main(void)
{
	int a;
	scanf("%d", &a);
	scanf("%s", str);
	int n = strlen(str);
	for (int i = 0; i < a; i++)scanf("%s", b[i]);
	int ret = 0;
	for (int i = 0; i < a; i++)
	{
		bool on = false;
		int m = strlen(b[i]);
		for (int j = 0; j < m; j++)
		{
			for (int k = 1; j + k*(n - 1) < m; k++)
			{
				int at = j;
				bool ok = true;
				for (int l = 0; l < n; l++)
				{
					if (str[l] != b[i][at]) ok = false;
					at=at+k;
				}
				if (ok)on = true;
			}
		}
		if (on)ret++;
	}
	printf("%d\n", ret);
	return 0;
}

Measured memory_bytes: 3208
#include <iostream>
#include <string>
#include <vector>


using namespace std;


long long n;
long long ans;

vector<char> cs = {'7', '5', '3'};


void dfs (string s) {
    if (s != "" and stoll(s) > n) return;
    if (
            find(s.begin(), s.end(), '7') != s.end() and
            find(s.begin(), s.end(), '5') != s.end() and
            find(s.begin(), s.end(), '3') != s.end()) {
        ans++;
    }

    for (char c: cs) {
        dfs(s+c);
    }
    return;
}


int main() {
    cin >> n;
    dfs("");
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define deb(x)   cout<<"> "<<#x<<" : "<<x<<endl;
#define deb2(x,y)cout<<"> "<<#x<<"->"<<x<<"  "<<#y<<"->"<<y<<endl;
#define LINE   cout << "--- LINE NO : " << __LINE__ <<"  ---"<< endl;
#define pnr(a)   for(auto x:a){cout<<x<<" ";}cout<<endl;
#define pnr2(a)  for(auto x:a){cout<<x.first<<" "<<x.second<<endl;}

#define  vt            vector
#define  ff            first
#define  ss            second
#define  int           long long
#define  db            long double
#define  pii           pair<int,int>
#define  Maxpq(x)      priority_queue<x>
#define  Minpq(x)      priority_queue<x,vt<x>,greater<x>>

#define  pb            push_back
#define  si(x)         (int)x.size()
#define  all(x)        x.begin(),x.end()
#define  mem(a,x)      memset(a,x,sizeof(a))
#define  FOR(a)        for(auto& x :  a )
#define  forr(i,n)     for(int i=0;i<n;i++)

#define  pi            2*acos(0.0)
#define  inf           (int)1e18
#define  mxn           (int)2e5+5
#define  mod           (int)1e9+7

int mainx()
{
	int d , s , t;
	cin >> d >> s >> t;
	if (s * t >= d)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}


inline void __INCLUDE() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt","w",stdout);
#endif
}

int32_t main() {

	// __INCLUDE();

	ios::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);

	//cout << fixed << setprecision(20);

	int tt = 1;
	//cin>>tt;
	for (int t = 1 ; t <= tt ; t++ )
	{
		// cout<<"Case #"<<t<<": ";
		mainx();
	}
	return 0 ;
}



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

string s;
ll ans=0L;

void dfs(ll su,ll d,ll t){
    if(d==s.size()){
        ans+=su+t;
        return ;
    }
    dfs(su+t,d+1,(s[d]-'0'));
    dfs(su,d+1,t*10+(s[d]-'0'));
}

int main(){

    cin >> s;

    dfs(0L,1L,(s[0]-'0'));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
#define MAXN 2000000
using namespace std;
int number[MAXN];
int main()
{
	int A, B, T;
	cin>>A>>B>>T;
	cout<<T / A * B<<endl;
	return 0; 
	
}


Measured memory_bytes: 256
class Tree
  AND, OR, XOR = (0..2).to_a
  ALL = "1111".to_i(2)

  def initialize(exp, sweet)
    @size = 0
    @root = parse(exp, sweet)
  end

  class Node
    attr_accessor :left, :right, :value
  end

  def parse(exp, sweet)
    node = Node.new
    case exp.chr
      when "("
        @size += 1
        exp.slice!(0) # "("
        node.left = parse(exp, sweet)
        exp.slice!(0) # " "
        node.right = parse(exp, sweet)
        exp.slice!(0) # ")"
      else
        node.value = sweet[exp.slice!(0).to_i - 1]
    end
    node
  end

  def solve(depth = 0, operator = Array.new)
    return (calculate(operator.dup) == ALL ? 1 : 0) if(depth == @size)
    [AND, OR, XOR].map{|op|
      operator[depth] = op
      solve(depth + 1, operator)
    }.inject(&:+)
  end

  def calculate(operator, node = @root)
    return node.value if node.value
    case operator.shift
      when AND
        calculate(operator, node.left) & calculate(operator, node.right)
      when OR
        calculate(operator, node.left) | calculate(operator, node.right)
      when XOR
        calculate(operator, node.left) ^ calculate(operator, node.right)
    end
  end
end

until (exp = gets.chomp) == "END"
  p Tree.new(exp, gets.to_i.times.map{gets.delete(" ").to_i(2)}).solve
end

Measured memory_bytes: 6160
#include<bits/stdc++.h>
using namespace std;
const int maxn = 4000;
#define int long long
int a[maxn], p;
int inv[maxn]{1,1};
int po[maxn]{1};
inline int form(int i){return (i+p) % p;return (i % p + p) % p;}
vector<int> operator * (const vector<int> &a, vector<int> b){
	vector<int> res(a.size() + b.size() - 1ul, 0);
	for(int i = 0;i < a.size();++i){
		for(int j = 0;j < b.size();++j){
			res[i+j] = form(res[i+j] + a[i] * b[j]);
		}
	}
	return res;
}
vector<int> fun{0, 1}, r;
int getv(int i){
	int ci = i, res = r[0];
	for(int j = 1;j < r.size();++j){
		res = form(res + ci * r[j]);
		ci = form(ci * i);
	}
	return res;
}
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> p;
	for(int i = 0;i < p;++i)cin >> a[i];
	// 
	for(int i = 2;i < p;++i)inv[i] = (p-p/i) * inv[p % i] % p;
	// 
	r.resize(p);	
	r[0] = a[0];
	for(int i = 1;i < p;++i){
		for(int j = 1;j < p;++j)po[j] = form(po[j-1] * i);
		int ls = 0, v = 1;
		for(int j = 0;j < p;++j)ls = form(ls + r[j] * po[j]);
		for(int j = 0;j < i;++j)v = form(v * form(i-j));
		int sc = form(inv[v] * form(a[i] - ls));
		for(int i = 0;i < fun.size();++i)r[i] = form(r[i] + sc * fun[i]);
		fun = fun * vector<int>{p-i, 1};
	}
	for(int i = 0;i < p;++i)cout << r[i] << " \n"[i==p-1];
}

Measured memory_bytes: 512
#include <stdio.h>

int main(){
  for(;;){
    int H,W,x,y;
    scanf("%d %d",&H,&W);
    if(H==0 && W==0){
      return 0;
    }
    for(y=0;y<H;y++){
      for(x=0;x<W;x++){
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
}

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

#define int long long
typedef pair<int,int> PII;

bool check[400][400];
char mp[400][400];
signed main(){
	int h,w;
	cin>>h>>w;
	for (int i = 0; i < h; ++i){
		for (int j = 0; j < w; ++j){
			cin>>mp[i][j];
		}
	}

	int ans=0;
	int dx[4]={1,-1,0,0};
	int dy[4]={0,0,1,-1};
	for (int i = 0; i < h; ++i){
		for (int j = 0; j < w; ++j){
			if(mp[i][j]=='.')
				continue;
			else if(check[i][j]==false){
				int black=1,white=0;
				queue<PII> que;
				check[i][j]=true;
				que.push(make_pair(i,j));
				while(que.size()){
					PII p = que.front();
					que.pop();
					for (int k = 0; k < 4; ++k){
						int ny=p.first+dy[k];
						int nx=p.second+dx[k];
						if(mp[ny][nx]!=mp[p.first][p.second]&&check[ny][nx]==false&&nx>=0&&nx<w&&ny>=0&&ny<h){
							que.push(make_pair(ny,nx));
							if(mp[ny][nx]=='.'){
								white++;
							}else if(mp[ny][nx]=='#')
								black++;
							check[ny][nx]=true;
						}
					}
				}

				
				ans+=black*white;
			}

		}

	}
	cout<<ans<<endl;
}



Measured memory_bytes: 512
n = int(input())
a = [int(i) for i in input().split()]

a.sort()

if n == 2:
	print(str(a[1])+" "+str(a[0]))
else:
	maximum = a[-1]
	a.pop()
	half = maximum/2
	a.append(half)
	a.sort()

	position = a.index(half)

	if position+1 >= len(a):
		print(str(maximum)+" "+str(int(a[position-1])))
		exit()
	else:
		large = int(a[position+1])
	if position-1 <= 0:
		print(str(maximum)+" "+str(int(a[position+1])))
		exit()
	else:
		small = int(a[position-1])

	if large - (half) < (half) - small:
		print(str(maximum)+" "+str(large))
	else:
		print(str(maximum)+" "+str(small))

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

vector<string> c;
int n;

int check(int a) {
    inc(i, 0, n){
        inc(j, 0, n){
            if(c[(i+a)%n][j] != c[(j+a)%n][i]){
                return 0;
            }
        }
    }
    return 1;
}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    cin >> n;
    c.resize(n);
    inc(i, 0, n) cin >> c[i];

    int cnt = 0;
    inc(i, 0, n) cnt += check(i);

    cout << cnt*n << endl;

    return 0;
}


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

using namespace std;

using int64 = long long;

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

  int a, b;
  cin >> a >> b;
  if (a > 0 && b > 0) {
    cout << "Positive" << endl;
  } else if (a < 0 && b < 0) {
    if ((b - a) % 2 == 0) {
      cout << "Negative" << endl;
    } else {
      cout << "Positive" << endl;
    }
  } else {
    cout << "Zero" << endl;
  }
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      n:usize,
      mut a:[i64; n]
   }
   a.sort_by(|a, b| b.cmp(a));
   let mut score = 0;
   for i in 1..n {
      score += a[i / 2];
   }
   println!("{}", score);
}


Measured memory_bytes: 6188
#include <iostream>
#include <stdio.h>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
    string s;
    cin >> s;
    int n = 0;
    for (int i = 0; i < s.size() / 2; ++i) {
        if (s[i] != s[s.size() - 1 - i]) n++;
    }
    cout << n << endl;
}

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

const int MAX = 20;

int main(){
    int n, l;
    cin >> n >> l;
    int dist = 0;
    int cnt = 1;
    rep(i,n){
        int d;
        cin >> d;
        if(dist + d <= l){
            cnt++;
            dist += d;
        }else{
            break;
        }
    }
    cout << cnt << endl;
}

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

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}

#define PRINT_VECTOR_MAX 100
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)min(v.size(),PRINT_VECTOR_MAX); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)min(v.size(),PRINT_VECTOR_MAX); i++) {for (ll j = 0; j < (ll)min(v[i].size(),PRINT_VECTOR_MAX); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

void Main();
int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	Main();
	return 0;
}

void Main(){
	string s; cin >> s; cout << s[0];
	cin >> s; cout << s[1];
	cin >> s; cout << s[2];
}


Measured memory_bytes: 3568
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    long H[N];
    cin >> H[0];
    for (int i = 1; i < N; ++i) {
        cin >> H[i];
        if (H[i - 1] <= H[i] - 1) H[i]--;
        else {
            if (H[i - 1] <= H[i]) continue;
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int 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,d;cin>>n>>d;
    ll p[n][d];
    rep(i,0,n-1){
        rep(j,0,d-1)cin>>p[i][j];
    }
    ll ans=0;
    rep(i,0,n-2){
        rep(j,i+1,n-1){
            ll sum=0;
            rep(k,0,d-1){
                sum +=(p[i][k]-p[j][k])*(p[i][k]-p[j][k]);
            }
            ll roo=(ll)sqrt(sum);
            if(roo*roo==sum)ans++;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}





Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll ans=0,size=1,bsize=0;
  bool same=true;
  string s;
  char c;
  ll k;
  cin >> s >> k;
  c=s[0];
  for(int i=0;i<s.size();i++){
    if(c!=s[i]){
      same=false;
      break;
    }
  }
  for(int i=s.size()-1;i>=0;i--){
    if(s[i]!=c){
      break;
    }
    bsize++;
  }
  for(int i=1;i<s.size();i++){
    if(s[i]!=c){
      break;
    }
    size++;
  }
  for(int i=size;i<s.size()-bsize;i++){
    if(s[i-1]==s[i]){
      ans++;
      s[i]='A';
    }
  }
//  cout << size<<" "<<bsize<<ans<<endl;
  ans = ans*k + (size/2) + (bsize/2)+((size+bsize)/2)*(k-1);
  if(same){
    ans = (s.size()*k)/2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
//long long num[100000];
int main(){
  string n;
  cin>>n;
  for(int i=0;i<3;i++){
    if(n[i]!=n[2-i]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8
#


def main(s, k):
    # 2**5000兆>10^18なので、左から数えて最初に出てきた2以外の数がほぼほぼ答え。
    # ただし、最初に1が詰まっていた場合、イレギュラー
    for i in range(k):
        if '1' != s[i:i+1]:
            print(s[i:i+1])
            return
    print(1)
    
    
if __name__ == '__main__':
    try:
        s = input().strip()
        k = int(input().strip())
        main(s, k)
    except EOFError:
        pass


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main () {
    int n,m;
    cin >> n >>m;
    vector <bool> a(m,false);
    vector <int>b(n);
    vector <vector <int>> c(n);
    for(int i =0;i<n;i++) {
        cin >> b[i];
        for(int j = 0;j<b[i]; j++) {
            int tmp;
            cin >> tmp;
            c[i].push_back(tmp);
        }
    }
    for(int i =1; i<m+1;i++) {
        bool flag1 = true;
        for(int j =0;j<n;j++) {
            bool flag2 = false;
            for(int k =0; k < b[j];k++) {
                if (i == c[j][k]){
                    flag2 = true;
                }
            }
            if (flag2 == false) {
                flag1 = false;
                break;
            }
        }
        if (flag1) {
            a[i] = true;
        }
    }
    int count =0;
    for(int i =1;i <= m; i++) {
       if (a[i]) {
           count++;

       }
    }
    cout << count << endl;
}

Measured memory_bytes: 504
using namespace std;
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#define min(a,b) (((a) < (b)) ? (a) : (b))

int main(){
    int n;
    cin >> n;
    vector<int> w(n);
    for (int i=0; i < n;i++){
        cin >> w[i];
    }
    vector<int> x;

    for (int i = 1; i < n-1;i++){
        //cout << "ja";
        int s1=0, s2=0;
        for (int j = 0; j <= i;j++){
            s1 += w[j];
        }
        for (int k = i + 1; k < n;k++){
            s2 += w[k];
        }
        x.push_back(abs(s1 - s2));
        //cout << abs(s1 - s2);
    }
    
    int m = 1000;
    for (auto i:x)
    {
        //cout << i<<" ";
        m = min(m, i);
    }
    cout << m;
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.functional;
import std.string;
import std.array;
import std.conv;

struct A {
    int next = -1;
    int move = int.max;
}

void main() {
    int N, D; readf("%d %d\n", &N, &D);
    int[][] f = new int[][N];
    int[][] g = new int[][](N, D);
    foreach (i; 0 .. N) {
        f[i]  = readln.chomp.split(" ").map!(to!int).array;
    }
    foreach (j; 0 .. D) {
        int mcost = int.max;
        foreach (i; 0 .. N) {
            mcost = min(mcost, f[i][j]);
        }
        foreach (i; 0 .. N) {
            if (f[i][j] == mcost) {
                g[i][j] = 1;
            }
        }
    }

    A[][] dp = new A[][](N, D);
    foreach (i; 0 .. N) {
        dp[i][D - 1] = A(-1, (g[i][D - 1] ? 0 : int.max));
    }

    foreach_reverse (j; 0 .. D - 1) {
        foreach (i; 0 .. N) {
            if (!g[i][j]) continue;
            foreach (k; 0 .. N ) {
                if (!g[k][j + 1]) continue;
                if (i == k) {
                    if (dp[i][j].move > dp[k][j + 1].move) {
                        dp[i][j].move = dp[k][j + 1].move;
                        dp[i][j].next = k;
                    }
                } else {
                    if (dp[i][j].move > dp[k][j + 1].move + 1) {
                        dp[i][j].move = dp[k][j + 1].move + 1;
                        dp[i][j].next = k;
                    }
                }
            }
        }
    }
    //foreach (_; dp) _.map!(a => a.move == int.max ? A(-1, -1) : a).writeln;

    int[] ans;

    A head;
    int headIndex;
    foreach (i; 0 .. N) {
        if (head.move > dp[i][0].move) {
            head = dp[i][0];
            headIndex = i;
        }
    }
    ans ~= headIndex;

    A cur = head;
    int d = 0;
    while (cur.next >= 0) {
        ans ~= cur.next;
        cur = dp[cur.next][++d];
    }

    int M = head.move;
    int P;
    foreach (i; 0 .. ans.length) {
        P += f[ans[i]][i];
    }

    writeln(P, " ", M);
    foreach (c; ans) {
        (c + 1).writeln;
    }
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve()
 {
     int l,h,n;
     cin>>l>>h>>n;
     int cnt=0;
     for(int i=l;i<=h;i++)
     {
            if(i%n==0)
                cnt++;
     }
     cout<<cnt;  
 }
        
main()
{
   //int t;
   //cin>>t;
   int t=1;
   while(t){
    t--;
    solve();
   }
   
   return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
template<typename T>void read(T &x){
	x=0;int f(1);char c(getchar());
	for(;!isdigit(c);c=getchar())if(c=='-')f=-f;
	for(; isdigit(c);c=getchar())x=(x<<3)+(x<<1)+(c-'0');
	x*=f;
}
template<typename T>void write(T x){
	if(x<0)putchar('-'),x=-x;
	if(x/10)write(x/10),x%=10;
	putchar(x+'0');
}
const long long mod=924844033;
long long inv[2004],invjc[2004],jc[2004];
long long c(int m,int n){
	return jc[n]*invjc[m]%mod*invjc[n-m]%mod;
}
long long dp[2004];
int get_size(int s,int k,int n){
	int rt=(n-s)/(k<<1),ans=rt+1<<1;
	if(s-k<1)--ans;
	if(s+rt*(k<<1)+k>n)--ans;
	return ans;
}
int main(){
	int n,k;
	read(n),read(k);
	jc[0]=invjc[0]=1;
	inv[1]=jc[1]=invjc[1]=1;
	for(int i=2;i<=n;++i){
		jc[i]=jc[i-1]*i%mod;
		inv[i]=(mod-mod/i)*inv[mod%i]%mod;
		invjc[i]=invjc[i-1]*inv[i]%mod;
	}
	dp[0]=1;
	for(int s=1,allsize=0,nowsize;s<=min(n,(k<<1));++s){
		allsize+=(n-s)/(k<<1)+1;nowsize=get_size(s,k,n);
		for(int i=allsize;i>=0;--i){
			for(int j=i-1;j>=0&&i-j<=nowsize-(i-j)+1;--j){
				dp[i]=(dp[i]+dp[j]*c(i-j,nowsize-(i-j)+1))%mod;
			}
		}
	}
	long long ans=0;
	for(int i=0,v=1;i<=n;++i,v=-v){
		ans=(ans+v*dp[i]%mod*jc[n-i]%mod+mod)%mod;
	}
	write(ans);
	return 0;
}


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

bool same(vector<int> &a, vector<int> &b) {
    rep(i, a.size()) {
        if (a[i] != b[i]) return false;
    }
    return true;
}

int main() {
    int n;
    scanf("%d", &n);
    vector<int> r(n);
    rep(i, n) {
        r[i] = i + 1;
    }
    vector<int> p(n);
    rep(i, n) {
        scanf("%d", &p[i]);
    }
    vector<int> q(n);
    rep(i, n) {
        scanf("%d", &q[i]);
    }
    int k = 0;
    int a, b;
    do {
        k++;
        if (same(p, r)) a = k;
        if (same(q, r)) b = k;
    } while (next_permutation(r.begin(), r.end()));
    printf("%d\n", abs(a - b));
}

Measured memory_bytes: 3788
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  lint N,D,A;
  cin>>N>>D>>A;
  pair<lint,lint> p[N];
  REP(i,N){
    int X,H;
    cin>>X>>H;
    p[i]=make_pair(X,H);
  }
  sort(p,p+N);
  queue<pair<lint,lint> > q;

  lint ans=0;
  lint B=0;
  REP(i,N){
    while(!q.empty()){
      auto qf=q.front();
      if(qf.first>p[i].first)break;
      q.pop();
      B+=qf.second;
    }
    if(p[i].second+B<=0)continue;
    lint HP=p[i].second+B;
    lint DC=(HP+A-1)/A;
    // cerr<<B<<" "<<HP<<endl;
    ans+=DC;
    B-=A*DC;
    q.push(make_pair(p[i].first+2*D+1,A*DC));
  }
  cout<<ans<<endl;
  return 0;
}


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

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

int main() {

    string S,T;
    cin >> S >> T;

    int ans = 0;
    rep(i,3){
        if(S[i]==T[i]) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import math
n, m = list(map(int, input().split()))
nC2 = math.factorial(n) // (math.factorial(2) * math.factorial(n - 2)) if n >= 2 else 0
mC2 = math.factorial(m) // (math.factorial(2) * math.factorial(m - 2)) if m >= 2 else 0
print(nC2 + mC2)

Measured memory_bytes: 61524
#include<bits/stdc++.h>
using namespace std;
int n;
int A[100000];
int partition(int p,int r){
  int x = A[r];
  int i = p - 1;
  for(int j=p;j<r;j++){
    if(A[j] <= x){
      i = i+1;
      swap(A[i],A[j]);
    }
  }
  swap(A[i+1],A[r]);
  return i+1;
}
int main(){
  cin >>n;
  for(int i = 0;i<n;i++)cin >>A[i];
  int pos = partition(0,n-1);
  for(int i = 0;i<pos;i++)cout << A[i] << " ";
  cout << "["<<A[pos]<<"] ";
  for(int i = pos+1; i < n-1;i++)cout <<A[i] <<" ";
  cout << A[n-1]<<endl;
}



Measured memory_bytes: 3388
from itertools import product
n, m, X = map(int, input().split())
ca = [tuple(map(int, input().split()))for _ in range(n)]
INF = 10**18
ans = INF
for x in product([0, 1], repeat=n):
    cost = 0
    ms = [0]*m
    for i in range(n):
        if x[i] == 0:
            continue
        c, *a = ca[i]
        cost += c
        for j in range(m):
            ms[j] += a[j]

    if all(X <= y for y in ms) and cost < ans:
        ans = cost


print(ans if ans != INF else -1)


Measured memory_bytes: 9152