akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define mod 1000000007
typedef long long ll;
using namespace std;

const int M = (int)(2e6 + 239);

void decitobinbitodeci()
{
    string binary = bitset<8>(128).to_string(); //to binary
    cout<<binary<<"\n";

    unsigned long decimal = bitset<8>(binary).to_ulong();
    cout<<decimal<<"\n";
}

int getnum(string a)
{
    int i,p=0;
    rep0(i,a.size())
    {
        p*=10;
        p+=a[i]-'0';
    }
    return p;
}

/*
1.always remember for ncr(n,2), you can calculate by
n*(n-1)/2
2.Power of 2 ->  (1ll<<i)
*/

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast

    string a;
    cin>>a;
    if(a=="ABC")
    {
        cout<<"ARC"<<endl;
    }
    else
    {
        cout<<"ABC"<<endl;
    }
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

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

    ll n,k;
    cin>>n>>k;
    ll ar[n];
    ll sum=0;
    for(ll i=0;i<n;++i){cin>>ar[i];sum+=ar[i];}
    sort(ar,ar+n);
    reverse(ar,ar+n);
    for(ll i=0;i<min(n,k);++i){
        sum-=ar[i];
    }
    cout<<sum;

    return (0);
}


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

void solve(){

	ll a,b,c,d ;
	cin>>a>>b>>c>>d ;

	cout<<max(b*c,max(b*d,max(a*d,a*c))) ;
}

int main(){

	
	int y ;

	y=1 ;
	//cin>>y ;

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

}

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

#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>

using namespace std;

