akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {

	/*
	 * 122B - 2nd Solution
	 * 
	 * For every right end point of a substring, we try to find the farthest left end point 
	 * Done so by having a loop to control the right end point 
	 * And then start going away from the right end point one by one
	 * The first if statement is that if the j-th character is not part of ACGT then we can just stop there because going any further won't produce an AGCT string
	 * The else if statement just means that if all the letters before the right end point (including itself) is part of AGCT then [0 ... i] is a possible AGCT string
	 * 
	 * Time Complexity O(N^2), Memory Complexity O(N)
	 * 
	 */
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int N = s.length();
		int ans = 0;
		for(int i = 0; i<N; i++) {
			for(int j = i; j>=0; j--) {
				if(s.charAt(j) != 'A' && s.charAt(j) != 'C' && s.charAt(j) != 'G' && s.charAt(j) != 'T') {
					ans = Math.max(ans, i - j);
					break;
				}
				else if(j == 0) {
					ans = Math.max(ans, i+1);
				}
			}
		}
		System.out.println(ans);
	}
}


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

int main()
{
  string s;
  int n;
  string process, tmp_s;
  int arg1, arg2;
  string arg3;

  cin >> s;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> process >> arg1>> arg2;
    if (process == "print") cout << s.substr(arg1, arg2 - arg1 + 1) << endl;
    else if (process == "reverse") {
      string tmp = s.substr(arg1 , arg2 - arg1 + 1);
      reverse(tmp.begin(), tmp.end());
      s.replace(arg1, arg2 - arg1 + 1, tmp);
    }
    else if (process == "replace") {
      cin >> arg3;
      s.replace(arg1, arg2 - arg1 + 1, arg3);
    }
  }

  return 0;
}


