akhauriyash/Code-Regression huggingface dataset:
// fahadmd16(IIEST Shibpur)
#include<bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define ll long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define db double
#define pll pair<ll, ll>
#define ALL(a) (a).begin(),(a).end()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define forn(i, n) for (ll i = 0; i < n; i++)
#define forn1(i, n) for (ll i = 1; i < n; i++)
#define forab(i,a,b) for(ll i=a;i<b;i++)
#define clr(x) memset(x, 0, sizeof(x))
#define count_bit(x) __builtin_popcount(x)
#define endl "\n"
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace(v) for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define eps 1e-12
#define nedl endl
const ll sz = 101;
const ll mod = 1e9+7;
typedef vector<ll> VL;
typedef vector<pll > VLL;
typedef vector<vector<ll> > VVL;
 
ll power(ll n,ll k,ll m){
    ll ans=1;
    while(k){
        if(k&1)ans=(ans*n)%m;
        k/=2;
        n=(n*n)%m;
    }
    return ans;
}

int main() {
    IOS;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    ll T=1;//cin>>T;
    while(T--){
        ll r,c;cin>>r>>c;
        char a[r][c];
        ll dp[r][c]={0};
        forn(i,r){forn(j,c)cin>>a[i][j];}
        
        
        
        
        
        dp[0][0]=(a[0][0]=='#');
        

        forn1(i,r){
            dp[i][0]=dp[i-1][0];
            if((a[i][0]=='#')&&(a[i-1][0]=='.'))
                dp[i][0]+=1;
            
        }

        forn1(i,c){
            dp[0][i]=dp[0][i-1];
            if((a[0][i]=='#')&&(a[0][i-1]=='.'))
                dp[0][i]+=1;
        }


        forn1(i,r){
            forn1(j,c){
                if(a[i][j]=='.')
                    dp[i][j]=min(dp[i-1][j],dp[i][j-1]);
                else{
                    //dp[i][j]=min(dp[i-1][j],dp[i][j-1]);
                    dp[i][j]=INT_MAX;
                    if(a[i-1][j]=='.')dp[i][j]=min(dp[i][j],1+dp[i-1][j]);
                    else dp[i][j]=min(dp[i][j],dp[i-1][j]);
                    if(a[i][j-1]=='.')dp[i][j]=min(dp[i][j],1+dp[i][j-1]);
                    else dp[i][j]=min(dp[i][j],dp[i][j-1]);
                }
            }
        }
        // forn(i,r){forn(j,c)cout<<dp[i][j]<<" ";cout<<endl;}cout<<endl;
        cout<<dp[r-1][c-1]<<endl;



    }
    return 0;
}


Measured memory_bytes: 384
s = raw_input()

counter = 0
counterA = 0
counterZ = 0

flag = False

for i in range(len(s)):
    counter += 1
    if s[i] == 'A' and not flag:
        counterA = counter
        flag = True
    if s[i] == 'Z':
        counterZ = counter
        

print counterZ-counterA+1

Measured memory_bytes: 9088
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    
  int a, b;
  int d, r;
  double f;
  cin >> a >>b;
  d=a/b;
  r=a%b;
  f=(double)a/b;
  printf("%d %d %f\n", d, r, f);
  
}


Measured memory_bytes: 3128
def floor(x):
    return int(x)

def main():
    (A,B,N) = list(map(int, input().split(' ')))

    X = B-1 if B-1 <= N else N
    X = float(X)

    ans = floor(A*X/B) - A*floor(X/B)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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 (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int n;
  cin>>n;



  cout << lcm(n,360)/n << endl;

}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	if (s[2]==s[3] and s[4]==s[5])
		cout<<"Yes";
	else
		cout<<"No";
}

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

using namespace std;

int main(){

	int x, y, z, lop, dlop;
	long long int k;
	vector<long long int> a, b, c, d, e;

	cin>> x >> y >> z;
	cin>> k;

	a.resize(x);
	b.resize(y);
	c.resize(z);

	for(int i=0;i<x;i++) cin>> a[i];
	for(int i=0;i<y;i++) cin>> b[i];
	for(int i=0;i<z;i++) cin>> c[i];

	sort(a.begin(), a.end(), greater<long long int>());
	sort(b.begin(), b.end(), greater<long long int>());
	sort(c.begin(), c.end(), greater<long long int>());

	lop=min(3000, x*y*z);

	for(int i=0;i<x;i++){
		for(int j=0;j<y;j++){
			d.emplace_back(a[i]+b[j]); 
		}
	}
	sort(d.begin(), d.end(), greater<long long int>());
	//for(int i=0;i<d.size();i++) cout<< "d " << d[i] << endl;

	dlop=min(lop, (int)d.size());
	for(int i=0;i<dlop;i++){
		for(int j=0;j<z;j++){
			e.emplace_back(d[i]+c[j]); 
		}
	}
	sort(e.begin(), e.end(), greater<long long int>());

	for(int i=0;i<k;i++) cout<< e[i] << endl;


}

