akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

class question {
public:
	int X;
	void ans() {
		cin >> X;
		if (X == 3 || X == 5 || X == 7) cout << "YES\n";
		else cout << "NO\n";
	}
};

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

	question q;
	q.ans();

	return 0;
}



Measured memory_bytes: 256
from collections import deque

int1 = lambda x: int(x) - 1
MOD = 10 ** 9 + 7

N, K = map(int, input().split())
T = [[] for _ in range(N)]

for i in range(N - 1):
    a, b = map(int1, input().split())
    T[a].append(b)
    T[b].append(a)

# dfs
ans = K
for i in range(len(T[0])):
    ans = (ans * (K - i - 1)) % MOD
D = deque(T[0])
visited = {0}

while D:
    v = D.pop()
    visited.add(v)
    for i in range(len(T[v]) - 1):
        ans = (ans * (K - i - 2)) % MOD
    for x in T[v]:
        if x not in visited:
            D.append(x)
print(ans)


Measured memory_bytes: 29388
while True:

    a,b = map(int,input().split())

    if a==0 and b == 0: 
        break
    for i in range(a):
        for j in range(b):
            if i == 0 or i == a -1 or j == 0 or j == b -1:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()




Measured memory_bytes: 7004
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoderSolve.Tool;

namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;

        
        
        //static char[] s;
        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();
            string A = Console.ReadLine();
            long N = A.Length;
            long ans = (N * (N - 1) / 2) + 1;
            
            for(var i = 0; i < 26; i++)
            {
                long c = A.Count(x => x == 'a' + i);
                ans -= c * (c - 1) / 2;
            }

            Console.WriteLine(ans);

            //Console.Out.Flush();
        }

        

    }

    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for(var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
    }

    struct Pair<T> : IComparable<Pair<T>> where T : IComparable<T>
    {
        public T variable;
        public int index;

        public Pair(T val, int i)
        {
            variable = val;
            index = i;
        }

        public int CompareTo(Pair<T> otherPair)
        {
            return variable.CompareTo(otherPair.variable);
        }

        public int CompareIndex(Pair<T> otherPair)
        {
            return index.CompareTo(otherPair.index);
        }
    }



}






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

