akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
int main()
 {
    int sum=0,i,j,k,n,a;
     cin>>n;
     for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            for(k=1;k<=n;k++){
      a=__gcd(k,__gcd(i,j));
      sum=sum+a;
            }
        }
     }
     cout<<sum;
 }


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll gcd(ll a, ll b)
{
	return a % b ? gcd(b, a % b) : b;
}
int main()
{
	ll a, b, g, i, res = 1;
	scanf("%lld%lld", &a, &b);
	if (a < b)
		swap(a, b);
	g = gcd(a, b);
	a = g;
	if (g != 1)
	{
		for (i = 2; i * i <= a && g != 1; i++)
		{
			b = 0;
			while (!(g % i))
			{
				b = 1;
				g /= i;
			}
			if (b)
				res++;
		}
		if (g >> 1)
			res++;
	}
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define ln "\n"
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define ppll pair<ll,pll>
#define vll vector<ll>
#define vpll vector<pll>
#define vvll vector<vector<ll>>
#define sll stack<ll>
#define qll queue<ll>
#define pqll priority_queue<ll>
#define mp make_pair
#define f first
#define s second
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define Test ll tt;cin>>tt; while(tt--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define init(x,n,v) for(ll i=0;i<=n;i++) x[i]=v;
#define scan(x,n)  for(ll i=0;i<n;i++)cin>>x[i];
#define scan1(x,n) for(ll i=1;i<=n;i++)cin>>x[i];
#define all(x) x.begin(),x.end()
#define maxn (ll)2e5+5

ll mod = 1e9+7;
ll dp[3001][3001];

int main() 
{
	fast_io;
    ll i,j,k,n,m;
	string a,b;
	cin>>a>>b;
    n=a.size(),m=b.size();
	for(i=0;i<=n;i++)
	 for(j=0;j<=m;j++)
	  if(i==0||j==0)
	   dp[i][j]=0;
	  else if(a[i-1]==b[j-1])
	   dp[i][j]=1+dp[i-1][j-1];
	  else
	   dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
	// if(dp[n][m]==0)cout<<"";
	// else{
		i=n,j=m;
		string st;
		while(i>0&&j>0)
         if(a[i-1]==b[j-1]){
			st+=a[i-1];
			i-=1; j-=1;
		 }
         else if(dp[i][j-1]>dp[i-1][j])
			j-=1;
		 else 
		    i-=1;
		if(!st.size())cout<<"";
		for(i=st.size();i>0;i--)cout<<st[i-1]; 
	return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#include<math.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define INF 2000000000
#define Min(a,b) (a<b?a:b)
#define Max(a,b) (a>b?a:b)
#define PI 3.1415926535897932
using namespace std;






int main()
{
int n,k;
    cin >> n;
    int h[n];
    cin>>k;
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }	
    int dp[n];
    for(int i;i<n; i++ ){
    	dp[i]=INT_MAX;
    }

    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < n; i++)
    {
    	for(int j=1; j<=k;j++){
    		if(i-j>=0)	
    			dp[i]=min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
    	}
    }
    cout << dp[n - 1] << '\n';
	return 0;

return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define boost ios::sync_with_stdio(0); cin.tie(0);
using namespace std;

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	boost;
	int count = 0;
	string s, t;
	cin >> s >> t;
	int len = s.length();
	FOR(i, 0, len) {
		if (s[i] != t[i]) {count += 1;}
	}
	cout << count << endl;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int *N, T, comp;
    string result;
    cin >> T;
    N = new int[T];

    for (int i = 0; i < T; i++)
        cin >> N[i];

    sort(N, N + T);

    for (int i = 0; i < T - 1; i++)
        comp += N[i];
    result = (comp > N[T - 1]) ? "Yes" : "No";

    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

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

	return 0;
}

Measured memory_bytes: 256
A, B = map(int, input().split())

Aimax = (A-1)%50*2-1
Bimax = (B-1)%50*2-1
Ajmax = (A-1)//50
Bjmax = (B-1)//50

rowA1 = ['#' for _ in range(100)]
rowA2 = ['.' if i%2==0 else '#' for i in range(100)]
rowA3 = ['.' if i%2==0 and i <= Aimax else '#' for i in range(100)]

rowB1 = ['.' for _ in range(100)]
rowB2 = ['#' if i%2==0 else '.' for i in range(100)]
rowB3 = ['#' if i%2==0 and i <= Bimax else '.' for i in range(100)]

state = []

r = 0
for j in range(50):
    if j%2 == 0 and r < Ajmax:
        state.append(rowA2)
        r += 1
    elif j%2 == 0 and r == Ajmax:
        state.append(rowA3)
        r += 1
    else:
        state.append(rowA1)

r = 0
for j in range(50):
    if j%2 == 1 and r < Bjmax:
        state.append(rowB2)
        r += 1
    elif j%2 == 1 and r == Bjmax:
        state.append(rowB3)
        r += 1
    else:
        state.append(rowB1)

print(100, 100)
for s in state:
    print(''.join(s))

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var XA = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (X, A) = (XA[0], XA[1]);
        var ans = X < A ? 0 : 10;

        WriteLine(ans);
    }
}


Measured memory_bytes: 28288
#include <stdio.h>
 
int main()
{
    float a, b, c, d, e, f, x, y;
    while(scanf("%f %f %f %f %f %f", &a, &b, &c, &d, &e, &f) != EOF) {
        y = (a*f - c*d) / (a*e - b*d);
        x = (c - b*y) / a;
        printf("%.3f %.3f\n", x, y);
    }
    return 0;
}

