akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	string s; cin >> s;
	string k1 = "dream";
	string k2 = "dreamer";
	string k3 = "erase";
	string k4 = "eraser";
	bool f = true;
	int len = s.length();
	while (len){
		if(len < 5) {
			f = false; break;
		}
		if (len >= 5) {
			string u = s.substr(len - 5, 5);
			if (k1 == u || k3 == u) {
				len -= 5; continue;
			}
		}
		if (len >= 6) {
			string u = s.substr(len - 6, 6);
			if (k4==u) {
				len -= 6; continue;
			}
		}
		if (len >= 7) {
			string u = s.substr(len - 7, 7);
			if (k2 == u) {
				len -= 7; continue;
			}
		}
		f = false; break;
	}
	if (f)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
 
class Dice {
public:
    int face[6];
    Dice() {}
    void dir(char ch) {
        if (ch == 'E') rot(0, 2, 5, 3);
        if (ch == 'W') rot(0, 3, 5, 2);
        if (ch == 'S') rot(0, 1, 5, 4);
        if (ch == 'N') rot(0, 4, 5, 1);
    }
 
    void rot(int a, int b, int c, int d) {
        int t[4] = {};
 
        t[0] = face[a];
        t[1] = face[b];
        t[2] = face[c];
        t[3] = face[d];
        face[a] = t[3];
        face[b] = t[0];
        face[c] = t[1];
        face[d] = t[2];
 
    }
};
 
int main() {
    Dice dice1;
    string D;
 
    for (int i = 0; i < 6; i++) {
        cin >> dice1.face[i];
    }
    cin >> D;
    for (int j = 0; j < D.size(); j++) {
        dice1.dir(D[j]);
    }
    cout << dice1.face[0] << endl;
    return 0;
}

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

using namespace std;

int main(int argc, char const *argv[]) {
	int n;
	unordered_set<string> s;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		char a[10];
		scanf("%s", a);
		s.insert(a);
	}

	printf("%d", s.size());
	return 0;
}


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

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

    vector<int> a(n), b(n);
    vector<pair<int, int>> menu(n);
    for(int i=0; i<n; i++){
        cin >> menu[i].first >> menu[i].second;
    }
    sort(menu.begin(), menu.end());
    for(int i=0; i<n; i++){
        a[i] = menu[i].first;
        b[i] = menu[i].second;
    }

    vector<vector<int>> dp(n+1, vector<int>(t)), prev(n+1, vector<int>(t));
    for(int i=0; i<n; i++){
        for(int j=0; j<t; j++){
            if(j - a[i] >= 0){
                if(dp[i+1][j] < dp[i][j-a[i]] + b[i]){
                    dp[i+1][j] = dp[i][j-a[i]] + b[i];
                    prev[i+1][j] = j-a[i];
                }
            }
            
            if(dp[i+1][j] < dp[i][j]){
                dp[i+1][j] = dp[i][j];
                prev[i+1][j] = j;
            }
        }
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        ans = max(ans, dp[i][t-1] + b[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 70912
N = int(input())
if N%2==1:
  print(0)
  
elif N<=4:
  print(0)

else:
  a = 0
  while N>5**a:
    a+=1
    
  a-=1
  ans = 0
  for i in range(1,a+1):
    ans += N//(5**i)//2
    
  print(ans)

Measured memory_bytes: 3060
using System;

public class P
{
    public int L { get; set; }
    public int r { get; set; }
}

public class hello
{
    public static P[] ps;
    public static int[] ans1, ans2, ans3;
    public static bool[] v2, v3;
    public static int pt;

    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        ps = new P[n];
        for (int i = 0; i < n; i++) ps[i] = new P { };
        var child = new bool[n];
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var id = int.Parse(line[0]);
            ps[id].L = int.Parse(line[1]);
            ps[id].r = int.Parse(line[2]);
            if (ps[id].L != -1) child[ps[id].L] = true;
            if (ps[id].r != -1) child[ps[id].r] = true;
        }
        ans1 = new int[n];
        ans2 = new int[n];
        ans3 = new int[n];
        v2 = new bool[n];
        v3 = new bool[n];
        var root = -1;
        for (int i = 0; i < n; i++) if (!child[i]) { root = i; break; }
        pt = 0;
        preOrder(root);
        pt = 0;
        inOrder(root);
        pt = 0;
        postOrder(root);
        Console.WriteLine("Preorder");
        Console.WriteLine(" " + string.Join(" ", ans1));
        Console.WriteLine("Inorder");
        Console.WriteLine(" " + string.Join(" ", ans2));
        Console.WriteLine("Postorder");
        Console.WriteLine(" " + string.Join(" ", ans3));
    }
    static void inOrder(int a)
    {
        v2[a] = true;
        if (ps[a].L != -1 && !v2[ps[a].L]) inOrder(ps[a].L);
        if (ps[a].L == -1) ans2[pt++] = a;
        else if (ps[a].L != -1 && v2[ps[a].L]) ans2[pt++] = a;
        if (ps[a].r != -1 && !v2[ps[a].r]) inOrder(ps[a].r);
    }
    static void postOrder(int a)
    {
        v3[a] = true;
        if (ps[a].L != -1 && !v3[ps[a].L]) postOrder(ps[a].L);
        if (ps[a].r != -1 && !v3[ps[a].r]) postOrder(ps[a].r);
        if (ps[a].L == -1 && ps[a].r == -1) { ans3[pt++] = a; return; }
        if (ps[a].L == -1 && ps[a].r != -1 && v3[ps[a].r]) { ans3[pt++] = a; return; }
        if (ps[a].L != -1 && v3[ps[a].L] && ps[a].r == -1) { ans3[pt++] = a; return; }
        if (ps[a].L != -1 && v3[ps[a].L] && ps[a].r != -1 && v3[ps[a].r]) { ans3[pt++] = a; return; }
    }
    static void preOrder(int a)
    {
        ans1[pt++] = a;
        if (ps[a].L != -1) preOrder(ps[a].L);
        if (ps[a].r != -1) preOrder(ps[a].r);
    }
}



Measured memory_bytes: 20004
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using Graph = vector<vector<int>>;


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;
}
ll modinv(ll a, ll m){
    ll b = m, u = 1, v = 0;
    while(b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if(u < 0) u += m;
    //cout << u << endl;
    return u;
}

ll paty_counter(ll level, ll x){
    ll size = pow(2, level+2) - 3;
    ll pmi = pow(2, level) - 1;
    if(x == 0){
        return 0;
    }else if(level == 0){    
        return 1;
    }else{
        if(x <= (size - 1)/2){
            return paty_counter(level-1, x-1);
        }else{
            return pmi + 1 + paty_counter(level-1, x - pow(2, level+1) + 3 - 2);
        }
    }

}
 
using namespace std;
using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
static ll x;
void dfs(const Graph &G, int v) {
    seen[v] = true;
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v); // 再帰的に探索
        x ++;
    }
}