int main()
{
    string S;

    cin >> S;

    if (S.length() != 4)
    {
        cout << "No" << endl;
        return 0;
    }

    if (!isupper(S[0]) || !isupper(S[1]) || !isupper(S[2]) || !isupper(S[3]))
    {
        cout << "No" << endl;
        return 0;
    }

    if( (   (S[0] == S[1]) && (S[2] == S[3])
       || (S[0] == S[2]) && (S[1] == S[3])
       || (S[0] == S[3]) && (S[1] == S[2]))
        && !( (S[0] == S[1]) && (S[1] == S[2]) && (S[2] == S[3])))
    {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int inf=0x3f3f3f3f;
int n,m,p;

struct Node
{
    int x,y;
};
const int maxn=3000+10;
vector<Node>s[maxn];
vector<int>w[maxn];

int ans=0;
int vis[maxn];
int dis[maxn];
int cnt[maxn];
int f=0;
int reachable[maxn];
void dfs(int x)
{
    reachable[x]=1;
    for(int i=0; i<w[x].size(); i++)
    {
        if(reachable[w[x][i]])
            continue;
        dfs(w[x][i]);
    }
}
bool SPFA()
{
    for(int i=2; i<=n; i++)
        dis[i]=-inf;
    vis[1]=1;
    queue<int>que;
    que.push(1);
    cnt[1]=1;
    while(!que.empty())
    {
        int top=que.front();
        que.pop();
        vis[top]=0;
       if(!reachable[top]||dis[top]==-inf)
            continue;
        for(int i=0; i<s[top].size(); i++)
        {
            Node no=s[top][i];
            int v=no.x;
            if(!reachable[v])//reachable
                continue;
            if(dis[v]<dis[top]+no.y)
            {
                dis[v]=dis[top]+no.y;
                if(vis[v]==0)
            {
                vis[v]=1;
                que.push(v);
                if(++cnt[v]>n)
                return false;
            }
            }
    }
    }
    return true;
}
bool bellman_ford(){
	for(int i=2;i<=n;i++){
		dis[i] = -inf;
	}
	for(int k=0;k<=n;k++){
		bool updated = false;
		for(int i=1;i<=n;i++){
			int l = s[i].size();
			if(!reachable[i]||dis[i]==-inf) continue;
			for(int j=0;j<l;j++){
				int v = s[i][j].x;
				if(!reachable[v]) continue;
				int c = s[i][j].y;
				if(dis[v]<dis[i]+c){
					updated = true;
					dis[v] = dis[i]+c;
				}
			}
		}
		if(!updated) return true;
	}
	return false;
}

int main()
{

    std::ios::sync_with_stdio(false);

    cin>>n>>m>>p;
    for(int i=0; i<m; i++)
    {
        int x,y,z;
        cin>>x>>y>>z;
        w[y].push_back(x);
        s[x].push_back({y,z-p});
    }
    dfs(n);
    bool flag=SPFA();
   // bool flag=bellman_ford();
    if(flag)
        cout<<max(0,dis[n])<<'\n';
    else
        puts("-1");

    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in = new Scanner(System.in); 
		boolean flag = false;
		int n=in.nextInt()+1;
		while(n--!=0)
		{
			char ch[] = in.nextLine().toCharArray();
			for(int i=0 ; i<ch.length-6; i++)
			{
				if(ch[i]=='H'&&ch[i+1]=='o'&&ch[i+2]=='s'&&ch[i+3]=='h'&&ch[i+4]=='i'&&ch[i+5]=='n'&&ch[i+6]=='o')
				{
					ch[i+6]='a';	
				}
			}
			for(int i=0; i<ch.length; i++)
				System.out.print(ch[i]);
			if(flag)
				System.out.println();
			flag=true;
		}
	}
}

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

using namespace std;

int main()
{
	int N,M,X;
	int A[100];
	cin>> N>> M>> X;
	for(int i=0;i<M;i++)cin>> A[i];

	int to0=0,toN=0;
	for(int i=0;i<M;i++)
	{
		if(A[i]<X)to0++;
		else toN++;
	}
	cout<< min(to0,toN)<< endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main()
{
	int n, r;
	int c[50], d[50];
	
	while (scanf("%d %d", &n, &r) && n){
		for (int i = 0; i < n; i++) c[i] = n - i;
		
		for (int i = 0; i < r; i++){
			int p, dx;
			scanf("%d %d", &p, &dx);
			for (int j = 0; j < n; j++) d[j] = c[j];
			for (int j = 0; j < p - 1; j++) d[j + dx] = c[j];
			for (int j = 0; j < dx; j++) d[j] = c[j + p - 1];
			for (int j = 0; j < n; j++) c[j] = d[j];
		}
		
		printf("%d\n", c[0]);
	}
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
template <typename T>
    using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <char cmp = '<'>
    bool icmp(ll a, ll b){ if(cmp=='>') return a > b; else return a < b;}
namespace enhanced_pair{
    typedef pair<ll,ll> pll;
    ostream& operator << (ostream& o, const pll a){
        o<<a.first<<" "<<a.second;
        return o;
    }
    istream& operator >> (istream& i, pll& p){
        i>>p.first>>p.second;
        return i;
    }
    template <char cmp1 = '<', char cmp2 = '<'>
        bool pcmp(pll a, pll b){ return icmp<cmp1> (a.first,b.first) || (a.first==b.first && icmp<cmp2> (a.second,b.second));}
    template <char cmp1 = '<', char cmp2 = '<'>
        struct pcmpobj{bool operator()(pll a, pll b){return pcmp<cmp1,cmp2>(a,b);}};
} using namespace enhanced_pair;
const ll BIG = 1e18;
const ll NMAX = 2e5+5;
const ll MOD = 1e9+7;
pll v[NMAX];
pll tofraction(string x){
    ll n=0,p2=0,p5=0,p10=0;
    bool point=0;
    for(ll i=0;i<x.size();i++)
        if(x[i]!='.')
            n=n*10+x[i]-'0';
    for(ll i=0;i<x.size();i++){
        if(point==1) p10++;
        if(x[i]=='.') point=1;
    }
    while(n && n%2==0){
        n/=2;
        p2++;
    }
    while(n && n%5==0){
        n/=5;
        p5++;
    }
    return {p2-p10,p5-p10};
}
ll cntatleast[55][55];
void tc(){
    ll n,ans=0;
    string x;
    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>x;
        v[i]=tofraction(x);
        for(ll n1=-25;n1<=v[i].first;n1++)
            for(ll n2=-25;n2<=v[i].second;n2++)
                cntatleast[n1+25][n2+25]++;
    }
    for(ll i=0;i<n;i++){
        ans+=cntatleast[-v[i].first+25][-v[i].second+25]-(v[i].first>=0 && v[i].second>=0);
    }
    cout<<ans/2;
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //ll q; cin>>q; while(q--)
        tc();

    return 0;
}


Measured memory_bytes: 6652
#include <iostream>

using namespace std;

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

int main(){
  int A[100], N, sw;
  cin >> N;
  for ( int i = 0; i < N; i++) cin >> A[i];

  sw = bubbleSort(A,N);

  for (int i = 0; i < N; i++){
    if(i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;

  return 0;
}



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

#define frs first
#define scn second
#define pbk push_back
#define ppk pop_back
#define mkp make_pair

using namespace std;

const int kLim = 20000;
typedef pair< int, int > Pr;
typedef pair< int, Pr > GnkNum;

int Z;
int M, N;
vector< GnkNum > gn;

void prep();
void read();
void soups_on();

int main() {
  cin >> Z;
  prep();
  for (int zi = 1; zi <= Z; ++zi)
    read(), soups_on();

  return 0;
}

void prep() {
  for (int i = -150; i <= 150; ++i)
    for (int j = -150; j <= 150; ++j)
      if (i || j)
        gn.pbk(mkp(i * i + j * j, mkp(i, j)));

  stable_sort(gn.begin(), gn.end());
}

void read() {
  cin >> M >> N;
}

void soups_on() {
  int res = 0, nrm, p, q;

  for (int i = 0; i < int(gn.size()); ++i) {
    nrm = gn[i].frs, p = gn[i].scn.frs, q = gn[i].scn.scn;
    if (nrm > M * M + N * N)
      break;

    if ((M * M + N * N) % nrm == 0) {
      if ((p * M + q * N) % nrm == 0 && (p * N - q * M) % nrm == 0)
        ++res;
    }
  }

  cout << (res > 8 ? "C" : "P") << "\n";
}

Measured memory_bytes: 3356
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int x;
  cin >> x;
  int a=2;
  vector<int> v(1,1);
  while(a*a<=x){
    int ans=a*a;
    v.push_back(ans);
    ans*=a;
    while(ans<=x){
      v.push_back(ans);
      ans*=a;
    }
    a++;
  }
  sort(v.begin(),v.end());
  cout << v[v.size()-1] << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
int main()
{
   string s;
   cin>>s;
   ll ans=0;
   for(int i=0;i<s.size();i++)
   {
        int val=s[i]-'0';
        ans=ans+val;
        ans%=9;
   }
  if(ans==0)
     cout<<"Yes";
  else
     cout<<"No";
}


Measured memory_bytes: 3724
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt
import math

import bisect
import re
import heapq


from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


yes = "Yes"
no = "No"


def main():
    n,k = mi()
    p = li()
    p.sort()
    ans = 0
    for i in range(k):
        ans+=p[i]
    print(ans)


main()




Measured memory_bytes: 10048
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define STR_MAX 4000
#define BUF_SIZE (STR_MAX+10)

// size: specify sizeof(str)
int get_str(char *str, int size) {
    if(!fgets(str, size, stdin)) return -1;
    return 0;
}

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

enum {
    ENUM_RED,
    ENUM_GREEN,
    ENUM_BLUE,
    ENUM_ALL
};

int table[256] = {
    ['R'] = 1<<ENUM_RED,
    ['G'] = 1<<ENUM_GREEN,
    ['B'] = 1<<ENUM_BLUE,
};

#define ALL_TYPE ((1<<ENUM_ALL) - 1)


int main(void) {
    int len = get_int(); // length
    char str[BUF_SIZE];
    get_str(str, BUF_SIZE);
    char type[BUF_SIZE] = {0};
    int i;
    for(i = 0; i < len; i++) {
        type[i] = table[str[i]];
    }
    static uint64_t dp[STR_MAX+1][1<<ENUM_ALL] = {0};
    dp[0][0] = 1;
    int pat;
    for(i = 1; i <= len; i++) {
        int tp = type[i-1];
        for(pat = 0; pat < (1<<ENUM_ALL); pat++) {
            dp[i][pat] = dp[i-1][pat];
            if(!(tp & pat)) { continue; }
            int prev_tp = pat & (~(tp));
            dp[i][pat] += dp[i-1][prev_tp];
#ifdef DEBUG
            printf("[%d]: dp[%d][%d -> %d] = %llu\n",tp, i,prev_tp, pat, dp[i][pat]);
#endif
        }
    }
    uint64_t exclude = 0;
    int dist;
    for(dist = 1; dist < len; dist++) {
        for(i = 0; i < len; i++) {
            if(i + 2*dist >= len) break;
            if((type[i] | type[i+dist] | type[i+dist*2]) == ALL_TYPE) exclude++;
        }
    }
#ifdef DEBUG
    printf("%llu %llu\n", dp[len][ALL_TYPE], exclude);
#endif
    printf("%llu\n", dp[len][ALL_TYPE]-exclude);
    return 0;
}

Measured memory_bytes: 1956
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

#define PI 3.14159265358979323846264338327950L

int main(int argc, char **argv)
{
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    long double theta_m = 6 * M;
    long double theta_h = 30 * (long double)H + 0.5 * (long double)M;
    long double theta;
    if (theta_m < theta_h) theta = theta_h - theta_m;
    else theta = theta_m - theta_h;

    if (theta > 180) theta = 360 -theta;
    theta = theta * PI / 180;

    long double a = (long double)(A * A + B * B) - 2.0 * (long double)(A * B) * cos(theta);
    cout << setprecision(20) << sqrtl(a) << endl;

    return 0;
}


Measured memory_bytes: 4160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
// Welcome to my source code!

int nums[26], numt[26];

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size();
    map<char, int> mps, mpt;
    for (int i = 0; i < n; i++) {
        mps[s[i]]++;
        mpt[t[i]]++;
    }
    for (auto x : mps) {
        nums[x.first - 'a'] += x.second;
    }
    for (auto x : mpt) {
        numt[x.first - 'a'] += x.second;
    }
    sort(nums, nums+26);
    sort(numt, numt+26);
    bool flag = true;
    for (int i = 0; i < 26; i++) {
        if (nums[i] != numt[i]) flag = false;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 776
#include <iostream>
#include <vector>
#include <cmath>
 
using namespace std;
 
int main(){
  int N; cin>>N;
  vector<int> C(N,0),V(N,0);
  for(int i=0;i<N;i++) cin>>V[i];
  for(int i=0;i<N;i++) cin>>C[i];
  int X=0,Y=0;
  for(int bit=0;bit<(1<<N);bit++){
    int tempX=0,tempY=0; 
    for(int j=0;j<N;j++){
      if(bit&(1<<j)){
        tempX+=V[j];
        tempY+=C[j];
      }
      if((tempX-tempY)>(X-Y)){
        X=tempX; Y=tempY;
      }
    }
  }
 
  cout<<X-Y<<endl;
 
  return 0;
}

Measured memory_bytes: 764
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

const int MAX_N = 400;
int S[MAX_N + 1];
int dp[MAX_N][MAX_N];
bool visited[MAX_N][MAX_N];

int rec(int left, int right) {
    if (left >= right) return 0;
    if (visited[left][right]) return dp[left][right];
    visited[left][right] = true;
    int mn = INF;
    for (int middle = left; middle <= right - 1; middle++) {
        mn = min(rec(left, middle) + rec(middle + 1, right) + S[right + 1] - S[left], mn);
    }
    return dp[left][right] = mn;
}

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        S[i+1] = S[i] + a;
    }
    cout << rec(0, N - 1) << endl;
}

Measured memory_bytes: 1664
#include<iostream>
using namespace std;
main(){
int a,b,c,k,x[1000][4],p[500];
while(true){
for(int i=0;i<500;i++){p[i]=2;}
cin>>a>>b>>c;
if(a==0){break;}
cin>>k;
for(int i=0;i<k;i++){
cin>>x[i][0]>>x[i][1]>>x[i][2]>>x[i][3];
if(x[i][3]==1){p[x[i][0]]=1;p[x[i][1]]=1;p[x[i][2]]=1;}
}
for(int i=0;i<k;i++){
if(p[x[i][0]]==1&&p[x[i][1]]==1&&x[i][3]==0){p[x[i][2]]=0;}
if(p[x[i][0]]==1&&p[x[i][2]]==1&&x[i][3]==0){p[x[i][1]]=0;}
if(p[x[i][1]]==1&&p[x[i][2]]==1&&x[i][3]==0){p[x[i][0]]=0;}
}
for(int i=1;i<=a+b+c;i++){cout<<p[i]<<endl;}
}
}

Measured memory_bytes: 1172
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long
#define MAX 100010
#define MAX_C 31

int n, C;
int s[MAX], t[MAX], c[MAX];
int imos[MAX_C][MAX];

void init_imos() {
  for (int i = 0; i <= C; i++) {
    for (int j = 0; j < MAX; j++) {
      imos[i][j] = 0;
    }
  }
}

void use_imos() {
  for (int i = 1; i <= C; i++) {
    for (int j = 1; j < MAX; j++) {
      imos[i][j] += imos[i][j - 1];
    }
  }
}

int solve() {
  int max_overlap = 0;
  for (int j = 0; j < MAX; j++) {
    int count = 0;
    for (int i = 1; i <= C; i++) {
      if (imos[i][j]) count++;
    }
    max_overlap = max(max_overlap, count);
  }
  return max_overlap;
}

signed main() {
  cin >> n >> C;
  init_imos();
  for (int i = 0; i < n; i++) {
    cin >> s[i] >> t[i] >> c[i];
    imos[c[i]][s[i]]++;
    imos[c[i]][t[i] + 1]--;
  }
  use_imos();
  cout << solve() << endl;
  return 0;
}

Measured memory_bytes: 26752
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

int x;

int main() {
	cin >> x;
	if (x < 1200)cout << "ABC" << endl;
	else cout << "ARC" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>

using namespace std;
#define mod 1000000007



long long power(int N){

long long p=1;
long long  i=1;
while(N>0){
    p*=i;
    i++;
    N-=1;
    if(p>=mod){
    p%=mod;
    }
}
return p;
}

int main(){

int N;
cin>>N;
cout<<power(N)<<endl;

 return 0;
}

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

using namespace std;
using ll = long long;

const int nax = 3005;
char cmp[nax];
int dp[nax][nax], pref[nax][nax];

const int mod = 1e9 + 7;

void add_self(int& a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}

signed main() {
    int n;
    scanf("%d", &n);
    scanf("%s", cmp);
    dp[1][1] = 1;
    for (int len = 2; len <= n; len++) {
        // let's compute prefix sums on dp[len-1]
        for (int i = 1; i <= len - 1; i++) {
            pref[len - 1][i] = (pref[len - 1][i - 1] + dp[len - 1][i]) % mod;
        }
        for (int b = 1; b <= len; b++) {
            int L, R;
            if (cmp[len - 2] == '<') {
                L = 1, R = b - 1;
            } else {
                L = b, R = len - 1;
            }
            if (L <= R) {
                add_self(dp[len][b], (pref[len - 1][R] - pref[len - 1][L - 1] + mod) % mod);
            }
        }
    }
    int answer = 0;
    for (int b = 1; b <= n; b++) {
        add_self(answer, dp[n][b]);
    }
    printf("%d\n", answer);
    return false;
}

Measured memory_bytes: 69504
#include<bits/stdc++.h>
#define f first
#define se second
#define pb push_back
#define pf push_front
#define eb emplace_back
#define emp emplace
#define ins insert
#define sz(s) (int)s.size()
#define rep(i,a,b) for( int i=a;i<b;i++)
#define repr(i,a,b) for( int i=a;i>=b;i--)
#define bitcount __builtin_popcount
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(n,m) memset(n,m,sizeof(n))
#define ii pair<int,int>
#define iii tuple<int, int, int>
#define si set<int>
#define vi vector<int>
#define vii vector<ii>
#define mi map<int,int>
#define lb lower_bound
#define ub upper_bound
#define present(s,x) (s.find(x) != s.end())
#define ford(container, it) for(auto it:container)
#define fors(container, it, a, b) for(auto it = a; it != b; it++)
#define Anurag_Gupta ios_base::sync_with_stdio(0);
#define IIIT_ALLD cin.tie(0);cout.tie(0);
#define mod 987654319
#define EPSILON 1e-9
#define PI acos(-1)
#define inf 1e17
#define int long long
#define debug(a) cerr<<#a<<": ";for(auto i:a)cerr<<i<<" ";cerr<<'\n';
#define trace(a) cerr<<#a<<": "<<a<<"\n"
#define gcd(a,b) __gcd(a,b)
using namespace std;
int add(int a, int b, int c){int res=a+b;return(res>=c?res-c:res);}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
int mul(int a, int b, int c){int res=(int)a*b;return(res>=c?res%c:res);}
template<typename T>T power(T e, T n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
template<typename T>T mdpower(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
/*------------------------------------------------------------------------------------------------------------------*/

int32_t main()
{
    Anurag_Gupta
    IIIT_ALLD
 
    
  
 
    int r;
    cin>>r;
    cout<<2*PI*r<<"\n";







 
#ifndef LOCAL_DEFINE
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}


Measured memory_bytes: 3792
width, high, num = map(int, input().split())
arr = [list(map(int, input().split())) for i in range(num)]

def rec(xl, yl, xh, yh, arr):
    if xl>xh or yl>yh:
        return 0
    if len(arr) == 0:
        return (xh-xl)*(yh-yl)
    if arr[0][2] == 1:
        xl = max(arr[0][0], xl)
    elif arr[0][2] == 2:
        xh = min(arr[0][0], xh)
    elif arr[0][2] == 3:
        yl = max(arr[0][1], yl)
    elif arr[0][2] == 4:
        yh = min(arr[0][1], yh)
    arr = arr[1:len(arr)]
    return rec(xl, yl, xh, yh, arr)

print(rec(0, 0, width, high, arr))

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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const int MOD = 1000000007;

        static void Solve()
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            var dp = new int[s.Length + 1, t.Length + 1];

            for (int i = 0; i < s.Length; ++i)
            {
                for (int j = 0; j < t.Length; ++j)
                {
                    if (s[i] == t[j])
                    {

                        dp[i + 1, j + 1] = Math.Max(dp[i, j] + 1, dp[i + 1, j + 1]);


                    }

                    dp[i + 1, j + 1] = Math.Max(dp[i + 1, j], dp[i + 1, j + 1]);

                    dp[i + 1, j + 1] = Math.Max(dp[i, j + 1], dp[i + 1, j + 1]);

                }
            }
            int len = dp[s.Length, t.Length];
            int lenS = s.Length;
            int lenT = t.Length;
            int x = lenS;
            int y = lenT;
            var cc = new char[len];
            
            while(x > 0 && y > 0)
            {
                if( dp[x,y] == dp[x-1,y])
                {
                    x--;
                }else if( dp[x,y] == dp[x, y-1])
                {
                    y--;
                }
                else
                {
                    x--;
                    y--;
                    cc[--len] = t[y];
                }
            }
            string ans = new string(cc);
            Console.WriteLine(ans);
        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 47712
N = int(input())
A = list(map(int,input().split()))
ans = 1
re = 0

for i in range(2,N,1):
    #print(re)
    if re == 0:
        if A[i-2] >= A[i-1] >= A[i]:
            re = 0
        elif A[i-2] <= A[i-1] <= A[i]:
            re = 0
        else:
            ans +=1
            re = 1
    else:
        re = 0
        continue
    if A[i-1] == A[i]:
        A[i-1] = A[i-2]
            


print(ans)


Measured memory_bytes: 14252
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>

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

using namespace std;

struct vert { int x, y; };

vert vs[51];

int main()
{
	int N,num=1;
	while(cin>>N,N)
	{
		rep(i,N)
		{
			cin>>vs[i].x>>vs[i].y;
		}

		int area = 0;
		rep(i,N)
		{
			int j = (i + 1) % N;
			area += vs[i].x * vs[j].y - vs[i].y * vs[j].x;
		}
		cout.precision(1);
		cout << num++ << " " << fixed << abs(area) / 2.0 << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
		int n = Integer.parseInt(reader.readLine());
		char[] list = reader.readLine().toCharArray();
		int clip = 0;
		for(int i = 0;i<n;i++){
			if(list[i]=='1') clip++;
		}
		int[][] rems = new int[2][n+1];
		ArrayList<Integer> l = new ArrayList<>();
		l.add(-1);
		l.add(1);	
      	if(clip==1)
        {
          for(int i=0;i<n;i++)
          {
            if(list[i]=='1')
              	writer.write(0+"\n");
            else
            {
              if(list[n-1]=='1')
                    writer.write(2+"\n");
                else{
                    if(i==n-1)
                        writer.write(2+"\n");
                    else
                        writer.write(1+"\n");
                    }
            }
          }
        }
      else{
		for(int i=0;i<2;i++){
			int temp = clip + l.get(i);
			for(int j = 0;j<=n;j++){
				if(temp==0){
					rems[i][j] = 0;
					continue;
				}
				if(j==0) rems[i][j] = 1%temp;
				else rems[i][j] = (rems[i][j-1]*2)%temp;
			}
		}
		int[] remlist = new int[2];
		for(int i = 0;i<2;i++){
			int temp = clip + l.get(i);
			for(int j = 0;j<n;j++){
				if(list[j]=='1'){
					remlist[i] = (remlist[i]+rems[i][n-j-1])%temp; 
				}
			}
		}
		for(int i = 0;i<n;i++){
			if(list[i]=='1'){
				if(clip==1){
					writer.write(0+"\n");
					continue;
				}
				int lp = ((remlist[0] - rems[0][n-i-1]) + (clip-1))%(clip-1);
				writer.write((1+solve(lp))+"\n"); 
			}
			else{
				int lp = (remlist[1] + rems[1][n-i-1])%(clip+1);
				writer.write((1+solve(lp))+"\n");	
			}
		}}
		writer.flush();
	}
	public static int solve(int p){
		if(p==0) return 0;
		int temp = p;
		int cnt = 0;
		while(p>0){
			if(p%2==1) cnt++;
			p=p>>1;
		}
		if(cnt==0) return 1; 
		return 1 + solve(temp%cnt);
	}
}

Measured memory_bytes: 51328
from collections import Counter
n = int(input())
l = Counter(list(map(int,input().split())))
m = int(input())
t = list(map(int,input().split()))
#print(l)
if n<m:
  print("NO")
  exit()
for j in t:
  if ( j in l ) and l[j]>=1:
    l[j] -= 1
 #   print(l)
    continue
  else:
    print("NO")
    exit()
else:
  print("YES")

Measured memory_bytes: 45792
//#include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <numeric>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
    ll X;
    cin >> X;
    ll P = X;
    bool prime_flag = true;
    for(ll i = P; i <= 100003; i++){
        for(ll j = 2; j*j <= i; j++){
            if( (i % j) == 0 ){
                prime_flag=false;
                break;
            }

        }

        if(prime_flag){//iがprimeの時
            P=i;
            break;
        }
        prime_flag=true;
    }
    cout << P << endl;


    /*
    //以下はぼつ
    vector<ll> N;
    bool flag=false;//割り切れるかフラグ
    if(X==2){
        cout << 2 << endl;
        return 0;
    }
    N.push_back(2);
    
    for(ll i = 3; i <= INF; i++){
        for(ll j = 0; j < N.size(); j++){
            if( (i % N[j]) == 0 ){
                flag=true;
            }
        }

        if(!flag){//割り切れない時
            N.push_back(i);
            if(i>=X){
                break;
            }
        }
        flag=false;
    }
    cout << N[N.size()-1] << endl;
    */

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <queue>
using namespace std;

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

int dp[1005][1005];
int main(){
    int h, w; cin >> h >> w;
    char map[h][w+1];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    rep(i,h) cin >> map[i];
    rep(i,h) rep(j, w){
        if(map[i][j] != '#'){
            if(j+1 < w && map[i][j+1] != '#') dp[i][j+1] = (dp[i][j+1] + dp[i][j]) % MOD;
            if(i+1 < h && map[i+1][j] != '#') dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % MOD;
        }
    }
    cout << dp[h-1][w-1] << endl;
    return 0;
}

Measured memory_bytes: 5120
N, x = map(int, input().split())
a = [0] + list(map(int, input().split()))
cnt = 0
for i in range(N):
    if a[i]+a[i+1]>x:
        tmp = a[i]+a[i+1]-x
        a[i+1] -= tmp
        cnt+=tmp
print(cnt)


Measured memory_bytes: 14064
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<stack>
using namespace std;
int main() {
	string s;	cin >> s;
	vector<char> ans;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == '1') {
			ans.push_back('1');
		}
		else if (s[i] == '0') {
			ans.push_back('0');
		}
		else if (s[i] == 'B'&&ans.size() > 0) {
			ans.pop_back();
		}
	}
	
	for (auto e : ans) {
		cout << e;
	}
	cout << endl;
	cin >> s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define OP ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
const int inf = int(1e9);
const int mod = inf + 7;
const double PI = acos(-1.0);
using namespace std;
const int N = 1e5 + 155;
template<typename T>
inline void read(T&x){
    x=0;int 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(); }
    x*=f;
}
 
 
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) r = (r * a) % mod;
		a = (a * a) % mod;
		n >>= 1;
	}
	return r;
}

int sqr(int a, int b) {
	return (a - b) * (a - b);
}
 
void solve(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	double r = accumulate(all(a), double(0)) / n;
	int x = round(r);
	int ans = 0;
	for(int u: a) {
		ans += sqr(u, x);
	}
	cout << ans;
}

int main(){
    OP
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
	//cin >> t;
    for(int i = 1; i <= t; i++) {
        solve();
    }
    return 0;
}

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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

int main() {
	int N, D;
	cin >> N >> D;
	int l = D * 2 + 1;
	cout << (l + N - 1) / l << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdbool.h>
#include<stdlib.h>

int main(void){
    int l;
    scanf("%d",&l);
    
    double a,b,c;
    a = l/3.0;
    b = l/3.0;
    c = l/3.0;

    double v = a*b*c;

    printf("%f",v);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int A = sc.nextInt();
		int H[] = new int[N];
		for(int i = 0; i < N; i++) {
			H[i] = sc.nextInt();
		}
		int ans = 0;
		double min = Double.MAX_VALUE;
		for(int i = 0; i < N; i++) {
			if(Math.abs(((double)T - (double)H[i] * 0.006) - (double)A) < min) {
				min = Math.abs(((double)T - (double)H[i] * 0.006) - (double)A);
				ans = i + 1;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22356
#include <iostream>

int main() {

	int a, b;

	std::cin >> a;
	std::cin >> b;

	if (a == b) {
		std::cout << "a == b" << std::endl;
	}
	else if (a < b) {
		std::cout << "a < b" << std::endl;
	}
	else{
		std::cout << "a > b" << std::endl;
	}

	return 0;

}


Measured memory_bytes: 3088
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	n := nextInt()
	n = n % 10
	if n <= 1 || n == 6 || n == 8 {
		fmt.Println("pon")
	} else if n == 3 {
		fmt.Println("bon")
	} else {
		fmt.Println("hon")
	}

}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

func max(a, b int) int {
	return int(max64(int64(a), int64(b)))
}

func max64(a int64, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func min(a, b int) int {
	return int(min64(int64(a), int64(b)))
}

func min64(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	// 10^2 = 100ってことは10に10を1回掛けることだね
	// なので初期値を含めると上限b-1未満
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


Measured memory_bytes: 1760
#include <iostream>
#include<math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <map>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)
typedef pair<int, int> P;


int main() {
    char C;
    cin >> C;
    C ++;
    cout << C << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=4010;
typedef bitset<N>B;
typedef long long ll;
const int mod=998244353;
ll p[N];
void init()
{
    p[0]=1;
    for(int i=1;i<N;i++) p[i]=p[i-1]*2%mod;
}
int last(B x)
{
    for(int i=N-1;i>=0;i--)
        if(x[i]) return i;
    return -1;
}
B gcd(B x,B y)
{
    if(x.none()) return y;
    if(y.none()) return x;
    int a=last(x),b=last(y);
    if(a<b) swap(x,y),swap(a,b);
    return gcd(y,x^(y<<a-b));
}
int n;
B x,y,a[7];
int main()
{
    init();
    cin>>n>>x;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=1;i<n;i++) a[0]=gcd(a[0],a[i]);
    ll ans=0;
    int s=last(x),t=last(a[0]);
    y.reset();
    for(int i=s;i>=t;i--)
    {
        if(x[i]) ans=(ans+p[i-t])%mod;
        if(x[i]!=y[i]) y^=a[0]<<(i-t);
    }
    for(int i=s;i>=0;i--)
    {
        if(x[i]==y[i])
        {
            if(i==0) ans++;
            continue;
        }
        if(x[i]) ans++;
        break;
    }
    printf("%lld\n",ans%mod);
}


Measured memory_bytes: 12544
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,m=map(int, input().split())
    checkl=[0]*m
    for i in range(n):
        a=list(map(int,input().split()))
        b=a[1:]
        for i in range(len(b)):
            checkl[b[i]-1]+=1
    print(checkl.count(n))

resolve()

Measured memory_bytes: 3060
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, K = map(int, input().split())
    P = tuple(map(lambda x: int(x) - 1, input().split()))
    C = tuple(map(int, input().split()))
    ans = -10**18

    for i in range(N):
        k = K
        D = [[0, 0] for i in range(N)]
        x = i
        X, Y = 0, 0
        count = 0
        score = 0
        for j in range(K):
            if D[P[x]][0] == 0:
                score += C[P[x]]
                D[P[x]][0] = score
                D[P[x]][1] = count
                x = P[x]
                count += 1
            else:
                X = D[P[x]][0] - C[P[x]]
                score -= X
                L = (count - D[P[x]][1])
                k -= D[P[x]][1]

                score *= (k // L) - 1
                l = (K % L) + L
                score += X
                ans = max(ans, score)
                for _ in range(l):
                    score += C[P[x]]
                    ans = max(ans, score)
                    x = P[x]

                break
            if score > ans:
                ans = score
    print(ans)


main()


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

using namespace std;

int main() {
  int n, a, b;
  string s;
  cin >> n >> a >> b >> s;
  int aa = 0, bb = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'a') {
      if (aa + bb < a + b) {
        cout << "Yes" << endl;
        aa++;
        continue;
      }
    } else if (s[i] == 'b') {
      if (aa + bb < a + b && bb < b) {
        cout << "Yes" << endl;
        bb++;
        continue;
      }
    }
    cout << "No" << endl;
  }

  return 0;
}

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

int main() {
  std::string S;
  std::cin >> S;
  int upper = std::stoi(S.substr(0,2));
  int lower = std::stoi(S.substr(2,2));
  auto mm = [](int n){
    return n>=1 && n<=12;
  };
  if(mm(upper)){
    if(mm(lower))
      std::cout << "AMBIGUOUS" << std::endl;
    else
      std::cout << "MMYY" << std::endl;
  }
  else{
    if(mm(lower))
      std::cout << "YYMM" << std::endl;
    else
      std::cout << "NA" << std::endl;
  } 
  return 0;
}


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

using namespace std;

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
 	string s,ss;int c,k,t=1;char m;
  	cin>>s;
  	ss=s;
  	reverse(ss.begin(),ss.end());
  	cin>>c;
  	while(c--){
      cin>>k;
      if(k==1){
      	if(t==0) t=1;
        else t=0;
      }
      else{
      	cin>>k>>m;
        if((k==1&&t==1)||(k==2&&t==0)) {s.insert(0,1,m);ss.push_back(m);}
      	else {ss.insert(0,1,m);s.push_back(m);}
      }
      
    }
  
  	if(t==0) cout<<ss;
    else cout<<s;

}

    

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

int main()
{
    int N;
    cin >> N;
    vector<int> W(N);
    for (int i = 0; i < N; i++) {
        cin >> W[i];
    }
    
    int ans = 1e9;
    for (int i = 1; i <= N; i++) {
        int S1 = 0;
        int S2 = 0;
        for (int j = 1; j <= N; j++) {
            if (i <= j) {
                S1 += W[j-1];
            }else{
                S2 += W[j-1];
            }
        }
        int result = abs(S1 - S2);
        ans = min(result, ans);
    }
    cout << ans << endl;
}

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

int main() {
	int t,n,s,f,sum=0;
	
	while(1){
		cin>>t;
		if(t==-1) break;
		if(t>30) sum=1150+1250+1400+(t-30)*160;
		else if(t>20) sum=1150+1250+(t-20)*140;
		else if(t>10) sum=1150+(t-10)*125;
		else if(t<=10) sum=1150;

        cout<<4280-sum<<endl;

		sum=0;
	}
	return 0;
}

Measured memory_bytes: 2968
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        boolean first=true;
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int i=0,n=0,m=0,l=0;
            while ((line = br.readLine()) != null) {
            	byte[] a=line.getBytes ("US-ASCII");
            	
            	for(int j=0;j<a.length;j++){
            		if(a[j]<=90&&a[j]>=65){
            			a[j]+=32;
            		}else if(a[j]<=122&&a[j]>=97){
            			a[j]-=32;
            		}
            	}
            	System.out.println(new String(a,"US-ASCII"));
            	break;
            }
        }
    }

}

Measured memory_bytes: 24352
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main() 
{   ll h,w;
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>h>>w;
    ll dp[h][w][h][w];
    vector<string> v;
    for(int i=0;i<h;i++)
    {
        string s;
        cin>>s;
        v.push_back(s);
    }
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            for(int k=0;k<h;k++)
                for(int l=0;l<w;l++) dp[i][j][k][l]=mod;
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
        {   if(v[i][j]=='.'){
            if(i-1>=0 && v[i-1][j]=='.') dp[i][j][i-1][j]=1;
            if(j+1<w && v[i][j+1]=='.') dp[i][j][i][j+1]=1;
            if(i+1<h && v[i+1][j]=='.') dp[i][j][i+1][j]=1;
            if(j-1>=0 && v[i][j-1]=='.') dp[i][j][i][j-1]=1;
        }
        }
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++) dp[i][j][i][j]=0;

    for(int k=0;k<h;k++)
    {
        for(int l=0;l<w;l++)
        {   if(v[k][l]=='.'){
            for(int i=0;i<h;i++)
                for(int j=0;j<w;j++)
                    for(int m=0;m<h;m++)
                        for(int n=0;n<w;n++) dp[i][j][m][n]=min(dp[i][j][m][n],dp[i][j][k][l]+dp[k][l][m][n]);
        }

        }
    }
    ll ans=-1;
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            for(int k=0;k<h;k++)
                for(int l=0;l<w;l++)
                    if(i==k && j==l) continue;
                    else if(dp[i][j][k][l]!=mod) ans=max(ans,dp[i][j][k][l]);
    cout<<ans;
    
}

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

const int N = 2e5 +5;
typedef long long ll;

int n, a[N], x;

int main() {
	cin>>n;
	for(int i = 2; i <= n; i++) {
		cin>>x;
		a[x]++;
	}
	for(int i = 1; i <= n; i++)
		cout<<a[i]<<endl;
	return 0;
}

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


int main(){
    int N,X;
    cin >> N >> X;
    vector<int> M(N);

    for(int i=0; i<N;i++) cin >> M.at(i);
    sort(M.begin(),M.end());//昇順ソート
    int simplesum=0;
    simplesum = accumulate(begin(M), end(M), 0);//全種類の合計
    
    int nokori = X - simplesum;//残りの材料のグラム数

    //できるだけ多く作る。材料少ないものから
    int count=0;
    int kosuu=0;
    kosuu = kosuu + N;
   // cout << M.at(0) << endl;
    while(1){

        if(nokori - M.at(0)<=0){
            break;
        }
        kosuu = kosuu + (nokori / M.at(count));
        nokori = nokori - (nokori / M.at(count)) * M.at(count);
        
        count++;

    }


    //cout << nokori << endl;
    cout << kosuu << endl;
    return 0;
}

Measured memory_bytes: 256