Measured memory_bytes: 3220
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
using ll = long long;
using vl = vector<long long>;
using vs = vector<string>;
using vll = vector<vector<long long>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
int main() {
    ll a, b;
    cin >> a >> b;
    if (a * b % 2 == 0 && a != 1 && b != 1) {
        cout << a * b / 2 << endl;
    }
    else {
        if (a == 1 || b == 1) {
            cout << 1 << endl;
        }
        else {
            cout << a * b / 2 + 1 << endl;
        }
    }
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(void)
{
    int a,b;
    for(int i = 0; i < 4; i++){
    cin >> a >> b;
        switch (a) {
            case 1:
                cout << 6000 * b << endl;
                break;
            case 2:
                cout << 4000 * b << endl;
                break;
            case 3:
                cout << 3000 * b << endl;
                break;
            case 4:
                cout << 2000 * b << endl;
                break;
            
            default:
                break;
        }
    }
}

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


int collect(int x, int K)
{
	int b = K - x;
	return min((2 * x), (2 * b));
}

int main()
{
	int N, K;
	vector<int> v;

	cin >> N >> K;

	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		v.push_back(x);
	}

	int res = 0;
	for (int i = 0; i < N; i++) {
		res = res + collect(v[i], K);
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
  
  int n,k; cin>>n>>k;
  if(k>n*(n-1)/2-(n-1)) {
    cout << -1 << endl;
    return 0;
  }
  vector<vector<int>> a(n);
  for(int i=0; i<n-1; i++){
    a.at(0).push_back(i+1);
    a.at(i+1).push_back(0);
  }
  k = n*(n-1)/2-(n-1)-k;
  cout << k+n-1<<endl;
  int now{1};
  for(int i=0; i<k; i++){
    if(a.at(now).back()==n-1) now++;
    if(a.at(now).back()+1==now){
      a.at(now).push_back(now+1);
      a.at(now+1).push_back(now);
    }
    else {
      int x = a.at(now).back();
      a.at(now).push_back(x+1);
      a.at(x+1).push_back(now);
    }
  }
  for(int i=0; i<n; i++){
    for(auto j:a.at(i)){
      if(i<j) cout <<i+1<<' '<<j+1<<endl;
    }
  }
}



Measured memory_bytes: 3684
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

struct edge {
    ll to, cost;
};

int V;
vector<edge> G[1000000];
ll d[1000000];

void addedge(int st, int ed, ll co) {
    edge e;
    e.to = ed;
    e.cost = co;
    G[st].push_back(e);
}

ll num[1000000];
ll used[1000000];
ll ansnum[1000000];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, 0, N - 1) {
        ll a, b;
        cin >> a >> b;
        addedge(a - 1, b - 1, 0);
        addedge(b - 1, a - 1, 0);
        num[a - 1]++;
        num[b - 1]++;
    }
    ll c[N];
    REP(i, 0, N) {
        cin >> c[i];
    }
    sort(c, c + N);
    priority_queue<plglg, vector<plglg>, greater<plglg> > que;
    REP(i, 0, N) {
        que.push(plglg(num[i], i));
    }
    ll mark = 0;
    fill(used, used + N, false);
    ll ans = 0;
    while (mark < N) {
        while (used[que.top().second]) {
            que.pop();
        }
        plglg p = que.top();
        que.pop();
        ans += c[mark] * p.first;
        ansnum[p.second] = c[mark];
        used[p.second] = true;
        REP(i, 0, G[p.second].size()) {
            edge e = G[p.second][i];
            if (!used[e.to]) {
                num[e.to]--;
                que.push(plglg(num[e.to], e.to));
            }
        }
        mark++;
    }
    cout << ans << endl;
    REP(i, 0, N) {
        cout << ansnum[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 29436
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}


int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	int n;
	cin >> n;
	string s;
	cin >> s;

	for(auto &c : s) c = 'A' + (c - 'A' + n) % 26;

	cout << s << endl;
	
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
#define ve vector
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
// *max_element(all(d))
// priority_queue<int,vector<int>,greater<int>>
int solve(){
  int h,w;
  cin >> h >> w;
  rep(i,h)rep(j,w){
    string tmp;
    cin >> tmp;
    if(tmp == "snuke"){
      char ans = 'A' + j;
      cout << ans;
      cout << i + 1 << endl;
      return 0;
    }
  }
  return 0; 
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

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

namespace Programminng
{
    class AOJ_Volume0009
    {
        public static void Main(string[] args)
        {
             int MAX = 1000000;
             int[] prime = new int[MAX];

             prime[0] = prime[1] = 0;
             for (int i = 2; i < MAX; i++)
             {
                 prime[i] = 1;
             }
             for (int i = 2; i < 1001; i++)
             {
                 if (prime[i] == 1)
                 {
                     for (int j = 2 * i; j < MAX; j += i)
                     {
                         prime[j] = 0;
                     }
                 }
             }
            
            
            while (true)
            {
                var input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) break;

                int number = int.Parse(input);
                int count = 0;

                for (int i = 2; i <= number; i++)
                {
                    count += prime[i];
                }
                Console.WriteLine(count);
            }
        }
    }
}

Measured memory_bytes: 13564
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
#define big 1000000007
long long int pow2(long long int n){
    if(n == 0){
        return 1;
    }
    else{
        return (2 * pow2(n-1))%big;
    }
}
int main(){
    long long int n;
    cin >> n;
    vector <long long int> a(n);
    for(int i = 0;i<n;i++){
        cin >> a[i];
    }
    vector< long long int > aoo(60); 
    for(int i = 0;i<n;i++){
        bitset<60> s(a[i]);
        for(int j = 0;j<60;j++){
            if(s.test(j)==1){
                aoo[j]++;
            }
        }
       // cout << s <<endl;;
    }
    long long int sum=0;
    for(int i = 0;i <60;i++){
        //cout <<"aoo[" <<i << "]=" << aoo[i]<<endl;
        sum += (aoo[i]*(n-aoo[i]))%big*pow2(i);
        sum = sum%big;

    }
    cout <<sum<<endl;
    
}

Measured memory_bytes: 2688
#include <iostream>
using namespace std;
#define MAX 101

int n;
int num[MAX];

int main()
{
	cin >> n;
	for (int i=0; i<n; ++i)
		cin >> num[i];

	for (int i=0; i<n; ++i) {
		if (num[i] % 2 == 0) {
			if (num[i] % 3 != 0 && num[i] % 5 != 0) {
				cout << "DENIED\n";
				return 0;
			}
		}
	}
	cout << "APPROVED\n";

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

vector<int> v;
void solve() {
	int n, q; string s;
	cin >> n >> q;
	cin >> s;
	rep(i, n - 1) {
		if (s[i] == 'A'&&s[i + 1] == 'C') {
			v.push_back(i);
		}
	}
	rep(i, q) {
		int l, r; cin >> l >> r;
		l--; r--;
		int le = lower_bound(v.begin(), v.end(),l) - v.begin();
		int ri = lower_bound(v.begin(), v.end(), r) - v.begin();
		cout << ri - le << endl;
	}
}
int main() {
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 1276
#169A
#A*Bを整数として出力せよ
#1.入力をプログラムで扱えるように受け取ること
a,b = map(int, input().split())
#print(a,b)
#2.受け取った入力値を使って適切に処理（計算）すること
answer = a * b

#3.計算した結果を出力すること
print(answer)

Measured memory_bytes: 9060
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
#define int long long
#define MAXN 100016
#define pii pair<int,int>
#define fi first
#define P 1000000007
#define se second
int n;
int A[MAXN] , B[MAXN];
pii a[MAXN << 1]; int k = 0;
signed main() {
	cin >> n;
	for( int i = 1 ; i <= n ; ++ i ) scanf("%lld",&A[i]) , a[++ k] = make_pair( A[i] , 0 );
	sort( A + 1 , A + 1 + n );
	for( int i = 1 ; i <= n ; ++ i ) scanf("%lld",&B[i]) , a[++ k] = make_pair( B[i] , 1 );
	sort( a + 1 , a + 1 + 2 * n );
	int lef = 0 , res = 1;
	for( int i = 1 ; i <= 2 * n ; ++ i ) {
		if( a[i].se == 0 ) {
			if( lef < 0 ) res *= -lef , res %= P;
			++ lef;
		} else {
			if( lef > 0 ) res *= lef , res %= P;
			-- lef;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 4992
//
// Created by nhatminh2947 on 8/11/19.
//

#include <bits/stdc++.h>

using namespace std;

int n;
map<string, long long> m;

int main() {
    cin >> n;


    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());

        m[s] += 1;
    }

    map<string, long long>::iterator it;

    long long ans = 0;
    for (it = m.begin(); it != m.end(); it++) {
        ans += (*it).second * ((*it).second - 1) / 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <algorithm>
#include <limits.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <math.h>
#define ll long long
#define MSET(x) memset((x), 0, sizeof((x)))
#define MMSET(x) memset((x), -1, sizeof((x)))
#define rep(i, a, b) for ( int (i) = a; (i) < (b) ; ++ (i) )
#define repA(i, a, b) for ( int (i) = a ;  (i) <= (b) ; ++ (i) )
#define repD(i, a, b) for ( int (i) = a; (i) >= (b) ; -- (i) )
#define fi first
#define se second
#define pb push_back
#define mfind(m, item) ((m).find((item)) != (m).end())
#define mp(a,b) make_pair((a),(b))
#define mt(a,b,c) make_pair(make_pair((a),(b)), (c))
#define tfi first.first
#define tse first.second
#define tth second
#define print cout << endl
#define tri pair<pair<int, int>, int>
using namespace std;

int n;
int candies[2][101];
int dp[2][101];

int main(){
    while ( cin >> n ) {
        MSET(candies);
        MSET(dp);
        for ( int j = 0 ; j  <2 ; ++ j ) 
            for ( int i  = 0 ; i < n ; ++ i ) {
                cin >> candies[j][i];
            }
        for ( int j = 0 ; j < 2 ; ++ j ) {
            for ( int i  = 0 ; i < n ;  ++ i  ){
                if ( i == 0 ){
                    if ( j == 0 ) {
                        dp[j][i] = candies[j][i];
                    }
                    else dp[j][i] = candies[0][0] + candies[1][0];
                }
                else {
                    if ( j == 1 ) {
                        dp[j][i] = max(dp[j][i - 1], dp[j - 1][i]) + candies[j][i];
                    }
                    else dp[j][i] = dp[j][i - 1] + candies[j][i];
                }
            }
        }
        cout << dp[1][n - 1] << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Deque;
import java.util.ArrayDeque;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Deque<Integer> deq = new ArrayDeque<Integer>();
        String str = "";
        int a = 0, b = 0;
        while(sc.hasNext()){
        	str = sc.next();
        	if(str.equals("+")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(a + b);
        	}else if(str.equals("-")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b - a);
        	}else if(str.equals("*")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(a * b);
        	}else if(str.equals("/")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b / a);
        	}else{
        		deq.addLast(Integer.parseInt(str));
        	}
        }
        System.out.println(deq.peekLast());
    }
}


Measured memory_bytes: 26296
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int N, W;
	int v[1001];
	int w[1001];
	int dp[101][10001];
	cin >> N >> W;
	fill_n(*dp, 101*10001, 0);
	rep(i, N)cin >> v[i] >> w[i];
	for(int i = 0; i < N; i++){
		for(int j = 0; j <= W; j++){
			if(j < w[i]){
				dp[i+1][j] = dp[i][j];
			}else{
				dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
			}
		}
	}
	FIN(dp[N][W]);

	return 0;
}

Measured memory_bytes: 5112
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n =sc.nextInt();
        int m =sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        int[] c = new int[m];
        int[] d = new int[m];
        for (int i = 0; i < m; i++) {
            c[i] = sc.nextInt();
            d[i] = sc.nextInt();
        }

        for (int i = 0; i < n; i++) {
            int min = Math.abs(a[i] - c[0]) + Math.abs(b[i] - d[0]);
            int minIndex = 0;
            for (int j = 0; j < m; j++) {
                int dis = Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]);
                if (min > dis) {
                    minIndex = j;
                    min = dis;
                }
            }
            System.out.println(minIndex + 1);
        }
    }
}