int main() {
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans = 0;
    ans = max(a*c, max(a*d, max(b*c, b*d)));
    if((a <= 0 & b >= 0) || (c <= 0 & d >= 0)){
        ans = max(ans, (ll)0);
    }
    cout << fixed << ans << endl;
}



Measured memory_bytes: 3696
#include<iostream>

int gcd( int a, int b )
{
	if( b == 0 )
		return a;

	return gcd( b, a % b );
}

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

int main(){
	int x,y;
	while( std::cin>>x>>y )
		std::cout<<gcd(x,y)<<' '<<lcm(x,y)<<std::endl;

	return 0;
}

Measured memory_bytes: 1160
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}


int main(){
    map<string, int> m;
    int n = nxt();
    REP(i, n){
        string s;
        cin >> s;
        m[s]++;
    }
    vector<string> v;
    vector<pair<int, string>> temp;
    for(auto x : m) temp.push_back({x.second, x.first});
    sort(all(temp));
    reverse(all(temp));
    REP(i, temp.size()){
        if(temp[i].first == temp[0].first) v.push_back(temp[i].second);
        else break;
    }
    sort(all(v));
    for(auto x : v) printf("%s\n", x.c_str());
    return 0;
}



Measured memory_bytes: 32876
//ITP1_2-D Circle in a Rectangle
//??????????????¢???????????????????????????
#include <iostream>

int main()
{
	int W,H,x,y,r;		//????????????,??????,??????x???y??§?¨?,??????
	std::cin >> W >> H >> x >> y >> r;
	
	int a=x-r;			//???????????????
	int b=W-(x+r);		//???????????????
	int c=H-(y+r);		//???????????????
	int d=y-r;			//???????????????
	
	if(a<0||b<0||c<0||d<0)
		std::cout << "No\n";
	else std::cout <<"Yes\n";
	
	return 0;
}

Measured memory_bytes: 1124
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)n; i++)
const int MOD = 1000000007;
// long long a;
int main(){
  int a,b,h;
  cin >> a>>b >>h;
  cout << (a+ b)*h/2<< endl;
}


Measured memory_bytes: 256
import numpy as np
N,K=list(map(int,input().split()))
p=list(map(int,input().split()))
p=list(map(lambda x:(x+1)/2, p))
p_cs=[0]
p_cs.extend(np.cumsum(p))
max_exp=0
for i in range(N-K+1):
  exp=p_cs[i+K]-p_cs[i]
  if exp>max_exp:
    max_exp=exp
print(max_exp)

Measured memory_bytes: 33684
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i): is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    n, a, b = MII()
    print(min(n*a, b))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,v.size())
