akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
#include <math.h>
#include <cmath>
#include <map>
#include <algorithm>
#include <functional>


int main()
{
	int N = 0, M = 0;

	std::cin >> N >> M;
	std::vector<std::pair<int, int>>P(M);

	std::string ans;
	for (int i = 0; i < N; i++)
	{
		ans.push_back('A');
	}

	for (int i = 0; i < M; i++)
	{
		int s, c;
		std::cin >> s >> c;
		s--;
	/*	std::pair<int, int>pp = std::make_pair(s, c);
		P.push_back(pp);*/

		if (s == 0 && c == 0){
			if (N != 1)
			{
				ans = "-1";
				break;
			}
		}
		if (ans[s] != 'A')
		{
			if (ans[s] != '0' + c){
				ans = "-1";
				break;
			}			
		}

		ans[s] = '0' + c;
		//std::cout << ans << std::endl;
	}

	if (ans != "-1"){
		for (int i = 1; i < N; i++)
		{
			ans[i] = (ans[i] == 'A') ? ('0' + 0) : ans[i];
		}
		if (ans[0] == 'A')
		{
			if (N != 1){
				ans[0] ='0' + 1;
			}
			else{
				ans[0] = '0' + 0;
			}				
		}
	}

	std::cout << ans << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define MAX 200005
using namespace std;
 
int main(){
  int n, t, ti[MAX], ans = 0;
  scanf("%d%d%d", &n, &t, &ti[0]);
  for(int i = 1; i < n; i++){
    scanf("%d", &ti[i]);
    ans += min(ti[i] - ti[i-1], t);
  }
  ans += t;
  printf("%d\n", ans);
}

Measured memory_bytes: 896
/*
 Author:Alokit Kumar
   */
  #include<bits/stdc++.h>
  using namespace std;
  #define int long long 
  int32_t main()
  {
    int n,m,i,j,k,l,q,s=0;
   string s1;
   cin>>s1;
   n=s1.size();bool hi=true;
   for(i=0;i<n;i++)
   {
     if(i%2==0)
     {
       if(s1[i]=='L')
       {
         hi=false;
         break;
       }
     }
     else
     {
       if(s1[i]=='R')
       {
         hi=false;
         break;
       }
     }
   }
   if(hi) cout<<"Yes";
   else cout<<"No";
  }

Measured memory_bytes: 256
from collections import Counter
n = int(input())
w = [input() for i in range(n)]
c = Counter(w).most_common()
if c[0][1]!=1: ans = "No"
else:
	last,ans = w[0][-1],"Yes"
	for i in w[1:]:
		if last!=i[0]: ans = "No"
		last = i[-1]
print(ans)

Measured memory_bytes: 3436
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    
    int ma=0;
    rep(i,1,n+1){
       if(s.substr(n-i,i)==t.substr(0,i)){
           ma=i;
       }
    }
    
    cout<<n*2-ma<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long double LD;
#define N 50 + 5

int n, A[N];
LD cur;

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++)
		scanf("%d", A + i);
	sort(A + 1, A + n + 1);
	cur = A[1];
	for (int i = 2; i <= n; i ++)
		cur = (cur + A[i]) / 2.0;
	printf("%.9Lf\n", cur);
	return 0;
}

Measured memory_bytes: 128
/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1; const double eps = 1e-6, ldeps = 1e-9;
struct Dbg { static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto o(C *x)->decltype(os << *x, 0);
template<class C> static char o(...);
template<class C> typename enable_if<sizeof o<C>(0)!=1,Dbg&>::type operator<<(const C &x) {os<<x; return *this;}
template<class C> Dbg &dump(C b, C e) {
    for (struct{C i;int j;} i={(*this<<"\n[",b),0}; i.i!=e and i.j<26; i.i++, i.j++) *this<<", "+2*(i.i==b)<<*i.i;
    return *this << ']';
}
template<class C> typename enable_if<sizeof o<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    return dump(begin(x), end(x));
}
template<class C, size_t X> typename enable_if<!is_same<C, const char>::value, Dbg&>::type operator<<(C (&x)[X]) {
    return dump(begin(x), end(x));
}
template<class B, class C> Dbg &operator<<(const pair<B, C> &x) {return *this<<'{'<<x.first<<", "<<x.second<<'}';}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#define cbug(a, args...) if (a) bug(args);
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int T, Q, cn;//}
const int inf = 1000000007, mxn = 200005;
#define im(a, b) if (a>=b) a -= b; else if (a<0) a += b;