Measured memory_bytes: 23124
import sys
input = sys.stdin.readline
N = int(input())
p = list(map(int, input().split()))
res = [0] * N
for i in range(N):
  res[p[i] - 1] = 10 ** 9 - N + i + 1

a = [1]
b = [res[0] - 1]
for i in range(1, N):
  if res[i] - a[-1] - 1 >= b[-1]:
    b.append(b[-1] - 1)
    a.append(res[i] - b[-1])
  else:
    a.append(a[-1] + 1)
    b.append(res[i] - a[-1])
print(*a)
print(*b)

Measured memory_bytes: 46000
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    n, m = list(map(int, input().strip().split()))
    print(n * max(0, n-1) // 2 + m * max(0, m-1) // 2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2005;
const int mod=1e9+7;

#define endl "\n"

int dp[N][N];

void solve(int n){
	for(int i=0;i<=n;i++) dp[i][0]=1;
	dp[1][1]=1;
	for(int i=2;i<=n;i++)
		for(int j=1;j<=n;j++)
			dp[i][j]=(1ll*dp[i-1][j]+dp[i-1][j-1])%mod;
}

int C(int n,int m){
	if(n<0||m<0||m>n) return 0;
	return dp[n][m];
}

int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int k,n;
	cin>>n>>k;
	solve(n);
	for(int i=1;i<=k;i++){
		cout<<1ll*C(k-1,i-1)*C(n-k+1,i)%mod<<endl;
		//cout<<1ll*C(k-1,i-1)*(1ll*C(n-k-1,i-2)+C(n-k-1,i-1)+C(n-k-1,i))%mod<<endl;
	}
	return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X, a, b, c, d;
  cin >> X;
  
  a = X / 1000;
  b = (X - 1000 * a) / 100;
  c = (X - 1000 * a - 100 * b) / 10;
  d = X - 1000 * a - 100 * b - 10 * c;
  
  if(a == b && b == c){
    cout << "Yes" << endl;
  }
  else if(b == c && c == d){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

using namespace std;

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

    char last = N.at(N.size() - 1);

    if (last == '3') {
        cout << "bon"<< endl;
    } else if (last == '0' || last == '1' || last == '6' || last == '8') {
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000000000009
#define int long long
using P = pair<int,int>;

signed main(){
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    vint red(n);
    int redcount = 0;
    vint green(n);
    int greencount = 0;
    vint blue(n);
    int bluecount = 0;
    for(int i = s.size()-1;i >= 0;i--){
      if(s[i] == 'R'){
        redcount++;
      }
      red[i] = redcount;
      if(s[i] == 'G'){
        greencount++;
      }
      green[i] = greencount;
      if(s[i] == 'B'){
        bluecount++;
      } 
      blue[i] = bluecount;
    }
    rep(i,n-2){
        for(int j = i+1;j < n-1;j++){
          if(s[i] == 'R' && s[j] == 'G'){
            ans += blue[j + 1];
            if(j + (j-i) < n) if(s[j + (j-i)] == 'B') ans--;
          }
          if(s[i] == 'R' && s[j] == 'B'){
            ans += green[j + 1];
            if(j + (j-i) < n) if(s[j + (j-i)] == 'G') ans--;
          }
          if(s[i] == 'B' && s[j] == 'R'){
            ans += green[j + 1];
            if(j + (j-i) < n) if(s[j + (j-i)] == 'G') ans--;
          }
          if(s[i] == 'B' && s[j] == 'G'){
            ans += red[j + 1];
            if(j + (j-i) < n) if(s[j + (j-i)] == 'R') ans--;
          }
          if(s[i] == 'G' && s[j] == 'R'){
            ans += blue[j + 1];
            if(j + (j-i) < n) if(s[j + (j-i)] == 'B') ans--;
          }
          if(s[i] == 'G' && s[j] == 'B'){
            ans += red[j + 1];
            if(j + (j-i) < n) if(s[j + (j-i)] == 'R') ans--;
          }
        }
    }
    if(n > 2) cout << ans << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define fi first
#define se second
const ll mod = 1e9+7;
const int N = 1e5+5;
void solve(){
	int n; 
	cin>>n; 
	int nn =n; 
	int sm = 0;
	while(nn){
		sm+=nn%10;
		nn/=10;
	}
	if(n%sm==0){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
const int INF = 1e9;
const int MAX = 100000;
const long long LINF = 1e18;


int gcd(int x,int y){
  int r = 1;
  while(r != 0){
    r = x % y;
    x = y;
    y = r;
  }
  return x;
}


int main(){
  int N;cin >> N;
  vector<int>A(N);
  for(int i = 0; i< N; i++){
    cin >>A[i];
  }
  sort(A.begin(),A.end());
  int ans = INF;
  int GCD = 0;
  for(int i = 0; i < N-1; i++){
    GCD = gcd(A[i],A[i+1]);
    ans = min(ans,GCD);
  }
  cout << ans << endl;
}
  


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

int main()
{
	std::string s_before;
	std::string s_after;

	std::getline(std::cin, s_before);

	s_after = s_before;
	std::transform(s_before.begin(), s_before.end(), s_after.begin(), toupper);

	for (unsigned int i = 0; i < s_after.length(); i++) {
		if (s_before[i] == s_after[i]) {
			std::transform(s_after.begin() + i, s_after.begin() + (i + 1), s_after.begin() + i, tolower);
		}
	}

	std::cout << s_after << std::endl;

}

Measured memory_bytes: 1184
import java.io.*
import java.util.*

fun solve(N: Long, M: Long){
    println(listOf(N-2, M-2).map{ Math.abs(it) }.reduce{ a,b -> a*b })
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toLong()
    val M = sc.next().toLong()
    solve(N, M)
}


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


#define fast_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
typedef long long int lli;
typedef long long ll;
typedef long double ld;


signed main(){
    fast_IO;
    int t=1;
    //cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        int a[n];
        for(int i=0;i<n;i++)
            cin>>a[i];
        sort(a,a+n);
        ll sum=0;
        for(int i=0;i<k;i++){
            sum+=a[i];
        }
        cout<<sum;
    }   
    return 0;
}


Measured memory_bytes: 3652
n=int(input())
l=[0]*n

for i in range(1,n+1):
    b=2
    while b <= i:
        while i%b==0:
            i = i//b
            l[b-1]+=1
        b+=1
x=1
for i in l:
    if i != 0:
        x=x*(i+1)%(10**9+7)
print(x)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    String s = sc.next();
    long k = sc.nextLong();

    for (int i = 0; i < Math.min(k, s.length()); i++) {
      if (s.charAt(i) != '1') {
        System.out.println(s.charAt(i));
        return;
      }
    }

    System.out.println(1);

  }
}

Measured memory_bytes: 35596
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>
#include <algorithm>
#define INF 1000000000
#define LM 55555
using namespace::std;


long long bc, now, C, H, W, X, Y, N,M, ans, r,l;



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

	if (N + M == 15)
	{
		cout << "+" << endl;
		return 0;
	}
	if (N*M == 15) {
		cout << "*" << endl;
		return 0;
	}

	cout << "x" << endl;
	return 0;

}




Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split(' ')))
br = 'False'
count = 0
while True:
  count += 1
  if not (a[-1] == 0) | (br == 'True'):
    for i in range(n):
      if a[i]%2 == 1:
        br = 'True'
        count -=1
        break
      else:
        a[i] = int(a[i]/2)

  else:
    count -= 1
    break


