akhauriyash/Code-Regression huggingface dataset:
from collections import deque, OrderedDict

class Puzzle:
    def __init__(self, field=None, path=''):
        self.f = field
        self.space = None
        for i in range(9):
            if self.f[i] == 9:
                self.space = i
        self.path = path

    def __lt__(self, pzl): # <
        for i in range(9):
            if self.f[i] == pzl.f[i]:
                continue
            return self.f[i] > pzl.f[i]
        return False

    def __gt__(self, pzl): # >
        for i in range(9):
            if self.f[i] == pzl.f[i]:
                continue
            return self.f[i] < pzl.f[i]
        return False

dx = [-1, 0, 1, 0]
dy = [0, -1, 0, 1]
dir = ['u', 'l', 'd', 'r']

def is_target(pzl):
    for i in range(9):
        if pzl.f[i] != i+1:
            return False
    return True

def bfs(pzl):
    queue = deque([])
    V = {}
    pzl.path = ''
    queue.append(pzl)
    V[str(pzl.f)] = True
    if is_target(pzl): return pzl.path

    while len(queue) != 0:
        u = queue.popleft()
        sx, sy = u.space//3, u.space%3
        for r in range(4):
            tx, ty = sx + dx[r], sy + dy[r]
            if tx < 0 or ty < 0 or tx >= 3 or ty >= 3:
                continue
            v = Puzzle(field=[u.f[i] for i in range(9)], path=u.path)
            v.f[u.space], v.f[tx*3+ty] = v.f[tx*3+ty], v.f[u.space]
            v.space = tx*3 + ty
            if str(v.f) not in V:
                V[str(v.f)] = True
                v.path += dir[r]
                if is_target(v): return v.path
                queue.append(v)
    return 'unsolvable'

field = []
for i in range(3):
    field.extend(list(map(int, input().split(' '))))

for i in range(9):
    if field[i] == 0: field[i] = 9

pzl = Puzzle(field=field)
ans= bfs(pzl)
print(len(ans))




Measured memory_bytes: 45412
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  string s[N];
  for(int i=0;i<N;i++) cin >> s[i];
  int M;
  cin >> M;
  string t[M];
  for(int i=0;i<M;i++) cin >> t[i];

  int ans = 0;
  for(int i=0;i<N;i++){
    int res = 0;
    string tes = s[i];
    for(int j=0;j<N;j++){
      if(tes == s[j]) res++;
    }
    for(int j=0;j<M;j++){
      if(tes == t[j]) res--;
    }
    ans = max(ans,res);
  }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+7;
int cnt,cnt2,cnt4;
int a[maxn];
int n;
int main()
{
   scanf("%d",&n);
   for(int i=1;i<=n;i++){
    scanf("%d",&a[i]);
    if(a[i]%4==0) cnt4++;
    else if(a[i]%2==0) cnt2++;
    else cnt++;
   }
   //cnt=n-cnt2-cnt4;
   if(cnt>cnt4+1 || (cnt2 && (cnt==cnt4+1))) puts("No");
   else puts("Yes");
   return 0;
}


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

using namespace std;

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

int main(){

    int n,h,w;

    cin >> n >> h >> w;

    int t = (n-h+1)*(n-w+1);
    cout << t << endl;

    return 0;
}

Measured memory_bytes: 256
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include <cstring>
using namespace std;
#define ll long long
int a[15][15],cost[15];
int vis[13],sum[13],x;
int check(int sum [],int n)
{
    for(int i=1;i<=n;i++)
    {
        if(sum[i]<x)
            return 0;
    }
//    cout << '\n';
    return 1;
}
int main()
{
    int n,m;
    cin >> n >> m >> x;
    for(int i=1;i<=n;i++)
    {
        cin >> cost[i];
        for(int j=1;j<=m;j++)
        {
            cin >> a[i][j];
        }
    }
    int ans = 2e9;
    for(int i=1;i<(1<<n);i++)
    {
        int x = i,k = 0;
        memset(vis,0,sizeof(vis));
        memset(sum,0,sizeof(sum));
        while(x)
        {
            ++k;
            if(x&1)
                vis[k] = 1;
            x = x >>1;
        }
        int cnt = 0;
        for(int i=1;i<=k;i++)
        {
            if(vis[i])
            {
                for(int j=1;j<=m;j++)
                {
                    sum[j]+=a[i][j];
                }
                cnt += cost[i];
            }
        }
//        for(int i=1;i<=m;i++)
//        {
//            cout << sum[i] << ' ';
//        }
//        cout << '\n';
        if(check(sum,m))
        {
//            cout << i << '\n';
            ans = min(ans,cnt);
        }
    }
    if(ans == 2e9)
        ans = -1;
    cout << ans;
    return 0;
}


Measured memory_bytes: 3632
n=int(input())
s=input()
l="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
ans=""
for i,j in enumerate(s):
  ides=l.find(j)
  if ides+n>25:
    ides-=26
  #print(i,j)
  ans+=l[ides+n]
print(ans)

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

// #define int long long
struct Fast {Fast() {cin.tie(0); ios::sync_with_stdio(false);}} fast;

signed main(void) {
  bool flag = true;
  int num; // num
  num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  // num = numeric_limits<int>::max(); // min
  int N;
  // int M;
  // array<int, 10000> A;
  string yes = "Yes";
  string no = "No";
  // string S;
  // string T;

  cin >> N;

  for (int i = 0; i <= N / 4; ++i) {
    for (int j = 0; j <= N / 7; ++j) {
      if (4 * i + 7 * j == N) {
        cout << yes << endl;
        return 0;
      }
    }
  }

  cout << no << endl;
  
  // for (auto it = A.begin(); it < A.begin() + N; ++it)
  //   cin >> *it;

  // for (auto it = A.begin(); it < A.begin() + N; ++it)
  //   if (*it % 2 == 0) ++num;

  // cout << num << end;
  
  return 0;
}