int main(int argc, char *argv[])
{
	int a;
	int ans;

	cin >> a;
	ans = a*a*a + a*a + a;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3628
import sys

def divisor(num):
    cnt = 0
    for i in range(1, n+1):
        if(num % i == 0):
            cnt += 1
    return cnt


n = int(input())
ans = 1

if n <= 105:
    if n == 105:
        print(1)
    else:
        print(0)
    sys.exit()

for i in range(106, n+1):
    if (divisor(i) == 8 and i % 2 == 1):
        ans += 1
print(ans)


Measured memory_bytes: 63020
#include<bits/stdc++.h>
#pragma warning(disable:4996)
using namespace std;
using ll = long long;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int INF = 100000;
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_A&lang=jp
int main() {
	int n, m;
	cin >> n >> m;
	vector<int>cs(m);
	for (int i = 0; i < m; i++) {
		cin >> cs[i];
	}
	vector<vector<int>>dp(m + 1, vector<int>(n+1,INF));
	for (int i = 0; i <= m; i++) {
		dp[i][0] = 0;
		
	}
	for (int j = 1; j <= n; j++) {
		for (int i = 0; i < m; i++) {
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
			if (j - cs[i] >= 0) {
				dp[i + 1][j] = min({ dp[i + 1][j],dp[i + 1][j - cs[i]] + 1});
			}
		
		}
	}
	
	
	cout << dp[m][n] << endl;
}



Measured memory_bytes: 7012
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> Vint;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

struct edge{
  int to, cost;
};

vector<edge> G[20];
ll longinf = 123451234512345LL;

ll dijkstra(int v, int e, int r, int g){   //(vertex, edge, start, goal)
  ll res = 0;
  int i, j;
  ll d[v];
  rep(i, v)d[i] = longinf;
  d[r] = 0LL;
  priority_queue<ll_i, vector<ll_i>, greater<ll_i> > Q;
  Q.push(mp(0LL, r));
  for(;!Q.empty();){
    ll_i now = Q.top();
    Q.pop();
    if(d[now.Y] < now.X)continue;
    rep(i, G[now.Y].size()){
      edge tmp = G[now.Y][i];
      if(d[tmp.to] > d[now.Y] + tmp.cost){
        d[tmp.to] = d[now.Y] + tmp.cost;
        Q.push(mp(d[tmp.to], tmp.to));
      }
    }
  }
  res = d[g];
  return res;
}

signed main(void){
  int i, j, k;
  for(int testcase = 0;testcase < 1234567;testcase++){
    int2(n, m);
    int a, b, c, d;
    rep(i, m){
      scanf("%d,%d,%d,%d", &a, &b, &c, &d);
      --a; --b;
      G[a].pb((edge){b, c});
      G[b].pb((edge){a, d});
    }
    
    scanf("%d,%d,%d,%d", &a, &b, &c, &d);
    --a; --b;
    pri(c - d - dijkstra(n, m, a, b) - dijkstra(n, m, b, a));

/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
//long longをllと省略
#define ll long long
//ユークリッドの互除法
ll gcd(ll a, ll b){
  ll t = a%b;
  while(t > 0){
    a = b;
    b = t;
    t  = a%b;
  }
  return b;
}
    
int main(){
  ll A,B;
  cin >> A >>B;
  //ansは素因数分解で出た数字の数＋1
  int ans=1;
  ll N =gcd(A,B);
  //素因数分解を実施(i*iは、素因数の小さい方は√N以下であるといういう性質から)
  for(ll i = 2;i*i <= N;i++){
    if(N%i==0){
      ans++;
      while(N%i==0){
        N/=i;
      }
    }
  }
  //素因数の大きいほうが√N以上だった場合
  if(N>1)ans++;
  cout << ans << endl;
  
  
  
}

Measured memory_bytes: 256
d=int(input())
c=list(map(int,input().split()))
c_days=[0]*26
c_days_2=[0]*26
fir_ans=0
sec_ans=0
for i in range(d):
    s=list(map(int,input().split()))
    ss=sorted(s, reverse=False)
    #最大満足度を選択
    for k in range(26):
        num=ss[k]
        n=s.index(num)
        if c_days_2[n]==0:

            fir_ans+=num
            continue 
    c_days_2[n]=i+1
    if i==0:
        nn=s.index(max(s))
    else:
        #最小不満を選択
        c_low=[c_days[x]*(i+1-c[x]) for x in range(26)]
        num=min(c_low)
        nn=c_low.index(num)
        sec_ans+=s[nn]
        c_days[n]=i+1

    for l in range(26):
        los=c[l]*(i+1-c_days[l])
        sec_ans-=los

        los=c[l]*(i+1-c_days_2[l])
        fir_ans-=los
    if fir_ans>=sec_ans:
        print(n+1)
        sec_ans=fir_ans
        c_days_2=c_days
    else:
        print(nn+1)
        fir_ans=sec_ans
        c_days=c_days_2



Measured memory_bytes: 9296
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
typedef long long ll;
using namespace std;

struct Dijkstra{
  int n,i;
  vector<vector<pair<int,int> > > edge; //cost,to
  vector<int> distance;
  vector<int> prev;

  void init(int v){
    n=v;
    edge.resize(n);
    distance.resize(n);
    prev.resize(n);
  }

  void input(int from,int to,int cost){
    edge[from].push_back({cost,to});
  }

  void calc(int start){
    for(i=0;i<n;i++){
      distance[i]=1e9+7;
      prev[i]=-1;
    }
    distance[start]=0;

    priority_queue<pair<int,int> > q; //distance,n
    pair<int,int> node;
    int from,to,tmp;
    q.push({0,start});

    while(!q.empty()){
      node=q.top();
      from=node.second;
      q.pop();
      if(node.first>distance[node.second]){
        continue;
      }

      for(i=0;i<edge[from].size();i++){
        to=edge[from][i].second;
        tmp=distance[from]+edge[from][i].first;
        if(distance[to]>tmp){
          distance[to]=tmp;
          prev[to]=from;
          q.push({tmp*-1,to}); //greater
        }
      }
    }
  }
};

int main(void){
  int v,e,r,s,t,d,i,j;
  Dijkstra graph;

  cin>>v>>e>>r;
  graph.init(v);
  for(i=0;i<e;i++){
    cin>>s>>t>>d;
    graph.input(s,t,d);
  }
  graph.calc(r);

  for(i=0;i<v;i++){
    if(graph.distance[i]!=1e9+7)cout<<graph.distance[i]<<endl;
    else cout<<"INF"<<endl;
  }

  return 0;
}



Measured memory_bytes: 13392
package main

import "fmt"

func main() {
	var K int
	fmt.Scan(&K)
	var res int
	for i := 1; i <= K; i++ {
		for j := 1; j <= K; j++ {
			for k := 1; k <= K; k++ {
				res += gcd(i, gcd(j, k))
			}
		}
	}
	fmt.Println(res)
}

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


Measured memory_bytes: 1772
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const int INF = 1e9;
inline int read(){
	int X = 0,w = 0 ;
	char ch = 0;
	while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
	while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
	return w ? -X : X;
}
const long long mod=1000000007ll;
void ad(long long &a,long long b){a+=b;a%=mod;}
void mn(long long &a,long long b){a+=mod-b;a%=mod;}
void ml(long long &a,long long b){a*=b;a%=mod;}
ll P[205];
ll dp[10005][205];
int main()
{
	int n,k;
	cin>>n>>k;
	P[0]=1ll;
	for(int i=0;i<=n;i++)
	{
		P[i+1]=P[i]*(k+1)%mod;
	}
	ll ans=0ll;
	dp[0][n]=1;
	for(int i=n-1;i>=0;i--)
	{
		for(int y=0;y<=n*n;y++)
		{
			if(!dp[y][i+1])
			{
				continue;
			}
			for(int x=0;x<=k;x++)
			{
				if(x<=i+1 and i+1-x<=y)
				{
					int p=(x+y)/(i+1);
					ad(ans,P[i]*p%mod*dp[y][i+1]%mod);
					ad(dp[y+p][i],dp[y][i+1]);
				}
				else
				{
					ad(dp[y][i],dp[y][i+1]);
				}
			}
		}
	}
	cout<<(k*(k+1)/2*P[n-1]%mod*n%mod+mod-ans)%mod;
	return 0;
}
 

Measured memory_bytes: 6400
import std;
immutable int letters = 26;
immutable int mod = 10 ^^ 9 + 7;
long powMod (long a, int p) {
	long res = 1;
	for ( ; p; p >>= 1) {
		if (p & 1) {
			res = (res * 1L * a) % mod;
		}
		a = (a * 1L * a) % mod;
	}
	return res;
}
alias invMod = a => powMod (a, mod - 2);
immutable int mult = ((letters - 1L) * invMod (letters)) % mod;
void main () {
	int k;
	while (readf !(" %s") (k) > 0) {
		readln;
	 	auto s = readln.strip;
		auto n = s.length.to !(int);
		auto cur = powMod (letters, k);
		auto res = cur;
		foreach (i; 0..k) {
			cur = (cur * 1L * mult) % mod;
			cur = (cur * 1L * (n + i)) % mod;
			cur = (cur * 1L * invMod (i + 1)) % mod;
			res = (res + cur) % mod;
		}
		writeln (res);
	}
}


Measured memory_bytes: 5544
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll 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 * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}
int keta(int a) {
	return to_string(a).size();
}
signed main() {
	int n;
	cin>>n;
	string s;
	cin>>s;
	int ans=0;
	rep(i,10){
		rep(j,10){
			rep(k,10){
				bool a=false,b=false,c=false;
				rep(l,n){
					if(!a&&ctoi(s[l])==i){
						a=true;
					}
					elif(a&&!b&&ctoi(s[l])==j){
						b=true;
					}
					elif(a&&b&&!c&&ctoi(s[l])==k){
						c=true;
					}
				}
				if(a&&b&&c){
					ans++;
				}
			}
		}
	}
	cout<<ans<<endl;	
}



Measured memory_bytes: 256
S = input()

l = len(S)

ls = [0 for i in range(l)]

cnt = 0

for i in range(l - 1):
    if S[i] == "R":
        cnt += 1
    if S[i] == "R" and S[i + 1] == "L":
        if cnt % 2 == 0:
            ls[i] += cnt // 2
            ls[i + 1] += cnt // 2
        else:
            ls[i] += cnt // 2 + 1
            ls[i + 1] += cnt // 2
        cnt = 0
        
for i in range(1, l)[::-1]:
    if S[i] == "L":
        cnt += 1
    if S[i] == "L" and S[i - 1] == "R":
        if cnt % 2 == 0:
            ls[i] += cnt // 2
            ls[i - 1] += cnt // 2
        else:
            ls[i] += cnt // 2 + 1
            ls[i - 1] += cnt // 2
        cnt = 0

for i in range(len(ls)):
    print(ls[i], end = " ")

Measured memory_bytes: 52000
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
int main(){
	ll a,b; cin>>a>>b;
	if(a>b) swap(a,b);
	if((a+b)%2==1) cout<<"IMPOSSIBLE";
	else cout<<(a+b)/2;
}


Measured memory_bytes: 3632
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static int num[];
    static Lab[] colors;
    static double ans;

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        num = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            num[i] = i;
        }
        colors = new Lab[n + 1];
        for (int i = 1; i <= n; i++) {
            colors[i] = new Lab(sc.nextDouble(), sc.nextDouble(),
                    sc.nextDouble());
        }
        ans = 0;
        combination(n, m, 0);
        System.out.printf("%.6f\n", ans);
    }

    static void combination(int n, int r, int k) {
        if (k == r) {
            double sum = 0;
            for (int i = 1; i <= r; i++) {
                for (int j = i + 1; j <= r; j++) {
                    sum += (colors[num[i]].L - colors[num[j]].L)
                            * (colors[num[i]].L - colors[num[j]].L)
                            + (colors[num[i]].a - colors[num[j]].a)
                            * (colors[num[i]].a - colors[num[j]].a)
                            + (colors[num[i]].b - colors[num[j]].b)
                            * (colors[num[i]].b - colors[num[j]].b);
                }
            }
            ans = Math.max(ans, sum);
        } else {
            int t = num[k + 1];
            for (int i = k + 1; i <= n; i++) {
                num[k + 1] = num[i];
                num[i] = t;
                if (num[k] < num[k + 1]) {
                    combination(n, r, k + 1);
                }
                num[i] = num[k + 1];
            }
            num[k + 1] = t;
        }
    }
}

