akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
 
int main()
{
  int S;
  int h;
  int m;
  int s;

  scanf("%d",&S);

  h=S/3600;
  m=(S%3600)/60;
  s=S%60;

  printf("%d:%d:%d\n",h,m,s);

  return 0;
}

Measured memory_bytes: 1828
import scala.io.Source.stdin

object Main {
  val v = new Array[Int](101)
  def main(args:Array[String]) =  {
    stdin.getLines.foreach { a => v(a.toInt) += 1 }
    v.zipWithIndex.filter( _._1 == v.max ).foreach { i => println(i._2) }
  }
}

Measured memory_bytes: 43772
#include<stdio.h>
#include<string.h>
#include<queue>
#include<map>
#include<map>
#include<vector>
#include<utility>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdlib.h>
using namespace std;
#define ll long long
#define pb push_back
int a[222222];
int main()
{
    int t;
    int n,m;
    scanf("%d%d",&n,&m);
    int minn=1e9+7;
    for(int i=0;i<m;i++) scanf("%d",&a[i]);
    for(int i=0;i<m;i++)
    {
        int t=(a[i]-a[(i+1)%m]+n)%n;
        if(t<minn) minn=t;
    }
    cout<<minn;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#define ll long long
#define mod 1000000007
using namespace std;
vector<vector<pair<ll, ll>>> vt;
vector<pair<ll, pair<ll, ll>>> vt1;
vector<pair<ll, pair<ll, ll>>> vt2;
ll p[1010], gap;
int visited[1010];
int find(int u) {
	if (p[u] == u)return u;
	return p[u] = find(p[u]);
}
int merge(int u, int v) {
	u = find(u), v = find(v);
	if (u == v)return 0;
	p[u] = v;
	return 1;
}
void dfs(int here, ll ch, int ggt)
{
	visited[here] = 1;
	if (ggt == here)
		gap = ch;
	for (int i = 0; i < vt[here].size(); i++)
	{
		ll next = vt[here][i].first;
		ll ncst = vt[here][i].second;
		if (!visited[next])
			dfs(next, max(ch, ncst), ggt);
	}
}
ll dst(int u, int v)
{
	gap = 0;
	memset(visited, 0, sizeof(visited));
	dfs(u, 0, v);
	return gap;
}
int main()
{
	ll n, m, k;
	scanf("%lld %lld %lld", &n, &m, &k);
	vt.resize(n + 1);
	for (int i = 1; i <= n; i++)
		p[i] = i;
	for (int i = 0; i < m; i++)
	{
		ll q, w, e;
		scanf("%lld %lld %lld", &q, &w, &e);
		vt1.push_back({ e,{ q,w } });
	}
	sort(vt1.begin(), vt1.end());
	ll xx = 0;
	for (int i = 0; i < vt1.size(); i++)
	{
		if (merge(vt1[i].second.first, vt1[i].second.second))
		{
			xx += vt1[i].first;
			vt[vt1[i].second.first].push_back({ vt1[i].second.second ,vt1[i].first });
			vt[vt1[i].second.second].push_back({ vt1[i].second.first,vt1[i].first });
		}
		else
		{
			vt2.push_back({ vt1[i].first,{ vt1[i].second.first,vt1[i].second.second } });
		}
	}
	if (xx > k)
	{
		puts("0");
		return 0;
	}
	ll dap1 = 0;
	if (xx == k)
	{
		dap1 = 1;
		n--;
		while (n--)
		{
			dap1 *= 2;
			dap1 %= mod;
		}
		dap1 = (dap1 - 2 + mod) % mod;
		for (int i = 0; i < vt2.size(); i++)
		{
			dap1 *= 2;
			dap1 %= mod;
		}
		
	}
	int cnt1 = 0;
	int cnt2 = 0;
	for (int i = 0; i < vt2.size(); i++)
	{
		ll ch1 = xx;
		ch1 += vt2[i].first;
		ch1 -= dst(vt2[i].second.first, vt2[i].second.second);
		if (ch1 == k)cnt1++;
		if (ch1 > k)cnt2++;
	}
	ll dap = 1;
	while (cnt1--)
	{
		dap *= 2;
		dap %= mod;
	}
	dap = (dap - 1 + mod) % mod;
	while (cnt2--)
	{
		dap *= 2;
		dap %= mod;
	}
	dap *= 2;
	dap %= mod;
	printf("%lld\n", (dap+dap1)%mod);
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>

typedef long long int ll;
using namespace std;

int main(){
	ll n,x,y;
	cin >> n >> x >> y;
	vector<ll> a(n);
	for(int i=0;i<n;i++)
		cin >> a[i];
	if(n > 1){
		if(llabs(y - *(a.end()-1)) < llabs(*(a.end()-1) - *(a.end()-2)))
			cout << llabs(*(a.end()-1) - *(a.end()-2)) << endl;
		else
			cout << llabs(y - *(a.end()-1)) << endl;
	}else{
		cout << llabs(a[0] - y) << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds; 
using namespace std;



typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 
 
 
//defines
typedef long long ll;
typedef long double ld;

    
ll a,b,c,n,m,k,t=1;

void solve()
{
   cin>>m>>n;
   vector<ll>v(n);
   map<ll,ll>f;
   for(ll i=0;i<n;i++)cin>>v[i],f[v[i]]++;
   ll start=1;
   if(f[m]==0)
   {
       cout<<m;return;
   }
   while(1)
   {
       if(f[m-start]==0)
       {
           cout<<m-start;return;
       }
       if(f[m+start]==0)
       {
           cout<<m+start;return;
       }
       start++;
   }
   
 if(t>0)cout<<"\n";
}

int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  //cin>>t;
    while(t--)
    {
        solve();
    }
  //cout<<sum;
        
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define fo(x, n) for(int i = x; i <= n; i++)
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector <int> vi;
const int MOD = 1e9 + 7;
void solve(){
    string s;
    cin >> s;
    if(s <= "2019/04/30") cout << "Heisei";
    else cout << "TBD";
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
	int T = 1;
    //cin >> T;
    fo(1, T){
        solve();
    }
}




Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for (auto &it : t) cout << it << " ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
  	int x;
  	cin >> x;
  	cout << x * x * x << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


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


void solve(long long N){
    int n = N % 10;
    if(n == 0 || n == 1 || n == 6 || n == 8){
        cout<<"pon"<<endl;
    }else if(n == 3){
        cout<<"bon"<<endl;
    }else{
        cout<<"hon"<<endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3760
#include <stdio.h>

int main(void)
{
	int a, b, num;
	int place;
	int sum;
	int i;
	
	while (scanf("%d%d%d", &a, &b, &place) != EOF){
		sum = 0;
		for (i = 0; i < place; i++){
			num = (a % b) * 10 / b;
			sum += num;
			
			a = (a % b) * 10 % b;
		}
		
		printf("%d\n", sum);
	}
	
	return (0);
}

Measured memory_bytes: 0
N = int(input())
S = [input() for _ in range(N)]
cnt = [[0] * N for _ in range(26)]
for i in range(N):
    for j in S[i]:
        cnt[ord(j) - 97][i] += 1
ans = []
for i in range(26):
    num = min(cnt[i])
    for j in range(num):
        ans.append(chr(97 + i))
ans.sort()
print("".join(ans))


Measured memory_bytes: 9168
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
string s, p;
signed main() {
	ld a, b, c, d;
	cin >> a >> b >> c >> d;
	printf("%.20LF\n", sqrt((c - a)*(c - a) + (b - d)*(b - d)));
}


Measured memory_bytes: 3200
#include<algorithm>
#include<cmath>//切り上げceil()
#include<deque>
#include<iomanip>//setprecision()
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<tuple>
#include<utility>
#define rep(i,n) for(ll i=0; i<n; i++)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int a,b,t,ans = 0;  cin >> a >> b >> t;
  for(int i = 1; i*a < t+0.5; i++){
    ans += b;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()

using namespace std;

void execute()
{
	int H, W;

	cin >> H >> W;
	vector<string> sentence(H);

	for (int i = 0; i < H; i++)
	{
		cin >> sentence[i];
	}

	for (int i = 0; i < H * 2; i++)
	{
		cout << sentence[i / 2] << endl;
	}

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize(3)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("sse3","sse2","sse")
#pragma GCC target("avx","sse4","sse4.1","sse4.2","ssse3")
#pragma GCC target("f16c")
#pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector")
#pragma GCC diagnostic error "-fwhole-program"
#pragma GCC diagnostic error "-fcse-skip-blocks"
#pragma GCC diagnostic error "-funsafe-loop-optimizations"
#pragma GCC diagnostic error "-std=c++14"
#include "bits/stdc++.h"
//#include "ext/pb_ds/tree_policy.hpp"
//#include "ext/pb_ds/assoc_container.hpp"
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) (x&(-x))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define EX0 exit(0);

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
typedef vector<ll> VLL;
typedef vector<int> VI;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9+7;
const ll inf = 1e9+7;
const ld eps = 1e-9;
const db PI = atan(1)*4;
template<typename T>
inline int sign(const T&a) {
    if(a<0)return -1;
    if(a>0)return 1;
    return 0;
}

template<typename T,typename S>inline bool upmin(T&a,const S&b){return a>b?a=b,1:0;}
template<typename T,typename S>inline bool upmax(T&a,const S&b){return a<b?a=b,1:0;}

template<typename T> inline void in(T &x) {
    x = 0;
    T f = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (isdigit(ch))  {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    x *= f;
}

ll twop(int x) {
    return 1LL<<x;
}

template<typename A,typename B > inline void in(A&x,B&y) {
    in(x);
    in(y);
}
template<typename A,typename B,typename C>inline void in(A&x,B&y,C&z) {
    in(x);
    in(y);
    in(z);
}
template<typename A,typename B,typename C,typename D> inline void in(A&x,B&y,C&z,D&d) {
    in(x);
    in(y);
    in(z);
    in(d);
}

namespace SOLVE {
    void main(){
    }
}

int dp[200010][2];
int main() {
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    k%=2;
    ll ans = a-b;
    if(k)ans*=-1;
    cout<<ans;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
a = list(map(int, input().split()))
if a[0] + a[1] == 0 and a[2] >= 1:
  print(1)
elif a[0] + a[1] + 1 >= a[2]:
  print(a[1] + a[2])
elif a[0] + a[1] + 1 < a[2]:
  print(a[0] + a[1] + 1 + a[1])


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k,i,p=0;
  cin>>k>>a>>b;
  for(i=a;i<=b;i++){
    if(i%k==0) p=1;
  }if(p==0){
    cout<<"NG"<<endl;
  }else{
    cout<<"OK"<<endl;
  }
}

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

static const int MAX = 200001;

struct Node{
  public:
    ll cnt;
    int parent;
    vector<int> children;
    Node(){
      cnt =0;
    }
};

int main(){
  Node node[MAX];
  int n, q;
  cin >> n >> q;
  rep(i, n-1){
    int a,b;
    cin >> a >> b;
    node[a].children.emplace_back(b);
    node[b].children.emplace_back(a);
  }
  rep(i,q){
    int p, x;
    cin >> p >> x;
    node[p].cnt += x;
  }
  bool check[MAX];
  rep(i,MAX) check[i] = false;
  stack<int> stk;
  stk.emplace(1);
  check[1] = true;
  while(!stk.empty()){
      int root = stk.top();stk.pop();
      rep(j,node[root].children.size()){
        int next = node[root].children[j];
        if(next == node[root].parent || check[next]) continue;
        stk.emplace(next);
        node[next].cnt += node[root].cnt;
        check[next] = true;
      }
  }

  for(int i = 1;i<=n;i++) cout << node[i].cnt << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 18036
#include<iostream>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define maxn 100000
#define LL long long
#define INF 0x3f3f3f3f
#define mset(p,v) memset(p,v,sizeof(p))
using namespace std;

bool check(string s)
{
    bool judge=true;
    int len=s.length()-1;
    for(int i=0;i<=len;i++)
    {
        if(i%2==1)
        {
            if(s[i]!='i')
            {
                judge=false;
                break;
            }

        }
        else
        {
            if(s[i]!='h')
            {
                judge=false;
                break;
            }
        }
    }
    if(len%2==0) judge=false;
    return judge;
}
int main()
{
    string s;
    cin>>s;
    if(check(s))
        printf("Yes\n");
    else
        printf("No\n");


	return 0;
}


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

int main(){
	std::string str;
	while(cin >> str) {
		for(int i = (int)str.length() - 1; i >= 0; i--) {
			cout << str[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 2976
#include<bits/stdc++.h>
#define eps 1e-9
#define MOD 1000000007;
#define INV_10 299473306;
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	double m;
	cin >> n >> m;
	double a[n], sum=0;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum+=a[i];
	}
	sort(a, a+n);
	reverse(a, a+n);
	double nb=0;
	for(int i = 0; i < n; i++)
	{
		if(a[i] >= sum/(4*m))
			nb++;
	}
	if(nb >= m)
		cout << "Yes\n";
	else
		cout << "No\n";
}

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

int N;
int main(){
	cin >> N;
	int v;
	set<int> s;
	vector<pair<int,int>> A(100001),B(100001);
	for(int i=1;i<=1e5;i++){
		A[i] = {0,i};
		B[i] = {0,i};
	}
	for(int i=0;i<N;i++){
		cin >> v;
		s.insert(v);
		if(i%2==0) A[v].first++;
		else B[v].first++;
	}
	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	int m = 1e5;
	if(A[m].second!=B[m].second){
		cout << N-A[m].first-B[m].first << endl;	
	}
	else{
		if(A[m-1].first>B[m-1].first){
			cout << N-A[m-1].first-B[m].first << endl;
		}else{
			cout << N-A[m].first-B[m-1].first << endl;
		}
	}
}

Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<ll,ll> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]


//根は片が入ってないやつ

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> to(n); //to[a]=b a->b
    vector<vector<int>> from(n);
    vector<bool> pre(n,1);
    rep(i,n+m-1){
        int a,b; cin >> a >> b;
        a--; b--;
        to[a].pb(b);
        from[b].pb(a);
        pre[b]=0;
    }
    int res[n];
    int st;
    rep(i,n){
        if(pre[i]){
            res[i]=-1;
            st=i;
            break;
        }
    }
    queue<int> q;
    vector<bool> visit(n,0);
    visit[st]=1;
    q.push(st);
    while(!q.empty()){
        int v=q.front(); q.pop();
        for(auto u:to[v]){
            if(visit[u]) continue;
            bool ok=1; //pre(u)=v?
            for(auto w:from[u]){
                if(!visit[w] || res[w]==v) ok=0;
            }
            if(ok){
                visit[u]=1;
                q.push(u);
                res[u]=v;
            }
        }
    }
    rep(i,n){
        cout << res[i]+1 << endl;
    }
    return 0;
}



Measured memory_bytes: 12160
/*
ID: jerrywcy
LINK:
LANG: C++
STATUS:
*/
#include <bits/stdc++.h>

#define init(array,x) memset(array,x,sizeof(array))

using namespace std;

typedef long long ll;

const int inf=0x3f3f3f3f;

int n;
int a[110];
double ans;

int read(){
    int f=1,x=0;
    char ss=getchar();
    while(ss<'0'||ss>'9'){if(ss=='-')f=-1;ss=getchar();}
    while(ss>='0'&&ss<='9'){x=x*10+ss-'0';ss=getchar();}
    return f*x;
}

int main()
{
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
    n=read();
    for (int i=1;i<=n;i++)a[i]=read();;
    for (int i=1;i<=n;i++)ans+=1.0/a[i];
    ans=1/ans;
    printf("%.9lf\n",ans);

	return 0;
}


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	double a, b, t;
	cin >> a >> b >> t;
	int ans = 0;
	for (int i = 1; i < 21;i++) {
		if (i * a <= t + 0.5) ans += b;
		else break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
def parent(n):
    return (n+1)/2-1

def left(n):
    return (n+1)*2-1

def right(n):
    return (n+1)*2

heap = []

H = int(raw_input())
keys = map(int, raw_input().strip().split(' '))
i = 0
for k in keys:
    p = parent(i)
    l = left(i)
    r = right(i)
    print "node %s: key = %s," % (i+1, k),
    if p  >= 0: print "parent key = %s," % keys[p],
    if l < len(keys): print "left key = %s," % keys[l],
    if r < len(keys): print "right key = %s," % keys[r],
    print "",
    print
    i += 1

Measured memory_bytes: 6456
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(x) x.begin(), x.end()
#define MOD 1000000007
#define vi vector < int >
#define pii pair < int, int >
#define INF (int)1e9
#define pb push_back
#define fastIO ios::sync_with_stdio(0); cin.tie(0);

int cache[21][int(pow(2, 21))];
int n;
vector < vi > arr;

int dpSol(int i, int vis)
{
    if(i == n)
        return 1;
        
    int &res = cache[i][vis];
    if(res != -1)
        return res;
        
    int ans = 0;
    for(int j = 0; j < n; ++j)
    {
        if(vis & (1 << j))
            continue;   
        else if(arr[i][j] == 1)
        {
            int temp = ((1 << j) | vis);
            ans = (ans + dpSol(i + 1, temp)) % MOD;
        }
    }
        
    return res = ans;
}

int main()
{
    fastIO
    
    cin >> n;
    arr = vector < vi >(n, vi(n));
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            cin >> arr[i][j];
            
    memset(cache, -1, sizeof(cache));
            
    cout << dpSol(0, 0);
    
    return 0;
}

Measured memory_bytes: 172288
from collections import Counter

def solve():
    MOD = 10**9 + 7

    N, K = map(int, input().split())
    Ass = [tuple(map(int, input().split())) for _ in range(N)]

    maxD = K.bit_length() - 1

    dp = [[Counter() for _ in range(N)] for _ in range(maxD+1)]
    for v, As in enumerate(Ass):
        v2s = []
        for v2, A in enumerate(As):
            if A == 1:
                v2s.append(v2)
        dp[0][v] = Counter(v2s)
    for d in range(1, maxD+1):
        for v in range(N):
            for v2, num2 in dp[d-1][v].items():
                for v3, num3 in dp[d-1][v2].items():
                    dp[d][v][v3] += num2 * num3
                    dp[d][v][v3] %= MOD

    anss = [1] * N
    for d in range(maxD+1):
        if K & (1<<d):
            ans2s = [0] * N
            for v in range(N):
                for v2, num in dp[d][v].items():
                    ans2s[v2] += anss[v] * num
                    ans2s[v2] %= MOD
            anss = ans2s

    print(sum(anss) % MOD)


solve()


Measured memory_bytes: 55612
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<string>
#include<functional>
using namespace std;
typedef	long long int ll;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    if(s[0] != '1' || s[n-2] != '1' || s[n-1] != '0'){
        cout << -1 << endl;
        return 0;
    }
    for(int i = 0; i < n-1; i++){
        if(s[i] != s[n-2-i]){
            cout << -1 << endl;
            return 0;
        }
    }
    int v = 1;
    for(int i = 0; i < n-1; i++){
        if(i==0){
            v = 2;
            cout << 1 << ' ' << 2 << endl;
        }
        else if(s[i]=='0'){
            cout << v << ' ' << i+2 << endl;
        }
        else if(s[i]=='1'){
            cout << v << ' ' << i+2 << endl;
            v = i+2;
        }
    }
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <map>

int main() {
  std::map<std::string , int> days;
  days["MON"] = 0;
  days["TUE"] = 1;
  days["WED"] = 2;
  days["THU"] = 3;
  days["FRI"] = 4;
  days["SAT"] = 5;
  days["SUN"] = 6;

  std::string S;
  std::cin >> S;

  std::cout << (6 - days[S] == 0 ? 7 : 6 - days[S]);
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N + 1);
    for (int i = 1; i <= N; i++)
        cin >> A[i];

    vector<bool> ball(N + 1, 0);
    vector<int> ans;

    for (int i = N; i >= 1; i--) {
        int mod = 0;
        for (int k = i * 2; k <= N; k += i) {
            mod ^= ball[k];
        }
        if (A[i] != mod) {
            ball[i] = 1;
            ans.push_back(i);
        }
    }

    cout << ans.size() << endl;
    for (auto& e:ans) {
        cout << e << " ";
    }
    if(ans.size() !=0) cout << endl;
}

Measured memory_bytes: 2428
#include<bits/stdc++.h>
int h[100001];
bool b[100001];
using namespace std;
int main()
{
	int n,m,a,c,ba=0;
	cin>>n>>m;
	for(int t=1;t<=n;t++)
	{
		cin>>h[t];
	}
	for(int t=0;t<m;t++)
	{
		cin>>a>>c;
		if(h[a]<=h[c])
		{
			//cout<<a<<" "<<t<<" ";
			b[a]=1;
		}
		if(h[c]<=h[a])
		{
			//cout<<c<<" "<<t<<" ";
			b[c]=1;
		}
	}
	for(int t=1;t<=n;t++)
	{
		if(b[t]==0)
		{
			ba++;
		}
	}
	cout<<ba;
	return 0;
}

Measured memory_bytes: 4140
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 入力
		int n = sc.nextInt();
		int[] a = new int[n+1];
		int m = sc.nextInt();

		int c = 0;
		int[] d = new int[n+1];
		for ( int i=0; i<m; i++ ) {
			int p = sc.nextInt();
			String s = sc.next();
			if ( a[p] == 0 ) {
				if ( s.equals("AC") ) {
					c++;
					a[p]++;
				} else {
					d[p]++;
				}
			}
		}

		int e = 0;
		for ( int i=1; i<=n; i++ ) {
			e = e + d[i] * a[i];
		}

		// 出力
		System.out.println(c + " " + e);
	}
}

Measured memory_bytes: 64284
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int m = Integer.parseInt(sc.next());
    int a[] = new int[n];
    int l = 0;
    int r = 0;
    int min = 0;
    int max = n;
    int ans = 0;

    for (int i=0; i<m; i++){
      l = Integer.parseInt(sc.next());
      r = Integer.parseInt(sc.next());
      if (l>min) { min=l; }
      if (max>r) { max=r; }
    }
    
    ans = max-min+1;
    if (ans<0) { ans=0; }
    System.out.println(ans);
    
  }
}


Measured memory_bytes: 50460
#include <bits/stdc++.h>
using namespace std;
 
//long long
using ll = long long;
 
// pair<int, int>
using PII = pair<int, int>;
 
//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
 
//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()
 
//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
 
//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
 
// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}
 
// a = max(a, b), a = min(a, b)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
// 階乗(MODをとる)
ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}
 
 
 
// 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度)
// COMinit()
// COM(x, y)
// とコンビで使う
 
// テーブルを作る前処理
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    int H, W;
    char c[25][25];
    int d[25][25];
    bool b[25][25] = {false};
    int ans;
int bfs(int _y, int _x){
    REP(i, H)REP(j, W) d[i][j] = -1;
    queue<pair<int, int>>que;
    d[_y][_x] = 0;
    que.emplace(_y, _x);
    while(!que.empty()){
        pair<int, int> p = que.front();
        que.pop();
        REP(i, 4){
            int ny = p.first + dy[i], nx = p.second + dx[i];
            if(ny >= 0 && ny < H && nx >= 0 && nx < W && d[ny][nx] == -1 && c[ny][nx] == '.'){
                d[ny][nx] = d[p.first][p.second] + 1;
                que.emplace(ny, nx);
            } 
        }
    }
    int res = -1;
    REP(i, H)REP(j, W){
        chmax(res, d[i][j]);
    }
    return res;
}
int main(){
    cin >> H >> W;
    REP(y, H)REP(x, W){
        cin >> c[y][x];
    }
    ans = 0;
    REP(y, H)REP(x, W){
        if(c[y][x] == '#') continue;
        ans = max(ans, bfs(y, x));
    }
    print(ans);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    
    char s[11];
    int count=0;
    int max=0;
    scanf("%s",s);
    
    for(int i=0; i<10; i++){
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')
            count++;
        else
            count=0;
        
        if(max<count)
            max=count;
    }
    printf("%d",max);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, k, b, ans;
string s;
int main(){
	cin>>n>>k>>s;
	rep(i,n-1) if(s[i] != s[i+1]) b++;
	printf("%d\n", n-1-max(0,b-k*2));
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;

  int ans;

  int arr[1000000];


int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS

    int a,b;
    cin >> a >> b;
    
    if(a > 0)
    {
       cout << "Positive";
       return 0;
    }

    if(a <= 0 and b >= 0)
    {
      cout << "Zero";
      return 0;
    }

    if(a%2 == b%2)
    {
      cout << "Negative";
    }
    else
    {
      cout << "Positive";
    }


    return 0;
}


Measured memory_bytes: 3656
/*
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
//*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb push_back
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

ll n;
ll a[maxn];
ll sum = 0;

int32_t main(){
    migmig
    cin >> n;
    for(int i = 0 ; i < n ; i ++)
        cin >> a[i],
        sum += a[i];
    if(sum%((n * (n + 1))/2LL))
        dokme("NO");
    ll num = sum/((n * (n + 1))/2LL);
    if(*min_element(a , a + n) < num)
        dokme("NO")
    if(*max_element(a , a + n) > num*n)
        dokme("NO")
    ll dick = ((a[1] - a[0]) + 1000000LL * n )%n;
    if(dick!=num%n)
        dokme("NO");
    for(int i = 1 ; i  < n ; i ++)
        if(((a[i] - a[i-1]) + 1000000LL * n )%n != dick)
            dokme("NO");
    cout << "YES";
    return(0);
}

Measured memory_bytes: 4372
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    A=LI()
    if sum(A)<=21:
        print("win")
    else:
        print("bust")
if __name__ == '__main__':
    main()

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

int main()
{
    int N;
    string s;
    scanf("%d", &N);
    cin>>s;
    long long red, green, blue, result;
    red = green = blue = 0;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'R')
            red++;
        if(s[i] == 'G')
            green++;
        if(s[i] == 'B')
            blue++;
    }
    result = red * green * blue;
    
    for(int i = 0; 2 * i < N; i++)
    {
        for(int j = 0; 2 * i + j < N; j++)
        {
            if(s[j] != s[i + j] && s[j] != s[2 * i + j] && s[i + j] != s[2 * i + j])
            {
                result--;
            }

        }
    }
    printf("%lld\n", result);
    return 0;
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  vector<int> vec = {a,b,c};
  sort(vec.begin(),vec.end());
  a = vec.at(0);
  b = vec.at(1);
  c = vec.at(2);
  int ans = 0;
  ans += c - b;  //aとbに１足す => bがcになる
  a = a + c - b; //aがa+c-bになる
  b = c;       //bがcになる
  
  if ((c-a)%2==0) ans += (c-a)/2;
  else ans += (c-a)/2 + 2;
  

  cout << ans << endl;
  
  
}


Measured memory_bytes: 256
import java.util.Scanner;

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

      int m = scan.nextInt();

    if (n>m){System.out.println("a"+" "+">"+" "+"b");}

    if (n<m){System.out.println("a"+" "+"<"+" "+"b");}

    if (n==m){System.out.println("a"+" "+"=="+" "+"b");}
  }
}


Measured memory_bytes: 26240
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int a,b;

int main(){
	cin>>a>>b;
	cout<<(b+a-3)/(a-1)<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
'''Snippets for lcm.
Available functions:
- lcm: Compute least common multiple of a and b.
'''


def lcm(a: int, b: int) -> int:
    '''Compute least common multiple of a and b.
    Args:
        a: Int of number (greater than 0).
        b: Int of number (greater than 0).
    Returns:
        least common multiple.
    Landau notation: O(log n)
    See:
    https://gist.github.com/endolith/114336/eff2dc13535f139d0d6a2db68597fad2826b53c3
    https://docs.python.org/3/library/sys.html#sys.version_info
    '''

    from sys import version_info

    if version_info.major == 3 and version_info.minor >= 5:
        from math import gcd
    else:
        from fractions import gcd

    return a * b // gcd(a, b)


def main():
    a, b, c, d = map(int, input().split())
    l = lcm(c, d)
    x = b // c - (a - 1) // c
    y = b // d - (a - 1) // d
    z = b // l - (a - 1) // l
    w = b - a + 1

    print(w - (x + y - z))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5096
# -*- coding: utf-8 -*-
# Nの取得
index = int(input())

# n回ループして配列に入れる
maximum = 0
other = 0
inputList = input().split()
for i in range(index):
    tmp = int(inputList[i])
    if tmp > maximum:
        maximum = tmp
        other = other + maximum
    else:
        other = other + tmp

if maximum < other - maximum:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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 gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

int main(){
  int m; cin >> m;
  ll ans = 0LL, sum = 0LL;
  rep(i, m){
    ll d,c; cin >> d >> c;
    ans += c;
    sum += d*c;
  }
  ll k = (sum-1)%9 + 1;
  //ans += sum/10 - 1;
  ans += (sum-k)/9 - 1;
  std::cout << ans << '\n';
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String s = saori.nextHayami();
		int num1 = Integer.parseInt(s.substring(0, 2));
		int num2 = Integer.parseInt(s.substring(2, 4));
		saori.close();
		if(0 <= num1 && num1 <= 99 && 1 <= num2 && num2 <= 12 && 0 <= num2 && num2 <= 99 && 1 <= num1 && num1 <= 12){
			System.out.println("AMBIGUOUS");
		} else if(0 <= num1 && num1 <= 99 && 1 <= num2 && num2 <= 12){
			System.out.println("YYMM");
		} else if(0 <= num2 && num2 <= 99 && 1 <= num1 && num1 <= 12){
			System.out.println("MMYY");
		} else {
			System.out.println("NA");
		}
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21332
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  vector<int> sum(n+1, 0);
  rep(i, n){
    cin >> p[i];
    sum[i+1] = sum[i] + p[i];
  }
  int maxNum = 0;
  int ind = 0;
  rep(i, n-k+1){
    int num = sum[i+k] - sum[i];
    if (maxNum < num){
      maxNum = num;
      ind = i;
    }
  }
  double ans = 0.0;
  rep(i, k){
    ans += (p[ind+i] + 1.0) / 2.0;
  }
  cout << fixed << setprecision(10) << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1792
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        N: i32,
        A: i32,
        B: i32,
    }

    let mut ans = min(A * N, B);
    println!("{}", ans);
}


Measured memory_bytes: 2132
n, k = [int(i) for i in input().split(" ")]

s = 0
for b in range(1, n + 1):
    if b > k:
        s += ((n + 1) // b) * (b - k) + max(0, (n + 1) % b - k)
if k == 0:
    s -= n
print(s)

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int h,w,k;
int c[7][7];

int num_sum(int bi, int bj){
    int sum=0;
    int a[7][7] ={};
    REP(i,h)REP(j,w)a[i][j]=c[i][j];

    for(int i = 0; i < h; i++){
        if(bi & (1<<i)){
            for(int j = 0; j < w; j++){
                a[i][j]=0;
            }
        }
    }
    for(int j = 0; j < w; j++){
        if(bj & (1<<j)){
            for(int i=0;i<h;i++){
                a[i][j]=0;
            }
        }
    }
    REP(i,h){
        REP(j,w){
//            cout << a[i][j] << " ";
            sum+=a[i][j];
        }
    }
    return sum;
}


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

    cin >> h >> w >> k;


    REP(i,h){
        string s;
        cin >> s;
        REP(j,w){
            if(s[j] == '.')c[i][j] = 0;
            else c[i][j] = 1;
        }
    }

    int res = 0;
    for(int bi = 0; bi < (1<<h); ++bi){
        for(int bj = 0; bj < (1<<w); ++bj) {
             int r = num_sum(bi, bj);
             if(r == k){
//                 cout << bi <<" "<<bj << endl;
                 res++;
             }
        }
    }
    cout << res << endl;
}




Measured memory_bytes: 3564
n = int(input())

taro_score = 0
hanako_score = 0

for i in range(n):
    taro,hanako = input().split()

    if taro>hanako:
        taro_score +=3
    elif taro<hanako:
        hanako_score += 3
    else:
        taro_score += 1
        hanako_score += 1
print("%d %d" % (taro_score,hanako_score))



Measured memory_bytes: 5600
#7
n = int(input())
s = input()
x,y = "",""
Max = 0

for i in range(1,n):
    x = list(set(list(s[:i])))
    y = list(set(list(s[i:])))
    cnt = 0
    for m in x:
        for n in y:
            if m == n:
                cnt +=1
                break
        if Max < cnt:
            Max = cnt
            
print(Max)

Measured memory_bytes: 9112
//reference ---->  errichto stream
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
int main(int argc,char ** argv){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n , w;
    cin >> n >> w;
    vector< int > val(n) , wei(n);
    int sum = 0;
    for(int i = 0 ; i < n ; i++ ){
    	cin >> wei[i] >> val[i];
    	sum += (val[i]); 
  	}
  	vector< ll > dp( sum + 1 , inf);// min weight with value sum + 1
    dp[0] = 0;
    for(int i = 0 ; i < n ; i++){
    	for(int j = sum - val[i] ; j >= 0 ; j--){
    		dp[j + val[i]] = min(dp[j + val[i]] , dp[j] + wei[i]);
    	}
    }
	ll ans = 0;
	for(ll i = 0 ; i <= sum ; i++){
		if(dp[i] <= w){
			ans = i;
		}
	}
	cout << ans << endl;
	return 0; 
}

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

// main
int main(){
    int N, X; cin >> N >> X;
    vector<int> m(N); rep(i, N) cin >> m[i];

    int res_X = X - accumulate(m.begin(), m.end(), 0);
    int count = N;

    sort(m.begin(), m.end());
    count += res_X / m[0];
    cout << count << "\n";

    return 0;
}

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

int main()
{
    ll N;
    cin >> N;
    vector<ll> v;
    ll p = 1;
    v.push_back(0);
    for (int i = 1; ; i++) {
        p *= 26;
        v.push_back(v[i-1]+p);
        if (v[i-1]+p > 1000000000000001) {
            break;
        }
    }
    for (int i = 1; i < v.size(); i++) {
        if (N <= v[i]) { // num of digits is i
            N -= v[i-1] + 1;
            char s[i+1];
            s[i] = 0;
            for (int j = 0; j < i; j++) {
                int c = N % 26;
                s[i-j-1] = 'a' + c;
                N /= 26;
            }
            printf("%s\n", s);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin >> n;
  cin >> s;
  int l = s.length();
  int i;
  for(i=0;i<l;i++){
    s[i] = ((s[i]-'A')+n)%26 + 'A';
  }
  cout << s;
}


Measured memory_bytes: 256
integer i,n,v(20),c(20)
read *,n
read *,v(1:n)
read *,c(1:n)
do i = 1,n
   if (v(i) > c(i)) then
      v(i) = v(i) - c(i)
   else
      v(i) = 0
   endif
enddo
print '(i0)',sum(v(1:n))
end

Measured memory_bytes: 256