akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

typedef struct {
  int id;
  int parent;        //親
  int child;         //子
  int right_sibling; //兄弟(右隣)
  int depth;         //深さ
}Node;

Node node[100000]; 
int c[100000];

main()
{
  int n, i, j, id, degree;
  
  scanf("%d", &n);
  
  for(i=0; i<n; i++)
    {
      node[i].parent = -1;
      node[i].child = -1;
      node[i].right_sibling = -1;
      node[i].depth = 0;
    }
  
  for(i=0; i<n; i++)
    {
      scanf("%d %d", &id, &degree);
      node[id].id = id;
      for(j=0; j<degree; j++)
        {
          scanf("%d", &c[j]);
          if(j == 0)
            {
              node[id].child = c[j];
            }
          else if(j != 0)
            {
              node[c[j-1]].right_sibling = c[j];
            }
          node[c[j]].parent = id;
          node[c[j]].id = c[j];
          // node[node[c[j]].id].depth = node[id].depth + 1;
        }
    }
  
  for(i=0; i<n; i++)
    {
      j = node[i].parent;
      
      while(1)
        {
          if(j == -1)
            {
              break;
            }
          
          j = node[j].parent;
          node[i].depth++;
        }
    }
  
 
  for(i=0; i<n; i++)
    {
      printf("node %d: parent = %d, depth = %d, ", node[i].id, node[i].parent, node[i].depth);
      
      if(node[i].parent == -1)
        {
          if(node[i].child != -1)
            {
              printf("root, [%d", node[i].child);
              j = node[i].child;
              while(node[j].right_sibling != -1)
                {
                  printf(", %d", node[j].right_sibling);
                  j = node[j].right_sibling;
                }
              printf("]\n");
            }
          else
            {
              printf("root, []\n");
            }
        }
      else if(node[i].parent != -1)
        {
          if(node[i].child != -1)
            {
              printf("internal node, [%d", node[i].child);
              j = node[i].child;
              while(node[j].right_sibling != -1)
                {
                  printf(", %d", node[j].right_sibling);
                  j = node[j].right_sibling;
                }
              printf("]\n");
            }
          else
            {
              printf("leaf, []\n");
            }
        }
      
    }

  return 0;
}

Measured memory_bytes: 2956
import sys
h, w = map(int, sys.stdin.readline().split())
dp = [[0] * w for _ in range(h)]
G = [list(map(int, i.split())) for i in sys.stdin.readlines()]
for x in range(h):
    dp[x][0] = 1 if G[x][0] == 0 else 0
for y in range(w):
    dp[0][y] = 1 if G[0][y] == 0 else 0
for i in range(1, h):
    for j in range(1, w):
        if(G[i][j] == 0):
            dp[i][j] = min(dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1]) + 1
print(max(max(i) for i in dp) ** 2)

Measured memory_bytes: 60408
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int a, b;
int d[10010];
/*==================================================*/
/*function*/