print(count)



Measured memory_bytes: 3060
#include <stdio.h>
int main()
{
  char a[3];
  for(int i=0;i<3;i++)
  scanf("%c",&a[i]);
  int flag=0;
  for(int i=0;i<2;i++)
  {
    if(a[i]!=a[i+1])
      flag=1;
  }
  if(flag)
    printf("Yes");
  else
    printf("No");
}

Measured memory_bytes: 128
def solution():
	a = raw_input()
		
	aIdx = 0
	zIdx = 0
	maxLength = 0
	hasSet = False
	for i in range(len(a)):
		if a[i] == 'A' and not hasSet:
			aIdx = i
			hasSet = True
		
		if a[i] == 'Z':
			zIdx = i 

	print zIdx - aIdx + 1

solution()
		

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
template<typename T> bool chmin(T& a, const T& b) {
  if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
  if (a < b) return a = b, true; else return false;
}

int top(int n){
  while(n >= 10){
    n /= 10;
  }

  return n;
}


void solve(){
  int N;
  cin >> N;

  int table[10][10] = {};

  REP(i, 1, 10){
    REP(j, 1, 10){
      REP(k, 1, N+1){
        if(k % 10 == j && top(k) == i)
          table[i-1][j-1]++;
      }
    }
  }

  ll ans = 0;
  rep(i,9){
    rep(j,9){
      ans += table[i][j] * table[j][i];
    }
  }

  cout << ans << endl;
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

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

int main() {
  long long n,m,d;
  cin>>n>>m>>d;
  cout << fixed << setprecision(8);
  double ans=1.000000*(n-d)/n*(m-1)/n;
  if(d!=0)ans*=2;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
		int c = scn.nextInt();

		int sum = a + b + c;

		if (sum >= 22) {
			System.out.println("bust");
		} else {
			System.out.println("win");
		}
	}
}

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