Measured memory_bytes: 256
class UnionFind:
    def __init__(self, N):
        # 親の場合は -{その集合のサイズ}
        self.parent = [-1 for _ in range(N)]

    def root(self, A):
        if self.parent[A] < 0:
            return A
        self.parent[A] = self.root(self.parent[A])
        return self.parent[A]

    def size(self, A):
        return -self.parent[self.root(A)]

    def connect(self, A, B):
        A = self.root(A)
        B = self.root(B)

        if A == B:
            return False

        if self.size(A) < self.size(B):
            A, B = B, A

        self.parent[A] += self.parent[B]
        self.parent[B] = A
        return True


N, M = map(int, input().split())

uni = UnionFind(N)

for i in range(M):
    X, Y, Z = map(int, input().split())
    uni.connect(X-1, Y-1)

dict = {}
for i in range(N):
    r = uni.root(i)
    dict[r] = 1

print(len(dict))

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll N, K;
ll T[100005];
vector<ll> d;

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

	cin >> N >> K;

	cin >> T[0];
	for (int i = 1;i < N;i++){
		cin >> T[i];
		d.push_back(T[i]-T[i-1]-1);
	}

	sort(d.begin(),d.end()); reverse(d.begin(),d.end());

	ll ans = T[N-1] - T[0] + 1;
	for (int i = 0;i < K-1;i++){
		ans -= d[i];
	}

	cout << ans << endl;

	return 0;

}



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

#define rep(i,beg,end)   for (auto i=(beg);i<(end);i++)
#define rep2(name,container) for(auto name=begin(container); name != end(container);name++)
#define all(cont)           begin(cont), end(cont)
#define rall(cont)           rbegin(cont), rend(cont)
using ll = long long;
using vi = vector<ll>;
const ll INFMAX = LLONG_MAX;
const ll INFMIN = LLONG_MIN;
const ll MOD = 1000000007;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll a, b;
	cin >> a >> b;
	cout << max(a - 2 * b, 0LL) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#define ll long long
#define maxn 100010
using namespace std;
int n,i;
ll a[maxn],b[maxn],f[maxn][3];
int read()
{
	int x=0;
	char c=getchar();
	while(!isdigit(c))c=getchar();
	while(isdigit(c))
	{
		x=x*10+c-'0';
		c=getchar();
	}
	return x;
}
char readch()
{
	char c=getchar();
	while(c!='-'&&c!='+')c=getchar();
	return c;
}
int main()
{
	n=read();
	a[1]=read();
	for(i=2;i<=n;i++)
	{
		if(readch()=='-')b[i]=-1;else b[i]=1;
		a[i]=read();
	}
	memset(f,-0x3f,sizeof(f));
	f[1][0]=a[1];
	for(i=2;i<=n;i++)
	{
		f[i][0]=max(f[i-1][0]+b[i]*a[i],f[i-1][1]-b[i]*a[i]);
		f[i][1]=max(f[i-1][1]-b[i]*a[i],f[i-1][2]+b[i]*a[i]);
		if(b[i]==-1)f[i][1]=max(f[i][1],f[i-1][0]+b[i]*a[i]);
		f[i][2]=f[i-1][2]+b[i]*a[i];
		if(b[i]==-1)f[i][2]=max(f[i][2],f[i-1][1]-b[i]*a[i]);
	}
	printf("%lld\n",f[n][0]);
}

Measured memory_bytes: 4096
using System;

namespace abc153_d
{
    class Program
    {
        static void Main(string[] args)
        {
            decimal input = decimal.Parse(Console.ReadLine());

            int index = 0;

            while (input / (decimal)Math.Pow(2, index) >= 1)
            {
                index++;
            }


            //decimal output = index - 1 + (int)Math.Pow(2, index - 1);
            decimal output = (decimal)Math.Pow(2, index) - 1;

            Console.WriteLine(output);
        }
    }
}


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

int main(){
    int N;
    cin >> N;
    map<int,int> ma1;
    map<int,int> ma2;
    int d;
    rep(i,N){
        cin >> d;
        ma1[d]++;
    }
    int M;
    int t;
    cin >> M;
    rep(i,M){
        cin >> t;
        ma2[t]++;
    }
    auto itr = ma2.begin();
    for(;itr != ma2.end();itr++){
        if(itr->second > ma1[itr->first]){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
ll a, b, c, n, m, x, y, z, w, h, ans, cnt, mx, mn;
string s, t;
vll dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
//vll dx = {-1, 0, 1, -1, 1, -1, 0, 1}, dy = {-1, -1, -1, 0, 0, 1, 1, 1};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n >> m){
        ll start = 0, last = 0;
        ans = 0;
        rep(i, n){
            cin >> a;
            ans += min(m, a - last);
            last = a;
        }
        print(ans + m);
    }
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;
using TextReader = System.IO.TextReader;
using System.Text;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var i = consoleReader.Int * 100 + consoleReader.Int * 10 + consoleReader.Int;
            return i % 4 == 0 ? "YES" : "NO";
        }

        #region いつもの
#pragma warning disable
        private ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader(Console.In)).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
    }
    static class Ext
    {
        public static Dictionary<TKey, int> GroupCount<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector) => source.GroupBy(keySelector).ToDictionary(g => g.Key, g => g.Count());
        public static Dictionary<TKey, int> GroupCount<TKey>(this IEnumerable<TKey> source) => source.GroupCount(i => i);
    }
    public class ConsoleReader { private string[] ReadLineSplit() => textReader.ReadLine().Split(Array.Empty<char>(), StringSplitOptions.RemoveEmptyEntries); private string[] line = Array.Empty<string>(); private int linePosition; private TextReader textReader; public ConsoleReader(TextReader tr) { textReader = tr; } public int Int => int.Parse(String); public long Long => long.Parse(String); public double Double => double.Parse(String); public string String { get { if (linePosition >= line.Length) { linePosition = 0; line = ReadLineSplit(); } return line[linePosition++]; } } public class SplitLine { private string[] splited; public SplitLine(ConsoleReader cr) { splited = cr.ReadLineSplit(); cr.line = Array.Empty<string>(); } public int[] Int => String.Select(x => int.Parse(x)).ToArray(); public int[] Int0 => String.Select(x => int.Parse(x) - 1).ToArray(); public long[] Long => String.Select(x => long.Parse(x)).ToArray(); public double[] Double => String.Select(x => double.Parse(x)).ToArray(); public string[] String => splited; } public SplitLine Split => new SplitLine(this); public class RepeatReader : IEnumerable<ConsoleReader> { ConsoleReader cr; int count; public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; } public IEnumerator<ConsoleReader> GetEnumerator() => Enumerable.Repeat(cr, count).GetEnumerator(); System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); public IEnumerable<string> String => this.Select(cr => cr.String); public IEnumerable<int> Int => this.Select(cr => cr.Int); public IEnumerable<int> Int0 => this.Select(cr => cr.Int - 1); public IEnumerable<long> Long => this.Select(cr => cr.Long); public IEnumerable<double> Double => this.Select(cr => cr.Double); } public RepeatReader Repeat(int count) => new RepeatReader(this, count); }
    #endregion
}