Measured memory_bytes: 43368
using System;
using System.Collections.Generic;

class Program {
  static void Main (string[] args) {
    string[] str = Console.ReadLine().Split(' ');
    int a = int.Parse(str[0]);
    int b = int.Parse(str[1]);
    int ab = (a * 3) + b;
    int ans = (ab % 2 == 0) ? ab / 2 : (ab - 1) / 2;
    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main()
{
  long int n,m;
  cin>>n>>m;
  int k,sum=0;
  for(int i=0;i<m;i++)
  {
      cin>>k;
      sum+=k;
  }
  if(sum>n)
    cout<<-1;
  else
    cout<<n-sum;
}


Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
 
class Hello
{
    
    static void aiueo(int a,int b,int c)
    {
        int sum=a+b;
        if(a==-1||b==-1)Console.WriteLine("F");
        else if(sum>=80)Console.WriteLine("A");
        else if(sum>=65)Console.WriteLine("B");
        else if(sum>=50||c>=50)Console.WriteLine("C");
        else if(sum>=30)Console.WriteLine("D");
        else Console.WriteLine("F");
    }
    
    static void Main()
    {
        string [] str=Console.ReadLine().Split(' ');
        int a=int.Parse(str[0]);
        int b=int.Parse(str[1]);
        int c=int.Parse(str[2]);
        
        
        for(;a+b+c!=-3;)
        {
            aiueo(a,b,c);
            str=Console.ReadLine().Split(' ');
            a=int.Parse(str[0]);
            b=int.Parse(str[1]);
            c=int.Parse(str[2]);
            
        }
    }
}


Measured memory_bytes: 15920
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);
#define Accepted 0
using namespace std;
typedef long long ll;
const int maxn = 1000000 + 10;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const double eps = 1e-10;
const double pi = acos(-1);
int T, cases, n, m;

int main()
{
    int a[5];
    for(int i = 0; i < 5; i++)cin >> a[i];
    int tmp = 0, ans = 0;
    for(int i = 0; i < 5; i++)
    {
        tmp = max(tmp, (a[i] + 9) / 10 * 10 - a[i]);
        ans += (a[i] + 9) / 10 * 10;
    }
    ans -= tmp;
    cout<<ans<<endl;
    return Accepted;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int man=1000005;
const int MAXM= 15000005;
int n,m,x,y;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin>>n>>m>>x>>y;
  int t;
  for(int i=0;i<n;i++)
  {
      cin>>t;
      x=max(x,t);
  }
   for(int i=0;i<m;i++)
  {
      cin>>t;
      y=min(y,t);
  }
  if(y-x>=1)
    cout<<"No War"<<endl;
  else
    cout<<"War"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


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

#define Mod 1000000007
#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n,k,q;cin>>n>>k>>q;
	ll f[n];
	memset(f,0,sizeof(f));
	ll total = q;
	while(q--){
		ll x;cin>>x;x--;
		f[x]++;
	}
	bool ok = 1;
	For(i,0,n){
		if(total-f[i]>=k){
			cout<<"No"<<endl;
		}else{
			cout<<"Yes"<<endl;
		}
	}































	
}

Measured memory_bytes: 1408
#include<stdio.h>
#include<string.h>
char s[200001];
char t[200001];
int main()
{
	int sum=0,len,i;
	scanf("%s",s);
	scanf("%s",t);
	len=strlen(s);
	for(i=0;i<len;i++)
	{
		if(s[i]!=t[i]) sum++;
	}
	printf("%d\n",sum);
}

Measured memory_bytes: 2120
#!/usr/bin/env python3

import fractions as f
import copy

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

a_abs = list(map(abs, a))

fu = 0
for i in range(N):
    if(a[i] < 0):
        fu += 1

if fu%2 == 0:
    max = sum(a_abs)
else:
    min_abs = a_abs.index(min(a_abs))
    max = sum(a_abs) - 2 * a_abs[min_abs]

print(max)


Measured memory_bytes: 16440
n = int(input())
score = {}
for _ in range(n):
    blue = input()
    if blue in score:
        score[blue] += 1
    else:
        score[blue] = 1
m = int(input())
for _ in range(m):
    red = input()
    if red in score:
        score[red] -= 1
    else:
        score[red] = -1
dict_max = max(score.values())
print(max(dict_max,0))


Measured memory_bytes: 3060
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef vector<int>     Vi;
typedef vector<ll>      Vl;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD1    = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define psb push_back
#define epb emplace_back
#define psf push_front
#define mkp make_pair
#define fst first
#define scd second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define repbit(bit, n)  for(int bit = 0; (bit) < (1 << (n)); ++(bit))
#define ifbit(bit, i)   if((bit) & (1 << (i)))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;
    Vi a(n+1); rep(i ,n) a[i] = i;
    int cnt = 0;
    rep(i, n){
        int p; cin >> p;
        if(p != a[i]+1) ++cnt;
    }
    if(cnt == 0 || cnt == 2)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int compare(const void*a,const void *b) {
	return *(int*)a - *(int*)b;
}

int main() {
	int n, t, x, ans = 0;
	scanf("%d%d%d", &n, &x, &t);
	ans = (((n - 1)/ x) + 1) * t;
	printf("%d",ans);
	return 0;
}

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

using std::min;
using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::for_each;

int main() {
	int n;
	cin >> n;
	vector<int> A(n);
	for_each(A.begin(),A.end(),[](int &_e){cin >> _e;});
	int m;
	cin >> m;
	vector<int> B(m);
	for_each(B.begin(),B.end(),[](int &_e){cin >> _e;});
	int comparison = 1; // 0: B > A; 1: B == A; 2: B < A
	int shorter = min(n,m);
	for (int i = 0;i != shorter;++i) {
		if (B[i] > A[i]) {
			comparison = 0;
			break;
		}
		else if (B[i] < A[i]) {
			comparison = 2;
			break;
		}
	}
	if (comparison == 1) {
		if (n > m) {
			comparison = 2;
		}
		else if (n < m) {
			comparison = 0;
		}
	}
	cout << (comparison == 0 ? 1 : 0) << endl;
}


Measured memory_bytes: 3104
import sys
input = sys.stdin.readline
from itertools import accumulate

MOD = 10**9+7

n, c = map(int, input().split())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))
E = [[0]*(c+1) for _ in range(n)]
for j in range(c+1):
  cumsum = tuple(pow(k, j, MOD) for k in range(401))
  cumsum = tuple(i%MOD for i in accumulate(cumsum))
  for i, (a, b) in enumerate(zip(A, B)):
    E[i][j] = cumsum[b] - cumsum[a-1]