int n, firstMod[4], p2Mod[4][mxn], pref[mxn], f[mxn];
char s[mxn];

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    cin >> n >> s;
    for (int i = 1; i <= n; i++) {
        pref[i] = pref[i%__builtin_popcount(i)]+1;
    }
    int cntSet = 0;
    for (int i = 0; i < n; i++) {
        cntSet += s[i] == '1';
    }
    for (int i = 0; i < 3; i++) {
        if (cntSet+i-1 <= 0) continue;
        p2Mod[i][0] = 1%(cntSet+i-1);
        for (int j = 1; j <= n; j++) {
            p2Mod[i][j] = p2Mod[i][j-1]<<1; im(p2Mod[i][j], cntSet+i-1)
        }
        for (int j = 0; j < n; j++) {
            firstMod[i] += (s[j] == '1' ? p2Mod[i][n-1-j] : 0); im(firstMod[i], cntSet+i-1)
        }
    }
    for (int i = 0; i < n; i++) {
        int o = s[i] == '1' ? 0 : 2;
        if (cntSet-1+o == 0) continue;
        int o2 = firstMod[o]+(s[i]=='1' ? -p2Mod[o][n-1-i] : p2Mod[o][n-1-i]); im(o2, cntSet-1+o)
        f[i+1] = pref[o2]+1;
    }
    for (int i = 1; i <= n; i++) {
        cout << f[i] << '\n';
    }
}

Measured memory_bytes: 7764
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    string s;
    cin >> s;
    
    for(int i =0 ; i < s.size(); i++) {
        if(s[i] == ',') {
            s[i] = ' ';
        }
    }
    
    cout << s << endl;
 return 0;   
}

Measured memory_bytes: 256
import scala.annotation.tailrec

object Main extends App {
  val sc = new java.util.Scanner(System.in) 
  sc.useDelimiter("\n")
  val s = sc.next().toList
  val t = Seq('A', 'C', 'G', 'T')
  var max = 0
  println(calc(0, 0, 0))

  @tailrec
  def calc(index: Int, max: Int, part: Int): Int = {
    if (index == s.length) {
      max
    } else if (t.contains(s(index))) {
      if (max < part + 1) {
        calc(index+1, part+1, part+1)
      } else {
        calc(index+1, max, part+1)
      }
    } else {
      calc(index+1, max, 0)
    }
  }
}

Measured memory_bytes: 55560
using System;
using System.Linq;

class Program {
    static void Main(string[] args) {
        var a = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        Array.Sort(a);
        Console.WriteLine(a[0] % 2 != 0 && a[1] % 2 != 0 && a[2] % 2 != 0 ? a[0] * a[1] : 0);
    }
}

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

int main(){
  int A, B;
  cin >> A >> B;
  if (A != 1 && B != 1) {
      cout << 1 << endl;
  } else if(A != 2 && B != 2) {
      cout << 2 << endl;
  } else {
      cout << 3 << endl;
  }
}


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

using namespace std;

long long a[100005], dp[100005], n;

int main () {
    cin >> n;

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

    for(int i = 2; i <= n; ++i){
        if(i > 2)dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
        else dp[i] = abs(a[i] - a[i - 1]);   
    }
    
    cout << dp[n];

    return 0;
}


Measured memory_bytes: 1792
// ABC093
// A - abc og ABC
#include<bits/stdc++.h>

using namespace std;