Measured memory_bytes: 13140
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

//My friends are small
public class Main{

	int n, W, MOD = 1000000007;
	int[] w;
	Map<Integer, Integer>[][] mem;
	
	int get(int k, int rest, int min){
		if(rest<0)return 0;
		if(k<0)return rest<min?1:0;
		if(mem[k][rest].containsKey(min))return mem[k][rest].get(min);
		int res = (get(k-1, rest, w[k])+get(k-1, rest-w[k], min))%MOD;
		mem[k][rest].put(min, res);
		return res;
	}
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt(); W = sc.nextInt();
		w = new int[n];
		for(int i=0;i<n;i++)w[i]=sc.nextInt();
		Arrays.sort(w);
		mem = new Map[n][W+1];
		for(int i=0;i<n;i++)for(int j=0;j<=W;j++)mem[i][j]=new HashMap<Integer, Integer>();
		System.out.println(get(n-1, W, 1<<29));
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

vector <int> mp[maxn];
int a[maxn],n,ans[maxn],dp[maxn],len;

inline void dfs(int u,int fa)
{
	int tmp=0,pos=0;
	if(a[u]>dp[len]) dp[++len]=a[u],ans[u]=len,pos=len;
	else
	{
		pos=lower_bound(dp+1,dp+len+1,a[u])-dp;
		tmp=dp[pos]; dp[pos]=a[u]; ans[u]=max(ans[fa],pos);
	}
	for(int i=0;i<mp[u].size();i++)
	{
		int v=mp[u][i]; if(v==fa) continue;
		dfs(v,u);
	}
	dp[pos]=tmp; if(tmp==0) len--;
}

int main()
{
	n=read(); rep(i,1,n) a[i]=read();
	rep(i,1,(n-1)){int u=read(),v=read(); mp[u].pb(v); mp[v].pb(u);}
	dfs(1,0); rep(i,1,n) printf("%d\n",ans[i]);
	return 0;
}

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

int main(){
	int a[10];
	string input, k;
	while (cin >> input){
		int ans = 0;
		for(int i = 0; i<10;i++){
			k = input[i];
			a[i] = stoi(k);
		}
		ans = a[0] + a[9] + (a[1] + a[8]) * 9 + (a[2] + a[7]) * 36 + (a[3] + a[6]) * 84 + (a[4] + a[5]) * 126;
		ans %= 10;
		cout << ans << endl;
	}
	return 0;
}

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

typedef long long ll;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int l, r, d;
    cin >> l >> r >> d;
    int count=0;
    for(int i=l; i<=r; i++){
        if(i%d==0) count++;
    }        
    cout<<count<<'\n';
    return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>

int main(){

  int n,i;
  int a;
  int max=0;
  int min=1000000000;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    if(max<a)max=a;
    if(min>a)min=a;
  }
  
  printf("%d\n",max-min);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    long long s;
    cin >> s;
    if(s == 1e18){
        long long a = 1e9;
        printf("0 0 %lld 1 0 %lld\n", a, a);
        return 0;
    }
    long long x0 = 0, y0 = 0, x1, y1 = 0, x2 = 0, y2;
    x1 = 1e9;
    y1 = 1;
    x2 = 1e9 - (s % (long long)1e9);
    y2 = (s+x2) / 1e9;

    cout << x0 << " " << y0 << " " << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main ()
{
	int a,b;
	cin>>a>>b;
	if(b==1)
	b=14;
	if(a==1)
	a=14;
	if(a>b)
	cout<<"Alice";
	else if(a==b)
	cout<<"Draw";
	else
	cout<<"Bob";
	return 0;
} 

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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		long l = stdIn.nextLong();
		/*
		BigDecimal a = BigDecimal.valueOf(l/3);
		
		System.out.println(a.multiply(a).multiply(a));*/
		
		
		System.out.println(l*l*l/27.0);

	}

}


Measured memory_bytes: 21844
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#l = list(map(int, input().split()))

n = int(input())
a = list(map(int, input().split()))

ans = "APPROVED"
for i in range(n):
    if (a[i] % 2 == 0):
        if (a[i] % 3 == 0 or a[i] % 5 == 0):
            pass
        else:
            ans = "DENIED"
            break
print(ans)


