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

//LIFE IS NOT A PROBLEM TO BE SOLVED

using namespace std;

#define rep(i,a,b) for(int i = int(a); i < int(b) ; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

typedef long long int ll;
typedef pair < ll, ll > ii;

bool cmp(ii a, ii b){
	return a.S > b.S;
}


int main(){
	
	ll n, h, maior = 0; cin >> n >> h;
	ii v[n];
	rep(i, 0, n) cin >> v[i].F >> v[i].S, maior = max(maior, v[i].F);
	
	sort(v, v+n, cmp);
	
	ll ini = 0, fim = 1000000000, mid, ans = 0;
	while(ini<=fim){
		mid = (ini+fim)/2;
		ll cnt = 0, dano = 0;
		rep(i, 0, n){
			if(cnt==mid) break;
			if(v[i].S>maior){
				dano+=v[i].S;
				cnt++;
			}
		}
		dano+=(mid-cnt)*maior;
		if(dano>=h){
			ans = mid;
			fim = mid-1;
		}else{
			ini = mid+1;
		}
	}
	
	cout << ans << '\n';
	
	
	return 0;
}

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

int main(void) {
	int team_score[100 + 1] = {};
	int point[30 + 1] = {};
	int p, s, q;
	
	while(scanf("%d,%d", &p, &s) != EOF) {
		if(p == 0 && s == 0)   break;
		team_score[p] = s;
		++point[s];
	}
	
	while(cin >> q) {
		int rank = 0;
		s = 30;
		while(team_score[q] <= s) {
			if(point[s] != 0) {
				++rank;
			}
			--s;
		}
		cout << rank << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3124
k,n = map(int,input().split())
s =  list(map(int, input().split()))
s.append(s[0]+k)

dist = 0
num = 0
for i in range(n):
    temp = s[i+1] - s[i]
    if temp > dist:
        dist = temp

print(k - dist)
    


Measured memory_bytes: 26444
/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 六  4/28 20:02:57 2018
 * Ended  Time*  : 六  4/28 20:06:05 2018
*********************************************/

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
map<LL, LL> cnt;
const int MAXN = 2e5;

int n;
int a[MAXN+5];


int main()
{
	scanf("%d", &n);
	LL sum = 0LL, ans = 0LL;
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		sum = sum + (LL)a[i];
		if(sum == 0LL) ans++;
		ans += cnt[sum];
		cnt[sum]++;
	}
	printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
 
#define pb insert
#define eb emplace_back
#define ff first
#define ss second
typedef long long int ll;
typedef long double ld;
 
#define all(a) a.begin(), a.end()
#define show(x) cerr <<#x <<" is "<<x<<"\n"
#define show2(x,y) cerr <<#x <<" "<< #y<< " "<<x<<" "<<y<<"\n"
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pp;
typedef vector<pp> vp;
typedef map<pp, ll> ipi;
typedef map<pp, char> ipc;
typedef map<ll, ll> ii;
typedef set<ll> sl;
typedef multiset<ll> msl;
typedef map<char, ll> ci;
typedef set<pair<ll, ll>> sp;
const ll mod = 1e9+7;
const ll N=2e6+1;


//main func
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	ll t;cin>>t;
	msl s;
	vl v(t);
	for(int i=0;i<t;i++){
	    ll k;cin>>k;
	    s.pb(k);
	    v[i]=k;
	}
	
	for(int i=0;i<t;i++){
	    auto it=s.find(v[i]);
	    if(it!=s.end()){
	        s.erase(it);
	    }
	    cout<<*--s.end()<<"\n";
	    s.pb(*it);
	}
	return 0;
}

Measured memory_bytes: 12544
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define CLR(a) memset(a,0,sizeof(a))
#define DBG(x) cout<<(#x)<<"="<<x<<endl
#define FOR(i,a,b)  for(int i=(a);i<(b);i++)
#define REP(i,a,b)  for(int i=(a);i<=(b);i++)
#define DOWN(i,a,b) for(int i=(a);i>=(b);i--)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const double eps=1e-8;
const int INF=0x3f3f3f3f;
const ll LL_INf=0x3f3f3f3f3f3f3f3f;
const ll mod=1000000009;
const int N=4000;

int h,w,d;
int x[N*N],y[N*N];
int magic[N*N];
int a[N][N];

int main(){
	cin>>h>>w>>d;
	REP(i,1,h) {
		REP(j,1,w){
			scanf("%d",&a[i][j]);
			x[a[i][j]]=i;
			y[a[i][j]]=j;
		}
	}

	REP(i,1,d) magic[i]=0;
	REP(i,d+1,h*w){
		magic[i]=magic[i-d]+abs(x[i]-x[i-d])+abs(y[i]-y[i-d]);
	}
	int q,l,r;
	scanf("%d",&q);
	while(q--){
		scanf("%d%d",&l,&r);
		if (l<=d) cout<<magic[r]<<endl;
		else cout<<magic[r]-magic[l]<<endl;
	}
	//cout<<1.*clock()/CLOCKS_PER_SEC<<"ms"<<"\n";
	return 0;
}

Measured memory_bytes: 12032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const int N = 3e5+6;
const int mod = 1e9+7;
const int inf = 1e8;
void solve(){
    ll k;
    cin>>k;
    ll st = 100;
    for(int i=0;i<=40000;i++){
        if(st>=k){
            cout<<i<<endl;
            return ;
        }
        ll interst = st*0.01;
        st+=interst;
    }
    exit(-1);
}
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: 3648
from collections import defaultdict


def main():
    num_city, num_tarin, num_q = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(num_tarin)]
    dp = [[0 for i in range(num_city)] for j in range(num_city)]
    for i in range(num_tarin):
        x, y = data[i]
        dp[x- 1][y - 1] += 1
    # print(dp)
    for i in range(num_city):
        for j in range(max(1, i), num_city):
            dp[i][j] += dp[i][j - 1]

    # print(dp)

    for i in range(num_q):
        x, y = map(int, input().split())
        kari = 0
        for j in range(x, y + 1):
            kari += dp[j - 1][y - 1]
        print(kari)