Measured memory_bytes: 648
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var ni = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        var r = ni[0] - ni[1] + 1;
        Console.WriteLine(r);
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define maxn 100100
#define ll long long
int h[maxn];
int n,a,b;
ll ned(ll x,ll y)
{
    return (x+y-1)/y;
}
bool judge(int x)
{
    ll cnt=0;
    for(int i=1;i<=n;++i)
    {
        if(h[i]<=1LL*x*b) continue;
        cnt+=ned(h[i]-x*b,a-b);
    }
    return cnt<=x;
}
int main()
{
    scanf("%d%d%d",&n,&a,&b);
    for(int i=1;i<=n;++i)
        scanf("%d",&h[i]);
    int lb=0,ub=1e9+100;
    while(ub>lb+1)
    {
        int mid=(lb+ub)>>1;
        if(judge(mid)) ub=mid;
        else lb=mid;
    }
    printf("%d\n",ub);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<vector>
#include<string>
#define rep(i,a,b) for(long long int i=(a);i<(b);i++)
#define se(a) a.begin(),a.end()
#define ll unsigned long long int
#define mll map<ll,ll>
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define mk make_pair
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define inf 1e18
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
void dfs(bool visited[],vector<ll> graph[],ll index,ll dp[])
{
	visited[index]=true;
	rep(i,0,graph[index].size())
	{
		if(visited[graph[index][i]]==false)
		dfs(visited,graph,graph[index][i],dp);
		dp[index]=max(dp[index],1+dp[graph[index][i]]);
	}
}
int main()
{
	boost;
	ll n,m;
	cin>>n>>m;
	vector<ll> graph[n+1];
	rep(i,0,m)
	{
		ll x,y;
		cin>>x>>y;
		graph[x].pb(y);
	}
	bool visited[n+1];
	memset(visited,0,sizeof(visited));
	ll dp[n+1];
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=n;i++)
	if(visited[i]==false)
	{
		dfs(visited,graph,i,dp);
	}
	cout<<*max_element(dp,dp+n+1)<<endl;
}

Measured memory_bytes: 9984
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