dp = [[0]*(c+1) for _ in range(n+1)]
dp[0][0] = 1
for i, e in enumerate(E):
  for j, f in enumerate(e):
    for k in range(c+1):
      if j+k <= c:
        dp[i+1][j+k] += dp[i][k]*f
        dp[i+1][j+k] %= MOD
ans = dp[n][c]
print(ans)

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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    rep(i,n) {
        set<char> a, b;
        rep(j,n) {
            if(i >= j) a.insert(s[j]);
            else b.insert(s[j]);
        }
        int temp = 0;
        for(auto d : a) {
            if(b.count(d)) temp++;
        }
        ans = max(ans, temp);

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
using namespace std;

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

int main() {
	string S;
	cin >> S;

	int resultA = 0;
	int resultB = 0;
	for (int i = 0; i < S.size(); ++i)
	{
		if (ConvStrToInt(S[i]) != 0)
		{
			++resultA;
		}
		else
		{
			++resultB;
		}
	}

	int printNum = min(resultA, resultB) * 2;
	cout << printNum << endl;
}

Measured memory_bytes: 512
package main

import (
	"bufio"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	iv, _ := strconv.Atoi(readStr())
	return iv
}

func readStr() string {
	sc.Scan()
	return sc.Text()
}

type poll struct {
	s string
	c int
}
type polls []poll

func (p polls) Len() int           { return len(p) }
func (p polls) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }
func (p polls) Less(i, j int) bool { return p[i].c > p[j].c }