if __name__ == '__main__':
    main()


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

int main(){
    char c;
    cin >> c;
    string ans = "vowel"; 
    if (c == 'a') {
    } else if ( c == 'i') {
    } else if ( c == 'u') {
    } else if ( c == 'e') {
    } else if ( c == 'o') {
    } else {
        ans = "consonant";
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long LL;

#define MAXN 100005
#define MAXM 500005

int n, q;
int e[MAXN], ans[MAXN];
string qr[MAXN];
vector<int> qs[MAXN];

int ne[MAXM][26], L = 1;
int co[MAXM];
vector<int> ed[MAXM];

int cnt[26][27];

void ff(int x) {
  for (auto& i: ed[x]) {
    for (auto& q: qs[i]) {
      string s = qr[q];
      int T = 0;
      for (int j = 0; j < 26; j += 1) {
        for (int k = 0; k < j; k += 1) T += cnt[s[j] - 'a'][s[k] - 'a'];
        T += cnt[s[j] - 'a'][26];
      }
      ans[q] = T;
    }
  }
  for (int i = 0; i < 26; i += 1) {
    if (!ne[x][i]) continue;
    for (int j = 0; j < 26; j += 1) {
      if (i == j || !ne[x][j]) continue;
      cnt[i][j] += co[ne[x][j]];
    }
    cnt[i][26] += (int)(ed[x].size());
    ff(ne[x][i]);
    for (int j = 0; j < 26; j += 1) {
      if (i == j || !ne[x][j]) continue;
      cnt[i][j] -= co[ne[x][j]];
    }
    cnt[i][26] -= (int)(ed[x].size());
  }
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i += 1) {
    string s; cin >> s;
    int nw = 0;
    for (int j = 0; j < (int)(s.length()); j += 1) {
      int c = s[j] - 'a';
      if (ne[nw][c] == 0) {
        ne[nw][c] = L;
        L += 1;
      }
      nw = ne[nw][c];
    }
    e[i] = nw;
    co[nw] += 1;
    ed[nw].push_back(i);
  }
  cin >> q;
  for (int i = 0; i < q; i += 1) {
    int x;
    cin >> x >> qr[i];
    x -= 1;
    qs[x].push_back(i);
  }
  for (int i = L - 1; i >= 0; i -= 1) {
    for (int j = 0; j < 26; j += 1) {
      if (ne[i][j]) co[i] += co[ne[i][j]];
    }
  }
  ff(0);
  for (int i = 0; i < q; i += 1) printf("%d\n", ans[i] + 1);
  return 0;
}


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

int main(void){
  int n,m,x[100000],dif[99999],sum = 0;
  cin >> n >> m;
  for(int i = 0; i < m; i++)cin >> x[i];
  sort(x,x + m);
  for(int i = 0; i < m - 1; i++)dif[i] = x[i + 1] - x[i];
  sort(dif,dif + m - 1);
  for(int i = 0; i < m - n; i++)sum += dif[i];
  cout << sum << endl;
  return 0;
}

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

int main() {
    int x,y,z;
    cin>>x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout<<x<<" "<<y<<" "<<z<<endl;
}


Measured memory_bytes: 256
import re
S=input().replace("?", ".")
T=input()
ans=[]
moji = len(T)
for i in range(len(S)-len(T)+1):
  m = re.search(S[i:moji+i], T)
  if m is not None:
    ans.append((S[0:i] + T + S[i+moji:]).replace(".", "a"))

if ans:
  print(sorted(ans)[0])
else:
  print("UNRESTORABLE")

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    string s;cin>>s;
    int n = SIZE(s);

    int result = 0;
    int n0 = 0;
    int n1 = 0;
    REP(i,n){
        if(n0 == 0 && n1 == 0){
            if(s[i]=='1'){
                n1++;
            }
            else{
                n0++;
            }
        }
        else if(n0 == 0){
            if(s[i]=='1'){
                n1++;
            }
            else{
                result += 2;
                n1--;
            }
        }
        else if(n1 == 0){
            if(s[i]=='1'){
                result += 2;
                n0--;
            }
            else{
                n0++;
            }
        }
        else{
            if(s[i]=='1'){
                result += 2;
                n0--;
            }
            else{
                result += 2;
                n1--;
            }

        }
    }
    cout<<result<<endl;
    
	return;
}

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

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