const int MAX = 1001;

struct edge{
  int n,cost;
  edge(int n=0, int c=0):n(n),cost(c){}
};

int n;
vector<edge> G[MAX];
bool af[MAX];

int func(int pos, int par){
  int sum = 0;

  for(int i=0;i<G[pos].size();i++){
    int next = G[pos][i].n;
    int cost = G[pos][i].cost;
    if(next == par) continue;
    if(af[next]) sum += cost;
    else sum += min(cost, func(next, pos));
  }

  return sum;
}

void solve(){
  cout << func(0,-1) << endl;
}

int main(){
  while(cin >> n){
    for(int i=0;i<n;i++) G[i].clear();
    fill(af,af+n,false);
    for(int i=1;i<n;i++){
      int x;
      cin >> x;
      if(x > 0) af[i] = true;
    }
    for(int i=0;i<n-1;i++){
      int a,b,c;
      cin >> a >> b >> c;
      G[a].push_back(edge(b,c));
      G[b].push_back(edge(a,c));
    }
    solve();
  }
}

Measured memory_bytes: 1252
n = gets.to_i
s = gets.split( " " ).map { |val| val.to_i }
q = gets.to_i
t = gets.split( " " ).map { |val| val.to_i }

cnt = 0
for i in ( 0 ... q )
	low = 0
	high = n - 1
	while low <= high
		m = ( low+high )/2
		if t[i] < s[m]
			high = m - 1
		elsif s[m] < t[i]
			low = m + 1
		else t[i] == s[m]
			cnt += 1
			break
		end
	end
