akhauriyash/Code-Regression huggingface dataset:
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1e5+5;

int dp[N][2];

string s;

int rec(int ind,int tight)
{
    if(ind==-1)
        return 1;

    int& res=dp[ind][tight];
    if(res!=-1)
        return res;

    res=0;
    int nt;
    for(int i=0;i<3;++i)
    {
        if(i)
        {
            if(s[ind]=='0')
            {
                if(tight)
                    break;
                else
                    nt=0;
            }
            else
                nt=tight;
        }
        else
        {
            if(s[ind]=='0')
                nt=tight;
            else
                nt=0;
        }

        res=(res+rec(ind-1,nt))%M;
    }

    //cout<<ind<<" "<<tight<<" "<<res<<"\n";

    return res;
}

void solve()
{
    mem(dp,-1);

    cin>>s;

    reverse(all(s));

    int ans=rec(sz(s)-1,1);
    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



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

using namespace std;

int main() {
    int N, M;
    int lower;
    int upper;
    int ans;

    cin >> N >> M;

    lower = 1;
    upper = N;

    for (int i = 0; i < M; i++) {
        int l, r;
        cin >> l >> r;
        lower = max(lower, l);
        upper = min(upper, r);
    }

    if (lower <= upper) {
        ans = upper - lower + 1;
    } else {
        ans = 0;
    }

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
  ll a, b, c;
  cin >> a >> b >> c;
  
  if(c - a - b < 0){
      cout << "No" << endl;
      return 0;
  }

  if(4 * a * b < (c - a - b) * (c - a - b)) cout << "Yes" << endl;
  else cout << "No" << endl;

}

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

//constexpr long double PIL = 3.141592653589793238462643383279502884L;
//constexpr double PI = 3.14159265358979323846;

#define sz(a) (int)((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

const ll MOD = 1e9 + 7;

int main() {
	int s, w;
	cin >> s >> w;
	cout << (w >= s ? "unsafe" : "safe") << '\n';
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll k=1,a=10,ans=1;
bool que(ll x){
    printf("? %lld\n",x);
    fflush(stdout);
    char c;
    scanf(" %c",&c);
    return c=='Y';
}
int main(void){
    while(a<=100000000000&&que(a)){
        k++;
        a*=10;
    }
    if(k>10){
        a=2;
        while(!que(a)){
            a*=10;
        }
        printf("! %lld\n",a/2);
        return 0;
    }
    ll l=0,r=10;
    while(r-l>1){
        ll m=(l+r)/2;
        if(que(m*a))r=m;
        else l=m;
    }
    ans=l;
    for(int i=1;i<k;i++){
        l=-1;
        r=10;
        while(r-l>1){
            ll m=(l+r)/2;
            if(que((ans*10+m)*a))r=m;
            else l=m;
        }
        ans=ans*10+l;
        a/=10;
    }
    printf("! %lld\n",ans+1);
}


Measured memory_bytes: 596
// inputに入力データが入る
function Main(input) {
  var S = input;
  var output = 1000;
  
  for (var i = 0; i < S.length - 2; i++) {
    var tmp = S.substr(i, 3);
    tmp = parseInt(tmp, 10);
    tmp = Math.abs(753 - tmp);
    output = (output > tmp) ? tmp : output;
  }

  //出力
  console.log(output);
}
//*この行以降は編集しないでください（Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef pair<int, int> pii;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

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 SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class C {
	ll x, y;
	ll ans{ 0 };
public:
	C()
	{
		cin >> x >> y;
	}
	void solve()
	{
		while (x < y)
		{
			x <<= 1;
			++ans;
		}

		if (x == y) ++ans;

		cout << ans << endl;
	}
};


int main()
{
	C solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int a[N], n;
map<int, int>v;

int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
        v[i - a[i]]++;
    }
    long long ans = 0;
    for(int i = 1; i <= n; i++){
        v[i - a[i]]--;
        ans += v[a[i]+i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 21344
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
  int N,K,Q;
  cin >> N >> K >> Q;
  int A[Q];
  for(int i=0;i<Q;i++){
    cin >> A[i];
  }
  int B[N];
  for(int i=0;i<N;i++){
    B[i] = K - Q;
  }
  for(int i=0;i<Q;i++){
    int answer = A[i]-1;
    B[answer]++;
  }
  for(int i=0;i<N;i++){
    if(B[i] > 0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1408
import math
import itertools
K=int(input())
l=list(itertools.combinations_with_replacement(range(1,K+1),3))
S=0
for i in l:
    a=i[0]
    b=i[1]
    c=i[2]
    x=math.gcd(a,b)
    if a==b==c:
        S+=math.gcd(x,c)
    elif a==b or b==c or c==a:
        S+=math.gcd(x,c)*3
    else:
        S+=math.gcd(x,c)*6   
print(S)





Measured memory_bytes: 105540
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, C;
  cin >> N >> M >> C;
  int A;
  vector<int> B(M);
  //vector<vector<int>> A = vector<vector<int>>(N, vector<int>(M));
  int cnt=0;
  for(int i=0; i<M; i++){
    cin >> B.at(i);
  }
  for(int i=0; i<N; i++){
    int sum = C;
    for(int j=0; j<M; j++){
      cin >> A;
      sum += A * B.at(j);
    }
    if(sum > 0){
      cnt++;
    }
  }
  cout << cnt;
}


Measured memory_bytes: 256
//AtCoder DP-A

//AnkitCode99 here....
//every ups and downs matter!

#include<bits/stdc++.h>
#define endl "\n"
#define Ryuga ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr)
typedef long long int ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back

using namespace std;

const ll sz=1e5+5;
const ll szz=1e6+6;
const ll mod=1e9+7;

ll h[sz],dp[sz],n;

ll minCost(ll idx)
{
	if(idx>=n)
		return 1e15;

	if(idx==n-1)
		return 0;

	if(dp[idx]!=-1)
		return dp[idx];

	return dp[idx]=min(abs(h[idx]-h[idx+1])+minCost(idx+1),abs(h[idx]-h[idx+2])+minCost(idx+2));
}

int main()
{
	Ryuga;

	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("op.txt","w",stdout);
	#endif

	clock_t startTime=clock();

	cin>>n;
	memset(dp,-1,sizeof dp);
	rep(i,0,n)
	{
		cin>>h[i];
	}

	cout<<minCost(0);

	cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;

}//Goodbye...

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

int main(){
    string a, b;
    cin >> a >> b;
    bool ans = false;
    for (int i=0; i<b.size(); ++i){
        if (a == b){
            ans = true;
            break;
        }
        b = b.back() + b.substr(0, b.size()-1);
    }
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int gcd(int A,int B){
  if(B>A)swap(A,B);
  if(B==0)return A;
  return gcd(B,A%B);
}

int main(){
  int N;
  cin >> N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  int ans=0;
  vector<int>L(N);
  vector<int>R(N);
  L[0]=A[0];
  R[N-1]=A[N-1];
  for(int i=1;i<N;i++){
    L[i]=gcd(A[i],L[i-1]);
  }
  for(int i=N-2;i>=0;i--){
    R[i]=gcd(A[i],R[i+1]);
  }
  for(int i=0;i<N;i++){
    int num=0;
    if(0<i){
      num=gcd(num,L[i-1]);
    }
    if(i<N-1){
      num=gcd(num,R[i+1]);
    }
    ans=max(ans,num);
  }
  cout << ans << endl;     

}
     

Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int n,ans;
int dp[114514];
bool isp(int a)
{
	for(int i=2;i*i<=a;i++)if(a%i==0)return 0;
	return 1;
}
main()
{
	cin>>n;
	dp[1]=1;
	for(int i=2;i<=n;i++)
	{
		if(!isp(i))continue;
		int cnt=0;
		for(int j=1;j<=n;j++)
		{
			int a=j;
			while(a%i==0)cnt++,a/=i;
		}
		for(int k=75;k>=1;k--)for(int j=1;j<=cnt;j++)
		{
			dp[k*(j+1)]+=dp[k];
		}
	}
	cout<<dp[75]<<endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

using namespace std;
#define int long long


class AStudyScheduling {
public:
    void solve(std::istream &in, std::ostream &out) {
      int h1, m1, h2, m2, k;
      in >> h1 >> m1 >> h2 >> m2 >> k;
      if ((h1 > h2) || (h1 == h2 && m1 > m2)) {
        h2 += 24;
      }
      out << h2 * 60 + m2 - h1 * 60 - m1 - k << endl;
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  AStudyScheduling solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3652
import sys
from collections import deque
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,M=map(int,input().split())
    edge=[[] for _ in range(N)]
    for i in range(M):
        X,Y,Z=map(lambda x:int(x)-1,input().split())
        edge[X].append(Y)
        edge[Y].append(X)
    used=[False]*N
    ans=0
    for i in range(N):
        if not used[i]:
            ans+=1
            queue=deque()
            queue.append(i)
            while queue:
                node=queue.popleft()
                used[node]=True
                for nextnode in edge[node]:
                    if not used[nextnode]:
                        queue.append(nextnode)
    print(ans)
                    

if __name__ == '__main__':
    main()


Measured memory_bytes: 61984
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,p,q,s;
  cin>>p>>q;
  for(a=0;a<1251;a++){
  if(p<=a*0.08&&a*0.08<p+1&&q<=a*0.1&&a*0.1<q+1){s=a; break;}
  else{s=-1;}
  }
  cout<<s<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll a,b; cin >> a >> b;
    ll ans = 0;
    ll sum = 1;
    while(sum < b){
        sum += a-1;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#define swap(a,b) {int t;t=a;a=b;b=t;}

int bubble_sort(int A[], int N) {
    int cnt =0;
    for(int i=0;i<N;i++) {
        for(int j=N-1;j>i;j--){
            if(A[j-1]>A[j]){
                swap(A[j-1],A[j]);
                cnt++;
            }
        }
    }
    return cnt;
}

int main() {
    int N, A[100+1];
    scanf("%d", &N);
    for(int i=0;i<N;i++) {
        scanf("%d", &A[i]);
    }
    int cnt = bubble_sort(A,N);
    for(int i=0;i<N;i++) {
        printf("%d%c", A[i], i==N-1?'\n':' ');
    }
    printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 2716
n, a, b = map(int, input().split())
v = list(map(int, input().split()))

v.sort(reverse=True)

maximum = sum(v[:a])

print(maximum / a)

def comb(n, r):
    if n - r < r:
        r = n - r
    if r < 0:
        return 0
    ans = 1
    for i in range(r):
        ans *= n - i
    for i in range(1, r+1):
        ans //= i
    return ans

# 選ぶ品物の価値が全て等しい時
if v[0] == v[a-1]:
    num = v.count(v[0])
    ans = 0
    for i in range(a, b+1):
        ans += comb(num, i)
    print(ans)
else:
    num = v.count(v[a-1])
    r = v[:a].count(v[a-1])
    print(comb(num, r))

Measured memory_bytes: 61948
#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
using namespace std;
const int maxN=1e6+5;
int main(){
    int len;
    string s;
    cin>>s;
    len=s.length();
    int cnt=0;
    for(int i=0;i<=(len-1)/2;i++){
        if(s[i]!=s[len-i-1])cnt++;
    }
    printf("%d\n",cnt);
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }

void dfs(int v,  vi &res, const vii &tree) {
  for(int nv : tree[v]) {
    if(res[nv] != inf) continue;
    res[nv] = res[v]+1;
    dfs(nv, res, tree);
  }
}

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

  int n, u, v;
  cin >> n >> u >> v;
  u--; v--;
  vii tree(n);
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  vi t(n,inf), a(n,inf);
  t[u] = 0, a[v] = 0;
  dfs(u,t,tree);
  dfs(v,a,tree);
  int ans = 0;
  rep(i,n) {
    if(t[i]+1 > a[i]) continue;
    int d = a[i];
    if(sz(tree[i]) == 1) d--;
    chmax(ans, d);
  }
  cout << ans << endl;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
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;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    int n, m, t;
    scanf("%d%d%d", &n, &m, &t);
    int a[n+2];
    a[0] = -m;
    a[n+1] = t+m;
    rep(i, n) scanf("%d", &a[i+1]);
    int ans = 0;
    rep(i, n+1) ans += max(0, a[i+1] - a[i] - 2*m);
    printf("%d\n", ans);
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define fr first
#define se second
const ll mod = 1e9+7;

ll power(ll x,ll y){
    if(x==0) return 1;
    ll ans=1;
    x%=mod;
    while(y>0){
        if(y&1)
            ans = (ans*x)%mod;
        x = (x*x)%mod;
        y = y>>1;
    }
    return (ans+mod)%mod;
}


void solve(ll cas){
    ll n;cin>>n;
    ll ans = (power(10,n) - 2*power(9,n) + power(8,n))%mod;
    cout<<(ans+mod)%mod<<endl;
}
// void solve(ll cas){
//     ll s;cin>>s;
//     if(s<=2){
//         cout<<0<<endl;return;
//     }
//     ll t=s/3,ans=0;
//     for(ll i=1;i<=t;i++){
//         ll x = s-3*i;
//         ans = (ans%mod + power(i,x)%mod)%mod;
//         // cout<<ans<<endl;
//     }
//     cout<<ans<<endl;
// }

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll qu=1;
    // cin>>qu;
    for(ll cas=1;cas<=qu;cas++){
        solve(cas);
    }
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
	int n;
	scanf("%d", &n);
	vector<int> h(n);
	rep(i, n) scanf("%d", &h[i]);
	int hmax = 0, count = 1;
	rep(i, n - 1){
		hmax = max(hmax, max(h[i], h[i + 1]));
		if(hmax <= h[i + 1])count++;
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define reep(i,n) for(ll i = n; i >-1; i--)
#define deb(variable) cout<<#variable<<"="<<variable<<endl
#define MMOD(i) ((i%MOD)+MOD)%MOD;
#define vec(i,j) vector<vector<ll>>(i,vector<ll>(j,0))
const ll INF=99999999999999999;
const ll MOD=128;
const ll MAX_N=100010;
ll a,b,d,e,x,y,z,k,m,n,l,q,h,w,ans=0;
vl v,v1,v2;
ll xmax,xmin,ymax,ymin;
char c;
string s1,s2;
vl g[200001];
vl visited;
ll dfs(ll x,ll k){
	//cout<<x<<" "<<k<<endl;
    visited[x]=1;
    rep(i,g[x].size()){
        if(visited[g[x][i]]==0){
            dfs(g[x][i],k+1);
        }
    }

    if(k>m){
        m=k;
        l=x;
    }
}
ll solve(void){
    visited=vl(200001,0);
    m=0;
    dfs(1,0);
    m=0;
    h=l;
    visited=vl(200001,0);
    dfs(h,0);
    //cout<<m<<endl;
    if(m%3==1)return -1;
    return 1;
}
int main(){
    cin>>n;
    rep(i,n-1){
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    if(solve()==1){
        cout<<"First";
    }
    else{
        cout<<"Second";
    }
}

Measured memory_bytes: 26240
// A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s,t;

    cin >> s>>t;
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == t[i])ans++;
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        List<int> list = new List<int>();
        int q = int.Parse(Console.ReadLine());
        for (int i = 0; i < q; i++)
        {
            int[] query = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (query[0] == 0)
            {
                list.Add(query[1]);
            }
            else if (query[0] == 1)
            {
                Console.WriteLine(list[query[1]]);
            }
            else
            {
                list.RemoveAt(list.Count - 1);
            }
        }
    }
}


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

//関数getinputdata宣言
vector<vector<string>> getinputdata();
vector<vector<int>> getinputdata2();

int main() {

    vector<vector<int>> vec_arr_result;

    vec_arr_result = getinputdata2();

    int n = vec_arr_result[0][0];

    vector<int> arr = vec_arr_result[1];

    sort(arr.begin(), arr.end());

    int maxdata = arr.back();

    int sumdata = accumulate(arr.begin(), arr.end(), 0);

    cout <<  ((maxdata < sumdata-maxdata) ? "Yes" : "No") << endl;

    return 0;
}

//関数getinputdata実装

vector<vector<int>> getinputdata2() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<int>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<int> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atoi(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;


}
//関数getinputdata実装

vector<vector<string>> getinputdata() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector < string>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<string> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(ret);
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;

}

Measured memory_bytes: 256
/*input
12001021211100201020
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=4005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int dp[maxn]; //idx = count of '1'
int tmp[maxn];
int main()
{
	IOS;
	string s;
	cin>>s;
	dp[0]=1;

	int cnt1=0,cnt2=0;

	for(int i=0;i<SZ(s)+SZ(s);i++){
		if(i<SZ(s)){
			if(s[i]=='0'){
				cnt1+=2;
			}
			else if(s[i]=='1'){
				++cnt1;
				++cnt2;
			}
			else cnt2+=2;
		}
		REP(j,maxn) tmp[j]=0;
		for(int j=0;j<maxn;j++){
			if(j<cnt1) tmp[j+1]+=dp[j];

			if(i-j<cnt2) tmp[j]+=dp[j];
		}
		REP(j,maxn) dp[j]=tmp[j]%MOD;

		//REP(j,10) cout<<dp[j]<<" \n"[j==9];
	}
	cout<<dp[cnt1]<<'\n';
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int x = scanner.nextInt(), y = scanner.nextInt();
			System.out.println(((x * 2 <= y) && (x * 4 >= y) && (0 == (y & 1))) ? "Yes" : "No");
		}
	}
}


Measured memory_bytes: 35624
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
typedef long long ll;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    cout << max(0, C - (A - B)) << endl;
    return 0;
}

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

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

    if (n % 500 <= k)
        cout << "Yes";
    else
        cout << "No";
    cout << endl;

    return 0;
}


Measured memory_bytes: 3572
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; } value
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> innputto(n-1), autopputo(n,0);
  REP(i,n-1) {
    cin >> innputto[i];
    int a = innputto[i];
    autopputo[a-1]++;
  }
  REP(i,n) cout << autopputo[i] << endl;
}

Measured memory_bytes: 4768
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;


ll n;
int w,h;
void depth(int x,int y,string s[],ll num){
  num++;
  //cout << x << "    " << y <<"     " <<num << endl;
  //cout << endl;
  /*REP(i,h){
    REP(j,s[0].size()){
      cout << s[i][j];
    }
    cout << endl;
    }
    cout << endl;*/
  if(num <= 10){
  if(x+1 < w && s[y][x+1] != '1'){
    int ww = 25;
    for(int i = x+1;i < w;i++){
      if(s[y][i] == '3'){
	n = min(n,num);
	return;
      }
      if(s[y][i] == '1'){
	ww = i;
	break;
      }
    }
    if(ww != 25){
      s[y][ww] = '0';
      
      depth(ww-1,y,s,num);
      s[y][ww] = '1';
    }
    
  }
  if(x-1 >= 0 && s[y][x-1] != '1'){
    int ww = 25;
    for(int i = x-1;i >= 0;i--){
      if(s[y][i] == '3'){
	n = min(n,num);
	return;
      }
      if(s[y][i] == '1'){
	ww = i;
	break;
      }
    }
    if(ww != 25){
      s[y][ww] = '0';
      
      depth(ww+1,y,s,num);
      s[y][ww] = '1';
    }
  }
  if(y-1 >= 0 && s[y-1][x] != '1'){
    int ww = 25;
    for(int i = y-1;i >= 0;i--){
      if(s[i][x] == '3'){
	n = min(n,num);
	return;
      }
      if(s[i][x] == '1'){
	ww = i;
	break;
      }
    }
    if(ww != 25){
      s[ww][x] = '0';
      
      depth(x,ww+1,s,num);
      s[ww][x] = '1';
    }
    
  }
  if(y+1 < h && s[y+1][x] != '1'){
    
    //cout << y+1 <<"         " <<x <<  endl;
    int ww = 25;
    for(int i = y+1;i < h;i++){
      if(s[i][x] == '3'){
	n = min(n,num);
	return;
      }
      if(s[i][x] == '1'){
	ww = i;
	break;
      }
    }
    if(ww != 25){
      s[ww][x] = '0';
      //cout << ww << endl;
      depth(x,ww-1,s,num);
      s[ww][x] = '1';
    }
    
  }
  }
  return;
  
  
}


int main(){
  
  while(cin >> w >> h,w+h){
    string s[h];
    REP(i,h){
      REP(j,w){
	string r;
	cin >> r;
	s[i] += r;
      }
    }
    n = INF;
    int x,y;
    REP(i,h){
      REP(j,w){
	if(s[i][j] == '2'){
	  x = j;
	  y = i;
	}
      }
    }
    
    depth(x,y,s,0);
    if(n == INF || n > 10)
      cout << -1 << endl;
    else
      cout << n << endl;
  }
  return 0;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define F first
#define S second
#define pss pair<string,string>
#define pcc pair<char,char>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define vs vector<string>
#define vl vector<ll>
#define vs vector<string>
#define vll vector<pll>
#define vss vector<pss>
#define vcc vector<pcc>
#define MP make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define Very_fast std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 2e4+5;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
inline ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll lowbit(ll x){return (x&-x);}
inline ll kissme(ll x,ll y)
{
	ll res=1;
	if(x==0)return 1;
	if(x==1)return y;
	res=kissme(x/2,y);
	res=res*res%mod;
	if(x%2==1)res=res*y%mod;
	return res;
}
int c[N],a[400][N],n,t,day[N];
vector<vi> ans;
int cal(vi x)
{
	int sum=0;
	rep(i,26)day[i]=0;
	rep(i,n)
	{
		sum+=a[i][x[i]];
		day[x[i]]=i+1;
		rep(j,26)
		{
			sum-=(i-day[j]+1)*c[j];
		}
	}
	return sum;
}
void solve()
{
	int mx=-1e9,num=0;
	for(int i=0;i<ans.size();i++)
	{
		int now=cal(ans[i]);
		if(mx<now)mx=now,num=i;
	}
	for(int i=0;i<ans[num].size();i++)cout<<ans[num][i]<<"\n";
	return;
}
signed main()
{
	srand(time(0));
	Very_fast;
	cin>>n;
	for(int i=0;i<26;i++)cin>>c[i];
	rep(i,n)
	rep(j,26)cin>>a[i][j];
	vi v;v.clear();
	rep(i,n)v.pb(i%26+1);ans.pb(v);
	v.clear();
	rep(qwq,100){
	rep(i,n)
	{
		int mx=-1e9,num1=-1,mx2=-1e9,num2=-1;
		rep(j,26)if((i-day[j]+1)*c[j]>mx)mx=(i-day[j]+1)*c[j],num1=j+1;
		rep(j,26)if(mx2<a[i][j])mx2=a[i][j],num2=j;
		int qaq=rand()%2;
		if(qaq)v.pb(num1+1);
		else v.pb(num2+1);
	}
	ans.pb(v);v.clear();
	}
	solve();
	return 0;
}

Measured memory_bytes: 5312
//make sure to make new file!
import java.io.*;
import java.util.*;

public class Main{

   public static long MOD = 1000000007L;
   
   public static void main(String[] args)throws IOException{
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out);
      
      StringTokenizer st = new StringTokenizer(f.readLine());
      
      int n = Integer.parseInt(st.nextToken());
      int m = Integer.parseInt(st.nextToken());
      
      
      long[] psums = new long[n+1];
      long[] ssums = new long[n+1];
      
      psums[0] = 0L;
      ssums[n] = (long)n;
      
      for(int k = 1; k <= n; k++){
         psums[k] = (psums[k-1] + k + MOD)%MOD;
      }
      
      for(int k = n-1; k >= 0; k--){
         ssums[k] = (ssums[k+1] + k + MOD)%MOD;
      }
      
      long answer = 0L;
      for(int k = m; k <= n; k++){
         long min = psums[k-1];
         long max = ssums[n-k+1];
         
         answer = ((answer + max - min + 1 + MOD)%MOD+MOD)%MOD;
      }
      
      
      answer = (answer + 1 + MOD)%MOD;
      
      out.println(answer);
      
      
      
      
      
      
      out.close();
   }
   
      
}

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

int main(){
    const int MOD = 1000000007;
    int N;
    cin >> N;
    bool isEven = N%2 ==0;
    int A[N];

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

    int check[N];
    for(int i=0; i<N; i++){
        check[i] = 2;
    }

    for(int i=0; i<N; i++){
        if(isEven){
            if(A[i] % 2 == 0){
                cout << 0 << '\n';
                return 0;
            }else{
               check[A[i]]--;
               if(check[A[i]]<0) {
                    cout << 0 << '\n';
                    return 0;
               }
            }
        }else{
            if(A[i] % 2 != 0){
                cout << 0 << '\n';
                return 0;
            }else{
               check[A[i]]--;
               if(check[A[i]]<0) {
                    cout << 0 << '\n';
                    return 0;
               }
            }
        }
    }
    if(isEven){
        if(check[0]!=2){
            cout << 0 << '\n';
            return 0;
        }
    }else{
        if(check[0]!=1){
            cout << 0 << '\n';
            return 0;
        }
    }

    int level = N/2;
    int ans = 1;
    for(int i=0; i<level; i++){
        ans = (ans*2)%MOD;
    }
    cout << ans << '\n';



}




Measured memory_bytes: 3892
def sum_of_numbers(n):
    '''
    (* int -> int *)
    '''
    res = [int(n) for n in list(str(n))]
    
    return sum(res)

if __name__ == "__main__":
    while True:
        n = input()
        if n == '0':
            break
        print(sum_of_numbers(n))


Measured memory_bytes: 5624
#include <stdio.h>

int a,b;
long long int MIN = -1;

int x[3010][3010];
long long int check[3010][3010][6];
long long int func(int s, int t, int k)
{
	if(s>a) return MIN;
	if(t>b) return MIN;
	if(k>4) return MIN;
	if(s==a&&t==b) return 0;
	if(check[s][t][k]!=-1) return check[s][t][k];
	
	long long int s1 = func(s+1,t,1);
	long long int s2 = func(s,t+1,k);
	long long int s3 = 0;
	if(x[s][t+1]>0) s3 = func(s,t+1,k+1)+x[s][t+1];
	long long int s4 = 0;
	if(x[s+1][t]>0) s4 = func(s+1,t,2) + x[s+1][t];
	
	long long int M = s1;
	M = M>s2?M:s2;
	M = M>s3?M:s3;
	M = M>s4?M:s4;
	return check[s][t][k] = M;
}
int main()
{
	for(int i=1;i<=17;i++) MIN*=10;
	
	int c;
	scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<=a;i++) for(int j=0;j<=b;j++) for(int k=0;k<=5;k++) check[i][j][k] = -1;
	for(int i=1;i<=c;i++)
	{
		int d,e,f;
		scanf("%d%d%d",&d,&e,&f);
		x[d][e] = f;
	}
	long long int s1 = func(1,1,1);
	long long int s2 = 0;
	if(x[1][1]>0) s2 = func(1,1,2) + x[1][1];
	printf("%lld",s1>s2?s1:s2);
}

Measured memory_bytes: 461028
// start fold
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<cstring>
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
using namespace std;
#define ri register int
#define il inline
#define LL long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define enter putchar('\n')
#define size(x) ((int)x.size())
#define mem0(x) memset(x,0,sizeof(x))
template<class T>il void in(T &x)
{
	x=0; short f=1; char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9') x=x*10+(c^'0'),c=getchar();
	x*=f;
}
template <typename T,typename ...Args>il void in(T &x, Args &...args)
{
	in(x); in(args...);
}
template<class T>il void out(T x,const char c='\n')
{
	static short st[30];
	short m=0;
	if(x<0) putchar('-'),x=-x;
	do st[++m]=x%10,x/=10; while(x);
	while(m) putchar(st[m--]|'0');
	putchar(c);
}
template <typename T,typename ...Args>il void out(const T &x,const Args &...args)
{
	out(x,' '); out(args...);
}
template<class T>il void print(T a[],int n)
{
	if(n<=0) return;
	for(ri i=0; i<n; ++i) out(a[i],' ');
	enter;
}
namespace i207M
{
// end fold
#define N 100005
int n,S;
int pos[N];
LL cnt[N];
signed main()
{
#ifdef M207
	freopen("in.in","r",stdin);
	// freopen("out.out","w",stdout);
#endif
	in(n),in(S);
	for(ri i=1; i<=n; ++i) in(pos[i],cnt[i]);
	int l=1,r=n; LL ans=0;
	while(1)
	{
		if(pos[r]<=S)
		{
			ans+=S-pos[l];
			break;
		}
		if(pos[l]>=S)
		{
			ans+=pos[r]-S;
			break;
		}
		ans+=pos[r]-pos[l];
		if(cnt[l]>=cnt[r])
			while(pos[r]>S&&cnt[l]>=cnt[r]) cnt[l]+=cnt[r--];
		else
			while(pos[l]<S&&cnt[l]<cnt[r]) cnt[r]+=cnt[l++];
	}
	out(ans);
	return 0;
}
// start fold
}
signed main()
{
	i207M::main();
	return 0;
}
// end fold

Measured memory_bytes: 1408
#include <iostream>
#include <cmath>
using namespace std;
template<class T> inline int countbit(T n){return (n==0)?0:(1+countbit(n&(n-1)));}

int shogen[16][16];


bool checkshogen(int pattern, int N) {
	int seijitu[16];
	for (int i = 1; i <= N; i++) {
		seijitu[i] = pattern & 1;
		pattern = pattern >> 1;
	}
	for (int i = 1; i <= N; i++) {
		if (seijitu[i] == 0) continue; // 不誠実なものの言うことは無視
		for (int j = 1; j <= N; j++) {
			if ((shogen[i][j]==1) && (seijitu[j]!=1)) {
				// 正直者が嘘をついている
				return false;
			}
			if ((shogen[i][j]==0) && (seijitu[j]!=0)) {
				// 正直者が嘘をついている
				return false;
			}
		}
	}
	return true;
}


int main(void) {
	int N;
	cin >> N;
	for (int i = 0; i <= N; i++) for (int j = 0; j <= N; j++)
		shogen[i][j]=-1;

	for (int i = 1; i <= N; i++) {
		int A, x, y;
		cin >> A;
		for (int j = 1; j <= A; j++) {
			cin >> x >> y;
			shogen[i][x] = y;
		}
	}

	// 2のN乗のパターンを作る
	// N=15なので間に合う
	int ans = 0;
	unsigned int last = (int)pow(2, N) -1;
	for (unsigned int i = 0; i <= last; i++) {
		// bitが1なら正直者、0なら不誠実とする
		if (checkshogen(i, N)) {
			ans = max(ans, countbit(i));
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

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

  std::vector<std::vector<int> > A;
  for(int i=0;i<2;i++){
    std::vector<int> tmp;
    for(int j=0; j<N; j++){
      int tmpint;
      cin >> tmpint;
      tmp.push_back(tmpint);
    }
    A.push_back(tmp);
  }

  for(int i=0; i<2; i++){
    for(int j=0;j<N;j++){
      if(j==0){
        if(i>0){
          A[i][j] = A[i-1][j] + A[i][j];
        }
      }
      else{
        int cand1;
        if(i==0){
          cand1 = 0;
        }
        else{
          cand1 = A[i-1][j] + A[i][j];
        }
        int cand2 = A[i][j-1] + A[i][j];
        if(cand1 > cand2){
          A[i][j] = cand1;
        }
        else{
          A[i][j] = cand2;
        }
      }
    }
  }

  cout << A[1][N-1] << endl;

  return 0;
}


Measured memory_bytes: 256
import math

A, B, C, D = input().split()

A = int(A)  # 高橋の体力
B = int(B)  # 高橋の攻撃力
C = int(C)  # 青木の体力
D = int(D)  # 青木の攻撃力

E = math.ceil(C/B)  # 高橋の攻撃回数
F = math.ceil(A/D)  # 青木の攻撃回数

if E <= F:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9156
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main()
{
	int n,m;
	cin>>n>>m;
	
	vector<string> a,b;
	
	for(int i = 0;i<n;i++)
	{
		string str;cin>>str;
		a.push_back(str);
	}
	
	for(int i = 0;i<m;i++)
	{
		string str;cin>>str;
		b.push_back(str);
	}
	
	if(m > n)
	{
		cout<<"No"<<endl;
	}
	else
	{
		bool ans = false;
		
		for(int i = 0;i<=n-m;i++)
		{
			for(int j = 0;j<=n-m;j++)
			{
			//	cout<<i<<" "<<j<<endl;
				
				bool is = true;
				for(int l = 0;l<m;l++)
				{
					for(int x = 0;x<m;x++)
					{
						if(a[i+l][j+x] != b[l][x]) is = false;
					}
				}
				
				ans|=is;	
			}
		}
		
		if(ans) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
		
	}
	return 0;
}

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

int main(void){
	int n, m;
	cin >> n >> m;
	vector<int>x(m),y(m),z(m);
	vector<int> a[n];
	for(int i = 0; i < m; ++i){
		cin >> x[i] >> y[i] >> z[i];
		x[i]--; y[i]--;
	}
	for(int i = 0; i < m; ++i){
		a[x[i]].push_back(y[i]);
		a[y[i]].push_back(x[i]);
	}
	vector<int> check(n);
	int ans = 0;
	for(int i = 0; i < n; ++i){
		if(check[i]==0){
			ans++;
			check[i]=1;
			queue<int> q;
			q.push(i);
			while(!q.empty()){
				int now = q.front();
				q.pop();
				for(auto x : a[now]){
					if(check[x]==0){
						check[x] = 1;
						q.push(x);
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8056
Scanf.scanf "%d" (fun d ->
    let c = Array.init 26 (fun _ -> Scanf.scanf " %d" (fun c -> c)) in
    let s = Array.init d (fun _ ->
        Array.init 26 (fun _ ->
            Scanf.scanf " %d" (fun s -> s)))
    in
    let last = Array.make 26 (-1) in
    let f a = a * (a - 1) / 2 in
    for i = 0 to d - 1 do
        let rec loop j mi mx =
            if j = 26 then (last.(mi - 1) <- i; Printf.printf "%d\n" mi) else
                if s.(i).(j) + c.(j) * (i - last.(j)) > mx then loop (j + 1) (j + 1) s.(i).(j)
                                                           else loop (j + 1) mi mx
        in
        loop 0 0 0
    done
)

Measured memory_bytes: 5988
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

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

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

int main() {
	int a, b, c; cin >> a >> b >> c;
	if (a <= c && c <= b)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3520
import Control.Applicative((<$>))
import Data.List(intercalate)

main :: IO ()
main = intercalate ":" . map show . secsToHMS . read <$> getLine >>= putStrLn

secsToHMS :: Int -> [Int]
secsToHMS secs0 =
    let (h, secs1) = secs0 `divMod` 3600
        (m, s) = secs1 `divMod` 60
    in [h, m, s]

Measured memory_bytes: 3628
//#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <utility>
#include <vector>
#include <limits>
#include <cmath>
#include <unordered_map>

typedef long long ll;

typedef struct {
    double length;
    ll div;
} LOG;

int main(int argc, char *argv[])
{
    int n, k;

    std::cin >> n >> k;

    std::vector<LOG> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i].length;
        a[i].div = 1;
    }

    while(k > 0) {
        // 降順ソート
        std::sort(a.begin(), a.end(), [](auto const &lhs, auto const &rhs) {
            return (lhs.length / lhs.div) > (rhs.length / rhs.div);
        });

        int div_add_longest = k / n;
        if (div_add_longest == 0) {div_add_longest = 1;}
        a[0].div += div_add_longest;
        k -= div_add_longest;
        double part_length_longest = a[0].length / a[0].div;

        for (int i = 1; i < a.size(); i++) {
            if (a[i].length / a[i].div <= part_length_longest) {continue;}

            int new_div = a[i].length / part_length_longest;
            if (a[i].length / new_div > part_length_longest) {new_div++;}

            int div_diff = new_div - a[i].div;
            if (div_diff > k) {
                div_diff = k;
            }

            a[i].div += div_diff;
            k -= div_diff;
            if (k == 0) {break;}
        }
    }

#ifdef _DEBUG
    for (int i = 0; i < a.size(); i++) {
        std::cout << a[i].length << " / " << a[i].div << " = " << (a[i].length / a[i].div) << std::endl;
    }
#endif

    double max = a[0].length / a[0].div;
    for(int i = 1; i < a.size(); i++) {
        max = std::max(max, a[i].length / a[i].div);
    }

    std::cout << static_cast<ll>(std::ceil(max)) << std::endl;

    return 0;
}


Measured memory_bytes: 6372
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long x = sc.nextLong();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}
		sc.close();

		long ans = 0;
		if (a[0] + a[1] > x) {
			if (a[0] > x) {
				ans += a[0] - x;
				a[0] = x;
				ans += a[1];
				a[1] = 0;
			} else {
				long d = x - a[0];
				ans += a[1] - d;
				a[1] = d;
			}
		}
		for (int i = 2; i < n; i++) {
			if (a[i - 1] + a[i] > x) {
				long d = x - a[i - 1];
				ans += a[i] - d;
				a[i] = d;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 55908
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;

int main(){
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;

    vector<int> ss(n+1, 0);
    for(int i = 0; i < n; ++i){
        if(s[i] == 'A' && s[i+1] == 'C')
            ss[i+1] = ss[i] + 1;
        else
            ss[i+1] = ss[i];
    }

    for(int Q = 0; Q < q; ++Q){
        int l, r;
        cin >> l >> r;
        --l, --r;
        cout << ss[r] - ss[l] << endl;
    }
    return 0;
}


Measured memory_bytes: 1408