int main(){
    int N, M; cin >> N >> M;
    vector<pair<int,int>> work;
    int a, b;
    while(cin >> a >> b){
        work.push_back(make_pair(b,a));
    }
    sort(work.begin(),work.end());
    reverse(work.begin(),work.end());
    long long ans = 0;
    set<int> sche;
    auto itr = work.begin();
    for( int i = 1; i <= M; i++ ) sche.insert(i);
    while( !(sche.empty()) && itr != work.end() ){
        auto now = sche.lower_bound((*itr).second);
        if( now != sche.end() ){
            ans += (*itr).first;
            sche.erase(*now);
        }
        itr++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5748
n,m,d = gets.chomp.split.map(&:to_i)

# 例えば2 3 1として
# [1,2]と[1,2]の組み合わせによる美しさの平均値＊３(m)

if d == 0
  beautify_sum = n
elsif d+1 <= n-d
  beautify_sum = 2*n-2*d
else
  beautify_sum = 2*d-n+2
end
ans = beautify_sum*1.0*(m-1)  / n**2

puts ans

# ary1.each do |i|
#   ary1.each do |j|
#     p [i,j]
#     if (i-j).abs == d
#       beautify_sum += 1
#     end
#   end


Measured memory_bytes: 1788
#include<stdio.h>
#include<math.h>
int main(void){
	int score[1000]={0};
	int i = 0, j, n;
	double s, sum = 0.0, av = 0.0;
	
	while(1){
		sum = 0.0, av = 0.0;
		scanf("%d", &n);
		if(n == 0){
			break;
		}else{
			for(i=0; i<n; i++){
				scanf("%d", &score[i]);
			}
		}
	
	for(i=0; i<n; i++){
	av += score[i]*1.0/n; 
	}
	
	for(i=0; i<n; i++){
	sum += (score[i]*1.0-av)*(score[i]*1.0-av)/n; 
	}
	printf("%lf\n", sqrt(sum));
	}
return 0;
}

Measured memory_bytes: 636
# ARC086C - Not so Diverse (ABC081C)
from collections import Counter


def main():
    n, k = list(map(int, input().rstrip().split()))
    A = sorted(Counter(map(int, input().split())).values(), reverse=True)
    print(sum(A[k:]))


if __name__ == "__main__":
    main()

Measured memory_bytes: 41500
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n;  cin >> n;
    int *d = new int[n];
    for (int i = 0; i < n; i++)
        cin >> d[i];
    sort(d, d+n);
    cout << d[n/2] - d[n/2-1] << endl;
    return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x%p;
		x = x * x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	int t = c - b;
	if (t > 0) {
		if (t > a) {
			cout << b + c - (t - a) + 1 << endl;
		}
		else {
			cout << b + c << endl;
		}
	}
	else {
		cout << b + c << endl;
	}
}

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


int main() {

    int d, n;
    cin >> d >> n;
    if (d == 0) {
        if (1 <= n && n <= 99) cout << n << endl;
        else cout << 101 << endl;
    } else if (d == 1) {
        if (1 <= n && n <= 99) cout << n * 100 << endl;
        else cout << 10100 << endl;
    } else {
        if (1 <= n && n <= 99) cout << n * 10000 << endl;
        else cout << 1010000 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import numpy as np

n = int(input())
a = input().split()
npa=np.array(a, dtype=int)

npa1=np.sort(npa)[::-1]

ninzuu=n-1
if (ninzuu % 2 != 0):
  ninzuu2=int((ninzuu-1)/2)
  atai=npa1[0]+sum(npa1[1:ninzuu2+1])*2
else:
  ninzuu2=int((ninzuu)/2)
  atai=npa1[0]+sum(npa1[1:ninzuu2])*2+npa1[ninzuu2]

print(atai)

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

typedef long long ll;
typedef long double ld;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN
#define INF         100000000000000000
#define PI          3.1415926535897932384626433832795l



#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)






// struct mycomp {
//     bool operator() (const pair<int,int> &a, const pair<int,int> &b) const{
//         if (a.second-a.first != b.second-b.first)
//         return (a.second-a.first > b.second-b.first);
//         return a.first < b.first;
//     }
// };



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


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}

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

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

	int n;
	cin>>n;
	string s;
	cin>>s;
	if(int(s.size())>n)
	{
		string z = s.substr(0, n);
		z+="...";
		cout<<z<<endl;
	}
	else{
		cout<<s<<endl;
	}
	
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<ll>t(n);
	for (int i = 0; i < n; i++)cin >> t.at(i);
	ll ans = t.at(0);
	for (int i = 1; i < n; i++) {
		ans = ans / __gcd(ans, t.at(i)) * t.at(i);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto n = lread();
    auto a = aryread();
    // writeln(a);
    auto ans = new long[](n);
    foreach (i; 0 .. (n - 1))
    {
        if (a[i] == a[i + 1])
        {
            ans[i + 1] = 0;
        }
        else if (a[i] > a[i + 1])
        {
            ans[i + 1] = a[i] - a[i + 1];
            a[i + 1] = a[i];
        }
    }
    // writeln(ans);
    sum(ans).writeln();
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 14204
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        int ln = s.length();
        s = s.substring(0, ln - 1);

        loop:for(int i=1; i<=200; i++){
            int l = s.length();
            if(l%2==0){
                for(int j=0; j<l/2; j++){
                    if(s.charAt(j)!=s.charAt(l/2+j)){
                        break;
                    }
                    if(j==l/2-1){
                        System.out.println(l);
                        break loop;
                    }
                }
            }
            s = s.substring(0, l - 1);
        }
    }
}

Measured memory_bytes: 23764
import sys
input = sys.stdin.readline
def print_ans(N, K, S):
    """Test Case
    >>> print_ans(3, 1, "ABC")
    aBC
    >>> print_ans(4, 3, "CABA")
    CAbA
    """
    tmp = S[K - 1].lower()
    ans = [tmp if i == K - 1 else s for i, s in enumerate(S) ]
    print(''.join(ans))

if __name__ == '__main__':
    N, K = map(int, input().rstrip().split())
    S = input().rstrip()
    print_ans(N, K, S)




Measured memory_bytes: 3316
import java.util.*;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int k = sc.nextInt();
		int x = sc.nextInt();
		
		for(int i = x - k + 1; i < x + k; i++) System.out.print(i + " ");
	}
}

