akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
int main(){
	string S;
	cin>>S;
	int N=S.length();
	ll cnt=0;
	ll ans=0;
	for(int i=0;i<N;i++){
		if(S[i]=='B')
			cnt++;
		else
			ans+=cnt;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
/*
ID: zhaowei10
TASK:
LANG: C++14
*/
#include "bits/stdc++.h"

using namespace std;

#ifdef LOCAL
#include "../../_library/cc/debug.h"
#define FILE "test"
#else
#define debug(...) 0
#define FILE ""
#endif

int64_t pwr(int64_t b, int64_t e, int64_t m) {
  int64_t res = 1;
  while (e) {
    if (e & 1) {
      res *= b;
      res %= m;
    }
    b *= b;
    b %= m;
    e >>= 1;
  }
  return res;
}

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  if (fopen(FILE ".in", "r")) {
    freopen(FILE ".in", "r", stdin);
    freopen(FILE ".out", "w", stdout);
  }

  int64_t m, n;
  cin >> m >> n;
  cout << pwr(m, n, 1e9 + 7) << '\n';
}




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

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

// chmax, chmin
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; }

int main() {
    int N,K;
    cin >> N >> K;
    map<int,int> m;
    REP(i,N){
        int a;
        cin >> a;
        m[a] += 1;
    }
    
    vector<int> v;
    for ( auto itr = m.begin(); itr != m.end(); ++itr){
        int val = itr->second;
        v.push_back(val);
    }
    
    sort(v.begin(),v.end());
    //for ( auto a: v) cout << a << endl;
    int ans = 0;
    if ( v.size() > K ){
        for ( int i = 0; i < v.size()-K; ++i){
            ans += v[i];
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 13488
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define vvi vector<vi >
#define str string
#define vs vector<str>
#define vb vector<bool>
#define slli set<lli>
#define mii map<int, int>
#define mlli map<int, lli>
#define msi map<str, int>
#define mp make_pair
#define pii pair<int, int>
#define pll pair<lli, lli>
#define vpii vector<pii >
#define vpll vector<pll >
#define pb push_back
#define loop(i, s, l, j) for(int i = s; i < l; i += j)
#define rloop(i, s, l, j) for(int i = s; i >= l; i -= j)
#define rep(i, n) loop(i,0,n,1)
#define rrep(i, n) rloop(i,n-1,0,1) 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ft first
#define sd second   
#define mit mii::iterator
#define vit vi::iterator
#define all(a) a.begin(),a.end()
#define min3(a, b, c) min(a, min(b, c))
#define mod 1000000007
#define inf 100000000000000000
#define limit 200005
#define minval -100000000000000000
/**********************************************************************************************************************************************/
int dx4[4] = {0, -1, 0, 1};
int dy4[4] = {1, 0, -1, 0};
int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Power(int base,int exp){int ans=1;  while(exp > 0){if(exp&1)ans=(1LL*ans*base)%mod; exp=exp>>1; base=(1LL*base*base)%mod;}  return ans;}
/**********************************************************************************************************************************************/ 

void input()
{
	int n;
	cin >> n;

	lli p10 = 1;
	rep(i,n)
		p10 = (p10 * 10)%mod;
	lli p9 = 1;
	rep(i,n)
		p9 = (p9 * 9)%mod;
	lli p8 = 1;
	rep(i,n)
		p8 = (p8 * 8)%mod;


	lli ans = p10;
	ans = (ans + p8)%mod;
	ans = (ans + (mod-p9))%mod;
	ans = (ans + (mod-p9))%mod;
	cout << ans << '\n';
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
 
    fastio();
    int q = 1;
    //cin >> q;
    while(q--)
        input();
}

Measured memory_bytes: 3636
n=int(input())
a=0
b=0
wa=0
frag=1
tmpa=[]
while frag:
    for i in range(wa+1):
        a=i
        b=wa-i
        #print(a,b)
        if a ** 5 - b ** 5 == n:
            frag=0
            break
        b = 0 - b
        #print(a, b)
        if a ** 5 - b ** 5 == n:
            frag=0
            break
    wa+=1
print(a,b)

Measured memory_bytes: 64924
#include <bits/stdc++.h>
#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()
{
	string s, t;
	cin >> s >> t;

	int sLen = s.size();
	int tLen = t.size();

	// 探索
	int curLoops = 0;
	int curPos = -1; // 0文字目に対応できるよう最初だけ-1
	int chPos;
	REP(idx, tLen) {
		if (curPos == -1) {
			chPos = (int)s.find(t[idx]);
		} else {
			chPos = (int)s.find(t[idx], curPos + 1);
			if (chPos < 0) {
				// 先頭から再探索
				chPos = (int)s.find(t[idx]);
			}
		}
		if (chPos < 0) {
			// 解なし
			cout << "-1" << endl;
			return 0;
		}

		if (curPos >= chPos) {
			++curLoops;
		}
		curPos = chPos;
	}

	long answer = (long)curLoops * sLen + curPos + 1L;

	cout << answer << endl;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int n;
	cin>>n;
	vi d(n);
	int f,l,sf,sl;
	rep(i,0,n*(n-1)/2){
		cin>>f>>l>>sf>>sl;
		f--;
		l--;
		if(sf<sl){
			d[l]+=3;
		}else if(sf>sl){
			d[f]+=3;
		}else{
			d[l]++;
			d[f]++;
		}
	}
	vi e=d;
	sort(all(e));
	rep(i,0,n){
		int res=upper_bound(all(e),d[i])-e.begin();
		o(n+1-res);
	}
}

Measured memory_bytes: 1216
#include<iostream>
#include<climits>
#include<algorithm>
using namespace std;
const long long INF = LLONG_MAX;
int main(){
  int n,m;
  long long k;
  long long a[200005]={0};
  long long b[200005]={0};
  cin>>n>>m>>k;
  
  for(int i=1;i<=n;i++){
    cin>>a[i];
    a[i]+=a[i-1];
  }
  a[n+1]=INF;
  for(int i=1;i<=m;i++){
    cin>>b[i];
    b[i]+=b[i-1];
  }
  b[m+1]=INF;
  
  int maxim=0;
  int start = upper_bound(a,a+n+1,k) - 1 - a;
  for(int i=start;i>=0;i--){
    int index=upper_bound(b,b+m+1,k-a[i]) - 1 - b;
    maxim=max(i+index,maxim);
  }
  cout<<maxim<<endl;
  return(0);
}

Measured memory_bytes: 6716
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<set>
#include<fstream>
#include<map>
#include<string>
#include <stdio.h>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<stack>
#include<climits>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll>vl;
typedef vector<int>vi;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef vector<char>vc;
typedef vector<string>vs;
#define MP make_pair
#define all(v) v.begin(),v.end()
const ll mod = 1000000007;
const ll OO = (ll)1e18;
const int dx[] = { 0, 1, -1, 0 };
const int dy[] = { 1, 0, 0, -1 };
ll gcd(ll a, ll b){ if (b == 0){ return a; }return gcd(b, a % b); }
ll fast_power(double base, ll power){
	if (power == 1) return base;
	if (power % 2 == 0) return fast_power((base*base), power / 2);
	else return(base*fast_power((base*base), power / 2));
}
//#pragma warning (disable : 4996)
void Qalbaz()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	
}

int main(){
	//Qalbaz();
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int n;
	cin >> n;
	vector < pair<pair<ll, ll>, ll>> vec(n);
	for (int i = 0; i < n - 1; i++)
	{
		cin >> vec[i].first.first >> vec[i].first.second >> vec[i].second;
	}
	ll ans, res;
	for (int i = 0; i < n - 1; i++)
	{
		ans = vec[i].first.first + vec[i].first.second;
		for (int j = i + 1; j < n - 1; j++)
		{
			if (ans % vec[j].second == 0)
			{
				if (ans >= vec[j].first.second)
					ans += vec[j].first.first;
				else
					ans = vec[j].first.second + vec[j].first.first;
			}
			else
			{
				res = ans / vec[j].second;
				ans = (res + 1) * vec[j].second;
				if (ans >= vec[j].first.second)
					ans += vec[j].first.first;
				else
					ans = vec[j].first.second + vec[j].first.first;
			}
		}
		cout << ans << "\n";
	}
	cout << "0\n";
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int n, c, e, ans[4009], pre[4009], dp[4009], ps[4009][4009], l[8002009], r[8002009], p[8002009]; long long s[4009];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%lld", &s[i]), s[i] += s[i - 1];
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j <= n; j++) {
			l[c] = i, r[c] = j, p[c] = c, c++;
		}
	}
	sort(p, p + c, [](int i, int j) { return s[r[i]] - s[l[i]] != s[r[j]] - s[l[j]] ? s[r[i]] - s[l[i]] < s[r[j]] - s[l[j]] : i > j; });
	fill(dp + 1, dp + n + 1, -(1 << 30));
	for (int i = 0; i < c; i++) {
		if (dp[r[p[i]]] < dp[l[p[i]]] + 1) {
			dp[r[p[i]]] = dp[l[p[i]]] + 1;
			ps[r[p[i]]][l[p[i]]] = pre[l[p[i]]];
			pre[r[p[i]]] = l[p[i]];
		}
	}
	printf("%d\n", dp[n]);
	int p1 = n, p2 = pre[n];
	while (p2 != 0) {
		ans[e++] = p2;
		swap(p1, p2);
		p2 = ps[p2][p1];
	}
	for (int i = e - 1; i >= 0; i--) printf(i == 0 ? "%d\n" : "%d ", ans[i]);
	return 0;
}


