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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	is >> p.first >> p.second;
	return (is);
}


ll power(ll n, ll k) {
	ll d = 1;
	for (ll i = 0; i < k; i++) d *= n;
	return (d);
}

ll choose(ll n, ll k) {
	ll f = 1;
	ll ans = 1;
	if (n < k) return (0);

	for (ll i = 1; i <= k; i++) {
		ans *= (n - i + 1);
		f *= i;
	}
	return (ans / f);
}
ll calc(string S, int K) {
	ll ret = 0;
	
	if (S.size() == 0 || K <= 0) return (0);
	if (S[0] == '0') return (calc(S.substr(1, S.size() - 1), K));

	ll val = S[0] - '0';
	
	for (int i = 0; i < val; i++) {
		ll k = K;
		if (i > 0) k--;
		ret += power(9, k) * choose(S.size() - 1, k);
	}

	string T = S.substr(1, S.size() - 1);
	if (K - 1 == 0 && val > 0) ret += 1;

	else ret += calc(T, K - 1);
	return (ret);
}

int main() {
	string S;	
	int K;
	cin >> S >> K;
	cout << calc(S, K) << endl;
	return (0);
}


Measured memory_bytes: 256
#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;
typedef long long ll;




int main()
{
    
    int N;
    cin >> N;
    vector<int> p(N);
    rep(i,N) cin >> p[i];
    sort(all(p));
    int ans = 0;
    rep(i,N-1) ans += p[i];
    cout << ans + p[N-1]/2 << endl;
    
    return 0;
}



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

using namespace std;

#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 1000010;
const int INF = 2147483600;

int N; char s[MAXN+1]; int g[MAXN+1];

inline int fn(int x){
	int mn=0,now=0;
	for(int i=1;i<=N;i++){
		if(s[i]=='1') ++now;
		else if(s[i]=='0') --now;
		else{
			if(now+1+max(g[i+1],0)<=x) ++now;
			else --now;
		}
		mn=min(mn,now);
	} return x-mn;
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%s",s+1); N=strlen(s+1); g[N+1]=0;
	for(int i=N;i>=1;i--){
		int val=(s[i]!='1'?-1:1);
		g[i]=max(val,g[i+1]+val);
	} int mx=0,now=0;
	for(int i=1;i<=N;i++){ if(s[i]!='1') --now; else ++now; mx=max(mx,now);  }
	printf("%d\n",min(fn(mx),fn(mx+1)));
	return 0;
}




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

int main() {
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	int count = 0;
	int now = a[0];
	int res = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == now) {
			res++;
			if (i == n - 1) {
				if (res % 2) count++;
			}
		} else {
			if (res % 2) count++;
			res = 1;
			now = a[i];
			if (i == n - 1) count++;
		}
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 640
def onigokko():
    A,V = map(int, input().split())
    B,W = map(int, input().split())
    T = int(input())
    
    if B < A:
        swap = A
        A = B
        B = swap
    
    tikaduku = V - W
    
    # 遠ざかったらアウト
    if tikaduku < 1:
        return 'NO'
    
    kyori = B - A
    
    if kyori <= tikaduku * T:
        return 'YES'
    
    return 'NO'

print(onigokko())

Measured memory_bytes: 9224
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 998244353;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, S;
  cin >> N >> S;
  vl A(N);
  REP(i, N) cin >> A[i];
  vvl DP = VVL(N + 1, S + 1, 0);
  DP[0][0] = 1;

  REP(i, N) {
    // DP[i + 1] = DP[i];
    REP(s, S + 1) {
      if (s >= A[i])
        DP[i + 1][s] += DP[i][s - A[i]];
      DP[i + 1][s] %= MOD;
      DP[i + 1][s] += DP[i][s] * 2;
      DP[i + 1][s] %= MOD;
    }
  }

  cout << DP[N][S] << endl;

  return 0;
}


Measured memory_bytes: 73688
char S[99999];
i,j;c[99],t;
main(N)
{
	for(scanf("%d%s",&N,S);i<N;c[S[i++]]++)for(j=N;j--;)t-=(S[i]^S[i+j]^S[i+j+j])==87;
	printf("%ld",1L*c[66]*c[71]*c[82]+t);
}

