akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
  ll k,a,b; cin>>k>>a>>b;
  ll now=1;
  if(k%2==1){
    now++; k--;
  }
  ll n=k/2;
  for(int i=0;i<n;i++){
    if(a+2<=b){
      if(now>=a){
        now+=(b-a);
      }else{
        now+=2;
      }
    }else{
      now+=2;
    }
  }
  cout<<now<<endl;
}

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

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >>d;
    ll ans = INF;
    if (a*d > ans) ans = a*d;
    if (a*c > ans) ans = a*c;
    if(b*d > ans) ans = b*d;
    if(b*c > ans) ans = b*c;
    cout << ans << endl;
}

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

using namespace std;

const string du[] = {".", ".", "#", "#"};
const string dd[] = {".", "#", ".", "#"};

char s[77];

string ask(string u, string d) {
  printf("%s\n%s\n", u.c_str(), d.c_str());
  fflush(stdout);
  scanf("%s", s);
  return s;
}

int main() {
  int n;
  scanf("%d", &n);
  string u = "", d = "";
  int sw = 0;
  while (true) {
    int j;
    for (j = 0; j < 4; ++j) {
      string r = (sw == 0 ? ask(u + du[j], d + dd[j]) : ask(du[j] + u, dd[j] + d));
      if (r == "end") {
        return 0;
      }
      if (r == "T") {
        break;
      }
    }
    if (j == 4) {
      sw = 1 - sw;
      continue;
    }
    if (sw == 0) {
      u += du[j];
      d += dd[j];
    } else {
      u = du[j] + u;
      d = dd[j] + d;
    }
  }
}

Measured memory_bytes: 724
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
map<ll,ll> f;
ll n; 
inline void read(ll &x)
{
	ll f;char c;
	for (f=1,c=getchar();c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for (x=0;c<='9'&&c>='0';c=getchar()) x=x*10+(c&15);x*=f;
}
inline ll fun(ll x)
{
	if(f[x]!=0) return f[x];
	else return f[x]=(fun(x/2)+fun((x-1)/2)+fun((x-2)/2))%mod; 
}
int main()
{
	f[0]=1;
	f[1]=2; 
	read(n);
	printf("%lld\n",fun(n));	
	return 0;
}



Measured memory_bytes: 256
using System;
//using System.Collections;
//using System.Collections.Generic;
using System.Linq;

namespace problem
{
  class Test
  {
    static void Main()
    {
      var s = Console.ReadLine().Split().Select(int.Parse).ToArray();
      int temp;

      for (int i = 0; i < 2; i++)
      {
        if (s[i] > s[i+1]) { temp = s[i+1]; s[i+1] = s[i]; s[i] = temp; }
      }
      if (s[0] > s[1]) { temp = s[1]; s[1] = s[0]; s[0] = temp; }
      Console.WriteLine(s[0] + " " + s[1] + " " + s[2]);
    }
  }
}


Measured memory_bytes: 9592
//c
#include <iostream>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <functional>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>

#define REP(i,b,n) for(int i=b;i<n;i++)
#define REPR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PB push_back
#define MP make_pair

using namespace std;

static const double PI = acos(-1.0);
static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> pii;

ll d, n, m;

int main(){
	
	while(cin>>d,d){
		
		vector<ll> shop;
		cin>>n>>m;
		
		shop.push_back(0);
		shop.push_back(d);
		shop.push_back(-d);
		
		for(ll i=0; i<n-1; ++i){
			
			ll a;
			cin>>a;
			shop.push_back(a-d);
			shop.push_back(a);
			shop.push_back(a+d);
		}
		
		sort(shop.begin(), shop.end());
		
		ll res = 0;
		
		for(ll i=0; i<m; ++i){
			
			ll a;
			cin>>a;
			
			vector<ll>::iterator it = upper_bound(shop.begin(), shop.end(), a);
			
			res += min( *it - a, a - *(it-1));
		}
		
		cout << res << endl;
	}
	
	return 0;
}

Measured memory_bytes: 5724
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
	


int main() {
	string s;
	cin >> s;
	int cnt = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == '1') cnt++;
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc130/tasks/abc130_c
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        w: i64, h: i64, x: i64, y: i64
    };
    println!("{} {}", ((w*h) as f64) / 2f64, ifv!(x * 2 == w && y * 2 == h, 1, 0));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 1e5 + 5;