Measured memory_bytes: 139200
#include<iostream>
#include<queue>
#include<map>
#define LEN 100
#define BASE 25

using namespace std;

int maps[LEN][LEN];
int off[LEN][LEN];

int checker[4];
int ncheck[4];

map<int, int> points[LEN];

class State {
public:
	char where;
	int enemy;
	int budget;
	int check[4];
	State() {check[0]=0;check[1]=0;check[2]=0;check[3]=0;}
	State(char w, int e, int b ) {
		where = w;
		enemy = e;
		budget = b; 
		check[0] = ncheck[0];
		check[1] = ncheck[1];
		check[2] = ncheck[2];
		check[3] = ncheck[3];
	}
};


inline bool operator< ( const State& a, const State& b) {
	if( a.enemy == b.enemy )
		return a.budget > b.budget;
	return a.enemy < b.enemy;
}

inline bool operator> ( const State& a, const State& b) {
	if ( a.enemy == b.enemy )
		return a.budget < b.budget;
	return a.enemy > b.enemy;
}

priority_queue<State, vector<State>, greater<State> > status;

inline void copy ( State now ) {
	checker[0] = now.check[0];
	checker[1] = now.check[1];
	checker[2] = now.check[2];
	checker[3] = now.check[3];
}

inline void ncopy ( ) {
	ncheck[0] = checker[0];
	ncheck[1] = checker[1];
	ncheck[2] = checker[2];
	ncheck[3] = checker[3];
}