func main() {
	n := readInt()
	m := make(map[string]int, n)
	for i := 0; i < n; i++ {
		s := readStr()
		m[s]++
	}

	ps := polls(make([]poll, 0, len(m)))
	for s, c := range m {
		ps = append(ps, poll{s, c})
	}
	sort.Sort(ps)

	ans := make([]string, 0, len(m))
	pmx := ps[0]
	ans = append(ans, pmx.s)
	for _, p := range ps[1:] {
		if p.c != pmx.c {
			break
		}
		ans = append(ans, p.s)
	}
	sort.Strings(ans)

	var wr = bufio.NewWriter(os.Stdout)
	for _, s := range ans {
		wr.WriteString(s + "\n")
	}
	wr.Flush()
}


Measured memory_bytes: 22912
import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}
import java.lang.{Character => char}

object Main extends App {
  val Array(n,k) = in.readLine.split(" ").map(_.toInt)
  val s = in.readLine.map(char.getNumericValue)

  val table = mu.ArrayBuffer.empty[Int]
  s./:(-1)( (b, i) => {
    val v = if(i == 1) 1 else -1
    if(i != b) table.append(v)
    else table(table.size-1) += v
    i
  })

  val sums = table.scanLeft(0)((acc,i) => acc + i.abs)
  0 +=: table

  def rec(acc:Int, cnt:Int, left:Int, right:Int, now:Int):Int = {
    if(right == table.size) acc
    else {
      val leftCnt = if(table(left) < 0) 1 else 0
      if(cnt-leftCnt == k && now == 1)
        rec(acc max (sums(right)-sums(left)), cnt-leftCnt, left+1, right, now)
      else
        rec(acc max (sums(right)-sums(left)), cnt+(now^1), left, right+1, now^1)
    }
  }

  val ans = rec(0,0,0,1,s.head)
  println(ans)
}

Measured memory_bytes: 36516
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

char input(){
  char a;
  cin >> a;
  return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin >> a >> b;
    if(a*2>=b){
      cout << b/2 << endl;
      return 0;
    }
    cout << a+(b-2*a)/4 << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, a, b) = (v[0], v[1], v[2]);
    if a + b > n + 1 || a * b < n || a > n || b > n {
        println!("-1");
        return;
    }
    let mut answers = VecDeque::new();
    for i in 1..a + 1 {
        answers.push_back(i);
    }

    let residual_b = b - 1;
    let mut each_len = vec![0; residual_b];
    for i in a + 1..n + 1 {
        each_len[i % residual_b] += 1;
    }
    let mut vs = vec![vec![]; residual_b];
    let mut pointer = a + 1;
    for i in (0..residual_b).rev() {
        for _ in 0..each_len[i] {
            vs[i].push(pointer);
            pointer += 1;
        }
    }
    assert_eq!(pointer, n + 1);
    for i in (0..residual_b).rev() {
        for &num in vs[i].iter().rev() {
            answers.push_front(num);
        }
    }
    for ans in answers {
        print!("{} ", ans);
    }
    println!("");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

string s;
int ans;

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

    char now = s[0];
    for(int i=0; i<s.length(); i++) {
        if(s[i]!=now) {
            now = s[i];
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
    int x;
    cin >> x;
    int a = x / 500;
    int b = (x - 500*a) / 5;
    int cnt_500 = 0;
    int cnt_5 = 0;
    for(int i = 0; i < a; i++){
        x = x - 500*i;
        cnt_500++;
    }
    for(int j = 0; j < b; j++){
        x = x - 5*j;
        cnt_5++;
    }
    cout << cnt_500 * 1000  + cnt_5 * 5 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <string.h>

int main(){
  int K,len,i;
  char S[101];
  scanf("%d %s",&K,S);
  len=strlen(S);
  if(len <= K){
    printf("%s",S);
  }
  else{
    for(i=0;i<K;i++){
    printf("%c",S[i]);
    }
    printf("...\n");
  }

  return 0;
}


Measured memory_bytes: 1676
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  A[0]--;
  FOR(i, 1, N){
    if(A[i-1] == A[i]) continue;
    A[i]--;
    if(A[i-1] > A[i]){
      No;
      return 0;
    }
  }
  Yes;

  return 0;
}

Measured memory_bytes: 1024
s = input()

while True:
  if s[-5:]=="dream":
    s = s[0:-5]
    continue
  elif s[-7:]=="dreamer":
    s = s[0:-7]
    continue
  elif s[-5:]=="erase":
    s = s[0:-5]
    continue
  elif s[-6:]=="eraser":
    s = s[0:-6]
    continue
    
  if not s:
    print("YES")
  else:
    print("NO")
  break

Measured memory_bytes: 3188
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long
     
    int main()
    {
    	ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        //std::numeric_limits<int>::max();
        int n,k,i,j;
        float x,ans,diff;
        
        cin>>n>>k;
        vector<int> arr(n);
        vector<double> cumu(n);
    
        for(i=0;i<n;i++)
        	{
        		cin>>arr[i];
        		x=(float)(1+arr[i])/2;
        		if(i==0)
        			cumu[0]=x;
        		else
        			cumu[i]=cumu[i-1]+x;
			}
			ans=cumu[k-1];
			for(i=k;i<n;i++)
        	{
        		diff=cumu[i]-cumu[i-k];
        		ans=max(diff,ans);
			}
			cout<<fixed<<setprecision(10)<<ans<<endl;
        
        
    }

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> pos(n);
	for(int& x : pos) cin >> x;
	int ans = 1e9;
	
	for(int meet = 1; meet <= 100; meet++) {
		int cur = 0;
		
		for(int x : pos) {
			cur += (x-meet)*(x-meet);
		}
		
		ans = min(ans, cur);
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    private static final BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) {
        String str = readLineStandardInput();
        char[] S = str.toCharArray();
        int y = 700;
        for(char s: S){
            if(s == 'o'){
                y += 100;
            }
        }
        System.out.println(y);
    }

    private static String readLineStandardInput() {
        String str;
        try {
            str = input.readLine();
        } catch(IOException e){
            str = null;
            System.out.println(e);
        }
        return str;
    }
}


