akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iomanip>
#define ll int
#define M 1000000000000000002
#define N 400003
#define pb push_back
#define endl "\n"

using namespace std;
double dp[3000][3000]; //increase the size


int main()
{
    ll n;double arr[N];
    cin>>n;
    for(ll i=1;i<=n;i++) cin>>arr[i];
    dp[1][1]=arr[1];
    dp[1][0]=1-arr[1];
    
    
    for(ll i=2;i<=n;i++)
    {
        for(ll j=0;j<=i;j++)
        {
            if(j==0)
            {
                dp[i][j]=dp[i-1][j]*(1-arr[i]);
            }
            else if(i==j)
            {
                dp[i][j]=dp[i-1][j-1]*arr[i];
        }
        else
        {
            dp[i][j]=dp[i-1][j-1]*arr[i]+dp[i-1][j]*(1-arr[i]);
        }
        
        }}
  
    double a=0.0;
    for(ll i=n;i>=(n/2)+1;i--)
    {
        a+=dp[n][i];
    }
    cout<<fixed<<setprecision(10)<<a<<endl;
        return 0;
    
}


Measured memory_bytes: 68864
/*
@author: sharrad99
*/
#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	PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vll vector<ll>
#define vbl vector<bool>
#define vpll vector<pll>
#define pb push_back
#define eb emplace_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(x) x.begin(),x.end()
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define mod 1000000007
#define INF 1000000000000000
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> ordered_set_pll;
#define ook order_of_key
#define fbo find_by_order
/*  
	Query 1 - order_of_key(k) : Number of items strictly smaller than k.
	Query 2 - find_by_order(k) : K-th element in the set (counting from zero).
	less<ll> means Query 1 will return numbers strictly less than k.
	greater<ll> means Query 1 will return numbers strictly greater than k.
*/
ll powmod(ll x, ll n){
	ll res = 1;
	while(n){
		if(n & 1){
			res *= x;
			res %= mod;
		}
		x *= x;
		x %= mod;
		n >>= 1;
	}
	return res;
}
ll invmod(ll a){
	return powmod(a, mod - 2);
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s, t;
	cin >> s >> t;
	t += s;
	cout << t << '\n';
}

Measured memory_bytes: 256
N,D,A=map(int, input().split())
XH=[list(map(int, input().split())) for _ in range(N)]

XH.sort()

B=0
Bt=[0]*N
Bx=[0]*N
l=0
r=-1

ans=0
for i in range(N):
    x,h = XH[i]
    if h<=0: continue
    #今までの爆弾ダメージを計算
    while l<=r:
        if Bx[l]<x: #もう届かない
            B-=Bt[l]*A
            l+=1
        else: #まだ届く
            break
    h-=B
    if h>0:
        t=(h+A-1)//A #ここで爆弾を使う回数
        ans+=t
        r+=1
        Bt[r]=t
        Bx[r]=x+(2*D)
        B+=A*t

print(ans)

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

// for loop
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

// abbreviati
#define PB(v) push_back(v)
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

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

// constant
const int INF = 1<<30;
const ll INFLL = 1LL << 60;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

/***Snippet***************************************************
ifelse, isprime, torad, todeg, lcm, bfs,chmin,chmax
**************************************************************/

// adjacency list
vector<int> to[100005];

// Graph
using Graph = vector<vector<int>>;

// Grid
int H,W;
vector<vector<int>> field;

// 4方向への移動ベクトル
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    vector<int> A(n);
    rep(i,0,n) cin >> A[i];

    int top=A[0];
    ll cnt=0;
    rep(i,0,n){
        if(top<A[i]) top=A[i];
        else{
            cnt+=(top-A[i]);
        }
    }
    
    cout << cnt ENDL;

    return 0;
}

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

int main() {
  	long long p, n;
  	cin >> p >> n;
  	long long a[n];
  	for(long long i = 0; i < n; i++) {
      	cin >> a[i];
    }
  	long long dist = 0;
  	for(long long i = 1; i < n; i++) {
      	dist = max(dist, a[i] - a[i - 1]);
    }
  	dist = max(dist, a[0] + p - a[n - 1]);
  	cout << p - dist << endl;
  	return 0;
}


Measured memory_bytes: 1792
from itertools import accumulate
n = int(input())
aaa = list(map(int, input().split()))
a_sum = list(accumulate(aaa))
ans = 1e10
for i in range(n - 1):
    ans = min(ans, abs(a_sum[i] - a_sum[n - 1] + a_sum[i]))
print(ans)