inline bool check ( int i ) {
	return 0 == ((1<<(i%25)) & checker[i/BASE]);
}

inline void add ( int i ) {
	ncheck[i/BASE] = ((1<<(i%25)) | checker[i/BASE]);
}

inline void insert ( int i, int e, int b ) {
	
	map<int,int>::iterator itr = points[i].find(e);
	if ( itr == points[i].end() ) {
		points[i][e] = b;
		status.push(State(i,e,b));
	} else if ( (*itr).second < b ) {
		(*itr).second = b;
		status.push(State(i,e,b));
	}
	
	itr++;
	int min = b+1;
	
	while( itr != points[i].end() ) {									
		if ((*itr).second > min) {
			(*itr).second = min;
		} else {
			min = (*itr).second+1;
		}
		itr++;
	}
}

int main () {


	while ( true ) {
		int n,m,l;
		cin >> n >> m >> l;

		if ( n == 0 )
			break;

		for ( int i=0; i<n; i++ ) {
			for ( int j=0; j<n; j++ ) {
				maps[i][j] = -1;
				off[i][j] = 0;
			}
			points[i].clear();
		}

		for ( int i=0; i<m; i++ ) {
			int a,b,d,e;
			cin >> a >> b >> d >> e;

			maps[a-1][b-1] = maps[b-1][a-1] = d;
			off[a-1][b-1] = off[b-1][a-1] = e;
		}

		for ( int i=0; i<4; i++ ) {
			ncheck[i] = 0;
			checker[i] = 0;
		}

		priority_queue<State, vector<State>, greater<State> > empty;
		status = empty;

		ncheck[0] = 1;
		status.push(State(0,0,l));
		int count = 0;
		while(!status.empty()) {
			State now = status.top();
			status.pop();
			if ( now.where == n-1 ) {
				cout << now.enemy << endl;
				break;
			}

			copy(now);

			for ( int i=0; i<n; i++ ) {
				if ( maps[now.where][i] > 0 ) {
					if ( check( i ) ) {
						ncopy();
						add(i);
						int e, b;
						if ( off[now.where][i] == 0 ) {
							e = now.enemy;
							b = now.budget;
							insert(i,e,b);
						} else {
							if ( now.budget - maps[now.where][i] >= 0 ) {
								e = now.enemy;
								b = now.budget - maps[now.where][i];
								insert(i,e,b);
							}
							e = now.enemy + off[now.where][i];
							b = now.budget;
							insert(i,e,b);
						}
					}
				}
			}
		}
	}
}

		

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

const int DIM = 2e5 + 5;

int arr[DIM];