Measured memory_bytes: 21076
n, m = map(int, input().split())
g = {}
for _ in range(m):
    a, b = map(int, input().split())
    if a not in g:
        g[a] = [b]
    if b not in g:
        g[b] = [a]
    if a in g:
        g[a].append(b)
    if b in g:
        g[b].append(a)
ans = "IMPOSSIBLE"
for i in g[1]:
    if n in g[i]:
        ans = "POSSIBLE"
print(ans)


Measured memory_bytes: 51596
import java.io.*;

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader bf =new BufferedReader(new InputStreamReader(System.in));
		String t;double v,u,y;
		while((t=bf.readLine())!=null){
			v=Double.parseDouble(t);
			u=v/9.8;y=4.9*u*u;
			System.out.println((int)Math.ceil((y+5)/5));
		}
	}
}

Measured memory_bytes: 9240
import java.util.Scanner;

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

        int H, W;
        H = sc.nextInt();
        W = sc.nextInt();

        if(H == 0 && W == 0)
            return;

        while(H != 0 || W != 0){
            for(int i = 0; i < H; i++){
                for(int j = 0; j < W; j++){
                    if(i % 2 == j % 2 )
                        System.out.print("#");
                    else
                        System.out.print(".");
                }
                System.out.println("");
            }
            System.out.println("");

            H = sc.nextInt();
            W = sc.nextInt();
        }

    }
}


Measured memory_bytes: 33256
#include <bits/stdc++.h>
#define Max 10000001
using namespace std;
//FILE *fi=freopen("1.txt","r",stdin);
long long kq;
long long d[200001];
struct flower{
    int h;
    long long w;
};
flower a[200001];
int n;
struct segmmentree{
    int l[Max];
    int r[Max];
    long long maxx[Max];
    int leaf[Max];
    void build(int i,int j,int x)
    {
        l[x]=i;
        r[x]=j;
        maxx[x]=0;
        if(i==j)
        {
            leaf[i]=x;
            return;
        }
        int mid=(i+j)/2;
        build(i,mid,2*x);
        build(mid+1,j,2*x+1);
    }
    void update(int pos,long long val)
    {
        int x=leaf[pos];
        maxx[x]=val;
        while(x)
        {
            x/=2;
            maxx[x]=max(maxx[2*x],maxx[2*x+1]);
        }
    }
    int qi,qj;
    long long TL(int x)
    {
        if(l[x]>qj||r[x]<qi)
            return 0;
        if(l[x]>=qi&&r[x]<=qj)
            return maxx[x];
        else
            return max(TL(2*x),TL(2*x+1));
    }
    long long hoi(int l,int r)
    {
        qi=l;
        qj=r;
        return TL(1);
    }
} tree;
int main()
{
    scanf("%d",&n);
    tree.build(1,n,1);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i].h);
    }
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i].w);
    for(int i=1;i<=n;i++)
    {
        long long tt=tree.hoi(1,a[i].h-1);
        d[i]=tt+a[i].w;
        tree.update(a[i].h,d[i]);
        kq=max(kq,d[i]);
    }
    cout<<kq;
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const ld pi = 3.141592653589793;