Measured memory_bytes: 9136
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{
    class Program
    {

        static void Main(string[] args)
        {
            String S = Console.ReadLine();
            char C = S[0];

            C = (char)(C + 1);

            Console.WriteLine(C);
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    long long x, k, d;
    cin >> x >> k >> d;

    if (abs(x) / d > k) {
        if (x > 0)x -= d * k;
        else x += d * k;
        cout << abs(x) << endl;
    } else {
        k -= abs(x) / d, x %= d;
        if (k % 2 == 0)cout << abs(x) << endl;
        else {
            if (x > 0)cout << abs(x - d) << endl;
            else cout << abs(x + d) << endl;
        }
    }
    return 0;
}

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

using namespace std;


int main() {
    string s;
    cin >> s;
    int i;
    if (s.size() > 2) {
        for (i = 0; i < s.size(); i++) {
            if (s[i] == s[i + 1] || s[i] == s[i + 2]) {
                cout << i + 1 << " " << i + 3 << endl;
                break;
            }
        }
        if (i == s.size()) cout << -1 << " " << -1 << endl;
    }
    else {
        if(s[0] == s[1]) cout << "1 2" << endl;
        else cout << -1 << " " << -1 << endl;
    }
    return 0;
}

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

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

  int N, K;
  cin >> N >> K;
  if(K == 1) cout << 0 << endl;
  else cout << (N-K) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<bitset>
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+8
#define EPS 1e-8
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = (j); i < (k); i++)

class edge{
    public:
    int to, c;
    edge(int to,int c):to(to),c(c){}
    edge(){}
    bool operator<(const edge &a)const{
    if(c!=a.c)return c>a.c;
    return to<a.to;
    }
};

int d[111000];

void Dijkstra(int a,vector < edge > G[111000]){
    priority_queue<edge> PQ;
    PQ.push(edge(a,0));
    while(!PQ.empty()){
        edge e=PQ.top();PQ.pop();
        if(d[e.to]!=INF)continue;
        d[e.to]=e.c;
        for(int i=0;i<G[e.to].size();i++){
            PQ.push(edge(G[e.to][i].to,G[e.to][i].c+e.c));
        }
    }
}

int main(){
	int n,m;
	while(scanf("%d%d",&n,&m),n){
		vector<edge> G[111000];
		for(int i = 0; i < m; i++){
			int f;
			scanf("%d",&f);
			if(f == 0){
				int a,b;
				scanf("%d%d",&a,&b);
				fill(d,d+n+1,INF);
				Dijkstra(a,G);
				printf("%d\n",d[b]==INF ? -1 : d[b]);
			}
			else{
				int c,d,e;
				scanf("%d%d%d",&c,&d,&e);
				G[c].push_back(edge(d,e));
				G[d].push_back(edge(c,e));
			}
		}
	}
    return 0;
}

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

int main(){
	int n,m;
	cin>>n>>m;
	vector<int>x(n),a(n);
	for(int i=0;i<n;i++){
		cin>>x[i];
	}
	for(int j=0;j<n;j++){
		a[j]=abs(x[j]-m);
	}
	int ans=a[0];
	for(int j=1;j<n;j++){
		ans=__gcd(ans,a[j]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int data[400][400], n, m, a, b, c;
	cin >> n >> m;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j) data[i][j] = -10000000;
	for (int i = 0; i < m; ++i) {
		cin >> a >> b >> c;
		data[a][b] = c;
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			for (int k = 0; k < n; ++k) {
				data[j][k] = max(data[j][k], data[j][i] + data[i][k]);
			}
		}
	}
	cout << data[0][n - 1] << endl;
	return 0;
}


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

void solve(int N,std::vector<int> p){
    std::vector<int> b=p;
    std::sort(p.begin(),p.end());
    int ct=0;
    for(int i=0;i<N;i++){
        if(b[i]!=p[i])ct++;
        if(ct==3){printf("NO");exit(0);}
    }
    printf("YES");
}

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int N=0;
    std::vector<int> p;
    std::cin>>N;
    for(int i=0,b=0;i<N;i++){
        std::cin>>b;
        p.push_back(b);
    }
    solve(N,p);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int w,a,b;
    scanf("%d%d%d",&w,&a,&b);
     if(a<b&&a+w<b)printf("%d\n",b-a-w);
    else if(b<a&&b+w<a)printf("%d\n",a-b-w);
    else printf("0\n");
    return 0;
}


Measured memory_bytes: 1652
import sys
A,B,C,D = map(int,input().split())

if not ( 1 <= A <= 100 and 1 <= B <= 100 and 1 <= C <= 100 and 1 <= D <= 100 ): sys.exit()

while A >= 1 and C >= 1:
    C -= B
    if C <= 0: print('Yes'); break
    A -= D
    if A <= 0: print('No'); break

Measured memory_bytes: 9196
N = int(input())
H = list(map(int, input().split()))
for n in range(N - 1, 0, -1):
    if H[n - 1] - H[n] > 1:
        print("No")
        exit()
    if H[n - 1] - H[n] == 1:
        H[n - 1] -= 1
print("Yes")


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