Measured memory_bytes: 1728
#include <iostream>                                                                                                                                                                                                
                                                                                                                                                                                                                   
using namespace std;                                                                                                                                                                                               
                                                                                                                                                                                                                   
int main(){
  int x, a;

  cin >> x >> a;

  int ans = (x < a) ? 0 : 10;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    string a, b, u; int c, d; cin >> a >> b >> c >> d >> u;
    if(a == u) cout << c-1 << ' ' << d << endl;
    else cout << c << ' ' << d-1 << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  ll a[n],b[n];
  rep(i,n) R a[i];
  rep(i,n) R b[i];
  ll ans=0;
  rrep(l,55) {
    if(!l) break;
    ll d[55][55];
    mem(d);
    rep(i,55)d[i][i]=1;
    rep(i,55) {
      REP(j,1,l)d[i][i%j]=1;
      REP(j,l,55) {
        if(ans&(1LL<<j)) d[i][i%j]=1;
      }
    }
    rep(k,55)rep(i,55)rep(j,55) d[i][j]|=d[i][k]&d[k][j];
    bool f=1;
    rep(i,n) f&=d[a[i]][b[i]];
    if(!f) ans|=1LL<<l;
  }
  if(ans>=1LL<<52) ans=-1;
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int grid[5][5];
int a[3], b[3];

bool check() {
  b[0] = grid[0][0] - a[0];
  b[1] = grid[0][1] - a[0];
  b[2] = grid[0][2] - a[0];

  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if (a[i] + b[j] != grid[i][j]) return false;
    }
  }

  return true;
}

int main() {
  // 入力
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> grid[i][j];
    }
  }

  bool flag = false;
  for (int i = 0; i <= 100; i++) {
    for (int j = 0; j <= 100; j++) {
      for (int k = 0; k <= 100; k++) {
        a[0] = i, a[1] = j, a[2] = k;
        if (check()) flag = true;
      }
    }
  }

  // 解答
  cout << (flag ? "Yes" : "No") << endl;

  return 0;
}


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

#define mp make_pair
#define pb push_back
#define int long long

using namespace std;
const int inf = 1e18;
const double EPS = 0.00000001;
const int mod = 1000000007;

signed main(){
    int a,b;
    cin >> a >> b;
    int cnt = 0;
    for(int i =2;i<=1000000;i++){
        if(a%i == 0 && b%i == 0){
            cnt++;
        }
        while(a%i == 0) a/= i;
        while(b%i == 0) b/= i;
    }
    if(a == b && a > 1) cnt++;
    cout << cnt+1;
}


Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair

using namespace std;

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

    double av;
    
    double sum = 0;
    rep(i,n) sum += a[i];
    av = sum/n;

    int min = 0;
    double tmp = (double)abs(a[0]-av);
    rep(i,n){
        if(tmp > (double)abs(av - a[i])){
            min = i;
            tmp = (double)abs(av - a[i]);
        }
    }

    cout << min << endl;
    return 0;
}

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

const lli m = 2e5+10;
lli n, k;