end

puts( cnt )

Measured memory_bytes: 15568
#define  _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <math.h>
#include <queue>
#include<memory>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <bitset>
#include<list>
#include <iomanip>
using namespace std;
typedef long long ll;
int m[200005];
void go()
{
	m[0] = 1;
	m[1] = 1;
	for (int i = 2; i < 40000; i++)
	{
		for (int j = i * i; j < 10000; j += i)
		{
			m[j] = 1;
		}
	}
}
int dp[(int)1e6+9];
int n;
int q[1000005];

int solve(int index) {
	if (index + 1  == n)return 0;
	if (index >= n)return 1e8;
	int &re = dp[index];
	if (re != -1)return re;
	return re = min(abs(q[index] - q[index + 1]) + solve(index + 1), abs(q[index] - q[index + 2]) + solve(index + 2));
}

int main()
{

	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	memset(dp, -1, sizeof dp);
	int x;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> q[i];
	}
	cout << solve(0) << endl;;
	return 0;
}

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

int main() {
    unsigned long N, K;
    cin >> N >> K;
    K *= 2;
    long double ans = 0;
    for(unsigned long i = 1; i <= N; ++i){
        auto j = i;
        long double p = 1;
        while((j *= 2) < K)p /= 2;
        ans += p;
    }
    printf("%.12Lf\n", ans / N);
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
from sys import maxsize


def main() -> int:
    n = next_int()
    lowest = maxsize
    highest = 0

    for _ in range(n):
        ai = next_int()
        lowest = min(lowest, ai)
        highest = max(highest, ai)

    print(highest - lowest)
    return 0


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#coding: utf-8
import math

a, b, C = (float(i) for i in input().split())
C = math.pi * C / 180
S = a * b * math.sin(C) / 2
h = b * math.sin(C)
L = a + b + math.sqrt(a**2 + b ** 2 - 2 * a * b * math.cos(C))

print("{:.8f}".format(S))
print("{:.8f}".format(L))
print("{:.8f}".format(h))



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

int main(){
	char ch[5];
	for(int i = 0;i<4;i++){
		cin >> ch[i];
	}
	int count = 0;
	for(int i =0;i< 4;i++){
		for(int j = i+1;j < 4;j++){
			if(ch[i] == ch[j]){
				count++;
			}
		}
	}
	if(count == 2){
		cout << "Yes";
	}else{
		cout << "No";
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    set<char> ans;
    rep(i, (int)s.size()) ans.insert(s[i]);
    for(char c = 'a'; c <= 'z'; c++){
        if(ans.find(c) == ans.end()){
            cout << c << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}

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

#define ll long long
#define all(it) it.begin(), it.end()
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPU(i, a, b, s) for(int i = a; i < b; i += s)
#define REPD(i, a, b, s) for(int i = a; i > b; i -= s)
#define endl "\n"

ll INF = 2e18;
ll MOD = 1e9 + 7;
int i, j, k, t;

int f(int x) {
    if(x % 2 == 0) {
        return x / 2;
    } else {
        return 3 * x + 1;
    }
}
int main() {
    int s;
    cin >> s;

    int now, next;
    unordered_map<int, int> m;
    now = s;
    m[s] = 1;

    REPU(i, 2, 1000001, 1) {
        next = f(now);
        if(m.find(next) == m.end()) {
            m[next] = 1;
        } else {
            cout << i << endl;
            exit(0);
        }
        now = next;
    }
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <math.h>
#define pai 3.14159265
int main(int argc, char const *argv[])
{
  double a,b,x;
  double t,at;
  scanf("%lf%lf%lf",&a,&b,&x);
  double c=a*a*b;
  if(x>(c/2)){
    t=2*(c-x)/(a*a*a);
  }else{
    t=b*b*a/(2*x);
  }
  at=atan(t)*180/pai;
  printf("%0.10lf",at);
  return (0);
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline void write(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
struct node
{
	int x,y;
}a[100010];
bool cmp(node a,node b)
{
	if(a.y==b.y)return a.x<b.x;
	else return a.y<b.y;
}
int fa[100010],cnt[100010],num[100010];
inline int findfa(int x)
{
	if(fa[x]!=x)fa[x]=findfa(fa[x]);
	return fa[x];
}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read();
    for(int i=1;i<=n;i++)a[i].x=read(),a[i].y=read();
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;i++)
    {
    	if(!num[a[i].x])num[a[i].x]=1,fa[a[i].x]=a[i].x;
    	if(a[i].y==a[i-1].y)
    	{
    		int fx=findfa(a[i].x),fy=findfa(a[i-1].x);
    		if(fx!=fy)fa[fy]=fx,num[fx]+=num[fy],cnt[fx]+=cnt[fy];
    	}
    	if(a[i].y!=a[i+1].y){int f=findfa(a[i].x);cnt[f]++;}
    }
    long long ans=0;
    for(int i=1;i<=100000;i++)if(findfa(i)==i)ans+=1LL*cnt[i]*num[i];
    printf("%lld\n",ans-n);
   	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define ll long long
#define int long long
#define sz(c) c.size()
#define fr first
#define sc second
#define pb push_back
#define sz(c) c.size()
#define ppb  pop_back
#define all(a)      (a).begin(),(a).end()
#define rep(i,a,n)   for( int i=a ; i<n ; i++)
#define U 1000000007
#define N 100005
#define ins insert
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(false);
    int k,ans=0;
    cin>>k;
    rep(i,1,k+1){
        rep(j,1,k+1){
            rep(u,1,k+1){
                int z = __gcd(i,j);
                z= __gcd(z,u);
                ans+=z;
            }
        }
    }
    cout<<ans;



}

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

using ll = long long;
using P = pair<int, int>;
using PP = pair<int, P>;
#define rep1(i,n) for (int i=1; i<=n; i++)
#define rep0(i,n) for (int i=0; i<n; i++)
#define chmin(a,b) if ((a)>(b)) { a=(b); }
#define chmax(a,b) if ((a)<(b)) { a=(b); }
#ifdef _DEBUG
string _format(string args) { string r = "", t; istringstream s(args); while (getline(s, t, ',')) r += t+":%d "; return r + "\n"; }
#define debug(...) do{printf(_format(#__VA_ARGS__).c_str(), __VA_ARGS__);}while(0)
#else
#define debug(...) do{}while(0)
#endif

int main() {
    std::ios::sync_with_stdio(false); std::cin.tie(nullptr); // disable when using stdio
    int n, m;
    cin >> n >> m;
    rep0(i,m) {
        int a;
        cin >> a;
        n -= a;
    }

    cout << ((n<0) ? -1:n) << endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <climits>

//ここからはじめあます
using namespace std;

int dp[2][1 << 22];

int main(void){
	while(1){
		int n, m; cin >> n >> m;
		if(!n && !m) break;

		int b[505][505]={0};
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				char c; cin >> c;
				b[i][j] = c - '0';
			}
		}

		int ans = 0;
		if(n <= 22){
			int S = 1 << n;
			for(int i=0; i<S; i++){
				int cnt = 0;
				int ingredient[501]={0};//材料
				for(int j=0; j<n; j++){
					if((i & (1<<(j))) == 0) continue;
					cnt++;
					for(int k=0; k<m; k++) ingredient[k] ^= b[j][k];
				}
				bool flag = true;
				for(int j=0; j<m; j++){
					if(ingredient[j] == 1){
						flag = false;
						break;
					}
				}
				if(flag) ans = max(ans, cnt);
			}
		}else{
			int B[501]={0};
			for(int i=0; i<n; i++){
				for(int j=0; j<m; j++){
					B[i] |= (b[i][j] << j);
				}
			}

			int S = 1 << m;
			fill(dp[0], dp[2], INT_MIN);
			dp[0][0] = 0;
			for(int i=0; i<n; i++){
				for(int j=0; j<S; j++){
					dp[(i+1)%2][j^B[i]] = max(dp[(i+1)%2][j^B[i]], dp[i%2][j] + 1);
					dp[(i+1)%2][j] = max(dp[(i+1)%2][j], dp[i%2][j]);
				}
			}
			ans = dp[n%2][0];
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 36816
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
int main () {
  string s;
  cin>>s;
  rep(i, 3){
    if(s[i] == s[i+1]) {
      cout<<"Bad"; return 0;
    }
  }
  cout << "Good";
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int f=0,s=0,t;
	for(int i=0;i<3;i++){
		cin >> t;
		if(t==5)f++;
		if(t==7)s++;
	}

	if(f==2&&s==1){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}

return 0;
}

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

int main(){
	/*input*/
	int n;	cin >> n;
	long double* x = new long double[n];
	char** u = new char*[n];
	for(int i = 0; i < n; i++){
		u[i] = new char [3];
	}
	for(int i = 0; i < n; i++){
		cin >> x[i] >> u[i];
	}
	/*calculation*/
	long double o = 0.0;
	for(int i = 0; i < n; i++){
		if(/*u[i] == "JPY"*/u[i][0] == 'J'){
			o+=x[i];
		}else if(/*u[i] == "BTC"*/u[i][0] == 'B'){
			o+=x[i] * 380000.0;
		}
	}

	/*output*/
	cout << o << endl;
	delete[] x;
	for(int i = 0; i < n; i++){
		delete[] u[i];
	}
	delete[] u; 
}


Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n,a[100000],cnt=0,sum,max=0,ka[100000]={};
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n-1;i++){
    if(a[i]!=a[i+1]){
      ka[cnt]++;
      if(i==n-2)ka[cnt]++;
    }
    else if(i>0&&a[i-1]==a[i]&&a[i]==a[i+1]){
      ka[cnt]++;
      cnt++;
    }
    else {
      ka[cnt]++;
      cnt++;
      if(i==n-2)ka[cnt]++;
    }
  }
  if(cnt==0)max=ka[0];
  else if(cnt==1)max=ka[0]+ka[1];
  else for(int i=0;i<cnt-1;i++){
      sum=ka[i]+ka[i+1]+ka[i+2];
      if(sum>max)max=sum;
    }
  printf("%d\n",max);
  return 0;
}  

Measured memory_bytes: 3980
#include<iostream>
#include<string>
#include <vector>
#include <algorithm> 
#include <list>

using namespace std;

int main(){
   long x;
   long a =100;
  cin >> x;
  for(long i = 1;;i+=1){
    a =1.01*a;
    if(a>=x){
      cout<<i;
      return 0;
      break;
    }
  }
}

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

int main() {
  int K;
  cin >> K;
  int x = 7 % K;
  srep(i, 1, K + 1) {
    if (x == 0) {
      cout << i << endl;
      return 0;
    }
    x = (x * 10 + 7) % K;
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 3648
S = input()

count = 1
answer = [0] * len(S)
# RLの切り替わるインデックスをマーク
n = 0
for i in range(len(S) - 1):
    if (S[i] == S[i + 1]):
        count += 1
    else:
        if (S[i + 1] == 'R'):
            # Lを割り振る
            answer[n] += count // 2
            answer[n + 1] += -(-count // 2)
            count = 1
        else:
            # Rを割り振る
            answer[i] += -(-count // 2)
            answer[i + 1] += count // 2
            count = 1
            n = i
    # 右端のLを割り振る
    if (i == len(S) - 2):
        answer[n] += count // 2
        answer[n + 1] += -(-count // 2)

for i, c in enumerate(answer):
    print(c, end='')
    print(' ', end='')


Measured memory_bytes: 5516
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
ll toll(char a[],int n)
{
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        ans = ans * 10;
        ans = ans + (a[i] - '0');
    }
    return ans;
}
int Sn(char a[],int n)
{
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        ans = ans + (a[i] - '0');
    }
    return ans;
}
int main()
{
    char a[100];
    scanf("%s",a);
    int len = strlen(a);
    ll N = toll(a,len);
    int sn = Sn(a,len);
    printf("%s\n",N%sn==0?"Yes":"No");

    return 0;
}


Measured memory_bytes: 256
N = int(input())
arr = list(map(int, input().split(' ')))

for i in range(N - 2, -1, -1):
    if arr[i] > arr[i + 1]:
        arr[i] -= 1
        if arr[i] > arr[i + 1]:
            print('No')
            break
else:
    print('Yes')


Measured memory_bytes: 14396
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
    while(1)
    {
        int n = 0;
        while(1)
        {
            char c;
            cin.get(c);
            if(c == '\n')
            {
                break;
            }
            n += atoi(&c);
        }
        if(n != 0)
        {
            cout << n << endl;
        }
        else
        {
            return 0;
        }
    }

}

Measured memory_bytes: 1140
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    char a; cin >> a;
    if(islower(a)) return 'a';
    else return 'A';
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<char>() << endl;
    return 0;
}


Measured memory_bytes: 3608