akhauriyash/Code-Regression huggingface dataset:
//q020.cpp
//Sat Sep 26 10:51:59 2020

#include <bits/stdc++.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	vector<ll> a(n),b(n),c(n);
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> b[i];
	rep(i,n) cin >> c[i];

	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());

	ll ans = 0;
	rep(i,n){
		ll x = b[i];
		ll up = lower_bound(a.begin(),a.end(),x)-a.begin();
		ll down = c.end()-upper_bound(c.begin(),c.end(),x);
		ans += up*down;
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 5644
import math
 
def C(n,r):
    f = math.factorial
    return int(f(n) // f(r) // f(n-r))

N,A,B=map(int,input().split())
v = [int(i) for i in input().split()]

v.sort(reverse=True)

m_ave = sum(v[:A])/A
x,y = v.count(v[A-1]),v[:A].count(v[A-1])

if v[0]==v[A-1] :
    comb = sum([C(x,i) for i in range(A,min(B,x)+1)])
else :
    comb = C (x,y)

print(m_ave)
print(comb)


Measured memory_bytes: 3188
def move(t,x,y)
  sum = x.abs + y.abs
  if sum <= t
    if sum % 2 == t % 2
      return 1
    else
      return 0
    end
  else
    return 0
  end
end

N = gets.to_i
t = [0]; x = [0]; y = [0]
1.upto(N) do |i|
  t[i], x[i], y[i] = gets.split(" ").map(&:to_i)
end
1.upto(t.size-1) do |i|
  if move(t[i]-t[i-1], x[i]-x[i-1], y[i]-y[i-1]) == 0
    puts "No"
    exit
  end
end
puts "Yes"

Measured memory_bytes: 4232
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <utility>
#include <cstdlib>

using namespace std;
typedef pair<int, int> pii;
const int MISSING = 0x7fffffff;

int main(){
	bool first = true;
	while(true){
		int p, s;
		cin >> p;
		if(p == 0){ break; }
		if(!first){ cout << endl; }
		first = false;
		cin >> s;
		vector< vector<int> > table(p + 1, vector<int>(s + 1));
		vector< vector<bool> > missing(p, vector<bool>(s));
		for(int i = 0; i <= p; ++i){
			for(int j = 0; j <= s; ++j){
				string item;
				cin >> item;
				if(item == "?"){
					table[i][j] = MISSING;
					missing[i][j] = true;
				}else{
					table[i][j] = atoi(item.c_str());
				}
			}
		}
		queue<pii> q;
		for(int i = 0; i < p; ++i){
			int count = 0, pos = 0, sum = 0;
			for(int j = 0; j < s; ++j){
				if(table[i][j] == MISSING){
					++count;
					pos = j;
				}else{
					sum += table[i][j];
				}
			}
			if(count == 1){ table[i][pos] = table[i][s] - sum; }
		}
		for(int i = 0; i < s; ++i){
			int count = 0, pos = 0, sum = 0;
			for(int j = 0; j < p; ++j){
				if(table[j][i] == MISSING){
					++count;
					pos = j;
				}else{
					sum += table[j][i];
				}
			}
			if(count == 1){
				table[pos][i] = table[p][i] - sum;
				q.push(pii(0, pos));
			}
		}
		while(!q.empty()){
			pii e = q.front();
			q.pop();
			if(e.first == 0){
				int count = 0, pos = 0, sum = 0;
				for(int i = 0; i < s; ++i){
					if(table[e.second][i] == MISSING){
						++count;
						pos = i;
					}else{
						sum += table[e.second][i];
					}
				}
				if(count == 1){
					table[e.second][pos] = table[e.second][s] - sum;
					q.push(pii(1, pos));
				}
			}else{
				int count = 0, pos = 0, sum = 0;
				for(int i = 0; i < p; ++i){
					if(table[i][e.second] == MISSING){
						++count;
						pos = i;
					}else{
						sum += table[i][e.second];
					}
				}
				if(count == 1){
					table[pos][e.second] = table[p][e.second] - sum;
					q.push(pii(0, pos));
				}
			}
		}
		bool valid = true;
		vector<int> answer;
		for(int i = 0; i < p; ++i){
			for(int j = 0; j < s; ++j){
				if(table[i][j] == MISSING){
					valid = false;
				}else if(missing[i][j]){
					answer.push_back(table[i][j]);
				}
			}
		}
		if(!valid){
			cout << "NO" << endl;
		}else{
			for(int i = 0; i < answer.size(); ++i){
				cout << answer[i] << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

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

    vl ans(n+1);
    exrep(i, 1, n) {
        for(ll z = 1; z*z <= i; z++) {
            for(ll y = 1; y*y + z*z <= i; y++) {
                if(z < y) {
                    continue;
                }
                for(ll x = 1; x*x + y*y + z*z <= i; x++) {
                    if(y < x) {
                        continue;
                    }
                    if(x*x + y*y + z*z + x*y + y*z + z*x == i) {
                        if(x == y && y == z) {
                            ans[i]++;
                        }
                        else if(x != y && y != z && z != x) {
                            ans[i] += 6;
                        }
                        else {
                            ans[i] += 3;
                        }
                    }
                }
            }
        }
    }
    
    exrep(i, 1, n) {
        out(ans[i]);
    }
    
    re0;
}

Measured memory_bytes: 3596
import sys

inp = sys.stdin
counter = {}

for text in inp:
    for a in text:
        a = a.lower()
        counter[a] = counter.get(a,0) + 1

for x in range(26):
    a = chr(ord('a')+x)
    print("{0} : {1}".format(a,counter.get(a,0)),sep='')


Measured memory_bytes: 5568
"""
8 10
0 1
1 2
0 2
0 3
3 2
3 4
3 5
5 6
5 7
6 7
"""
import sys
sys.setrecursionlimit(100000)
V,E = map(int,input().split())
C = [[] for _ in range(V)]
for i in range(E):
    tmp = list(map(int,input().split()))
    C[tmp[0]].append(tmp[1])
    C[tmp[1]].append(tmp[0])

INF = 10000000
visited = [False]*V
visit_cnt = 1
prenum = [0]*V
parent = [-1]*V
lowest = [INF]*V

def DFS(node):
    visited[node] = True
    global visit_cnt
    prenum[node] = visit_cnt
    visit_cnt += 1
    for adj in C[node]:
        if not visited[adj]:
            parent[adj] = node
            DFS(adj)

    node_lowest = prenum[node]
    for adj in C[node]:
        if adj != parent[node] and parent[adj] != node:
            if  prenum[adj] < node_lowest:
                node_lowest = prenum[adj]
        else:
            if parent[adj] == node and lowest[adj] < node_lowest:
                node_lowest = lowest[adj]
    lowest[node] = node_lowest
        
root = 0
DFS(root)
ans = []

root_cnt = 0
for p in parent:
    if p == root:
        root_cnt += 1
if root_cnt > 1:
    ans.append(root)

for node in range(V):
    if parent[node] != root and node != root:
        if prenum[parent[node]] <= lowest[node]:
            ans.append(parent[node])
ans = set(ans)
ans = list(ans)
ans.sort()
for i in ans:
    print(i)


Measured memory_bytes: 19312
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <map>
#include <math.h>
#include <utility>

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<pair<int, int>> job(N); // first:期限 secont:所要時間
    for (int i = 0; i < N; i++){
        int a, b;
        cin >> a >> b;
        job[i] = make_pair(b, a);
    }
    sort(job.begin(), job.end());

    int time = 0;
    for (int i = 0; i < N; i++){
        time += job[i].second;
        if(time > job[i].first){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}

void f(int n,int m){
  int sx,sy;
  int dd=150;

  int d[300][300];
  rep(i,300){
    rep(j,300){
      d[i][j]=INF;
    }
  }

  d[dd][dd]=0;
  vector<P> v;

  while(m--){
    int x,y;
    cin>>x>>y;
    v.PB(P(x,y));
  }
  
  cin>>sx>>sy;

  rep(i,v.size()){
    d[v[i].S+dd-sy][v[i].F+dd-sx]=-INF;
  }
  

  queue<P> q;
  q.push(P(dd,dd));
  int ans=0;
  while(!q.empty()){
    P p=q.front(); q.pop();
    if(d[p.F][p.S]<=n)
      ans++;
    else
      continue;
    //cout<<p.F<<' '<<p.S<<endl;
    if(abs(p.F-dd)>31||abs(p.S-dd)>31) continue;
    FOR(i,-1,2){
      FOR(j,-1,2){
        if(i==0&&j==0||i*j<0) continue;
        int x=p.S+i,y=p.F+j;
        if(d[y][x]>d[p.F][p.S]+1){
          d[y][x]=d[p.F][p.S]+1;
          q.push(P(y,x));
        }
      }
    }
  }

  cout<<ans<<endl;
}




main(){
  int n,m;
  while(true){
    cin>>n>>m;
    if(n==0) break;
    f(n,m);
  }

}



Measured memory_bytes: 3828
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

# define INF 0x3f3f3f3f

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

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

  int N;
  cin >> N;

  ll ct, ca;
  cin >> ct >> ca;

  REP(i, N - 1) {
    ll t, a;
    cin >> t >> a;

    ll n = max((ct + t - 1)/ t, (ca + a - 1) / a);
    ct = n * t;
    ca = n * a;
  }

  cout << ct + ca << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <list>

using namespace std;
typedef long long int ll;
ll MOD = pow(10,9) + 7;

void print(vector<ll>& v)
{
    for (auto i:v)
    {
        cout<<i<<" ";
    }
    cout<<endl;
}

void helper(vector<list<ll>>& adj,vector<bool>& vis,vector<ll>& W,vector<ll>& B,ll node)
{
    //cout<<"BEGIN"<<endl;
    //print(W);
    //print(B);
    vis[node] = true;
    list<ll> ngb = adj[node];

    if (ngb.empty())
    {
        W[node] = 1;
        B[node] = 1;

        /**
        cout<<"UPDATED"<<endl;
        print(W);
        print(B);
        **/

        return;
    }

    W[node] = 1;
    B[node] = 1;

    for (ll n:ngb)
    {
        if (!vis[n])
        {
            helper(adj,vis,W,B,n);
            ll new_B_n = (B[n]*W[node]) % MOD;
            ll new_B_node = (B[node]*W[n]) % MOD;

            ll new_W_n = ((W[n]*B[node])%MOD + (W[n]*W[node])%MOD)%MOD;
            ll new_W_node = ((W[node]*B[n])%MOD + (W[node]*W[n])%MOD)%MOD;

            W[n] = new_W_n;
            W[node] = new_W_node;

            B[n] = new_B_n;
            B[node] = new_B_node;
        }
    }
    /**
    cout<<"UPDATED"<<endl;
    print(W);
    print(B);
    **/

}

ll solve(vector<list<ll>>& adj)
{
    ll n = adj.size();
    vector<bool> visited(n);
    vector<ll> W(n);
    vector<ll> B(n);

    ll root = 0;
    helper(adj,visited,W,B,root);

    ll ans = (W[root] + B[root])%MOD;

    return ans;
}

int main()
{
    ll N;
    cin>>N;
    vector<list<ll>> adj(N);

    for (int i=0;i<N-1;++i)
    {
        ll from;
        ll to;
        cin>>from;
        cin>>to;
        --from;
        --to;
        adj[from].push_back(to);
        adj[to].push_back(from);
    }

    cout<<solve(adj)<<endl;

    return 0;
}


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

int main() {
	string moji;
	int i,acnt,bcnt;
	while(1){
		cin>>moji;
		i=acnt=bcnt=0;
		if(moji[i]=='0') break;
		i++;
		while(moji[i]=='A' || moji[i]=='B'){
			if(moji[i]=='A') acnt++;
			if(moji[i]=='B')bcnt++;
			i++;
		}
		if(acnt>bcnt)acnt++;
		else bcnt++;
		cout<<acnt<<" "<<bcnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 3204
n,m=map(int,input().split())
li=[]
ans=[]
cnt=0
for i in range(m):
    p,y=map(int,input().split())
    li.append([p,y,i])
li=sorted(li,key=lambda x:x[1])
li=sorted(li,key=lambda x:x[0])
pre=li[0][0]
for j in range(m):
    if li[j][0]==pre:
        cnt+=1
        ans.append([str(pre).zfill(6)+str(cnt).zfill(6),li[j][2]])
        
    else:
        pre=li[j][0]
        cnt=1
        ans.append([str(pre).zfill(6)+str(cnt).zfill(6),li[j][2]])

ans=sorted(ans,key=lambda x:x[1])
for k in range(m):
    print(ans[k][0])

Measured memory_bytes: 43476
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	
	public static final double INF = Integer.MAX_VALUE;
	public static void main(String[] args) {
		doIt();
	}
	
	public static void doIt(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String s = sc.nextLine();
			String[] ss = s.split(" ");
			int len = ss.length;
			int box = Integer.parseInt(ss[0]);
			int n = len - 1;
			//System.out.println("n = " + n);
			int[] r = new int[n];
			for(int i = 1; i < len; i++){
				r[i - 1] = Integer.parseInt(ss[i]);
			}
			int max = 1 << n;
			//集合Sが箱に入っていて、nが最後の時の幅の最小値
			double[][] dp = new double[max][n];
			//arg1とarg2を並べた時の幅。2sqrt(a1*a2)
			double[][] width = new double[n][n];
			for(int i = 0; i < n; i++){
				
				for(int j = i + 1; j < n; j++){
					width[i][j] = 2*Math.sqrt(r[i]*r[j]);
					width[j][i] = width[i][j];
				}
			}
			//dp[0][0] = 0;
			//init
			for(double[] a : dp){
				Arrays.fill(a, INF);
			}
			for(int i = 0; i < n; i++){
				dp[1 << i][i] = r[i];
			}
			
			
			for(int i = 1; i < max; i++){
				for(int j = 0; j < n; j++){
					if(dp[i][j] != INF){
						//最小値があれば、新たなケーキを足してみる
						for(int k = 0; k < n; k++){
							//既に使われているか？
							if(((i >> k) & 1) == 0){
								dp[i + (1 << k)][k] = Math.min(dp[i + (1 << k)][k], dp[i][j] + width[j][k]);
							}
						}
					}
				}
			}
			double min = INF;
			//最後に半径を足す
			for(int i = 0; i < n; i++){
				min = Math.min(min, dp[max - 1][i] + r[i]);
			}
			//System.out.println(min);
			System.out.println(min > box? "NA" : "OK");
		}
	}

}

Measured memory_bytes: 14000
#include <bits/stdc++.h>
#include<unordered_map>
#define lli long long int
#define f first
using namespace std;


int main() {

	std::ios::sync_with_stdio(0);
	std::cin.tie(0);

	int n, a[(int)1e5 + 1], c = INT_MIN, counter = 0;
	cin >> n;
	for (int i = 0; i < n; ++i)cin >> a[i]; // 10 4 8 7 3
	for (int i = 1; i < n; ++i) {
		if (a[i - 1] >= a[i])counter++;
		else {
			c = max(c, counter);
			counter = 0;
		}
	}
	cout << max(c, counter) << '\n';
	return 0;
}

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

int main(){
    int N,M; cin >> N >> M;
    vector<vector<int>> s(M);
    for(int i = 0; i < M;i++){
        int k; cin >> k;
        for(int j = 0; j < k; j++){
            int l; cin >> l; l--;
            s[i].push_back(l);
        }
    }
    vector<int> p(M);
    for(int i = 0; i < M; i++)cin >> p[i];
    
    long long res = 0;
    for(int bit = 0; bit < (1<<N); bit++){
        bool ok = true;
        for(int i = 0; i < M; i++){
            int con = 0;
            for(auto v:s[i]){
                if(bit & (1<<v))con++;
            }
            if(con % 2 != p[i])ok = false;
        }
        if(ok)res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 3584
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

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

	int K, X;
	cin >> K >> X;

	for (int i = X - K + 1; i < X + K; i++) {
		cout << i << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	string n; cin >> n;
    reverse(all(n));
    static int dp[1000100][2];
    rep(i, 1000100) {
        dp[i][0] = dp[i][1] = INF;
    }
    dp[0][0] = 0;
    int sz = (int)n.size();
    rep(i, sz) {
        int c = n[i] - '0';
        chmin(dp[i + 1][0], dp[i][0] + c);
        chmin(dp[i + 1][0], dp[i][1] + c + 1);
        chmin(dp[i + 1][1], dp[i][0] + 10 - c);
        chmin(dp[i + 1][1], dp[i][1] + 10 - c - 1);
        //cerr << dp[i + 1][0] << " " << dp[i + 1][1] << endl;
    }
    cout << min(dp[sz][0], dp[sz][1] + 1) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 17052
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n,ans=0;
  cin >> n;
  for(long i=1;i*i<=n-1;i++) {
    if((n-1)%i==0) {
      if(i!=1) ans++;
      if((n-1)/i!=i) ans++;
    }
  }
  for(long i=1;i*i<=n;i++) {
    if(n%i==0) {
      if(i!=1) {
        long a=n;
        while(a%i==0) a/=i;
        if(a%i==1) ans++;
      }
      if(n/i!=i) {
        long a=n;
        while(a%(n/i)==0) a/=(n/i);
        if(a%(n/i)==1) ans++;
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
	static final long MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] line = sc.next().toCharArray();
		long[] dp1 = new long[line.length]; // L = a + b
		long[] dp2 = new long[line.length];	// L > a + b
		dp1[0] = 2;
		dp2[0] = 1;
		for (int i = 1; i < line.length; i++) {
			if (line[i] == '0') {
				dp1[i] = dp1[i - 1];
				dp2[i] = dp2[i - 1] * 3 % MOD;
			} else {
				dp1[i] = dp1[i - 1] * 2 % MOD;
				dp2[i] = (dp1[i - 1] + dp2[i - 1] * 3) % MOD;
			}
		}
		System.out.println((dp1[dp1.length - 1] + dp2[dp2.length - 1]) % MOD);
	}
}


Measured memory_bytes: 26396
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define speedX ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout<< name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_time() cout << "\n\nTime of execution: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define trace(...)
#define end_time()
#endif


#define int long long 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
inline bool equals(ld a, ld b) {return fabs(a - b) < 1e-9;}
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define mod 1000000007


void solve(){
	string s;
	cin>>s;
	for(int i = 0; i<s.length(); i++){
		cout<<"x";
	}
	cout<<"\n";
}
signed main(){
	speedX;
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	end_time();
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
using namespace std;
typedef pair<int,int> _P;
typedef pair<_P,int> P;
int M,N,field[90][90];
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
int dfs(int x,int y) {
	int mx=0;
	for(int i=0;i<4;i++) {
		int nx=x+dx[i],ny=y+dy[i];
		if(0>nx||nx>=M||0>ny||ny>=N) continue;
		if(!field[nx][ny]) continue;
		field[nx][ny]=0;
		mx=max(mx,dfs(nx,ny));
		field[nx][ny]=1;
	}
	return mx+1;
}
int main() {
	while(scanf("%d %d",&M,&N),M|N) {
		for(int y=0;y<N;y++) for(int x=0;x<M;x++)
			scanf("%d",&field[x][y]);
		int ans=0;
		for(int y=0;y<N;y++) for(int x=1;x<M;x++) {
			if(field[x][y]) {field[x][y]=0;ans=max(ans,dfs(x,y));field[x][y]=1;}
		}
		printf("%d\n",ans);
	}
}

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

int main() {
  ll N,M;
  cin>>N>>M;
  ll ans;
  if(N==1&&M==1) ans=1;
  else if(N==1) ans=M-2;
  else if(M==1) ans=N-2;
  else ans = (N-2)*(M-2);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys

N = int(sys.stdin.readline().strip())

data = []
for _ in range(N):
    a, b = map(int, sys.stdin.readline().strip().split())
    data.append((a, b))

ans = 0
adds = 0
for i in range(N):
    a, b = data[N-1-i]
    a += adds
    r = (a - 1) // b
    target = b * (r + 1)
    tmp = target - a
    ans += tmp
    adds += tmp

print(ans)

Measured memory_bytes: 48732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const int Inf = 1e9;
const ll INF= 1e18;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    string S;
    cin >> S;
    string T;
    vector<int> vec;
    int cnt = 0;
    for(int i = 0;i < S.size();i++) {
        if(S.at(i) != 'x') {
            T.push_back(S.at(i));
            vec.push_back(cnt);
            cnt = 0;
        }
        else {
            cnt++;
        }
    }
    vec.push_back(cnt);
    bool ret1 = true;
    for(int i = 0;i < T.size();i++) {
        if(T.at(i) != T.at(T.size() - 1 - i)) {
            ret1 = false;
        }
    }
    if(ret1 == false) {
        cout << -1 << endl;
    }
    else {
        int ret2 = 0;
        for(int i = 0;i < vec.size() / 2;i++) {
            ret2 += max(vec.at(i),vec.at(vec.size() - 1 - i)) - min(vec.at(i),vec.at(vec.size() - 1 - i));
        }
        cout << ret2 << endl;
    }
}

Measured memory_bytes: 1148
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

class Lines {
public:
	vector<int> v;

	bool operator == (const Lines opt) const {
		vector<int> vr;
		vr = v;
		reverse(all(vr));
		for (int i = 1; i < vr.size(); i += 2) {
			vr[i] = -vr[i];
		}

		return (v == opt.v || vr == opt.v);
	}
};

signed main() {
	while (true) {
		int n;
		cin >> n;

		if (n == 0) break;

		vector<Lines> vlines;
		rep(i, n + 1) {
			int m;
			cin >> m;

			Lines lines;

			int ppx, ppy, px, py;
			rep(j, m) {
				int x, y;
				cin >> x >> y;

				if (j > 1) {
					int tmp;
					if (ppx < px) {
						tmp = (py < y ? 1 : -1);
					} else if (ppx > px) {
						tmp = (py < y ? -1 : 1);
					} else if (ppy > py) {
						tmp = (px < x ? 1 : -1);
					} else {
						tmp = (px < x ? -1 : 1);
					}
					lines.v.push_back(tmp);
				}

				if (j > 0) {
					lines.v.push_back(abs(px - x) + abs(py - y));
				}

				if (j > 0) {
					ppx = px;
					ppy = py;
				}
				px = x;
				py = y;
			}

			vlines.push_back(lines);
		}

		for (int i = 1; i <= n; i++) {
			if (vlines[0] == vlines[i]) {
				cout << i << endl;
			}
		}

		cout << "+++++" << endl;
	}

    return 0;
}

Measured memory_bytes: 3112
import sys
H,W,h,w=map(int,input().split())
if W%w==0 and H%h==0:
  print('No')
  sys.exit()
print('Yes')
if W%w!=0:
  m=[]
  a=str(1000*(w-1))
  b=str(-1001)
  for i in range(W):
    if i%w==0:
      m.append(a)
    else:
      m.append(b)
  s=' '.join(m)
  for i in range(H):
    print(s)
else:
  m1=' '.join([str(1000*(h-1))]*W)
  m2=' '.join([str(-1001)]*W)
  for i in range(H):
    if i%h==0:
      print(m1)
    else:
      print(m2)
  
      

Measured memory_bytes: 66500
#include <cstdio>
#include <cmath>

using namespace std;

int main(void){
	int n, i;
	double xa, ya, ra, xb, yb, rb;
	scanf("%d",&n);
	for(i = 0;i < n;i++){
		scanf("%lf%lf%lf%lf%lf%lf",&xa,&ya,&ra,&xb,&yb,&rb);
		if(sqrt(pow(xb - xa,2.0) + pow(yb - ya,2.0)) + rb < ra){
			printf("2\n");
		}else if(sqrt(pow(xb - xa,2.0) + pow(yb - ya,2.0)) + ra < rb){
			printf("-2\n");
		}else if(sqrt(pow(xb - xa,2.0) + pow(yb - ya,2.0)) <= ra + rb){
			printf("1\n");
		}else{
			printf("0\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1048
# 色は10000色、Nは高々100なのでどの色に変えるかは考えなくてよい。

N = int(input())
s_list = list(map(int, input().split()))

# 同じ色で連続している匹数(block_size)のリストを作成する。
s_block_list = []
block_size = 1
for i in range(1, N):
  if s_list[i] == s_list[i-1]:
    block_size += 1
  else:
    s_block_list.append(block_size)
    block_size = 1
s_block_list.append(block_size)
# block_size // 2の総和
print(sum([s // 2 for s in s_block_list]))

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

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	vector<int> L(n);
	for(int i = 0; i < n; ++i) {
		cin >> L[i];
	}
	
	sort(L.begin(), L.end());

	int ans = 0;
	for(int i = 0; i < n; ++i) {
		for(int j = i + 1; j < n; ++j) {
			int c = lower_bound(L.begin(), L.end(), L[i] + L[j]) - L.begin();
			ans += c - (j + 1);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
module Main where

import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    n <- readLn
    rs <- fmap (sortBy (\(_, b1) (_, b2) -> b2 `compare` b1)) $
        replicateM n $ do
        [a, b] <- fmap read . words <$> getLine :: IO [Int]
        return (a, b)
    bs <- fmap (sortBy (\(a1, _) (a2, _) -> a1 `compare` a2)) $
        replicateM n $ do
        [c, d] <- fmap read . words <$> getLine :: IO [Int]
        return (c, d)
    let f (c, d) (a, b) = a < c && b < d
    let rs' = foldl' (\acc b -> deleteBy f b acc) rs bs
    print $ length rs - length rs'

Measured memory_bytes: 1020
#include <iostream>
using namespace std;
typedef long long  ll;

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
int main()
{
	ll N; cin >> N;
	ll a = 2, b = 1, c = 3;
	if (N == 1) {
		cout << 1 << endl;
		return 0;
	}
	if (N == 1) {
		cout << 3 << endl;
		return 0;
	}

	repe(i, 3, N) {
		a = b;
		b = c;
		c = a + b;
	}
	cout << c << endl;

	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<pair<ll,ll> > > vvpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) x.begin() , x.end()
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define left (node << 1)
#define right (node << 1) + 1
#define pii pair<int,int> 
#define mii map<int,int>
#define vi vector<int>
#define umii unordered_map<int,int>
#define mod 998244353
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<": " <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl

#define repo(i,o,e) for(int i = o ; i < e ; i++)
#define rep(n) for(int i = 0 ; i < n ; i++)
const ll sz = 1e5+5;
//C'mon
int arr[sz];
int pre[sz];
void solve(){
	int n , q , l , r;
	cin >> n >> q;
	string s;
	cin >> s;
	for(int i = 0 ; i < n-1 ; ++i){
		if(s[i] == 'A' and s[i+1] == 'C')arr[i+1] = 1;
	}
	pre[0] = arr[0];
	for(int i = 1 ; i < n ; ++i)pre[i] = arr[i] + pre[i-1];
	while(q--){
		cin >> l >> r;
		cout << pre[r-1] - pre[l-1] << endl;
	}
}

int main(){
    FIO;
    int t = 1;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 1872
#include <stdio.h>

#include <string.h>

int main(void){
    int k;
    scanf("%d",&k);

    char s[101];
    scanf("%s",s);
    int i;

    if(strlen(s)>k){
        for(i=0;i<k;i++){
            printf("%c",s[i]);
        }
        printf("...\n");
    }
    else{
        printf("%s\n",s);
    }

    return 0;
}


Measured memory_bytes: 1612
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <numeric>
 
using namespace std;
 
int facctorialMethod(int k);
int hoge(int*, int, int);
 
int main() {
	long long int n, m, c=0, d=0;
	cin >> n;
    int a[n], b[n];
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++) {
      if(i!=n-1)
        c += hoge(a,i,n) * facctorialMethod((n-i)-1);
      else
        c++;
    }
    for(int i=0;i<n;i++) cin >> b[i];
    for(int i=0;i<n;i++) {
        if(i!=n-1)
            d += hoge(b,i,n) * facctorialMethod((n-i)-1);
        else
          d++;
    }

    cout << abs(c-d) << endl;
}
 
int hoge(int *a, int b, int c) {
  int cnt = 0;
  for(int i=b+1;i<c;i++) {
     if(a[i] < a[b]) cnt++;
  }
  return cnt;
}
 
int facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        long[] b = new long[n];
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
        }
        long[] c = new long[n];
        for (int i = 0; i < n; i++) {
            c[i] = sc.nextInt();
        }
        Arrays.sort(a);
        Arrays.sort(b);
        Arrays.sort(c);
        System.out.println(solve3(a, b, c));
    }

    private static long solve3(long[] a, long[] b, long[] c) {
        int n = a.length;
        long[] aa = new long[n];
        for (int i = n - 1, j = n - 1; i >= 0 && j >= 0; ) {
            if (a[i] < b[j]) {
                aa[j] = i + 1;
                j--;
            } else {
                i--;
            }
        }
        long[] cc = new long[n];
        for (int k = 0, j = 0; k < n && j < n; ) {
            if (c[k] > b[j]) {
                cc[j] = n - k;
                j++;
            } else {
                k++;
            }
        }
        long sum = 0;
        for (int i = 0; i < n; i++) {
            sum += aa[i] * cc[i];
        }
        return sum;
    }
}


Measured memory_bytes: 93980
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define MAPFOR(it,m) for( auto it = (m).begin(); it != (m).end() ; ++it )
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

string gen(ll n, string s) {
    if(n==0) return s;
    char c = 'a' + ((n+25)%26);
    if(c=='z') return gen(n/26-1, c+s); 
    return gen(n/26, c+s);
}

int main(void){
    ll n;
    cin >> n;
    cout << gen(n, "") << endl;
    
    return 0;
}

Measured memory_bytes: 3584
import java.util.*;
class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int N = sc.nextInt();
        int[] A = new int[N];
        int largest = 0;
        A[0] = sc.nextInt();
        largest = A[0];
        for (int i = 1; i < A.length; i++) {
            A[i] = sc.nextInt();
        }
        largest = A[0] + K - A[N-1];
        for (int i = 1; i < A.length; i++) {
            largest = Math.max(largest,A[i] - A[i-1]);
        }
        
        System.out.println(K - largest);
        
    }
}

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

int main(){
    int n; cin >> n;
    vector<string> sortlist;
    for(int i = 0; i < n; i++){
        string a; cin >> a;
        sort(a.begin(), a.end());
        sortlist.push_back(a);
    }
    sort(sortlist.begin(), sortlist.end());
    long long int count = 1;
    long long int ans = 0;
    for(int i = 0; i < n-1; i++){
        if(sortlist[i] == sortlist[i+1]){
            count++;
        }else{
            ans += (count*(count-1))/2;
            count = 1;
        }
    }
    ans += (count*(count-1))/2;
    cout << ans << endl;
}  

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

using namespace std;

#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mmp make_pair
#define st first
#define nd second
#define rd third
#define ll long long
#define pii pair <int, int>
#define tri pair <pii, int>
#define itr pair <int, pii>
#define PQ priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define Rep(i, n) for (int (i) = 0; (i) <= (int)(n); i++)
#define For(i, a, n) for (int (i) = (a); (i) <= (int)(n); i++)
#define Forn(i, a, n) for (int (i) = (a); (i) >= (int)(n); i--)
#define FORD(i, n) for (int (i) = (int)(n) - 1; i>= 0; i--)
#define rep(i, n) for (int (i) = 1; (i) <= (int)(n); i++)
#define EACH(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define DEBUG(x) cout << #x << " = " << (x) << endl;
#define PR(a, n) {cout << #a << " = "; FOR(_, 1, n) cout << a[_] << ' '; puts(""); }
#define PRO(a, n) { cout << #a << " = "; REP(_, n) cout << a[_] << ' '; puts(""); }
#define pi 3.1415926535897932384626433832795028841971
//#define LOCAL

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

inline ll read()
{
	ll x = 0; int f = 1, c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
	return x * f;
}

int n, k; 
vector <int> h; 
ll ans; 

int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	
	n = read(), k = n - read(); 
	REP(i, n) h.pb(read()); 
	sort(all(h)); 
	REP(i, k) ans += h[i]; 
	printf("%lld\n", ans); 
	
	return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <complex>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define sz size()
#define endl "\n"
#define print(X) cout << (X) << "\n"
// #define input(X) getline(cin,X)
static const int INF = 1e+9+7;
static const ll INFL = 1e+18+7;
ll n,m,l;
string s,t;
ll d[200010],dp[300][300];
char field[200][200];

int main(){
  cin >> n >> m;
  if(n <= 8 && m <= 8)puts("Yay!");
  else puts(":(");
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) = println(run {
    val (n,m,c) = readLine()!!.split(" ").map { it.toInt() }
    val b = readLine()!!.split(" ").map { it.toInt() }
    val a = (1..n).map { readLine()!!.split(" ").map { it.toInt() } }

    a.count {
        it.mapIndexed {i, v -> v*b[i] }.sum() + c > 0
    }
})


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

const int N = 1e2 + 5;

bool flag = true;
vector<int> ans;
int n;
int a[N];

int main() {
    ios::sync_with_stdio(false);
    set<pair<int, int>> s;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        s.insert(make_pair(i, a[i]));
    }
    for (int i = n; i >= 1; i--) {
        pair<int, int> pick = make_pair(-1, -1);
        for (auto x: s) {
            if (x.first == x.second) {
                pick = x;
            }
        }
        if (pick == make_pair(-1, -1)) {
            flag = false;
            break;
        } else {
            ans.push_back(pick.first);
            s.erase(s.find(pick));
            int cnt = 1;
            for (auto x: s) {
                pair<int, int> tmp = *s.find(x);
                s.erase(s.find(x));
                tmp.first = cnt;
                cnt++;
                s.insert(tmp);
            }
        }
    }
    if (flag == false) {
        cout << -1 << endl;
        return 0;
    }
    reverse(ans.begin(), ans.end());
    for (int x: ans) {
        cout << x << endl;
    }
    cout << endl;
    return 0;
}

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define fre freopen("C:\\in.txt", "r", stdin)
#define _for(i,a,b) for(int i=a; i< b; i++)
#define _rep(i,a,b) for(int i=a; i<=b; i++)
#define lowbit(a) ((a)&-(a))
#define inf 0x3f3f3f3f
#define endl "\n"
using namespace std;
typedef long long ll;
template <class T>
void read(T &x)
{
    char c; bool op=0;
    while(c=getchar(), c<'0'||c>'9') if(c=='-') op=1;
    x=c-'0';
    while(c=getchar(), c>='0'&&c<='9') x=x*10+c-'0';
    if(op) x=-x;
}

const int maxn=5e5+5;
int T, n, m, a[maxn];
int res, num[1000005], ans[maxn];
struct Node{
    int l, r, idx;
}q[maxn];
int block;

bool cmp(Node x, Node y){
    return x.l/block^y.l/block? x.l<y.l : (((x.l/block)&1)? x.r<y.r : x.r>y.r);
}

void add(int x){
    if(!num[a[x]]) res++;
    num[a[x]]++;
}

void del(int x){
    num[a[x]]--;
    if(!num[a[x]]) res--;
}

int main()
{
    //read(T);
    T=1;
    while(T--)
    {
        read(n); read(m);
        memset(num, 0, sizeof(num));
        res=0;
        _rep(i, 1, n) read(a[i]);

        _rep(i, 1, m) read(q[i].l), read(q[i].r), q[i].idx=i;
        block=n/sqrt(m*2/3);
        sort(q+1, q+1+m, cmp);
        int l=0, r=0;
        _rep(i, 1, m){
            int ql=q[i].l, qr=q[i].r;
            while(l<ql) del(l++);
            while(l>ql) add(--l);
            while(r<qr) add(++r);
            while(r>qr) del(r--);
            ans[q[i].idx]=res;
        }
        _rep(i, 1, m) printf("%d\n", ans[i]);
    }
    return 0;
}


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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

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

const lli MOD = 1000000007LL;

lli modpow(lli a, lli n){
    lli res = 1;

    for(lli ai = a; n; n>>=1){
        if(1&n) res = (res*ai)%MOD;
        ai=(ai*ai)%MOD;
    }
    return res;
}

lli inv(lli n){
    return modpow(n, MOD-2);
}

lli modperm(lli n, lli k){
    lli res = 1;
    rep(i, k){
        res = (res*(n-i))%MOD;
    }
    return res;
}

lli modcomb(lli n, lli k){
    return (modperm(n, k)*inv(modperm(k, k)))%MOD;
}

lli posmod(lli n){
    lli res = n;
    res %= MOD;
    if(res < 0) res += MOD;
    return res;
}
lli a, b, n;
lli x;
lli res;

int main(void){
    cin >> a >> b >> n;
    x = min(b-1, n);
    res = (a*x/b)-(a*(x/b));
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

int main() {
    int R; cin >> R;
    if (R < 1200) cout << "ABC" << '\n';
    else if (R < 2800) cout << "ARC" << '\n';
    else cout << "AGC" << '\n';
    return 0;
}

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

int n;

int main() {
  cin >> n;
  string s;
  int ac = 0;
  int wa = 0;
  int tle = 0;
  int re = 0;
  rep (i, n) {
    cin >> s;
    if (s == "AC") ac++;
    if (s == "WA") wa++;
    if (s == "TLE") tle++;
    if (s == "RE") re++;
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
  return 0;
}


Measured memory_bytes: 3632
import itertools
n=int(input())
s=dict()
for i in ["M","A","R","C","H"]:
    s[i]=0
for i in range(n):
    _s=input()
    if _s[0] in ["M","A","R","C","H"]:
        s[_s[0]]+=1
s=list(s.items())
ans=0
for i in range(5):
    for j in range(i+1,5):
        for k in range(j+1,5):
            ans+=(s[i][1]*s[j][1]*s[k][1])
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

class UnionFindTree {
public:
	int treeCnt; //ツリーの数
	vi rank, p; //rank => 根の高さ, p => 親
	vi num; //木の要素数
	vi diff_weight;
	UnionFindTree() {}
	UnionFindTree(int size) {
		rank.resize(size, 0);
		p.resize(size, 0);
		num.assign(size, 1);
		diff_weight.assign(size, 0);
		treeCnt = 0;
		REP(i, size) {
			makeset(i);
		}
	}

	void makeset(int x) {
		p[x] = x;
		rank[x] = 0;
		treeCnt++;
	}

	//同じ木に属しているか判定
	bool isSame(int x, int y) {
		return root(x) == root(y);
	}

	//木と木を繋ぐ処理をする。
	// weight(y) - weight(x) = w となるように link する
	void link(int x, int y, int w) {
		w += weight(x); w -= weight(y);
		x = root(x);
		y = root(y);
		if (x == y) {
			return;
		}
		if (rank[x] < rank[y]) {
			swap(x, y); w = -w;
		}

		//yのrootをxのrootの下にくっつける
		if (rank[x] == rank[y]) ++rank[x];
		p[y] = x;
		diff_weight[y] = w;
		treeCnt--;
	}


	//xが属している木の根を探る
	int root(int x) {
		if (p[x] == x) return x;
		int r = root(p[x]);
		diff_weight[x] += diff_weight[p[x]];
		return p[x] = root(p[x]);
	}

	int weight(int x) {
		root(x);//あらかじめ経路圧縮しておく
		return diff_weight[x];
	}

	int diff(int x, int y) {
		return weight(y) - weight(x);
	}

	int countTree() {
		return treeCnt;
	}

	int getNum(int a) {
		return num[root(a)];
	}
};


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	UnionFindTree uft(N);
	REP(i, M) {
		int l, r, d;
		cin >> l >> r >> d;
		l--; r--;
		if (uft.isSame(l, r)) {
			if (uft.diff(l, r) != d) {
				cout << "No" << endl;
				PAU;
				return 0;
			}
			else continue;
		}
		uft.link(l, r, d);
	}
	cout << "Yes" << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 2040