/*==================================================*/

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

    d[1] = 1;
    REP(i,2,1000){
        d[i] = d[i-1] + i;
        if(b-a == i){
            cout<<d[i-1] - a<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

int main(){
	int N,A;
	cin >> N >> A;

	string ans;
	if(N%500<=A){
		ans="Yes";
	}else{
		ans="No";
	}

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

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

signed main() {
	int n;
	cin >> n;
	int a[100005];
	rep(i, n) cin >> a[i];
	int sa[100005];
	sort(a, a + n);
	rep(i, n - 1) {
		sa[i] = a[i + 1] - a[i];
	}
	int ans = 0;
	if (n % 2 == 0) {
		int now = 0;
		rep(i, n / 2 - 1) {
			now += 2;
			ans += now * (sa[i] + sa[n - 2 - i]);
			//cout << now << " " << sa[i] << " " << sa[n - 2 - i] << endl;
			//now *= 2;
		}
		ans += (now + 1) * sa[n / 2 - 1];
		//cout << now + 1 << " " << sa[n / 2 - 1] << endl;
		cout << ans << endl;
	}
	else {
		int now = 0;
		rep(i, n / 2 - 1) {
			now += 2;
			ans += now * (sa[i] + sa[n - 2 - i]);
		}
		ans += (now + 1) * min(sa[n / 2], sa[n / 2 - 1]) + (now + 2) * max(sa[n / 2], sa[n / 2 - 1]);
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main() {

	int A, B, C;
	cin >> A >> C >> B;
	if(A > C) {
		int s = C;
		C = A;
		A = s;
	}

	if( A < B && B < C) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int N; cin >> N;
	string S, ans; cin >> S;
	ans = S;

	for(int i = 0; i < S.size(); ++i){
		if(S[i]+N <= 'Z') ans[i] = S[i]+N;
		else ans[i] = S[i]-26+N;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import sys

#S = 'RRLRL'
#S = 'RRRLLRLLRRRLLLLL'
#S = 'RRLLLLRLRRLL'
S = input()

RL = [1]*len(S)
for i in range(len(S)-1):
	if S[i]=='R' and S[i+1]=='R':
		RL[i+1] += RL[i]
		RL[i] = 0
for i in range(len(S)-1,1,-1):
	if S[i]=='L' and S[i-1]=='L':
		RL[i-1] += RL[i]
		RL[i] = 0
print(RL,file=sys.stderr)

i = 0
while i < len(S)-1:
	if RL[i]==0 or RL[i+1]==0:
		i += 1
		continue

	a = RL[i]//2 + RL[i+1]//2
	b = RL[i]//2 + RL[i+1]//2
	if RL[i  ]%2==1: a += 1
	if RL[i+1]%2==1: b += 1
	RL[i],RL[i+1] = a,b
	i += 2
print(RL,file=sys.stderr)

for i in range(len(S)):
	print('{} '.format(RL[i]),end='')
print()



Measured memory_bytes: 61928
#include <stdio.h>
int main(void)
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if(a<b && b<c)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 2692
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// 複数行の標準入力
		ArrayList<String> strList = new ArrayList<String>();
		Scanner in = new Scanner(System.in);
		while (in.hasNext()) {
			String buf = in.nextLine();
			strList.add(buf);
		}
		in.close();

		// 入力データの分割
		String[] HW = strList.get(0).split(" ");
		int h = Integer.parseInt(HW[0]);
		int w = Integer.parseInt(HW[1]);

		// 入力データの整理
		strList.remove(0);
		Boolean[][] inputData = new Boolean[h][w];
		for (int i = 0; i < strList.size(); i++) {
			inputData[i] = new Boolean[w];
			String tmp = strList.get(i);
			// 文字列の分割
			for (int j = 0; j < tmp.length(); j++) {
				// 通り道ならtrue
				inputData[i][j] = tmp.charAt(j) == '#';
			}
		}

		// 入力データのチェック
		// 右か下にしか移動できない

		int down = 0;
		int right = 0;
		while (true) {
			if (inputData[down][right]) {
				// 通過点をチェック
				inputData[down][right] = false;
			} else {
				break;
			}
			// 最終地点まで到達
			if (right == (w - 1) && down == (h - 1)) {
				break;
			}

			if (down < (h - 1) && inputData[down + 1][right]) {
				down++;
			} else if (right < (w - 1) && inputData[down][right + 1]) {
				right++;
			} else {
				break;
			}
		}

		boolean ngCheck = false;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (inputData[i][j]) {
					ngCheck = true;
				}
			}
		}
		if (ngCheck) {
			System.out.println("Impossible");
		} else {
			System.out.println("Possible");
		}
	}
}


Measured memory_bytes: 9172
from fractions import gcd

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

if A % 2 != 0 or B % 2 != 0 or C % 2 != 0:
    print(0)
elif A == B and B == C:
    print(-1)
else:
    n = gcd(gcd(A+B, B+C), C+A)
    ans = 0
    while n % 2 == 0:
        ans += 1
        n //= 2
    print(ans)

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

int main()
{
	long long int n;
	cin>>n;
	if(n==1)
	cout<<1.000000000;

else if(n%2==0)
	cout<<0.500000000;
	else
	cout<<((n/2)+1)/(n*1.0);
	
	
	
	return 0;
}



Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

const int maxn =300003, INF = 0x7f7f7f7f;
int low[maxn], a[maxn];
int n, ans;

int binary_search(int *a, int r, int x)
//二分查找，返回a数组中第一个>=x的位置
{
    int l = 1, mid;
    while(l <= r)
    {
        mid = (l+r) >> 1;
        if(a[mid] <= x)
            l = mid + 1;
        else
            r = mid - 1;
    }
    return l;
}

int main()
{
    scanf("%d", &n);
    for(int i=1; i<=n; i++)
    {
        scanf("%d", &a[i]);
        low[i] = INF;   //由于low中存的是最小值，所以low初始化为INF
    }
    low[1] = a[1];
    ans = 1;   //初始时LIS长度为1
    for(int i=2; i<=n; i++)
    {
        if(a[i] < low[ans])    //若a[i]>=low[ans]，直接把a[i]接到后面
            low[++ans] = a[i];
        else       //否则，找到low中第一个>=a[i]的位置low[j]，用a[i]更新low[j]
            low[binary_search(low, ans, a[i])] = a[i];
    }
    printf("%d\n", ans);   //输出答案
    return 0;
}


Measured memory_bytes: 1792
def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x]) #経路圧縮
        return par[x]
def same(x,y):
    return find(x) == find(y)
def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    par[x] = y
    size[y] = size[x] + size[y]
    size[x] = 0

N,M = list(map(int, input().split()))
plist = list(map(int,input().split()))
ABs = [list(map(int, input().split())) for _ in range(M)]
par = [i for i in range(N+1)]
size = [1 for _ in range(N+1)]

for AB in ABs:
    unite(AB[0],AB[1])

Ans = 0
for i in range(len(plist)):
    if plist[i] == i+1:
        Ans +=1
    else:
        if same(plist[i],i+1):
            Ans += 1
print(Ans)

Measured memory_bytes: 35692
def AppendQue(now, depth, que, past_visit, maze):
    Next = ((now[0] - 1, now[1]), (now[0], now[1] - 1),
            (now[0] + 1, now[1]), (now[0], now[1] + 1))
    for h, w in Next:
        if h < 0 or w < 0 or h >= H or w >= W:
            continue
        elif (h, w) in past_visit:
            continue
        elif maze[h][w] == "#":
            continue
        elif (h, w) in que:
            continue

        que.append((h, w))
        depth[(h, w)] = depth[now] + 1


H, W = map(int, input().split())

maze = []
black = 0
for i in range(H):
    maze.append(input())
    black += maze[i].count("#")

if maze[0][0] == "#" or maze[H - 1][W - 1] == "#":
    print(-1)
    exit()

que = []
now = (0, 0)
depth = {}
depth[now] = 1
que.append(now)
past_visit = set()
while True:
    if len(que) == 0:
        print(-1)
        exit()
    now, que = que[0], que[1:]
    if now == (H - 1, W - 1):
        break
    past_visit.add(now)
    AppendQue(now, depth, que, past_visit, maze)

print(H * W - black - depth[(H - 1, W - 1)])

Measured memory_bytes: 3700
#include<stdio.h>

int main()
{
   int a,b;
   while(true)
   {
       scanf("%d %d",&a,&b);
       if(a==0&&b==0) break;
       if(a<=b)
       {
           printf("%d %d\n",a,b);
       }
       else
       {
           printf("%d %d\n",b,a);
       }
   }
}


Measured memory_bytes: 2600
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define int long long
const int mod=1e9+7;
const int N=4e5+5;
int n,m,S,T,sum,top,ans,x[N],y[N],z[N],dis[5][N],vis[N],gs[5][N],head[N];
struct E{
	int too,next,zh;
}edge[N*2];
struct node{
	int id,val;
};
bool operator < (node a,node b)
{
	return a.val>b.val;
}
void add(int a,int b,int c)
{
	edge[++top].too=b;edge[top].zh=c;
	edge[top].next=head[a];head[a]=top;
}
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
void dj(int s,int op)
{
	memset(dis[op],0x3f,sizeof(dis[op]));
	priority_queue<node>q;
	q.push((node){s,0});
	dis[op][s]=0;gs[op][s]=1;
	memset(vis,0,sizeof(vis));
	while(!q.empty())
	{
		int u=q.top().id;q.pop();
		if(vis[u])continue;
		vis[u]=1;
		for(int i=head[u];i;i=edge[i].next)
		{
			int v=edge[i].too,w=edge[i].zh;
			if(dis[op][v]>dis[op][u]+w)
			{
				dis[op][v]=dis[op][u]+w;
				gs[op][v]=0;
				q.push((node){v,dis[op][v]});
			}
			if(dis[op][v]==dis[op][u]+w)
			{
				gs[op][v]=(gs[op][v]+gs[op][u])%mod;
			}
		}
	}
}
signed main()
{
	n=read();m=read();
	S=read();T=read();
	for(int i=1;i<=m;i++)
	{
		x[i]=read(),y[i]=read(),z[i]=read();
		add(x[i],y[i],z[i]);
		add(y[i],x[i],z[i]);
	}
	dj(S,1);
	dj(T,2);
	if(dis[1][T]==0x3f3f3f3f3f3f3f3f){puts("0");return 0;}
	sum=dis[1][T];
	ans=gs[1][T]*gs[2][S]%mod;
//	cout<<ans<<endl;
	for(int i=1;i<=n;i++)
	{
		if(dis[1][i]*2==sum&&dis[2][i]*2==sum)ans=(ans-gs[1][i]*gs[1][i]%mod*gs[2][i]%mod*gs[2][i]%mod+mod)%mod;
//		if(dis[2][i]+dis[1][i]==sum)ans=(ans-gs[2][i]*gs[1][i]%mod+mod)%mod;
//		cout<<ans<<endl;
	}
//	cout<<ans<<endl;
//	if(sum%2==1){cout<<ans<<endl;return 0;}
	for(int i=1;i<=m;i++)
	{
		int xu=(dis[2][y[i]]+z[i]-dis[1][x[i]])/2;
		if(dis[1][x[i]]+dis[2][y[i]]+z[i]==sum&&xu>0&&xu<z[i])ans=(ans-gs[1][x[i]]*gs[1][x[i]]%mod*gs[2][y[i]]%mod*gs[2][y[i]]%mod+mod)%mod;
		xu=(dis[1][y[i]]+z[i]-dis[2][x[i]])/2;
		if(dis[2][x[i]]+dis[1][y[i]]+z[i]==sum&&xu>0&&xu<z[i])ans=(ans-gs[2][x[i]]*gs[2][x[i]]%mod*gs[1][y[i]]%mod*gs[1][y[i]]%mod+mod)%mod;
	}
	cout<<ans;
}
/*
给出一张n个节点,m条边的无向图，给出起点s和终点t。询问两个人分别从s和t出发，走最短路不相遇的方案数。
最短路计数好题，减去不符合条件的。
不符合条件的，我们dis[s][x]+dis[t][x]=dis[s][t]
枚举在哪个点（边）相遇 
*/

Measured memory_bytes: 44756
#include<iostream>
#include<cstdio>
#include<map>
#include<algorithm>
#define LL long long

using namespace std;
const int N = 1e4+7;
int main()
{
	ios :: sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	int n;
	cin>>n;
	string s;
	int ans=0,kBA=0,Bk=0,kA=0;
	for(int i=0;i<n;i++){
		cin>>s;
		int len=s.size() ;
		for(int i=1;i<len;i++) {
			if(s[i]=='B'&&s[i-1]=='A') ans++;
		}
		if(s[0]=='B'&&s[len-1]=='A') kBA++;
		else if(s[0]=='B') Bk++;
		else if(s[len-1]=='A') kA++;
	}
	if(kBA>0) {
		ans+=kBA-1;
		if(Bk) ans++,Bk--;
		if(kA) ans++,kA--;
	}
	ans+=min(Bk,kA);
	cout<<ans<<endl;
	return 0;
 } 

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

using namespace std;
using ll = long long;

int main() {
    int k;
    cin >> k;
    ll sum = 0;
    for (int i = 1; i <= k; ++i) {
        for (int j = 1; j <= k; ++j) {
            for (int m = 1; m <= k; ++m) {
                ll n = __gcd(__gcd(i, j), m);
                sum += n;
            }
        }
    }
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 3640
n = int(input())
flag = True
ls = list(map(int, input().split()))
ls[0] -= 1

for i in range(n - 1):
    if ls[i] > ls[i + 1]:
        flag = False
        break
    elif ls[i] < ls[i + 1]:
        ls[i + 1] -= 1

if flag:
	print('Yes')
else:
	print('No')


Measured memory_bytes: 15020
n = int(input())
ca, cb = 0, 0
for i in range(n):
    a, b = map(int,input().split())
    x, y = 1, 1
    if ca > a:
        x = ca // a
        if ca % a:
            x += 1
    if cb > b:
        y = cb // b
        if cb % b:
            y += 1
    x = max(x, y)
    ca = a * x
    cb = b * x
print(ca + cb)


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

using namespace std;
using ll = long long int;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<priority_queue<int>> q(n);
    int index = 0;
    q[0].push(a[0]);
    for(int i = 1; i < n; i++)
    {
        if(a[i] <= a[i - 1]){
            for(int j = index + 1; j < n; j++)
            {
                if(q[j].empty())
                {
                    q[j].push(a[i]);
                    index = j;
                    break;
                }else if(q[j].top() < a[i])
                {
                    q[j].push(a[i]);
                    index =  j;
                    break;
                }
            }
        }else{
            for(int j = 0; j <= index; j++)
            {
                if(q[j].empty())
                {
                    q[j].push(a[i]);
                    index = j;
                    break;
                }else if(q[j].top() < a[i])
                {
                    q[j].push(a[i]);
                    index = j;
                    break;
                }
            }
        }
    }
    int count = 0;
    for(int i = 0; i < n; i++)
    {
        if(q[i].size() != 0) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
	
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int ans = a + b + c - max(max(a, b), c);
	cout << ans << endl;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(a,j,n) for(ll i=a;i<j;i=i+n )
typedef pair<ll,ll> P;
const ll mod = 1000000007;
const ll INF = 1000000009;
ll i;

int main(){
    ll A,B,M;
    cin>>A>>B>>M;
    V a(A), b(B);
    rep(0,A,1)cin>>a.at(i);
    rep(0,B,1)cin>>b.at(i);
    V x(M),y(M),c(M);
    rep(0,M,1)cin>>x.at(i)>>y.at(i)>>c.at(i);
    ll mina=a.at(0),minb=b.at(0);
    rep(1,A,1)mina=min(mina,a.at(i));
    rep(1,B,1)minb=min(minb,b.at(i));
    ll ans=mina+minb;
    rep(0,M,1){
        ans=min(a.at(x.at(i)-1)+b.at(y.at(i)-1)-c.at(i),ans);
    }
    cout<<ans<<endl;


}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);

  int s;
  cin >> s;
  cout << s / 3600 << ":" << (s % 3600) / 60 << ":" << s % 60 << endl;
  return 0;
}



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

int main(){
  string s;
  cin >>s;
  int a = 0;
  a += s[0]=='+' ? 1:-1;
  a += s[1]=='+' ? 1:-1;
  a += s[2]=='+' ? 1:-1;
  a += s[3]=='+' ? 1:-1;
  cout << a<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    clock_t start = clock();

    ll d; cin>>d;
    vl cs(26); cin>>cs;
    vvl ss(d, vl(26)); cin>>ss;

    std::random_device rnd;
    std::mt19937 mt(rnd());
    std::uniform_int_distribution<> rd(0, d - 1);
    std::uniform_int_distribution<> rq(0, 25);
    std::uniform_int_distribution<> rp(0, 100);

    ll ans = 0;
    vl last(26, -1);
    vl ts(d);
    rep(i, d) {
        ll m = -LINF;
        ll mi = 0;
        rep(j, 26) {
            ll temp = ans + ss[i][j];
            vl tlast(26);
            copy(rng(last), tlast.begin());
            last[j] = i;
            rep(k, 26) {
                temp -= cs[k] * (i - last[k]);
            }
            if (temp > m) {
                m = temp;
                mi = j;
            }
            else swap(last, tlast);
        }
        ans = m;
        ts[i] = mi;
    }

    ll m = 0;
    vl mv(d);
    clock_t end = clock();
    while (static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0 < 1900.0) {
        ll e = rd(mt);
        ll q = rq(mt);
        while (ts[e] == q) {
            e = rd(mt);
            q = rq(mt);
        }
        ll temp = 0;
        ll p = ts[e];
        ts[e] = q;
        vl last(26, -1);
        rep(i, d) {
            temp += ss[i][ts[i]];
            last[ts[i]] = i;
            rep(j, 26) {
                temp -= cs[j] * (i - last[j]);
            }
        }
        if (temp < ans && rp(mt) < 99) {
            ts[e] = p;
        }
        else ans = temp;
        end = clock();
        if (m < ans) {
            m = ans;
            copy(rng(ts), mv.begin());
        }
    }
    rep(i, d) cout<<mv[i] + 1<<endl;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
int main(){
    ll n,m;
    cin >> n >> m;
    ll ans = 0;
    ans += min(n,m/2);
    n -= ans;
    m -=ans*2;
    cout << ans + m/4 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int X;
int L[100];
int main(){
  int i, s=0;
  rd(N);
  rd(X);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(L[Lj4PdHRW]);
    }
  }
  for(i=0;i<N;i++){
    s += L[i];
    if(s > X){
      break;
    }
  }
  wt_L(i+1);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190706-1

// --- original code ---
// int N, X, L[100];
// {
//   int i, s = 0;
//   rd(N,X,L(N));
//   rep(i,N){
//     s += L[i];
//     if(s > X) break;
//   }
//   wt(i+1);
// }


Measured memory_bytes: 256
//bismillah
//author anaksoleh
//creadit errichto
//26 Dec 2019
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll INF = 1e18L + 5;

void min_self(ll *a,ll b){
    *a = min(*a,b);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N,W;
    cin >> N >> W;
    vector<int> weight(N) , val(N);
    int sum_val = 0;
    for(int i = 0 ; i < N ; i++){
        cin >> weight[i] >> val[i];
        sum_val += val[i];
    }
    vector<ll> dp(sum_val+1,INF);
    dp[0] = 0;
    for(int item = 0 ; item < N ; item++){
        for(int val_already = sum_val - val[item] ; val_already >= 0 ; val_already--){
            min_self(&dp[val_already+val[item]],dp[val_already] + weight[item]);
        }
    }
    ll ans = 0;
    for(int i = 0 ; i < sum_val + 1 ; i++){
        if(dp[i] <= W){
            ans = max(ans,(ll)i);
        }
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1024
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
#include<cmath>
#include<cstdio>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;
typedef pair<int, int> P;
int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

int main() {
	ll i, j, k, l, m, n, sum, flag, cc,M,X,H,W,K,A,B;
	char N[100001];
	cin >> N;
	int n0, n1;
	n0 = n1 = 0;
	REP(i, 0, strlen(N)) {
		if (N[i] == '0') {
			n0++;
		}
		else
			n1++;
	}
	output(strlen(N)-abs(n0 - n1));
	
	return 0;
}

Measured memory_bytes: 384
// Java program For handling Input/Output 
import java.io.*; 
import java.util.*;
import java.math.*;
//import java.awt.*;

public class Main 
{ 
    FastReader sc;
    //actual logic
    void solve() throws IOException{
        long h = sc.nl();
        long ans = 0;
        long exp = 1;
        while(h > 0)
        {
            ans += exp;
            exp *= 2;
            h /= 2;
        }
        System.out.println(ans);

    }   

    //constructor
    Main()
    {
        try{  
            sc = new FastReader();
        }catch(Exception e){
            System.out.println(e);
        }
    }


    //main metohd
    public static void main(String[] args) throws IOException
    { 
     new Main().solve();
 }
    //Utility methods

 static class FastReader{
    BufferedReader br;
    StringTokenizer st;
    FastReader(){
        br = new BufferedReader(new InputStreamReader(System.in));
        try{
            st = new StringTokenizer(br.readLine());
        }catch(Exception e){
            System.out.println(e);
        }
    }

    FastReader(String s){
        try{
            br = new BufferedReader(new FileReader(s));
            st = new StringTokenizer(br.readLine());
        }catch(Exception e){
            System.out.println(e);
        }
    }

    String ns(){
        if(!st.hasMoreTokens())
        {
            try{
                st = new StringTokenizer(br.readLine());
            }catch(Exception e){
                System.out.println(e);
            }    
        }
        return st.nextToken();

    }

    int ni(){
        return Integer.parseInt(ns());
    }

    long nl(){
        return Long.parseLong(ns());
    }

    double nd(){
        return Double.parseDouble(ns());
    }
}
}


Measured memory_bytes: 22484
#include <cstdio>
#include <bitset>

int n,a,s;
std::bitset<2002005> b;

int main()
{
    for(b[0]=1,scanf("%d",&n);n--;)
        scanf("%d",&a),b|=b<<a,s+=a;
    for(int i=(s+1)>>1;true;++i)if(b[i])return printf("%d\n",i),0;
}

Measured memory_bytes: 896
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);


int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    int max_l = 0;
    rep(i, n) {
        cin >> l[i];
        max_l = max(l[i], max_l);
    }
    int summ = 0;
    int plused = 0;
    rep(i, n) {
        summ += l[i];
    }
    if (max_l < summ - max_l) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

typedef long long ll;

using namespace std;

ll n, a[200005], ans, cnt;

int main() {
    cin >> n;
    for (ll i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1);
    ans += a[n];
    cnt = n - 2;
    for (ll i = n - 1; i >= 1; i--) {
        if (cnt < 1) break;
        if (cnt == 1) ans -= a[i];
        ans += 2 * a[i];
        cnt -= 2;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

int kw[21],kd[21];

int main(){

  while(1){
    int w,d,sum=0;
    cin >> w >> d;
    if (w==0)break;
    rep(i,21)kw[i]=0;
    rep(i,21)kd[i]=0;
    rep(i,w){
      int hw;
      cin >> hw;
      kw[hw]++;
    }
    rep(i,d){
      int hd;
      cin >> hd;
      kd[hd]++;
    }
    rep(i,21){
      sum += max(kw[i],kd[i])*i;
    }
    cout << sum << endl;
  }

  return 0;
}



Measured memory_bytes: 2988
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		sc.close();
		
		char[] abc = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r',
				's','t','u','v','w','x','y','z'};
		
		boolean none = true;
		
		
		for(char alfa: abc) {
			if(s.indexOf(alfa) == -1) {
				System.out.println(alfa);
				none = false;
				break;
			}
		}
		
		if(none) {
			System.out.println("None");
		}

	}

}


Measured memory_bytes: 38876
object Main extends App {
  val n = scala.io.StdIn.readInt()
  var playList = Vector.empty[(String, Int)]
  (1 to n).foreach { _ =>
    val stInput = scala.io.StdIn.readLine()
    val stInputArray = stInput.split(" ")
    val title = stInputArray(0)
    val time = stInputArray(1).toInt
    playList :+= (title, time)
  }
  val sleepTitle = scala.io.StdIn.readLine()
  var sleepTitleFind = false
  var sleepTime = 0
  playList.foreach { p =>
    if (sleepTitleFind) {
      sleepTime = sleepTime + p._2
    } else {
      if (p._1 == sleepTitle) {
        sleepTitleFind = true
      }
    }
  }
  println(sleepTime)
}

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h+2);
    rep(i,h) cin >> s[i];

    bool ans = true;
    rep(i,h){
        rep(j,w){
            char c = s[i][j];
            if(c == '.') continue;
            bool b = false;
            if(i != 0){
                if(s[i-1][j] == '#'){
                    b = true;
                    continue;
                }
            }
            if(i != h-1){
                if(s[i+1][j] == '#'){
                    b = true;
                    continue;
                }
            }
            if(j != 0){
                if(s[i][j-1] == '#'){
                    b = true;
                    continue;
                }
            }
            if(j != w-1){
                if(s[i][j+1] == '#'){
                    b = true;
                    continue;
                }
            }
            if(!b){
                ans = false;
                break;
            }
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
use std::cmp::{max, min};
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(
        it,
        n: usize,
        vw: [(usize, usize); n],
        q: usize,
        vl: [(u1, usize); q]
    );
    let nu = min(2usize.pow(9) - 1, n);
    let wm = vl.iter().map(|(_, l)| *l).max().unwrap();
    let mut dp = vec![vec![0; wm + 1]; nu];

    let (v, w) = vw[0];
    for j in w..(wm + 1) {
        dp[0][j] = v;
    }

    for i in 1..nu {
        let (v, w) = vw[i];
        for j in 0..(wm + 1) {
            let pi = (i - 1) / 2;
            dp[i][j] = max(if j >= w { dp[pi][j - w] + v } else { 0 }, dp[pi][j]);
        }
    }

    let mut vws = vec![(0usize, 0usize)];
    let mut buf = vec![];
    for &(i, l) in vl.iter() {
        if i < nu {
            println!("{}", dp[i][l]);
        } else {
            let mut u = i;
            while u >= nu {
                let (vu, lu) = vw[u];
                for &(v, l) in vws.iter() {
                    buf.push((v + vu, l + lu));
                }
                vws.append(&mut buf);
                u = (u - 1) / 2;
            }

            let mut ret = dp[u][l];
            for &(v, w) in vws.iter() {
                if l >= w {
                    ret = max(ret, dp[u][l - w] + v)
                }
            }
            vws.clear();
            vws.push((0, 0));
            buf.clear();
            println!("{}", ret);
        }
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 412596
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())


typedef struct{
  ll pos;
  ll depth;
} data;
//
// struct Node{
//
// }



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

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }

// ll gcd(ll m, ll n){
//   if(m<n) swap(m,n);
//   if(n==0) return m;
//   return gcd(n, m%n);
// }





int main() {

  ll N,K;
  cin >> N>>K;
  vint h(N);
  rep(i,N){
    cin>>h[i];
  }

  vint dp(N, LLONG_MAX);

  dp[0] = 0;

  rep(i,N-1){
    rep(j,K){
      if(i+j+1 > N-1) break;
      dp[i+1+j] = min(dp[i+1+j], dp[i]+abs(h[i+1+j]-h[i]));
    }
  }


  // dp[0] = 0;
  // dp[1] = abs(h[1]-h[0]);
  //
  // repf(i,2,N){
  //   dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]));
  // }

  cout << dp[N-1] << endl;


}

















//


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    double a;
    while (cin>>n) {
        if (n==0) {
            break;
        } else {
            std::deque<double> deq;
            double sum=0;
            for (int i=0;i<n;i++) {
                cin>>a;
                deq.emplace_back(a);
                sum+=a;
            }
            double ave=sum/n;
            int count=0;
            for (int j=0;j<n;j++) {
                if (deq[j]<=ave) {
                    count++;
                }
            }
            cout<<count<<endl;
        }
    }
}



Measured memory_bytes: 3356
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&y);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */


int main() {
    ll a[3] = {};
    rep(i,3){
        scanf("%lld",&a[i]);
    }

    int max = a[0];
    int min = a[0];

    rep(i,3){
        if(max<a[i]){
            max=a[i];
        }
        if(min>a[i]){
            min=a[i];
        }
    }



    int ans = max - min;

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


Measured memory_bytes: 256
using System;

class BandC
{
	static void Main(string[] args)
	{
		int N, x;
		int[] a;

		string[] vals = Console.ReadLine().Split(' ');

		N = int.Parse(vals[0]);
		x = int.Parse(vals[1]);
		a = new int[N];
		
		vals = Console.ReadLine().Split(' ');
		for(int i=0; i<N; i++)
		{
			a[i] = int.Parse(vals[i]);
		}
		
		int sum;
		long count = 0;

		for(int i=0; i<N-1; i++)
		{
			sum = a[i] + a[i+1];
			if(sum > x)
			{
				count += sum - x;
				a[i+1] -= sum - x;
				if(a[i+1] < 0)
					a[i+1] = 0;
			}
		}

		Console.WriteLine(count);
	}
}


Measured memory_bytes: 16728
#include <cstdio>
#include <cstring>
#include <algorithm>

int n,m,k;
double all;
void dfs(int v,int val){
	if(v==n){
		all+=std::max(val-k,1);
		return;
	}
	for(int i=1;i<=m;i++){
		dfs(v+1,val+i);
	}
}

int main(void){
	while(1){
		scanf("%d %d %d",&n,&m,&k);
		if(n+m+k==0)break;
		all=0.0;
		dfs(0,0);
		for(int i=0;i<n;i++){
			all/=m;
		}
		printf("%.20f\n",all);
	}
	return 0;
}

Measured memory_bytes: 1064
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  ll n,j,s,l;
  cin>>n;
  ll ans = n-1;
  for(ll i=1;i<=sqrt(n);i++)
  {
    if(n%i==0){
      j = i;
      s = n/j;
  
   ans = min(ans,(j-1)+(s-1));
    l = 1;
  }
 } 
  if(l==1)
     cout<<ans<<endl;
     else
     cout<<n-1<<endl;
  
}

