akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(void){
    long long h,n; cin>>h>>n;
    long long ans=INF;
    //縦に線
    if(n>=3){
    if(n%3==0) {cout<<0<<endl; return 0;}
    else {
        chmin(ans,h);
    }}
    //横に線
    if(h>=3){
    if(h%3==0) {cout<<0<<endl; return 0;}
    else{
        chmin(ans,n);
    }}
    //cout<<ans<<endl;
    //左に1つ、右に2つ
    for(int i=1;i<n;i++){
    int mn=i;
    long long sq1=mn*h;
    int mh1=h/2;
    int mh2=h-mh1;
    long long sq2=(n-mn)*mh1,sq3=(n-mn)*mh2;
    long long minq=INF,maxq=-1;
    chmin(minq,sq1); chmin(minq,sq2); chmin(minq,sq3);
    chmax(maxq,sq1); chmax(maxq,sq2); chmax(maxq,sq3);
    chmin(ans,maxq-minq);
    }
    //上に2つ,下に1つ
    //cout<<ans<<endl;
    for(int i=1;i<h;i++){
    int mh=i;
    long long sq1=mh*n;
    int mn1=n/2;
    int mn2=n-mn1;
    long long sq2=(h-mh)*mn1,sq3=(h-mh)*mn2;
    long long minq=INF,maxq=-1;
    chmin(minq,sq1); chmin(minq,sq2); chmin(minq,sq3);
    chmax(maxq,sq1); chmax(maxq,sq2); chmax(maxq,sq3);
    chmin(ans,maxq-minq);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
/**
 *    Creator :  bizarre
 *    Date : 1/2020
 *    Problem Number : 103
**/
#include <bits/stdc++.h>
using namespace std;
#define counting ones = __builtin_popcount
vector<int> prime_Numbers;
bool primes[100005];
void prime(int n)
{
    for(int i=2; i<=n; i++)
        primes[i]=true;
    for(int i=2; i<=n; i++)
    {
        if(primes[i]==true)
        {
            prime_Numbers.push_back(i);
            for(int j=i+i; j<=n; j+=i)
                primes[j]=false;
        }
    }
}

int fib(int n)
{
    //  base case
    if(n==1||n==0)
        return n;
// transition
    return fib(n-1)+fib(n-2);
}
int main()
{
//freopen("input.txt", "rt", stdin);
//freopen("output.txt", "wt", stdout);
    int n,k;
    cin>>n>>k;
    long long arr[n+2],sum=0;;
    for (int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    for (int i=n-1;i>=0;i--){
        if (k>0){
            k--;
            continue;
        }
        else if (k<=0){
            sum+=arr[i];
        }
    }
    cout <<sum;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
const bool DEBAG = false;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;

int N;
vector<ll> numbers(20000, 0);
int index = 0;
int reach[20000] = {0};



struct Tree{
    ll num;
    vector<int> connect;
};

void dfs(int n, vector<Tree> &tree){
    if(reach[n] == 0){
        reach[n] = 1;
        tree[n].num = numbers[index];
        index ++ ;
    }
    for(int i = 0; i < tree[n].connect.size(); i++){
        if(reach[ tree[n].connect[i] ] == 0 ){
            dfs( tree[n].connect[i], tree );
        }
    }

}

int main(){


    cin >> N;
    vector<Tree> tree(N);

    if(N == 1){
        int c;
        cin >> c;
        cout << 0 << endl;
        cout << 0 << endl;
        return 0;
    }

    for(int i = 0; i < N - 1; i++){
        int a, b;
        cin >> a >> b;
        a --;
        b --;
        tree[a].connect.push_back( (b) );
        tree[b].connect.push_back( (a) );

    }

    for(int i = 0; i < N; i++){
        cin >> numbers[i];
    }
    sort(rall(numbers) );

    if(DEBAG) cout << "sort" << endl;

    /*
    int connectMax = 0;
    int start = 0;
    for(int i = 0; i < N; i++){
       if( (int)tree[i].connect.size() > connectMax){
           connectMax = (int)tree[i].connect.size();
           start = i;
       }
    }
    */

    if(DEBAG) cout << "dfs" << endl;

    dfs(0, tree);
    cout << accumulate(all(numbers), 0ll) - numbers[0] << endl;
    cout << tree[0].num ;
    for(int i = 1; i < N; i++){
        cout << " " << tree[i].num ;
    }
    cout << endl;
    


}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000
//配列を順に確認していき、最大値を返す関数

signed main() {
  int n,k;cin>>n>>k;
  vector<int>a(n);
  vector<int>b(n);
  int ans=INF;
  rep(i,n){cin>>a[i];}
  //bit全探索でN個からK個選んでいるならば、
  for(int bit=0;bit<(1<<n);bit++){
    int count=0;
    vector<int>c(n);
    for(int i=0;i<n;i++){
      if(bit&(1<<i)){
        count++;
        c[i]=1;
      }
    }
      if(count==k){
          //前から順に確認していって、それまでの最大値saidai（i）＋１にするのに必要なコストを、tempにたす
          int saidai=0;
          int tmpcst=0;
          rep(j,n){
            b[j]=a[j];
            if(c[j]){
              if(saidai>=a[j]){b[j]=saidai+1;}
              tmpcst+=(b[j]-a[j]);
            }
            saidai=max(saidai,b[j]);
          }
          ans=min(tmpcst,ans);
      }
    }


  cout<<ans<<endl;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
dict = {}
for m in range(M):
    a,b = map(int,input().split())
    if a in dict:
        dict[a].append(b)
    else:
        dict[a] = [b]
    if b in dict:
        dict[b].append(a)
    else:
        dict[b] = [a]
ans = 0
l = [0 for i in range(N+1)]
l[1] = 1
def dfs(l,now):
    global ans
    if sum(l) == N:
        ans += 1
        return(0)
    for i in dict[now]:
        if l[i] == 0:
            l[i] += 1
            now = i
            dfs(l,now)
            l[i] -= 1
        else:
            continue
dfs(l,1)
print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
// #define mod  1000000007
#define N 102
// #define MAX 200005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n"
const int inf = (int)1e18 + 10;
signed main(){
 int a , b;
   cin >> a >> b;
   if(a == b){
    cout << 1 << endl;
   }
   else{
    int c = ( a + b);
    if(c%2 == 0)
      cout << (c/2) << endl;
    else
      cout << "IMPOSSIBLE\n";
    
   }

}	

Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC65 B
n = int(input())

a = [int(input()) for _ in range(n)]

b = 1
c = 0
for i in range(n):
    c += 1
    b = a[b-1]
    if b == 2:
        print(c)
        quit()
print(-1)


Measured memory_bytes: 49520
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T>inline auto vec2(class vector<T>::size_type h,class vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
template<class RandomAccessIterator>inline void psortb(RandomAccessIterator first,RandomAccessIterator last){using P=pair<decltype(first->first),decltype(first->second)>;sort(first,last,[](const P&p1,const P&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);});}

int main()
{
    ll x=in();
    cout<<(360%x==0?360/x:360/x*lcm(360,360%x)/(360%x))<<endl;
}



Measured memory_bytes: 3596
#include<iostream>
#include<math.h>
using namespace std;

int main() {
    long long  Q,a[100], b[100],c;
    cin >> Q;
    for (int i = 0;i < Q;i++) {
        cin >> a[i] >> b[i];
    }
    for (int i = 0;i < Q;i++) {
        
        c = sqrt(a[i] * b[i]);
        if (c*c == a[i] * b[i])c--;
        if (a[i] > b[i])swap(a[i], b[i]);
        
        if (a[i] == b[i]|| a[i] + 1 == b[i]) {
            cout << 2 * a[i] - 2 << endl;
        }else if (c*(c + 1) >= a[i] * b[i]) {
            cout << 2 * c - 2<< endl;
        }else if (c*c < a[i] * b[i]) {
            cout << 2 * c - 1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <sstream>

using namespace std;

int main() {
    int K;
    cin >> K;
    for (int i = 0; i < K; ++i) {
        cout << "ACL";
    }
    return 0;
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
	is >> p.first >> p.second;
	return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}
/*
typedef __int128_t Int;
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
  if (s) {
	__uint128_t tmp = value < 0 ? -value : value;
	char buffer[128];
	char *d = std::end(buffer);
	do {
	  --d;
	  *d = "0123456789"[tmp % 10];
	  tmp /= 10;
	} while (tmp != 0);
	if (value < 0) {
	  --d;
	  *d = '-';
	}
	int len = std::end(buffer) - d;
	if (dest.rdbuf()->sputn(d, len) != len) {
	  dest.setstate(std::ios_base::badbit);
	}
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
	if ('0' <= s[i] && s[i] <= '9')
	  ret = 10 * ret + s[i] - '0';
  return ret;
}
*/

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
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 (a > b) {
		a = b;
		return true;
	}
	return false;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int H, W; cin >> H >> W;
	int h, w; cin >> h >> w;
	cout << H*W-(h*W+w*H-h*w) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int h,w;
	while(cin >> h >> w){
		if(h == 0 && w == 0){
			break;
		}
		for(int i = 0; i < h; i++){
			if(i % 2 == 0){
				for(int j = 0; j < w / 2; j++){
					cout << "#.";
				}
				if(w % 2 == 1){
					cout << "#";
				}
			}
			if(i % 2 == 1){
				for(int j = 0; j < w / 2; j++){
					cout << ".#";
				}
				if(w % 2 == 1){
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1152
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int k = sc.nextInt();
        int s = sc.nextInt();
        int count = 0;
        for(int i = 0; i <= k; i++){
        	for(int j = 0; j <= k; j++){
            	if(s - i - j >= 0 && s - i - j <= k){
                   	count++;
                }
            }
        }
        System.out.println(count);
    }
}

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

int main() {
    char c[3][3];
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }

    cout << c[0][0] << c[1][1] << c[2][2] << endl;


    return 0;
}

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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    ll X;
    cin >> X;

    ll key = X/100;
    ll yet = X%100;

    if( key*5 >= yet )
    {
        if( yet%5 == 0 ) cout << 1 << endl;
        else
        {
            key -= yet/5;
            yet %= 5;
            if( key != 0 ) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }
    else cout << 0 << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
const ll mod = 1000000007;

int n, _;
vector<int> a;
vector<int> x;

signed main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> _;
        a.push_back(_);
    }
    int sum_all = accumulate(a.begin(), a.end(), 0LL);

    // 山1に降った雨の量x_1(の半分)を求める
    int sum_par = 0;
    for (int k = 0; k < ((n - 1) / 2); k++) {
        sum_par += a[2 * k + 1];
    }
    x.push_back(sum_all / 2 - sum_par);

    // 残りも求める
    for (int i = 0; i < n - 1; i++) x.push_back(a[i] - x[i]);
    for (auto &it : x) cout << it * 2 << endl;
}

// サイクリック→全部足して2で割る
// 奇数個なので2個置きに足すと1つを除いた和になる
// iについて解く→i+1 + 2k (mod n) (k=0:(n-1)/2)について足す
// 行列（連立方程式）

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n;
    cin >> n;
    map<lli, lli> rec;
    lli ans = 0;
    lli tmp = 1;
    rep(i,n){
        lli a;
        cin >> a;
        if(a==tmp){
            tmp++;
        }
        else{
            ans++;
        }
    }
    if(tmp==1){
        ans = -1;
    }
    out(ans);
}

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

int main() {
  int x, y;
  cin >> x >> y;
  if (y % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  for (int i = 0; i <= x; i++) {
    int sum = (x - i) * 2 + 4 * i;
    if (y == sum) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,j,ans;
  string s;
  cin>>n>>s;
  vector<vector<int>> z(2,vector<int>(n+1));
  for(i=1;i<=n;i++){
    for(j=0;j<2;j++) z.at(j).at(i)+=z.at(j).at(i-1);
    if(s.at(i-1)=='E') z.at(0).at(i)++;
    else if(s.at(i-1)=='W') z.at(1).at(i)++;
  }
  ans=n;
  for(i=1;i<=n;i++) ans=min(ans,z.at(1).at(i-1)+z.at(0).at(n)-z.at(0).at(i));
  cout<<ans<<endl;
}

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

// B - Lucas Number (リュカ数)
// https://atcoder.jp/contests/abc079/tasks/abc079_b
// APG4b 3.01 数値型 の演習問題でもある

// // このアルゴリズムで再帰的にやるとN=43を超えたあたりから反応しなくなる
// // 計算が遅すぎるのかも知れない
// uint64_t calc_lucas(int N) {
//     uint64_t L;

//     if(N == 1) L = 1;
//     if(N == 0) L = 2;

//     if(N > 1) { L = calc_lucas(N - 1) + calc_lucas(N - 2); }

//     return L;
// }

// こちらのforによる加算方式に変えたところ計算できた
uint64_t calc_lucas(int N) {
    uint64_t L[N + 1];  // 配列メモリ確保

    L[0] = 2LL;
    L[1] = 1LL;

    if(N == 0 || N == 1) {
        return L[N];  // Nが0または1の場合は対応したリュカ数を返す
    } else if(N >= 2) {
        for(int i = 2; i <= N; i++) {
            L[i] = L[i - 1] + L[i - 2];
        }
    }
    return L[N];
}

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

    uint64_t L = calc_lucas(N);

    cout << fixed << setprecision(20);  // 今回は小数点以下の表示はないため無関係
    cout << L << endl;
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) FOR(i, 0, n)
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define FILLINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i, a, b) ((a) <= (i) && (i) <= (b))
using namespace std;
template <typename T> inline bool CHMIN(T& a, T b) { if(a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a, T b) { if(a < b) { a = b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(begin(a), end(a)); }
template <typename T> inline void REV(T& a) { reverse(begin(a), end(a)); }
template <typename T> inline void UNI(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <typename S, typename T> inline T LB(S& v, T a) { return *lower_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int LBP(S& v, T a) { return lower_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> inline T UB(S& v, T a) { return *upper_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int UBP(S& v, T a) { return upper_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> ostream& operator << (ostream& os, const pair<S, T>& p) { os << p.first << " " << p.second; return os; }
template <typename S, typename T> istream& operator >> (istream& is, pair<S, T>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator >> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) { for(auto &e : t) fill_v(e, v); }
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const lint MOD = 1000000007;

void _main() {
    int n;
    while (cin >> n, n) {
        vector<int> a(n);
        cin >> a;
        SORT(a);
        int sum = 0;
        FOR (i, 1, n - 1) sum += a[i];
        cout << sum / (n - 2) << endl;
    }
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}


Measured memory_bytes: 3124
from collections import deque

N = int(input())
S = input()

d = deque()
o = deque()
stack = []
for i in range(N):
    if S[i] == '(':
        stack.append(S[i])
        d.append('(')
    else:
        if len(stack) > 0:
            if stack[-1] == '(':
                stack.pop()
                d.append(')')
                
            else:
                stack.append(')')
        else:
            d.appendleft('(')
            d.append(')')

print(''.join(d) + ''.join([')']*len(stack)))


Measured memory_bytes: 38256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

  	Int N, K; cin >> N >> K;
    if (N%K == 0) cout << 0 << endl;
    else cout << 1 << endl;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * 2857.cc: Tournament Chart
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

char s[256];
int vs[26];

/* subroutines */

int winner(char *(&cpt)) {
  if (*cpt != '[') {
    int w = *(cpt++) - 'a';
    //printf("vs[%c]=%d\n", w + 'a', vs[w]);
    return (vs[w] >= 0) ? w : -1;
  }

  cpt++; // '['
  int w0 = winner(cpt);
  if (w0 < 0) return -1;
  cpt++; // '-'
  int w1 = winner(cpt);
  if (w1 < 0) return -1;
  cpt++; // ']'

  if (vs[w0] > 0 && vs[w1] == 0) {
    vs[w0]--;
    return w0;
  }
  if (vs[w0] == 0 && vs[w1] > 0) {
    vs[w1]--;
    return w1;
  }
  return -1;
}

/* main */

int main() {
  scanf("%s", s);

  memset(vs, -1, sizeof(vs));
  char ai[2];
  int vi;
  while (scanf("%s%d", ai, &vi) == 2)
    vs[ai[0] - 'a'] = vi;

  char *cpt = s;
  int w = winner(cpt);
  if (w >= 0 && vs[w] == 0) puts("Yes");
  else puts("No");
  return 0;
}



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

int main()
{
    int n, x, fn = 0;
    cin >> n;
    x = n;
    while (0 < x)
    {
        fn += x % 10;
        x /= 10;
    }
    if (n % fn == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N int
	var s, t string
	fmt.Scan(&N, &s, &t)

	overlap := 0
	for i := N; i >= 0; i-- {
		if s[N-i:] == t[:i] {
			overlap = i
			break
		}
	}
	fmt.Println(2*N - overlap)
}


Measured memory_bytes: 512
import bisect

N=int(input())
L=list(map(int, input().split()))
L=sorted(L)

count=0
for i in range(N-2):
  a=L[i]
  for j in range(i+1, N-1):
    b=L[j]
    r=bisect.bisect_left(L, a+b)
    count+=r-1-j
    
print(count)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define loop for(;;)
#define rep(i, n) for(long i = 0; i < (long)(n); ++i)
typedef std::vector<long> LI;

struct Solver {
   std::vector<long> nexts[2123];
   std::vector<long> overlap[2123];
   long n, len, s;
   LI xs, ys, zs;
   long f(long i, long k) {
      long dx = std::max((long)0, s - std::abs(xs[k] - xs[i]));
      long dy = std::max((long)0, s - std::abs(ys[k] - ys[i]));
      long dz = std::max((long)0, s - std::abs(zs[k] - zs[i]));
      if( dx == 0 or dy == 0 or dz == 0 ) return 0;
      return 2 * (dx * dy + dy * dz + dz * dx);
   }
   void solve() {
      std::cin >> n >> len >> s;
      if( !(n|len|s) ) exit(0);
      xs.resize(n), ys.resize(n), zs.resize(n);
      rep(i, n) std::cin >> xs[i] >> ys[i] >> zs[i];
      rep(i, n) rep(k, n) {
         if( i == k ) continue;
         long over = f(i, k);
         if( over == 0 ) continue;
         nexts[i].push_back(k);
         overlap[i].push_back(over);
      }
      long res = -(1LL << 53);
      rep(i, n) {
         visited.resize(n, false);
         res = std::max(res, dfs(i, len-1, i));
      }
      visited.resize(n);
      printf("%ld\n", res >= 0 ? 6 * s * s * len - res : -1);
   }
   std::vector<bool> visited;
   long dfs(long v, long d, long begin) {
      if( d == 0 ) {
         if( len >= 3 ) {
            rep(i, nexts[v].size()) {
               long next = nexts[v][i];
               long over = overlap[v][i];
               if( next == begin ) {
                  return over;
               }
            }
         }
         return 0;
      }
      long res = -(1LL << 53);
      visited[v] = true;
      rep(i, nexts[v].size()) {
         long next = nexts[v][i];
         long over = overlap[v][i];
         if( visited[next] ) continue;
         res = std::max(res, dfs(next, d-1, begin) + over);
      }
      visited[v] = false;
      return res;
   }
};

int main() {
   loop std::shared_ptr<Solver>(new Solver())->solve();
}

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

namespace abc148
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var vs = Console.ReadLine().Split().ToArray();
            string S = vs[0];
            string T = vs[1];
            string ans="";
            for (int i = 0; i < n; i++)
            {
                ans += S[i];
                ans += T[i];

            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
(* Vicfred
 * https://atcoder.jp/contests/abc145/tasks/abc145_b
 * string manipulation
 * *)
let main =
    Scanf.scanf "%d\n%s" @@ fun n s ->
        print_endline @@
        if Array.fold_left (&&) (n mod 2 = 0) @@
        Array.init (n/2) @@ fun i -> s.[i] = s.[i+n/2]
        then "Yes"
        else "No"



Measured memory_bytes: 3696
N,K=gets.split.map &:to_i
unless K<=(N-1)*(N-2)/2
  p -1
  exit
end
k=N*(N-1)/2
p k-K
1.upto(N) do |u|
  (u+1).upto(N) do |v|
    puts [u,v]*" "
    k-=1
    exit if k==K
  end
end

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

vector<ll> a(60);
vector<ll> p(60);

ll hbg(ll i, ll x){
  if(i==0&&x==1){ return 1; }
  if(x==1){ return 0; }
  if(1<x && x<=1+a[i-1]){ return hbg(i-1,x-1);}
  if(x==2+a[i-1]){ return p[i-1]+1;}
  if(2+a[i-1]<x && x<=2+2*a[i-1]){ return p[i-1]+1 + hbg(i-1,x-2-a[i-1]);}
  if(x==3+2*a[i-1]){ return 1+2*p[i-1]; }
}

int main(){
  ll n,k;
  cin >> n >> k;
  a[0]=1; p[0]=1;
  rep(i,n){
    a[i+1]=2*a[i]+3;
    p[i+1]=2*p[i]+1;
  }
  ll ans=hbg(n,k);
  cout << ans << endl;
  return 0;
}


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

int     main()
{
    char s[11];
    scanf("%s", s);
    int i;
    i = strlen(s);
    if (i % 2 == 1)
    {
        printf("No");
        return 0;
    }
    int j;
    j = 0;
    while (j < i)
    {
        if (!(s[j] == 'h' && s[j + 1] == 'i'))
        {
            printf("No");
            return 0;
        }
        j += 2;
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 128
// AOJ 0205
#include<iostream>
#include<set>

int main()
{
	int a[5];
	while( std::cin >> *a, *a )
	{
		std::set<int> s;
		s.insert( *a );
		for( int i = 1; i != 5; ++i )
		{
			std::cin >> a[i];
			s.insert( a[i] );
		}

		if( s.size() == 1 || s.size() == 3 )
			for( int i = 0; i != 5; ++i )
				std::cout << 3 << std::endl;
		else
		{
			int win = *s.begin() == 1 ? *( ++s.begin() ) == 2 ? 1 : 3 : 2;
			for( int i = 0; i != 5; ++i )
				std::cout << ( a[i] == win ? 1 : 2 ) << std::endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int A, B, X;
    cin >> A >> B >> X;
    if (A <= X && X <= A + B) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0; 
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var NK = ReadLine().Split().Select(int.Parse).ToArray();
        int N = NK[0], K = NK[1];
        var A = ReadLine().Split().Select(int.Parse).ToArray();

        var dic = new Dictionary<int, int>();
        for (int i = 0; i < N; i++)
        {
            if (dic.ContainsKey(A[i]))
            {
                dic[A[i]]++;
            }
            else
            {
                dic[A[i]] = 1;
            }
        }

        var numscount = dic.Values.ToArray();
        Array.Sort(numscount);

        int ans = 0;
        for (int i = 0; i < numscount.Length-K; i++)
        {
            ans += numscount[i];
        }

        WriteLine(ans);
    }
}


Measured memory_bytes: 52428
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
}

Measured memory_bytes: 256
#include <iostream>

int a, b, c;

int main() {
	std::cin >> a >> b >> c;
	int x = static_cast<int>(b / a);
	if (x >= c) {
		std::cout << c << std::endl;
		return 0;
	}
	else {
		std::cout << x << std::endl;
	}
}


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

  //vectorに全入力値を代入する
  rep(i,n) {
    rep(j,d) cin >> x[i][j];
  }

  rep(i,n)rep(j,i) {
    int sq = 0;
    rep(k,d) {
      int s = x[i][k]-x[j][k];
      sq += s*s;
    }
    int s = sqrt(sq) + 0.5;
    if (s*s == sq) ans++;
  }

  cout << ans << endl;
}

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

int main(void){

  int N,D,x,i,j;
  scanf("%d",&N);
  scanf("%d",&D);

  if(N%(2*D+1) != 0)
    x = N / (2*D+1) + 1;

  else
    x = N / (2*D+1);

  printf("%d",x);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int eval(int n){
  vector<int> primes;
  for(int i = 2; i <= n ; i++){
    if(n%i==0){
      primes.push_back(i);
      while(n%i==0)n/=i;
    }
  }
  int res = primes.back();
  REP(i,primes.size()-1){
    res -= primes[i];
  }
  return res;
}
int main(){
  int a,b;
  while(cin>>a>>b,a||b){
    if(eval(a)<eval(b))cout<<"b"<<endl;
    else cout<<"a"<<endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
#include<set>
#include<map>
#define ccl main
using namespace std;
int n,a[100001],ans=0;
int ccl(){
	scanf("%d",&n);
	for(int i=1;i<=n+n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+n+1);
	for(int i=1;i<=n;i++)
		ans+=min(a[i+i-1],a[i+i]);
	cout<<ans;
	return 0;
}


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

vector<int> Input(const int n)
{
    vector<int> W;
    for(int i = 0; i < n; i++){
        int w;
        cin >> w;
        W.push_back(w);
    }
    return W;
}
 
bool IsAllLoaded(int& P, vector<int>& W, int& k)
{
    int TrackIndex = 0;
    int CurrentSum = 0;
    int i = 0;
    for(i = 0; i < W.size(); i++){
        if(W[i] > P){
            return false;
        }
        if(CurrentSum + W[i] > P){
            TrackIndex++;
            if(TrackIndex == k){
                return false;
            }
            CurrentSum = 0;
        }
        CurrentSum += W[i];
    }
    return true;
}
 
int Calc(vector<int>& W, int& k)
{
    int Sum = accumulate(W.begin(), W.end(), 0 );
    int max = *std::max_element(W.begin(), W.end());
    int P = std::max((Sum + k - 1) / k, max);
    while(!IsAllLoaded(P, W, k)){
        P++;
    }
    return P;
}
 
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> W = Input(n);
    int P = Calc(W, k);
    cout << P << endl;
    return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N;
int main()
{
	scanf("%lld", &N);
	for(ll n = 1; n <= 3500; ++n)
		for(ll h = 1; h <= 3500; ++h)
		{
			ll down = n * h * N, up = 4ll * n * h - n * N - h * N;
			if(up > 0 && down % up == 0 && down / up > 0) 
			{
				printf("%lld %lld %lld\n", h, n, down / up);
				return 0;
			}
		}
	return 0;
}

Measured memory_bytes: 256
import sys
from copy import deepcopy
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def cal(a,b,k):
    return min(abs(a-b), k-abs(a-b))

def cal2(l):
    n = len(l)
    ans = 0
    for i in range(n-1):
        ans += l[i+1] - l[i]
    return ans
def main():
    k,n = map(int, input().split())
    As = list(map(int, input().split()))
    le = list()
    for i in range(n):
        if i == n-1:
            le.append(cal(As[i], As[0] , k) )
        else:
            le.append(As[i+1]- As[i])
    print(k-max(le))
if __name__ == '__main__':
    main()

Measured memory_bytes: 28440
$N = 8
$row = Array.new(8, 0)
$col = Array.new(8, 0)
$dpos = Array.new(15, 0)
$dneg = Array.new(15, 0)
$board = Array.new(8){ Array.new(8, ".") }
$flag = true
def printBoard
  $board.each{|b| puts b.join("")}
end

def putQueen(i)
  if i == $N
    printBoard if $flag
    $flag = false
    return
  end
  if $row[i] == 1
    putQueen(i+1)
  else
    $N.times{|j|
      next if $col[j] == 1 || $dpos[i+j] == 1 || $dneg[i-j+$N-1] == 1
      $row[i] = j
      $col[j] = $dpos[i+j] = $dneg[i-j+$N-1] = 1
      $board[i][j] = "Q"
      putQueen(i+1)
      $row[i] = $col[j] = $dpos[i+j] = $dneg[i-j+$N-1] = 0
      $board[i][j] = "."
    }
  end
end

n = gets.to_i
n.times{
  i,j = gets.split.map(&:to_i)
  $board[i][j] = "Q"
  $row[i] = $col[j] = $dpos[i+j] = $dneg[i-j+$N-1] = 1
}
putQueen(0)


Measured memory_bytes: 6888
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=500100;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
ll n,i,l,r,x,y,a[N];
int main(){
	//freopen("1.out","w",stdout);
	n=read();
	for(i=1;i<=n;i++)a[i]=read();
	l=2;r=2;
	for(i=n;i;i--){
		if((l-1)/a[i]==r/a[i])goto fuck;
		l=(l-1)/a[i]*a[i]+a[i];r=r/a[i]*a[i]+a[i]-1;
	}printf("%lld %lld\n",l,r);
	return 0;fuck:puts("-1");
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//A
int main(){
    int k,a,b;
    scanf("%d %d%d",&k,&a,&b);
    for(int i=a;i<=b;i++){
        if(i%k==0){
            printf("OK");
            return 0;
        }
    }
    printf("NG");
}


Measured memory_bytes: 3724
#include <iostream>
#include <string>

using namespace std;

int main()
{
  string str;
  bool cout_flag = false;
  cin >> str;
  for (int i = 0; i < str.length() - 1; i++)
  {
    if(str[i] == str[i + 1])
    {
      cout << i + 1 << " " << i + 2;
      cout_flag = true;
      break;
    }
    else if(i < str.length() - 2 && str[i] == str[i + 2])
    {
      cout << i + 1 << " " << i + 3;
      cout_flag = true;
      break;
    }
  }

  if (!cout_flag)
  {
    cout << "-1 -1";
  }

  return 0;
}


Measured memory_bytes: 512
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in [0]*m]
g=[[] for _ in [0]*n]
[g[a-1].append(b-1) for a,b in ab]
[g[b-1].append(a-1) for a,b in ab]

from itertools import permutations

cnt=0
for i in permutations(range(1,n)):
    i=(0,)+i
    for j in range(n-1):
        if i[j+1] not in g[i[j]]:
            break
    else:
        cnt+=1
print(cnt)

Measured memory_bytes: 3064
# 初期入力
N = int(input())
S =input()
S_list =[i for i in S]

#
S_2 =[]
S_2.append(S[0])
for i in range(N):
    for j in range(len(S)-1):
        if S[j] != S[j+1]:
            S_2.append(S[j+1])
    S="".join(S_2)
    break
print(len(S))

Measured memory_bytes: 4724
import scala.io.StdIn.{readLine,readInt}

object Main extends App {

  def exec(w:String):Unit =  {
    val len = w.length

    def shuffle(i:Int):String = {
      val cnt = (for(j <- 0 until i) yield readInt).sum
      (w drop (cnt%len))+(w take (cnt%len))
    }

    if(w=="-") return else { val n = readInt;println(shuffle(n));val w = readLine ; exec(w) }
  }

  val w = readLine; exec(w)
}

Measured memory_bytes: 43900
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return a % 1000000007;
}


int main(){
  string s; cin >> s;  ll acount,bcount,ccount;
  acount = 0; bcount = 0; ccount = 0;
  
  for(char x : s){
    if(x == 'a') acount++;
    else if(x == 'b') bcount++;
    else ccount++;
  }
  
  if(max(abs(acount - bcount),max(abs(bcount - ccount),abs(ccount - acount))) < 2)
    cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>

using namespace std;

int main(){
  int n,k,i;
  string s;
  cin >> n >> s >> k;
  char c = s[k-1];
  for(i=0;i<n;i++){
    if(s[i]!=c) s[i] = '*';
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    println!(
        "{}",
        if 2 > n {
            1
        } else if 4 > n {
            2
        } else if 8 > n {
            4
        } else if 16 > n {
            8
        } else if 32 > n {
            16
        } else if 64 > n {
            32
        } else {
            64
        }
    )
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 int mod=1e9+7;
const int INF=1001001001;
int64_t dp[55][3000][55];
int main() {
  int N,A;
  cin>>N>>A;
  vector<int>x(N);
  for(int i=0;i<N;i++){
    cin>>x[i];
  }
  for(int i=0;i<=N;i++){
    for(int j=0;j<=3000;j++){
      for(int k=0;k<=N;k++){
        dp[i][j][k]=0;
      }
    }
  }
  dp[0][0][0]=1;
  for(int i=0;i<N;i++){
    for(int j=0;j<=N*A;j++){
      for(int k=0;k<=N;k++){
        if(dp[i][j][k]==0){continue;}
        dp[i+1][j][k]+=dp[i][j][k];
        dp[i+1][j+x[i]][k+1]+=dp[i][j][k];
      }
    }
  }
 
  int64_t cnt=0;
  for(int k=1;k<=N;k++){
    cnt+=dp[N][k*A][k];
  }
  cout<<cnt<<endl;
  return 0;  
}

Measured memory_bytes: 69336
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;// ;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max()/100;
constexpr long long DINF = 1000000000000;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>g;
vector<edge>ed;
vector<Pll>pv;
map<LL, LL>ma;
set<LL>st;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m, k, p, q, w, h, s, t, ans, cnt, sum, a[310000], b[310000]
,d[110000][3];
string str;
bool f;
char c[1100][1100];
int main() {
	cin >> str;
	rep(i, str.size()) {
		a[str[i]]++;
	}
	rep(i, str.size()) {
		if (a[str[i]] != 2) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int main() {
  int n; cin >> n;
  int x[n];
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  int cost = 999999; int sum;
  for (int i = 0; i <= 100; i++) {
    sum = 0;
    for (int j = 0; j < n; j++) {
      sum+=pow(x[j] - i, 2);
    }
    cost = min(sum, cost);
  }
  cout << cost;
}

Measured memory_bytes: 256
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=500000+10;

int n; char s[N];
int prenxt[N],sufnxt[N];

inline void getnext() {
    for (re int i=2,j=prenxt[1]=0;i<=n;++i) {
        while (j&&s[j+1]!=s[i]) j=prenxt[j];
        if (s[j+1]==s[i]) ++j;
        prenxt[i]=j;
    }
    reverse(s+1,s+n+1);
    for (re int i=2,j=sufnxt[n]=0;i<=n;++i) {
        while (j&&s[j+1]!=s[i]) j=sufnxt[j];
        if (s[j+1]==s[i]) ++j;
        sufnxt[i]=j;
    }
}

inline int checkpre(int i) { return !prenxt[i]||i%(i-prenxt[i]); }
inline int checksuf(int i) { return !sufnxt[i]||i%(i-sufnxt[i]); }

int main() {
    scanf("%s",s+1); n=strlen(s+1); getnext();
    if (checkpre(n)) { puts("1\n1"); return 0; }
    if (n-prenxt[n]==1) { printf("%d\n1\n",n); return 0; }
    int ans=0;
    for (re int i=1;i<=n;++i)
        if (checkpre(i)&&checksuf(n-i)) ++ans;
    printf("2\n%d\n",ans);
    return 0;
}


Measured memory_bytes: 4608
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main()
{
    string a, b;
    cin >> a >> b;
    string tmp = a+b;
    int num = stoi(tmp);

    for(int i = 1; i*i < 100200; i++){
        if(num == i*i){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

#define REP(i,n) for(long long i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(long long i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int N, H;
vector<int> a, b;

int main(){
  cin >> N >> H;
  a.resize(N), b.resize(N);
  REP(i, N){
    cin >> a[i] >> b[i];
  }
  int maxa = 0;
  sort(b.begin(), b.end());

  REP(i, N){
    maxa = max(maxa, a[i]);
  }
  int cnt = 0;
  REPR(i, b.size()-1){
    if(b[i] < maxa){
      break;
    }
    H-= b[i];
    cnt++;
    if(H <= 0){
      break;
    }
  }

  if(H > 0){
    cnt += H/maxa;
    H = H% maxa;
    if(H){
      cnt++;
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define endl "\n"

typedef long long ll;
using namespace std;

//ll const N = 32000;

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

    double N, X, T;
    cin >> N >> X >> T;

    cout << (ll)(ceil(N / X) * T);

    return 0;
}


Measured memory_bytes: 3736
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String number = lines[0];
        String[] num = number.split("");
        int hundred = Integer.parseInt(num[0]);
        int ten = Integer.parseInt(num[1]);
        int one = Integer.parseInt(num[2]);

        for (int i = 0; i < num.length; i++){
            if (num[i].contains("7")){
                System.out.println("Yes");
                return;
            }
        }
            System.out.println("No");

    }
  
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
  
}


Measured memory_bytes: 35744
n = int(input())
Tarou = Hanako = 0
for i in range(n):
    a, b = map(str, input().split())
    if a > b: Tarou += 3
    elif a < b: Hanako += 3
    else:
        Tarou += 1
        Hanako += 1
print(Tarou, Hanako)


Measured memory_bytes: 5596