int main(void){
	cin >> n >> k;
	vector<lli> c(m);
	rep(i, n){
		lli ai;
		cin >> ai;
		c[ai]++;
	}
	sort(c.begin(), c.end(), greater<lli>());
	lli ans = n;
	rep(i, k) ans-=c[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4852
#include<iostream>
#define m long long
using namespace std;
#define d(s,i,n) for(int i=s;i<n;i++)
m l[90],r[90],e[90][90],f[90][90];
int main(){m n;cin>>n;l[0]=1;r[0]=1;d(1,i,90)l[i]=r[i-1],r[i]=l[i-1]+r[i-1];d(0,i,89){e[i][0]=1,f[i][0]=1;d(1,j,90){if(i+1==j)f[i][j]=f[i][j-1]*2+e[i][j-1];else f[i][j]=f[i][j-1]+e[i][j-1];e[i][j]=f[i][j-1];}}d(0,i,n){m c,d;cin>>c>>d;if(d>c)swap(c,d);m k=0;d(0,j,90)if(c>=r[j]&&d>=l[j])k=j;m g;if(k==0)k=1,g=1;else if(k==1)if(d==1)g=c;else g=4;else{g=1;if(d>=r[k]&&c>=l[k]&&l[k]<r[k])g++;d(0,j,k)if(f[j][k]<=c&&e[j][k]<=d)g+=1+(c-f[j][k])/e[j][k];d(0,j,k)if(f[j][k]<=d)g+=1+(d-f[j][k])/e[j][k];}cout<<k<<" "<<g%1000000007<<endl;}}	

Measured memory_bytes: 4452
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    string s;
    cin >> s;
    string t;
    cin >> t;
    reverse(All(t));
    if(s == t) puts("YES");
    else puts("NO");
    return 0;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a, b;
    cin >> a >> b;
    int ans = 0;
    for(int i = 0; i < 3; ++i) ans += (a[i] == b[i]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import bisect

N = int(input())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
B.sort()
C.sort()

B_num = []
for i in range(N):
    if i == 0:
        B_num.append(bisect.bisect_left(A, B[i]))
    else:
        B_num.append(bisect.bisect_left(A, B[i]) + B_num[i-1])

count = 0
for i in range(N):
    idx = bisect.bisect_left(B, C[i])
    if idx == 0:
        continue
    else:
        count += B_num[idx - 1]

print(count)

Measured memory_bytes: 24180
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

string s;

int main(){
	cin>>s;
	if(s=="SUN") cout<<7<<endl;
	if(s=="MON") cout<<6<<endl;
	if(s=="TUE") cout<<5<<endl;
	if(s=="WED") cout<<4<<endl;
	if(s=="THU") cout<<3<<endl;
	if(s=="FRI") cout<<2<<endl;
	if(s=="SAT") cout<<1<<endl;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;


void solve(long long N, std::vector<long long> X, std::vector<long long> L){
	vector<P> ps;
	for(int i=0;i<N;i++){
		ps.push_back(P(X[i],L[i]));
	}
	sort(ps.begin(),ps.end());
	LL last=-1e10;
	int ret=0;
	for(auto p:ps){
		if(last<=p.first-p.second){
			ret++;
			last=p.first+p.second;
		}
		else{
			last=min(last,p.first+p.second);
		}
	}
	cout << ret << endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> X(N);
    std::vector<long long> L(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
        scanf("%lld",&L[i]);
    }
    solve(N, std::move(X), std::move(L));
    return 0;
}


Measured memory_bytes: 3956
#include<iostream>
#include<string>
using namespace std;
int main(){
    string S;
    cin >> S;
    int ans=0;
    for(int i=0;i<S.size();i++){
        for(int j=i;j<S.size();j++){
            for(int k=0;k<=j-i;k++){
                if(S[i+k]!='A' && S[i+k]!='C' && S[i+k]!='G' &&
                S[i+k]!='T') break;
                if(j==i+k){
                    if(ans<j-i+1) ans=j-i+1;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    int n;
    cin >> n;
    vector<int> p(n), q(n);

    rep(i,n)cin >> p[i],p[i]--;
    rep(i,n)cin >> q[i],q[i]--;

    map<vector<int>,int> ord;

    int iter = 0;
    vector<int> v(n);
    rep(i,n) v[i] = i;
    do{
        ord[v] = iter++;
    }while(next_permutation(all(v)));
    
    cout << abs(ord[p] - ord[q]) <<endl;
    return 0;
}



Measured memory_bytes: 5248
N = list(input())
num = len(N)
if N.count('9') == num:
    print(9*num)
elif N.count('9') == num-1 and N[0] != '9':
    print(int(N[0])+9*(num-1))
else:
    if num <= 1:
        print(''.join(N))
    else:
        ans = int(N[0])-1
        ans += 9*(num-1)
        print(ans)


Measured memory_bytes: 9184
import scala.io.StdIn

case class Expr(l:Int, op: String, r:Int)

object Main {
  def calc(str:String):Option[Int] = {
    if(str.trim.isEmpty == false){
      val inputs = str.split(" ")
      Expr(inputs(0).toInt, inputs(1), inputs(2).toInt) match {
        case Expr(l, "+", r) => Some(l + r)
        case Expr(l, "-", r) => Some(l - r)
        case Expr(l, "*", r) => Some(l * r)
        case Expr(l, "/", r) => Some(l / r)
        case _ => None
      }
    }else{
      None
    }
  }

  def main(args: Array[String]): Unit = {
    Iterator.continually(StdIn.readLine()).takeWhile(_ != null).foreach{
      calc(_).foreach(println _)
    }
  }
}

Measured memory_bytes: 43948
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 合宿参加人数
		int N = sc.nextInt();
		// 合宿実施日数
		int D = sc.nextInt();
		// 合宿終了後の残りチョコ
		int X = sc.nextInt();
		// 食べたチョコ
		int total = 0;
		for(int i = 0; i<N; i++) {
			int A = sc.nextInt();
			total += eat(A, D);
		}
		System.out.println(total + X);
	}

	public static int eat(int A, int D) {
		ArrayList<Integer> days = new ArrayList<Integer>();
		for(int i = 0; i < D; i++) {
			if(i * A + 1 <= D){ days.add(A); };
		}
		return days.size();
	}
}

Measured memory_bytes: 20948
// ABC122_B
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）

int main() {
    // input(sunippets: inpv, inpn, inps)
    string S;
    cin >> S;
    
    // calculation
    ll now = 0, res = 0;
    REP(i, S.length()) {
        if (S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C') {
            now++;
        } else {
            res = max(res, now);
            now = 0;
        }
    }
    res = max(res, now);
    cout << res << "\n";
    
    return 0;
}

Measured memory_bytes: 256
H, W = [int(x) for x in input().split()]
an = [[int(x) for x in input().split()] for _ in range(H)]

pathes = []
for h in range(H):
  for w in range(W):
    if h % 2 == 0:
      ww = w
    else:
      ww = W - 1 - w
    pathes.append((ww, h))


N = H * W 
outs = []
for n in range(N - 1):
  w1, h1 = pathes[n]
  w2, h2 = pathes[n + 1]
  if an[h1][w1] % 2 == 1:
    outs.append((h1 + 1, w1 + 1, h2 + 1, w2 + 1))
    an[h2][w2] += 1
    
print(len(outs))
for out in outs:
  print(" ".join([str(i) for i in out]))
    


  

Measured memory_bytes: 47968
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int N,X,T;
    cin>>N>>X>>T;
    int ans=0;
    if(N%X==0){
        ans=N/X;
    }else{
        ans=N/X+1;
    }
    cout << ans * T << endl;
    return 0;
}

Measured memory_bytes: 3644
/*
      author : nishi5451
      created: 12.08.2020 14:49:20
*/

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


int main(){
    int h,w,n;
    cin >> h >> w >> n;
    int ans;
    ans = n/max(h,w);
    if(n%max(h,w) != 0) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void){
  cout << std::fixed << std::setprecision(16);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int64_t a,b,x;
  cin>>a>>b>>x;
  if(b*a*a/2>=x){
    double y=sqrt((double)(4*x*x+a*a*b*b*b*b)/(double)(a*a*b*b));
    double radian=acos(b/y);

    cout<< 90.0-radian*(double)(180.0/M_PI)<<endl;
  }else{
    double y=2*(double)x/(double)(a*a)-(double)b;
    double radian=atan((b-y)/a);
    cout<< radian*(double)(180.0/M_PI)<<endl;
  }


  return 0;
}


Measured memory_bytes: 256
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int a,b,c,cnt=0;
cin >> a >> b >> c;
for(int i=100;i>=1;i--){
    if(a%i==0 && b%i==0){
        cnt++;
        if(cnt==c){
            cout << i << endl;
            return 0;
        }
    }
}

return 0;}
///....


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define tr(container, it) \
    for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const double pi = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;

ll X[1000];
ll Z[1000];
ll Y[1000];
pll S[1000];
void _(){
    int n,m;
    cin >> n >>m;
    cout << ((m==100)+m)*(n==0?1:n==1?100:10000);

}


int main() {
#if __MINGW32__
    freopen("E:\\Workspace\\Desktop\\cpp\\IO\\Input.txt", "r", stdin);
    freopen("E:\\Workspace\\Desktop\\cpp\\IO\\Output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    _();
    return 0;

}








Measured memory_bytes: 256
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;

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

    int cnt = 1;
    int D = 0;
    for (int i = 0; i < N; ++i) {
        int L; cin >> L;
        D += L;
        if (D <= X) cnt++;
    }

    cout << cnt;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
char s[N];
int main() {
	scanf("%s", s);
	int n = (int) strlen(s);
	int l = 0, r = n - 1;
	bool gg = 0;
	int ans = 0;
	while (l < r) {
		if (s[l] == s[r]) {
			l ++;
			r --;
		}
		else if (s[l] == 'x') {
			ans ++;
			l ++;
		}
		else if (s[r] == 'x') {
			ans ++;
			r --;
		}
		else {
			gg = 1;
			break;
		}
	}
	if (gg) ans = -1;
	printf("%d\n", ans);
}


Measured memory_bytes: 384
from collections import deque

s = str(input())
q = int(input())
flip = -1
strf = deque()
strb = deque()

for i in range(q):
    query = list(map(str, input().split()))
    if query[0] == '1':
        flip = flip * -1
    elif query[0] == '2':
        if query[1] == '1':
            if flip == -1:
                strf.appendleft(query[2])
            else:
                strb.append(query[2])
        elif query[1] == '2':
            if flip == -1:
                strb.append(query[2])
            else:
                strf.appendleft(query[2])

# print(strf)
# print(strb)
ans = ''.join(strf) + s + ''.join(strb)
if flip == 1:
    ans = ans[::-1]
print(ans)

# s = str(input())
# q = int(input())
# flip = -1
# strs = '/'
 
# for i in range(q):
#     query = list(map(str, input().split()))
#     if query[0] == '1':
#         flip = flip * -1
#     elif query[0] == '2':
#         if query[1] == '1':
#             if flip == -1:
#                 strs = query[2] + strs
#             else:
#                 strs = strs + query[2]
#         else:
#             if flip == -1:
#                 strs = strs + query[2]
#             else:
#                 strs = query[2] + strs
 
# if flip == -1:
#     ans = strs.replace('/', s)
# else:
#     ans = strs[::-1].replace('/', s[::-1])
 
# print(ans)

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

ll dp[101][100001];
ll fn(ll c[],ll w[],ll n,ll W)
{
    if(n==0 || W==0)
    {
        return 0;
    }
    if(dp[n][W] != -1)
    {
        return dp[n][W];
    }
    if(w[n-1] <= W)
    {
        return dp[n][W] = max(c[n-1]+fn(c,w,n-1,W-w[n-1]),fn(c,w,n-1,W));
    }
    else
    {
        return dp[n][W] = fn(c,w,n-1,W);
    }
}
int main()
{
    ll i,n,k;
    cin>>n>>k;
    ll c[n];
    ll w[n];
    for(i=0; i<=n; i++)
    {
        cin>>w[i]>>c[i];
    }
    memset(dp,-1,sizeof(dp));
    fn(c,w,n,k);
    cout<<dp[n][k]<<"\n";
    return 0;
}

Measured memory_bytes: 82536
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int N;
	scanf("%d",&N);

	if(N == 1){
		printf("! 1\n");
		return 0;
	}

	int max_dist = 0,max_index;

	int tmp;

	for(int i = 2; i <= N; i++){
		printf("? 1 %d\n",i); fflush(stdout);
		scanf("%d",&tmp);
		if(tmp > max_dist){
			max_dist = tmp;
			max_index = i;
		}
	}

	int ans[N];
	ans[0] = max_index;

	for(int i = 1; i <= N; i++){
		if(i == max_index)continue;
		printf("? %d %d\n",max_index,i); fflush(stdout);
		scanf("%d",&tmp);
		ans[tmp] = i;
	}

	printf("! %d",max_index);
	for(int i = 1; i < N; i++){
		printf(" %d",ans[i]);
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,i;
	string s;
	cin>>n>>s;
	for(i=0;i<s.size();i++)
	{
	    cout<<char('A'+(s[i]+n-'A')%26);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  int x, a;
  cin >> x >> a;
  cout << (x < a ? 0 : 10) << endl;
}


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

int main(){
    int n;
    cin >> n;
    long long ans = 0;
    for(int i=0;i<n;i++){
        int tmp;
        cin >> tmp;
        while(tmp%2 == 0){
            tmp /=2;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int k, x;
	cin >> k >> x;
	if (k * 500 >= x) {
		put("Yes");
	} else {
		put("No");
	}
	return 0;
}

Measured memory_bytes: 256
module Main where

    import Debug.Trace
    import Text.Printf

    solve :: Int -> Int -> String
    solve a b = (show q ++ " " ++ show r ++ " " ++ f) where
        (q, r) = divMod a b
        f = printf "%.5f" ((fromIntegral a / fromIntegral b)::Double)

    readLine:: IO [Int]
    readLine = fmap (map read . words) getLine
    
    main :: IO() 
    main = do
        [a, b]    <- readLine
        let ans = solve a b
        putStrLn ans
    


Measured memory_bytes: 3848
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#define INF 2139062143
#define inf -2139062144
#define ll long long
using namespace std;
int a[100005];
int gcd(int a, int b) {
	return b ? gcd(b, a%b) : a;
}
int main(){
	int n,k,i,j;
	scanf("%d%d",&n,&k);
	int ma = inf;
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		ma = max(ma,a[i]);
	}
	int re = a[0];
	for(i=0;i<n;i++){
		re = gcd(re,a[i]);
	}
	if(ma >= k && k%re == 0){
		printf("POSSIBLE\n");
	}else{
		printf("IMPOSSIBLE\n");
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

struct RH {
  vector<unsigned long long> p,hash;
  void init(const string s) {
    unsigned long long m=1000000007,q=1,n=s.size();
    p.resize(n+1);hash.resize(n+1);p[0]=q;hash[0]=0;
    rep(i,n){p[i+1]=p[i]*m;hash[i+1]=s[i]+hash[i]*m;}
  }
  unsigned long long h(int i)const{return hash[i];}
  unsigned long long h(int i,int j)const{return h(j)-h(i)*p[j-i];}
};


RH r[2][666];
void Main() {
  int n;
  R n;
  vector<string> s(n*2);
  rep(i,n) {
    R s[i];
    s[i]+=s[i];
  }
  rep(i,n) s[i+n]=s[i];
  vector<string> t=s;
  rep(i,n*2) {
    REP(j,i,n*2) swap(t[i][j],t[j][i]);
  }
  rep(i,n*2) r[0][i].init(s[i]);
  rep(i,n*2) r[1][i].init(t[i]);
  int ans=0;
  rep(i,n)rep(j,n) {
    int c=0;
    rep(k,n) if(r[0][i+k].h(j,j+n)==r[1][j+k].h(i,i+n)) c++;
    if(c==n) ans++;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 14208
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	string s; cin>>s;
	vector<int>v;
	int sum=0;
	for(int i=0;s[i];i++) v.push_back(s[i]-'0');
	for(auto  i=v.begin();i!=v.end();i++) sum+=*i;
	sum%9==0?cout<<"Yes":cout<<"No";
}


Measured memory_bytes: 4112
import Control.Applicative ((<$>))
import Control.Monad (replicateM)

main :: IO ()
main = do
  solve <$> replicateM 3 (map read . words <$> getLine) >>= putStrLn

solve :: [[Int]] -> String
solve [[c11, c12, c13],[c21, c22, c23], [c31, c32, c33]]
  | tsm `mod` 3 /= 0 = "No"
  | s0 == s1 && s1 == s2 && s2 == s3 = "Yes"
  | otherwise = "No"
  where
    tsm = c11 + c12 + c13 + c21 + c22 + c23 + c31 + c32 + c33
    s0 = tsm `div` 3
    s1 = c11 + c22 + c33
    s2 = c12 + c23 + c31
    s3 = c13 + c21 + c32


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int n,m,K;
    cin >> n >> m >> K;
    bool ok = false;
    for(int l=0;l<=m;l++){
        int e = m - 2*l;
        int r = K-n*l;
        if(e<=0) break;
        if(r%e==0 && r/e>=0 && r/e<=n){
            ok = true;
            break;
        }
    }
    cout << (ok? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
A[5][4][12],N,i,j,k,t;
main(void){
    for(scanf("%d",&N);N--;){
        scanf("%d%d%d%d",&i,&j,&k,&t);
        A[i][j][k]+=t;
    }
    for(i=1;i<5;i++){
        for(j=1;j<4;j++){
            for(k=1;k<11;k++){
                printf(" %d%s",A[i][j][k],k==10?"\n":"");
            }
        }
        if(i<4)
        puts("####################");
    }
}

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

using namespace std;

struct vil {
  int id;
  int x;
  int y;
};

struct edge {
  int from;
  int to;
  int cost;
};

class union_find {
public:
  union_find(int n) : vec(n+1) {
    for (int i = 0; i < n; ++i) {
      vec[i] = i;
    }
  }
  int find(int x) {
    if (x == vec[x]) return x;
    return vec[x] =  find(vec[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    vec[x] = y;
    return;
  }
  
  vector<int> vec;
};

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

  int n;
  cin >> n;
  vector<vil> vs(n);
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    vs[i] = vil{i+1, x, y};
  }

  vector<edge> edges;
  edges.reserve(n*2);
  sort(vs.begin(), vs.end(), [](const vil& l, const vil& r) -> bool {
      return l.x < r.x;
    });
  for (int i = 0; i < n - 1; ++i) {
    edges.push_back(edge{vs[i].id, vs[i+1].id, abs(vs[i].x - vs[i+1].x)});
  }
  sort(vs.begin(), vs.end(), [](const vil& l, const vil& r) -> bool {
      return l.y < r.y;
    });
  for (int i = 0; i < n - 1; ++i) {
    edges.push_back(edge{vs[i].id, vs[i+1].id, abs(vs[i].y - vs[i+1].y)});
  }
  sort(edges.begin(), edges.end(), [](const edge& l, const edge& r) -> bool {
      return l.cost < r.cost;
    });


  union_find uf(n);
  uint64_t ans = 0;
  for (auto& e : edges) {
    if (uf.find(e.from) != uf.find(e.to)) {
      ans += e.cost;
      uf.unite(e.from, e.to);
    }
  }
  cout << ans << "\n";
}


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

int main(){
    char str [201];
    cin >> str;
    int n = strlen(str);
    for(int i = n - 2; i>0; i-=2){
        if(strncmp(str, str+i/2, i/2)==0){
            cout << i;
            return 0;
        }
    }
    return 0;
}


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

int main() {
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  std::vector<int64_t> cnt(n);
  for (int i = 0; i < n; ++i) std::cin >> a[i];
  long long sum = std::accumulate(a.begin(), a.end(), 0LL);
  std::vector<int> od(n);
  std::iota(od.begin(), od.end(), 0);
  std::sort(od.begin(), od.end(), [&](int i, int j) { return a[i] > a[j]; });
  std::set<int> s, t;
  for (int i = 0; i < n; ++i) s.insert(i);
  for (int i = 0, j = 0; i < n; i = j) {
    for (j = i; j < n && a[od[i]] == a[od[j]]; ++j) {
      t.insert(od[j]);
      s.erase(od[j]);
    }
    if (!s.empty() && *s.begin() < *t.begin()) {
      int dist = a[od[i]] - a[od[j]]; 
      cnt[*t.begin()] += 1LL * dist * t.size();
      sum -= 1LL * dist * t.size();
    } else {
      cnt[*t.begin()] += sum;
      break;
    }
  }
  for (int i = 0; i < n; ++i) std::cout << cnt[i] << "\n";
}


Measured memory_bytes: 7296
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

// 橋・関節点列挙 O(V)
struct LowLink {
private:
    vector< vector< int > > G;
    int V; // 頂点数
    vector< int > used, ord, low;

    int dfs(int idx, int k, int par) {
        used[idx] = true;
        ord[idx] = k++;
        low[idx] = ord[idx];
        bool is_articulation = false;
        int cnt = 0;
        for (auto &to : G[idx]) {
            if (!used[to]) {
                ++cnt;
                k = dfs(to, k, idx);
                low[idx] = min(low[idx], low[to]);
                is_articulation |= ~par && low[to] >= ord[idx];
                if (ord[idx] < low[to]) bridge.push_back(minmax(idx, (int)to));
            }
            else if (to != par) {
                low[idx] = min(low[idx], ord[to]);
            }
        }
        is_articulation |= par == -1 && cnt > 1;
        if (is_articulation) articulation.push_back(idx);
        return k;
    }

public:
    vector< int > articulation; // 関節点
    vector< pair< int, int > > bridge; // 橋

    LowLink(int V) : V(V) {
        G.resize(V);
    }

    // 無向辺を張る
    void add_edge(int v, int u) {
        G[v].push_back(u);
        G[u].push_back(v);
    }

    void build() {
        used.assign(V, 0);
        ord.assign(V, 0);
        low.assign(V, 0);
        int k = 0;
        for (int i = 0; i < V; i++) {
            if (!used[i]) k = dfs(i, k, -1);
        }
    }
};

int main() {
    int v, e; cin >> v >> e;
    LowLink G(v);
    REP(i, e) {
        int a, b; cin >> a >> b;
        G.add_edge(a, b);
    }
    G.build();
    sort(G.bridge.begin(), G.bridge.end());
    for (auto &e : G.bridge) {
        cout << e.first << " " << e.second << endl;
    }
    return 0;
}


Measured memory_bytes: 4556
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string s;
  cin >> s;
  ll ans = INF;
  char c = s[0];
  bool flag = true;
  for (int i = 1; i < s.length(); i++) {
    if (s[i] != c) {
      flag = false;
      break;
    }
  }
  if (flag) {
    cout << 0 << endl;
    return 0;
  }
  for (char c = 'a'; c <= 'z'; c++) {
    ll cnt = 0;
    string t = s;
    while (t.length() > 1) {
      string new_t = "";
      ll c_cnt = 0;
      for (int i = 0; i < t.length() - 1; i++) {
        if (t[i] == c || t[i + 1] == c) {
          new_t += c;
          c_cnt++;
        } else {
          new_t += t[i];
        }
      }
      t = new_t;
      cnt++;
      if (c_cnt == t.length()) break;
    }
    ans = min(cnt, ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
    // Your code here!
    int n,k;
    scanf("%d %d",&n,&k);
    int min ,max;
    int anmin=0,anmax=0;
    int i;
    scanf("%d %d",&anmin,&anmax);
    for(i=1;i<k;i++){
        scanf("%d %d",&min,&max);
        if(min >anmin){
            anmin= min;
        }
        if(max <anmax ){
            anmax= max;
        } 
    }   
    int ans=anmax-anmin+1;
    if(anmin> anmax ){
        ans=0;
    }
    printf("%d\n",ans);
    return 0;
}

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

using namespace std;

bool b[26];

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    b[s[i] - 'a'] = true;
  }
  for (int i = 0; i < 26; i++) {
    if (!b[i]) {
      cout << s << (char)('a' + i) << endl;
      return 0;
    }
  }
  for (int i = 25; i > 0; i--) {
    if (s[i] < s[i - 1]) {
      b[s[i] - 'a'] = false;
      b[s[i - 1] - 'a'] = false;
    } else if (i == 25) {
      for (int j = 0; j <= 23; j++) {
        cout << s[j];
      }
      cout << s[25] << endl;
      return 0;
    } else {
      for (int j = 0; j < i - 1; j++) {
        cout << s[j];
      }
      for (int j = 0; j < 26; j++) {
        if (!b[j] && s[i - 1] < (char)('a' + j)) {
          cout << (char)('a' + j) << endl;
          return 0;
        }
      }
    }
  }
  cout << -1 << endl;
  return 0;
}


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

int main(){
    int A,B,N;
    cin>>N;
    if(N==2){
        cin>>A>>B;
        cout<<A+B;
    }else{
        cout<<"Hello World"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
# 入力
N, K = map(int, input().split())
A = list(map(int, input().split()))


# MSBから順に0or1を決めていく
# 0にする場合、下位ビットの最適値は貪欲に求まる
def s(i):
    return sum((a >> (i - 1)) & 1 for a in A)


def g(L, b):
    m = 2**(b - 1)
    return (
        0 if b == 0 else
        g(L, b - 1) + m * s(b) if L < m else
        g(L >> 1, b - 1) + m * max(
            s(b),
            N - s(b)
        ) if L == (2**b - 1) else
        max(
            g(m - 1, b - 1) + m * s(b),
            g(L - m, b - 1) + m * (N - s(b))
        )
    )


ans = g(K, max(K, *A).bit_length())

# 出力
print(ans)


Measured memory_bytes: 70672