Measured memory_bytes: 3616
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<utility>
#include<string>
#include<map>
#include<unordered_map>
#include<queue>

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

using namespace std;

typedef long long ll;
typedef pair<int, int> Pi;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
int lcm(int a, int b){return a*b / gcd(a, b);}


int main(){
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;

    s = '#' + s + '#';

    auto reachable = [&](int start, int end){
        for (int i = start; i + 1 <= end; i++) {
            if (s[i] == '#' && s[i + 1] == '#') return false;
        }
        return true;
    };

    if(!reachable(a, c) || !reachable(b, d)){
        cout << "No" << endl;
        return 0;
    }

    if(c > d){
        bool snuke_over = false;
        for(int i = b; i <= d; i++){
            if(s[i-1] == '.' && s[i] == '.' && s[i+1] == '.'){
                snuke_over = true;
            }
        }
        if(!snuke_over){
            cout << "No" << endl;
            return 0;
        }
    }


    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3900
use std::io::{BufRead, Write};

fn main() {
    let stdin = std::io::stdin();
    let stdout = std::io::stdout();
    let mut reader = std::io::BufReader::new(stdin.lock());
    let mut writer = std::io::BufWriter::new(stdout.lock());

    let (x, _n): (i32, usize) = {
        let mut buf = String::new();
        reader.read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };

    let p: Vec<usize> = {
        let mut buf = String::new();
        reader.read_line(&mut buf).unwrap();
        let iter = buf.split_whitespace();
        iter.map(|x| x.parse().unwrap()).collect()
    };

    let mut check = vec![true; 102];
    for i in p {
        check[i] = false;
    }

    let mut diff = 1000;
    let mut ans = 0;
    for i in 0..102 {
        if check[i] && (x - i as i32).abs() < diff {
            diff = (x - i as i32).abs();
            ans = i;
        }
    }
    writeln!(writer, "{}", ans).unwrap();
}

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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

#define N 12
#define K (1<<N)
#define INF 123456789

int dp[K];

int main()
{
    canhazfast();

    int n, m, k, ans;

    cin >> n >> m;
    k = 1<<n;
    fill(dp+1, dp+k, INF);
    for (int i = 0; i < m; ++i) {
        int a, b, msk = 0;
        cin >> a >> b;
        for (; b; --b) {
            int c;
            cin >> c;
            msk |= 1<<(c-1);
        }
        for (int j = k-1; j >= 0; --j) dp[j|msk] = min(dp[j|msk], dp[j]+a);
    }
    ans = dp[k-1];
    if (ans >= INF) ans = -1;
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
//WA

#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
#include <limits.h>
//#include <math.h>

int main() {
  int n, c;
  scanf("%d%d", &n, &c);
  int d[c][c], g[n][n], cnt[3][c];
  for (int i=0; i<c; i++) for (int j=0; j<c; j++) scanf("%d", &(d[i][j]));
  for (int i=0; i<3; i++) for (int j=0; j<c; j++) cnt[i][j] = 0;
  for (int i=0; i<n; i++) for (int j=0; j<n; j++) {
    scanf("%d", &(g[i][j]));
    g[i][j]--;
    cnt[(i+j)%3][g[i][j]]++;
  }
  int ans = INT_MAX, sum;
  for (int i=0; i<c; i++) {
    for (int j=0; j<c; j++) {
      if (i == j) continue;
      for (int k=0; k<c; k++) {
        if (i == k || j == k) continue;
        sum = 0;
        for (int l=0; l<c; l++) sum += cnt[0][l]*d[l][i] + cnt[1][l]*d[l][j] + cnt[2][l]*d[l][k];
        ans = (ans < sum) ? ans : sum;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define fo(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define MAXN 1000002
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
void solve()
{
  int l,r,d;
  cin>>l>>r>>d;
  int cnt=0;
  for(int i=l;i<=r;i++)
  {
    if(i%d==0)
    cnt++;
  }
  cout<<cnt<<endl;
}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 3580