class Lab {
    double L;
    double a;
    double b;

    Lab(double L, double a, double b) {
        this.L = L;
        this.a = a;
        this.b = b;
    }
}

Measured memory_bytes: 12000
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)
	a := make([]int, 4)
	for i := 0; i < 4; i++ {
		n, err := strconv.Atoi(string(s[i]))
		if err != nil {
			panic(err)
		}
		a[i] = n
	}
	fmt.Println(solve(a))
}

func solve(a []int) string {
	n := 4
	for bit := 0; bit < 1<<uint(n); bit++ {
		ans := a[0]
		f := fmt.Sprintf("%d", a[0])
		for i := uint(1); i < uint(n); i++ {
			if (bit & (1 << i)) > 0 { // bitのi番目に1が立っているか？
				ans += a[i]
				f += fmt.Sprintf("+%d", a[i])
			} else {
				ans -= a[i]
				f += fmt.Sprintf("-%d", a[i])
			}
		}
		if ans == 7 {
			return fmt.Sprintf("%s=%d", f, ans)
		}
	}
	return ""
}


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

using namespace std;

int main()
{
  string result;
  cin >> result;
  
  int lose = 8;
  for(auto itr : result)
  {
    if(itr == 'x')
      --lose;
  }
  
  cout << (lose > 0 ? "YES" : "NO" ) << endl;
  
  return 0;
}

