akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;



void main() {
    immutable long inf = 1L << 59;

    auto s = readln.split.map!(to!int);
    auto v = s[0];
    auto e = s[1];

    auto g = new long[][](v, v);
    foreach (i; 0..v) g[i][] = inf;
    foreach (i; 0..v) g[i][i] = 0;

    foreach (_; 0..e) {
        s = readln.split.map!(to!int);
        auto x = s[0];
        auto y = s[1];
        auto cost = s[2];
        g[x][y] = cost;
    }

    auto dist = warshall_floyd!(long, inf)(g);

    if (v.iota.map!(i => dist[i][i] < 0).any) {
        writeln("NEGATIVE CYCLE");
    } else {
        dist.each!(a => a.map!(b => b == inf ? "INF" : to!string(b)).join(" ").writeln);
    }
}

T[][] warshall_floyd(T, T inf)(const T[][] graph) {
    import std.conv : to;

    int n = graph.length.to!int;
    auto dist = new T[][](n, n);
    foreach (i; 0..n) foreach (j; 0..n) dist[i][j] = graph[i][j];

    foreach (i; 0..n)
        foreach (j; 0..n)
            foreach (k; 0..n)
                if (dist[j][i] != inf && dist[i][k] != inf)
                    dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);

    return dist;
}



Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pow_mod(ll fi,ll se,ll mod){
  if(se==0){
    return 1;
  }
  if(se%2){
    return pow_mod(fi,se-1,mod)*fi%mod;
  }
  ll t=pow_mod(fi,se/2,mod);
  return t*t%mod;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

vector<pair<int,int>> Dir={{-1,0},{1,0},{0,1},{0,-1}};
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/



int main(){
  ll n,k;
  cin>>n>>k;
  op(n-k+1);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define int long long
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359
 
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;
///*X.find_by_order("index")
///X.order_of_key("key")
 
#define deb(x) {x}
#ifndef local
	#define deb(x) ;
#endif
 
 
///----------------------------------------------------------------------------------

int n,k;
int arr[305];
int DP[305][305][305];

int fun(int cur, int rem, int prev)
{
	if (cur == n) return arr[prev];
	
	
	if (DP[cur][rem][prev] != -1) return DP[cur][rem][prev];
	
	int &res = DP[cur][rem][prev];
	
	///take 
	
	int take = fun(cur+1, rem, cur);
	if (prev != 303 && arr[cur] < arr[prev]) take += arr[prev] - arr[cur];
	
	int no = LLONG_MAX;
	if (rem)
		no = fun(cur+1, rem-1, prev);
	
	res = min(take, no);
	return res;
	
}

void solve()
{
	cin>>n>>k;
	rep(i,0,n)cin>>arr[i];
	memset(DP,-1,sizeof DP);
	cout<<fun(0,k,303);
	
}

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
 	
 	#ifdef local
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	clock_t qwertyuiop = clock();
	#endif
 
	int t=1;
	//cin>>t;
	
	rep(a,0,t)
	{
		//cout<<"Case #"<<a+1<<": ";
		solve();

	}
	
	#ifdef local
	{qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}

Measured memory_bytes: 221952
#include <bits/stdc++.h>
using namespace std;
#define RE(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define SZ(x) ((int)(x.size()))
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pii = pair<int,int>;
using C = complex<double>;
const double PI = 3.14159265;
const double eps = 1e-8;
const int N = 100;
const int M = N*(N+N);
const int inf = 1e9+7;
const ll INF = 1e18;
ll pw(ll a, ll b){ll t=1;a%=M;for(;b;b>>=1){if(b&1){t=t*a%M;}a=a*a%M;}return t;}
ll gcd(ll a, ll b){return b?gcd(b, a%b): a;}


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

    int n, m, x;
    cin>>n>>m;
    vector<vector<int>> a(n, vector<int>(m));
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>a[i][j];
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++){
            cin>>x;
            a[i][j]=abs(a[i][j]-x);
        }
    vector<vector<vector<bool>>> dp(n, vector<vector<bool>>(m, vector<bool>(M)));
    dp[0][0][a[0][0]]=1;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++){
            for(int k=0;k<M;k++){

                if(j&&dp[i][j-1][k]){
                    dp[i][j][k+a[i][j]]=1;
                    dp[i][j][abs(k-a[i][j])]=1;
                }
                if(i&&dp[i-1][j][k]){
                    dp[i][j][k+a[i][j]]=1;
                    dp[i][j][abs(k-a[i][j])]=1;
                }

            }
        }

    for(int k=0;k<M;k++)
    if(dp[n-1][m-1][k]){
        cout<<k<<"\n";
        return 0;
    }

}

Measured memory_bytes: 18432
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