int main(){
  int n; cin >> n;
  int maxcount = 0;
  int ans = 0;
  rep(i,n){
    int d1, d2; cin>>d1>>d2;
    if (d1 == d2){
      maxcount++;
      ans = max(maxcount, ans);
    }
    else maxcount = 0;
  }
  if (ans >= 3) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    long long int c=0,ans=0;
    for(int i=0;i<10000000;i++)
    {
        c+=7;
        c%=n;
        c*=10;
        ans++;
        if(c==0)
        {
            break;
        }
    }
    if(c==0)
        cout<<ans<<endl;
    else
        cout<<"-1"<<endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000009
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  double L;
  cin >> L;
  cout << fixed << setprecision(12);
  cout << (L/3) * (L/3) * (L/3) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;
vector<int> cnt(200006, 0);
int get(int x){
	return cnt[x] * (cnt[x] - 1) / 2;
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	
	vector<int> arr(n);
	int ans = 0;
	for(int i = 0; i < n; i++){
		cin >> arr[i];
		ans -= get(arr[i]);
		cnt[arr[i]]++;
		ans += get(arr[i]);
	}
	for(auto p : arr){
		ans -= get(p);
		cnt[p]--;
		ans += get(p);
		cout << ans << "\n";
		ans -= get(p);
		cnt[p]++;
		ans += get(p);
	}
}

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

int main(){
  int A, B;
  cin >> A >> B;
  
  if (A >= 13){
    cout << B << endl;
  }
  else if (6 <= A && A <= 12){
    cout << B/2 << endl;
  }
  else {
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
from collections import deque

H,W = map(int, input().split())
maze = [input() for _ in range(H)]
visited = [[False]*W for _ in range(H)]
q = deque([])

# initialize
for h in range(H):
    for w in range(W):
        if maze[h][w] == "#":
            q.append((h,w,0))
            visited[h][w] = True

ans = 0
while q:
    h,w,d = q.popleft()
    for dy,dx in zip([0,0,-1,1], [-1,1,0,0]):
        nh, nw = h+dy, w+dx
        if not(0<=nh<H and 0<=nw<W):
            continue
        if not visited[nh][nw]:
            q.append((nh,nw,d+1))
            visited[nh][nw] = True
            ans = max(ans, d+1)

print(ans)


Measured memory_bytes: 133980
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
/*#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX*/

using namespace std;

using ll = long long;

#define mp make_pair

const int p = 1000000007;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

/*struct DSU {
    vector<int> sz;
    vector<int> parent;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU(int n) {
        sz.resize(n);
        parent.resize(n);
        for (int i = 0; i < n; i++) make_set(i);
    }
};*/

/*const int N = 1000000;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}*/


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

    int n;
    cin>>n;
    vector<int> a(n+1);
    for (int i = 1; i<=n; i++)
    {
        int i1 = i;
        for (int c = 2; c*c<=n; c++) if (i1%c==0)
        {
            while (i1%c==0)
            {
                i1/=c; a[c]++;
            }
        }
        if (i1>1) a[i1]++;
    }
    int res = 1;

    /*for (int i = 0; i<=n; i++) cout<<a[i]<<' ';
    cout<<endl;*/

    for (int i = 1; i<=n; i++) res = mul(res, a[i]+1);
    cout<<res;


}

Measured memory_bytes: 256
crd_n = $stdin.gets(chomp:true).to_i
cards = []
score = [0,0]

crd_n.times do
  cards << $stdin.gets.split
end

cards.each do | card |
  case card[0] <=> card[1]
  when 0
    score[0] += 1
    score[1] += 1
  when -1
    score[1] += 3
  when 1
    score[0] += 3
  end
end

puts score.join(" ")


Measured memory_bytes: 6868
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<utility>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int inf=10000000000000007;
signed main(){
  int n,d,a;cin>>n>>d>>a;
  vector<pair<int,int>> enemy(n);
  rep(i,n)cin>>enemy[i].first>>enemy[i].second;
  sort(enemy.begin(),enemy.end());
  vector<int> x(n);
  vector<int> h(n);
  rep(i,n){
    x[i]=enemy[i].first;
    h[i]=enemy[i].second;
  }
  x.push_back(inf);
  h.push_back(0);
  vector<int> damage(n+1,0);
  vector<int> end(n+1,0);
  vector<int> front(n+1,0);
  int left=0;
  int now=0;
  int res=0;
  rep(i,n){
    left=i;
    now-=end[i];
    if(now*a>=h[i])continue;
    int buf=(h[i]-1)/a+1-now;
    res+=buf;
    now+=buf;
    front[i]+=buf;
    auto it=upper_bound(x.begin(),x.end(),x[i]+2*d);
    int index=it-x.begin();
    end[index]+=buf;
  }
  cout<<res<<endl;
  /*rep(i,n){
    cout<<enemy[i].first<<" "<<enemy[i].second<<endl;;
  }*/
  return 0;
}


Measured memory_bytes: 13256
#include <bits/stdc++.h>
#include <deque>
#include <unordered_map>
#define MOD 1000000007
#define REP(i,num)for(int i=0;i<(num);++i)

using namespace std;

struct P {
    long long num, v;
};

int main() {
    ios::sync_with_stdio(false);
    long long K;
    deque<P> dq;
    int visited[200001]={0,};
    int ans=9999999;
    cin>>K;

    P p;
    p.num=1;p.v=1;
    dq.push_back(p);
    while (!dq.empty()) {
        P now = dq.front();
        dq.pop_front();
        visited[now.num] = 1;
        if (now.num % K == 0) {
            ans = now.v;
            break;
        }
        if (visited[now.num + 1] == 0) {
            P next;
            next.v = now.v + 1;
            next.num = now.num + 1;
            dq.push_back(next);
        }
        if (visited[(now.num * 10) % K] == 0) {
            P next2;
            next2.v = now.v;
            next2.num = (now.num * 10)%K;
            dq.push_front(next2);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define maxn 500
#define ll long long
char str[maxn][maxn];
int n,m,i,j,s1,s2;
int mv[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
bool mark[maxn][maxn];
ll ans=0;
using namespace std;
void dfs(int x,int y)
{
	int i,px,py;
	mark[x][y]=false;
	if (str[x][y]=='.') s2++;
		else s1++;
	for (i=0;i<4;i++)
	{
		px=x+mv[i][0];
		py=y+mv[i][1];
		if (px && py && (px<=n) && (py<=m) && mark[px][py] && (str[x][y]!=str[px][py])) dfs(px,py);
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++)
		scanf("%s",str[i]+1);
	memset(mark,true,sizeof(mark));
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++)
			if (mark[i][j])
			{
				s1=s2=0;
				dfs(i,j);
				ans+=1LL*s1*s2;
			}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 8192
domitory = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for i in range(n):
    b,f,r,v = list(map(int,input().split()))
    domitory[b-1][f-1][r-1] += v
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(f" {domitory[i][j][k]}",end="")
        print()
    if i == 3:
        break
    print("####################")



Measured memory_bytes: 5640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
using namespace std;

vector<int> node[100007];
int id;
int dist[2][100007];

void dfs(int idx,int par=-1)
{
	if(~par)dist[id][idx]=dist[id][par]+1;
	for(int i=0;i<node[idx].size();i++)
	{
		if(node[idx][i]!=par)dfs(node[idx][i],idx);
	}
}

int main()
{
	int n;
	cin>>n;
	REP(i,n-1)
	{
		int u,v;
		cin>>u>>v;
		--u,--v;
		node[u].push_back(v);
		node[v].push_back(u);	
	}
	id=0;
	dfs(0);
	id=1;
	dfs(n-1);
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		if(dist[0][i]<=dist[1][i])cnt++;
	}
	cout<<(cnt>=(n+2)/2?"Fennec":"Snuke");
	return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define C 0.5772156649
#define pi acos(-1.0)
#define ll long long
#define mod 20090717
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1

using namespace std;

const double g=10.0,eps=1e-12;
const int N=100000+10,maxn=60000+10,inf=0x3f3f3f;

int a[N],b[N],c[N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    for(int i=0;i<n;i++)cin>>c[i];
    sort(a,a+n);
    sort(b,b+n);
    sort(c,c+n);
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        int p1=lower_bound(a,a+n,b[i])-a;
        p1--;
        if(p1<0||a[p1]>=b[i])continue;
        int p2=upper_bound(c,c+n,b[i])-c;
        if(c[p2]<=b[i])continue;
       // cout<<p1<<" "<<p2<<endl;
        ans+=(ll)(p1+1)*(n-p2);
    }
    cout<<ans<<endl;
    return 0;
}
/********************

********************/


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,k;
  double c;
  cin >> n >> k;
  vector<double> data(n+1);
  
  for(double i=1; i<=n; i++){
    int a = i;
    int b = 0;
    while(1){
      if(a >= k){
        break;
      }else{
        a *= 2;
        b++;
      }
    }
    
    c = n*pow(2,b);
    
    data.at(i) = c;
  }
  
  double sum=0;
  
  for(int i=1; i<=n; i++){
    sum += 1/data.at(i);
  }

  cout << setprecision(12) << sum << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		boolean color[]=new boolean[8];
		int z=0,a=0,y=0,min=0,max=400,tourist=0;
		while(z<N){
			a=stdIn.nextInt();
			while(y<9){
				if(y==8){
					tourist++;
					break;
				}
				if(min<=a&&a<max){
					color[y]=true;
					break;
				}
				min+=400;max+=400;
				y++;
			}y=0;
			z++;min=0;max=400;
		}z=0;y=0;min=0;max=0;
		while(z<8){
			if(color[z])
				min++;
			z++;
		}
		if(min==0&&tourist!=0)
			System.out.println(1+" "+tourist);
		else
			System.out.println(min+" "+(min+tourist));
	}
}

Measured memory_bytes: 21844
n,m=map(int,input().split())
l=[]
f=0
nf=0
for i in range(n):
    l.append(list(input()))
    
for i in range(n):
    for j in range(m):
        if l[i][j]=='#':
            if (i>0 and l[i-1][j]=='#') or (j>0 and l[i][j-1]=='#') or (i<n-1 and l[i+1][j]=='#') or (j<m-1 and l[i][j+1]=='#'):
                f=0
            else:
                nf=1
if nf==1:
    print('No')
else:
    print('Yes')
            
              
                                                                                         

Measured memory_bytes: 3064
h, w = map(int, input().split())

p = list(range(h*w))

def find(x):
    global p
    if p[x] == x:return x
    p[x] = find(p[x])
    return p[x]

def unite(x, y):
    global p
    x = find(x)
    y = find(y)
    if x != y:p[x] =y

def real_number(i, j):
    i += 1
    j += 1
    i %= 4
    j %= 4
    if i == 1 and j == 1:return 6
    if i == 1 and j == 2:return 3
    if i == 1 and j == 3:return 1
    if i == 1 and j == 0:return 4
    if i == 2 and j == 1:return 2
    if i == 2 and j == 3:return 2
    if i == 3 and j == 1:return 1
    if i == 3 and j == 2:return 3
    if i == 3 and j == 3:return 6
    if i == 3 and j == 0:return 4
    if i == 0 and j == 1:return 5
    if i == 0 and j == 3:return 5
    return -1
    
field = [input() for i in range(h)]
for i in range(h):
    for j in range(w):
        if str(real_number(i,j)) != field[i][j]:continue
        if i + 1 < h and str(real_number(i+1,j)) == field[i+1][j]:
            unite(i*w+j, (i+1)*w+j)
        if j + 1 < w and str(real_number(i,j+1)) == field[i][j+1]:
            unite(i*w+j, i*w+j+1)

if find(0) == find(h*w-1):
    print("YES")
else:
    print("NO")
    
        


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

 int main(){
     int n;
     cin >> n;
     vector<int> p(n);
     rep(i,n){
         cin >> p[i];
     }
     int a = max_element(p.begin(),p.end())-p.begin();
     p[a]/=2;
     int sum=0;
     rep(i,n){
         sum+=p[i];
     }
     cout << sum << endl;
     return 0;
 }

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

using namespace std;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	cout << fixed << setprecision(6) << (double)((n + 1) / 2) / n << endl; 
	return 0;	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define P pair<int,int>
#define PP pair<P,int>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int n,a,b;
vi vec;
bool check(int now){
    int cnt=0;
    REP(i,n){
        if(b*now<vec[i]){
            cnt+=(vec[i]-b*now+a-b-1)/(a-b);
        }
    }
    return cnt<=now;
}
signed main(){
    cin>>n>>a>>b;
    vec.resize(n);
    REP(i,n){
        cin>>vec[i];
    }
    int ok=INF;
    int ng=0;
    while(ok-ng>1){
        int mid=(ok+ng)/2;
        if(check(mid)){
            ok=mid;
        }else{
            ng=mid;
        }
    }
    cout<<ok<<endl;
    return 0;
}

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

typedef vector<int> vec1;
typedef vector<vector<int>> vec2;
typedef vector<vector<char>> cvec2;
typedef pair<int, int> pairi;
typedef map<int, int> mapii;

vec1 vecplus(const vec1 &first, const vec1 &second){
  int len = first.size();
  vec1 answer(len);
  rep(i,len){
    answer.at(i) = first.at(i) + second.at(i);
  }
  return answer;
}

vec2 listmake(const int &row, const int &col){
  vec2 list;
  rep(i,row){
    vec1 v(col);
    rep(j,col){
      cin >> v.at(j);
    }
    list.push_back(v);
  }
  return list;
}

int main(){
  int N;
  cin >> N;
  if(N % 10 == 3){
    cout << "bon" << endl;
  }else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8){
    cout << "pon" << endl;
  }else{
    cout << "hon" << endl;
  }
}

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

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

int main()
{
	int a; cin>>a;
	int L=a/100,R=a%100;
	if(1<=L&&L<=12){
		if(1<=R&&R<=12) cout<<"AMBIGUOUS"<<endl;
		else cout<<"MMYY"<<endl;
	}else{
		if(1<=R&&R<=12) cout<<"YYMM"<<endl;
		else cout<<"NA"<<endl;
	}
	return 0;
}


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

int main(int argc, char const *argv[]) {
  int n, m;
  string s, t;
  cin >> s;
  cin >> t;
  n = s.size();
  m = t.size();

  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());

  if (s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main()
{
	string a;
	cin >> a;
	string b, c, d;
	b = "Sunny";
	c = "Cloudy";
	d = "Rainy";
	if (a == b)
		cout << c;
	if (a == c)
		cout << d;
	if (a == d)
		cout << b;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <functional> 
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <cstdlib>
typedef long long ll;
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
 
using namespace std;
 
int main(){

    string s;
    cin >> s;
    int k;
    cin >> k;

    set<string,greater<string> > d;
    for(int i = 0;i < s.size();i++){
        for(int j = 0;j < k && i + j < s.size();j++){
            string x = s.substr(i,j+1);
          	//cout << x <<endl;
            if(d.size() < k) d.insert(x);
            else if(x < *(d.begin())){
              	//cout << *(d.begin()) <<" "<< x <<endl;
              	auto y = d.insert(x); 
                if(y.se)d.erase(*(d.begin()));
                
            }
        }
    }
  	//for(auto w:d)cout << w << endl;
    cout << *(d.begin());

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

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;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//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) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

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

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n;
    cin>>n;
    VL ans(n);
    REP(i,n-1){
        LL a;
        cin>>a;
        ans[a-1]++;
    }
    REP(i,n){
        PUTS(ans[i]);
    }
}

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

using LL = long long;

const LL INF = 1e18;

vector<LL> solve(auto a, auto M, auto T) {
  auto mul = [&](auto v, auto w) {
    auto r = v;
    for(auto i = 0; i < T; ++i) for(auto j = 0; j < T; ++j) r[(i + j) % T] = max(r[(i + j) % T], v[i] + w[j]);
    return r;
  };

  function<vector<LL>(vector<LL>, int)> pow = [&](auto v, auto m) {
    if(!m) return vector<LL>(T, -INF);
    if(m & 1) return mul(v, pow(v, m - 1));
    return pow(mul(v, v), m >> 1);
  };

  vector<LL> v(T, -INF);
  v[0] = 0;
  for(auto i: a) v[i % T] = max(v[i % T], i);
  return pow(v, M);
}

int main() {
  int N, M, T;
  cin >> N >> M >> T;

  vector<LL> a(N);
  for(auto& i: a) cin >> i;

  auto dp = solve(a, M, T);
  for(auto i = T-1; 0 < i; --i) dp[i-1] = max(dp[i-1], dp[i]);

  int Q;
  cin >> Q;
  for(int i = 0; i < Q; ++i) {
    int A, B;
    cin >> A >> B;

    if(B <= dp[A] / T) cout << "yes" << endl;
    else               cout << "no" << endl;
  }
}

Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long int ll;
typedef pair<int, int> P;
#define INF 1e9 + 7

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

    int r, d, x;
    cin >> r >> d >> x;
    
    int last = x;
    for(int i=1; i<=10; i++){
        cout << last * r - d << endl;
        last = last * r - d;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct Fenwick{
  vector<vector<ll>> tr;
  Fenwick(){}
  Fenwick(int sz){
    tr = vector<vector<ll>>(sz, vector<ll>(sz));
  }
  void add(int x, int y, int v){
    x++, y++;

    int ox = x, oy = y;
    int res = 0;
    while(x < tr.size()){
      y = oy;
      while(y < tr.size()){
        tr[x][y] += v;
        y += y & -y;
      }
      x += x & -x;
    }
  }
  void add(int x1, int y1, int x2, int y2){
    add(x1, y1, 1);
    add(x1, y2 + 1, -1);
    add(x2 + 1, y1, -1);
    add(x2 + 1, y2 + 1, 1);
  }
  int get(int x, int y){
    x++, y++;
    int ox = x, oy = y;
    int res = 0;
    while(x){
      y = oy;
      while(y){
        res += tr[x][y];
        y -= y & -y;
      }
      x -= x & -x;
    }
    return res;
  }
};
int cnt[2001][2001];
int main()
{
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
	int n, k;
	cin >> n >> k;
	int x, y;
	char c;
	for(int i = 0;i < n;i++){
    scanf("%d %d %c", &x, &y, &c);
    if(c == 'B')
      y += k;
    y %= 2 * k;
    x %= 2 * k;
    if(x >= k && y >= k)
      x -= k, y -= k;
    if(x < k && y >= k)
      x += k, y -= k;
    cnt[x][y]++;
	}
  for(int i = 1;i < 2000;i++)
    for(int j = 0;j < 2000;j++)
      cnt[i][j] += cnt[i - 1][j];
  for(int i = 0;i < 2000;i++)
    for(int j = 1;j < 2000;j++)
      cnt[i][j] += cnt[i][j - 1];
  int res = 0;
  for(int i = 0;i <= k;i++){
    for(int j = 0;j < k;j++){
      int a1, a2, a3;
      a1 = a2 = a3 = 0;
      if(i && j){
        a1 = cnt[i - 1][j - 1];
      }
      a2 = cnt[i + k - 1][k - 1]
      - (i ? cnt[i - 1][k - 1] : 0)
      - (j ? cnt[i + k - 1][j - 1] : 0)
      + (i && j ? cnt[i - 1][j - 1] : 0);
      if(j)
        a3 = cnt[2 * k - 1][j - 1] - cnt[i + k - 1][j - 1];
      res = max(res, a1 + a2 + a3);
    }
  }
  for(int i = k + 1;i < 2 * k;i++){
    for(int j = 0;j < k;j++){
      int a1, a2, a3;
      a1 = a2 = a3 = 0;
      a1 = cnt[2 * k - 1][k - 1]
      - (i ? cnt[i - 1][k - 1] : 0)
      - (j ? cnt[2 * k - 1][j - 1] : 0)
      + (i && j ? cnt[i - 1][j - 1] : 0);
      if(j)
        a2 = cnt[i - 1][j - 1] - cnt[i - k - 1][j - 1];
      a3 = cnt[i - k - 1][k - 1] - (j ? cnt[i - k - 1][j - 1] : 0);
      res = max(res, a1 + a2 + a3);
    }
  }
  cout << res;
	return 0;
}


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

int fac(int n){
	if(n==0) return 1;
	int fac=1;
	for(int i=1;i<=n;i++) fac*=i;
	return fac;
}
int com(int n, int r){
	if(r==0||n==0) return 1;
	int com=1;
	for(int i=0;i<r;i++) com*=(n-i);
	for(int i=1;i<=r;i++) com/=i;
	return com;
}

int main() {
	pair<double, double> p[10];
	int n, num=0; cin>>n;
	double distance=0, pathes=1, path[10][10];
	
	for(int i=0;i<=n-2;i++){
		num+=fac(n-2-i)*fac(i)*com(n-2,i);
	}
	pathes=fac(n);
	
	for(int i=0;i<n;i++){
		double x, y;
		cin>>x>>y;
		p[i]=make_pair(x,y);
	}
	
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			path[i][j]=sqrt(
				pow(p[i].first-p[j].first,2)+
				pow(p[i].second-p[j].second,2));
		}
	}
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			distance+=path[i][j]*num*2;
		}
	}
	distance/=pathes;
	printf("%.7lf",distance);
	return 0;
}

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

using sll = signed long long;

int main(){
	sll X, K, D;
	std::cin >> X >> K >> D;

	const auto x_sig_ = X >= 0 ? 1 : -1;

	auto absX_ = X * x_sig_;
	auto absD_ = D < 0 ? -D : D;

	const auto minimal_ = absX_ / absD_;

	const auto ans =
		minimal_ > K
		? [=]()
	{
		const auto ret = X - K * absD_ * x_sig_;
		return ret < 0 ? -ret : ret;
	}()
		: [=]()
	{
		const auto even_case_ = X - minimal_ * absD_ * x_sig_;
		const auto odd_addition_ = - ( K - minimal_ ) % 2 * absD_ * x_sig_;
		const auto ret = even_case_ + odd_addition_;
		return ret >= 0 ? ret : -ret;
	}( );

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

	return 0;
}

Measured memory_bytes: 3196
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
int dyy[]={0,-1,0,1};
int dxx[]={-1,0,1,0};

#define int ll

int n,k;

signed main(){
    cin>>n>>k;
    
    int x;
    x=n/k;
    int y=k/2;
    int cnt=1;
    
    if(k%2==1){cout<<x*x*x<<endl;
   }else{ cnt=n*2/k-n/k;
    
    cout<<x*x*x+cnt*cnt*cnt<<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);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int ab = b-a;
        int cb = c-b;
        if(ab == cb){
            System.out.println("YES");
            return;
        }
        System.out.println("NO");
    }
}


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