Measured memory_bytes: 256
import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.IO as T
import qualified Data.Text.Lazy.Read as T
import qualified Data.Vector.Unboxed as VU

main :: IO ()
main = do
  let
    modulus = 1000000007 :: Int
    f :: Int -> Int
    f 0 = 1
    f 1 = 0
    f s = go (s - 2) 1 0 0
    go :: Int -> Int -> Int -> Int -> Int
    go 0 _ _ c = c
    go k a b c = go (k - 1) b c ((a + c) `mod` modulus)
  s <- unsafeTextToInt <$> T.getLine :: IO Int
  print . f $ s

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
using ll = long long;
unordered_set<int>g[200002];
int n, m, a, b, step = 0, ans = 0;
bool vis[200002];
void dfs(int num)
{
	//cout << num << " ";
	vis[num] = 1;
	step++;
	for (auto it : g[num])
	{
		if (!vis[it])dfs(it);
	}
}
int main()
{
	cin >> n >> m;
	while (m--)
	{
		cin >> a >> b;
		g[a].insert(b);
		g[b].insert(a);
	}
	for (int i = 0; i < n; i++)
	{
		if (!vis[i])
		{
			step = 0;
			dfs(i);
			ans = max(step, ans);
		}
	}
	cout << ans;
}

Measured memory_bytes: 39716
#include <stdio.h>

int main()
{
  int i, j, k, n, d;
  scanf("%d %d", &n, &k);
  
  int h[n];
  int cost[n-1];
  for (i=0; i<n; i++)  scanf("%d", &h[i]);
  
  cost[n-2] = h[n-2] - h[n-1];
  if (cost[n-2] < 0)  cost[n-2] = -cost[n-2];
  for (i=n-3; i>=0; i--) {
    d = h[i]-h[i+1];
    if (d<0)  d = -d;
    cost[i] = d + cost[i+1];

    for (j=2; j<=k; j++) {
      if (i+j>=n) continue;
      d = h[i] - h[i+j];
      if (d < 0) d = -d;
      if (i+j >= n-1) {
	if (cost[i] > d)
	  cost[i] = d;
      } else {
	if (cost[i] > d + cost[i+j])
	  cost[i] = d + cost[i+j];
      }
    }
  }
  printf("%d\n", cost[0]);

  return 0;
}


Measured memory_bytes: 896
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	var ans string

	if a <= c && c <= b {
		ans = "Yes"
	} else if b <= c && c <= a {
		ans = "Yes"
	} else {
		ans = "No"
	}

	fmt.Println(ans)
}


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

int n,m,k,i,j;
bool p;

int main()
{
    p=false;
    cin>>n>>m>>k;
    for (i=0;i<=n;i++)
    for (j=0;j<=m;j++)
        if (i*m+j*n-i*j*2==k) {cout<<"Yes"<<endl;p=true;return 0;}
    if (p==false) cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
 long int A,B,K;
  scanf("%ld %ld %ld",&A,&B,&K);
  int i;
  if(A>K){printf("%ld %ld",A-K,B);
  }else if(A+B-K>=0){printf("%ld %ld",0,A+B-K);
    }else{printf("%ld %ld",0,0);
    }return 0;
  }


Measured memory_bytes: 1712
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int kai(int a) {
	int n = 0;
	while (1) {
		if (a % 2 == 0) {
			a = a / 2;
			n++;
		}
		else break;
	}
	return n;
}
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	int count = 100000;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		count = min(kai(A[i]), count);
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3596
#include"iostream"
#include<stdlib.h>
#include<stdio.h>
#include<time.h>
#include<list>
#include<map>
#include<string>
#include<algorithm> 
#include <queue> 
#include <sstream>
#include <fstream>
#include<cmath>
#define INF 1000000000
#define LL long long
using namespace std;

vector<LL> v;
vector<LL> vv;
long long N, M, ans, A[100000], AA[100000],B;
string s;



int main() {
	cin >> N >> M;
	if (M%N == 0) {
		cout << N + M<<endl;
	}
	else {
		cout << -N + M << endl;
	}
	return 0;
}

Measured memory_bytes: 256
S = input()
res = [0]*(len(S)+1)

for i in range(len(S)):
    if S[i] == '<':
        res[i+1] = res[i] + 1

for i in range(len(S)-1,-1,-1):
    if S[i] == '>':
        res[i] = max(res[i], res[i+1]+1)

print(sum(res))

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
#define PER(i,n) for(int i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



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

  string s;
  cin >> s;
  string d[4] = {"dream", "dreamer", "erase", "eraser"};
  while(sz(s) >= 5) {
    bool ok = false;
    rep(i,4) {
      if(sz(s) < sz(d[i])) continue;
      if(s.substr(sz(s)-sz(d[i]), sz(d[i])) == d[i]) {
        ok = true;
        s.erase(sz(s)-sz(d[i]));
      }
    }
    if(ok == false) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 512
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		// 出力
		System.out.println(a*b/2);
	}
}