int main(){
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> A(Q);
  for(int i=0; i<Q; i++) cin >> A[i];
  
  vector<int> Point(N, K-Q);
  for(int i=0; i<Q; i++){
    Point[A[i]-1]++;
  }
  for(int i=0; i<N; i++){
    if(Point[i]>0) cout << "Yes"<<endl;
    else cout << "No"<<endl;
  }
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag,
		tree_order_statistics_node_update> ordered_set;

long long mem[3005][3005];
bool vis[3005][3005];
int n;
long long arr[3005];
long long sol(int left , int right , bool st){
	if(left>right)
		return 0;
	if(vis[left][right])
		return mem[left][right];
	vis[left][right] = true;
	long long ret = 0;
	if(!st){
		ret = max(sol(left + 1 , right , st^1) + arr[left] , sol(left , right - 1 ,st^1) + arr[right]);
	}else{
		ret = min(sol(left + 1 , right , st^1) - arr[left] , sol(left , right - 1 ,st^1) - arr[right]);
	}
	return mem[left][right] = ret;
}
int main(){
	cin>>n;
	for(int i= 0;i < n; i++)
		cin>>arr[i];
	cout<<sol(0,n-1,0);
	return 0;
}


Measured memory_bytes: 78464
/** ２たてH cm よこ W cm の長方形を描くプログラムを作成して下さい。
*1 cm × 1cm の長方形を '#'で表します。
*/

/*sucannerクラス使うためにインポート*/
import java.util.Scanner;

class Main {
	// プログラムのエントリポイント
	public static void main(String[] args) {
		// 入力ストリームの生成
		Scanner sc = new Scanner(System.in);
		//処理を繰り返す
		while (true){
			//２つの数字を受け取る
			 int intH = sc.nextInt();
			 int intW = sc.nextInt();
			 //受け取った数字が二つとも０の場合処理を終了する
			if(intH == 0 && intW == 0){
				break;
			}

			//受け取った縦の数字の回数改行する
			for (int i = 0; i < intH ; i++){
				//受けとった横の数字の個数分＃を表示する
				for ( int j = 0; j < intW ; j++){
					System.out.print("#");
				}
				System.out.println("");
			}
			//表示完了後改行する。
			System.out.println("");
		}
	}
}

Measured memory_bytes: 25756
a, b, c, d = map(int, input().split())

cnt = 0

while a > 0 and c > 0:
    # 後手の攻撃
    if cnt & 1:
        a -= d
        cnt += 1
    else:
        c -= b
        cnt += 1

print("Yes" if cnt & 1 else "No")


Measured memory_bytes: 9108
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;


//?????§??¬?´???°
int gcd(int x, int y) {
    int r;
    if(x < y) swap(x, y);

    while(y > 0){
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main(){
    int p, q;
    cin >> p >> q;

    q/= gcd(p, q);

    int ans = 1;
    for(int i = 2; q >= i * i; i++){
        if(q % i == 0){
            ans*=i;
            while(q % i == 0){
                q/=i;
            }
        }
    }
    cout << ans * q << endl;
}

Measured memory_bytes: 3060
int main(void)
{
    int cards[4][13];
    int n;
    char mark;
    int num;
     
    int i,j;
     
    for(i = 0;i < 13;i++){
        cards[0][i] = i + 1;
        cards[1][i] = i + 1;
        cards[2][i] = i + 1;
        cards[3][i] = i + 1;
    }
     
    scanf("%d\n",&n);
     
    for(i = 0;i < n;i++){
        if(i != n-1)scanf("%c %d\n",&mark,&num);
        else scanf("%c %d",&mark,&num);
        switch(mark){
            case 'S':
                cards[0][num-1] = 0;
                break;
            case 'H':
                cards[1][num-1] = 0;
                break;
            case 'C':
                cards[2][num-1] = 0;
                break;
            case 'D':
                cards[3][num-1] = 0;
                break;
        }
    }
     
    for(i = 0;i < 4;i++){
        for(j = 0;j < 13;j++){
            if(cards[i][j] != 0){
                switch(i){
                    case 0:
                        printf("S %d\n",cards[i][j]);
                        break;
                    case 1:
                        printf("H %d\n",cards[i][j]);
                        break;
                    case 2:
                        printf("C %d\n",cards[i][j]);                   
                        break;
                    case 3:
                        printf("D %d\n",cards[i][j]);
                        break;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2036
#include <iostream>
#include <string>
#include <algorithm>
#define N_MAX 100
#define H_MAX 1000
int map[N_MAX+1][H_MAX+1] = {};
using namespace std;

int main(void)
{
  int n,m,a;
  int h,p,q;
  while(cin>>n>>m>>a,n)
  {
    for(int i = 0;i <= N_MAX;i++)
      for(int j = 0;j <= H_MAX;j++)
        map[i][j] = 0;
    for(int i = 0;i < m;i++){
      cin>>h>>p>>q;
      map[p][h] = q;
      map[q][h] = p;
    }
    int nh = H_MAX;
    while(nh >= 0)
    {
      if(map[a][nh])
        a = map[a][nh];
      nh--;
    }
    cout<<a<<endl;
  }
  return 0;
}

Measured memory_bytes: 1556
<?php
 
	fscanf(STDIN, "%d", $N);

	$count = 0;
	for ($i = 1; $i <= $N; $i++) {
      fscanf(STDIN, "%d %d", $d1, $d2);
      if ($d1 === $d2) {
        $count++;
      } else {
        $count = 0;
      }
      if ($count === 3) {
        echo ("Yes");
        return ;
      }
    }
	echo ("No");

?>

Measured memory_bytes: 16064
use std::io;
use std::io::Read;

fn main() {
    loop {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();

        let H: i32 = iter.next().unwrap().parse().unwrap();
        let W: i32 = iter.next().unwrap().parse().unwrap();

        if H == 0 && W == 0 {
            break;
        }

        for _ in 0..H {
            for _ in 0..W {
                print!("#");
            }
            println!("");
        }
        println!("");
    }
}


Measured memory_bytes: 5028
#include <cstdlib>
#include <iostream>
#include <typeinfo>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

unsigned long f(unsigned long n, unsigned long x)
{
  if (n == -1)
  {
    return 0;
  }
  else
  {
    return n / x + 1;
  }
}

int main()
{
  unsigned long a, b, x;
  cin >> a >> b >> x;
  unsigned long ans;
  ans = f(b, x) - f(a - 1, x);
  cout << ans << endl;
  return 0;
}

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

int main(){
    
    int N,l,r;
    
    cin >> N;
    
    int sum = 0;
    
    for(int i = 0; i < N; i++){
        
        cin >> l >> r;
        
        sum += r - l + 1;
        
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int ans=0;
  for(int i=1;i<=n;i++){
    int u;
    cin>>u;
    if(i%2==1&&u%2==1)
      ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3568
/******************************************************************************

            EYENINE,THE ELDER_WAND!!!
            THE ROOT OVER MINUS EIGHTY ONE!!

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

#include<bits/stdc++.h>
#define ALL_UP_WITH return 0
#define vi vector<int>
using namespace std;
int count1=0;
string s[100];
int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,l;
    cin>>n>>l;
    for(int i=0;i<n;i++)
        cin>>s[i];
        sort(s,s+n);

    for(int i=0;i<n;i++)
        cout<<s[i];

    cout<<endl;



    ALL_UP_WITH;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int A;
    int B;
    int rest;

    scanf("%d %d",&A,&B);
    if(2*B<=A){
        rest = A - 2*B;
        printf("%d",rest);
    }else if(2*B>A){
        printf("0");
    }

    return 0;
}


Measured memory_bytes: 128
// In the name of Allah
// #Isart

#include<bits/stdc++.h>

#define pii pair<int, int>
#define pb push_back
#define F first
#define S second
#define ll long long
#define ld long double
#define int long long 

using namespace std;

const int MAXN = 1e5 + 10;

int32_t main(){
	ios::sync_with_stdio(false); cin.tie(0);
	ll tmp = 1, id = 10;
	for(int i = 0; i < 10; i ++){
		cout << "? " << tmp << endl;
		char in; cin >> in;
		if(in == 'N'){
			id = i;
			break;
		}
		tmp *= 10;
	}	
	if(id == 10){
		ll ans = 1; tmp = 9;
		for(int i = 0; i < 10 ; i ++){
			cout << "? " << tmp << endl;
			char in; cin >> in;
			if(in == 'Y'){
				cout << "! " << ans << endl;
				return 0;
			}
			ans *= 10;
			tmp = tmp * 10 + 9;
		}
	}
	string now;
	for(int i = 0; i < id - 1; i ++){
		int l = 0, r = 10;
		if(i == 0) l = 1;
		while(r - l > 1){
			int mid = (l + r) / 2;
			char test = '0' + mid;
			string out = now ; out += test;
			cout << "? " <<  out << endl;
			char in; cin >> in;
			if(in == 'Y') l = mid;
			else r = mid;
		}
		char test = '0' + l;
		now = now + test;
	}
	for(int i = 0; i < 10; i ++){
		if(id == 1 and i == 0) continue; 
		char test = '0' + i;
		string out = now; out += test; out += '9';
		cout << "? " << out << endl;
		char in; cin >> in;
		if(in == 'Y'){
			now += test;
			break;
		}
	}
	cout << "! " << now << endl;
	return 0;	
}

Measured memory_bytes: 624
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define ll long long
#define PB push_back
const int inf = 1000 * 1000 * 1000;
const ll INF = 1e17;

const int N = 16;
int a[N], n, k, ans = INF;
bool mark[N];

void gen(int id = 0, int t = k){
	if(t == 0){
		int last = 0, Ans = 0;
		for(int i = 0; i < n; i++){
			int o = 0;
			if(mark[i] == true){
				if(last >= a[i]){
					Ans += last + 1 - a[i];
					o += last + 1 - a[i];
				}
			}
			last = max(last, a[i] + o);
		}

		ans = min(ans, Ans);
		return;
	}
	if(id == n)
		return;
	gen(id + 1, t);
	mark[id] = true;
	gen(id + 1, t - 1);
	mark[id] = false;
}


int32_t main(){
	ios::sync_with_stdio(false);cin.tie(0);
	
	cin >> n >> k;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	gen();
	
	cout << ans << '\n';
}

// Tu te faufiles
// entre mes lignes
// Tu te faufiles
// entre mes lignes
// Charlotte Cardin - Faufile

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

int main() {
    int n; cin >> n;
    vector<int> a(n); for (auto i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());

    int64_t ans = a.size(), sum = a[0], cnt = 1;
    for (auto i = 0; i < n - 1; i++) {
        if(sum * 2 < a[i + 1]) ans = a.size() - cnt;
        sum += a[i + 1]; cnt++;
//        cout << i << " " << sum << " " << cnt << endl;
    }

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

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int k;
    cin >> k;
    string s = "ACL";
    string ans = "";
    rep(i,k) ans += s;
    cout << ans << endl;
    return 0;
}

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

int main(){
	rep(i, 5){
		int a;
		cin >> a;
		if(a == 0){
			cout << i+1 << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3448
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main()
{
  int i, j, n, k, *array, count=0;

  scanf("%d", &n);

  array = (int *)malloc(n * sizeof(int));
  
  for( i=0; i<n; i++ )
    {
      scanf("%d", &array[i]);

      k = sqrt( array[i] );

      if( array[i] != 1 ) count++;
      
      for( j=2; j<=k; j++ )
	{ 
	  if( array[i] % j == 0 )
	    {
	      count--;
	      break;
	    }
	}
    }
  
  printf("%d\n", count);
  
  return 0;
}
  



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

typedef long long lint;
typedef long double ldouble;
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = 1e18;
const lint MOD = 1e9 + 7;
const lint inv = MOD - 2;

struct unionFind{

    vector<int> par, rank;

    void init(int n){
        par.resize(n);
        rank.resize(n, 0);
        rep(i, n){
            par[i] = i;
        }
        return;
    }

    int root(int x){
        if(par[x] == x){
            return x;
        }else{
            par[x] = root(par[x]);
            return par[x];
        }
    }

    bool unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry){
            return false;
        }
        if(rank[rx] < rank[ry]){
            par[rx] = ry;
        }else if(rank[rx] == rank[ry]){
            par[rx] = ry;
            rank[ry]++;
        }else{
            par[ry] = rx;
        }
        return true;
    }

    bool same(int x, int y){
        return root(x) == root(y);
    }

};

struct edge{
    int from, to;
    lint cost;
    int id;

    bool operator<(const edge & right) const {
        return cost < right.cost;
    }
};

int main(){
    int n, m;
    cin >> n >> m;
    vector<edge> edges;
    rep(i, m){
        edge e;
        cin >> e.from >> e.to >> e.cost;
        e.from--;
        e.to--;
        e.id = i;
        edges.push_back(e);
    }
    sort(edges.begin(), edges.end());
    vector<edge> MST;
    lint sum = 0;
    unionFind uf;
    uf.init(n);
    rep(i, m){
        edge e = edges[i];
        if(uf.unite(e.from, e.to)){
            MST.push_back(e);
            sum += e.cost;
        }
    }
    pair<int, lint> ans;
    ans.first = 0;
    ans.second = 0;
    rep(i, MST.size()){
        lint tmp = 0;
        uf.init(n);
        rep(j, m){
            edge e = edges[j];
            if(!uf.same(e.from, e.to) && e.id != MST[i].id){
                uf.unite(e.from, e.to);
                tmp += e.cost;
            }
        }
        if(sum != tmp){
            ans.first++;
            ans.second += MST[i].cost;
        }
    }
    cout << ans.first << " " << ans.second << endl;
    return 0;
}


Measured memory_bytes: 4596
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

nA = nC = 0
ans = 0
for i, b in enumerate(B):
    while nA<N and A[nA]< b: nA += 1
    while nC<N and C[nC]<=b: nC += 1
    ans += nA*(N-nC)

print(ans)

Measured memory_bytes: 24096
n, k, q = map(int, input().split())
point = [k] * n
for i in range(q):
  correct_person = int(input())
  point[correct_person - 1] += 1
for i in range(n):
  if point[i] - q <= 0:
    print("No")
  else:
    print("Yes")

Measured memory_bytes: 6596
#include<bits/stdc++.h>
using namespace std ;
#define x first
#define y second 
#define ll long long 
#define _for(i,j,k) for(int i=j;i<k;i++)
#define endl  '\n'
#define inf 1<<29-1 
#define ll long long
#define db double
#define ld long double
#pragma GCC optimize(2)
#define ull unsigned long long
#define maxn 110
int dp[maxn][maxn];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num;
    cin>>num;
    memset(dp,0, sizeof(dp));
    for (int k = 0; k <=9 ; ++k) {
        dp[1][k]=1;
    }
    for (int i = 2; i <=10 ; ++i) {
        for (int j = 0; j <=9 ; ++j) {
            dp[i][j]=dp[i-1][j]+dp[i-1][j-1]+dp[i-1][j+1];
        }
    }
    queue<int> ans;
    int l=0, r = 0,fl=0;
    for (int j = 1; j <=10 ; ++j) {
        for (int i = 1; i <=9 ; ++i) {
            if(num<=dp[j][i]){
                l=j;
                r=i;
                fl=1;
                break;
            }
            num-=dp[j][i];
        }
        if(fl==1)break;
    }
    l--;
    ans.push(r);
    while(l!=0){
        if(num<=dp[l][r-1]){
            r--;
            ans.push(r);
        }else{
            num-=dp[l][r-1];
            if(num<=dp[l][r]){
                ans.push(r);
            }else{
                num-=dp[l][r];
                r++;
                ans.push(r);
            }
        }
        l--;
    }
    while(!ans.empty()){
        int now=ans.front();
        cout<<now;
        ans.pop();
	}
}

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

public class Main {
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		int m = scanner.nextInt();
		int n = scanner.nextInt();
		
		long sum=0;
		
		long[] p = new long[m];
		long[] q = new long[n];
		for (int i=0;i<m;i++)
		{
			p[i] = scanner.nextInt();
			sum += p[i] * (n+1);
		}
		for (int i=0;i<n;i++)
		{
			q[i] = scanner.nextInt();
			sum += q[i] * (m+1);
		}
		
		//System.out.println(sum);
		
		Arrays.sort(p);
		Arrays.sort(q);
		int x=m-1, y=n-1;
		while (x!=-1 && y!=-1)
		{
			if (y==-1 || (x>=0 && p[x] >= q[y]))
			{
				sum -= p[x] * (y+1);
				x--;
			}
			else
			{
				sum -= q[y] * (x+1);
				y--;
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 67316
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>

int main() {
	int n;
	std::cin >> n;
	long long int ans = 1, b = 1000000007, d[1010] = {};
	for (int i = 2;i <= n;i++) {
		int nSum = 0, c = i;
		for (int j = 2;j <= i;j++) {
			while (true) {
				if (c%j != 0) {
					break;
				}
				c /= j;
				d[j] += 1;
			}
			if (c == 1) {
				break;
			}
		}
	}
	for (int i = 2;i <= n;i++) {
		if (d[i] != 0) {
			ans *= (d[i] + 1);
			ans %= b;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_s(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

#define MOD 1000000007

void my_search(int pos, vector<vector<int>> &tree, vi &ans)
{
  vi news;
  rep(i, tree[pos].size())
  {
    if (ans[tree[pos][i]] == -1)
    {
      ans[tree[pos][i]] = pos;
      news.push_back(tree[pos][i]);
    }
  }
  rep(i, news.size())
  {
    my_search(news[i], tree, ans);
  }
}

int main()
{
  int n, m;
  cin >> n >> m;

  vector<vector<int>> tree(n);

  rep(i, m)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }

  queue<int> now;
  vi ans(n, -1);
  ans[0] = 0;
  now.push(0);
  while (!now.empty())
  {
    int _now = now.front();
    now.pop();
    rep(i, tree[_now].size())
    {
      if (ans[tree[_now][i]] == -1)
      {
        ans[tree[_now][i]] = _now;
        now.push(tree[_now][i]);
      }
    }
  }

  cout << "Yes" << endl;
  rep_s(i, 1, n)
  {
    cout << (ans[i] + 1) << endl;
  }
}


Measured memory_bytes: 10196
#include <iostream>
#include <algorithm>
 
using namespace std;
 
#define RMAX 50*49/2 + 1
 
int main(void) {
  int N, K, R, boat[51][51], bnynum[51], pq[RMAX][2], pqF, usa[51] = {0}, temp;
 
  cin >> N >> K;
 
  for(int j = 1; j <= K; j++) {
    cin >> bnynum[j];
 
    for(int i = 1; i <= bnynum[j]; i++) {
      cin >> boat[j][i];
    }
    sort(boat[j]+1, boat[j]+1 + bnynum[j]);
  }
   
  cin >> R;
 
  for(int i = 0; i < R; i++) {
    cin >> pq[i][0] >> pq[i][1];
  }
 
  for(int j = 1; j <= K; j++) {
    for(int r = 0; r < R; r++){
      pqF = 0;
      for(int i = 1; i <= bnynum[j]; i++) {
     
    if(boat[j][i] == pq[r][pqF]) {
      if(pqF == 0) {
        pqF = 1; temp = boat[j][i];
      } else {
        usa[temp] = 1; usa[boat[j][i]] = 1;
        break;
      }
    }
 
      }
    }
  }
 
  int res = 0;
  for(int i = 1; i <= 50; i++) {
    res += usa[i];
  }
 
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  Int a,b,c;
  cin>>a>>b>>c;

  Int odd=0,even=0;
  if(a&1) odd++;else even++;
  if(b&1) odd++;else even++;
  if(c&1) odd++;else even++;

  if(even==3) drop("Tem");
  if(even==2) drop("Tem");
  if(even==1) drop("Hom");
  if(even==0) drop("Hom");

  assert(0);
  return 0;
}



Measured memory_bytes: 3136
fn read<T: std::str::FromStr>() -> T {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().parse().ok().unwrap()
}

fn main() {
  let s: String = read();
  let cs: Vec<char> = s.chars().collect();
  
  let ans = if cs[0] == cs[1] || cs[1] == cs[2] || cs[2] == cs[3] { "Bad" } else { "Good" };

  println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <cassert>
using namespace std;

typedef unsigned int ui;

#define forn(i,n) for (int i = 0; i < int(n); i++)
#define pb push_back
#define si(c) ((int)(c).size())
typedef vector<ui> vi;

const int MAXN = 700;

int m,n,d;
vector<ui> row[MAXN*MAXN];

int id(int i, int j) { return i*m + j; }

void mark(int i, int j) {
	row[i][j>>5] |= ui(1)<<(j&31);
}

bool check(int i, int j) { return row[i][j>>5] & (1<<(j&31)); }

void operator^=(vi &a, const vi &b) {
        int n =si(a);
        assert(n = si(b));
        forn(i,n) a[i] ^= b[i];
}

void init(int N) {
	int sz = N/32 + 1;
	forn(i,N) row[i].clear(), row[i].resize(sz,0);
}

int main(int argc, char *argv[])
{
    ios_base::sync_with_stdio(false);
	while (cin >> m >> n >> d && n) {
		int target = m*n;
		init(target);
		forn(i,n) forn(j,m) {
			vi cols;
			int x; cin >> x;
			if (x) cols.pb(target);
            cols.pb(id(i,j));
			for (int ii = max(0,i-d); ii <= min(n-1,i+d); ii++) {
				int di = abs(i-ii), dj = d - di;
				int jj = j - dj;
				if (jj >= 0) cols.pb(id(ii,jj));

				if (dj == 0) continue;
				jj = j + dj;
				if (jj < m) cols.pb(id(ii,jj));
			}
			int ID = id(i,j);
			for (int c : cols) mark(ID,c);
		}

        vector<bool> vis(target,false);
        forn(j,target) {
                forn(i,target) if (!vis[i] && check(i,j)) {
                        vis[i] = true;
                        forn(i2,target) if (!vis[i2] && check(i2,j)) row[i2] ^= row[i];
                        break;
                }
        }
        vi bad(si(row[0]),0);
        bad[target>>5] |= 1<<(target&31);
        
        bool res = true;
        forn(i,target) if (row[i] == bad) { res = false; break; }

        cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 12804
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
#include <random>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <complex>
#include <functional>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < int(b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> int(a);)
#define all(v) v.begin(),v.end()
#define trav(x, v) for(auto &x : v)
#define sz(v) int((v).size())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long double ld;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n, x;
	cin >> n >> x;
	if(x == 1 || x==2*n-1){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	if(n==2){
		cout << 1 << endl << 2 << endl << 3 << endl;
	} else {
		if(x > 2){
			int ix = 0;
			vi skrap;
			rep(i,1,2*n-1+1) if(i < x-2 || i > x+1)
				skrap.push_back(i);
			rep(i,0,n-2) cout << skrap[ix++] << endl;
			cout << x-1 << endl << x << endl << x+1 << endl << x-2 << endl;
			rep(i,n+2,2*n-1) cout << skrap[ix++] << endl;
		} else {
			int ix = 0;
			vi skrap;
			rep(i,1,2*n-1+1) if(i < x-1 || i > x+2)
				skrap.push_back(i);
			rep(i,0,n-2) cout << skrap[ix++] << endl;
			cout << x+1 << endl << x << endl << x-1 << endl << x+2 << endl;
			rep(i,n+2,2*n-1) cout << skrap[ix++] << endl;
		}
	}
}

Measured memory_bytes: 2420