Measured memory_bytes: 38548
//--- pC ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	public Solution () {
		reader = new Reader();
		while (reader.hasNext()) {
			run_case();
		}
	}
	private void run_case() {
		long n = Long.parseLong(reader.ns());

		long min_sum = (long)1e12+5;
		for (long cur = 1; cur * cur <= n; cur ++) {
	        if (n % cur == 0) {
	            long a = cur;
	            long b = n / cur;
				min_sum = Math.min(min_sum, a + b);
	            // System.out.println(a + " " + b);
	        }
	    }

		System.out.println(min_sum - 2);

		return;
	}


}

class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public String ns() {return this.next();}
}


Measured memory_bytes: 24660
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		int N = I[0], M = I[1];
		var qs = new List<Query>(M);
		for (var i = 0; i < M; i++) qs.Add(new Query(G));
		qs.Sort();
		var s = 0;
		for (var i = 0; i < M; )
		{
			var j = i + 1;
			while (j < M && qs[j].L < qs[i].R) j++;
			s++;
			i = j;
		}
		WriteLine(s);
	}
}
struct Query : IComparable<Query>
{
	public readonly int L, R;
	public Query(int[] i) { L = i[0] - 1; R = i[1] - 1; }
	public int CompareTo(Query query) => R.CompareTo(query.R);
}