int main( void ) {
    
    int n, l;
    cin >> n >> l;
    
    int p = -1;
    for( int i = 1; i <= n; i ++ ) {
        cin >> arr[i];
        
        if( i >= 2 && arr[i - 1] + arr[i] >= l )
            p = i - 1;
    }
    
    if( p == -1 )
        cout << "Impossible\n";
    else {
        cout << "Possible\n";
        
        for( int i = 1; i < p; i ++ )
            cout << i << "\n";
        for( int i = n - 1; i > p; i -- )
            cout << i << "\n";
        cout << p << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 1152
n = int(input())
d = list(map(int, input().split()))
if d[0] != 0:
    print(0)
else:
    import collections
    c = collections.Counter(d)
    c_sorted = sorted(c.items())
    u = [x[1] for x in c_sorted]
    u.remove(u[0])
    if len(u)!= max(d):
        print(0)
    else:
        if d.count(0) > 1:
            print(0)
        else:
            x = 1
            for i in range(len(u)-1):
                x = x * (u[i] ** u[i+1])
                 
            print(x%998244353)

Measured memory_bytes: 69684
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

Measured memory_bytes: 78436
#include <iostream>
#include <cmath>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ':' << x << endl

using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

int main(){
    int n, m;
    int A[100], B[100];
    cin >> n >> m;
    for(int i=0; i < m; i++)
        cin >>A[i] >> B[i];
    for(int i=0; i < m; i++)
        A[i]--, B[i]--;
    bool Path[8][8]={};
    for(int i=0; i < m; i++){
        Path[A[i]][B[i]] = 1;
        Path[B[i]][A[i]] = 1;
    }

    int Nodes[8]={0, 1, 2, 3, 4, 5, 6, 7};
    int cnt=0;
    do{
        if(Nodes[0]!=0) continue;
        for(int i=0; i < n; i++){
            if(i== n-1){
                cnt++;
                continue;
            }
            if(! Path[Nodes[i]][Nodes[i+1]]==1) break;
        }
    }while(next_permutation(Nodes, Nodes+n));

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
from functools import reduce

N, X = map(int, input().split())
x_list = list(map(int, input().split()))

if X not in x_list:
    x_list.append(X)
    x_list.sort()
    N += 1    

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

if N >= 3:
    space = [abs(x_list[i + 1] - x_list[i]) for i in range(N - 1)]
    print(reduce(gcd, space))
elif N == 2:
    space = x_list[1] - x_list[0]
    print(space)
elif N == 1:
    space = x_list[0]
    print(space)






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

int main(){
  int x, a;
  cin >> x;
  a = x % 7;
  if (a == 0) {
     cout << "thu" << endl; 
  }else if (a == 1) {
     cout << "fri" << endl; 
  }else if (a == 2) {
      cout << "sat" << endl; 
  }else if (a == 3) {
      cout << "sun" << endl; 
  }else if (a == 4) {
      cout << "mon" << endl; 
  }else if (a == 5) {
      cout << "tue" << endl; 
  }else if (a == 6) {
      cout << "wed" << endl; 
  }
  return 0;
}



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

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

  vector<int> a(N);
  rep(i, 0, N) {
    cin >> a.at(i);
  }

  int Ans = -1, Button = 1, count = 0;

  while (count < N) {
    count++;
    if (a[Button-1] == 2) {
      Ans = count;
      break;
    } else {
      Button = a[Button-1];
    }
  }

  cout << Ans << endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>

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

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1 << 29; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

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

  int n;
	cin >> n;

	vector<ll> a(n);

	rep(i, n) {
		cin >> a[i];
	}

	ll ans = 0;
	int r = 0, syaku = a[0];
	rep(l, n) {
		while (r + 1 < n && (syaku & a[r+1]) == 0) {
			syaku += a[r+1];
			r++;
		}
		ans += (ll) r-l+1;
		syaku -= a[l];
	}

	std::cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N ;
    string s ;
    cin >> s ;
    N = s.length() ;
    int red , blue ;
    red = 0 ;
    blue = 0 ;
    for(int i = 0 ; i < N ; i++){
        if(s[i] - '0' == 0) red++ ;
        else blue++ ;
    }
    cout << min(red,blue)*2 << endl;
    return 0 ;
}


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

int N, A, B, C, L[10], INF = 1e9;

int rec(int i, int a, int b, int c){
	if (i == N){
		if (a != 0 && b != 0 && c != 0)	{
			return abs(A-a) + abs(B-b) + abs(C-c);
		}else{
			return INF;			
		}
	}
	return min({
		rec(i + 1, a, b, c),
		rec(i + 1, a + L[i], b, c) + (a == 0 ? 0 :10),
		rec(i + 1, a, b + L[i], c) + (b == 0 ? 0 :10),
		rec(i + 1, a, b, c + L[i]) + (c == 0 ? 0 :10)
	});
}

int main() {

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

    cout << rec(0,0,0,0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define inf 2147483647
#define infll LLONG_MAX
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    int n, x, y;
    cin >> n >> x >> y;
    vector<vector<int>> adj(n, vector<int>(n, 0));
    map<int, int> cost;

    x--; y--; // 0-origin

    for(int i=1; i<n; i++) cost[i] = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            adj[i][j] = min(j-i, min(abs(x-i)+1+abs(y-j), abs(y-i)+1+abs(x-j)));
            cost[adj[i][j]]++;
        }
    }

    for(auto p: cost) cout << p.second << endl;
}

Measured memory_bytes: 16128
//ABC 159 D-Banned K
//https://atcoder.jp/contests/abc159/tasks/abc159_d
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, i;
    cin >> n;
    vector<int> a(n);
    map<int, long long> cnt;
      
    for (i=0; i<n; i++){
	   cin>>a[i];
	   cnt[a[i]]++;
	}
	   
	long long ret = 0;
    map<int,long long>::iterator p;
   
    for(p=cnt.begin(); p!=cnt.end(); p++)
       ret += (p->second - 1) * p->second / 2;
    
	for(int k=0; k<n; ++k) 
	{
        long long n = cnt[a[k]];
        long long tmp = ret - (n-1)*n/2 + (n-2)*(n-1)/2;
        cout << tmp << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 10240
#include <iostream>

using namespace std;

typedef long long ll;

ll MOD = 1000000007;
ll dp[100005][13];

int main() {
    string s; cin >> s;
    dp[0][0] = 1;
    for(ll i = 1; i<= s.size(); i++) {
        // printf("%lld桁目\n", i);
        int c;
        if(s[i-1] == '?') {
            c = -1;
        } else {
            c = s[i-1] - '0';
        }
        for(int j = 0; j < 13; j++) {
            if(c == -1) {
                for(int k = 0; k < 10; k++) {
                    // cout << j*10+k << endl;
                    dp[i][(j*10+k)%13] += dp[i-1][j];
                    dp[i][(j*10+k)%13] %= MOD;
                }
            } else {
                dp[i][(j*10+c)%13] += dp[i-1][j];
                dp[i][(j*10+c)%13] %= MOD;
            }
        }
    }
    for(int i = 0; i <= s.size(); i++) {
        for(int j = 0; j < 13; j++) {
            // printf("%3lld ", dp[i][j]);
            // cout << dp[i][j] << " ";
        }
        // cout << endl;
    }
    cout << dp[s.size()][5] << endl;
}


Measured memory_bytes: 10624
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include "math.h"
#include <set>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
double A,B,X;

vector <int > H;
int main()
{

	cin >> A >> B >> X;
	if(A+B+X>=22){
		cout << "bust";
	} else{
		cout << "win";
	}

}



Measured memory_bytes: 256
#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>

using namespace std;
typedef long long ll;
typedef pair<int,int> Pi;
#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()

char s[100010];

void solve(){
	scanf("%s", s+1);
	int n = (int)strlen(s+1);
	if((s[1] == s[n]) ^ (n%2 == 1)){
		puts("First");
	}
	else puts("Second");
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}

Measured memory_bytes: 384
# import sys
# input = sys.stdin.readline

def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))

n,m,k = mp()
a = lmp()
b = lmp()
a.append(int(1e12))
b.append(int(1e13))
ans = -1

def cum_sum(lst):
    cums = [0] * (len(lst)+1)
    cums[1] = lst[0]
    for i in range(2,len(lst)+1):
        cums[i] = cums[i-1] + lst[i-1]
    return cums

a = cum_sum(a)
b = cum_sum(b)
import bisect
for i in range(len(a)-1):
    can_use = k-a[i]
    if can_use < 0:
        continue
    u = bisect.bisect_right(b, can_use)
    cnt = i + u - 1
    ans = max(ans, cnt)