#define all(v) (v).begin(),(v).end()
#define bit(n) (1ll<<(n))
#define clamp(n,mi,ma) max(min(n,ma),mi)
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b) cout<<((n)?a:b)<<endl
#define YES(n) cho(n,"YES","NO")
#define Yes(n) cho(n,"Yes","No")
#define Poss(n) cho(n,"Possible","Impossible")
template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>ostream&operator<(ostream&o,const T&t){return o<<t;}
template<class T>istream&operator>(istream&i,T&t){return i>>t;}
#ifndef LOCAL
struct ostdmy{
template<class T>ostdmy&operator<<(const T&t){return*this;}
template<class T>ostdmy&operator<(const T&t){return*this;}};ostdmy cer_;
#define cerr cer_
#endif
int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n;
    cin>n;
    vvi a(2,vi(n));
    cin>a;
    vvi cs(2,vi(n+1));
    REP(i,n){
        cs[0][i+1]=cs[0][i]+a[0][i];
    }
    REPR(i,n){
        cs[1][i]=cs[1][i+1]+a[1][i];
    }
    cerr<cs<endl;
    int ma=0;
    REP(i,1,n+1){
        chmax(ma,cs[0][i]+cs[1][i-1]);
    }
    cout<ma<endl;


    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int i, j, n, u, k, v;
  int M[100][100];

  scanf("%d", &n);

  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  M[i][j] = 0;
	}
    }

  for(i=0;i<n;i++)
    {
      scanf("%d%d", &u, &k); u--;
      for(j=0;j<k;j++)
	{
	  scanf("%d", &v); v--;
	  M[u][v] = 1;
	}
    }

  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  if(j)printf(" ");
	  printf("%d", M[i][j]);
	}
      printf("\n");
    }
  return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    ll n;   cin >> n;
    vector<ll> isPrime(55'556, true);
    isPrime[0] = isPrime[1] = false;
    for(int i=2; i*i<=55'555; i++){
        if(!isPrime[i]) continue;
        for(int j=2*i; j<=55'555; j+=i){
            isPrime[j] = false;
        }
    }
    vector<ll> res;
    rep(i, 55'556){
        if(isPrime[i] && i%10==3) res.push_back(i);
    }

    
    rep(i, n){
        cout << res[i];
        if(i<n-1)   cout << ' ';
        else cout << endl;
    }
}


Measured memory_bytes: 3756
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define CL(arr, val) memset(arr, val, sizeof(arr))
#define ten(n) ((ll)(1e##n))
#define pb push_back

template <typename T> void chmax(T& a, const T& b) { a = max(a, b); }
template <typename T> void chmin(T& a, const T& b) { a = min(a, b); }

template <typename T> void uniq(T& c) { sort(c.begin(), c.end()); c.erase(unique(c.begin(), c.end()), c.end()); }

typedef pair<ll, int> pint;
typedef pair<pint, int> P;

int main()
{
    int n, m, l, rank;
    while (cin >> n >> m >> l >> rank, n)
    {
        vector<pint> g[55]; // (cost, to)
        while (m--)
        {
            int u, v, c;
            cin >> u >> v >> c;
            --u, --v;

            g[u].pb(pint(c, v));
            g[v].pb(pint(c, u));
        } 

        int start, goal;
        cin >> start >> goal;
        --start, --goal;

        int ball[55] = {};
        rep(i, l)
        {
            int b;
            cin >> b;
            --b;
            ball[b] |= 1 << i;
        }

        vector<ll> dp[55][1 << 7];

        priority_queue<P, vector<P>, greater<P> > q;
// dp[start][ball[start]].pb(0);
        q.push(P(pint(0, ball[start]), start));
        while (!q.empty())
        {
            int pos = q.top().second;
            ll cost = q.top().first.first;
            int bal = q.top().first.second;
            q.pop();

            if (dp[pos][bal].size() == rank)
                continue;

            dp[pos][bal].pb(cost);

            foreach (it, g[pos])
            {
                ll ncost = cost + it->first;
                int npos = it->second;
                int nbal = bal | ball[npos];

                if (dp[npos][nbal].size() < rank)
                {
                    q.push(P(pint(ncost, nbal), npos));
                }
            }
        }

        const int all_ball = (1 << l) - 1;
        if (dp[goal][all_ball].size() == rank)
            cout << dp[goal][all_ball][rank - 1] << endl;
        else
            cout << "NA" << endl;
    }
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n, m;
    cin >> n >> m;
    int stu[n][2], che[m][2];

    rep(i, n) cin >> stu[i][0] >> stu[i][1];
    rep(i, m) cin >> che[i][0] >> che[i][1];

    rep(i, n)
    {
        int mind = 1e9, p;
        rep(j, m)
        {
            int dis = abs(stu[i][0] - che[j][0]) + abs(stu[i][1] - che[j][1]);
            if (dis < mind)
            {
                mind = dis;
                p = j + 1;
            }
        }
        cout << p << endl;
    }
    return 0;
}

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

