akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define vi vector<int>
#define pii pair<int,int>
#define vpi vector<pair<int,int>>
#define pb push_back
#define F first
#define S second
#define REP(i,a,b) for(ll i = a; i < b; i++)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define bins(v, x) binary_search(v.begin(), v.end(), x)
#define pi 2*acos(0.0)
#define INF 1e6 + 5
const int mod = 1e9 + 7;

ll modExp(ll base, ll exp, ll mod) {
   ll res = 1;
   while (exp > 0) {
    	if (exp % 2 == 1) {
        	res= (res * base) % mod;
		}
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}

ll nCr(ll n,ll k){ 
   ll C[n + 1][k + 1]; 
   
   REP(i,0,n+1){ 
      REP(j,0,min(i,k)+1) {
         if(j==0 || j==i) {
            C[i][j] = 1;  
         } else {
            C[i][j] = C[i-1][j-1] + C[i-1][j]; 
         }
      } 
   }
   return C[n][k]; 
}

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

    long double ans = 100;
    int cnt = 0;
    while(ans < x) {
        ans = floor(ans * (1.01));
        cnt++;
    }

    p1(cnt);

}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

typedef long long int int64;

int main(int argc, char **argv)
{
    int N, K;
    cin >> N >> K;
    int p[N];
    for (int i = 0; i < N; ++i) cin >> p[i];

    // E = (1 + p_i) / 2
    int64 maxExpval = 0;
    for (int i = 0; i < K; ++i) {
        maxExpval += p[i] + 1;
    }
    int64 tmpExpval = maxExpval;
    for (int i = K; i < N; ++i) {
        tmpExpval = tmpExpval - (p[i - K] + 1) + (p[i] + 1);
        if (tmpExpval > maxExpval) maxExpval = tmpExpval;
    }
    if (maxExpval % 2 == 0) cout << maxExpval / 2;
    else cout << maxExpval / 2 << ".5";

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;

int solve(int n){
    int i=0;
    while(true){
        if(n<=10*i) return 10*i;
        i++;
    }
}

int main(){
    vector<int> vec(5);
    int sum = 0;
    int min = 10;
    for(int j=0;j<5;j++){
        int i; cin >> i;
        sum += solve(i);
        if(i%10 != 0 && i%10 < min) min = i%10;
    }

    cout << sum-10+min << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define quick                    \
    ios::sync_with_stdio(false); \
    cin.tie(0);
#define time cerr << (0.1 * clock()) / CLOCKS_PER_SEC << endl;
#define mod 1000000007
typedef long long ll;
typedef pair<ll, ll> pl;
#define forn(n) for (ll i = 0; i < ll(n); i++)

void solve() {
    ll a, b;
    cin >> a >> b;
    cout << (a*b) << '\n';
}

int main() {
    quick;
    solve();
    // ll t;
    // cin >> t;
    // while (t--) {
    //     solve();
    // }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);std::cout<<std::fixed<<std::setprecision(10);
    int N;
    cin >> N;
    cout <<N*N*N<< "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;
static const int MAX_N = 100000;

int N;
int A[305][305];
vector<P2> G;
vector<P1> E[305];
int ans;
int dist[305];
int used[305][305]={false};

int dijkstra(int s,int e){
    for(int i=0;i<305;++i)dist[i] = INF;
    priority_queue< P1, vector<P1>, greater<P1> > pq;
    dist[s] = 0;
    pq.push(P1(0,s));
    while(!pq.empty()){
        P1 p = pq.top();
        pq.pop();
        int v = p.second;
        if(dist[v]<p.first)continue;
        for(auto e : E[v]){
            if(dist[e.first]>dist[v]+e.second){
                dist[e.first] = dist[v]+e.second;
                pq.push(P1(dist[e.first],e.first));
            }
        }
    }
    return dist[e];
}

signed main(){
    cin>>N;
    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            int a;
            int u = min(i,j);
            int v = max(i,j);
            cin>>a;
            A[u][v] = a;
            G.PB(P2(a,P1(u,v)));
        }
    }

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

    for(auto u : G){
        int from = u.second.first, to = u.second.second;
        if(used[from][to])continue;
        used[from][to] = true;
        int cost = dijkstra(from,to);
        if(cost==INF||cost>u.first){
            E[from].PB(P1(to,u.first));
            E[to].PB(P1(from,u.first));
            ans+=u.first;
        }
        else {
            if(cost!=u.first){
                cout<<-1<<endl;
                return 0;
            }
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 5236
#include <iostream>
#include <algorithm>
#include<vector>
#include <queue>
#include<string>
using namespace std;
const int INF = 1000000000;

int main()
{

	int a, b;
	cin >> a >> b;
	int ans =0 ;
	int k = 1;
	while (k < b) {
		k--;
		ans++;
		k += a;
	
	}
	cout << ans<< endl;

}

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

signed main()
{
  int k, n;
  int table[55] = {0};
  int kanade = 0;

  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> table[i];
  }

  sort(table, table + n, greater<int>() );
  
  for (int i = 0; i < k; i++) {
    kanade += table[i];
  }

  cout << kanade << endl;

  return (0);
}


Measured memory_bytes: 256
# input
N = int(input())
A = list(map(int, input().split()))

# 参考：https://qiita.com/HUVEC/items/97739696ab51cacd10f2
# エラトステネスの篩の原理を基に求める

A.sort()
Amax = max(A)

dp = [1] * (Amax + 1)
ans = 0

for i in range(len(A) - 1):
    p = A[i]

    if dp[p] == 1:
        for q in range(Amax // p + 1):
            dp[p * q] = 0

        if A[i] != A[i + 1]:
            ans += 1

if dp[Amax] == 1:
    ans += 1

print(ans)

Measured memory_bytes: 32056
#include<cstdio>
#include<cstring>
using namespace std;

int main()
{
    char a[15];
    int x,y,i,p;
    scanf("%s",a);
    if(a[0] == 'A' && a[1] >= 'a' && a[1] <= 'z' && a[strlen(a)-1] >= 'a' && a[strlen(a)-1] <='z')
        x = 0;
    else
        x = 1;
    y = 0;
    p = 0;
    for(i = 2; i < strlen(a); i++)
    {
        if(a[i] == 'C' && i != strlen(a)-1)
            y++;
        if(a[i] >= 'a' && a[i] <= 'z')
            p++;
    }
    if(x == 0 && y == 1 && p == strlen(a)-3)
        printf("AC");
    else
        printf("WA");
    return 0;
}


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

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    vector<int> s(13);
    vector<int> h(13);
    vector<int> c(13);
    vector<int> d(13);

    rep(i, n){
        char ch;
        int num;
        cin >> ch >> num;

        if(ch == 'S'){
            s[num-1] = 1;
        }else if(ch == 'H'){
            h[num-1] = 1;
        }else if(ch == 'C'){
            c[num-1] = 1;
        }else if(ch == 'D'){
            d[num-1] = 1;
        }
    }

    rep(i, s.size()){
        if(s[i] == 0){
            cout << "S " << i + 1 << endl;
        }
    }
    rep(i, h.size()){
        if(h[i] == 0){
            cout << "H " << i + 1 << endl;
        }
    }
    rep(i, c.size()){
        if(c[i] == 0){
            cout << "C " << i + 1 << endl;
        }
    }
    rep(i, d.size()){
        if(d[i] == 0){
            cout << "D " << i + 1 << endl;
        }
    }
}



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

int n, m;

int main() {
    cin>>n>>m;
    
    if(n==1){
    	n+=13;
	}
	if(m==1){
		m+=13;
	}
	
	if(n>m){
		cout<<"Alice\n";
	}
	else if(m>n){
		cout<<"Bob\n";
	}
	else{
		cout<<"Draw\n";
	}
} 

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
int n,w;
int v[101];
int cnt[101];

int main(void){
	while(1){
		scanf("%d %d",&n,&w);
		if(n+w==0)break;
		memset(cnt,0,sizeof(cnt));
		int wid=1,high=0;
		for(int i=0;i<n;i++){
			scanf("%d",&v[i]);
			while(v[i]>=wid*w)wid++;
			cnt[v[i]/w]++;
			high=std::max(high,cnt[v[i]/w]);
		}
		double res=0.0;
		for(int i=0;i<wid;i++){
			if(wid>1)res+=(double)cnt[i]*(wid-i-1)/(high*(wid-1));
			else res+=(double)cnt[i]/high;
		}
		res+=0.01;
		printf("%.10f\n",res);
	}
	return 0;
}

Measured memory_bytes: 1068
// A.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	string s[3];
	cin >> s[0] >> s[1] >> s[2];
	cout << s[0][0] << s[1][1] << s[2][2] << endl;
	return 0;
}


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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

#define int ll

main()
{
  while(1){
    int m,nmin,nmax; cin >> m >> nmin >> nmax; nmin--; nmax--;
    if(m == 0) break;
    vi p(m); rep(i,m) cin >> p[i];
    int maxv = 0, pos;
    FOR(i,nmin,nmax+1){
      if(p[i] - p[i+1] >= maxv){
	maxv = p[i] - p[i+1];
	pos = i;
      }
    }
    cout << pos + 1 << endl;
  }
}


Measured memory_bytes: 3000
s = list(input())
t = list(input())

answer = []
for i in range(len(s)-len(t)+1):
    a = 0
    for j in range(len(t)):
        if s[i+j]=='?' or s[i+j]==t[j]:
            a += 1
    if a == len(t):
        ans = []
        for k in range(len(s)):
            if i <= k < i + len(t):
                ans.append(t[k-i])
            elif s[k]=='?':
                ans.append('a')
            else:
                ans.append(s[k])
        ans = ''.join(ans)
        answer.append(ans)
if len(answer)==0:
    print('UNRESTORABLE')
else:
    print(sorted(answer)[0])

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int A, B;
  cin >> A >> B;
  int res = (A + B) % 24;
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 256
while true
    n, m = gets.chomp.split.map(&:to_i)
    break if [n, m] == [0, 0]
    arr = gets.chomp.split.map(&:to_i).sort
    c, amt = 0, 0
    until arr.empty?
        price = arr.pop
        amt += price if c % m != m - 1
        c += 1
    end
    puts amt
end


Measured memory_bytes: 7308
from heapq import heappush, heappop, heapify
X,Y,A,B,C = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)
P,Q = p[:X],q[:Y]

heapify(P)
heapify(Q)

for i in range(C):
  if min(P[0],Q[0]) > r[i]:
    break
  if P[0] < Q[0]:
    heappop(P)
    heappush(P,r[i])

  else:
    heappop(Q)
    heappush(Q,r[i])
print(sum(P)+sum(Q))


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

int main() {
	int a, b, x;
	cin >> a >> b;
  if((a+b)%2==0)
 	x = (a + b)/2;
  else
    x = 1 + (a + b)/2;
  	cout << x << endl;
}

Measured memory_bytes: 256
// Author : Hardik Upadhyay
// college: SVNIT 
// slogan : Ab to phod dunga
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i = a ; i >= b; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
const int MAXN = 100005;
ll mod=1000000007;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int x;
	cin>>x;
	if(360%x == 0){
		cout<<360/x<<nl;
	}
	else{
		for(int i = 1; i <= 180; i++){
			if((360*i)%x==0){
				cout<<(360*i)/x<<nl;
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;cin>>a>>b>>c;
  multiset<int> m; m.insert({a,b,c});
  for(auto x: m){
  	if(m.count(x)==1){
    	cout<<x; return 0;
    }
  }
}

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

int main(){
	int n, k, g, mx = 0;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n){
		cin >> a.at(i);
		if(i == 0){
			g = __gcd(a.at(0), a.at(0));
		}else{
			g = __gcd(g, a.at(i));
		}
		mx = max(mx, a.at(i));
	}
	
	if(mx >= k && k % g == 0){
		cout << "POSSIBLE" << endl;
	}else{
		cout << "IMPOSSIBLE" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
int l,m;
scanf("%d %d",&m,&l);
int a[m];
int n,B=0;
int A=0,x;
for(n=0;n<m;n++){
 scanf("%d",&a[n]);
 B+=a[n];
  if(n>0){
   for(A=n;A>0;A--)
     if(a[A-1]<a[A]){
     x=a[A];a[A]=a[A-1];a[A-1]=x;}
   }}
if(a[l-1]*4*l<B)printf("No\n");
else printf("Yes\n");  
  return 0;}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>

int main(){
	int n;
	cin>>n;
	vector<int> G[n+1];
	
	for(int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	
	queue<int> qs;
	queue<int> qe;
	qs.push(1);
	qe.push(n);
	
	vector<int> used(n+1,0);
	used[n]=1;
	
	int ssco=0;
	int esco=0;
	
	int bfsp=1;
	int tmp=0;
	int bfsp2=1;
	while(!qs.empty()||!qe.empty()){
		for(int j=0;j<bfsp;j++){
			if(!qs.empty()){
				int a=qs.front();
				qs.pop();
				used[a]=1;
				ssco++;
				for(int i=0;i<G[a].size();i++){
					if(used[G[a][i]]==0){
						qs.push(G[a][i]);
						used[G[a][i]]=1;
						tmp++;
					}
				}
			}
		}
		bfsp=tmp;
		tmp=0;
		
		
		for(int j=0;j<bfsp2;j++){
			if(!qe.empty()){
				int a=qe.front();
				qe.pop();
				used[a]=1;
				esco++;
				for(int i=0;i<G[a].size();i++){
					if(used[G[a][i]]==0){
						qe.push(G[a][i]);
						used[G[a][i]]=1;
						tmp++;
					}
				}
			}
		}
		bfsp2=tmp;
		tmp=0;
	}
	
	//cout<<ssco<<" "<<esco<<endl;
	
	if(ssco>esco){
		cout<<"Fennec"<<endl;
	}else{
		cout<<"Snuke"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 6144
def d(n)
  if n < 0
    return -1 * n
  else
    return n
  end
end

inp = gets.split(" ")  
a = inp[0].to_i
b = inp[1].to_i
c = inp[2].to_i
d = inp[3].to_i

if d(c-a) <= d
  print("Yes")
  print("\n")
elsif d(b-a) <= d && d(c-b) <= d
  print("Yes")
  print("\n")
else
  print("No")
  print("\n")
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	string n; cin >> n;
	n[3]='8';
	cout << n << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n;
  int x=0,y=0,t=0,tk;
  int k;

  scanf("%d",&n);
  for(int i=0;i<n;++i){
    tk = -t;
    k = x+y;
    scanf("%d%d%d",&t,&x,&y);
    tk += t;
    k += tk - x - y;
    if(k < 0 || k%2 != 0){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}


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

using ll = long long;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	vector <int> g[n+1];
	for (int i=1; i<=n; i++) {
		for (int j=1; j<=n; j++) {
			char x;
			cin >> x;
			if (x == '1') {
				g[i].push_back(j);
			}
		}
	}
	int ans = -1;
	for (int i=1; i<=n; i++) {
		queue <int> bfs;
		vector <int> d(n+1);
		d[i] = 1;
		bfs.push(i);
		bool can = 1;
		while (!bfs.empty()) {
			int v = bfs.front();
			bfs.pop();
			for (auto j:g[v]) {
				if (!d[j]) {
					d[j] = d[v]+1;
					bfs.push(j);
				}
				if (d[j] == d[v]) {
					can = 0;
				}
			}
			if (bfs.empty() && can) {
				ans = max(ans, d[v]);
			}
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int w;cin>>w;
  int a[w];
  for(int i=0;i<w;i++) cin>>a[i];
  int c[2][w],d[2][w];
  for(int i=0,t=-1,m=-1;i<w;i++){
    if(a[i]<0&&(m<0||-a[m]+m>-a[i]+i)) m=i;
    if(!a[i]) t=i,m=-1;
    c[0][i]=m;
    d[0][i]=t;
  }
  for(int i=w-1,t=-1,m=-1;i>=0;i--){
    if(a[i]<0&&(m<0||-a[m]-m>-a[i]-i)) m=i;
    if(!a[i]) t=i,m=-1;
    c[1][i]=m;
    d[1][i]=t;
  }
  int ans=0;
  for(int i=0;i<w;i++){
    int t1=0,t2=0;
    if(d[0][i]>=0) t1=min(a[i],c[0][i]<0?a[i]:-a[c[0][i]]-i+c[0][i]);
    if(d[1][i]>=0) t2=min(a[i],c[1][i]<0?a[i]:-a[c[1][i]]-c[1][i]+i);
      ans+=max(0,max(t1,t2));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 5060
s = input()
k = int(input())
a = ord("a") + 26
mod = 26
ans = ""
for i in s[:-1]:
  tmp = (a - ord(i)) % mod
  if tmp <= k:
    k -= tmp
    ans += "a"
  else:
    ans += i
ans += chr(ord("a") + (ord(s[-1]) - a + k) % mod)
print(ans)

Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    ll N;
    cin >> N;
    cout << N * (N - 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#!python3.4.3
import math

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)
  
N, M = map(int, input().split(' '))

result = 0

if N > 1:
  result += permutations_count(N, 2)

if M > 1:
  result += permutations_count(M, 2)

print(result // 2)

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

using namespace std;

int main()
{
	int A, B, C, K;

	cin >> A >> B >> C >> K;

	if(A > K){
		cout << K << endl;
	}
	else{
		if(K < A+B){
			cout << A << endl;
		}
		else{
			cout << A-(K-(A+B)) << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3616
package main

import "fmt"

func main() {
	var a, b, k int
	fmt.Scanln(&a, &b, &k)

	big := 0
	small := 0
	if a > b {
		big = a
		small = b
	} else {
		big = b
		small = a
	}

	d := 1
	n := 0
	for {
		if big%d != 0 {
			d++
			continue
		}
		m := big / d
		if small%m == 0 {
			n++
			//fmt.Println(i, n)
			if n == k {
				fmt.Println(m)
				return
			}
		}
		d++
	}
}


Measured memory_bytes: 512
#include <stdio.h>
int main()
{
  int K,A,B,MOD=0;
  scanf("%d %d %d",&K,&A,&B);
  while(A<=B)
  {
   if(A%K==0)
   {
    MOD=1; 
   }
    A++;
  }
 if(MOD==1)
 {
   printf("OK");
 }
  else
  {
   printf("NG"); 
  }
  return 0;
}

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

using namespace std;
#define ll long long
int main() {
    ll n,m;
    cin>>n>>m;
    unordered_map<ll,ll> map;
    for(int i=1;i<=n;i++)
    {
        ll x;
        cin>>x;
        map[i]=x;
    }
    vector<vector<ll>> graph(n+1);
    for(ll i=0;i<m;i++)
    {
        ll a,b;
        cin>>a>>b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    int ans=0;
    for(ll i=1;i<=n;i++)
    {
        bool check=true;
        for(auto &x:graph[i])
        {
            if(map[x]>=map[i])check=false;
        }
        if(check)
        {
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 13200
import Math._
object Main extends App {
  val n = readLine().toInt

  for (i <- 0 until n) {
    val Seq(x1, y1, x2, y2, x3, y3) = readLine().split(' ').map(_.toDouble).toList
    val l1 = pow(x2 - x3, 2) + pow(y2 - y3, 2)
    val l2 = pow(x3 - x1, 2) + pow(y3 - y1, 2)
    val l3 = pow(x1 - x2, 2) + pow(y1 - y2, 2)

    val G1 = l1*(l2 + l3 - l1)
    val G2 = l2*(l3 + l1 - l2)
    val G3 = l3*(l1 + l2 - l3)

    val px = (G1 * x1 + G2 * x2 + G3 * x3) / (G1 + G2 + G3)
    val py = (G1 * y1 + G2 * y2 + G3 * y3) / (G1 + G2 + G3)

    val u1 = sqrt(l1)
    val u2 = sqrt(l2)
    val u3 = sqrt(l3)

    val r = (u1 * u2 * u3) / sqrt((u1 + u2 + u3) * (-u1 + u2 + u3) * (u1 - u2 + u3) * (u1 + u2 - u3))

    println("%.3f %.3f %.3f".format(px, py, r))
  }
}


Measured memory_bytes: 44396
import java.util.*;
import java.io.*;
public class Main {
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                PrintWriter ou = new PrintWriter(System.out);
                int n = Integer.parseInt(sc.next());
                long[] a = new long[n];
                for(int i = 0 ; i < n ; i++){
                        a[i] = Long.parseLong(sc.next());
                }
                sc.close();
                Arrays.sort(a);
                int lef = 0;
                int rig = n;
                while(rig - lef > 1){
                        int che = (lef + rig) / 2;
                        boolean nowh = true;
                        long hp = 0;
                        for(int i = 0 ; i <= che ; i++){
                                hp += a[i];
                        }
                        for(int i = che + 1 ; i < n && nowh ; i++){
                                if(hp * 2 < a[i]) nowh = false;
                                else hp += a[i];
                        }
                        if(nowh) rig = che;
                        else lef = che;
                }
                int yono = n - rig - 1;
                for(int che = rig ; che >= rig - 1 ; che--){
                        boolean nowh = true;
                        long hp = 0;
                        for(int i = 0 ; i <= che ; i++){
                                hp += a[i];
                        }
                        for(int i = che + 1 ; i < n && nowh ; i++){
                                if(hp * 2 < a[i]) nowh = false;
                                else hp += a[i];
                        }
                        if(nowh) yono++;
                }
                ou.print(yono + "\n");
                ou.flush();
        }
}

Measured memory_bytes: 61776
#include <stdio.h>
#define ll long long
#define MAX(a,b) ((a)>(b)?(a):(b))
int main(void){
    int n;
    ll a=1,b=1;
    ll c,d;
    scanf("%d",&n);
    while(n-->0){
        scanf("%lld %lld",&c,&d);
        ll k=MAX((a+c-1)/c,(b+d-1)/d);
        a = c*k, b = d*k;
    }
    printf("%lld\n",a+b);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int L, R, d;
	cin >> L >> R >> d;

	int ans = 0;
	for( int x = L; x <= R; x++ ) {
		if( x % d == 0 ) ans++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3672
H,W,K=map(int,input().split(' '))
S=[input() for i in range(H)]
ans = [[0]*W for i in range(H)]
cnt = 1
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            ans[i][j] = cnt
            cnt += 1
def group(h,w,k):
    ans[h][w] = k
    if 0<=w+1<W and ans[h][w+1] == 0:
            group(h,w+1,k)
    if 0<=w-1<W and ans[h][w-1] == 0:
            group(h,w-1,k)
def group_h(h,w,k):
    ans[h][w] = k
    if 0<=h+1<H and ans[h+1][w] ==0:
        group_h(h+1,w,k)
    if 0<=h-1<H and ans[h-1][w] == 0:
        group_h(h-1,w,k)

for h,i in enumerate(ans):
    for w,j in enumerate(i):
        if j != 0:
            group(h,w,j)
for h,i in enumerate(ans):
    for w,j in enumerate(i):
        if j != 0:
            group_h(h,w,j)
for i in ans:
    for j in i:
        print(j,"",end="")
    print("")

Measured memory_bytes: 99036
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,t,c; cin>>x; t=x; c=0;
    c=500; 
    for(int i=c;i>=-c;i--){
        for(int j=c;j>=-c;j--){
            int u=pow(i,5)-pow(j,5); 
            if(u==x) {cout<<i<<" "<<j; return 0;}
        }
    }
    return 0;
}

Measured memory_bytes: 4092
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String ans = "No";
		int jdg = n%28;
		if(jdg == 0) {
			ans = "Yes";
		}else {
			while(jdg >= 3) {
				if(jdg%4 == 0 || jdg%7 == 0) {
					ans = "Yes";
					break;
				}else {
					jdg -= 7;
				}
			}
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
#define GEts(s) getline(cin,s);
using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
static const double pi = 3.141592653589793;
lint modpow(lint a,lint n,lint p){if(n==1)return a%p;if(n%2==1)return (a*modpow(a,n-1,p))%p;lint t=modpow(a,n/2,p);return (t*t)%p;}//a^n%p
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位

class unionfind{
public:
	vector<int> table;
	vector<int> wod;
	void init(int size){
		table.resize(size);
		wod.resize(size);
		rep(i,size)table[i]=i,wod[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
};

vector<int> fu(lint n){
	vector<int> ret;
	arep(i,2,1000000){
		while(n%i==0){
			ret.pb(i);
			n/=i;
		}
	}
	if(n!=1)ret.pb(n);
	sort(ret);
	return ret;
}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(12);
	lint m,n;
	in(m,n);
	out(modpow(m,n,MOD));
	return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  int A, B;
  cin >> A >> B;
  cout << A * B << endl;
}

Measured memory_bytes: 3576
#include <stdio.h>
int calc(int x){
        int a=0;
        if(x>9){
                while(x>9){
                        a+=x%10;
                        x=x/10;
                }
                return a+x;
        }else return x;
}

int main(void){
        int n;
        int i;
        if(scanf("%d",&n)==1);
        int min=n;
        for(i=1;i<n;i++){
                if(min>calc(i)+calc(n-i))min=calc(i)+calc(n-i);
        }
        printf("%d\n",min);

        return 0;
}


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

int main() {
	long long n, a[5], min;
	cin >> n;
	min = 1000000000000005;
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
		if (a[i] < min) min = a[i];
	}
	long long ans;
	ans = 4 + n / min;
	if (n%min != 0) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
max_1 = 0
max_2 = 0
max_1_index = -1
for i in range(N):
	new_num = int(input())
	if max_1 <= new_num:
		max_2 = max_1
		max_1 = new_num
		max_1_index = i
	elif max_2 <= new_num:
		max_2 = new_num
	
for i in range(N):
	if max_1_index == i:
		print(max_2)
	else:
		print(max_1)



Measured memory_bytes: 4540
import java.util.Scanner;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();

        if (n < k) {
            System.out.println(n * x);
        }else {
            int total = k * x;
            total += (n - k) * y;
            System.out.println(total);
        }

    }
}

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

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

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

    vector<long long> b(N);
    for (int i = 0; i < N; i++)
    {
        cin >> b[i];
    }

    long long count_add_a = 0;
    long long count_add_b = 0;
    for (int i = 0; i < N; i++)
    {
        if (a[i] > b[i])
        {
            count_add_b += a[i] - b[i];
        }
        else if (a[i] < b[i])
        {
            count_add_a += (b[i] - a[i]) / 2;
        }
    }
    if (count_add_a < count_add_b)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES":"NO");}
void Yn(bool z){cout<<(z?"Yes":"No");}
void yn(bool z){cout<<(z?"yes":"no");}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
int n;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  cout << n/3 << endl;
  return 0;
}

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

int main() {
    string s;
    int k;
    cin >> s >> k;

    vector<string> v;
    for (int i = 0; i < s.size(); i++) {
	string d;
	for (int j = 0; j < k; j++) {
	    if (i + j < s.size()) d += s[i + j];
	    v.push_back(d);
	}
    }



    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    cout << v[k-1] << endl;

    return 0;
}


Measured memory_bytes: 1660
#include<iostream>
#include<cfloat>
#include<cmath>
#include<vector>

using namespace std;
#define rep(i, n) for ( int i = 0; i < (int)n; i++ )
#define EPS (1e-8)

class Point{
    public:
    double x, y;
    
    Point ( double x = 0, double y = 0): x(x), y(y){}
    
    Point operator + ( Point p ){ return Point(x + p.x, y + p.y); }
    Point operator - ( Point p ){ return Point(x - p.x, y - p.y); }
    Point operator * ( double a ){ return Point(x*a, y*a); }
};
typedef Point Vector;
typedef vector<Point> Polygon;

double norm( Vector a ){ return a.x*a.x + a.y*a.y; }
double dot( Vector a, Vector b ){ return a.x*b.x + a.y*b.y; }
double cross( Vector a, Vector b ){ return a.x*b.y - a.y*b.x; }

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

int ccw( Point p0, Point p1, Point p2 ){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if ( cross(a, b) > EPS ) return COUNTER_CLOCKWISE;
    if ( cross(a, b) < -EPS ) return CLOCKWISE;
    if ( dot(a, b) < -EPS ) return ONLINE_BACK;
    if ( norm(a) < norm(b) ) return ONLINE_FRONT;
    return ON_SEGMENT;
}

bool isIntersect(Point p1, Point p2, Point p3, Point p4){
    return ( ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
	     ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0 );
}

bool isInside(Polygon pol, Point p){
    rep(i, 4){
	if ( ccw(pol[i], pol[(i+1)%4], p ) == COUNTER_CLOCKWISE ) return false;
    }
    return true;
}

bool isIntersectSQ(Polygon p1, Polygon p2 ){
    rep(i, 3) rep(j, 3){
	if ( isIntersect(p1[i], p1[i+1], p2[j], p2[j+1] ) ) return true;
    }
    rep(i, 4) if(isInside(p1, p2[i])) return true;
    rep(i, 4) if(isInside(p2, p1[i])) return true;
    return false;
}

Polygon P[100];
int n, G[100][100];
bool V[100];

void dfs( int u ){
    V[u] = true;
    rep(v, n) if ( G[u][v] && !V[v] ) dfs(v);
}

int compute(){
    rep(i, n) rep(j, n ) G[i][j] = 0;
    rep(i, n) rep(j, n ) if ( isIntersectSQ(P[i], P[j]) ) G[i][j] = 1;
    rep(i, n) V[i] = false;
    int ncomponent = 0;
    rep(i, n){
	if ( V[i] ) continue;
	ncomponent++;
	dfs(i);
    }
    return ncomponent;
}

int main(){
    int N;
    double x, y;
    while( cin >> N && N ){
	rep(i, N){
	    cin >> n;
	    rep(j, n){
		Polygon pol;
		rep(k, 4){
		    cin >> x >> y;
		    pol.push_back(Point(x, y));
		}
		P[j] = pol;
	    }
	    cout << compute() << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 1004
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<N;i++)
#define INF 1e9
typedef long long LL;
const LL MOD = 1e9+7;

int main() {
  LL N;
  cin >> N;
  vector<LL> H(N);
  rep(i,N) cin >> H[i];

  string answer = "Yes";
  for(int i=N-1; i>0; i--) {
    if (H[i-1] > H[i]) { H[i-1]--; }
    if (H[i-1] > H[i]) { answer = "No"; break; }
  }
  cout << answer << endl;
  
  return 0;
}


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

#define ll long long int
ll const mod = 1e9 + 7;

ll power(ll x, ll y, ll p){ //x^y % p
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or equal to p 
    while (y > 0) {
        if (y & 1) // If y is odd, multiply x with result 
        res = (res*x) % p; 
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
}

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    
    int dp[n] {0};
    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=(int)1e9;
        for(int j=max(0, i-k);j<i;j++)
        {
            dp[i] = min(dp[j]+abs(a[i]-a[j]), dp[i]);
        }
    }
    cout<<dp[n-1];
	// your code goes here
	return 0;
}


Measured memory_bytes: 1024
inf = float('inf')
X,N = map(int,input().split())
p = list(map(int,input().split()))
ans = 101
diff = inf
for i in range(101,-1,-1):
    if i not in p:
        if diff >= abs(i-X):
            diff = abs(i-X)
            ans = i

print(ans)

Measured memory_bytes: 61644
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#define N 200005
#define lowbit(o) o&(-o)
using namespace std;
int i,j,k,l,s,n,m,R[N],L[N],st[N],ans,mx[N],top;
int a[N],b[N];
char c[N];
inline bool cmp(int x,int y) {
	return R[x]<R[y];
}
int main() {
	scanf("%s",c+1);
	n=strlen(c+1);
	for (i=1;i<=n;i++) a[i]=c[i]-48,L[i]=R[i]=100000000;
	scanf("%s",c+1);
	for (i=1;i<=n;i++) b[i]=c[i]-48;
	for (i=1;i<=n;i++) for (j=1;j<=n;j++) if (b[j]) L[i]=min(L[i],(i-j+n)%n),R[i]=min(R[i],(j-i+n)%n);
	ans=100000000;
	for (i=1;i<=n;i++) {
		top=0; int now=i;
		for (j=1;j<=n;j++) {
			if (a[now]!=b[j]) st[++top]=now;
			now%=n; now++;
		}//printf("%d\n\n",j);
		sort(st+1,st+1+top,cmp);
		mx[top+1]=0;
		for (k=top;k;k--) mx[k]=max(mx[k+1],L[st[k]]);
		
		for (k=0;k<=top;k++) {
			//workL:
			ans=min(ans,(R[st[k]]+max((i-(n+1)+n)%n,mx[k+1]))*2-(i-(n+1)+n)%n+top);
			//workR:
			ans=min(ans,(mx[k+1]+max(((n+1)-i+n)%n,R[st[k]]))*2-((n+1)-i+n)%n+top);
		}
	}
	if (ans>=100000000) ans=-1;
	printf("%d\n",ans);
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define fi first
#define se second
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 1e6+9
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}




void test_case() {
	
    int n, m;
    cin>>n>>m;

    unordered_map<int,int> corr, wron;

    int a =0;
    int b=0;


    rep(i,m) {
        int x;
        cin>>x;

        string s;
        cin>>s;

        if(s == "AC") {
            if(corr[x] == 0) {
                a++;
                b+= wron[x];
                corr[x] = 1;
            }
        } else {
            wron[x]++;
        }
    }


    cout<<a<<" "<<b<<endl;

   




}


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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    int t = 1;
    // cin >> t;
    while(t--)
    {   
        test_case();
    }
}

Measured memory_bytes: 11248
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const ll MOD = 998244353;
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}
ll rev(ll x) {
	return bin_pow(x, MOD - 2);
}

const int N = 4001000;
ll f[N], rf[N];
ll p2[N], rp2[N];

ll getC(int n, int k) {
	if (k < 0 || k > n) return 0;
	return mult(f[n], mult(rf[k], rf[n - k]));
}

int n, m;
char s[N];
int a[N], b[N], c[N], d[N];
ll L[N], R[N];
int sum[N];

ll solve() {
	for (int i = 0; i <= n; i++)
		sum[i] = 0;
	for (int i = 0; i < n; i++) {
		sum[i + 1] = sum[i];
		if (a[i] && b[i])
			sum[i + 1]++;
	}
	int A = 0;
	for (int i = 0; i < m; i++)
		A += c[i];
	int B = 0;
	for (int i = 0; i < n; i++) {
		L[i] = R[i] = 0;
	}
	for (int i = 0; i < n; i++) {
		if (a[i] == 0 && b[i] == 0) continue;
		if (A == 0) {
			L[i] = (B == 0 ? 1 : 0);
		} else {
			L[i] = getC(A - 1 + B, B);
		}
		B += a[i] + b[i];
	}
	A = B = 0;
	for (int i = 0; i < m; i++)
		A += d[i];
	for (int i = n - 1; i >= 0; i--) {
		if (a[i] == 0 && b[i] == 0) continue;
		if (A == 0) {
			R[i] = (B == 0 ? 1 : 0);
		} else {
			R[i] = getC(A - 1 + B, B);
		}
		B += a[i] + b[i];
	}
	ll ans = 0;
	ll curSum = 0;
	for (int i = 0; i < n; i++) {
		curSum = add(curSum, mult(L[i], rp2[sum[i]]));
		ans = add(ans, mult(mult(curSum, R[i]), p2[sum[i + 1]]));
	}
	return ans;
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	f[0] = 1;
	for (int i = 1; i < N; i++)
		f[i] = mult(f[i - 1], i);
	rf[N - 1] = rev(f[N - 1]);
	for (int i = N - 1; i > 0; i--)
		rf[i - 1] = mult(rf[i], i);
	p2[0] = 1;
	for (int i = 1; i < N; i++)
		p2[i] = add(p2[i - 1], p2[i - 1]);
	rp2[0] = 1;
	for (int i = 1; i < N; i++) {
		rp2[i] = rp2[i - 1];
		if (rp2[i] & 1) rp2[i] += MOD;
		rp2[i] >>= 1;
	}

	scanf("%d%d", &n, &m);
	scanf("%s", s);
	for (int i = 0; i < n; i++)
		a[i] = (int)s[i] - '0';
	scanf("%s", s);
	for (int i = 0; i < n; i++)
		b[i] = (int)s[i] - '0';
	scanf("%s", s);
	for (int i = 0; i < m; i++)
		c[i] = (int)s[i] - '0';
	scanf("%s", s);
	for (int i = 0; i < m; i++)
		d[i] = (int)s[i] - '0';

	bool allZ = true;
	for (int i = 0; i < n; i++)
		allZ &= a[i] == 0 && b[i] == 0;
	for (int i = 0; i < m; i++)
		allZ &= c[i] == 0 && d[i] == 0;
	if (allZ) {
		printf("1\n");
		return 0;
	}

	ll ans = solve();
	swap(n, m);
	swap(a, c);
	swap(b, d);
	ans = add(ans, solve());
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 198528
#include <iostream>
#include <vector>

using namespace std;

int main() {
  string s;
  cin >> s;
  vector<string> v;
  v.push_back("dream");
  v.push_back("dreamer");
  v.push_back("erase");
  v.push_back("eraser");

  bool dp[s.size() + 1];
  for (int i = 0; i < s.size() + 1; i++) {
    dp[i] = false;
  }
  dp[0] = true;
  for (int i = 0; i < s.size() + 1; i++) {
    if (!dp[i]) {
      continue;
    }
    for (int j = 0; j < v.size(); j++) {
      if (s.substr(i, v[j].size()) == v[j]) {
        dp[i + v[j].size()] = true;
        // cout << i + v[j].size() << endl;
      }
    }
  }
  if (dp[s.size()]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 3304
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        //タップダンスの動き
        String s;
        //標準入力を読み込むためのScanner
        Scanner sc = new Scanner(System.in);
        //動きやすいかどうかの結果
        String result = "Yes";
        
        //タップダンスの動きを標準入力から取得
        s = sc.next();
        //文字列から"L"を探す
        for(int i = 0; i < s.length(); i++){
            //文字列に"L"が含まれている位置を取得
            int index = s.indexOf("L", i);
            
            //"L"が見つかった場合、動きづらいどうかの判定と取得位置の更新をする
                //"L"が奇数文字目にあれば動きづらい
            if(index != -1){
                if((index + 1) % 2 != 0){
                    result = "No";
                }
                //Lが見つかった位置を指定
                i = index;
            }
        }
        
        //文字列から"R"を探す
        for(int i = 0; i < s.length(); i++){
            //文字列に"R"が含まれている位置を取得
            int index = s.indexOf("R", i);
            
            //"R"が見つかった場合、動きづらいどうかの判定と取得位置の更新をする
                //"R"が偶数文字目にあれば動きづらい
            if(index != -1){    
                if((index + 1) % 2 == 0){
                    result = "No";
                }
                //Rが見つかった位置を指定
                i = index;
            }
        }
        
        //結果を出力
        System.out.println(result);

    }
}


Measured memory_bytes: 21844
n = gets.to_i
a = gets.split.map(&:to_i)
count = 0

l = r = 0
x = y = a[0]
while r < n
  if x == y
    count += r - l + 1
    r += 1
     break if r == n
    x ^= a[r]
    y += a[r]
  else
    x ^= a[l]
    y -= a[l]
    l += 1
  end
end

puts count

Measured memory_bytes: 15372
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 100000000000
#define mod 1000000007
#define pll pair<long,long>
#define se second
#define fi first
#define pb push_back
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update>pllordered_set;



int main()
{
			ios_base::sync_with_stdio(false);
			cin.tie(NULL);
			string s,t;
			cin>>s>>t;
			ll n=s.length();
			vector<vector<ll> > v(27);
			for(ll i=0;i<s.length();i++)
			{
				v[s[i]-'a'].pb(i+1);
			}
			ll pos=0,diff=0;
			ll ans=0;
			for(ll i=0;i<t.length();i++)
			{
				ll p=t[i]-'a';
				if(v[p].size()==0)
					{
						cout<<-1;
						exit(0);
					}
				
					
					auto p1=upper_bound(v[p].begin(),v[p].end(),pos);
					if(p1!=v[p].end())
						{
							
							pos=*p1;
							//cout<<pos<<endl;
							ans=floor(ans*1.0/n)*n+pos;
						}
					else
					{
						pos=v[p][0];
						ans=ceil(ans*1.0/n)*(n)+pos;
					}
					//cout<<pos<<endl;
				
			}
			cout<<ans;
			
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}

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

    int k;
    cin >> k;
    if (k < 10) {
        cout << k;
        return 0;
    }

    queue<ll> q;
    for (ll i = 1LL; i < 10; i++) {
        q.push(i);
    }

    while (true) {
        if (k == 1) {
            break;
        }
        ll now = q.front();
        //cout << "D: " << now << "\n";
        q.pop();
        ll d = now%10;
        if (d != 0) {
            q.push(now*10 + d-1);
        }
        q.push(10*now+d);
        if (d != 9) {
            q.push(now*10 + d + 1);
        }
        k--;
    }

    cout << q.front();




    return 0;
}


Measured memory_bytes: 1792
N,M = list(map(int, input().split()))
KS = [list(map(int, input().split())) for _ in range(M)]
P = list(map(int, input().split()))

answer = 0
from itertools import product
for sw in product([0,1], repeat=N):
  for p, ks in zip(P,KS):
    K = ks[0]
    S = ks[1:]
    if sum([sw[s-1] for s in S])%2 != p%2:  
      break
  else:
    answer += 1
    
print(answer)

Measured memory_bytes: 3064