Measured memory_bytes: 24168
#include<cstdio>
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
#define MN 100000
struct edge{int nx,t;}e[MN*2+5];
int h[MN+5],en,f[MN+5],o;
inline void ins(int x,int y)
{
	e[++en]=(edge){h[x],y};h[x]=en;
	e[++en]=(edge){h[y],x};h[y]=en;
}
void dfs(int x,int fa)
{
	f[x]=1;
	for(int i=h[x];i;i=e[i].nx)if(e[i].t!=fa)
	{
		dfs(e[i].t,x);
		if(f[e[i].t])f[x]?f[x]=0:o=1;
	}
}
int main()
{
	int n=read(),i;
	for(i=1;i<n;++i)ins(read(),read());
	dfs(1,0);
	puts(f[1]||o?"First":"Second");
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

P f(int N){
    if(N < 10) return P(N,N);
    P res;
    res.second = N%10;
    while(N > 9) N /= 10;
    res.first = N;
    return res;
}
int main(void){
    int N; cin >> N;

    ll ans = 0;
    FOR(i,1,N+1){
        P p = f(i);
        int b, digit=0;
        if(p.first == p.second) ans++;
        if(p.second == 0) continue;
        b = 10*p.second + p.first;
        while(true){
            int tmp = 10*(p.second*pow(10,digit) + pow(10,digit)-1) + p.first;
            if(tmp - 10*(pow(10,digit)-1) > N) break;
            if(tmp <= N) ans += pow(10,digit);
            else{
                int l = 0, r = pow(10,digit)-1, n = (l+r)/2;
                while(r-l > 1){
                    int tmp2 = 10*(p.second*pow(10,digit) + n) + p.first;
                    if(tmp2 > N) r = n;
                    else l = n;
                    n = (l+r)/2;
                }
                ans += l+1;
            }
            digit++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using ll=long long;

int main() {
  set<int> s;
  int a,b,c; cin >>a >>b >>c;
  s.insert(a);
  s.insert(b);
  s.insert(c);
  cout <<s.size() <<endl;
  return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <algorithm>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
#include <cmath>
#include <stack>
#include <limits>
#include <ctime>

using namespace std;

#define ll long long
#define sc(n) static_cast<ll>(n)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {
	IO;
#ifdef _DEBUG
	ifstream cin("In.txt");
#endif	
	ll n,sm=0;
	cin >> n;
	for (size_t i = 1; i <= n; i++) {
		if (!(i % 3 == 0 || i % 5 == 0))
			sm += i;
	}
	cout << sm << endl;
	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
using namespace std;
//cout << "Yes" << endl;
//cout << "No" << endl;
int seiyaku_check(long i,int Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
	}
}

int main(){
	
	int a,b;
	
	cin >> a >> b;
	
	seiyaku_check(a,1,3);
	seiyaku_check(b,1,3);
	
	if( a == b)exit(1);
	
	cout << 6-a-b << endl;
	
return 0;
}


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

typedef long long ll;
typedef long double ld; 
typedef double db; 
typedef string str; 

typedef pair<int, int> pi;
typedef pair<ll,ll> pl; 
typedef pair<ld,ld> pd; 

typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 998244353;
const ll INF = 1e18;
const int MX = 1000001;

int N, A, lastSeen = 0;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> N;
    F0R(i, N) {
        cin >> A;
        if (A == lastSeen + 1) lastSeen++;
    }
    if(lastSeen) cout << N - lastSeen;
    else cout << -1;
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp32 {
    class Program {
        static void Main(string[] args) {
            var t = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            Array.Sort(t);
            int A = t[0];
            int B = t[1];

            int ans = 0;

            ans += B;

            if (A <= B - 1) {
                ans += B - 1;
            } else {
                ans += A;
            }

            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 13396
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<sstream>
#include<string>
#include<cstdlib>

int main()
{
	std::string N;
	while( std::cin >> N, N != "0000" )
	{
		int cnt = 0;

		bool f = true;
		for( int i = 0; i != 3; ++i )
			f &= N[i] == N[i+1];

		if( f )
			std::cout << "NA" << std::endl;
		else
		{
			while( N != "6174" )
			{
				std::string L = N;
				std::sort( L.rbegin(), L.rend() );
				
				std::string S = L;
				std::reverse( S.begin(), S.end() );
				
				std::ostringstream oss;
				oss << std::setw( 4 ) << std::setfill( '0' ) << atoi( L.c_str() ) - atoi( S.c_str() );
				N = oss.str();

				++cnt;
			}

			std::cout << cnt << std::endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int t;
string num;

void solve(){
    int n = num.size()-1, ans = -1, cnt = 0;
    vector<int> part;
    rep(S, 1<<n){
        vector<int> idx = {0};
        rep(i, n)if(S>>i & 1) idx.push_back(i+1);
        idx.push_back(n+1);
        bool flag = true;
        int sum = 0;
        rep(i, idx.size()-1){
            string tmp = num.substr(idx[i], idx[i+1]-idx[i]);
            sum += stoi(tmp);
        }
        if(!flag || sum > t) continue;
        if(ans == sum) ++cnt;
        else if(chmax(ans, sum)){
            part = idx;
            cnt = 1;
        }
    }
    if(cnt == 0) puts("error");
    else if(cnt > 1) puts("rejected");
    else{
        printf("%d ", ans);
        rep(i, part.size()-1){
            cout << num.substr(part[i], part[i+1]-part[i]);
            printf(i == part.size()-2 ? "\n" : " ");
        }
    }
}

int main(){
    while(cin >> t >> num && t){
        solve();
    }
}


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

bool is_triangle(int a, int b, int c) {
  // a <= b <= c
  if (a == b || a == c || b == c) {
    return false;
  } 
  if (a + b > c) {
    return true;
  } 
  return false;
}

int main() {
  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 - 2; i++) {
    for (int j = i + 1; j < N - 1; j++) {
      for (int k = j + 1; k < N; k++) {
        if (is_triangle(L[i], L[j], L[k])) {
          ans++;
        }
      }
    }
  }
  cout << ans;
}


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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c)

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

int main()
{
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  for(int i = 0 ; i < n ; i++)
  {
    int a;
    cin >> a;
    if(a  %2 == 0)
    {
      if((a % 3 != 0) && (a % 5 != 0))
      {
        cout << "DENIED\n";
        return 0;
      }
    }
  }

  cout << "APPROVED" << endl;
  return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<ll,ll,ll> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int A,B; cin >> A >> B;
    if(A <= 5) cout << 0 << endl;
    else if(A <= 12) cout << B/2 << endl;
    else cout << B << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
bool check(vector<int> u, int x)
{
for(int i=0;i<u.size();i++)
{
if(u[i]<x)
	return false;
}
return true;
}


int main()
{
    int n,flag=0,y,m,x,ans=INT_MAX;
    cin>>n>>m>>x;
    vector<int> c(n);
    vector<vector<int>> a(n,vector<int>(m));
    
    for(int i=0;i<n;i++)
    {
    for(int j=0;j<=m;j++)
    {
    if(j==0)
    cin>>c[i];
    else
    cin>>a[i][j-1];	
    }
    }
   
    int tot=1<<n;
    int cost;
    
    for(int mask=0;mask<tot;mask++)
    {
    vector<int> u(m,0);
    cost=0;
    for(int i=0;i<n;i++)
    {
    if((mask&(1<<i))!=0)
    {
    cost+=c[i];
    for(int j=0;j<m;j++)
    u[j]+=a[i][j];
    }	
    }
    if(check(u,x))
    {
    flag=1;
    ans=min(ans,cost);	
    }
    }
    if(flag==0)
    	cout<<-1;
    else
        cout<<ans;
    
	return 0;
}

Measured memory_bytes: 3116
import java.util.*;
public class Main { 
	static ArrayList<Integer> list = new ArrayList<Integer>();
	static ArrayList<Integer> oddList = new ArrayList<Integer>();
	static int[] dp;
	static int[] odp;
	static int n;
	static int INF = 1 << 22;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		makeList();		
		dp = new int[1000001];
		odp = new int[1000001];
		Arrays.fill(dp, INF);
		Arrays.fill(odp, INF);
		dp[0] = odp[0] = 0;
		dp();
		oddDp();
		while(true) {
			n = stdIn.nextInt();
			if(n == 0) break;
			int ansA = 0;
			int ansB = 0;
			
			ansA = dp[n];
			ansB = odp[n];
			System.out.println(ansA + " " + ansB);
		}
	}
	public static void dp() {
		for(int i = 0; i <= 1000000; i++) {
			for(int j = 0; j < list.size(); j++) {
				int a = list.get(j);
				if(i - a < 0) break;
				if(dp[i - a] + 1 < dp[i]) {
					dp[i] = dp[i-a] + 1;
				}
			}
		}
	}
	public static void oddDp() {
		for(int i = 0; i <= 1000000; i++) {
			for(int j = 0; j < oddList.size(); j++) {
				int a = oddList.get(j);
				if(i - a < 0) break;
				if(odp[i - a]+1 < odp[i]) {
					odp[i] = odp[i-a]+1;
				}
			}
		}
		
	}
	public static void makeList() {
		for(int i = 1; i < 182; i++) {
			int a = i * (i + 1) * (i + 2);
			if(a % 6 == 0) {
				a /= 6;
				list.add(a);
				if(a % 2 == 1) {
					oddList.add(a);
				}
			}
		}
	}
	
}

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

int main(){
  int k,s;
  cin >> k >> s;
  int  res = 0;
  vector<int> vec(2*k+1,0);
  for(int i = 0;i <= k;i++){
	for(int j = 0;j <= k;j++){
	  vec[i+j]++;
	}
  }
  for(int i = 0;i <= k;i++){
	int sub = s - i;
	if(2*k < sub || sub < 0) continue;
	res += vec[sub];
  }
  
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i=a;i<b;i++)
#define REP(i, n) FOR(i, 0, n)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
#define PB push_back
#define MP make_pair
#define YES() printf("yes\n"),exit(0);
#define NO() printf("no\n"),exit(0);

#define N 112345
int uf_par[N], uf_siz[N];
int grp(int a){
  if(uf_par[a]==a) return a;
  else return uf_par[a]=grp(uf_par[a]);
}
void merg(int a, int b){
  a=grp(a);
  b=grp(b);
  if(uf_siz[a]<uf_siz[b]) swap(a,b);
  uf_par[b]=a;
  uf_siz[a]+=uf_siz[b];
}

int n, m;
int d[N];
vi path[N];
int dfs(int a, int p){
  d[a]=1;
	int cnt=0;	
	REP(j, path[a].size()){
		int b=path[a][j];
    if(b==p) continue;
		if(d[b]==-1) continue;
    if(d[b]){
			// printf("%d=>%d\n",a,b);
      d[b]++;
      cnt++;
    }else{
      // printf("%d->%d\n",a,b);
      cnt+=dfs(b,a);
    }
	}
  cnt-=d[a]-1;
  if(cnt) merg(a,p);
  d[a]=-1;
	return cnt;
}
vi stick[N];
int memo[N][2];
int DP(int,int,bool);
int dp(int a, int p, bool av){
	if(~memo[a][av]) return memo[a][av];
	else return memo[a][av]=DP(a,p,av);
}
int DP(int a, int p, bool av){
	int x=0, y=INT_MIN;
	REP(i, stick[a].size()){
		int b=stick[a][i];
		if(b==p) continue;
		x+=dp(b, a, 1);
	}
	if(av){
		y=uf_siz[a];
		REP(i, stick[a].size()){
			int b=stick[a][i];
			if(b==p) continue;
			y+=dp(b, a, 0);
		}
	}
	// printf("dp(%d, %d)=max(%d, %d)\n", a, av, x, y);
	return max(x, y);
}

int main(){
  scanf("%d%d", &n, &m);
	REP(i, m){
		int s, t;
		scanf("%d%d", &s, &t);
		path[s].PB(t);
		path[t].PB(s);
	}
	
  fill(d, d+N, 0);
	// fill(vis, vis+N, false);
	REP(i, N) uf_par[i]=i;
  fill(uf_siz,uf_siz+N,1);
    REP(i, n) if(!d[i]) dfs(i,-1);
	
	// REP(i, n) printf("%2d ", i);  printf("\n");
  // REP(i, n) printf("%2d ", grp(i));printf("\n");
  // REP(i, n) printf("%2d ", uf_siz[i]);printf("\n");
	
	REP(i, n){
		REP(j, path[i].size()){
			int p=grp(i), q=grp(path[i][j]);
			if(i<path[i][j] && p!=q){
				stick[p].PB(q);
				stick[q].PB(p);
		    //printf("%d-%d\n", p, q);
			}
		}
	}
	REP(i, n) memo[i][0]=memo[i][1]=-1;
	int ans=0;
	REP(i, n){
		int j=grp(i);
		if(memo[j][1]==-1){
			//printf("%d\n", ans);
			ans+=dp(j,-1,1);
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 16984
#include <iostream>
#include <vector>
#include <string>

constexpr int INF = (1e9);

using P = std::pair<int, std::vector<int>>; //top,subs

std::vector<P> vec;

std::string in;

std::vector<int> ans;

int main()
{

    int n, k, c;

    std::cin >> n >> k >> c;

    int x = INF;

    std::cin >> in;

    //vec作成

    P pair;
    pair.first = INF;

    for (int i = n - 1; i >= 0; --i)
    {
        char ch = in[i];
        if (x >= c && ch == 'o')
        {
            if (pair.first != INF)
                vec.push_back(pair);
            pair.first = i;
            pair.second.clear();
            x = 0;
        }
        else
        {
            ++x;
            if (ch == 'o')
                pair.second.push_back(i);
        }
    }

    vec.push_back(pair);

    //k=vec.size()かの確認
    if (vec.size() > k)
        return 0;

    //DEBUG
    std::cerr << "DEBUG:START" << std::endl;
    for (auto p : vec)
    {
        std::cerr << p.first << std::endl;
        for (int x : p.second)
            std::cerr << x << ' ';
        std::cerr << std::endl;
    }
    std::cerr << "DEBUG:END" << std::endl;

    int m = vec.size(), moveable = 0; //moveableはどれだけ前に動けるかが前もって格納されている

    //位置的に一番前のクラスターは候補者を好きなだけ代替として拾わせることができる
    if (!vec[m - 1].second.empty())
    {
        moveable = vec[m - 1].first - *(vec[m - 1].second.rbegin());
    }
    else
    {
        ans.push_back(vec[m - 1].first + 1);
    }

    for (int i = m - 2; i >= 0; --i)
    {

        moveable += vec[i].first - c - vec[i + 1].first - 1; //クラスター間の距離の分だけ動ける距離を追加

        bool flag = true; //代わりに拾わせられる候補者が出てくるかのフラグ

        for (int j = vec[i].second.size() - 1; j >= 0; --j)
        {
            if (vec[i].first - vec[i].second[j] <= moveable)
            {
                flag = 0;
                moveable = vec[i].first - vec[i].second[j]; //次のクラスターがどれだけ動けるか
                break;
            }
        }
        if (flag)
        {
            ans.push_back(vec[i].first + 1);
            moveable = 0;
        }
    }

    //ans吐き出し
    for (auto x : ans)
        std::cout << x << std::endl;

    return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    while(b!=0){
        int tmp=a%b;
        a=b;
        b=tmp;
    }
    return a;
}

ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}

int main(){

    int x;
    cin>>x;

    int d=lcm(360,x);

    cout<<d/x<<"\n";

    return 0;

}

Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stdio.h>
#include<deque>
#include<map>
#include<queue>
#include<cmath>

typedef long long ll;

#define debug(x) cout << #x << '=' << x << endl;
#define debug_arr(a, n) for(ll i = 0; i < n; i++)cout << a[i] << ' '
#define inf 100000000000
#define loop(i,n) for(ll i = 0; i < n; i++)
#define graph vector<vector<ll>>
#define P pair<ll,ll>

using namespace std;

struct job {
    int time;
    int deadline;
};

bool compare(const job& l, const job& h){
    return l.deadline < h.deadline;
}

int main(){
    int n;
    cin >> n;
    vector<job> todo(n);
    loop(i,n){
        cin >> todo[i].time >> todo[i].deadline;
    }

    sort(todo.begin(), todo.end(), compare);

    long long time = 0;
    loop(i,n){
        // cout << todo[i].time << todo[i].deadline << endl;
        time += todo[i].time;
        if(time > todo[i].deadline){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;

}

Measured memory_bytes: 1792
ans = 0
N = int(input())
for i in range(1,N+1):
    divisor = 0
    if i % 2 == 0:
        continue
    for q in range(1,i+1):
        if i % q == 0 :
            divisor += 1
    if divisor == 8:
        ans += 1
print(ans)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define int long long
using namespace std ;
int read() {
  int x = 0 , f = 1 ;
  char c = getchar() ;
  while(c < 48 || c > 57) {
    if(c == '-') f = -1 ;
    c = getchar() ;
  }
  while(c > 47 && c < 58) {
    x = (x << 1) + (x << 3) + (c & 15) ;
    c = getchar() ;
  }
  return x * f ;
}
void print(int x) {
  if(x < 0) x = -x , putchar('-') ;
  if(! x) { putchar('0') ; }
  static char st[30] ; int stp = 0 ;
  while(x) { st[++ stp] = x % 10 ^ 48 ; x /= 10 ;}
  while(stp) { putchar(st[stp --]) ; }
  putchar('\n') ;
}
signed main() {
  string s ;
  cin >> s ;
  int len = s.length() ; s = " " + s ;
  int ans = 0 ;
  for(int i = 1 ; i <= (len >> 1) ; i ++)
    if(s[i] != s[len - i + 1]) ans ++ ;
  print(ans) ;
  return 0 ;
}


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

int main(){
    set<unsigned> data;
    int N;
    cin >> N;
    for(int i=0;i<N;i++){
        int p[3];
        cin >> p[0] >> p[1] >> p[2];
        sort(p,p+3);
        data.insert(p[0]*1000000 + p[1]*1000 + p[2]);
    }
    cout << N-data.size() << endl;

    return 0;
}


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

int main(){
    
    int N;
    string s,t;
    cin >> N;
    cin >> s >> t;

    for(int i = 0;i < N;i++){
        //cout << r.substr(0,i) <<" "<< t.substr(0,i)<<endl;
        if(s.substr(i)==t.substr(0,N-i)){
            
            cout << N + i<<endl;
            return 0;
        }
        
    }

    cout <<s.size() + t.size() <<endl;
    return 0;
}
    
    



Measured memory_bytes: 256
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#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 unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


ll gcd(ll a, ll b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N;
    in(N);

    vll A(N);
    inN(A, N);

    ll ans = A[0];
    rep(i, N) ans = gcd(ans, A[i]);

    outl(ans);

    return 0;
}

Measured memory_bytes: 3960
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long,long>>;

int main() {
    int N;
    cin >> N;
    vecl A(N+1);
    vecl B(N);
    REP(i,N+1) cin >> A.at(i);
    REP(i,N) cin >> B.at(i);
    ll ans = 0;
    for(int i = 0; i < N; i++) {
        ans += min(A.at(i),B.at(i));
        B.at(i) -= min(A.at(i),B.at(i));  
        A.at(i) -= min(A.at(i),B.at(i));
        ans += min(A.at(i+1),B.at(i));
        A.at(i+1) -= min(A.at(i+1),B.at(i)); 
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//    M
//  --^^^
//N --^^^
//  ^^---

int main(){
  int N; cin >> N;
  int M,K; cin >> M >> K;
  bool flag = false;
  REP(i,N+1){
    REP(j,M+1){
      if( (N-i)*j + i*(M-j) == K){
        flag = true;
        break;
      }
    }
  }
  cout << (flag? "Yes\n":"No\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  string s ;
  cin >> s ;
  
  int num1, num2 ;
  
  num1 = (s.at(0)-'0')*10+(s.at(1)-'0') ;
  num2 = (s.at(2)-'0')*10+(s.at(3)-'0') ;
  
  //cout <<num1<<" "<<num2<<endl ;
  
  if(num1==0 && num2==0){
    cout <<"NA"<<endl ;
  }
  else if(num1==0 && num2>12){
    cout <<"NA"<<endl ;
  }
  else if(num1>12 && num2==0){
    cout <<"NA"<<endl ;
  }
  else if(num1>12 && num2>12){
    cout <<"NA"<<endl ;
  }
  else if(num1<=12 && num2<=12 && num2!=0 && num1!=0){
    cout <<"AMBIGUOUS"<<endl ;
  }
  else if(num1<=12 && num2>12){
    cout <<"MMYY"<<endl ;
  }
  else if(num1<=12 && num2==0){
    cout <<"MMYY"<<endl ;
  }
  else{
    cout <<"YYMM"<<endl ;
  }

  return 0 ;
}






Measured memory_bytes: 256
import Control.Monad
import Data.List

main=do
    n<-readLn
    ss<-replicateM n readLn
    let s = sum ss
    print $ if s`mod`10 /= 0
        then s
        else case find (\n -> n`mod`10 /= 0) $ sort ss of
            (Just x) -> s-x
            Nothing -> 0

Measured memory_bytes: 1020
lis = []
for i in range(5):
  lis.append(int(input()))
k = int(input())
t = 0
lis_b = lis[1:]
lis_c = lis[2:]
lis_d = lis[3:]
lis_e = lis[4:]
for item in lis_b:
  if abs(item - lis[0]) > k:
    print(":(")
    exit()
for item in lis_c:
  if abs(item - lis[1]) > k:
    print(":(")
    exit()
for item in lis_d:
  if abs(item - lis[2]) > k:
    print(":(")
    exit()
for item in lis_e:
  if abs(item - lis[3]) > k:
    print(":(")
    exit()
  
print("Yay!")


Measured memory_bytes: 3064
# ABC068 C - Cat Snuke and a Voyage
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n,m = nm()
G = [[] for _ in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

# print(G)

for g in G:
    island_1toi = False
    island_iton = False
    for gg in g:
        if gg == 0:
            island_1toi = True
        if gg == n-1:
            island_iton = True

        if island_1toi == True and island_iton == True:
            print('POSSIBLE')
            exit()

print('IMPOSSIBLE')


Measured memory_bytes: 38324
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int S = sc.nextInt();
      int s = S % 60;
      int M = S / 60;
      int m = M % 60;
      int h = M / 60;
      System.out.println(h + ":" + m + ":" + s);
    }
    
  
    
}



Measured memory_bytes: 26256
import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict as dd
from math import log,ceil

def main():
    v=[0 for i in range(100001)]
    n=int(input())
    ar=list(map(int,input().split()))
    s=0
    for i in ar:
        s+=i
        v[i]+=1
    q=int(input())
    for i in range(q):
        a,b=map(int,input().split())
        s-=a*v[a]
        s+=b*v[a]
        v[b]+=v[a]
        v[a]=0
        print(s)


BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")


if __name__ == "__main__":
    main()



Measured memory_bytes: 96096
#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>;
vector<int>  ki[1100];
ll dp[1100];
ll nodes[1100];
ll nCm[1100][1100];
ll lose[1100];
const int mod = 1000000;
void dfs(int now){
    dp[now] = 1;

    for(auto next:ki[now]){
        
        dfs(next);
        nodes[now] += nodes[next] +1;//+1はnext自身(nodes[x]はxを含まない)
        dp[now] *= nCm[nodes[now]][nodes[next]+1];//(今まで見たnextのノード数+1)C(今見ているnextのノード数)
        dp[now] %= mod;
        dp[now] *= dp[next];
        dp[now] %= mod;
        
        

    }
}
int main()
{
    int n;cin >> n;
    rep(i,n-1){
        int a,b;cin >>  a >> b;
        a--;b--;
        ki[a].push_back(b);
        lose[b]++;
    }
    //nCmの計算
    nCm[0][0] = 1;
    for(int i = 1;i < 1005;i++){
        for(int j = 0;j < 1005;j++){
            if(j == 0)nCm[i][j] = 1;
            else (nCm[i][j] = nCm[i-1][j]+nCm[i-1][j-1])%=mod;
        }
    }

    int root;
    //優勝者(木の根）を探す
    rep(i,n)if(!lose[i]){
        root = i;
        break;
    }
    dfs(root);
    int ans = dp[root];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11856
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    Int N, D; cin >> N >> D;
    int ans = 0;
    while (N--) {
        Int X, Y; cin >> X >> Y;
        if (X*X + Y*Y <= D*D) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>

int main() {
  int k, x;
  std::cin >> k >> x;
  const int min_pos = -1000000;
  const int max_pos = 1000000;

  if (x - k < min_pos) {
  }

  for (int i = std::max(x - k + 1, min_pos), e = std::min(x + k, max_pos);
       i < e; ++i) {
    std::cout << i << " ";
  }
  std::cout << std::endl;
  return 0;
}

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

using namespace std;

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

    int N, a;
    cin >> N;
    vector<int> A;
    for (int i = 0; i < N; ++i)
    {
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(), A.end());
    int alice = 0;
    int bob = 0;
    
    if(N % 2 == 0) {
        for(int i = 0; i < N; i += 2){
            bob += A[i];
            alice += A[i+1];
        }
    } else {
         for(int i = 0; i < N; i += 2){
            alice += A[i];
            bob += A[i+1];
        }
    }

    cout << alice - bob << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);
	int n, m;
	cin >> n >> m;
	vector<bool> ac(n);
	vector<int> wa(n);
	int accnt = 0;
	int wacnt = 0;
	REP(i, m)
	{
		int p;
		string s;
		cin >> p >> s;
		p--;
		if (ac[p])continue;
		if (s == "AC")
		{
			ac[p] = true;
			wacnt += wa[p];
			accnt++;
		}
		else
		{
			wa[p]++;
		}
	}
	cout << accnt << " " << wacnt;
	return 0;
}

Measured memory_bytes: 640
<?php

while ($line = trim(fgets(STDIN))) {
	$hand = explode(',', $line);
	sort($hand);
	$group = array();
	foreach ($hand as $n) {
		$group[$n] = isset($group[$n]) ? $group[$n] + 1 : 1;
	}
	sort($group);
	$max = max($group);
	if (isFourCard($max)) {
		echo "four card\n";
		continue;
	}
	if (isFullHouse($group)) {
		echo "full house\n";
		continue;
	}
	if (isStraight($hand)) {
		echo "straight\n";
		continue;
	}
	if (isThreeCard($max)) {
		echo "three card\n";
		continue;
	}
	if (isTwoPair($group)) {
		echo "two pair\n";
		continue;
	}
	if (isOnePair($group)) {
		echo "one pair\n";
		continue;
	}
	echo "null\n";
}

function isFourCard($max) {
	return $max == 4;
}

function isThreeCard($max) {
	return $max == 3;
}

function isFullHouse($group) {
	$c = count($group);
	return ($group[$c - 1] == 3) && ($group[$c - 2] == 2);
}

function isTwoPair($group) {
	$c = count($group);
	return ($group[$c - 1] == 2) && ($group[$c - 2] == 2);
}

function isOnePair($group) {
	$c = count($group);
	return ($group[$c - 1] == 2) && ($group[$c - 2] < 2);
}

function isStraight($hand) {
	$min = $hand[0];
	if ($min == 1 && !in_array(2, $hand)) {
		for ($i = 10; $i <= 13; $i++) {
			if (!in_array($i, $hand)) {
				return false;
			}
		}
		return true;
	}
	for ($i = $min + 1; $i < $min + 5; $i++) {
		if (!in_array($i, $hand)) {
			return false;
		}
	}
	return true;
}

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

int main(){
  int a[100];
  int ans[100];
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=n-1;i>=0;i--){
    int add=-1;
    for(int j=0;j<=i;j++){
      if(a[j]==j+1){add=j;}}
      if(add==-1){cout<<-1<<endl;return 0;}
      else{
        ans[i]=add+1;
        for(int k=add;k<=i;k++){
          a[k]=a[k+1];
        }
      }

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


Measured memory_bytes: 256
n,m,l = map(int, input().split())
A = [[0 for j in range(m)] for i in range(n)]
B = [[0 for j in range(l)] for i in range(m)]
C = [[0 for j in range(l)] for i in range(n)]
for i in range(n):
  A[i] = list(map(int, input().split()))
for i in range(m):
  B[i] = list(map(int, input().split()))
for i in range(n):
  for j in range(l):
    for k in range(m):
      C[i][j] += A[i][k] * B[k][j]

for i in range(n):
  for j in range(l-1):
    print(C[i][j],end=' ')
  print(C[i][l-1],sep='')


Measured memory_bytes: 7084
#include <stdio.h>

void swap(int *a, int *b) {
    int temp = *a;
    *a = *b;
    *b = temp;
}

// flagを用いたバブルソート
int bubbleSort(int A[],int N) {
    int i,j;
    int sw = 0;
    unsigned short flag = 1;
    for(i=0;flag;i++) {
        flag = 0;
        for(j=N-1;j>=i+1;j--) {
            if(A[j]<A[j-1]) {
                swap(&A[j],&A[j-1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main(void) {
    int i, A[100], N, sw;
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);

    sw = bubbleSort(A,N);

    for(i=0;i<N;i++) {
        if (i) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n%d\n",sw);

    return 0;
}


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

int main (void){
  
  int A, B; cin >> A >> B;
  
  if((A * B) % 2 == 0){
    
    cout << "No" << endl;
    
  }else{
    
    cout << "Yes" << endl;
    
  }
  
  return 0;
  
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string N;
    cin >> N;
    ll ans = 0;
    iter(c, N) ans += c == '2';
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3568
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<cstdlib>
#include<map>
#include<vector>
#include<ctime>
#include<stack>
#define mp make_pair
#define pa pair<int,int>
#define INF 0x3f3f3f3f
#define inf 0x3f
#define fi first
#define se second
#define pb push_back

using namespace std;

const int MAXN=100010;
struct edge
{
	int next,to,val;
};
edge e[MAXN*10];
int head[MAXN],cnt;
void addedge(int u,int v,int w)
{
	e[++cnt].next=head[u];
	e[cnt].to=v;
	e[cnt].val=w;
	head[u]=cnt;
}
int dis[MAXN],n;
bool visit[MAXN];
priority_queue <pa,vector<pa>,greater<pa> > q;
void Dijkstra()
{
	for (int i=0;i<=n;i++)
	{
		dis[i]=INF;
	}
	dis[1]=0;
	q.push(mp(0,1));
	while (!q.empty())
	{
		int x=q.top().se;
		q.pop();
		if (visit[x])
		{
			continue;
		}
		visit[x]=1;
		for (int i=head[x];i;i=e[i].next)
		{
			int v=e[i].to;
			if (dis[v]>dis[x]+e[i].val)
			{
				dis[v]=dis[x]+e[i].val;
				q.push(mp(dis[v],v));
			}
		}
	}
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<n;i++)
	{
		addedge(i,(i+1)%n,1);
		addedge(i,(i*10)%n,0);
	}
	Dijkstra();
	cout<<dis[0]+1;
	return 0;
}


Measured memory_bytes: 4988
import java.util.*

fun main(args: Array<String>) {
    val s = readLine()!!
    val t = TreeSet(s.toList())

    if (t.size == 2) {
        println("Second")
        return
    }

    if (s.first() == s.last()) {
        if (s.length % 2 != 0) {
            println("Second")
        } else {
            println("First")
        }
    } else {
        if (s.length % 2 == 0) {
            println("Second")
        } else {
            println("First")
        }
    }
}


Measured memory_bytes: 34656
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;


int main() {
  int a, b;
  cin >> a>> b;
  int diff = b-a;
  int ans=0;
  rep(i,diff){
    ans += i;
  }
  cout<< ans-a << endl;
  return 0;
}

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

using namespace std;

int main()
{
  int a , b;
  cin >> a >> b;
  if(a == 0 && b == 100) cout << 101 << endl;
  else if(a == 1 && b == 100) cout << 10100 << endl;
  else if(a == 2 && b == 100) cout << 1010000 << endl;
  else {
      while(a--) b *= 100;
      cout << b << endl;
  }
}


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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

ll n, m;
set<ll> candidates;

void init()
{
    ll i = 1;
    while (i * i <= m)
    {
        if (m % i == 0)
        {
            candidates.emplace(i);
            candidates.emplace(m / i);
        }
        ++i;
    }
}

int main()
{
    cin >> n >> m;
    init();
    ll ans = 0;
    for (ll candidate : candidates)
    {
        if (candidate * n <= m)
        {
            ans = max(ans, candidate);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384