Measured memory_bytes: 18488
import qualified Data.Map as M
import qualified Data.Map as M
import Control.Monad

solve :: [Int] -> M.Map Int Int -> M.Map Int Int
solve inData ans
 | null inData = ans
 | otherwise   = solve (tail inData) newAns
   where newAns = M.insertWith (+) (head inData) 1 ans

main = do
 [n,k,q] <- map read . words <$> getLine :: IO [Int]
 aList   <- replicateM q (read <$> getLine) :: IO [Int]
 mapM_ putStrLn $ map ((\x -> if x > 0 then "Yes" else "No") . (\x -> x + k - q) . snd) $ M.toList $ solve aList $ M.fromList $ zip [1..n] $ repeat 0

Measured memory_bytes: 67228
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] h = new int[n];

		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}

		if (n == 1) {
			System.out.println("Yes");
		} else {
			boolean flag = true;
			for (int i = 0; i < n - 1; i++) {
				if (h[i + 1] - h[i] <= -2) {
					System.out.println("No");
					System.exit(0);
				} else if (h[i + 1] - h[i] == -1) {
					if (flag) {
						flag = false;
					} else {
						System.out.println("No");
						System.exit(0);
					}
				} else if (h[i + 1] - h[i] >= 1) {
					flag = true;
				}

			}
			System.out.println("Yes");

		}

		sc.close();
	}
}

Measured memory_bytes: 49716
dish = [int(input()) for i in range(5)]
a = [i%10 for i in dish]

x=10
for i in a:
  if i>0:
    x=min(x,i)
if x ==10:
  x = 0
y = a.index(x)
l = dish.pop(y)

time = [(i//10+1)*10  if i%10 != 0 else i for i in dish]

ans = sum(time) + l
print(ans)

Measured memory_bytes: 9140
import java.util.Scanner;
import java.lang.Integer;
import java.lang.StringBuilder;
import java.lang.Math;

public class Main {
  private static int N;
  private static int W;
  private static int[] weight;
  private static int[] value;
  private static int[][] dp;

  private static int calc() {
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= W; j++) {
        if (j < weight[i]) {
          dp[i][j] = dp[i - 1][j];
        } else {
          dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - weight[i]] + value[i]);
        }
      }
    }

    return dp[N][W];
  }

  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    N = in.nextInt();
    W = in.nextInt();

    value = new int[N + 1];
    weight = new int[N + 1];

    // init
    value[0] = 0;
    weight[0] = 0;
    for (int i = 1; i <= N; i++) {
      value[i] = in.nextInt();
      weight[i] = in.nextInt();
    }

    dp = new int[N + 1][W + 1];
    for (int i = 0; i <= N; i++) {
      dp[i][0] = 0;
    }
    for (int j = 0; j <= W; j++) {
      dp[0][j] = 0;
    }

    int result = calc();
    System.out.println(result);
  }
}

Measured memory_bytes: 30860
def InsertionSort(A,N,g):
    cnt=0
    for i in range(g,N):
        v=A[i]
        j=i-g
        while(j>=0 and A[j]>v):
            A[j+g]=A[j]
            j-=g
            cnt+=1
        A[j+g]=v
    return A,cnt
        # print(end='\n')
def shellSort(A,N):
    m=len(A)
    G=[1]
    fig=1
    a=0
    b=2
    while(True):
        fig=b**2*b
        # fig=fig*3+1
        if fig>m:break#超えたら
        G.append(fig)
        b+=1
    G=G[::-1]
    for i in G:
        sort,cnt=InsertionSort(A,N,i)
        a+=cnt
    print(len(G))
    for j in G:print(j,end=' ')
    print(end='\n')
    print(a)
    for k in sort:print(k,end='\n')



N=int(input())
A=[int(input()) for x in range(N)]
shellSort(A,N)


Measured memory_bytes: 45520
#include <cstdio>
#include <stdio.h>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <queue>
#include <string>
#include <map>
#include <cmath>
#include <iostream>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    if((a * b) % 2 == 1) {
        printf("Odd\n");
    } else {
        printf("Even\n");
    }
    return 0;
}

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

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

using namespace std;

int main() {
  int n, c, k;
  std::cin >> n >> c >> k;
  std::vector<int> t(n);
  rep(i, n) std::cin >> t[i];

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

  int sum = 0;
  int i = 0;
  while (i < n) {
    ++sum;
    int pos = i;
    while (i < n && k >= t[i] - t[pos] && c > i - pos)
      ++i;
  }

  std::cout << sum << std::endl;
  return 0;
}


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