ll n, a, q, b, c, sum;
map<int, int> memo;

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    memo[a]++;
    sum += a;
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> b >> c;
    memo[c] += memo[b];
    // sum -= b * memo[b];
    // sum += c * memo[c];
    sum += (c - b) * memo[b];
    memo[b] = 0;
    cout << sum << endl;
  }
}

Measured memory_bytes: 7992
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int A1 = scan.nextInt();
		int A2 = scan.nextInt();
		int A3 = scan.nextInt();

		if(A1 + A2 + A3 >= 22) {
			System.out.println("bust");
		}else {
			System.out.println("win");
		}
	}

}

Measured memory_bytes: 21844
#include"iostream"
using namespace std;
int main(void){
	string a,b,c;
  	int A,B;
	cin >> a >> b >> A >> B >>c;
  
  if(a==c){
   cout << A-1 << " " << B;
  }else{
  	cout << A << " "<< B-1;
  }

}


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

int main()
{
	int n, k;
	cin >> n >> k;
	int a[n];
	int dp[k+1];
	memset(dp, 0, sizeof(dp));

	for(int i=0; i<n; i++)
	{
		cin >> a[i];
		dp[a[i]] = 1;
	}

	for(int i = a[0]; i <= k; i++)
	{
		for(int j = 0; j < n and !(dp[i]); j++)
		{
			if(i >= a[j]  && !dp[i - a[j]])
			{
				dp[i] = 1;
				break;
			}
		}
	}

	if(dp[k])
		cout << "First";
	else
		cout << "Second";
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <atcoder/lazysegtree>
#include <atcoder/modint>

using namespace std;
using namespace atcoder;

using mint = modint998244353;

struct S {
	mint a;
	int sz;
};

struct F {
	mint a, b;
};

S op(S l, S r) {
	return S{l.a + r.a, l.sz + r.sz};
}

S e() {
	return S{0, 0};
}

S mapping(F l, S r) {
	return S{r.a * l.a + r.sz * l.b, r.sz};
}

F composition(F l, F r) {
	return F{r.a * l.a, r.b * l.a + l.b};
}

F id() {
	return F{1, 0};
}

int main() {
	int n, q;
	scanf("%d %d", &n, &q);
	vector<S> a(n);
	for (int i = 0; i < n; i++) {
		int x; scanf("%d", &x);
		a[i] = S{x, 1};
	}
	lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);
	for (int i = 0; i < q; i++) {
		int t; scanf("%d", &t);
		if (t == 0) {
			int l, r, c, d;
			scanf("%d %d %d %d", &l, &r, &c, &d);
			seg.apply(l, r, F{c, d});
		} else {
			int l, r;
			scanf("%d %d", &l, &r);
			printf("%d\n", seg.prod(l, r).a.val());
		}
	}
	return 0;
}

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

typedef long long ll;

ll cnt[10] = {0};
ll ans;

int main()
{
    for(int i = 0; i < 7; i++)scanf("%lld",cnt + i);

    ans = cnt[0] / 2 * 2 + cnt[3] / 2 * 2 + cnt[4] / 2 * 2;
    if(cnt[0] && cnt[3] && cnt[4])
    {
        cnt[0]--;
        cnt[3]--;
        cnt[4]--;
        ans = max(ans,3 + cnt[0] / 2 * 2 + cnt[3] / 2 * 2 + cnt[4] / 2 * 2);
    }
    ans += cnt[1];
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
"use strict";
function Main(input) {
    let Ln = input.split(/\s/).map((v) => v - 0);
    let a = Ln[0], b = Ln[1], c = Ln[2];
    let d = Math.floor(b / a);
    console.log(Math.min(d, c));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  int ans = 0;
  vector<int> v(n), c(n);
  rep(i, n) cin >> v[i];
  rep(i, n) cin >> c[i];
  rep(i, n) if(v[i] - c[i] > 0) ans += v[i]-c[i];
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double sumaFraccion = 0;
        int n = in.nextInt();
        for (int i = 0; i < n; i++) {
            double Ai= in.nextDouble();
            sumaFraccion+= 1.0/Ai;
            
        }
        double resutlado = 1/sumaFraccion;
        System.out.println(resutlado);
    }
}

Measured memory_bytes: 22740
k,n = map(int,input().split())
a = list(map(int,input().split()))
s = []
for i in range(n-1):
    s.append(a[i+1]-a[i])
s.append(k-a[n-1]+a[0])
# print(s)
s.remove(max(s))

print(sum(s))