int main() {
  int n, k;
  cin >> n >> k;
  unordered_set<int> have;
  for (int i = 0; i < k; ++i) {
    int d;
    cin >> d;
    for (int j = 0; j < d; ++j) {
      int a;
      cin >> a;
      have.insert(a);
    }
  }
  cout << (n - have.size()) << "\n";

  return 0;
}


Measured memory_bytes: 3256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long  a,b,c,x,y,sum1,sum2,mi,d,p,m,ans[3];
    cin>>a>>b>>c>>x>>y;
    ans[0]=a*x+b*y;

    sum1=(c)*x*2;
    if(x<y)
        mi=y-x;
    else
        mi=0;
    mi*=b;

    ans[1]=sum1+mi;

    sum2=c*y*2;
    if(x>y)
        mi=x-y;
    else
        mi=0;
    mi*=a;
    ans[2]=sum2+mi;

    sort(ans,ans+3);

        cout<<ans[0]<<endl;




    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(void) {
	int n;
	while(cin >> n && n) {
		string str;
		bool um = true;
		bool uf = false;
		bool df = false;
		int count = 0;
		for (int i = 0; i < n; ++i) {
			cin >> str;
			if (um) {
				if (str[1] == 'u') {
					if (uf) {
						++count;
						uf = false;
						um = false;
					}
					else {
						uf = true;
						df = false;
					}
				}
				else {
					uf = false;
				}
			}
			else {
				if (str[1] == 'd') {
					if (df) {
						++count;
						df = false;
						um = true;
					}
					else {
						uf = false;
						df = true;
					}
				}
				else {
					df = false;
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout<<(#x)<<" is "<<(x)<<endl
int main(){
string s;
cin>>s;
int c=0;
vector<int>v;
for(int i=0;i<3;i++)
{
    if(s[i]=='R')
        c++;
    else
        {v.push_back(c);c=0;}
}if(c>0)
v.push_back(c);
cout<<*max_element(v.begin(),v.end());

}









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

int main(){
  ll n;
  cin>>n;
  ll ans=0;
  for(ll i=1;i<=n;i++){
    ans+=i*(n+1-i);
  }
  for(int i=0;i<n-1;i++){
    ll x,y;
    cin>>x>>y;
    if(x>y){
      swap(x,y);
    }
    ans-=x*(n-y+1);
  }
  cout<<ans<<endl;
}

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

typedef long long ll;
typedef long double ld;

int niz[500005];
int ima[500005];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    string s;
    cin >> s;
    int n = s.size();
    if(s[0] == '<') ima[0] = 1;
    else ima[0] = 2;
    for(int i=1; i<n; i++){
        if(s[i] == '>' && s[i-1] == '<') ima[i] = 2;
        if(s[i] == '<' && s[i-1] == '>') ima[i] = 1;
    }
    ll sum = 0;
    if(s[n-1] == '<') ima[n] = 2;
    else ima[n] = 1;
    for(int i=0; i<=n; i++){
        if(ima[i] == 1){
            for(int j=i+1; j<=n; j++){
                niz[j] = max(niz[j], niz[j-1]+1);
                if(ima[j]) break;
            }
            for(int j=i-1; j>=0; j--){
                niz[j] = max(niz[j], niz[j+1]+1);
                if(ima[j]) break;
            }
        }
    }
    for(int i=0; i<=n; i++) sum += niz[i];
    cout << sum;
    return 0;
}


Measured memory_bytes: 4764
s = list(input())
flag = 0
for i in range(len(s)):
    if i % 2 == 1:
        if s[i] == "R":
            flag = 1
    else:
        if s[i] == "L":
            flag = 1
if flag == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
import sys
from collections import deque
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N, M = [int(x) for x in input().strip().split()]
L = [deque([]) for _ in range(N)]

for m in range(M):
    l, r, d = [int(x) for x in input().strip().split()]
    L[l-1].append((r, d))
    L[r-1].append((l, -d))

D = [0] * N
F = [False] * N

def dfs(n, d):
    # print('n = {}, d = {}'.format(n, d))
    if F[n-1]:
        if D[n-1] == d:
            # print('  already passed')
            return True
        else:
            # print('  already passed, but wrong')
            return False
    F[n-1] = True
    D[n-1] = d
    for nn, d_ in L[n-1]:
        # print('  dfs({}, {})'.format(nn, d+d_))
        if not dfs(nn, d+d_):
            return False
    else:
        return True

for n in range(1, N+1):
    if not dfs(n, D[n-1]):
        print('No')
        exit()
else:
    print('Yes')

Measured memory_bytes: 183480
#!/usr/bin/env python
# coding: utf-8

# In[20]:


A,B,C = map(int, input().split())


# In[22]:


A_ = A
B_ = B
C_ = C

ans = 0
while True:
    if A_%2 != 0 or B_%2 != 0 or C_%2 != 0:
        print(ans)
        break
    else:
        A_tmp = B_//2 + C_//2
        B_tmp = A_//2 + C_//2
        C_tmp = A_//2 + B_//2
        A_ = A_tmp
        B_ = B_tmp
        C_ = C_tmp
        ans += 1
#         print(A_,B_,C_)
        if A_ == A and B_ == B and C_ == C:
            print(-1)
            break


# In[ ]:






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

int main(void)
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b == c || a + c == b || b + c == a)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

long long n, x[100005], ans, a, b;

int main()
{
    cin >> n >> a >> b;
    for(int i = 0; i < n; i++){
        cin >> x[i];
        if(i == 0) continue;
        if(a * (x[i] - x[i - 1]) > b){
            ans += b;
        }
        else {
            ans += a * (x[i] - x[i - 1]);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(){
	long long a,a1,a2;
	scanf("%lld %lld %lld",&a,&a1,&a2);
	long long t = a1+(a-1)*a2-(a1*(a-1)+a2);
	if(t>=0){
		printf("%lld\n",t+1);
	}
	else printf("0\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using ulint = unsigned long long int;
using uint = unsigned int;

//#define DEBUG
#ifdef DEBUG
#define dump(i) cout << "[*]" #i " : " << i << endl;
#else
#define dump(i)
#endif

int main() {
  int n, idx = 0;
  cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  vector<int> h(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i] >> h[i];
    if (h[i] != 0) {
      idx = i;
    }
  }
  for (int i = 0; i <= 100; ++i) {
    for (int j = 0; j <= 100; ++j) {
      lint v = h[idx] + abs(x[idx] - i) + abs(y[idx] - j);
      bool flag = true;
      for (int k = 0; k < n; ++k) {
        lint vv = max(v - abs(x[k] - i) - abs(y[k] - j), 0LL);
        if (h[k] != vv) {
          flag = false;
        }
      }
      if (flag) {
        cout << i << " " << j << " " << v << endl;
        return 0;
      }
    }
  }
  return 0;
}

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

static const int N = 100;
static const int INF = (1 << 21);

int n, M[N][N];
int d[N]; // 距離で訪問状態を管理する

void bfs(int s) {
	queue<int> q;
	q.push(s);
	for (int i = 0; i < n; i++) d[i] = INF;
	d[s] = 0;
	int u;
	while (!q.empty()) {
		u = q.front(); q.pop();
		for (int v = 0; v < n; v++) {
			if (M[u][v] == 0) continue;
			if (d[v] != INF) continue;
			d[v] = d[u] + 1;
			q.push(v);
		}
	}

	for (int i = 0; i < n; i++) {
		cout << i + 1 << " " << ((d[i] == INF) ? (-1) : d[i]) << endl;
	}
}

int main() {
	int u, k, v;

	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) M[i][j] = 0;
	}

	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		u--; // 0オリジン
		for (int j = 0; j < k; j++) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}

	bfs(0);
	
	return 0;
}


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

int main(void){
    long long N;
    cin>>N;
    long long temp=N;
    long long sum=0;
    while(temp>0){
        sum+=temp%10;
        temp=temp/10;
    }
    if(N%sum==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



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

ll A[1005],B[1005];
ll dp[1005][10005];

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);


  ll h,n;cin>>h>>n;

  for(int i=0;i<n;i++){
    cin>>A[i]>>B[i];
  }
  for(int i=0;i<=n;i++){
    for(int j=0;j<=h;j++){
      dp[i][j]=pow(10,8);
    }
  }
  for(int i=0;i<n;i++){
    auto a = A[i], b = B[i];
    dp[i][0]=0;
    for(int j=0;j<=h;j++){
      auto damage = min(h, j + a);
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
      dp[i + 1][damage] = min(dp[i + 1][damage], dp[i + 1][j] + b);
    }
  }

  cout<<dp[n][h]<<endl;

  
  return 0;
}


Measured memory_bytes: 78464
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
struct Edge{
	int v,c,nxt;
}e[50010];int tot;
int first[210];
void build(int u,int v,int c)
{
	e[++tot]=(Edge){v,c,first[u]};
	first[u]=tot;
	return ;
}
void adde(int u,int v,int c)
{
	build(u,v,c);
	build(v,u,0);
	return ;
}
int S,T;
int dep[210];
queue<int>q;
bool bfs()
{
	memset(dep,0,sizeof(dep));
	dep[S]=1;q.push(S);
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		for(int i=first[u];i;i=e[i].nxt)
			if(e[i].c&&!dep[e[i].v])
			{
				dep[e[i].v]=dep[u]+1;
				q.push(e[i].v);
			}
	}
	return dep[T]>0;
}
int cur[210];
int dfs(int u,int flow)
{
	if(u==T)return flow;
	for(int &i=cur[u];i;i=e[i].nxt)
		if(e[i].c&&dep[u]+1==dep[e[i].v])
		{
			int d=dfs(e[i].v,min(flow,e[i].c));
			if(d){
				e[i].c-=d;
				e[i^1].c+=d;
				return d;
			}
		}
	return 0;
}
void dinic()
{
	int ans=0;
	while(bfs())
	{
		for(int i=0;i<=T;i++)
			cur[i]=first[i];
		int d;
		while(d=dfs(S,1e9))ans+=d;
	}
//	printf("%d\n",ans);
	return ;
}
int n,m;
int a[110][110];
int b[110][110];
int c[110][110];
bool book[110][110];
int col(int x)
{
	return (x-1)/m+1;
}
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			scanf("%d",&a[i][j]);
	for(int i=1;i<=m;i++)
	{
		tot=1;memset(first,0,sizeof(first));
		S=0;T=2*n+1;
		for(int j=1;j<=n;j++)
		{
			adde(S,j,1);
			adde(j+n,T,1);
		}
		for(int j=1;j<=n;j++)
			for(int k=1;k<=m;k++)
				if(!book[j][k])
					adde(j,n+col(a[j][k]),1);
		dinic();
		for(int j=1;j<=n;j++)
		{
			int ccol=0;
			for(int k=first[j];k;k=e[k].nxt)
			{
				int v=e[k].v-n;
				if(e[k].c||v<1||v>n)continue;
				ccol=v;break;
			}
			for(int k=1;k<=m;k++)
				if(!book[j][k]&&col(a[j][k])==ccol){
					book[j][k]=true;
					b[j][i]=a[j][k];
					break;
				}
		}
	}
	for(int i=1;i<=m;i++)
		for(int j=1;j<=n;j++)
			for(int k=1;k<=n;k++)
				if(col(b[k][i])==j)c[j][i]=b[k][i];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			printf("%d%c",b[i][j],j==m?'\n':' ');
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			printf("%d%c",c[i][j],j==m?'\n':' ');
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
using namespace std;
using ll = long long;
int main(void){
    int n;
    cin >> n;
    int ans=0;
    for(int i=1;i<=n;i++){
        ans+=i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        //
        //Compute c1 = new Compute();//計算系
        //変数
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        int answer = 0;
        //String answer="No";
        //StringBuilder answer=new StringBuilder();
        //List<Integer> list = new ArrayList<>();
        //int array[] = new int[];

        //入力
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int r = sc.nextInt();
        Set<Integer> set=new HashSet<>();

        for (int i=l;i<=r;++i)
        {
            set.add(i%2019);
            if (set.size()==2019) {break;}
        }

        int a[]=new int[set.size()];
        int ind=0;
        for (int i:set)
        {
            a[ind]=i;
            ++ind;
        }

        for (int i=0;i<a.length;++i)
        {
            for (int j=i+1;j<a.length;++j)
            {
                min=Math.min(min,(a[i]*a[j])%2019);
            }
        }
        answer=min;
        //出力
        //BigDecimal bd = new BigDecimal(answer);
        //System.out.println(bd.setScale(12,BigDecimal.ROUND_DOWN));
        //System.out.println(String.format("%.0f",answer));
        System.out.println(answer);
    }
}

Measured memory_bytes: 24020