using ll = long long;

const ll INF = (1LL << 50);

int main() {
    int n;
    ll x;
    cin >> n >> x;

    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    vector<ll> score(n, INF);
    ll ans = INF;
    for (int v = 0; v < n; v++) {
        ll s = 0;
        for (int i = 0; i < n; i++) {
            score[i] = min(score[i], a[(i - v + n) % n]);
            s += score[i];
        }
        // cerr << "v: " << v << " s: " << s << endl;
        s += v * x;
        ans = min(ans, s);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;]
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

double p,q,a,n,syou;
int ans;

int check(double a,double b)
{
	return (a - b < 1e-9 && b - a < 1e-9)?1:0;
}


void dfs(double sum,int seki,int now,int mae)
{
	for(int i = mae;i < a;i++)
	{
		if(seki * i > a)break;
		double aa = (double)1/i;
		if(check(syou,sum+aa))
		{
			ans++;
		}
		else if(sum+aa < syou && now < n)
		{
			dfs(sum+aa,seki*i,now+1,i);
		}
	}
}

int main()
{
	
	while(cin>>p>>q>>a>>n,p != 0)
	{
		syou = p/q;
		ans = 0;
		dfs(0,1,1,1);
		cout << ans << endl;
	}	
	
	return 0;
}

Measured memory_bytes: 3184
long long D(S,d,s,n){if(d==0)return S==s;long long r=0;for(;n<10;n++)r+=D(S,d-1,s+n,n+1);return r;}
main(n,s){for(;scanf("%d%d",&n,&s),n|s;)printf("%lld\n",D(s,n,0,0));exit(0);}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int a[3];
    f(i, 3) cin>>a[i];
    sort(a, a + 3, greater<>());
    cout<<a[0] * 10 + a[1] + a[2]<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class  Main{
	public static void main(String[] args)
	{
		Scanner sc =new Scanner(System.in);
		String s=sc.next(); //入力された文字列
		int C_exi=0;	//Cが存在する時1、しない時0
		int F_exi=0;	//Fが存在する時1、しない時0
		
		//Cが存在するか確認
		for(int i=0;i<s.length();i++){
			if(s.charAt(i)=='C'){
				C_exi=1;	//Cが存在したらC_exiを1に
				for(int j=i;j<s.length();j++){
					if(s.charAt(j)=='F') F_exi=1;
				}
			}
		}

		if(F_exi==1) System.out.println("Yes");
		else System.out.println("No");
	}
} 

Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

int A[110][110];
int a[100010];
int p = 1;

int next() { if(a[p] == 0) ++p; a[p]--; return p; }

void solve(){
	int n, m; scanf("%d%d", &n, &m);
	int q; scanf("%d", &q);
	for(int i=1;i<=q;i++) scanf("%d", a+i);
	for(int i=1;i<=n;i++) {
		int ans[110] = {};
		if(i & 1) for(int j=1;j<=m;j++) ans[j] = next();
		else for(int j=m;j;j--) ans[j] = next();
		for(int j=1;j<=m;j++) printf("%d ", ans[j]); puts("");
	}
	
}

int main(){
	int T = 1; //scanf("%d", &T);
	while(T--) {
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 384
package main

import "fmt"

// 2018-08-04T13:47:11+0800
// 2018-08-04T14:03:18+0800
// 2018-08-04T14:40:46+0800
func main() {
	var N, K int
	fmt.Scanf("%d%d", &N, &K)
	out := 0
	for b := K + 1; b <= N; b++ {
		span := b - K
		mul := (N - K) / b
		if mul == 0 {
			out += span
		} else {
			out += span * mul
			if mul*b+b <= N {
				out += span
			} else {
				out += N + 1 - (mul*b + K)
			}
		}
	}
	if K == 0 {
		out -= N - K
	}
	fmt.Println(out)
}

Measured memory_bytes: 512
#include <cstring>  // memset
#include <iostream>

using namespace std;

bool G[50][50] = {{false}};
bool visited[50] = {false};

struct Edge {
  int u;
  int v;
};
Edge edges[50];

void DFS(int u, int N) {
  visited[u] = true;

  for (int v = 0; v < N; ++v) {
    if (!G[u][v]) continue;
    if (visited[v]) continue;
    DFS(v, N);
  }
}

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

  int N, M;
  cin >> N >> M;
  int a, b;

  for (int i = 0; i < M; ++i) {
    cin >> a >> b;
    --a;
    --b;
    G[a][b] = G[b][a] = true;
    edges[i] = {a, b};
  }

  int ans = 0;
  for (int i = 0; i < M; ++i) {
    auto e = edges[i];
    if (!G[e.u][e.v]) continue;
    G[e.u][e.v] = G[e.v][e.u] = false;
    DFS(0, N);
    bool has_bridge = false;
    for (int v = 0; v < N; ++v) {
      if (!visited[v]) {
        has_bridge = true;
        break;
      }
    }
    if (has_bridge) ++ans;
    G[e.u][e.v] = G[e.v][e.u] = true;
    memset(visited, false, N);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

long long M = 1e9 + 7;

int main(void)
{
    string s;
    cin >> s;
    int max = 100100;
    long long dp[max][2];

    dp[0][0] = 1;
    dp[0][1] = 2;
    int n = s.length();

    rep(i, 1, n)
    {
        if (s[i] == '0')
        {
            dp[i][0] = 3 * dp[i - 1][0] % M;
            dp[i][1] = dp[i - 1][1] % M;
        }
        else
        {
            dp[i][0] = (3 * dp[i - 1][0] + dp[i - 1][1]) % M;
            dp[i][1] = 2 * dp[i - 1][1] % M;
        }
    }
    cout << (dp[n - 1][0] + dp[n - 1][1]) % M << endl;
}


Measured memory_bytes: 2048
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

type Node struct {
	id, to int
}

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, M := sc.nextInt(), sc.nextInt()
	G := make([][]Node, N)
	for i := 0; i < M; i++ {
		from := sc.nextInt() - 1
		to := sc.nextInt() - 1
		G[from] = append(G[from], Node{i, to})
		G[to] = append(G[to], Node{i, from})
	}
	found := false
	done := make([]bool, N)
	var dfs func(id, start, to int)
	dfs = func(id, start, to int) {
		done[to] = true
		for _, node := range G[to] {
			if id != node.id && !done[node.to] {
				if node.to == start {
					found = true
					done[to] = true
				} else {
					dfs(id, start, node.to)
				}
			}
		}
	}
	edges := make([]bool, M)
	ans := 0
	for from, nodes := range G {
		for _, node := range nodes {
			found = false
			done = make([]bool, N)
			if !edges[node.id] {
				dfs(node.id, from, node.to)
				edges[node.id] = true
				if !found {
					ans++
				}
			}
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 640
N,M=map(int,input().split())
S=[[] for i in range(M)]
K=[]
for m in range(M):
     kS=[int(i) for i in input().split()]
     K.append(kS[0])
     for k in range(kS[0]):
         S[m].append(kS[k+1])
P=[int(i) for i in input().split()]

# #スイッチの全通りの状態についてそれぞれの電球が点灯しているか見る
ans=0
for i in range(1<<N):
    on=set()
    for j in range(N):
        if ((i >> j) & 1) == 1:
            on.add(j+1)
    # print(i,on)
    for m in range(M):
        on_num=0
        for k in range(K[m]):
            if S[m][k] in on:
                on_num+=1
        if on_num%2 != P[m]:
            break
        if m ==M-1:
            ans+=1
print(ans)


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

using namespace std;

void Solve();

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

void Solve(){
  int n;
  	scanf("%d",&n);
  vector<int> A(n);
  for(int i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  vector<int> B(n);
  for(int i=n;i>0;i--){
    for(int j=i;j>0;j--){
      if(A[j-1]==j){
        B[i-1]=j;
        A.erase(A.begin()+j-1);
        break;
      }
    }
  }

  if(B[0]==0){
    printf("%d\n",-1);
    return;
  }

  for(int i=0;i<n;i++){
    printf("%d\n",B[i]);
  }
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}



int main(){
    static const double pi = 3.141592653589793;
    ld a,b,h,m;
    cin >> a >> b >> h >> m;

    ld da = h*30+m*0.5;
    ld db = m*6;

    ld d = min(abs(da-db),360-abs(da-db));
    
    d = cosl(d/180*pi);

    ld ans = sqrt((a*a)+(b*b)-(2*a*b*d));


    cout << setprecision(10) << ans << endl;
}


Measured memory_bytes: 4160
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    char a[55][55],c;
    int i,j,h,w,sum=0,b[55][55];
    while(cin >> h >> w){
           // getchar();
       for(i = 0 ; i < h; i++)
        {for(j = 0 ; j < w; j++)
          {cin >> c;
           if(c=='#')
           a[i][j]=c;
           else
           a[i][j]=0;

          }
          //getchar();
        }
    for(i = 0 ; i < h; i++)
        for(j = 0 ; j < w; j++)
        {
            if(a[i][j] != '#')
            {
            if(a[i-1][j-1]=='#'&&(i-1>=0))
                sum++;
            if(a[i-1][j]=='#'&&(i-1>=0))
                sum++;
            if(a[i-1][j+1]=='#'&&(i-1>=0))
                sum++;
            if(a[i][j-1]=='#'&&(j-1>=0))
                sum++;
            if(a[i][j+1]=='#'&&(j+1<w))
                sum++;
            if(a[i+1][j-1]=='#'&&(i+1<h&&j-1>=0))
                sum++;
            if(a[i+1][j]=='#'&&(i+1<h))
                sum++;
            if(a[i+1][j+1]=='#'&&(i+1<h&&j+1<w))
                sum++;
            b[i][j]=sum;sum=0;
            }
        }
        for(i = 0 ; i < h; i++)
        {for(j = 0 ; j < w; j++)
            if(a[i][j]!='#')
            cout << b[i][j] ;
            else
             cout << '#';
        cout << endl;
        }

    }
    return 0;
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	if(n == 1){
		cout << "Hello World";
		return 0;
	}
	else{
		int a, b;
		cin >> a >> b;
		cout << (a + b);
		
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n); i >= 0; i--)
#define revrepr(i, a, b) for (int i = (a); i >= b; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

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

const long long MOD = 1e9+7;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

int main() {
    set<int> s;
    rep(i, 3) {
        int a;
        cin >> a;
        s.insert(a);
    }
    cout << (s.size() == 2 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;

//ll num[50];
//ll num2[50];
ll num[ten52];
//stack<char> stk;
//set<ll> sll;
//map<string,ll> mp,mp1;
//map<pair<ll,ll>,ll>::iterator iter;
//map<ll,ll> mp;
//deque<char> deq;
//vector<ll> vll;


int main(void)
{
    //double ans=0.0,d,d1,d2;
    //float f,g,h;
    long long int m,n,i,j,k=1;
    long long int a,a1,a2,a3,sum;
    //string s,s1,s2;
    //char c,c1;
    sum=a=a1=a2=a3=0;
    cin>>a1>>a2>>n;
    if(a2==1 || a1==1)
    {
        cout<<0;
        return 0;
    }
    if(a2>n)
        cout<<(a1*n/a2);
    else
        cout<<(a1*(a2-1)/a2);
    return 0;
}





Measured memory_bytes: 3588
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

// 3, 11
// 0, 3, 11, 14
// 0, 3, 3, 6


int solve() {
  vector<pair<ll,pair<ll,ll>>> vec;
  ll N, X, D;

#ifndef TEST
  cin >> N >> X >> D;
#else
  N = 3;
  X = rand() % 100000 - 50000;
  D = rand() % 100000 - 50000;
#endif

  if (D < 0) {
    D = -D;
    X = -X;
  }

  ll l = 0, r = 0;
  for (ll i=0; i<=N; i++) {
    ll B = X * i;
    ll P = D != 0 ? B % D : 0;
    ll Q = D != 0 ? B / D : B;
    if (P < 0) {
      P += D;
      Q -= 1;
    }

    if (i > 0 && D) {
      l += i-1;
      r += N-i;
    }

    vec.push_back({P, {Q+l, Q+r+1}});
  }

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

  ll ans = 0, prev = -1;
  l = 0, r = 0;

  for (int i=0; i<=N; i++) {
    debug(vec[i]);
    if (prev != vec[i].first || r < vec[i].second.first) {
      ans += r - l;
      prev = -1;
    }

    if (prev != vec[i].first) {
      l = vec[i].second.first;
      r = vec[i].second.second;
    } else {
      r = max(r, vec[i].second.second);
    }

    prev = vec[i].first;
  }

  ans += r - l;

#ifdef TEST
  set<ll> ss;
  for (int i=0; i<(1<<N); i++) {
    ll sum = 0;
    for (int j=0; j<N; j++) {
      if (i & (1 << j)) continue;

      sum += X + D * j;
    }
    ss.insert(sum);
  }

  if (ans != ss.size()) {
    cerr << ans << " " << ss.size() << endl;
    cerr << N << " " << X << " " << D << endl;
    exit(1);
  }
#else
  cout << ans << endl;
#endif

  return 0;
}

int main() {
#ifndef TEST
  solve();
#else
  while(1) solve();
#endif
}


Measured memory_bytes: 8432