Measured memory_bytes: 26420
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int N;
    cin >> N;
    vector<int> C(N - 1), S(N - 1), F(N - 1);
    REP(i, N - 1) {
        cin >> C[i] >> S[i] >> F[i];
    }
    REP(i, N) {
        if (i == N - 1) {
            cout << 0 << endl;
            break;
        }
        int t = 0;
        FOR(j, i, N - 1) {
            if (t < S[j]) {
                t = S[j];
            }
            t = (t + F[j] - 1) / F[j] * F[j];
            t += C[j];
        }
        cout << t << endl;
    }

    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int n, m, d[100][100], g[100][100];
int main()
{
    memset(d, 0x3f, sizeof(d));

    cin>>n>>m;
#define rep(i, n) for(int i=0;i<n;++i)
    rep(i, m) {
        int a, b, c; cin>>a>>b>>c;
        --a, --b;
        d[a][b]=d[b][a]=g[a][b]=g[b][a]=c;
    }
    rep(i, n) d[i][i]=0;
    rep(k, n) rep(i, n) rep(j, n)
        d[i][j]=min(d[i][j], d[i][k]+d[k][j]);

    int res=0;
    rep(i, n) rep(j, n) res+=g[i][j]&&d[i][j]<g[i][j];
    cout<<res/2<<endl;
}


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

static int current;

void DFS(int *d, int *f, int **edges, int n, int i)
{
    int j;

    //if(d[i] != 0) {
    //    return;
    //}

    //fprintf(stderr, "%d\n", i);

    if(d[i] == 0) {
        d[i] = current;
        current += 1;
    }
    for(j = 0; j < n; j++) {
        if(edges[i][j] != 0 && d[j] == 0) {
            DFS(d, f, edges, n, j);
            if(f[j] == 0) {
                f[j] = current;
                current += 1;
            }
        }
    }
    if(f[i] == 0) {
        f[i] = current;
        current += 1;
    }
}

int main()
{
    int n;
    int u;
    int k;
    int v;
    int *d;
    int *f;
    int i;
    int j;
    int **edges;


    scanf("%d", &n);
    d = (int *)malloc(sizeof(int) * n);
    f = (int *)malloc(sizeof(int) * n);
    edges = (int **)malloc(sizeof(int *) * n);
    for(i = 0; i < n; i++) {
        d[i] = 0;
        f[i] = 0;
        edges[i] = (int *)malloc(sizeof(int) * n);
        for(j = 0; j < n; j++) {
            edges[i][j] = 0;
        }
    }

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

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

    current = 1;
    for(i = 0; i < n; i++) {
        //fprintf(stderr, "[%d] \n", i);
        if(d[i] == 0) {
            DFS(d, f, edges, n, i);
        }
    }

    for(i = 0; i < n; i++) {
        printf("%d %d %d\n", i+1, d[i], f[i]);
    }

    return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int main()
{
  int a, b, c;
  fscanf(stdin, "%d %d %d", &a, &b, &c);
  double theta =  c * M_PI / 180.0;
  double S = 0.5 * a * b * sin(theta);
  double L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(theta));
  double h = b * sin(theta);
  fprintf(stdout, "%f\n", S);
  fprintf(stdout, "%f\n", L);
  fprintf(stdout, "%f\n", h);
  return 0;
}