print(ans)







Measured memory_bytes: 111388
#include<cstdio>
#include<algorithm>

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

using namespace std;

const int INF=1<<29;
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

const int N_MAX=144,T_MAX=6;
int Dreyfus_Wagner(int n,int d[N_MAX][N_MAX],int nt,int *t){
	rep(k,n) rep(i,n) rep(j,n) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);

	static int dp[1<<T_MAX][N_MAX];
	rep(S,1<<T_MAX) rep(i,n) dp[S][i]=INF;
	rep(i,nt) rep(j,n) dp[1<<i][j]=d[t[i]][j];

	rep(S,1<<nt) if(S && S&S-1) {
		rep(p,n) for(int T=S-1&S;T;T=T-1&S) {
			dp[S][p]=min(dp[S][p],dp[T][p]+dp[S&~T][p]);
		}
		rep(p,n) rep(q,n) dp[S][p]=min(dp[S][p],dp[S][q]+d[p][q]);
	}

	return dp[(1<<nt)-1][t[0]];
}

int main(){
	for(int h,w;scanf("%d%d",&h,&w),h;){
		int d[N_MAX][N_MAX];
		rep(i,h) rep(j,w) rep(y,h) rep(x,w) d[i*w+j][y*w+x]=(i==y&&j==x?0:INF);

		int n=0,heart[6];
		rep(i,h) rep(j,w) {
			int choco; scanf("%d",&choco);
			if(choco) heart[n++]=i*w+j;
			rep(k,4){
				int y=i+dy[k],x=j+dx[k];
				if(0<=y && y<h && 0<=x && x<w) d[i*w+j][y*w+x]=1;
			}
		}

		printf("%d\n",h*w-Dreyfus_Wagner(h*w,d,n,heart)-1);
	}

	return 0;
}

Measured memory_bytes: 880
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
#include <iomanip>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)



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

    int L1 = L*L*L;
    
    

    long double V = (long double)(L1/27.0000000000);
    
    

    cout << fixed << setprecision(12) << V << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD (int)1e9+7
typedef long long llong;
using namespace std;

llong f(int x){
	llong res=1;
	for(int i=1;i<=x;++i){
		res*=i;
		res%=MOD;
	}
	return res;
}

int main(){
	int n,m;
	cin>>n>>m;
	
	if(abs(n-m)>1){
		cout<<0<<endl;
		return 0;
	}
	
	llong ans=f(n);
	ans*=f(m);
	ans%=MOD;
	
	if(abs(n-m)==0){
		ans*=2;
		ans%=MOD;
	}
	
	cout<<ans<<endl;
}

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

using namespace std;

int main() {
	int A, B, X;
	cin >> A >> B >> X;
	if (A <= X && X <= (A + B)) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 3572
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
using ll=long long;
using Vec = vector<ll>;
using P = pair<ll, ll>;
using VecP = vector<P>;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)

//static const ll MOD = 1000000007;
//static const ll INF = 1000000000000000000;
//#define PI 3.14159265358979323846
//
//int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
//
//int findSumDigits(int s) {
//    int num = 0;
//    int temp = 0;
//    while (s) {
//        temp = s % 10;
//        num += temp;
//        s = s / 10;
//    }
//    return num;
//}
//
//int countDivisorNum(int n) {
//    int count = 0;
//    for (int i = 1; i <= n; i++) {
//        if (n % i == 0) {
//            count++;
//        }
//    }
//    return count;
//}

int main() {
    ll n, d;
    cin >> n >> d;
    ll x, y;
    ll count = 0;
    ll result;
    rep(i, n, 0) {
        cin >> x >> y;
        result = x * x + y * y;
        if (result <= (d * d)) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3628
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

S = int(input())


def f(n: int) -> int:
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1


List_A = [S]
for i in range(10 ** 6):
    A = f(List_A[i])
    if A in List_A:
        print(i+1+1)
        break
    else:
        List_A.append(A)


Measured memory_bytes: 9132
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

struct StVal {
	ll v = 0; StVal() {}
	StVal(const ll _v) : v(_v) {}
	StVal(const StVal &v1, const StVal &v2) { v = max(v1, v2); }
	operator ll() const { return v; }
};

struct SegTree {
	int n;
	vector<StVal> st;
	vector<int> leaves;

	SegTree(const int n) : n(n), leaves(n) { init(1, 0, n - 1); }

	void init(const int si, const int lo, const int hi) {
		if (lo == hi) {
			if (si >= (int)st.size()) st.resize(si + 1);
			st[si] = StVal(); leaves[lo] = si;
		}
		else {
			const int mid = (lo + hi) >> 1;
			init(si << 1, lo, mid);
			init(si << 1 | 1, mid + 1, hi);
			st[si] = StVal(st[si << 1], st[si << 1 | 1]);
		}
	}

	StVal query(const int l, const int r) { return (l <= r && l < n && r >= 0) ? query(l, r, 1, 0, n - 1) : StVal(); }
	StVal query(const int l, const int r, const int si, const int lo, const int hi) {
		if (l <= lo && hi <= r) return st[si];

		const int mid = (lo + hi) >> 1;
		if (r <= mid) return query(l, r, si << 1, lo, mid);
		if (mid < l) return query(l, r, si << 1 | 1, mid + 1, hi);
		return StVal(query(l, r, si << 1, lo, mid), query(l, r, si << 1 | 1, mid + 1, hi));
	}

	void update(const int i, ll x) {
		int si = leaves[i]; st[si].v = x;
		for (si >>= 1; si; si >>= 1)
			st[si] = StVal(st[si << 1], st[si << 1 | 1]);
	}

	ll findMax() {
		ll res = 0;
		for (int i = 0; i < n; i++)
			res = max(res, st[leaves[i]].v);
		return res;
	}
};

vector<int> h, a;

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

	int n; cin >> n; SegTree st(n + 1);
	h.resize(n); a.resize(n);
	for (auto &x : h) { cin >> x; }
	for (auto &x : a) { cin >> x; }
	
	for (int i = 0; i < n; i++)
		st.update(h[i], st.query(0, h[i]) + a[i]);

	cout << st.findMax() << '\n';
	cin.ignore(2); return 0;
}

Measured memory_bytes: 9572
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

int main(){
    int N;
    while(std::cin >> N, N){
        int min = 500, max = 0;
        REP(i, N){
            int sum = 0;
            REP(j, 5){
                int p;
                std::cin >> p;
            
                sum += p;
            }

            min = std::min(min, sum);
            max = std::max(max, sum);
        }

        std::cout << max << " " << min << std::endl;
    }
}

Measured memory_bytes: 1160
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	list := make([]int, n)
	aList := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&list[i])
		aList[list[i]-1] = i + 1
	}

	for i := 0; i < n; i++ {
		fmt.Print(aList[i], " ")
	}
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define ls x << 1
#define rs x << 1 | 1
using namespace std;
const int N = 2e5 + 10;
int a[N], qz[N][2];
int mn[N << 2], tag[N << 2];