Measured memory_bytes: 23764
def f_lcs(S, T):
    """
    文字列s, tが与えられる。sの部分列かつtの部分列であるような文字列のうち、
    最長のものを1つ求めよ。文字列xの部分列とは、xから0個以上の文字を除いたあと、
    残りの文字を元の順序で連結して得られる文字列のことである。
    """
    # 参考: https://qiita.com/drken/items/03c7db44ccd27820ea0d
    from itertools import product

    # dp[i+1][j+1]: sのi文字目までとtのj文字目まで見たときにできる
    # Longest Common Subsequence (LCS) の長さ
    dp = [[0] * (len(T) + 1) for _ in range(len(S) + 1)]
    for i, j in product(range(len(S)), range(len(T))):
        # もし s_i = t_j なら、dp[i][j] から作れるLCSに対し、 s_i(t_jも同じ) を
        # 加えることで、それまでより長いLCSを作りうる
        if S[i] == T[j]:
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1)
        # dp[i+1][j] に対して、tのj文字目を見てもLCSの長さは不変。
        # なぜなら、もし、sのi文字目とtのj-1文字目が等しいなら、それらを
        # LCSに加えてしまっているのでsのi文字目とtのj文字目とではLCSの候補にできない。
        # つまり、 dp[i+1][j+1]=dp[i+1][j] である。
        # 逆に、等しくないなら、 sのi文字目とtのj文字目から新たなLCSを作りうるが、
        # これは単に dp[i+1][j+1] の値である。結局、配列の2つの要素のうち小さくない方を選べばいい。
        # 同じく、 dp[i][j+1] に対して、sのi文字目を見てもLCSの長さは不変。
        # これらの事実を反映したのが下の式。
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j], dp[i][j + 1])

    ans = ''
    # DPテーブルから、現時点で見ているノードがどのノードから遷移してきたかを
    # 特定することでLCSの文字列を復元する
    i, j = len(S), len(T)
    while i > 0 and j > 0:
        if dp[i][j] == dp[i - 1][j]:
            i -= 1  # (i-1, j) -> (i, j) と遷移していた
        elif dp[i][j] == dp[i][j - 1]:
            j -= 1  # (i, j-1) -> (i, j) と遷移していた
        else:
            # (i-1, j-1) -> (i, j) と遷移していた
            ans += S[i - 1]  # T[j-1]でも(同じ文字なので)構わない
            i -= 1
            j -= 1
    ans = ans[::-1]  # DPテーブルの末尾から走査する都合上、解が逆さになる
    return ans

S = input()
T = input()
print(f_lcs(S, T))

Measured memory_bytes: 113244
N, M, K = gets.strip.split.map(&:to_i)
A = gets.strip.split.map(&:to_i)
B = gets.strip.split.map(&:to_i)

a, b = [0], [0]
N.times do |i|
  a << a[i] + A[i]
end
M.times do |i|
  b << b[i] + B[i]
end

ans, j = 0, M

(N+1).times do |i|
  if a[i] > K
    break
  end
  while b[j] > K - a[i]
    j -= 1
  end
  ans = [ans, i + j].max
end
puts ans

Measured memory_bytes: 49600
#include <stdio.h>

int main(){
    int d,n,i,sum=1;
    scanf("%d %d",&d,&n);
    for(i=0;i<d;i++){
        sum *= 100;
    }
    if(n==100) printf("%d\n",sum*101);
    else printf("%d\n",sum*n);
    return 0;
}

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

#define int long long
#define uint unsigned int
#define pii pair<int, int>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,n,0)
#define ALL(c) ((c).begin()), ((c).end())

#define PB(a) push_back(a)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a,b) make_pair(a,b)
#define MT(...) make_tuple(__VA_ARGS__)

#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))

#define PW(n) (1LL << (n))

using namespace std;

template <class T> inline bool CHMIN(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline void SORT(T &a) { sort(a.begin(), a.end()); }
template <class T> inline void REV(T &a) { reverse(a.begin(), a.end()); }
template <class T> inline void UNI(T &a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }

template <class S, class T> ostream& operator << (ostream& os, const pair<S, T> v) {
  os << "(" << v.first << ", " << v.second << ")"; return os;
}

const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

/* ---------------------------------------------------------------------------------------------------- */

int N;
string s;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> s;
  int a = 0, b = 0;
  REP(i, N) {
    a += s[i] == 'R';
    b += s[i] == 'B';
  }
  cout << (a > b ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,count=0;
  vector<string>S;
  string a;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>a;
    S.push_back(a);
  }
  if(N==1){
    cout<<1;
    return 0;
  }
  sort(S.begin(),S.end());
  for(int i=0;i<N;i++){
    if(S[i]==S[i+1]){

    }else{
            count++;
    }

  }
  cout<<count;
  return 0;
}

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


void sub_insertion_sort(std::vector<int>& a, long long& cut, int g){
    for (int i = g; i < a.size(); i++){
        int v = a[i];
        int j = i - g;

        while((j >= 0) && (a[j] > v)){
            a[j+g] = a[j];
            j -= g;
            cut++;
        }
        a[j+g] = v;
    }
}
void shell_sort(std::vector<int>& a, std::vector<int>& g, long long& cut){
    
    for (int h = 1;;){
        if (h > a.size()) break;
        g.push_back(h);
        h = 3*h + 1;
    }
    //for (int i = 0; i < m; i++) g[i] = m - i;
    g[0] = 1;

    for (int i = g.size()-1; i >= 0; i--){
        sub_insertion_sort(a, cut, g[i]);
    }

}