Measured memory_bytes: 1224
A,B,C,X,Y=map(int,input().split())
check=[0]*4
check[0]=A*X+B*Y
check[1]=C*max(X,Y)*2
check[2]=C*Y*2+A*(X-Y) if X>Y else float('inf')
check[3]=C*X*2+B*(Y-X) if X<Y else float('inf')
print(min(check))


Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> 	pii;
typedef long long 		ll;
typedef vector<int> 	vi;
#define PI 				3.14159265
#define int				long long
#define f 				first
#define s 				second
#define umap 			unordered_map
#define pb 				push_back
#define eb 				emplace_back
#define ins 			insert
#define all(a) 			a.begin(),a.end()
#define mtup 			make_tuple
#define nl 				'\n'
#define FLASH 			ios_base::sync_with_stdio(false);cin.tie(NULL);
#define maxheap 		priority_queue<ll>
#define minheap 		priority_queue<ll,vector<ll> ,greater<ll>>
#define rep(i,s,e)		for (int i = s; i <= e; i++)
#define repr(i,s,e) 	for (int i = s; i >= e; i--)
#define mem0(a)			memset(a, 0, sizeof(a))
#define mem1(a)			memset(a, -1, sizeof(a))
#define beg(a)			a.begin()
#define sz(x) 			((int)(x.size()))
#define len(str)		((int)(str.length()))
const ll inf = 1e18 + 1;
const int mod = 998244353;
const int maxn = 3e5;
ll modpow(ll a,ll b,int mod = inf) {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 gcd(int a,int b) {return __gcd(a,b);}
int n, h[maxn], mincost = LLONG_MAX, dp[maxn], k;

int solve(int i){
	if (i == 1) return dp[i] = 0;
	if (dp[i] != inf) return dp[i];
	rep(j,1,k) if (i - j >= 1) dp[i] = min(solve(i - j) + abs(h[i - j] - h[i]), dp[i]);
	return dp[i];
}

signed main(){
	FLASH
	cin>>n>>k;
	rep(i,1,n) cin>>h[i];
	rep(i,1,200000) dp[i] = inf;
	cout<<solve(n);
	return 0;
}


Measured memory_bytes: 7040
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int dish[5];
    int time = 0;
    int min_mod = 10;
    for(int i = 0;i < 5; i++){
        cin >> dish[i];
        if(dish[i] % 10 != 0){
            time += (dish[i] / 10) * 10 + (dish[i] % 10) + (10 - dish[i] % 10); 
            min_mod = min(min_mod, (dish[i] % 10));
        }else{
            time += dish[i] / 10 * 10;
        }
    }

    cout << time - (10 - min_mod) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const lli MAX=1e5+3;

int main(){
	lli N,M;
	cin>>N>>M;
	lli sum[MAX];
	sum[0]=0;
	rep1(i,N){
		int A;
		cin>>A;
		sum[i]=(sum[i-1]+A%M)%M;
	}
	sort(sum, sum+N+1);
	sum[N+1]=M;
	int check=sum[0];
	int same=1;
	lli ans=0;
	rep1(i,N+1){
		if(sum[i]==check){
			same++;
		}
		else{
			check=sum[i];
			ans+=(lli)same*(same-1)/2;
			same=1;
		}
	}
	cout<<ans;
}

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

#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define fi first
#define se second
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef long double ld;
typedef string st;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
const ll MOD = 1e9 + 7 ;
const ll INF=1e14;
ll mpow(ll a,ll b,ll p=MOD){a=a%p;ll res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const ll N=800005;
ll dp[1001][1001];
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll h,w;
  cin>>h>>w;
  st a[h];
  forn(i,h) cin>>a[i];
  dp[0][0]=1;
  forn(i,h) forn(j,w)
  {
    if(i==0&&j==0) continue;
    if(a[i][j]=='.')
    {
      if(i-1>=0&&i-1<h) dp[i][j]+=dp[i-1][j];
      dp[i][j]%=MOD;
      if(j-1>=0&&j-1<w) dp[i][j]+=dp[i][j-1];
      dp[i][j]%=MOD;
    }
  }
  cout<<dp[h-1][w-1];
}
//nothing is impossible

Measured memory_bytes: 9088
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <climits>

using namespace std;
typedef pair<int,int> NODE;

int dijk(int a,int b,int n, vector<vector<pair<int,int> > >info){
	priority_queue<NODE,vector<NODE>,greater<NODE> > Q;

	vector<NODE> node(n);
	for(int i=0;i<node.size();i++){
		node[i].first  = INT_MAX;
		node[i].second = i;
	}
	
	node[a].first = 0;	
	Q.push(node[a]);

	while(!Q.empty()){
		NODE now = Q.top();
		Q.pop();
		
		for(int i=0;i<info[now.second].size();i++){
			int to   = info[now.second][i].first;
			int cost = now.first + info[now.second][i].second;
			
			if(cost < node[to].first){
				node[to].first = cost;
				Q.push(node[to]);
			}
		}
	}
	return node[b].first;
}

int main(){
	int n,m,a,b,c,d,ret;
	cin >> n >> m;
		
	vector< vector< pair<int,int> > > info(n);
	
	for(int i=0;i<m;i++){
		scanf("%d,%d,%d,%d\n",&a,&b,&c,&d);
		a--;b--;
		info[a].push_back( make_pair(b,c) );
		info[b].push_back( make_pair(a,d) );
	}

	scanf("%d,%d,%d,%d\n",&a,&b,&c,&d);
	a--;b--;
		
	ret = c-d;

	cout << ret - dijk(a,b,n,info) - dijk(b,a,n,info) << endl;
}

Measured memory_bytes: 0