const ll LINF = 1e18 + 5;
constexpr int mod = 1e9 + 7;
int n, k, f[N], c[N];
vector <int> G[N];
ll powmod(ll a, ll b)
{
	ll ans = 1;
	while(b)
	{
		if(b&1) ans = ans*a%mod;
		a = a*a%mod;
		b >>= 1;
	}
	return ans;
}
void dfs(int u, int fa)
{
	int pre = 0;
	f[u] = fa;
	for(int v : G[u])
	{
		if(v==fa) continue;
		dfs(v, u);
		c[v] = c[pre] + 1;
		pre = v;
	}
}
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> k;
 	for(int i=1; i<n; i++) 
 	{
 		int u, v;
 		cin >> u >> v;
 		G[u].pb(v); G[v].pb(u);
 	}
 	c[0] = -1;
 	dfs(1, 0);
 	ll ans = 1;
 	for(int i=1; i<=n; i++)
 	{
 		if(f[i]) c[i]++;
 		if(f[f[i]]) c[i]++;
 		if(k-c[i]<0) ans = 0;
 		ans = ans*(k-c[i])%mod;
 	}
 	cout << ans;
	return 0;
}


Measured memory_bytes: 11264
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  ll a=0,b=0;
  char s[LIMIT1];
  
  scanf("%s",s);
  scanf("%lld",&k);
  j=1;
  n = strlen(s);
  rep(i,n){
	if(i!=n-1&&s[i]==s[i+1]) j++;
    else{
      result += (ll)floorl(j/2.0);
      j=1;
    }
  }
  a=1;
  b=1;
  rep(i,n-1){
    if(s[i]!=s[i+1]) break;
    a++;
  }
  per(i,n-1){
    if(s[i]!=s[i+1]) break;
    b++;
  }
  result *= k;
  if(s[0]==s[n-1]){
    if(a==b && a==n) result = (ll)floorl(n*k/2);
    else result -= (k-1)*(ll)(floorl(a/2.0)+floorl(b/2.0)-floorl((a+b)/2.0));
  }
  printf("%lld",result);
  return 0;
}



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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

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

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//main code