int main(){
    int N;
    std::cin >> N;
    std::vector<int> a(N);
    for (int i = 0; i < N; i++) std::cin >> a[i];

    long long cut{0};
    std::vector<int> g;
    shell_sort(a, g, cut);

    std::cout << g.size() << std::endl;
    for (int i = g.size() - 1; i >= 0; i--) {
        std::cout << g[i];
        if (i) std::cout << " ";
    }
    std::cout << std::endl << cut << std::endl;

    for (int i = 0; i < a.size(); i++){
        std::cout << a[i] << std::endl;
    }

    return 0;
}


Measured memory_bytes: 6700
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1000000000000;

typedef pair<ll,ll> P;



int main() {
    ll H, W;
    cin >> H >> W;

    ll ch, cw, dh, dw;
    cin >> ch >> cw;
    cin >> dh >> dw;
    ch--;
    cw--;
    dh--;
    dw--;

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

    vector<string>shw(H);
    for (ll i=0; i<H; i++)cin >> shw[i];

    //全探索して
    vector<vector<ll>>d(H, vector<ll>(W)); // 距離の配列
    vector<vector<bool>>checked (H, vector<bool>(W));
    vector<vector<bool>>queued(H, vector<bool>(W));
    for (ll i=0; i<H; i++){
        for (ll j=0; j<W; j++){
            d[i][j] = INF;
        }
    }
    deque<P>que;
    d[ch][cw] = 0;

    que.push_front(P(ch,cw));
    queued[ch][cw] = true;
    // O(HW*25) = O(HW)
    while (que.size()){
        P p = que.front(); que.pop_front();
        // あるいて行ける場合
        for (ll i=0; i<4; i++){
            ll ny = p.first + dy[i];
            ll nx = p.second + dx[i];

            if (0 <= ny and ny < H and 0 <= nx and nx < W and shw[ny][nx] == '.'){
                if (not queued[ny][nx]) {
                    que.push_front(P(ny,nx));
                    queued[ny][nx] = true;
                }
                d[ny][nx] = d[p.first][p.second];   
            }
        }   
        //魔法を使う場合
        for (ll i=-2; i<3; i++){
            for (ll j=-2; j<3; j++){
                ll ny = p.first + i;
                ll nx = p.second + j;
                if (i==0 and j==0)continue;

                if (0 <= nx and nx < W and 0 <= ny and ny < H and shw[ny][nx] == '.'){
                    // 現状見つかってるルートよりも，このワープのほうが効率的な場合
                    if (d[ny][nx] > d[p.first][p.second] + 1){
                        que.push_back(P(ny,nx));
                        d[ny][nx] = d[p.first][p.second]+1;
                    }
                    
                }
            }
        }
    }
    ll ans = 0;
    if (d[dh][dw] == INF)ans = -1;
    else ans = d[dh][dw];

    cout << ans << endl;

}

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

int main(){
  string S;
  cin >> S;
  int N=S.size();
  for(int i=0;i<N;i++){
    if(i%2==0){
      if(S.at(i)=='L'){
        cout << "No" << endl;
        return 0;
      }
    }else{
      if(S.at(i)=='R'){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}


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

int main() {
	int n,k;

	cin >> n >> k ;
	
	int sum = 0;
	
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		if (abs(0 - x) < abs(k - x)) {
			sum += abs(0 - x) * 2;
		}
		else
		{
			sum += abs(k - x) * 2;
		}
	}
	
	cout << sum << endl;
	
}

Measured memory_bytes: 256
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = nextInt()

    for (i in 0..25) {
        for (j in 0..14) {
            if (i * 4 + j * 7 == n) {
                println("Yes")
                return
            }
        }
    }

    println("No")
}

fun next() = readLine()!!
fun nextInt() = next().toInt()

fun println(value : Any) {
    pw.println(value)
}

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

int main()
{
    int n;
    std::set<int> a;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        int tmp;
        scanf("%d", &tmp);
        auto it = a.find(tmp);
        if (it != a.end()) a.erase(it);
        else a.insert(tmp);
    }
    printf("%d\n", a.size());

    return 0;
}

Measured memory_bytes: 4864
n,q=map(int,input().split())
s=str(input())
lr=[list(map(int, input().split())) for _ in range(q)]
l=[0]*n
count=0
for i in range(1,n):
  if s[i-1]=='A' and s[i]=='C':
    count+=1
  l[i]=count
for i in range(q):
  print(l[lr[i][1]-1]-l[lr[i][0]-1])

Measured memory_bytes: 30688
N, M = map(int, input().split())
ken = [[] for i in range(N)]
Y = []
for i in range(M):
    p, y = map(int, input().split())
    Y.append(y)
    ken[p-1].append(i)
# print(ken)
for i in range(len(ken)):
    ken[i].sort(key=lambda x: Y[x])
# print(ken)

ans = ["0"] * M
for i in range(len(ken)):  # i:ken番号
    for j in range(len(ken[i])):  # j:県の中でj番目
        ans[ken[i][j]] = str(i+1).zfill(6) + str(j+1).zfill(6)
for a in ans:
    print(a)