int main () {
  string a ;
  cin >> a ;
  int pre[4] = {} ;
  for(int i = 0 ; i < a.length() ; i++ ) {
    if(a[i]=='N') pre[0] = 1 ;
    if(a[i]=='S') pre[1] = 1 ;
    if(a[i]=='W') pre[2] = 1 ;
    if(a[i]=='E') pre[3] = 1 ;
  }
  bool can = true ;
  if((pre[0]==0&&pre[1]==1)||(pre[0]==1&&pre[1]==0)) can = false ;
  if((pre[2]==0&&pre[3]==1)||(pre[2]==1&&pre[3]==0)) can = false ;
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl ;
  //for(int i = 0 ; i <4 ; i++ ) cout << pre[i] ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
char s[111];
int main(){
    cin>>n;
    cin>>s + 1;
    int ans = 0;
    for(int i = 1;i <= n; i++){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')ans++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef struct _data {
	int x;
	int y;
} data;

int  main()
{
	int a,b;
	cin >> a >> b;
	char A[b+1];
	char B[a+1];
	int i = 0;

	while(i < b)
		A[i++] = a + 48;
	A[i] = '\0';
	i = 0;
	while(i < a)
		B[i++] = b + 48;
	B[i] = '\0';
	if (strcmp(A,B) <= 0)
		cout << A << endl;
	else
		cout << B << endl;
	return (0);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int A,B,C = 0;

int main(void) {
    cin >> A >> B >> C;
    
    if(A == B && B == C)
    {
        cout << "No";
        return 0;
    }
    
    if(A == B)
    {
        cout << "Yes";
    }
    else if(A == C)
    {
        cout << "Yes";
    }
    else if(B == C)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
  ll N,A,B;
  cin>>N>>A>>B;
  ll cnt=N/(A+B);
  ll ans=cnt*A;
  ll a=N-cnt*(A+B);
  ans+=min(A,a);
  cout<<ans<<endl;
}


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

int K, S;
int Z;
int ans = 0;

int main(int argc, char *argv[]){
    cin >> K >> S;
    rep(X, K+1){
        if(X > K) continue;
        rep(Y, K+1){
            if(Y > K) continue;
            Z = S - X - Y;
            if(Z > K) continue;
            if(Z < 0) continue;

            if((X + Y + Z) == S) ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

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

int func(int num)
{
    if (num % 2) {
        return num * 3 + 1;
    }else{
        return num / 2;
    }
}

int assess(int num, vector<int>& vec){
    for (int i = 0; i < vec.size(); ++i){
        if (num == vec[i]) return true;
    }
    return false;
}

int main()
{
    int input_number;
    cin >> input_number;
    vector<int> vec;

    int now_number = input_number;
    bool valuation;

    vec.push_back(now_number);

    while(true){
    /// roop start ///
        //func関数で数列を計算
        now_number = func(now_number);

        //assess関数でベクトルと現在の値を評価
        valuation = assess(now_number,vec);
        if (valuation){
            cout << vec.size() + 1 << endl;
            break;
        }
        // now_number を追加して再度ループ
        vec.push_back(now_number);
    /// roop end ///
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        long h = sc.NextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = sc.NextInt();
            b[i] = sc.NextInt();
        }

        Array.Sort(b, (l, r) => r.CompareTo(l));

        int aMax = a.Max();
        // a最強 + bの上位
        long ans = (h + aMax - 1) / aMax;
        long t = 0;
        for (int i = 0; i < n; i++)
        {
            t += b[i];
            if (t >= h) ans = Math.Min(ans, i + 1);
            else ans = Math.Min(ans, i + 1 + (h - t + aMax - 1) / aMax);
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

const int maxn = 200005;
int N, K, p[maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> p[i];
        ++p[i];
    }
    int cur = 0;
    for (int i = 0; i < K; i++) {
        cur += p[i];
    }
    int ans = cur;
    for (int i = 0; i+K < N; i++) {
        cur -= p[i];
        cur += p[i+K];
        ans = max(ans,cur);
    }
    cout << fixed << setprecision(10) << (double)(ans)/2 << endl;
}



Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    static class Poker {
        String color;
        Integer num;

        public Poker(String color, Integer num) {
            this.color = color;
            this.num = num;
        }

        @Override
        public String toString() {
            return this.color + this.num + "";
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Poker[] po1 = new Poker[n];
        Poker[] po2 = new Poker[n];
        for (int i = 0; i < po1.length; i++) {
            String next = sc.next();
            String a = String.valueOf(next.charAt(0));
            Integer b = Integer.parseInt(String.valueOf(next.charAt(1)));
            Poker poker = new Poker(a, b);
            po1[i] = poker;
            po2[i] = poker;
        }
        bubble(po1);
        SelectionSort(po2);
        if (isStable(po1, po2)) System.out.print("Stable\n");
        else System.out.print("Not stable\n");
    }

    private static boolean isStable(Poker[] po1, Poker[] po2) {
        for (int i = 0; i < po1.length; i++) {
            if (!po1[i].color.equals(po2[i].color)) return false;
        }
        return true;
    }

    private static Poker[] SelectionSort(Poker[] po) {
        for (int i = 0; i < po.length; i++) {
            int min = i;
            for (int j = i; j < po.length; j++) {
                if (po[j].num < po[min].num) {
                    min = j;
                }
            }
            if (i != min) po = swap(po, i, min);
        }
        print(po);
        return po;
    }

    private static Poker[] bubble(Poker[] po) {
        for (int i = 0; i < po.length; i++) {
            for (int j = po.length - 1; j > i; j--) {
                if (po[j].num < po[j - 1].num) {
                    po = swap(po, j, j - 1);
                }
            }
        }
        print(po);
        System.out.print("Stable\n");
        return po;
    }


    private static void print(Poker[] po) {
        for (int i = 0; i < po.length - 1; i++) {
            System.out.print(po[i] + " ");
        }
        System.out.print(po[po.length - 1] + "\n");
    }

    private static Poker[] swap(Poker[] po, int j, int i) {
        Poker poker = po[j];
        po[j] = po[i];
        po[i] = poker;
        return po;
    }
}


Measured memory_bytes: 26276
#include <algorithm>
#include <cstdio>
using namespace std;
int n, k;
long long int a[200005], s[200005], ps = 0;
const long long MOD = 1e9 + 7;
int main() {
  scanf("%d %d", &n, &k);
  long long res = 1;
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
  }
  sort(a, a + n);

  if (k % 2) {
    res = a[n - 1];
    int w = res > 0 ? 1 : -1;
    int l = 0, r = n - 2, cnt = 1;
    while (cnt < k && l < r) {
      if (w * a[l] * a[l + 1] > w * a[r] * a[r - 1]) {
        s[ps++] = a[l++];
        s[ps++] = a[l++];
        cnt += 2;
      } else {
        s[ps++] = a[r--];
        s[ps++] = a[r--];
        cnt += 2;
      }
    }
  } else {
    res = 1;
    int l = 0, r = n - 1, cnt = 0;
    while (cnt < k && l < r) {
      if (a[l] * a[l + 1] > a[r] * a[r - 1]) {
        s[ps++] = a[l++];
        s[ps++] = a[l++];
        cnt += 2;
      } else {
        s[ps++] = a[r--];
        s[ps++] = a[r--];
        cnt += 2;
      }
    }
  }
  for (int i = 0; i < ps; ++i) {
    res = (1l * (s[i] % MOD) * (res % MOD) + MOD) % MOD;
  }
  res = (res % MOD + MOD) % MOD;
  printf("%lld\n", res);
  return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int int64_t
#define pb push_back
#define pf push_front
#define pii pair<int, int>
#define F first
#define S second
#define T  third
#define vecsort(x) sort(x.begin(), x.end())
#define vecrsort(x) sort(x.rbegin(), x.rend())
#define massort(x, n) sort(x, x + n)
using namespace std;
int max(int32_t a, int b){
   return max((int)a, b);
}
int max(vector<int> x){
    return *max_element(x.begin(), x.end());
}
set<int> c[26];

int32_t main(){
    string s, t;
    cin >> s >> t;
    for(int i = 0; i < s.size(); i ++){
        c[s[i]-'a'].insert(i);
    }
    int ans = 0;
    int cur = -1;
    for(int i = 0; i < t.size(); i ++){
        if(c[t[i]-'a'].upper_bound(cur) == c[t[i]-'a'].end()){
            ans += s.size();
            cur = -1;
            if(c[t[i]-'a'].upper_bound(cur) == c[t[i]-'a'].end()){
                cout << -1;
                return 0;
            }else{
                cur = *c[t[i]-'a'].upper_bound(cur);
            }
        }else{
            cur = *c[t[i]-'a'].upper_bound(cur);
        }
    }
    if(cur != -1)
        ans += cur + 1;
    cout << ans;
}




Measured memory_bytes: 5248
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
using namespace std;
int main(){
    string s;
    cin>>s;
    int l=s.length();
    for(int i=l-1;i>=0;i--){
        if((s[i]=='m')&&(s[i-1]=='a')&&(s[i-2]=='e')&&(s[i-3]=='r')&&(s[i-4]=='d')){
            i-=4;
        }else if((s[i]=='r')&&(s[i-1]=='e')&&(s[i-2]=='m')&&(s[i-3]=='a')&&(s[i-4]=='e')&&(s[i-5]=='r')&&(s[i-6]=='d')){
            i-=6;
        }else if((s[i]=='e')&&(s[i-1]=='s')&&(s[i-2]=='a')&&(s[i-3]=='r')&&(s[i-4]=='e')){
            i-=4;
        }else if((s[i]=='r')&&(s[i-1]=='e')&&(s[i-2]=='s')&&(s[i-3]=='a')&&(s[i-4]=='r')&&(s[i-5]=='e')){
            i-=5;
        }else{
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}   





Measured memory_bytes: 512
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long dp[][][][] = new long[N + 1][4][4][4];
		
		dp[0][3][3][3] = 1;
		for(int i = 0; i < N; i++) {
			for(int a = 0; a < 4; a++) {
				for(int b = 0; b < 4; b++) {
					for(int c = 0; c < 4; c++) {
						if(dp[i][a][b][c] == 0) continue;
						for(int d = 0; d < 4; d++) {
							if(b == 0 && c == 2 && d == 1) continue;
							if(b == 0 && c == 1 && d == 2) continue;
							if(a == 0 && c == 2 && d == 1) continue;
							if(b == 2 && c == 0 && d == 1) continue;
							if(a == 0 && b == 2 && d == 1) continue;
							dp[i + 1][b][c][d] = (dp[i + 1][b][c][d] + dp[i][a][b][c]) % 1000000007;
						}
					}
				}
			}
		}
		
		long ans = 0;
		for(int a = 0; a < 4; a++) {
			for(int b = 0; b < 4; b++) {
				for(int c = 0; c < 4; c++) {
					ans = (ans + dp[N][a][b][c]) % 1000000007;
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22740
#include <stdio.h>
#include <stdlib.h>
int main(void){
    // Your code here!
    int x, y,z=0, kaunnto = 0;
    scanf("%d%d", &x, &y);
   int turu = x, kame=0;
   for(int i=0;i<=x;i++){
       z = turu*2 + kame*4;
       if(z==y){
           printf("Yes");
           kaunnto = 1;
       }
       turu = turu-1;
       kame = kame+1;
   }
   if(kaunnto==0){
       printf("No");
   }
    return 0;
    
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
using LL = long long;
using P = pair<int,int>;
const int Max_N=1010;

int A[Max_N][Max_N];


int main(){
	int N;
	cin >> N;
	rep(i,N){
		rep(j,N-1){
			int a;
			cin >> a;
			a--;
			A[i][j]=a;
		}
	}
	vector<int> op(N);
	vector<bool> pushed(N);
	int ans=0, sum=N;
	queue<int> q1, q2;	
	rep(a,N){
		int n=A[a][0], m=op[n];
		if(n<a) continue;
		if(A[n][m]==a) q1.push(a);
	}
	while(sum){
		ans++;
		if(q1.empty()){
			cout << -1 << endl;
			return 0;
		}
		while(!q1.empty()){
			int a=q1.front(); q1.pop();
			int n=A[a][op[a]], m=op[n];
			q2.push(a), q2.push(n);
			op[a]++; op[n]++;
			if(op[a]==N-1) op[a]=-1, sum--;
			if(op[n]==N-1) op[n]=-1, sum--;
		}
		while(!q2.empty()){
			int a=q2.front(); q2.pop();
			if(op[a]==-1) continue;
			int n=A[a][op[a]], m=op[n];
			if(pushed[n]) continue;
			if(A[n][m]==a) q1.push(a), pushed[a]=true;
		}
		rep(i,N) pushed[i]=false;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4224
#include<iostream>
#include<vector>
using namespace std;
int main(){
  long long int a,b,c,k,ans=0;
  cin>>a>>b>>c>>k;
  if(a<=k){
    k=k-a;
    ans+=a;
  }
  else{
    cout<<k<<endl;
    return 0;
  }
  if(b<=k){
    k=k-b;
  }
  else{
    cout<<ans<<endl;
    return 0;
  }
  if(c<=k){
    k=k-c;
    ans-=c;
  }
  else{
    cout<<ans-k<<endl;
    return 0;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3624
N = int(input())
V = str(input())
C = str(input())
V = V.split()
C = C.split()
V_list = []
C_list = []
diff_list = []
for i in range(N):
    V_list.append(int(V[i]))
    C_list.append(int(C[i]))
for i in range(N):
    diff_list.append(V_list[i] - C_list[i])

diff_list.sort()
diff_list.reverse()
result = 0
for i in range(N):
    if diff_list[i] >= 0:
        result = result + diff_list[i]
    else:
        break

print(result)  

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll LINF = 1001002003004005006LL;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int n; cin >> n;
    ll k; cin >> k;
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
        --a[i];
    }

    vector<int> ord(n, -1);
    vector<int> s;
    int now = 0;
    while (ord[now] == -1) {
        s.push_back(now);
        ord[now] = s.size()-1;
        now = a[now];
    }
    
    int repLen = s.size() - ord[now];
    int toLen = ord[now];

    //cout << toLen << " " << repLen << endl;
    if (k < toLen) cout << (s[k]+1)  << endl;
    else {
        k -= toLen;
        k %= repLen;
        cout << (s[toLen + k]+1) << endl;
    }
    return 0;
}




















Measured memory_bytes: 5864
#include <bits/stdc++.h> 
#define rep(i,N)  for(int i=0; i<N; i++)
#define ol(a) cout << a << endl;
#define PI 3.14159265359
using namespace std;

int main(){
  int n; cin >> n;
  //vector<int> a(n);
  map<int,int> tisa;
  int64_t sum=0;
  int x;
  rep(i,n){
    
    cin >> x;
    //a[i] = x;
    tisa[x] += 1;
    sum += x;
  }

  int q; cin >> q;
  rep(i,q){
    int b,c; cin >> b >> c;
    tisa[c] += tisa[b];
    sum += (c-b)*tisa[b];
    tisa[b] = 0;
    ol(sum)
  }
  
}

Measured memory_bytes: 7952
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>
using namespace std;
int main(void){
    int left[4] = {0,0,0,0},right[4] = {0,0,0,0};
    double l_e,r_e;
    while(scanf("%lf %lf",&l_e,&r_e)!=EOF){
        if(l_e >= 1.1){
            left[0]++;
        }else if(l_e >= 0.6){
            left[1]++;
        }else if(l_e >= 0.2){
            left[2]++;
        }else{
            left[3]++;
        }
 
        if(r_e >= 1.1){
            right[0]++;
        }else if(r_e >= 0.6){
            right[1]++;
        }else if(r_e >= 0.2){
            right[2]++;
        }else{
            right[3]++;
        }
    }
    for(int i=0;i<4;i++){
        cout << left[i] << " " << right[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3180
#include <stdio.h>
#include <stdlib.h>

int main()
{
	char S[11];
	scanf("%s", S);
	
	int i, l, flag = 1, count = 0, mark[11] = {1};
	for (l = 0; S[l] != 0; l++);
	if (S[0] != 'A') flag = 0;
	for (i = 2; i <= l - 2; i++) {
		if (S[i] == 'C') {
			count++;
			mark[i] = 1;
		}
	}
	if (count != 1) flag = 0;
	for (i = 0; i < l; i++) {
		if (mark[i] == 0 && (S[i] < 'a' || S[i] > 'z')) flag = 0;
	}
	
	if (flag == 1) printf("AC\n");
	else printf("WA\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;


void solve()
{
	int n;
	cin>>n;
	int ans=ceil((double)n/2.0);
	cout<<ans<<endl;
	
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll N = S.size();
    map<char,ll> mp;
    rep(i,0,N) mp[S[i]]++;
    ll v1 = max(mp['a'], max(mp['b'], mp['c']));
    ll v2 = min(mp['a'], min(mp['b'], mp['c']));
    if(v1 - v2 <= 1){
        print("YES");
    }else{
        print("NO");
    }
}


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

using namespace std;

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

    unsigned int cnt = 0;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        if (a % 2 == 0) cnt++;
    }

    auto ans = (int) pow(3, N) - (1u << cnt);
    cout << ans << endl;
    return 0;
}

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

const long long N=200000;
long long a[N],b[N];


int main(){
	
ios_base::sync_with_stdio(false);

long long a,b;

cin>>a>>b;

cout<<max((long long)0,a-2*b)<<endl;

return 0;}

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

static const int MAX = 10000;
static const int INFTY = (1 << 20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;

//重み付き有向グラフの隣接リスト表現
vector<pair<int, int>> adj[MAX];


void dijkstra() {
    priority_queue<pair<int, int>> PQ;

    int color[MAX], d[MAX];
    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
        color[i] = WHITE;
    }

    // 0 start
    d[0] = 0;
    PQ.push(make_pair(0, 0));
    color[0] = GRAY;

    while (!PQ.empty()) {
        // choose u
        pair<int, int> f = PQ.top(); // cost, node
        PQ.pop();

        int u = f.second;
        color[u] = BLACK;
        // 最小値を取り出し、それが最短でなければ無視
        if (d[u] < f.first * (-1)) {
            continue;
        }

        for (int j = 0; j < adj[u].size(); j++) {
            int v = adj[u][j].first;
            if (color[v] == BLACK)
                continue;
            
            if (d[v] > d[u] + adj[u][j].second) {
                d[v] = d[u] + adj[u][j].second;

                PQ.push(make_pair(d[v] * (-1), v));
                color[v] = GRAY;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
    }
}

int main() {
    int k, u, v, c;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v >> c;
            adj[u].push_back(make_pair(v, c));  // node_id, cost
        }
    }

    dijkstra();
}


Measured memory_bytes: 8012
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

#include <iostream>
#include <queue>
#include <vector>
using namespace std;

typedef long long i64;
struct Graph {
  struct edge {
    int to;
    i64 cap;
    i64 rev;
    edge(int t,i64 c,i64 r){
      to = t;
      cap = c;
      rev = r;
    }
  };

  int n;
  vector< vector< edge > > edges;

  Graph(int N) {
    n = N;
    edges.resize(n, vector<edge>());
  }

  int size() const { return n; }

  vector<edge> &operator[](int v) { return edges[v]; }
};

struct Dinic {
  int N;
  vector<int> level;
  vector<int> itr;
  Graph G;

  Dinic(int n) : G(n) { N = n; }

  void add_edge(int from, int to, i64 cap, i64 rev_cap) {
    G[from].push_back(Graph::edge(to, cap, (int)G[to].size()));
    G[to].push_back(Graph::edge(from, rev_cap, (int)G[from].size() - 1));
  }

  bool g_level(int s, int t) {
    level.assign(N, -1);
    queue<int> que;
    que.push(s);
    level[s] = 0;
    while (!que.empty()) {
      int v = que.front();
      que.pop();
      for(int i = 0;i < G[v].size();i++){
        Graph::edge& e = G[v][i];
        if (e.cap > 0 && level[e.to] == -1) {
          level[e.to] = level[v] + 1;
          que.push(e.to);
        }
      }
    }
    return level[t] >= 0;
  }

  i64 dfs(int v, int t, i64 f) {
    if (v == t) return f;

    for (int &i = itr[v]; i < G[v].size(); i++) {
      Graph::edge &e = G[v][i];
      if (e.cap > 0 && level[e.to] > level[v]) {
        i64 mi_f = dfs(e.to, t, min(f, e.cap));
        if (mi_f > 0) {
          e.cap -= mi_f;
          G[e.to][e.rev].cap += mi_f;
          return mi_f;
        }
      }
    }
    return 0;
  }

  i64 max_flow(int s, int t) {
    i64 result = 0;
    i64 flow;
    while (g_level(s, t)) {
      itr.assign(N, 0);
      while ((flow = dfs(s, t, 1e9)) > 0) result += flow;
    }
    return result;
  }
};

int N,E;

int main(){
  cin >> N >> E;
  Dinic dinic(N);
  rep(i,0,E - 1){
    int u,v,c;
    cin >> u >> v >> c;
    dinic.add_edge(u,v,c,0);
  }

  cout << dinic.max_flow(0,N - 1) << endl;

}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
 
 
 int grouping(int input){
   if(input ==1 || input == 3 || input==5 || input==7 || input==8 || input==10 || input==12)
    return 1;
  else if(input ==2)
    return 2;
  else
    return 3;
 }

int main() {
 
  int x,y;
  cin>>x>>y;

  int x_grp = grouping(x);
  int y_grp = grouping(y);

  if(x_grp==y_grp)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

	return 0;
}



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

int main(){
    ll r,l;cin>>l>>r;
    ll ans=2018;

    r = min(r,l+4038);

    for (ll i = l; i <=r; i++)
    {
        for(ll j=i+1; j<=r; j++){
            ll x = i*j%2019;
            ans = min(ans,x);
        }
    }
    cout<<ans<<endl;

return 0;
}

Measured memory_bytes: 256
import re
while True:
    try:
        a,b,n = map(int, input().strip().split())
        u = str((float(a)/b))
        v = list(re.sub(r'[^\.]*\.', '', u))[:n]
        w = sum(map(int,v))
        print(w)

    except EOFError:
        break

Measured memory_bytes: 7712
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#pragma GCC optimize ("Ofast,unroll-loops,-ffloat-store")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")

#include <bits/stdc++.h>
using namespace std;

string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif
 
#define cin_exception cin.exceptions(cin.failbit);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using ll = int_fast64_t; using ld = long double;

// -----------------------------------------------------------------------------

const int N = 1e5 + 5;
int n, m, k;
int vi[N], sz[N];
int ans[N];
vector<int> g[N];

void dfs(int u, int r) {
    if (vi[u]) return;
    vi[u] = r;
    ++sz[r];
    for (auto &v : g[u]) {
        dfs(v, r);
    }
}

void solve() {
    cin >> n >> m >> k;
    for (int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for (int i = 1; i <= n; ++i) {
        dfs(i, i);
        ans[i] = sz[vi[i]] - 1 - g[i].size();
    }
    for (int i = 0; i < k; ++i) {
        int a, b; cin >> a >> b;
        if (vi[a] != vi[b]) continue;
        --ans[a]; --ans[b];
    }
    for (int i = 1; i <= n; ++i) {
        cout << ans[i] << ' ';
    }
    cout << '\n';
}

int main() {
    fast_io; cin_exception;
    int t = 1; // cin >> t;
    for (int i = 0; i < t; ++i) {
        solve();
    }
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

int main(){
  int a, p;
  cin >> a >> p;
  cout << (a*3+p) / 2 << endl;

  return 0;
}

Measured memory_bytes: 256