int main() {
	int a, b, h;
	cin >> a >> b >> h;

	cout << (a + b)*h / 2 << endl;






	return 0;
}

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

int main(){

    int n,y;
    cin>>n>>y;

    for(int i=0;i<=n;i++){
        for(int j=0;j<=n-i;j++){
            int k=n-i-j;
            if(10000*i+5000*j+1000*k==y){
                cout<<i<<" "<<j<<" "<<k<<endl;
                return 0;
            }

        }
    }  

    cout<<-1<<" "<<-1<<" "<<-1<<endl;






    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void run(void){
  int n;
  scanf("%d",&n);
  int k=1;
  while(k*(k+1)/2<n) k++;
  while(n>0){
    if(n>=k){
      printf("%d\n",k);
      n-=k;
    }
    k--;
  }
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 128
private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

var n: Int = 0

fun main(args: Array<String>) {
    n = readInt()
    val a = listOf('a')

    f(a)
}

fun f(list: List<Char>) {
    if (list.size >= n) {
        println(list.joinToString(""))
        return
    }
    ('a'..list.max()!!.inc()).map { c -> list.asSequence().plus(c).toList() }.forEach(::f)
}


Measured memory_bytes: 71244
n = int(input())
p = list(map(int,input().split()))
q = p.copy()
q.sort()
status = 0

for i in range(n):
    for j in range(n):
        r = []
        r = p.copy()
        if i == j:
            pass
        else:
            tmp = r[i]
            r[i] = r[j]
            r[j] = tmp

        if q == r:
            status = 1
            break

if status == 0:
    print("NO")
else:
    print("YES")


Measured memory_bytes: 3064
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

const int mod = 998244353;
enum{N=100023};
il ll qpow(ll a,ll b){
	ll ans= 1;
	for(; b; b>>=1,a=a*a%mod) if( b&1 ){
		ans= ans*a%mod;
	} return ans;
}
il ll inv(ll x){ return qpow(x,mod-2); }
const ll inv2 = inv(2);
const int fn = 1<<10;
void FWT_XOR(ll*A,int n,int IFWT){
	for(int t=1;t<n;t<<=1){
		for(int l=0;l<n;l+=t*2){
			rep(i,0,t-1){
				ll x=A[l+i], y=A[l+t+i];
				A[l+i] = (x+y)%mod;
				A[l+t+i] = (x-y)%mod;
			}
		}
		if( IFWT==-1 ){
			rep(i,0,n-1) A[i] = A[i]*inv2%mod;
		}
	}
}

struct Edge{ int nxt,to; } bow[N*4];
int head[N],tot_e;
il void add(int x,int y){
	bow[++tot_e] = (Edge){head[x],y};
	head[x] = tot_e;
}

int s[N];
bool vis[N];
int dfs(int u){
	if( vis[u] ) return s[u];
	vis[u] = 1;
	vector<int>vec;
	each(i,u){
		int v = bow[i].to;
		vec.push_back(dfs(v));
	}
	sort(vec.begin(),vec.end());
	int n = unique(vec.begin(),vec.end())-vec.begin()-1;
	vec.resize(n+2); vec[n+1] = -1;
	int ans = -1;
	rep(i,0,n+1) if( vec[i]!=i ){ ans = i; break; }
	return s[u] = ans;
}

ll f[N],g[N];

int main(){
	int n = ci();
	static ll pow1[N];
	ll P = qpow(10,18); pow1[0]=1;
	rep(i,1,n) pow1[i] = pow1[i-1]*P%mod;
	rep(i,0,fn-1) f[i] = 1;
	int T = 3;
	while( T-- ){
		int m = ci();
		memset(head,0,sizeof(head));
		memset(vis,0,sizeof(vis));
		rep(i,1,m){
			int x[] = {ci(),ci()};
			if( x[0]>x[1] ) swap(x[0],x[1]);
			add(x[0],x[1]);
		}
		rep(i,1,n) if( vis[i]==0 ) dfs(i);
		memset(g,0,sizeof(g));
		rep(i,1,n) g[s[i]] = (g[s[i]]+pow1[i])%mod;
		FWT_XOR(g,fn,1);
		rep(i,0,fn-1) f[i] = f[i]*g[i]%mod;
	}
	FWT_XOR(f,fn,-1);
	printf("%lld\n",(f[0]+mod)%mod);
	return 0;
}


Measured memory_bytes: 5888
#include "bits//stdc++.h"
using namespace  std;

vector<int> v1{ 1, 3, 5, 7, 8, 10, 12 };
vector<int> v2{ 4, 6, 9, 11};
vector<int> v3{ 2 };

int main() {
	vector<int>	A(13, 0);
	for (auto i : v1) {
		A[i] = 1;
	}
	for (auto i : v2){
		A[i] = 2;
	}
	for (auto i : v3) {
		A[i] = 3;
	}
	int x, y;
	cin >> x >> y;
	if (A[x] == A[y]) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod = 998244353;
int sum(int a, int b) {
    int s = a + b;
    if (s >= mod) s -= mod;
    return s;
}
int mult(int a, int b) {
    return (1LL * a * b) % mod;
}
int sub(int a, int b) {
    int s = a - b;
    if (s < 0) s += mod;
    return s;
}
const int maxN = 305;
const int maxS = maxN * maxN;
int dp[maxS], ndp[maxS];
int ways[maxS], nways[maxS];
int n;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    dp[0] = 1;
    ways[0] = 1;
    int total = 1;
    for (int i = 1; i <= n; i++) total = mult(3, total);
    int total_sum = 0;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        total_sum += x;
        memset(ndp, 0, sizeof ndp);
        memset(nways, 0, sizeof nways);
        for (int j = 0; j <= i * 300; j++) {
            ndp[j] = sum(ndp[j], mult(dp[j], 2));
            nways[j] = sum(nways[j], ways[j]);
            ndp[j + x] = sum(ndp[j + x], dp[j]);
            nways[j + x] = sum(nways[j + x], ways[j]);
        }
        for (int j = 0; j <= i * 300; j++) {
            dp[j] = ndp[j];
            ways[j] = nways[j];
        }
    }
    for (int i = 0; i <= n * 300; i++) {
        if (2 * i >= total_sum) {
            total = sub(total, mult(dp[i], 3));
        }
    }
    if (total_sum % 2 == 0) {
        total = sum(total, mult(3, ways[total_sum / 2]));
    }
    cout << total;
    return 0;
}

Measured memory_bytes: 1664
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e9;
const ll MOD = 1e9 + 7;

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

int main()
{
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for (auto &e : S)
    cin >> e;

  int ans = 0;
  for (int i = 0; i < H; ++i)
  {
    for (int j = 0; j < W; ++j)
    {
      if (S[i][j] == '#')
        continue;
      int sy = i, sx = j;
      for (int k = 0; k < H; ++k)
      {
        for (int l = 0; l < W; ++l)
        {
          if (S[k][l] == '#')
            continue;
          int gy = k, gx = l;
          queue<pair<int, int>> q;
          q.emplace(sy, sx);
          vector<vector<int>> v(H, vector<int>(W, -1));
          v[sy][sx] = 0;
          while (!q.empty())
          {
            pair<int, int> p = q.front();
            q.pop();
            if (p.first == gy && p.second == gx)
              break;
            for (int i = 0; i < 4; ++i)
            {
              int ny = p.first + dy[i], nx = p.second + dx[i];
              if (0 <= ny && ny < H && 0 <= nx && nx < W && S[ny][nx] == '.' && v[ny][nx] == -1)
              {
                q.emplace(ny, nx);
                v[ny][nx] = v[p.first][p.second] + 1;
              }
            }
          }
          ans = max(ans, v[gy][gx]);
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <climits>
#include <math.h>
#include <utility>
#include <ctime>
#include <cstdlib>
using namespace std;

typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) a.begin(),a.end(

int main() {
	ll n, m; cin >> n >> m;
	if (2 * n >= m) {
		cout << m / 2 << endl;
	}
	else {
		ll ans = n;
		ans += (m - 2 * n) / 4;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main
import "fmt"
func main() {
  var s,t string
  var n,m int
  fmt.Scan(&s)
  n = len(s)
  m = 0
  t = s[0:1]
  for i:=1;i<n;i++ {
    if t != s[i:i+1] {
      m++
      t = s[i:i+1]
    }
  }
  fmt.Println(m)
}

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

const ll MOD=1000000007;

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b){
  ll p=1;
  for(int i=0;i<b;i++){
    p*=a;
  }
  return p;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll binom1(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i)/(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

int main(){
  int i,j,k,cnt=0;
  string s;
  cin>>s;
  int n=s.size();
  for(i=0;i<n;i++){
    if(i%2==0){
      if(s[i]=='p')cnt--;
    }else if(s[i]=='g')cnt++;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;
                                                                                                     
ll MOD=1000000007;                                                                                     
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int x,ans=8,a=599; cin>>x;
    while(1){
        if(x<=a){
            cout<<ans<<endl;
            break;
        }
        a+=200; ans--;
    }
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
const ll p=1000000007;
int main(){
  int h,w;
  cin >> h >> w;
  int k[h][w];
  rep(i,h)rep(j,w)k[i][j]=-1;
  queue<pair<int,int>> q;
  rep(i,h){
    string s;
    cin >> s;
    rep(o,w){
      if(s[o]=='#'){
        k[i][o]=0;
        q.push(make_pair(i,o));
      }
    }
  }
  int ans=0;
  while(q.size()!=0){
    pair<int,int> a=q.front();
    q.pop();
    int x=a.first,y=a.second;
    if(x!=0){
      if(k[x-1][y]==-1){
        k[x-1][y]=k[x][y]+1;
        ans=max(ans,k[x][y]+1);
        q.push(make_pair(x-1,y));
      }
    }
    if(x!=h-1){
      if(k[x+1][y]==-1){
        k[x+1][y]=k[x][y]+1;
        ans=max(ans,k[x][y]+1);
        q.push(make_pair(x+1,y));
      }
    }
    if(y!=0){
      if(k[x][y-1]==-1){
        k[x][y-1]=k[x][y]+1;
        ans=max(ans,k[x][y]+1);
        q.push(make_pair(x,y-1));
      }
    }
    if(y!=w-1){
      if(k[x][y+1]==-1){
        k[x][y+1]=k[x][y]+1;
        ans=max(ans,k[x][y]+1);
        q.push(make_pair(x,y+1));
      }
    }
  }
  cout << ans << endl;
}


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

using namespace std;

int *dp;
bool *visited;

vector<vector<int>> G;

void dfs(int v){
	visited[v] = 1;
	for(auto u: G[v]){
		//cout<<"First: v = "<<v<<" u = "<<u<<" "<<dp[v]<<" "<<dp[u]<<"\n";
		if(!visited[u]) dfs(u);
		//cout<<"Return: v = "<<v<<" u = "<<u<<" "<<dp[v]<<" "<<dp[u]<<"\n";
		dp[v] = max(dp[v], 1+dp[u]);
	}
}

int main(){
	int n ,m, i, u, v;
	scanf("%d%d",&n,&m);

	//for(i=0;i<=n;i++) dp[i] = 0;
	for(i=0;i<=n;i++) G.push_back(vector<int> ());

	visited = new bool[n+1]{0};
	dp = new int[n+1]{0};

	for(i=0;i<m;i++){
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
	}
	for(i = 1; i <= n; i++) {
		if(!visited[i])
		dfs(i);
	}
	int ans = 0;
	for(i = 1; i <= n; i++) {
		ans = max(ans, dp[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 8304
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int k = scanner.nextInt();
		int n1 = a+k-1;
		int n2 = b-k+1;
		if (n1>=n2) {
			for (int i=a; i<=b; i++) {
				System.out.println(i);
			}
		}else {
			for (int i=a; i<=n1; i++) {
				System.out.println(i);
			}
			for (int i=n2; i<=b; i++) {
				System.out.println(i);
			}
		}
	}

}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n; cin>>n;
	string s; cin>>s;
	int k; cin>>k;
	for(int i=0;i<n;i++)
	{
		if(s[i]!=s[k-1])
			s[i]='*';
	}
	cout<<s<<endl;
}

Measured memory_bytes: 384
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

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

	void solver() {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		boolean ans = true;
		for (int i = 0; i < s.length; i += 2) {
			ans &= s[i]=='R' || s[i]=='U' || s[i]=='D';
		}
		for (int i = 1; i < s.length; i += 2) {
			ans &= s[i]=='L' || s[i]=='U' || s[i]=='D';
		}
		System.out.println(ans ? "Yes" : "No");
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#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 REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n,m;
int main(){
	cin >> n >> m;

	cout << min(n,m / 2) + max((m - 2 * n) / 4,0ll) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iostream>
#include <set>
#include <string>
#include <utility>

using namespace std;

// どこかで必ずループするため、通過したときの回数を記録することで計算量を削減できる
// ループしたときの回数から通過したときの回数を引くと、１ループの転移回数がもとまるので、あとはKを割ったあまりの回数遷移すればよい

int main() {
  long long town_num, warp_num;

  cin >> town_num >> warp_num;

  long long warps[town_num];

  for (long long i = 0; i < town_num; i++) {
    long long tmp;
    cin >> tmp;
    warps[i] = tmp - 1;
  }

  // ループするまで遷移する
  deque<long long> passed_on(town_num, -1);
  long long crt_warp_num = 0;
  long long crt_town = 0;

  // 宛先に到達するか、ループに突入するまでワープ
  while (true) {
    // 宛先に到達
    if (crt_warp_num >= warp_num) {
      cout << crt_town + 1 << endl;
      return 0;
    }

    // 既に通った街であるため、ループに突入したことがわかった
    // ループを抜けて、最終的にたどり着く街を見つける
    if (passed_on[crt_town] > -1) {
      break;
    }

    // ワープする
    passed_on[crt_town] = crt_warp_num;

    crt_warp_num++;
    crt_town = warps[crt_town];
  }

  // crt_warp_num : ワープに入った遷移回数
  // crt_town : ワープに入った街

  // ループで遷移する回数
  long long roop_warp_num = crt_warp_num - passed_on[crt_town];
  // 最後までループしたときの残りの遷移回数
  long long rest_warp_num = (warp_num - crt_warp_num) % roop_warp_num;

  for (long long i = 0; i < rest_warp_num; i++) {
    crt_town = warps[crt_town];
  }

  cout << crt_town + 1 << endl;

  return 0;
}

Measured memory_bytes: 6364
// Problem : E - Dist Max
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、 
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 🚶ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int N;
	cin>>N;
	ll mxs=INT_MIN,mns=INT_MAX,mxd=INT_MIN,mnd=INT_MAX;
	F0R(x,N)
	{
		ll a,b;
		cin>>a>>b;
		ckmax(mxs,a+b);
		ckmin(mns,a+b);
		ckmax(mxd,a-b);
		// bug(mxd);
		ckmin(mnd,a-b);
		// bug(mnd);
	}
	cout<<max(mxs-mns,mxd-mnd);
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

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

#define error(args...) { 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) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

void code() {
    int n;
    cin>>n;
    int ans=360/__gcd(n, 360);



    cout << ans << "\n";
}

signed main() {
    std::ios_base::sync_with_stdio(false);
    int t=1;
    for(int i=0; i<t; i++) {
        code();
    }
}


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

int main()
{
  	int a, b, c;
  	cin>>a>>b>>c;
  	if(a > 10 || a < 1 || b > 10 || b < 1 || c > 10 || c < 1)
      exit(0);
  	if((a == 5 && b == 5 && c == 7) || (a == 5 && b == 7 && c == 5) ||
      (a == 7 && b == 5 && c == 5))
      cout<<"YES\n";
 	else
      cout<<"NO\n";
  	/*int aa[20];
  	for(int i = 0; i < 20; i++)
    {
      	aa[a]++;
      	aa[b]++;
      	aa[c]++;
    }
  	if(aa[5] == 2 && aa[7] == 1)
      cout<<"YES\n";
  	else
      cout<<"NO\n";*/
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

using ll = long long;

int main()
{
    int r,g;
    cin >> r >> g;
    cout << 2*g - r << endl;
    return 0;
}

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

long long h,w;

int main() {
	cin>>h>>w;
	if(h==1 || w==1)
		cout<<"1"<<endl;
	else if(h%2==1 && w%2==1)
		cout<<(h*w+1)/2<<endl;
	else cout<<h*w/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  int n;
  cin >> n ;
  
  int d[n];
  rep(i,n)cin >> d[i];
  
  int ans=0;
  
  rep(i,n-1){
    for(int j=i+1;j<n;j++){
      ans += d[i]*d[j];
    }
  }
  
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include<fstream>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

/*ofstream fout("bcount.out");
ifstream fin("bcount.in");*/

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    string s;
    cin>>s;
    ll n = (int)s.length();
    ll ans = 0;;
    rep(i,0,n)
    {
    	ans += s[i] - '0';
    }
    ans%9 == 0 ? cout<<"Yes"<<endl : cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3752
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node {int p,l,r;};
struct Node T[MAX];
int n;

void preParse(int u){
	if(u==NIL)return;
	printf(" %d",u);
	preParse(T[u].l);
	preParse(T[u].r);
}

void inParse(int u){
	if(u==NIL)return;
	inParse(T[u].l);
	printf(" %d",u);
	inParse(T[u].r);
}

void postParse(int u){
	if(u==NIL)return;
	postParse(T[u].l);
	postParse(T[u].r);
	printf(" %d",u);
}

int main(){
	int i,v,l,r,root;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		T[i].p=NIL;
	}
	
	for(i=0;i<n;i++){
	scanf("%d %d %d",&v,&l,&r);
		T[v].l=l;
		T[v].r=r;
		if(l!=NIL)T[l].p=v;
		if(r!=NIL)T[r].p=v;
	}
	
	for(i=0;i<n;i++)if(T[i].p==NIL)root=i;
	
	printf("Preorder\n");
	preParse(root);
	printf("\n");
	printf("Inorder\n");
	inParse(root);
	printf("\n");
	printf("Postorder\n");
	postParse(root);
	printf("\n");
	
	return 0;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main()
{
    int r, g, b;
    cin >> r >> g >> b;
    int num = 100 * r + 10 * g + b;

    string ans;
    if (num % 4 == 0)
    {
        ans = "YES";
    }
    else
    {
        ans = "NO";
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

def main():
    K = int(input())
    A, B = map(int, input().split())
    for i in range(A,B+1):
        if i % K == 0:
            print('OK')
            exit()
    print('NG')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    string s;
    cin >> s;
    int l = 0, r = s.size() - 1;
    int ans = 0;
    while (l < r) {
        if (s[l] == s[r]) {
            l++;
            r--;
        } else if (s[l] == 'x') {
            ans++;
            l++;
        } else if (s[r] == 'x') {
            ans++;
            r--;
        } else {
            ans = -1;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <set>
#include <map>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  string s;
  std::cin >> s;
  vvl dp = vv(s.size()+1, 14, 0, ll);
  ll now = 1;
  dp[0][0]=1;
  for(int i=0;i<s.size();i++){
    if(s[s.size()-1-i]!='?'){
      ll k = (now*(s[s.size()-1-i]-'0'))%13;
      for(int j=0;j<=13;j++){
        dp[i+1][(j+k)%13]=(dp[i+1][(j+k)%13] + dp[i][j])%1000000007;
      }
    }else{
      for(int m=0;m<=9;m++){
        ll k = (now*m)%13;
        for(int n=0;n<=13;n++){
          dp[i+1][(n+k)%13]=(dp[i+1][(n+k)%13] + dp[i][n])%1000000007;
        }
      }
    }
    now = (now*10)%13;
  }
  std::cout << dp[s.size()][5] << '\n';
  return 0;
}


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

int main() {
int N, M, X;
cin >> N >> M >> X;
vector<int> A(N+1,0);
for(int i=0; i<M; i++)
{
  int x;
  cin >> x;
  A[x]=1;
}
int left, right;
left = accumulate(A.begin()+1, A.begin()+X, 0);
right = accumulate(A.begin()+X+1, A.end(), 0);
cout << min(left, right) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAXN 1000010
vector<int> adj[MAXN];
int prefix[MAXN], visited[MAXN], carbon[MAXN];
int node, query;
class fastio {
public:
    fastio() {
        ios_base::sync_with_stdio(false);
        cout.tie(nullptr);
        cin.tie(nullptr);
    }
} __fastio;
void graph(int u, int v) {
    //Directed tree because parent cost will be added to child and not the opposite
    adj[u].push_back(v);
    adj[v].push_back(u);
}
void dfs(int u, int cost) {
    visited[u] = 1;
    //Adding the cost of parent i.e, cost and adding the total prefix sum i.e, prefix[u]
    //Accoring to problem parent cost will always be added to the child hence always adding it
    carbon[u] = prefix[u] + cost;
    for(int i : adj[u]) {
        if(visited[i] != 1) {
            dfs(i, carbon[u]);
        }
    }
}
void solve() {
    cin >> node >> query;
    for(int i=0; i<node-1; i++) {
        int u, v;
        cin >> u >> v;
        graph(u, v);
    }
    for(int i=0; i<query; i++) {
        int u, p;
        cin >> u >> p;
        //storing the total summation value of 'p' for 'u' in prefix[u]
        prefix[u] += p;
    }
    dfs(1, 0);
    for(int i=1; i<=node; i++) {
        cout << carbon[i] <<  " ";
    }
}
int main() {
  __fastio;
  solve();
  return 0;
}


Measured memory_bytes: 48640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int min = 999;
        int sum = 0;
        for (int i = 0; i < 5; i++) {
            int tmp = sc.nextInt();
            if (tmp % 10 < min && tmp % 10 != 0) {
                min = tmp % 10;
            }

            sum += ((int)Math.ceil(tmp/10.0) * 10);
        }
        if (min != 999) {
            sum = sum - (10 - min);
        }

        System.out.println(sum);
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
int main () {
	int H , W ; cin >> H >> W ;
	int h , w ; cin >> h >> w ;
	int ans = ( H - h ) * ( W - w );
	cout << ans << endl ;
  	return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		String[] temp = scanner.nextLine().split(" ");
		int n = Integer.parseInt(temp[0]);
		int m = Integer.parseInt(temp[1]);

		Map<Integer, Integer> ans = new HashMap<Integer,Integer>();


		for(int i = 0; i < n; i++) {

			String[] list = scanner.nextLine().split(" ");
			for(int j = 1; j < list.length; j++) {

				int put =  Integer.parseInt(list[j]);
				if(ans.containsKey(put)) {
					ans.put(put, ans.get(put) + 1);
				}else {
					ans.put(put, 1);
				}
			}
		}
		int a = 0;
		for(Entry<Integer, Integer> entry : ans.entrySet()) {

			if(entry.getValue() == n) {
				a++;
			}
		}
		System.out.println(a);
	}

}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert
#ifdef LOCAL
template <class T, class S>
ostream &operator<<(ostream &str, const pair<T, S> &p) {
  return (str << "{" << p.fi << ", " << p.se << "}");
}
template <template <class...> class Container, class... T>
ostream &operator<<(ostream &str, const Container<T...> &vec) {
  str << '[';
  for (auto it = vec.begin(); it != vec.end(); it++) {
    if (it != vec.begin())
      str << ", ";
    str << *it;
  }
  str << ']';
  return str;
}
#define var(x) "[" << #x << ": " << x << "] "
struct dbg {
  dbg() { cout << "  "; }
  ~dbg() { cout << endl; }
  template <class T> dbg &operator<<(T oth) {
    cout << oth;
    return *this;
  }
};
#else
#define var(x) 0
struct dbg {
  template <class T> dbg &operator<<(T oth) { return *this; }
};
#endif
using ll = long long;
using ull = unsigned long long;
using ld = long double;
int main(int argc, char **argv) {
  //ios::sync_with_stdio(false), cin.tie(0);
  auto solve = [&]() {
    ll h, w, k, ans = 0;
    cin >> h >> w >> k;
    vector<vector<bool>> matr(h, vector<bool>(w, false));
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        char c;
        cin >> c;
        matr[i][j] = c - '#';
      }
    }
    for (int i = 0; i < (1 << h); i++) {
      for (int j = 0; j < (1 << w); j++) {
        int c = 0;
        for (int a = 0; a < h; a++)
          for (int b = 0; b < w; b++)
            if (!(((i >> a) & 1) || ((j >> b) & 1)) && !matr[a][b])
              ++c;
        if (c == k)
          ++ans;
      }
    }
    cout << ans << '\n';
  };
  int t;
  t = 1;
  while (t--)
    solve();
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int s, w;
  cin>>s>>w;
  cout<<(s<=w ? "unsafe" : "safe")<<'\n';
  return 0;
}


Measured memory_bytes: 3604
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void){
    char s[100020],t[100020],a[5]="maerd",b[7]="remaerd",c[5]="esare",d[6]="resare";
    scanf("%s",s);
    t[strlen(s)]='\0';
    for (int i=0; i<strlen(s); i++){
        t[i]=s[strlen(s)-i-1];
    }
    int count=0;
    while(count<strlen(s)){
        if (strncmp(t+count,a,5)==0){
            count+=5;
        } else if (strncmp(t+count,b,7)==0){
            count+=7;
        } else if (strncmp(t+count,c,5)==0){
            count+=5;
        } else if (strncmp(t+count,d,6)==0){
            count+=6;
        } else {
            printf("NO\n");
            exit(0);
        }
    }
    printf ("YES\n");
	return 0 ;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n, a, gold = 0;
  cin >> n;
  unordered_map<string, int> mp;

  rep(i, n) {
    cin >> a;
    if (1 <= a && a < 400)
      mp["gray"]++;
    else if (400 * 1 <= a && a < 400 * 2)
      mp["cha"]++;
    else if (400 * 2 <= a && a < 400 * 3)
      mp["green"]++;
    else if (400 * 3 <= a && a < 400 * 4)
      mp["waterblue"]++;
    else if (400 * 4 <= a && a < 400 * 5)
      mp["blue"]++;
    else if (400 * 5 <= a && a < 400 * 6)
      mp["yellow"]++;
    else if (400 * 6 <= a && a < 400 * 7)
      mp["orange"]++;
    else if (400 * 7 <= a && a < 400 * 8)
      mp["red"]++;
    else
      gold++;
  }
  if (gold > 0) {
    cout << ((mp.size() != 0) ? mp.size() : 1) << " " << mp.size() + gold
         << endl;
  } else {
    cout << mp.size() << " " << mp.size() << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String str1 = sc.next();
		String str2 = sc.next();

		switch (str1 + str2){
			case("HH"):System.out.println("H"); break;
			case("DH"):System.out.println("D"); break;
			case("HD"):System.out.println("D"); break;
			case("DD"):System.out.println("H"); break;
		}

	}
}

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

#define FOR(i,a,n) for (int i = a; i < (int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = int_fast64_t;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);

int main() {
  int n; cin >> n;
  vector<ll> a(n); REP(i,n) cin >> a[i];

  ll res = 0; int right = 0;
  ll sum = 0;
  REP(left, n) {
    while (right < n && ((sum xor a[right]) == (sum + a[right]))) {
      sum += a[right];
      right++;
    }
    res += right-left;
    if (right == left) right++;
    else sum -= a[left];
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1792
import Data.List.Split

import Control.Monad

getLineRepeat :: Int -> IO [String]
getLineRepeat times = replicateM times getLine

main = do
	input <- getLineRepeat 6
	let a = read <$> input :: [Int]
	let max = a !! 5
	putStrLn $ if any (\x -> x > max) [a2 - a1 | a1 <- init a, a2 <- init a, a1 < a2] then ":(" else "Yay!"


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;
  vector<int> city(N,0);
  vector<int> roadA(M);
  vector<int> roadB(M);
  for(int i = 0; i < M; i++){
    cin >> roadA[i] >> roadB[i];
  }
  for(int i = 0; i < M; i++){
    city[roadA[i]-1]++;
    city[roadB[i]-1]++;
  }
  for(int i = 0; i < N; i++){
    cout << city[i] << endl;
  }
}

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

#define int long long

using namespace std ;

bool Check_Triangle(int a,int b,int c){
    if(a + b > c && b + c > a && c + a > b && a != b && a != c && b != c)
    return 1 ;
    else return 0 ;
}

signed main(){
    int n ;
    cin >> n ;
    int The_length[n] ;
    for(int i=0;i < n;i++){
        cin >> The_length[i] ;
    }
    int The_Triangle_Count = 0 ;


    for(int i=0;i < n-2;i++){
        for(int j=i+1;j < n-1;j++){
            for(int k=j+1;k < n;k++){
                if(k > j && j > i && Check_Triangle(The_length[i],The_length[j],The_length[k]) == 1){
                    The_Triangle_Count++ ;
                }else continue ;
            }
        }
    }

    cout << The_Triangle_Count << endl ;













    return 0 ;
    }


Measured memory_bytes: 3620
/**
*    author:  yuya1234
*    created: 29.08.2020 21:02:26
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SORT(x) sort(x.begin(),x.end())
#define SORTD(x) sort(x.rbegin(),x.rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define SZ(x) ll(x.size())

#define MEMSET(v, h) memset((v), h, sizeof(v))

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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

  string s,t;
  cin>>s>>t;

  int ans=SZ(t);
  int cnt;

  REP(i,SZ(s)-SZ(t)+1)
  {
    cnt=SZ(t);
    REP(j,SZ(t))
    {
      if(s[i+j]==t[j])cnt--;
    }
  chmin(ans,cnt);
  }

  cout<<ans<<endl;


  return 0;
}

Measured memory_bytes: 3656
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n,d;cin>>n>>d;
  if (n<=(2*d+1)){
    cout << 1 << endl;
    return 0;
  }

  int c = 2*d + 1;
  cout << (n+c-1)/c << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


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

int main(){
  int a;
  int b;
  int c;
  cin >> a >> b >> c ;
  if((a+b)>=(b+c) && (a+c)>=(b+c)){
    cout << b+c;
  }
  else if((b+c)>=(a+b) && (a+c)>=(a+b)){
    cout << a+b;
  }
  else if((b+c)>=(a+c) && (a+b)>=(a+c)){
    cout << a+c;
  }
}

  

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int n, k;
	cin >> n >> k;
	int a = 1;
	for(int i=0;i < n;i++){
		if(a >= k){
			a += k;
		}else{
			a += a;
		}
	}
	cout << a << endl;
}

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

using ll = long long;
//print(fixed << setprecision(10));
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repk(i,n,k) for(int i = k; i < (n); i++)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
double PI = acos(-1.0);
int INF = 1e9;
ll LINF = 1e18;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    ll a;
    string b;
    cin >> a >> b;
    int bb = b[0] - '0';
    int bbb = 10*(b[2] - '0')+(b[3]-'0');
    ll ans = a*(100*bb+bbb)/100;
    print(ans);
    return 0;
}

Measured memory_bytes: 3656
n, m = gets.chomp.split(' ').map(&:to_i)
max_ = 100000*n
dp = Array.new(2**n, max_)
dp[0] = 0

for i in 1..m do
  dp2 = Array.new(2**n, max_)
  cost, _ = gets.chomp.split(' ').map(&:to_i)
  cs = gets.chomp.split(' ').map(&:to_i)
  key = cs.map{|c| 1<<(c-1)}.inject(:+)
  for x in 0..((2**n)-1) do
    key2 = x|key
    #dp2[x] = [dp2[x], dp[x]].min
    #dp2[key2] = [dp2[key2], dp[x] + cost].min
    a,b = dp2[x], dp[x]
    dp2[x] = (a < b) ? a : b
    a,b = dp2[key2], dp[x] + cost
    dp2[key2] = (a < b) ? a : b
    
  end
  dp = dp2
end

if dp[2**n-1] == max_ then
  print -1
else
  print dp[2**n-1]
end




Measured memory_bytes: 8316