Measured memory_bytes: 30380
#include<iostream>
#include<utility>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<cstring>
#define nax 100001
#define INF 1e9+5
#define mod 1000000007
#define ll long long int
using namespace std;
ll n=0,k=0;
int main(){
	cin >> n >> k;
	vector <ll> v(n);
	for(int i=0;i<n;i++){
		cin >> v[i];
	}
	vector<ll> dp(k+1,0);
	dp[0]=1;
	for(int i=0;i<n;i++){
		vector<ll> fake(k+1,0);
		for(int j=k;j>=0;j--){
			int l=j+1;
			int r=j+min(v[i],k-j);
			if(l<=r){
				fake[l]=(fake[l]+dp[j])%mod;
				if(r+1<=k){
					fake[r+1]=(fake[r+1]-dp[j]+mod)%mod;
				}
			}
		}
		int pre=0;
		for(int j=0;j<k+1;j++){
			pre=(pre+fake[j])%mod;
			dp[j]=(dp[j]+pre)%mod;
//			cout << dp[j] << " " ;
		}
//		cout << "\n"; 
	}
	cout << dp[k];
	return 0;
}


Measured memory_bytes: 1792
# coding=utf-8

line = input().split(" ")
n = int(line[0])
k = int(line[1])

ret = 0
for b in range(1,n+1):
    ret += n//b*max(b-k, 0) + max(n%b-k+1, 0)
    if 0%b>=k:
        ret -= 1

print(ret)


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

int n, cur;
string s, t;
set<int> nxt[26];
ll ans = 0;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> s >> t;
    n = s.size();
    for (int i = 0; i < n; i++) {
		nxt[s[i] - 'a'].insert(i + 1);
	}
    
    for (auto& c : t) {
		int index = c - 'a';
		if (!nxt[index].size()) {
			cout << -1;
			return 0;
		} 
		
		auto it = nxt[index].upper_bound(cur);
		if (it == nxt[index].end()) {
			it = nxt[index].begin();
			ans += n - cur;
			ans += *it;
			cur = *it;
		} else {
			ans += *it - cur;
			cur = *it;
		}
	}
	
	cout << ans;
    return 0;
}


Measured memory_bytes: 5200
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

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

int pcnt(int x) {
    return __builtin_popcount(x);
}

int f(int x) {
    if (x == 0) return 0;
    return f(x%pcnt(x)) + 1;

}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> x(n);
    rep(i, n) x[i] = s[i] - '0';
    int pc = 0;
    rep(i, n) pc += x[i];
    vector<int> ans(n);
    rep(b, 2) {
        int npc = pc;
        if (b == 0) ++npc;
        else        --npc;
        if (npc <= 0) continue; 
        int r0 = 0;
        rep(i, n) {
            r0 = (r0*2)%npc;
            r0 += x[i];
        }
        int k = 1;
        for (int i = n-1; i >= 0; --i) {
            if (x[i] == b) {
                int r = r0;
                if (b == 0) r = (r+k)%npc;
                else r = (r-k+npc)%npc;
                ans[i] = f(r) + 1;
            }
            k = (k*2)%npc;
        }
    }
    rep(i, n) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 5132
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

vector<pair<int,int>> e[100000];
ll d[100000];
int k;

void dfs(int v){
    for(auto u:e[v]){
        int nt=u.first;
        int ct=u.second;
        if(nt!=k&&d[nt]==0){
            d[nt]=d[v]+ct;
            dfs(nt);
        }
    }
}

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b,c;
        cin>>a>>b>>c;
        --a,--b;
        e[a].push_back({b,c});
        e[b].push_back({a,c});
    }
    int q;
    cin>>q>>k;
    dfs(--k);
    for(int i=0;i<q;i++){
        int x,y;
        cin>>x>>y;
        --x,--y;
        cout<<d[x]+d[y]<<endl;
    }
}


Measured memory_bytes: 11136
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int a[3]; int m = 100; int M = 1;
  for(int i = 0; i < 3; i++){
    scanf("%d", &a[i]);
    if(m > a[i]) m = a[i];
    if(M < a[i]) M = a[i];
  }
  
  int ans = M - m;
  
  printf("%d\n", ans);
  
  return 0;
}

Measured memory_bytes: 128
n = int(input())
tarou = 0
hanako = 0
for i in range(n):
    a,b = input().split()
    if(a < b ):
        hanako += 3
    elif(a > b):
        tarou += 3
    elif( a == b ):
        hanako += 1
        tarou += 1
print(tarou,hanako)


Measured memory_bytes: 5600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		sc.close();

		long ans = 0L;
		for(int i=1;i<n;i++) {
			int tmp;
			if(n%i==0) {
				tmp = n/i-1;
			}else {
				tmp = n/i;
			}
			ans = ans +tmp;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 35928
#include<bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair  <int,int> ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef set   <int>     si;
typedef set   <ii>      sii;
typedef vi::iterator itt;
typedef si::iterator jtt;

#define fori(i,x) for(itt i=x.begin();i!=x.end();i++)
#define forj(j,x) for(jtt j=x.begin();j!=x.end();j++)
#define all(x)   x.begin(), x.end()
#define clr(x,v) memset(x,v,sizeof(x))

#define _ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define x first
#define y second
#define pb push_back
#define endl "\n"
#define MOD int(1e9+7)
#define N 200123
int n, v[N], val;
int main(){_
    cin >> n;
    for(int i=1;i<n;i++){
        cin >> val;
        v[val]++;
    }
    for(int i=1;i<=n;i++){
        cout << v[i] << endl;
    }
}

Measured memory_bytes: 4420
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] abcd = scanner.nextLine().split(" ", 4);
        int a = Integer.parseInt(abcd[0]);
        int b = Integer.parseInt(abcd[1]);
        int c = Integer.parseInt(abcd[2]);
        int d = Integer.parseInt(abcd[3]);

        if (b <= c || d <= a) {
            System.out.println(0);
        } else {
            System.out.println(Math.min(b, d) - Math.max(c, a));
        }
    }
}


Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <tuple>
using namespace std;