int main(int argc, char const* argv[])
{
	int n,m;
	cin >> n >> m;
	VL imos(n+1,0), rui(n+1,0);
	for (int i = 0; i < m; i++) {
		int l,r;
		cin >> l >> r;
		l--;r--;
		imos[l]++;
		imos[r+1]--;
	}
	rui[0] = imos[0];
	LL ans = 0;
	if (rui[0] == m) {
		ans++;
	}
	for (int i = 1; i < n+1; i++) {
		rui[i] = rui[i-1] + imos[i];
		if (rui[i] == m) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <queue>
#include <algorithm>
using namespace std;

int res;

int main() {
	int n,i;
	cin>>n;
	int v[n],c[n];
	for(i=0;i<n;i++) cin>>v[i];
	for(i=0;i<n;i++) cin>>c[i];
	for(i=0;i<n;i++){
		if(v[i]-c[i]>0) res += v[i]-c[i];
	}
	cout<<res;
 	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 4
#define TIME 60

int main(){
  int i, data, sum=0, x, y;

  for(i=0; i<N; i++){
    scanf("%d", &data);
    sum += data;
  }

  x = sum / TIME;
  y = sum % TIME;

  printf("%d\n%d\n", x, y);
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int n;cin >> n;
    int arr[n];
    for(int i = 0;i < n;i++)cin >> arr[i];
    for(int i = 0;i < n;i++)
    {
        if(arr[i]%2 == 0)
        {
            if(arr[i]%3 != 0 && arr[i]%5 != 0)
            {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}


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

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

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

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    a = root(a);
    return -Parent[a];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(a < b) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }

  bool issame(int a, int b){
    return root(a) == root(b);
  }
};

int n;

bool dfs(int v, vvi &G, vi &color,int col = 0){
  color[v] = col;
  rep(nv,n) {
    if(G[v][nv] == 1e9 || v == nv) continue;
    if(color[nv] == -1){
      if(!dfs(nv, G, color, 1-col)) return false;
    }
    else{
      if(color[v] == color[nv]) return false;
    }
  }

  return true;
}

int main(){
  cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s[i];

  vvi G(n,vi(n));
  rep(i,n) rep(j,n) {
    if(i == j) G[i][i] = 0;
    else if(s[i][j] == '1') G[i][j] = 1;
    else if(s[i][j] == '0') G[i][j] = 1e9;
  }

  vi color(n,-1);
  
  bool bip = dfs(0, G, color);

  if(!bip){
    cout << -1 << endl;
    return 0;
  }


  rep(k,n) rep(i,n) rep(j,n) chmin(G[i][j], G[i][k] + G[k][j]);

  int ans = 0;
  rep(i,n) rep(j,n) {
    if(G[i][j] == 1e9) continue;
    chmax(ans, G[i][j]);
  }

  cout << ans + 1 << endl;

}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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; }

string S;
int y,m,d;

int main(){
    cin>>S;
    if(S[6]>='5'||S[5]=='1'){
        out("TBD");
    }
    else{
        out("Heisei");
    }
}


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

int main(){
    int n;
    int ans=0;
    cin >> n;
    vector<vector<int>> data(n, vector<int>(2));
 
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 2; j++) {
        cin >> data.at(i).at(j);
        }
    }

    for(int k=0;k<n;k++){
        ans += (data.at(k).at(1)-data.at(k).at(0)+1);
    }

    cout << ans << endl;

  return 0;
}

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

bool search(int64 p, int64 q) {
  for (int64 a = 1;; ++a) {
    int64 a2 = a * a;
    if (a2 > q) return false;
    int64 a3 = a2 * a;
    if (a3 > q) return false;
    int64 a4 = a3 * a;
    if (a4 > q) return false;
    int64 b = a - p;
    int64 s = a4 + a3 * b + a2 * b * b + a * b * b * b + b * b * b * b;
    if (s == q) {
      cout << a << " " << b << endl;
      return true;
    }
  }
}

void solve(long long X) {
  for (int64 p = 1; p * p <= X; ++p) {
    int64 r = 1;
    int64 x = X;
    while (x % p == 0) {
      x /= p;
      r *= p;
      if (search(min(x, r), max(x, r))) {
        exit(0);
      }
      if (p == 1) break;
    }
  }
}

int main() {
  long long X;
  cin >> X;
  solve(X);
}


Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <vector>
#include <tuple>
#include <algorithm>

using namespace std;
int main() {
	int n, m;
	cin >> n >> m;

	vector<tuple<int, int, int>> v(m);
	
	for (int i = 0; i < m; ++i) {
		cin >> get<0>(v[i]) >> get<1>(v[i]);
		get<2>(v[i]) = i;
	}
	
	sort(v.begin(), v.end());
	
	int p = 1, count = 1;
	for (int i = 0; i < m; ++i) {
		if (p != get<0>(v[i])) {
			p = get<0>(v[i]);
			count = 1;
		}
		
		get<1>(v[i]) = count;
		++count;
	}
	
	sort(v.begin(), v.end(),
		 [] (tuple<int, int, int> &l, tuple<int, int, int> &r) { return get<2>(l) < get<2>(r); });
			 
	for (int i = 0; i < m; ++i) {
		cout << setfill('0') << setw(6) << get<0>(v[i]) << setfill('0') << setw(6) << get<1>(v[i]) << endl;
	}
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=9999999999999999;

bool func(string s){
  string k(s.rbegin(),s.rend());
  return s==k;
}

int main() {
   string S;
   cin>>S;
   int N=S.size();
   if(func(S)&&func(S.substr(0,(N-1)/2))&&func(S.substr((N+1)/2))){cout<<"Yes"<<endl;}
   else{cout<<"No"<<endl;}
return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int         long long
#define mod         1000000007
#define FAST        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n)      for(int i=0;i<n;i++)
#define fp(i,k,n)   for(int i=k;i<=n;i++)
#define fr(i,k,n)   for(int i=k;i>=n;i--)
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define dbg(x)      cout << (#x) << " is " << (x) << '\n' 
#define F           first
#define S           second
#define sz(x)       (int)(x).size()
#define lb          lower_bound
#define ub          upper_bound
#define all(a)      a.begin(),a.end()
#define getc getchar_unlocked
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
/*---------------------------------------------------------------------------------------------------*/

void solve()
{
  int n;
  string s;
  s="";
  cin >> n;
  while(n>0)
  {
    int val=(n%26);
    if(val==0)
      {val=26;n--;}
    s.pb(('a'+val-1));
    n/=26;
  }
  reverse(all(s));
  cout << s << '\n'; 
  return;
} 

signed main()
{
  FAST
  int T=1;
//   cin >> T;
  while(T--)
  {
    solve();
  }
  return 0;
}


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

const int INF = (int)1e9 + 1;

int d1[100][100], d2[100][100];

int main() {
	while (1) {
		int n, m;
		cin >> n >> m;
		if (n == 0 && m == 0) break;

		for (int i = 0; i < m; i++) {
			for (int j = 0; j < m; j++) {
				if (i == j) {
					d1[i][j] = 0;
					d2[i][j] = 0;
				}
				else {
					d1[i][j] = INF;
					d2[i][j] = INF;
				}
			}
		}
		for (int i = 0; i < n; i++) {
			int a, b, c, t;
			cin >> a >> b >> c >> t;
			a--; b--;
			d1[a][b] = d1[b][a] = c;
			d2[a][b] = d2[b][a] = t;
		}
		for (int k = 0; k < m; k++) {
			for (int i = 0; i < m; i++) {
				for (int j = 0; j < m; j++) {
					d1[i][j] = min(d1[i][j], d1[i][k] + d1[k][j]);
					d2[i][j] = min(d2[i][j], d2[i][k] + d2[k][j]);
				}
			}
		}
		int k;
		cin >> k;
		for (int i = 0; i < k; i++) {
			int p, q, r;
			cin >> p >> q >> r;
			p--; q--;
			if (r == 0) {
				cout << d1[p][q] << endl;
			}
			else {
				cout << d2[p][q] << endl;
			}
		}
	}
}


Measured memory_bytes: 3184
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;

static const int INFTY = (1<<21);
enum Color{
    WHITE,
    GRAY,
    BLACK
};
int n;

int M[100][100];
Color color[100];
int d[100];
int q[100];

int prim(){
    for(int i=0; i<n; i++){
        color[i] = WHITE;
        d[i] = INFTY;
    }
    d[0] = 0;
    q[0] = -1;

    while(true){
        int minv = INFTY;
        int u = -1;
        //点決定
        for(int i=0; i<n; i++){
            if(minv > d[i] && color[i]!=BLACK){
                u = i;
                minv = d[i];
            }
        }
        if(u == -1) break;
        color[u] = BLACK;
        for(int v=0; v<n; v++){
            if(color[v]!=BLACK && M[u][v]!=INFTY){
                if(d[v]>M[u][v]){
                    d[v] = M[u][v];
                    q[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    int sum = 0;
    for(int i=0; i<n; i++){
        if(q[i]!=-1) sum+=M[i][q[i]];
    }
    return sum;
}

int main(){

    scanf("%d", &n);

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            int x;
            scanf("%d", &x);
            if(x==-1) M[i][j] = INFTY;
            else M[i][j] = x;
        }
    }
    int x = prim();

    printf("%d\n", x);

    return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++)cin>>a[i];
  int x=a[0];
  for(int i=1;i<N;i++)x^=a[i];
  if(x==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>

#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e10

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; }
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
typedef std::pair<ll, ll> P;

using namespace std;

bool pairCompare(const P& f, const P& s){
    return f.first < s.first;
}

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> b(n);
    rep(i, n){
        b[i] = a[i] - (i+1);
    }
    sort(all(b));

    ll p;
    if(n % 2 == 1){
        p = (n-1)/2;
    }else{
        p = ((n/2) + (n/2-1))/2;
    }

    ll q = b[p];
    ll ans = 0;
    rep(i, n){
        ans += abs(b[i]-q);
    }

    cout << ans;

}


Measured memory_bytes: 3328
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define repp(a,b,c,d) for(int a=b; a<=c; a+=d)
#define rep(a,b,c) repp(a,b,c,1)
#define revv(a,b,c,d) for(int a=b; a>=c; a-=d)
#define rev(a,b,c) revv(a,b,c,1)
typedef long long ll;

int main()
{
	char ft[55],sc[55];
	scanf("%s",ft);
	scanf("%s",sc);
	int lg=strlen(ft)-1,lg2=strlen(sc)-1;
	rep(i,0,lg)
	{
		printf("%c",ft[i]);
		if(i<=lg2) printf("%c",sc[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
S=list(input())
N=len(S)
ans1=0
ans2=0
for i in range(N): #101010...
    if i%2==0 and S[i]!='1':
        ans1+=1
    if i%2==1 and S[i]!='0':
        ans1+=1
for i in range(N): #01010...
    if i%2==0 and S[i]!='0':
        ans2+=1
    if i%2==1 and S[i]!='1':
        ans2+=1
print(min(ans1,ans2))

Measured memory_bytes: 49392
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> grh;
vector<int> ord, low;
vector<pair<int, int>> brg;
int cnt;
void dfs (int crr, int prt) {
  low[crr] = ord[crr] = cnt++;
  for (int nxt : grh[crr]) {
    if (ord[nxt] == -1) {
      dfs(nxt, crr);
      if (ord[nxt] == low[nxt]) brg.push_back({crr, nxt});
      low[crr] = min(low[crr], low[nxt]);
    } else if (nxt != prt) {
      low[crr] = min(low[crr], ord[nxt]);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  grh.resize(n);
  ord.resize(n, -1);
  low.resize(n);
  for (int i = 0; i < m; i++) {
    int s, t;
    cin >> s >> t;
    grh[s].push_back(t);
    grh[t].push_back(s);
  }
  cnt = 0;
  dfs(0, 0);
  for (auto& p : brg) {
    int& crr = p.first;
    int& nxt = p.second;
    if (crr > nxt) swap(crr, nxt);
  }
  sort(brg.begin(), brg.end());
  for (auto p : brg) {
    int crr = p.first;
    int nxt = p.second;
    cout << crr << ' ' << nxt << '\n';
  }
  return 0;
}


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

int main() {
  int K;
  cin >> K;
  int sum = 0;
  int g,k;
  if (K%2 == 0) {
    g = K/2;
    k = K/2;
  }
  else {
    g = (K-1)/2;
    k = (K+1)/2;
  }
  cout << g*k << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
// #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define forn(i,o,n) for(int i=o;i<n;i++)
#define int long long
// #define endl "\n"
#define mod 1000000007
#define double long double
#define pb push_back
#define swap(x,y) (x^=y^=x^=y)
using namespace std;

int32_t main(){
     #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout); 
    #endif
    int n,w;
    cin>>n>>w;
    vector<int> wt(n);
    std::vector<int> v(n);

    for(int i=0;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        wt[i]=a;
        v[i]=b;
    }


    int dp[n+1][w+1];
    for(int i=0;i<n+1;i++)
    {
        dp[i][0]=0;
    }
    for(int i=0;i<w+1;i++)
        dp[0][i]=0;
    for(int i=1;i<n+1;i++)
    {
        for(int j=1;j<w+1;j++)
        {
            if(i==0||j==0)
            {
                dp[i][j]==0;
            }
            else  if(wt[i-1]<=j)
            {
                dp[i][j]=max((v[i-1]+dp[i-1][j-wt[i-1]]),dp[i-1][j]);
            }
            else
            {
                dp[i][j]=dp[i-1][j];
            }  
        }
    }
    int ans=dp[n][w];
    /*for(int i=0;i<w+1;i++)
    {
        ans=max(ans,dp[n][i]);
    }*/
    cout<<ans<<endl;
}

Measured memory_bytes: 82532
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tp3 = tuple<int, int, int>;
using Mat = vector<vector<ll>>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
template<typename T>
T minch(T& l, T& r) {
    return l = min(l, r);
}
template<typename T>
T maxch(T& l, T& r) {
    return l = max(l, r);
}
template<typename T>
void output(const T& val) {
    cout << val << endl;
}
template<typename T>
void output(const vector<T>& vec, const bool newline = false) {
    for (const T& val : vec)cout << val << (newline ? '\n' : ' '); cout << endl;
}
template<typename T>
void output(const vector<vector<T>>& mat) {
    for (const auto& row : mat)output(row);
}
// ============ template finished ============
struct Node {
    ll size;
    ll diff; // b-a
    ll initDiff;
    ll parent;
    ll makeCost;
};
ll N, res = 0;
Mat graph;
vector<Node> nodes;
void dfs(ll now, ll parent) {
    auto& node = nodes[now];
    node.parent = parent;

    vector<pair<ll, ll>> childs;
    for (ll next : graph[now])if (next != parent) {
        dfs(next, now);
        childs.push_back({ nodes[next].size, nodes[next].diff });
    }
    if (childs.empty())return;

    ll acts = 0;
    for (auto& child : childs)acts = min(acts, child.second);
    acts = -acts;
    if (acts > 0) {
        node.makeCost += acts;
        for (auto& child : childs)child.second += acts;
        node.diff -= acts * graph[now].size();
        if (parent != -1) nodes[parent].diff += acts;
    }
    for (auto& child : childs) {
        ll cost = child.first*child.second;
        node.makeCost += cost;
        node.diff += child.second;
        node.size += child.first;
    }
    res += node.makeCost;
}


int main()
{
    cin >> N;
    graph.resize(N);
    rep(i, N - 1) {
        ll u, v;
        cin >> u >> v;
        u--; v--;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    {
        vector<ll> a(N), b(N);
        rep(i, N)cin >> a[i];
        rep(i, N)cin >> b[i];
        rep(i, N) {
            Node node;
            node.diff = node.initDiff = a[i] - b[i];
            node.size = 1;
            node.makeCost = 0;
            nodes.push_back(node);
        }
    }
    dfs(0, -1);
    //cerr << "---" << endl;
    output(res);
    return 0;
}



Measured memory_bytes: 23760
#include <stdio.h>
#include <math.h>

int a(long long b);

int main(void){
    long long n, n2;
    int i, j, min, ans;
    scanf("%lld", &n);
    n2 = sqrt(n);
    min = n2;
    for(i=1; i<=n2; i++){
        if(n%i == 0){
            long long b = n / i;
            ans = a(b);
            if(ans<min){
                min = ans;
            }
        }
    }
    printf("%d\n", min);
    return 0;
}

int a(long long b){
    int t;
    if(b==0){ return 0; }
    else{ 
        b /= 10;
        t = 1 + a(b);
    }
    return t;
}

Measured memory_bytes: 128
/*Hey, What's up?*/

#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector<long long>v,vc;
int main()
{
    fastio;
    long long a=0,b=0,c,d,e,f=0,l,g,m,n,k,i,j,t,p,q,lo,hi,mid;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>a;
        v.push_back(a);
        vc.push_back(a);
    }
    lo=0;
    hi=vc[0];
    while(lo<=hi)
    {
        for(i=0; i<n; i++)
        {
            vc[i]=v[i];
        }
        mid=(lo+hi)/2;
        a=mid;
        for(i=0; i<n; i++)
        {
            vc[i]-=a;
            vc[(i-1+n)%n]-=a;
            a=vc[i];
        }
        if(vc[n-1]==0)
        {
            f=mid;
            break;
        }
        else if(vc[n-1]>0)
            lo=mid+1;
        else
            hi=mid-1;

    }
    a=f;
    for(i=0; i<n; i++)
    {
        cout<<2*a<< ' ';
        v[i]-=a;
        v[(i-1+n)%n]-=a;
        a=v[i];
    }
    return 0;
}


Measured memory_bytes: 3180
#include <iostream>

using namespace std;

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;

  vll ni, san, roku;

  for(int i=2;i<=30000;i++){
    if(i%6==0) roku.push_back(i);
    else if(i%3==0) san.push_back(i);
    else if(i%2==0) ni.push_back(i);
  }

  if(n==3){
    std::cout << "2 5 63" << '\n';
  }else if(n>=4){
    vll ans;
    ll f = min((ll)ni.size(), n-2);
    if(f%2) f--;
    ll s = min(n-f, (ll)san.size());
    if(s%2) s--;
    re(i, f) ans.push_back(ni[i]);
    re(i, s) ans.push_back(san[i]);
    re(i, n-f-s) ans.push_back(roku[i]);
    re(i, ans.size()) std::cout << ans[i] << (i==ans.size()-1?"\n":" ");
  }
  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 100011

int n, i;
int a[maxN];

int cmmdc(int a, int b) {
    if (a < b) swap(a, b);

    while (b != 0) {
        a %= b;
        swap(a, b);
    }

    return a;
}

bool solve() {
    int i;
    int even, odd, aux;

    even = odd = 0;
    for (i = 1; i <= n; i++) {
        if (a[i] & 1)
            odd++;
        else
            even++;
    }

    if (even & 1)
        return true;

    if (odd >= 2)
        return false;

    if (odd != 1) cerr << "error";

    for (i = 1; i <= n; i++) {
        if (a[i] & 1) {
            a[i] ^= 1;
            if (a[i] == 0) return false;
        }
    }

    aux = a[1];
    for (i = 2; i <= n; i++) aux = cmmdc(aux, a[i]);
    for (i = 1; i <= n; i++) a[i] /= aux;

    return !solve();
}

int main()
{
  //  freopen("test.in","r",stdin);

    scanf("%d", &n);
    for (i = 1; i <= n; i++) scanf("%d", &a[i]);

    if (solve())
        printf("First\n");
    else
        printf("Second\n");


    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

struct Rollinghash{
    string S;
    int n;
    vector<unsigned long long int> powb1;
    vector<unsigned long long int> powb2;
    vector<unsigned long long int> H1;
    vector<unsigned long long int> H2;
    unsigned long long int B1 = 1000007;
    unsigned long long int B2 = 1000009;
    unsigned long long int M1 = 1000000007;
    unsigned long long int M2 = 1000000009;

    Rollinghash(string S):S(S){
        n=(int)(S.size());
        H1.resize(n+1);
        H2.resize(n+1);
        powb1.resize(n+1);
        powb2.resize(n+1);
        init();
    }
    void init(){
        unsigned long long int p1 = 1;
        unsigned long long int p2 = 1;
        powb1[0] = p1;
        powb2[0] = p2;
        H1[0] = 0;
        H2[0] = 0;
        for(int i=1;i<=n;i++){
            powb1[i] = (powb1[i-1]*B1)%M1;
            powb2[i] = (powb2[i-1]*B2)%M2;
        }
        for(int i=1;i<=n;i++){
            H1[i] = (H1[i-1]*B1 + S[i-1])%M1;
            H2[i] = (H2[i-1]*B2 + S[i-1])%M2;
        }
    }
    //[l,r)
    pair<unsigned long long int,unsigned long long int> hash(int l,int r){
        return make_pair( (H1[r] - (H1[l] * powb1[r-l])%M1 + M1)%M1,(H2[r] - (H2[l] * powb2[r-l])%M2 + M2)%M2 );
    }
}; 

int main(){
    string T,P;
    cin >> T >> P;
    if((int)(T.size()) < (int)(P.size())){
        return 0;
    }

    Rollinghash Rt(T),Rp(P);
    int m = P.size();

    for(int i=0;i<T.size();i++){
        if(Rt.hash(i,i+m)==Rp.hash(0,m)){
            cout << i << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 36400
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows * * * * * * */
#include         <bits/stdc++.h>
using namespace std;
#pragma GCC      optimize ("Ofast")
#pragma GCC      optimize ("unroll-loops")
#pragma GCC      target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define IOS      ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC     cout.precision (10); cout << fixed
#define bg(x)    " [ " << #x << " : " << (x) << " ] "
#define x        first
#define y        second
using ll = long long;
using ff = long double;
using pii = pair<int,int>;

#define debug(args...) { \
/* WARNING : do NOT compile this debug func calls with following flags: // \
 * // -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2*/ \
   string _s = #args; replace(_s.begin(), _s.end(), ',', ' ');\
   stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); \
}
void err(istream_iterator<string> it) { it->empty();
   cerr << " (Line : " << __LINE__ << ")" << '\n';
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << fixed << setprecision(15) << " [ " <<  *it << " : " << a  << " ] "<< ' ';
	err(++it, args...);
}

const int N = (int)1e5 + 10;

vector < vector <int>> adj;
vector <int> order;
int dp[N];
bool vis[N];
int n, m;

void dfs (int u) {
   vis[u] = true;
   for (int v : adj[u]) if (!vis[v]) dfs (v);
   order.push_back(u);
}

void solve() {
   fill (vis, vis + n, false);
   fill (dp, dp + n, 0);
   for (int u = 0; u < n; ++u) if (!vis[u]) dfs (u);

   reverse(order.begin(), order.end());

   for (int u : order) {
      for (int v : adj[u]) dp[v] = max(dp[v], dp[u] + 1);
   }

   int mx_val = 0;
   for (int u : order) mx_val = max(mx_val, dp[u]);
   cout << mx_val << "\n";
}

void read() {
   cin >> n >> m;
   order.clear();
   adj.assign(n, vector <int> ());

   for (int e = 0; e < m; ++e) {
      int u, v;
      cin >> u >> v;
      --u, --v;
      adj[u].push_back(v);
   }
}

signed main() {
   IOS; PREC;

   read(), solve();
   return EXIT_SUCCESS;
}


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

int main() {
	string N;
	int K;
	cin >> N >> K;
	int L = N.length();
	if (L < K) {
		cout << 0 << endl;
		return 0;
	}
	string A(L, '0');
	int ans = 0;
	switch (K) {
	case 1:
		for (int i = 0; i < L; i++) {
			A = string(L, '0');
			for (char a = '1'; a <= '9'; a++) {
				A[i] = a;
				if (A <= N) ans++;
			}
		}
		break;
	case 2:
		for (int j = 1; j < L; j++) {
			for (char a = '1'; a <= '9'; a++) {
				A[0] = a;
				for (char b = '1'; b <= '9'; b++) {
					A[j] = b;
					if (A <= N) ans++;
					A[j] = '0';
				}
			}
		}
		ans += (L - 1) * (L - 2) / 2 * 9 * 9;
		break;
	case 3:
		for (int j = 1; j < L; j++) {
			for (int k = j + 1; k < L; k++) {
				for (char a = '1'; a <= '9'; a++) {
					A[0] = a;
					for (char b = '1'; b <= '9'; b++) {
						A[j] = b;
						for (char c = '1'; c <= '9'; c++) {
							A[k] = c;
							if (A <= N) ans++;
							A[k] = '0';
						}
						A[j] = '0';
					}
				}
			}
		}
		ans += (L - 1) * (L - 2) * (L - 3) / 6 * 9 * 9 * 9;
	}
	cout << ans << endl;
}

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

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]){
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a[4],b[4],i,sum_a=0,sum_b=0;
  for(i=0;i<4;i++){
    scanf("%d",&a[i]);
    sum_a += a[i];
  }
  for(i=0;i<4;i++){
    scanf("%d",&b[i]);
    sum_b += b[i];
  }
  if(sum_a>sum_b){
    printf("%d\n",sum_a);
  }
  else{
    printf("%d\n",sum_b);
  }
  return(0);
}
  

Measured memory_bytes: 1776
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      xyhs: [(i64,i64,i64); n],
    }

    for cx in 0..101 {
        for cy in 0..101 {
            let mut hh = -1;
            for &(x, y, h) in xyhs.iter() {
                if h == 0 {
                    continue;
                }
                hh = h + (x-cx).abs() + (y-cy).abs();
                break;
            }
            assert!(hh >= 0);


            let mut ok = true;
            for &(x, y, h) in xyhs.iter() {
                let h2 = max(hh-(x-cx).abs()-(y-cy).abs(), 0);
                if h != h2 {
                    ok = false;
                    break;
                }
            }
            if ok {
                return puts!("{} {} {}\n", cx, cy, hh);
            }
        }
    }
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int N;
    cin >> N;
    for (int i = 1; i < 100000; i++) {
        if (floor(i * 1.08) == N) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
import copy

N = int(input())
S = input()

RL = [0]*(N+1)
GL = copy.deepcopy(RL)
BL = copy.deepcopy(RL)
R = []
G = []
B = []
for i in range(N):
    if S[i] == 'R':
        R.append(i+1)
        RL[i+1] = 1
    elif S[i] == 'G':
        G.append(i+1)
        GL[i+1] = 1
    elif S[i] == 'B':
        B.append(i+1)
        BL[i+1] = 1

len_r = len(R)
len_g = len(G)
len_b = len(B)
ans = 0
if max(len_r, len_g, len_b) == len_b:
    for i in range(len_r):
        for j in range(len_g):
            ans += len_b
            tmp_abs = abs(R[i]-G[j])

            index = (min(R[i], G[j])-tmp_abs)
            if index > 0 and BL[index] == 1:
                ans -= 1

            index = (max(R[i], G[j])+tmp_abs)
            if index <= N and BL[index] == 1:
                ans -= 1

            if tmp_abs % 2 == 0 and BL[max(R[i], G[j])-(tmp_abs//2)] == 1:
                ans -= 1

elif max(len_r, len_g, len_b) == len_g:
    for i in range(len_r):
        for j in range(len_b):
            ans += len_g
            tmp_abs = abs(R[i]-B[j])

            index = (min(R[i], B[j])-tmp_abs)
            if index > 0 and GL[index] == 1:
                ans -= 1

            index = (max(R[i], B[j])+tmp_abs)
            if index <= N and GL[index] == 1:
                ans -= 1

            if tmp_abs % 2 == 0 and GL[max(R[i], B[j])-(tmp_abs//2)] == 1:
                ans -= 1

else:
    for i in range(len_g):
        for j in range(len_b):
            ans += len_r
            tmp_abs = abs(G[i]-B[j])

            index = (min(G[i], B[j])-tmp_abs)
            if index > 0 and RL[index] == 1:
                ans -= 1

            index = (max(G[i], B[j])+tmp_abs)
            if index <= N and RL[index] == 1:
                ans -= 1

            if tmp_abs % 2 == 0 and RL[max(G[i], B[j])-(tmp_abs//2)] == 1:
                ans -= 1
print(ans)


Measured memory_bytes: 9452
#include <cstdio>
int main(){
  char d[3],key[3],val[3],table[256];
  int n,m,i;

  scanf("%d",&n);
  while(n>0){
    for(i=0;i<256;i++) table[i]=i;
    for(i=0;i<n;i++){
      scanf("%s %s",key,val);
      table[key[0]]=val[0];
    };
    scanf("%d",&m);
    for(i=0;i<m;i++){
      scanf("%s",d);
      printf("%c",table[d[0]]);
    }
    printf("\n");
    scanf("%d",&n);
  };
  return 0;
};

Measured memory_bytes: 1000