int main(){
    string s;
    cin >> s;
    if(s[0]!=s[1] && s[1]!=s[2] && s[2]!= s[0]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
#include<time.h>
#define M(a,b) ((a)>(b)?(a):(b))
int main()
{
	char a[20];
	int i,n;
	for(i=0;i<16;i++) scanf("%c",&a[i]);
	n=(a[0]!='C')+(a[1]!='O')+(a[2]!='D')+(a[3]!='E')+(a[4]!='F')+(a[5]!='E')+(a[6]!='S')+(a[7]!='T')+(a[8]!='I')+(a[9]!='V')+(a[10]!='A')+(a[11]!='L')+(a[12]!='2')+(a[13]!='0')+(a[14]!='1')+(a[15]!='6');
    printf("%d",n);
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N,M,S;
int dp[64][3005];

int main(){
  while(scanf("%d%d%d", &N,&M,&S) && N||M||S){
    memset(dp, 0, sizeof dp);
    dp[0][0] = 1;
    for(int i=1;i<=M;i++){
      for(int j=SQ(N);j>=0;j--){
	for(int s=0;s+i<=S;s++){
	  dp[j+1][s+i] = (dp[j+1][s+i] + dp[j][s])%100000;
	}
      }
    }
    printf("%d\n", dp[SQ(N)][S]);
  }
  return 0;
}

Measured memory_bytes: 1944
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a[3];
    for(register int i=0;i<3;i++){
        scanf("%d",a+i);
    }
    sort(a,a+3);
    int ans=a[0]+a[1];
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print a[input() - 1]

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

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n, m;
    cin >> n >> m;
    vector<vector<pair<ll, ll> > > adj(n);
    vector<pair<ll, pair<ll, ll> > > edges;
    for(int i = 0; i < m; i++){
        ll a, b, c;
        cin >> a >> b >> c;
        adj[a - 1].push_back({b - 1, -c});
        edges.push_back({a - 1, {b - 1, -c}});
    }
    vector<ll> dist(n, 1e18);
    dist[0] = 0;
    for(int i = 0; i < n - 1; i++)
        for(int j = 0; j < m; j++){
            if(dist[edges[j].first] < 1e18)
                dist[edges[j].second.first] = min(dist[edges[j].second.first], dist[edges[j].first] + edges[j].second.second);
        }
    ll ans = dist[n - 1];
    for(int i = 0; i < n - 1; i++)
        for(int j = 0; j < m; j++){
            if(dist[edges[j].first] < 1e18)
                dist[edges[j].second.first] = min(dist[edges[j].second.first], dist[edges[j].first] + edges[j].second.second);
        }
    if(dist[n - 1] < ans){
        cout << "inf" << endl;
        return 0;
    }
    cout << -dist[n - 1] << endl;
}

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

using namespace std;

void solve()
{
	int N, M, P;
	while(cin >> N >> M >> P, N || M || P)
	{
		vector<int> Vec(N);
		int sum = 0;
		for(int i = 0; i < N; ++i)
		{
			cin >> Vec[i];
			sum += Vec[i];
		}
		if(Vec[M - 1] == 0)
		{
			cout << 0 << endl;
			continue;
		}
		sum *= (100 - P);
		cout << sum / Vec[M - 1] << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
//p.sum()が不変なので和に注目する。和と言えば累積和なので、累積和を取ってみる。すると交換操作と対応することが分かる。
//l_i > 0より、バブルソートの交換回数を求め、実際に条件を満たすかを判定すればよい。これは、Fenwick(BIT)とsort()でできる。
//末尾の2要素が交換できないことに注意。
#include <iostream>
#include <algorithm>
#include <vector>
#define int long long
using namespace std;
typedef pair<int, int> P;

struct BIT {
	int a[200000];
	int n;
	//add(p, w)…array[p] += w (1-indexed). sum(p)…return array[1] + … + array[p]
	void init(int n) { this->n = n; for (int i = 0; i <= n; i++) a[i] = 0; }
	void add(int p, int w) { for (int i = p; i <= n; i += i & -i) a[i] += w; }
	int sum(int p) { int ret = 0; for (int i = p; i > 0; i -= i & -i) ret += a[i]; return ret; }
};

int n;
int p[100000];
int l[100000];
int rp[100000];
vector<P> pos;
BIT seg;

signed main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> p[i];
	for (i = 0; i < n; i++) cin >> l[i];
	rp[0] = p[0];
	for (i = 1; i < n; i++) rp[i] = rp[i - 1] + p[i];
	
	pos.resize(n - 1);
	for (i = 0; i < n - 1; i++) pos[i] = P(rp[i], i);
	sort(pos.begin(), pos.end());
	
	int swapCnt = 0;
	seg.init(n - 1);
	for (i = 0; i < n - 1; i++) seg.add(i + 1, 1);
	for (i = 0; i < n - 1; i++) {
		swapCnt += seg.sum(pos[i].second);
		seg.add(pos[i].second + 1, -1);
	}
	
	sort(rp, rp + n);
	for (i = 0; i < n; i++) {
		int p_i;
		if (i == 0) p_i = rp[i];
		else p_i = rp[i] - rp[i - 1];
		if (p_i < l[i]) { cout << -1 << endl; return 0; }
	}
	cout << swapCnt << endl;
	return 0;
}


Measured memory_bytes: 7528
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<queue>

using ll = long long;
using p = std::pair<int, int>;
ll n, m;
std::vector<std::vector<int>> f;
std::set<p> check;

void dfs(int u, std::vector<int> &cnt, int color, int pre = -1){
    cnt[u] = color;
    for(int i = 0; i < f[u].size(); i++){
        int next = f[u][i];
        if(next != pre && cnt[next] == -1){
            dfs(next, cnt, color, u);
        }
    }
}

int main(){
    std::cin >> n >> m;
    f.resize(n);
    for(int i = 0; i < m; i++){
        int a, b;
        std::cin >> a >> b;
        a--; b--;
        auto iter = check.find(std::make_pair(a, b));
        if(iter == check.end()){
            check.emplace(a, b);
            check.emplace(b, a);
            f[a].push_back(b);
            f[b].push_back(a);
        }
    }

    int color = 0;
    std::vector<int> cnt(n, -1);
    for(int i = 0; i < n; i++){
        if(cnt[i] == -1){
            dfs(i, cnt, color);
            color++;
        }
    }

    std::vector<std::queue<int>> group(color);
    for(int i = 0; i < n; i++){
        group[cnt[i]].push(i);
    }

    int ans = 0;
    /*
    while(1){
        int num_group = 0;
        for(int i = 0; i < color; i++){
            if(!group[i].empty()){
                num_group++;
                group[i].pop();
            }
        }

        if(num_group == 0) break;
        ans++;
    }
    */

    while(1){
        int num_group = 0;
        int not_zero_min = n;
        for(int i = 0; i < color; i++){
            if(!group[i].empty()){
                num_group++;
                not_zero_min = std::min(not_zero_min, (int)group[i].size());
            }
        }
        
        if(num_group == 0) break;
        ans += not_zero_min;
        if(num_group == 1){
            break;
        }
        // 削りだし
        for(int i = 0; i < color; i++){
            if(!group[i].empty()){
                for(int j = 0; j < not_zero_min; j++){
                    group[i].pop();
                }
            }
        }
    }

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


Measured memory_bytes: 143020
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
int main() {
	int n, t, a[200001];
	cin >> n >> t;
	for (int i = 0; i < n; i++)cin >> a[i];
	int count=a[0], an=0;
	for (int i = 0; i < n; i++) {
		int memo =max(count,a[i]);
		count = a[i] + t;
		an += count - memo;
	}

	cout << an << endl;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <vector>
#include <algorithm>

#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define STRS(i,str) for(int i=0;(str)[i];i++)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX3(a,b,c) ((a)>(b)?(a)>(c)?(a):(c):(b)>(c)?(b):(c))
#define MIN3(a,b,c) ((a)<(b)?(a)<(c)?(a):(c):(b)<(c)?(b):(c))
#define MED(a,b,c) ((a)<(b)?(a)>(c)?(a):(b)<(c)?(b):(c):(a)>(c)?(b)<(c)?(c):(b):(a))
#define RNG(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define RNG3(a,b,c) ((a)>(b)?(b)>(c)?(a)-(c):(c)>(a)?(c)-(b):(a)-(b):(b)>(c)?(c)>(a)?(b)-(a):(b)-(c):(c)-(a))
#define MAXI(a,b) {if((a)<(b))(a)=(b);}
#define MINI(a,b) {if((a)>(b))(a)=(b);}
#define BEGINFOR(a,b,c,d,e,f,g,h,i) a;goto i##_6;i##_2:c;goto i##_6;i##_3:h;goto i##_7;i##_4:d;goto i##_8;i##_5:f;goto i##_8;i##_6:if(b)goto i##_4;else goto i##_9;i##_7:if(g)goto i##_5;else goto i##_1;i##_8:if(e)goto i##_2;else goto i##_3;i##_9:
#define CONTINUE(i) goto i##_3
#define BREAK(i) goto i##_1
#define ENDFOR(i) goto i##_3;i##_1:

int main(){
	int n, k, ans = 0;
	std::vector<int> v(200000);
	scanf("%d%d", &n, &k);
	REP(i, n){
		int a;
		scanf("%d", &a);
		v[a]++;
	}
	std::sort(v.begin(), v.end());
	std::vector<int>::iterator it = v.end();
	REP(i, k){
		--it;
		ans += *it;
	}
	printf("%d\n", n - ans);
}

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

int main() {
  string S1;
  string S2;
  string S3;
  
  char sc1;
  char sc2;
  char sc3;
  
  cin >> S1;
  cin >> S2;
  cin >> S3;
 
  sc1 = S1.at(0);
  sc2 = S2.at(0);
  sc3 = S3.at(0);
  
  cout << sc1 << sc2 << sc3 << endl;
  
 
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int B[4] = {1, 4, 7, 9};
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N[4];
    rep(i, 4) cin >> N[i];
    sort(N, N + 4);
    rep(i, 4) {
        if(N[i] != B[i]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 3624
//
//  main.c
//  B
//
//  Created by s1262004 on 2019/07/19.
//  Copyright © 2019 s1262004. All rights reserved.
//

#include <stdio.h>
int n, timeUsed;
typedef struct node{
    int to[100];
    int edge;
    int color; // 0 -> WHITE, 1 -> GREY, 2 -> BLACK
    int dis, fin;
} node_t;

node_t vertex[100];

void dfs();
void visit(int);

int main(int argc, const char * argv[]) {
    int i, j;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        int key, num;
        scanf("%d %d", &key, &num);
        for (j = 0; j < num; j++) {
            int temp;
            scanf("%d", &temp);
            vertex[key-1].color = 0;
            vertex[key-1].edge = num;
            vertex[key-1].to[j] = temp - 1;
        }
    }
    
    dfs();
    
    for (i = 0; i < n; i++){
        printf("%d %d %d\n", i + 1, vertex[i].dis, vertex[i].fin);
    }
    
    
    return 0;
}

void dfs(){
    int i;
    timeUsed = 0;
    for (i = 0; i < n; i++){
        if (vertex[i].color == 0) visit(i);
    }
}

void visit(int ix){
    int i;
    vertex[ix].color = 1;
    vertex[ix].dis = ++timeUsed;
    
    for (i = 0; i < vertex[ix].edge; i++){
        int link = vertex[ix].to[i];
        //printf("(%d, %d)\n", ix, link);
        if (vertex[link].color == 0) visit(link);
    }
    
    vertex[ix].color = 2;
    vertex[ix].fin = ++timeUsed;
}



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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    vi C(N+1), F(N+1), S(N+1);
    REP1(i, N-1) cin >> C[i] >> S[i] >> F[i];

    REP1(i, N)
    {
        int x = i, t = 0;
        while(x != N)
        {
            t = max(t, S[x]);
            if(t % F[x] != 0) t = (t+F[x]-1)/F[x]*F[x];
            t += C[x];
            x++;
        }
        cout << t << endl;
    }
}
    
int main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long

using pi = pair<int, int>;

typedef tree< pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update>Order_Set;

Order_Set X;

const int mxn = 2e5+100;
const int Mod = 1e9+7;

int arr[mxn], qs[mxn];
int bitOn[55];
map<int,int>Mp, cnt, op;
vector<int>Pi, Ans;
vector<int>G[mxn];
set<int>seet[mxn];

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

int visit[3][100005];
int n, k;

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

    auto loop = [&](int n, int tim) { for(int i=1 ; i<=tim ; i++) cout<<n; cout<<endl;};

    int n, k;
    cin>>n>>k;
    if(n <= k) loop(n, k);
    else loop(k, n);

    return 0;
}





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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    lli a[5] , k ; bool t = true ;
    loopcin(5 , a) ;
    cin >> k ;
    loop(5)
    {
        for (lli j = 1 ; j < 5 ; j ++)
        {
            if (a[j] - a[i] > k)
                t = false ;
        }
    }
    cout << (t ? "Yay!" : ":(" ) ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



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

import sys
input = sys.stdin.readline
lmax,rmin = 1,N

for i in range(M):
  l,r = list(map(int,input().split()))
  if l > lmax:
    lmax = l
  if r < rmin:
    rmin = r

print(max(0,rmin-lmax+1))


Measured memory_bytes: 42348
import sys


def main():
    n = int(sys.stdin.readline().strip())
    v = [int(s) for s in sys.stdin.readline().strip().split()]

    v.sort()

    cur = v[0]
    for i in range(1, len(v)):
        cur = (cur + v[i]) / 2
    print(cur)


main()


Measured memory_bytes: 38384
#include <functional>
#include <iostream>
#include <vector>

int main() {
  int n;
  std::cin >> n;
  std::vector<std::vector<int>> t(n);
  for (int i = 0; i != n - 1; i += 1) {
    int a, b;
    std::cin >> a >> b;
    a -= 1;
    b -= 1;
    t[a].push_back(b);
    t[b].push_back(a);
  }
  int m;
  std::cin >> m;
  std::vector<int> z(1 << m, 0);
  {
    std::vector<int> x(n, 0);
    for (int i = 0; i != m; i += 1) {
      int u, v;
      std::cin >> u >> v;
      u -= 1;
      v -= 1;
      x[u] ^= 1 << i;
      x[v] ^= 1 << i;
    }
    std::function<void(int, int)> dfs = [&](int v, int p) {
      for (int e : t[v]) {
        if (e == p)
          continue;
        dfs(e, v);
        z[x[e]] += 1;
        x[v] ^= x[e];
      }
    };
    dfs(0, n);
  }
  for (int i = 1; i != 1 << m; i <<= 1) {
    for (int j = 0; j != 1 << m; j += 1) {
      if (j & i)
        z[j] += z[j ^ i];
    }
  }

  long long ans = 0;
  for (int i = 0; i != 1 << m; i += 1) {
    auto res = 1LL << z[(1 << m) - 1 ^ i];
    for (int j = 0; j != m; j += 1)
      if (i >> j & 1)
        res = -res;
    ans += res;
  }
  std::cout << ans << std::endl;
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    
    int cnt = 0;
    for (int i=a;i<b;i++){
        if(c <= i && i < d) cnt++;
    }
    
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for _ in range(n):
    s = input()
    if s == "AC":
        ac += 1
    elif s == "WA":
        wa += 1
    elif s == "TLE":
        tle += 1
    else:
        re += 1
print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re)) 

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

int main()
{
  int a, goal;
  cin >> a >> goal;
  int v = 1;
  int cnt = 0;
  while (v < goal) {
    v += a - 1;
    cnt++;
  }
  cout << cnt << '\n';
  return 0;
}


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

 int main(){
  int a,b;
  cin >> a >> b;
  if(a < b){
      cout << "a < b" << endl;
  }else if(a > b){
      cout << "a > b" << endl;
  }else{
      cout << "a == b" <<endl;
  }
  return 0;
 }  


Measured memory_bytes: 3088
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define mod 1000000009
#define e  2.718281828459045
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define ll long long
const int N = 1e9;
string song[55]={""}; 
int tim[55]={0};
int main(){
	int n;
	cin>>n;
	int t=0;
	for(int i=0;i<n;i++){
		cin>>song[i]>>tim[i];
		t+=tim[i];
		tim[i]=t;
	}
	string slp="";
	cin>>slp;
	for(int i=0;i<n;i++){
		if(song[i]==slp){
			cout<<tim[n-1]-tim[i];
			return 0;
		}
	}
	cout<<0;
	return 0;
}


Measured memory_bytes: 256
import sys
n = int(input())
li = []
for _ in range(n):
    i = int(input())
    li.append(i)
li.sort()
s = sum(li)
if s % 10 != 0:
    print(s)
    sys.exit()

for l in li:
    if l%10 != 0:
        s -= l
        break
if s%10 == 0:
    print(0)
else:
    print(s)

Measured memory_bytes: 38256
var output;
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){return null;}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//不明値:何もしない 異常時:文字列「error」を返す（できる？）
//1:数値へ変換 2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字に分割 7:1文字に分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return "error";}}
function Main() {
  var tmp = myconv(next(),4);
  var min = Math.min(tmp[0],tmp[1]);
  var max = Math.max(tmp[0],tmp[1]);
  var output = "";
  for(var i = 0; i < max; i++){
    output += min.toString();
  }
  myout(output);
}


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(),(a).end()

using namespace std;

int main(int argc, char const *argv[]) {
  int sum=0,temp1,temp2,N;
  scanf("%d",&N);
  for (size_t i = 0; i < N; i++) {
    scanf("%d%d",&temp1,&temp2);
    sum+=(temp2-temp1)+1;
  }
  printf("%d\n",sum);
  return 0;
}


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

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

const int INF = 1e9 + 7;

using namespace std;

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

  int n;
  string s;
  cin >> n >> s;

  string res;
  rep (i, 0, s.size()) {
    res +=  'A' + (((s[i] - 'A') + n) % 26);
  }

cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,c,K,i;
    scanf("%d %d %d %d", &a, &b, &c, &K);
    for(i = 0; i < K; i++){
        if(b <= a) b = b * 2;
        else if(c <= b) c = c * 2;
    }
    if(a < b){
        if(b < c) printf("Yes");
        else printf("No");
    }
    return 0;
}

Measured memory_bytes: 1684
/**
       ������������    ������������
		Author : Avi J Patel
		University : DA-IICT
       ������������    ������������
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair 
#define mt make_tuple
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define Mod 998244353
#define N 200001
#define large 10000000000000001
#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    if(a.second < b.second) return true; 
    else if(a.ss==b.ss) return a.ff<b.ff;
	else return false;
}
bool sortbyboth(const pair<int,int> &a, const pair<int,int> &b)
{
	if(a.first<b.first) return true;
	else if(a.first==b.first) return a.second<b.second;
	else return false;
}
int main()
{
	double n;
	cin>>n;
	double r;
	if((int)n%2==0)
	{
		r=n/2;
	}	
	else
	 r=(int)n/2+1;
	cout<<fixed<<setprecision(10);
	cout<<r/n;
	return 0;
}












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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int a;
        cin >> a;
        if((i%2 == 1) && (a%2 == 1)) ans++;
    }
    cout << ans << endl;
    
    return 0;
}

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

int a,b;

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

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> a >> b;

    cout << gcd(a,b) << '\n';
    return 0;
}


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

using namespace std;

int main(void) {
	int a, b;
	cin >> a >> b;
	if ((a % 3 == 0) || (b % 3 == 0) || ((a + b) % 3 == 0)) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}

	return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<int,P> PP;

struct edge {
	int to,cost;
	edge(int t,ll c):to(t),cost(c) {}
};

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

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

int n,m;
ll x[100000],y[100000];
const int MOD=1e9+7;

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

	cin>>n>>m;
	REP(i,n) cin>>x[i];
	REP(i,m) cin>>y[i];

	ll sumx=0,sumy=0;
	REP(i,n) (sumx+=i*x[i]-(n-i-1)*x[i])%=MOD;
	REP(i,m) (sumy+=i*y[i]-(m-i-1)*y[i])%=MOD;

	cout<<(sumx*sumy)%MOD<<endl;

	return 0;
}


Measured memory_bytes: 1792
n = int(input())
s = input()

rw = 0
re = 0
lw = 0
le = 0
ans = 10**9

for i in range(n):
    if s[i:i+1] == "W":
        rw += 1
    else:
        re += 1

if s[0:1] == "W":
    rw -= 1
else:
    re -= 1
if re+lw < ans:
    ans = re + lw

for i in range(1,n):
    if s[i:i+1] == "W":
        rw -= 1
    else:
        re -= 1
    if s[i-1:i] == "W":
        lw += 1
    else:
        le += 1
    if re+lw < ans:
        ans = re + lw
print(ans)

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

using namespace std;

typedef long long ll;

int main(){
	int n;
	cin >> n;
	int abc[n][3];
	for(int i = 0; i < n; i++)cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
	ll hap[n][3] = {0};
	hap[0][0] = abc[0][0];
	hap[0][1] = abc[0][1];
	hap[0][2] = abc[0][2];
	for(int i = 1; i < n; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 3; k++)if(j != k)hap[i][j] = max(hap[i-1][k]+abc[i][j], hap[i][j]);
		}
	}
	cout << max(hap[n-1][0], max(hap[n-1][1], hap[n-1][2])) << endl;
    return 0;
}

Measured memory_bytes: 3712
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
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);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

const long long MOD = 998244353;
// const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

  ll n;
  std::cin>>n;

  std::vector<ll> s(n);
  rep(i,0,n)std::cin>>s[i];

  ll ans=std::numeric_limits<ll>::min();

  rep(i,1,n){
    ll val=0;
    for(ll k=0;k*i<=n-1;k++){
      ll a=n-1-k*i;
      if(i>=a)continue;
      if(a%i==0&&a/i<=k)continue;
      val+=s[k*i]+s[a];
      chmax(ans,val);
    }
  }

  std::cout<<ans<<"\n";

  return 0;
}


Measured memory_bytes: 1024
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define endl "\n"
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
 
//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
 
//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 
//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}
 
//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
//grobal variable
//------------------------------------------
int N,M;
VI Vec;
 
//動的計画法で役に立つ関数
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; }
 
//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}
 
ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a/g*b;
}
 
int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int W, H, x, y;
    cin >> W >> H >> x >> y;
    long double S = W * (H /2.0);
    if (W == 2*x && H == 2*y)
    {
        printf("%.6Lf 1\n", S);
    }
    else
    {
        printf("%.6Lf 0\n", S);
    }
  
    return 0;
}
 


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import qualified Data.Maybe as Maybe

solve :: Int -> Int -> Int
solve a b =
    if (a <= 9 && b <= 9)
        then a * b
        else -1

main = do
    [a, b] <- map (fst . Maybe.fromJust . BS.readInt) . BS.words <$> BS.getLine
    let ans = solve a b
    print ans

Measured memory_bytes: 3776
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << fixed << setprecision(20);
    int n; cin >> n;
    int x=0,y=0,t=0;
    bool check = true;
    rep(i,n){
        int ti; cin >>ti;
        int xx,yy; cin >> xx >> yy;
        if(abs(xx-x)+abs(yy-y) > ti-t){
            check = false;
        } else if(((ti-t) - abs(xx-x)+abs(yy-y)) % 2 == 1){
            check = false;
        }
    }
    if(check) yes();
    else no();
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[m];
		int[] b = new int[m];
		int[] c = new int[m];
		int[] cost = new int[n];
		ArrayDeque<Integer> list = new ArrayDeque<Integer>();
		
		for(int i=0;i<m;i++){
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		
		int k = 0;
		int p = 0;
		list.push(0);
		while(true){
			k = list.size();
			for(int i=0;i<k;i++){
				p = list.pop();
				for(int j=0;j<m;j++){
					if(p==a[j] && cost[p]+c[j]>cost[b[j]]){
						cost[b[j]] = cost[p] + c[j];
						list.push(b[j]);
					}
				}
			}
			if(list.size()==0) break;
		}
		System.out.println(cost[n-1]);
	}	
}

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

#define ll long long
#define ar array

void solve() {
    double l;
    cin >> l;
    double res = l * l * l / 27;
    cout << res << endl;
}

int main() {
    int L;
    scanf("%d",&L);
    printf("%.12f\n",(double)L*L*L/27);
}



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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define prinp(p) cout<<p.first<<" "<<p.second<<endl
#define prinv(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int in=f;in<f+n;in++) cin>>V[in]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD = 1e9+7,MAX = 1e6+5;
const ll INF = 1e18+5;

int main()
{
	string s,t;
	cin>>s>>t;
	int ns=s.length();
	int nt=t.length();
	int ans = MOD;
	for(int i=0;i+nt-1<ns;i++)
	{
		int temp=0;
		for(int j=0;j<nt;j++)
		{
			if(s[i+j]!=t[j]) temp++;
		}
		ans = min(ans,temp);
	}
	cout<<ans<<endl;
}	

Measured memory_bytes: 3632
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    s = S()
    t = S()
    ans = inf
    for i in range(len(s)-len(t) + 1):
        diff_cnt = 0
        for j in range(len(t)):
            if i + j >= len(s):
                continue
            if t[j] == s[i+j]:
                continue
            else:
                diff_cnt += 1
        ans = min(ans, diff_cnt)
    print(ans)


main()



Measured memory_bytes: 78280
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

int main()
{
    int n,i;
    string s1,s2;
    cin>>n;
    cin>>s1;
    cin>>s2;
    for(i=0;i<n;i++)
        cout<<s1[i]<<s2[i];
    cout<<"\n";
    return 0;
}


Measured memory_bytes: 256
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=5e5+4;

int main()
{
	int s,w;

	cin>>s>>w;

	if(w>=s)
	cout<<"unsafe";
	else
	cout<<"safe";

    return 0; 
}

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

int main(){
  string S,T;
  int A,B;
  string U;
  cin>>S>>T>>A>>B>>U;
  if(S==U){
    A--;
  }else{
    B--;
  }
  
  cout<<A<<" "<<B<<endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	Scanner sc = new Scanner(System.in);

	int[][][] ink=new int[][][]{
		null,
		new int[][]{
			new int[]{0,0},
			new int[]{1,0},
			new int[]{0,1},
			new int[]{-1,0},
			new int[]{0,-1}
		},
		new int[][]{
			new int[]{0,0},
			new int[]{1,0},
			new int[]{0,1},
			new int[]{-1,0},
			new int[]{0,-1},
			new int[]{1,1},
			new int[]{-1,1},
			new int[]{-1,-1},
			new int[]{1,-1}
		},
		new int[][]{
				new int[]{0,0},
				new int[]{1,0},
				new int[]{0,1},
				new int[]{-1,0},
				new int[]{0,-1},
				new int[]{1,1},
				new int[]{-1,1},
				new int[]{-1,-1},
				new int[]{1,-1},
				new int[]{2,0},
				new int[]{-2,0},
				new int[]{0,2},
				new int[]{0,-2}
			}
	};
	
	public void run() {
		int[][] map=new int[10][10];
		while (sc.hasNext()) {
			String str=sc.nextLine();
			String[] sa=str.split(",");
			int x=Integer.parseInt(sa[0]);
			int y=Integer.parseInt(sa[1]);
			int size=Integer.parseInt(sa[2]);
			for(int i=0;i<ink[size].length;i++){
				int _x=x+ink[size][i][0];
				int _y=y+ink[size][i][1];
				if(0<=_x&& _x <10 &&0<=_y && _y<10)
					map[_x][_y]++;
			}
		}
		int white=0;int max=0;
		for(int x=0;x<10;x++)
			for(int y=0;y<10;y++){
				if(map[x][y]==0)white++;
				if(max<map[x][y])max=map[x][y];
			}
		ln(white);
		ln(max);
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
using namespace std;

int main() {

	long A, B, C, ans;

	cin >> A >> B >> C;

	ans = min(B + C, A + B + B + 1); //毒入りを全部食べられるなら、B + C. 全部食べられないなら(解毒剤+ 1)+ B.

	cout << ans << endl;

}

Measured memory_bytes: 256