int h[101][101];
vector<tuple<int, int, int>> pyramid;
vector<tuple<int, int, int>> measure;

void init_pyramid()
{
  for (auto y = 0; y <= 100; y++) {
    for (auto x = 0; x <= 100; x++) {
      pyramid.emplace_back(make_tuple(x, y, 0));
    }
  }
}

void read_measure_data()
{
  int n;
  cin >> n;
  for (auto i = 0; i < n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    measure.emplace_back(make_tuple(a, b, c));
  }
}

void check1()
{
  for (auto&& m : measure) {
    for (auto&& p : pyramid) {
      if (get<2>(p) < 0) continue;
      if (get<2>(m) == 0) continue;
      int guess = get<2>(m) + abs(get<0>(p) - get<0>(m)) + abs(get<1>(p) - get<1>(m));
      if (get<2>(p) == 0) {
	get<2>(p) = guess;
      } else if (get<2>(p) != guess) {
	get<2>(p) = -1;
      }
    }
  }
}

void check2()
{
  for (auto&& m : measure) {
    for (auto&& p : pyramid) {
      if (get<2>(p) < 0) continue;
      if (get<2>(m) != 0) continue;
      int guess = abs(get<0>(p) - get<0>(m)) + abs(get<1>(p) - get<1>(m));
      if (guess - get<2>(p) < 0) {
	get<2>(p) = -1;
      }
    }
  }
}

void print_ans()
{
  for (auto&& p : pyramid) {
    if (get<2>(p) > 0) {
      cout << get<0>(p) << " " << get<1>(p) << " " << get<2>(p) << endl;
    }
  }
}

int main()
{
  init_pyramid();
  read_measure_data();
  check1();
  check2();
  print_ans();
}


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

using namespace std;


long long M, N; // Nが後半部 Mが前半部

std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
    if ('0' <= s[i] && s[i] <= '9')
      ret = 10 * ret + s[i] - '0';
  return ret;
}


int main(){
    string INPUT;
    cin >> INPUT;
    cin.ignore();

    const int BORDER = 9; // とりあえず9桁が最低ライン
/*    if(INPUT.length() <= BORDER){
        N = stoll (INPUT);

        // 26進数に変換
        string s;

        // 26進数
        while(N > 0){
            int tmp = N % 26;
            char c = 'a' + tmp;
            if(c == 'a') c = 'z';
            else c -= 1;
            s +=  c;
            N /= 26;
        }
        reverse(s.begin(), s.end());
        cout << s << endl;
    } else */{
        __int128 NX = parse(INPUT);

        // 26進数に変換
        string s;

        // 26進数
        while(NX > 0){
            --NX;
            int tmp = NX % 26;
            char c = 'a' + tmp;
            //if(c == 'a') c = 'z';
            //else c -= 1;
            NX /= 26;
            s +=  c;
        }
        reverse(s.begin(), s.end());
        cout << s << endl;

        
    }

    //if(N == 0){
    //    cout << 'a' << endl;
    //    return 0;
    //}

    return 0;
}

Measured memory_bytes: 3604
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

import bisect
from collections import deque

lis = deque()
for i in range(n):
    ind = bisect.bisect_left(lis,a[i])
    if ind==0:
        lis.appendleft(a[i])
    else:
        lis[ind-1] = a[i]

print(len(lis))


Measured memory_bytes: 53720
n = int(input())
a = map(int,input().split())
field = [0 for _ in range(100001)]

for i in a:
    field[i] += 1

ans = 0

for i in range(100001-3):
    ans = max(ans,field[i]+field[i+1]+field[i+2])

print(ans)

Measured memory_bytes: 10764
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    loop {
        let a:u32 = sc.read();
        let b:u32 = sc.read();
        if a!=0 || b!=0 {
            if a > b {
                println!("{} {}", b , a);
            }else {
                println!("{} {}", a , b);
            }
        }else {
            break;
        }
    }
}

use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
 
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


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

int main(){
    string S;
    bool flag = 0;
    int count = 0;


    cin >> S;

    if(S[0] == 'R'){ 
        count = 1;
        flag = 1;
    }
    if(S[1] == 'R'){
        if(flag){
            count++;
        }else{
            count = 1;
            flag = 1;
        }
    }else{
        flag =0;
    }
    if(S[2] == 'R'){
        if(flag){
            count++;
        }else{
            count = 1;
        }
    }

    cout << count << endl;


    return 0;
}

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

#define ll long long

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];

    for(int i=0; i<n; ++i)
        cin >> b[i];

    if(lexicographical_compare(a.begin(), a.end(), b.begin(), b.end())){
        int count=0;
        do{
            if(a == b){
                cout << count;
                return 0;
            }
            count++;
        }
        while(next_permutation(a.begin(), a.end()));
    }
    else{
        int count=0;
        do{
            if(a == b){
                cout << count;
                return 0;
            }
            count++;
        }
        while(prev_permutation(a.begin(), a.end()));
    }
    return 0;
}


Measured memory_bytes: 3604