void down(int x) {
  if(tag[x]) {
    mn[ls] += tag[x];
    tag[ls] += tag[x];
    mn[rs] += tag[x];
    tag[rs] += tag[x];
    tag[x] = 0;
  }
}

void upd(int x, int l, int r, int L, int w) {
  if(l == r) {
    mn[x] = min(mn[x], w);
    return ;
  }
  down(x);
  int mid = (l + r) >> 1;
  if(L <= mid) upd(ls, l, mid, L, w);
  else upd(rs, mid + 1, r, L, w);
  mn[x] = min(mn[ls], mn[rs]);
}

void add(int x, int l, int r, int L, int R, int w) {
  if(L <= l && r <= R) {
    mn[x] += w;
    tag[x] += w;
    return ;
  }
  down(x);
  int mid = (l + r) >> 1;
  if(L <= mid) add(ls, l, mid, L, R, w);
  if(R > mid) add(rs, mid + 1, r, L, R, w);
  mn[x] = min(mn[ls], mn[rs]);
}

int get(int x, int l, int r, int L, int R) {
  if(L <= l && r <= R) {
    return mn[x];
  }
  down(x);
  int mid = (l + r) >> 1;
  if(R <= mid) return get(ls, l, mid, L, R);
  else if(L > mid) return get(rs, mid + 1, r, L, R);
  else {
    return min(get(ls, l, mid, L, R), get(rs, mid + 1, r, L, R));
  }
}

struct data {
  int l, r;
} q[N];

bool cmp(data A, data B) {
  return A.l == B.l ? A.r < B.r : A.l < B.l;
}


int main() {
  memset(mn, 0x3f, sizeof mn);
  int n;
  scanf("%d", &n);
  for(int i = 1; i <= n; ++i) {
    for(int j = 0; j < 2; ++j)
      qz[i][j] = qz[i - 1][j];
    scanf("%d", &a[i]);
    qz[i][a[i]]++;
  }
  upd(1, 0, n, 0, 0);
  int m;
  scanf("%d", &m);
  for(int i = 1; i <= m; ++i) {
    scanf("%d%d", &q[i].l, &q[i].r);
  }
  sort(q + 1, q + 1 + m, cmp);
  int lt = 1;
  for(int i = 1; i <= n; ++i) {
    for(; lt <= m && q[lt].l == i; ++lt)
      upd(1, 0, n, q[lt].r, get(1, 0, n, 0, q[lt].r));
    if(a[i])
      add(1, 0, n, 0, i - 1, 1);
    else 
      add(1, 0, n, 0, i - 1, -1);
  }
  printf("%d\n", get(1, 0, n, 0, n) + qz[n][0]);
  return 0;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,x=0;
    cin>>n;
    vector<int>a(n);
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(i=1;i<=n;i+=2)
    {
      a[i]=a[i]*a[i];
      if(a[i]%2)
        x++;
    }
    cout<<x<<endl;
    return 0;

}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << (x) << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;

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

    ll cnt = x / 11 * 2;

    if (x % 11 > 6) cnt += 2;
    else if (x % 11 > 0) cnt++;

    OUT(cnt);

    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
x = list(map(int, input().split()))
if m <= n:
    print(0)
    exit()

x.sort()

dif = [0] * (m-1)
for i in range(m-1):
    dif[i] = x[i+1] - x[i]

dif.sort()
print(sum(dif[:m-n]))

Measured memory_bytes: 52904
using System;
using System.Linq;

namespace ABC079
{
    class C
    {
        static void Main(string[] args)
        {
            var length = 4;

            var s = Console.ReadLine();
            var ABCD = s.Select(c => int.Parse(c.ToString())).ToArray();

            var bits = (1 << (length - 1));
            for (int i = 0; i < bits; i++)
            {
                var sum = ABCD[0];
                for (int j = 0; j < length - 1; j++)
                    if ((1 & (i >> (length - 2 - j))) == 1) sum += ABCD[j + 1];
                    else sum -= ABCD[j + 1];

                if (sum == 7)
                {
                    var ans = ABCD[0].ToString();
                    for (int j = 0; j < length - 1; j++)
                    {
                        if ((1 & (i >> (length - 2 - j))) == 1) ans += "+" + ABCD[j + 1].ToString();
                        else ans += "-" + ABCD[j + 1].ToString();
                    }
                    ans += "=7";
                    Console.WriteLine(ans);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 13396
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include<iomanip>

using namespace std;

const int N = 5000;
int n;
int stones[N];
bool win[N];
vector<int> graph[N];
bool check(int v, int par = -1)
{
	for (int i = 0; i < graph[v].size(); i++)
	{
		int u = graph[v][i];
		if (u != par && stones[u] < stones[v])
		{
			if (!check(u, v))
			{
				return true;
			}
		}
	}
	return false;
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> stones[i];
	}
	for (int i = 0; i < n - 1; i++)
	{
		int u, v;
		cin >> u >> v;
		graph[u - 1].push_back(v - 1);
		graph[v - 1].push_back(u - 1);
	}
	for (int i = 0; i < n; i++)
	{
		check(i);
	}
	for (int i = 0; i < n; i++)
	{
		if (check(i))
		{
			cout << i + 1 << " ";
		}
	}

}

	
            



Measured memory_bytes: 512
a, b, m = map(int, input().split())
a_l = list(map(int, input().split()))
b_l = list(map(int, input().split()))
coupons = [list(map(int, input().split())) for _ in range(m)]

ans = min(a_l) + min(b_l)
pairs = []
for a_i, b_i, c in coupons:
    pairs.append(a_l[a_i-1]+b_l[b_i-1]-c)

print(min(ans, min(pairs)))






Measured memory_bytes: 42412
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <queue>

using namespace std;

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

	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	sort(b.begin(), b.end(), greater<int>());
	int a_max = *max_element(a.begin(), a.end());

	// cout << "a_max " << a_max << endl;
	// for (auto x : b) {
	// 	cout << x << endl;
	// }
	// cout << "---" << endl;

	int ans = 0;
	for (auto x : b) {
		if (x <= a_max) {
			break;
		}
		ans++;
		h -= x;
		if (h <= 0) {
			break;
		}
	}

	if (h > 0) {
		ans += (h + a_max - 1) / a_max;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int N, M;
  while(cin >> N >> M){
    vector<vector<string>> r(N);

    REP(i,M){
      int p; cin >> p;
      string s; cin >> s;
      
      r[p-1].push_back(s);
    }

    int ac = 0;
    int pen = 0;

    REP(i,N){
      if(count(ALL(r[i]), "AC")){
        ++ac;

        REP(j,r[i].size()){
          if(r[i][j] == "AC") break;
          ++pen;
        }
        
      }
    }

    cout << ac << " " << pen << endl;
  }

  return 0;
}


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

int ans;
string a;

int main(void)
{
//   scanf("%03d" ,&a);
   cin >> a;
   if(a[0]=='1')
     ans++;
   if(a[1]=='1')
     ans++;
   if(a[2]=='1')
     ans++;
   cout << ans;
   return 0;
}


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

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
using namespace std;

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

	int N;
	cin >> N;
	int A[N];
	REP(i, N) cin >> A[i];

	REP(i, N) {
		int key = A[i];
		int j = i - 1;
		while(j >= 0 && A[j] > key) {
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = key;

		REP(k, N) {
			cout << A[k];
			if(k != N-1) cout << " ";
			else cout << endl;
		}
	}
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		int s, w;
		cin >> s >> w;
		if(w>=s){
			cout << "unsafe" << endl;
		}
		else{
			cout << "safe" << endl;
		}
		return 0;
	}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll k,n;
	cin>>k>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
	}

	vector<ll> p;
	for(ll i=1;i<n;i++)
	{
		p.push_back(a[i]-k);
	}
	for(ll i=0;i<n;i++)
	{
		p.push_back(a[i]);
	}
	for(ll i=0;i<n;i++)
	{
		p.push_back(a[i]+k);
	}
	
	ll ans = INT_MAX;
	for(ll i=n-1;i<2*n-1;i++)
	{

		//cout<<p[i]<<" "<<p[i-(n-1)]<<" "<<p[i+n-1]<<endl;
		ans=min(ans,p[i]-p[i-(n-1)]);
		ans=min(ans,p[i+n-1]-p[i]);
		//cout<<ans<<"\n";
	}
	cout<<ans;
}

Measured memory_bytes: 12012
/* ファイル名：ITP1_1_C	*/
/* 内容：たて a cm よこ b cm の長方形の面積と周の長さを求める	*/

/* include	*/
#include <stdio.h>

/* 外部変数宣言	*/

/* プロトタイプ宣言	*/

/* 関数名:main	*/
/* 処理内容:たて a cm よこ b cm の長方形の面積と周の長さを求める	*/
int main( void )
{
	/* 内部変数定義*/
	int a;	/* たての長さ		*/
	int b;	/* よこの長さ		*/
	
	int area;	/* 面積			*/
	int lap;	/* 周の長さ		*/
	
	scanf("%d %d",&a,&b);
	
	area = a * b;			/* 面積を求める		*/
	
	lap = ( a + b ) * 2;	/* 周の長さを求める	*/
	
	printf("%d %d\n",area,lap);	/* 出力する	*/
	
	return 0;
}



Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }


int main(int argc, char const *argv[]) {
  int a, b, c;
  cin >> a >> b >> c;
  cout << min(a+b,min(b+c,c+a)) << endl;
  return 0;
}


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

#define ll long long
#define str string
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second

#define vc vector<char>
#define vvc vector<vc>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvvll vector<vvll>
#define vs vector<str>
#define vvs vector<vs>
#define vpii vector<pii>
#define vvpii vector<vpii>
#define vpll vector<pll>
#define vvpll vector<vpll>
#define vb vector<bool>
#define vvb vector<vb>
#define rep(i, a, b) for (int i = (a); i < int(b); i++)
#define repi(i, a, b) for (int i = (a); i <= int(b); i++)


using namespace std;
ll INF = LONG_LONG_MAX;
ll mod = 1000000000 + 7;

template <typename T, typename L>
void read(vector<T> & _data, L & _size, bool _shift) {
    _data.resize(_size + (ll)_shift);
    for (ll i = (ll)_shift; i < _size + (ll)_shift; i++)
        cin >> _data[i];
}

template <typename T, typename L>
void read(vector<vector<T>> & _data, L & _rows, L & _cols, bool _shiftRows, bool _shiftCols) {
    _data.resize(_rows + (ll)_shiftRows);
    for (ll i = 0; i < _rows + (ll)_shiftRows; i++)
        _data[i].resize(_cols + (ll)_shiftCols);
    for (ll i = (ll)_shiftRows; i < _rows + (ll)_shiftRows; i++)
        for (ll j = (ll)_shiftCols; j < _cols + (ll)_shiftCols; j++)
            cin >> _data[i][j];
}

template <typename T>
void write(vector<T> & _data, bool _shift) {
    for (ll i = (ll)_shift; i < _data.size(); i++)
        cout << _data[i] << " ";
    cout << endl;
}


//TODO: SOLUTION

ll dif(str s, str t) {
    ll x = 0;
    rep(i, 0, s.size()) {
        if (s[i] != t[i])
            x++;
    }
    return x;
}

void solve() {
    str s, t;
    cin >> s >> t;
    ll ans = s.size();
    rep(i, 0, s.size() - t.size() + 1) {
        ans = min(ans, dif(s.substr(i, t.size()), t));
    }
    cout << ans << endl;
}


int main() {

    // TODO: Set value of this variable manually
    bool _multipleTestCases = false;

    if (_multipleTestCases) {
        ll t; cin >> t;
        while (t--)
            solve();
    }
    else {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include "iomanip"

using namespace std;

int main() {
    long long a, b, x;
    cin >> a >> b >> x;
    cout << (b / x) - (a / x) + (a % x == 0 ? 1 : 0);
    return 0;
}



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

typedef long long ll;
const int MAX_N = 100000;

int main () {
	int N;
	std::unordered_map<ll, int> cnt;

	std::cin >> N;
	for(int i = 0; i < N; ++i) {
		ll a;
		std::cin >> a;
		++cnt[a];
	}

	int ans = 0;
	for(auto p : cnt) {
		if(p.second < p.first) ans += p.second;
		else ans += p.second - p.first;
	}

	std::cout << ans << std::endl;
}


Measured memory_bytes: 4260
import queue

class VInfo(object):
    def __init__(self,x,y,d,color):
        self.color=color
        self.d=d
        self.x=x
        self.y=y
    def turnColor(self):
        if self.color==".":return "#"
        else:return "."

h,w=map(int,input().split())
a=[[str(i) for i in input()] for j in range(h)]
sx,sy=0,0
gx,gy=w-1,h-1
cw=0
mapA=[]
m=100000000000000
for my in range(h):
    l=[]
    for mx in range(w):
        l.append(m)
    mapA.append(l)

q=queue.Queue()
if a[0][0]==".":q.put(VInfo(0,0,0,"."))
else:q.put(VInfo(0,0,1,"#"))
l=[]
while not q.empty():
    now=q.get()
    if now.x==gx and now.y==gy:
        if now.color=="#":l.append((mapA[gy][gx]+2)//2)
        else:l.append((mapA[gy][gx]+1)//2)

    if now.y+1<h and a[now.y+1][now.x]==now.color and mapA[now.y+1][now.x]>now.d:
            mapA[now.y+1][now.x]=now.d
            q.put(VInfo(now.x,now.y+1,now.d,now.color))
    if now.y+1<h and a[now.y+1][now.x]!=now.color and mapA[now.y+1][now.x]>now.d:
            mapA[now.y+1][now.x]=now.d
            q.put(VInfo(now.x,now.y+1,now.d+1,now.turnColor()))
    if now.x+1<w and a[now.y][now.x+1]==now.color and mapA[now.y][now.x+1]>now.d:
            mapA[now.y][now.x+1]=now.d
            q.put(VInfo(now.x+1,now.y,now.d,now.color))
    if now.x+1<w and a[now.y][now.x+1]!=now.color and mapA[now.y][now.x+1]>now.d:
            mapA[now.y][now.x+1]=now.d
            q.put(VInfo(now.x+1,now.y,now.d+1,now.turnColor()))
print(min(l))

Measured memory_bytes: 102740
#include<bits/stdc++.h>
using namespace std;
const int N=300010,mod=1e9+7;
long long ans=0,a[N];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    //位运算每一位互不影响，同一位可以一起算
    //只有1与0进行异或时才得到1，因此这一位上1的数目乘0的数目就是异或为1的所有可能情况数
    for(int i=0;i<60;i++)
	{
        long long x=0;
        for(int j=0;j<n;j++) if(a[j]>>i&1) x++;	//统计每个数第i位的1
        long long now=x*(n-x)%mod;	//每个数第i位的1的个数乘0的个数
        for(int j=0;j<i;j++)now=now*2%mod;	//把权重移回去
        ans+=now;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560