akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <stack>

using namespace std;

int main(){
  int A,B;
  cin >> A >> B;
  if(A+B>=24){
    cout << (A+B)-24 << endl;
  }else{
    cout << A+B << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long N,K;
    cin >> N >> K;
    vector<long long> A(N+4,0);
    vector<long long> DP(N+4,100000000000);
    for (long long i = 0; i<N; ++i) {
        cin >> A[i];
    }
    DP[0] = 0;
    DP[1] = abs(A[0]-A[1]);
    if (N==2) {
        cout << DP[1];
    }
    else {
        for (long long i = 2,total=0; i<N; ++i) {
            for (int k = 1; k<=K && i-k>=0; ++k) {
                DP[i] = min(DP[i], abs(A[i]-A[i-k])+DP[i-k] );
            } 
        }
        cout << DP[N-1];
    }
}

Measured memory_bytes: 4768
(let* ((d-read (read))
    (c (make-array 27))
    (s (make-array (list (+ d-read 1) 27)))
    (td 0)
    (ans 0)
    (last (make-array '(27) :initial-element 0)))

    (loop for i from 1 to 26 do
        (setf (aref c i) (read))
    )
    (loop for i from 1 to d-read do
        (loop for j from 1 to 26 do
            (setf (aref s i j) (read))
        )
    )
    (loop for d from 1 to d-read do
        (let ((x 1))
            (loop for i from 2 to 26 do
                (if (<= (aref s d x) (aref s d i))
                (setq x i)
                )
            )
            (setq td x)
            (setf (aref last td) d)
            (incf ans (aref s d td))
            (loop for j from 1 to 26 do
                (decf ans (* (aref c j) (- d (aref last j))))
            )
            (format t "~D~%" x)
        )
    )
)

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

int main(){

  int a,b,c,d,e,f,g,h,i;
  
  cin>>a>>b>>e;


  for(int s=-300;s<=300;s++){

    h=s-(b+e);

    c=s-(a+b);

    i=s-(a+e);

    f=s-(c+i);

    d=s-(e+f);

    g=s-(c+e);

    if(a+b+c==s&&d+e+f==s&&g+h+i==s&&a+d+g==s&&b+e+h==s&&c+f+i==s&&a+e+i==s&&c+e+g==s){

      cout<<a<<' '<<b<<' '<<c<<endl;
      
      cout<<d<<' '<<e<<' '<<f<<endl;
      
      cout<<g<<' '<<h<<' '<<i<<endl;
      
      return 0;
    }
    
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(int n)
{
	int count = 0;

	while (n > 0)
	{
		n /= 10;

		count++;
	}
	return count;
}
int digit(int n)
{

	int ans = 0;
	while (n > 0)
	{
		ans += n % 10;
		n /= 10;
	}
	return ans;
}
ll combination(ll n, ll r)
{
	if (r * 2 > n)
		r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i)
	{
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int GCD(int x, int y)
{
	return x ? GCD(y % x, x) : y;
}
vector<int> divisor(int n)
{
	vector<int> value;
	FOR(i, 1, pow(n, 0.5) + 1)
	{
		if (i <= sqrt(n))
		{
			if (n % i == 0)
			{
				value.push_back(i);
				if (i * i != n)
				{
					value.push_back(n / i);
				}
			}
		}
	}
	return value;
}

int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	//int tmp=b-a+1;
	cout<<max((ll)b*(n-2)-(ll)a*(n-2)+1,(ll)0)<<endl;
}


Measured memory_bytes: 256
fn main() {
    // input
    // N
    let n = read_line::<usize>();
    // A
    let a = read_vec::<usize>();
    // B
    let b = read_vec::<u32>();
    // C
    let c = read_vec::<u32>();

    let mut ans = b.into_iter().sum::<u32>();

    for now in 0..((n - 1) as usize) {
        if a[now] + 1 == a[now + 1] {
            ans += c[a[now] - 1];
        }
    }

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

#[allow(dead_code)]
fn read_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read_line::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstring>
#include<string.h>
using namespace std;
int n,m,i,j,k,a,b,c,g;
char s[3000][3000],gg;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("\n");
		scanf("%c",&gg);
		a=0;
		while (gg!='\n'){
			s[i][a]=gg;
			a++;
			scanf("%c",&gg);
		}
		for (int j=1;j<i;j++){
			if (strcmp(s[i],s[j])==0) g=1;
		}
		if (i==1) continue;
		if (s[i-1][strlen(s[i-1])-1]!=s[i][0]) g=1;
	}
	if (g==1) printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1144
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();
   int C = sc.nextInt();
   int K = sc.nextInt();
 
   int[] re = {A,B,C};
   Arrays.sort(re);
   
   int d =1;
   for(int i =0;i<K;i++) d*=2;
 
   System.out.println(re[0]+re[1]+re[2]*d);
 }
}

Measured memory_bytes: 21332
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
S = input()

def check(S):
    if S[0]!="A":
        return False
    if Counter(S[2:-1])["C"]!=1:
        return False
    s_counter = Counter(S)
    for w in s_counter:
        if w.isupper():
            if w == "A":
                if s_counter[w] != 1:
                    return False
            elif w == "C":
                if s_counter[w] != 1:
                    return False
            else:
                return False
    return True

if check(S):
    print("AC")
else:
    print("WA")
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#define ll long long
#define rep(i, a, b) for(int i = a; i < b; i++)
using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if((abs(a-b) <= d && abs(b-c) <= d) || abs(a-c) <= d) cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair < int, int >;

const int mod = 1e9 + 7;
void add_self (int & a, int b) {
	a += b;
	if (a >= mod) a -= mod;
}
int mul (int a, int b) {
	return (ll) a * b % mod;
}

struct Matrix {
	vector < vector < int > > mat;
	Matrix (int m, int n) {
		mat.resize (m, vector < int > (n));
	}
	Matrix operator * (const Matrix & b) const {
		int m = mat.size();
		int n = b.mat[0].size();
		int K = mat[0].size();
		assert (K == (int) b.mat.size());
		Matrix c = Matrix (m, n);
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n; j++) {
				for (int k = 0; k < K; k++) {
					add_self (c.mat[i][j], mul (mat[i][k], b.mat[k][j]));
				}
			}
		}
		return c;
	}
	Matrix operator ^ (ll k) {
		const int m = mat.size(), n = mat[0].size();
		assert (m == n);
		Matrix answer (m, m);
		for (int i = 0; i < m; i++) {
			answer.mat[i][i] = 1;
		}
		while (k > 0) {
			if (k & 1) answer = answer * (*this);
			*this = (*this) * (*this);
			k >>= 1;
		}
		return answer;
	}
};

int main() {
	int n; ll k;
	scanf ("%d%lld", &n, &k);
	Matrix a (n, n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			scanf ("%d", &a.mat[i][j]);
		}
	}
	Matrix answer = a ^ k;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			add_self (ans, answer.mat[i][j]);
		}
	}
	printf ("%d\n", ans);
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;

int main(){
    int A, B, C;
    cin >> A >> B;
    for(int i=1; i<=3; ++i){
        if(A*B*i%2 == 1){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
  int N, A, B, digit, j;
  long long sum = 0;
  cin >> N >> A >> B;
  for(int i = 1; i <= N; i++) {
    digit = 0;
    j = i;
    while(j > 0) {
      digit += j % 10;
      j = j / 10;
    }
    if(digit >= A && digit <= B) {
      sum += i;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
N = int(input())
A = [ int(x) for x in input().split()]

S = [0]

for a in A:
    S += [ S[-1] + a ]

l = 0
r = 2
ans = float('inf') 

for i in range(1, N-1):
    while S[i] - S[l+1] > S[l]:
        l += 1

    while S[N] - S[r+1] > S[r] - S[i]:
        r += 1

    a = S[l]
    b = S[i] - S[l]
    c = S[r] - S[i]
    d = S[N] - S[r]
  
    ans = min(ans, max(a,b,c,d) - min(a,b,c,d))
print(ans)


Measured memory_bytes: 24684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int N;
string s;
int ans=0;
int main(void)
{
    cin >> N;
    cin >> s;
    for(int i=0;i<N;i++)
    {
        if(s[i]=='>') 
        {
            ans=N-i;
            break;
        }
    }
    for(int i=N-1;i>=0;i--)
    {
        if(s[i]=='<') 
        {
            ans=max(ans,i+1);
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = stdIn.nextInt();
		}
		int max, min;
		max = min = a[0];
		for (int j = 0; j < n; j++) {
			if (max < a[j])
				max = a[j];
			if (min > a[j])
				min = a[j];
		}

		int dif;
		dif = max - min;
		System.out.println(dif);
	}
}

Measured memory_bytes: 21844
using System;
using System.Collections;
using System.Collections.Generic;
 
class TEST{
	static void Main(){
		while(true){
			int n=int.Parse(Console.ReadLine());
			if(n==0)break;
			Sol mySol =new Sol(n);
			mySol.Solve();
		}
	}
}

class Sol{
	public void Solve(){
		
		long[] Weight=new long[N];
		for(int i=0;i<N;i++)Weight[i]=0;
		
		
		for(int i=0;i<N;i++){
			long g=gcd(Mob[i][0],Mob[i][1]);
			Mob[i][0]/=g;
			Mob[i][1]/=g;
			if(Mob[i][2]==0 && Mob[i][3]==0)Weight[i]=Mob[i][0]+Mob[i][1];
		}
		bool chk=true;
		while(chk){

			chk=false;
			for(int i=0;i<N;i++){
				if(Weight[i]!=0)continue;
				if(Mob[i][2]!=0 && Weight[Mob[i][2]-1]==0){
					chk=true;
					continue;
				}
				if(Mob[i][3]!=0 && Weight[Mob[i][3]-1]==0){
					chk=true;
					continue;
				}
				long wl=1;
				if(Mob[i][2]!=0 && Weight[Mob[i][2]-1]!=0)wl=Weight[Mob[i][2]-1];
				long wr=1;
				if(Mob[i][3]!=0 && Weight[Mob[i][3]-1]!=0)wr=Weight[Mob[i][3]-1];
				
				long lcm=wl*wr*Mob[i][0]*Mob[i][1]/gcd(wl*Mob[i][0],wr*Mob[i][1]);
				long rl=lcm/(wl*Mob[i][0]);
				long rr=lcm/(wr*Mob[i][1]);
				Weight[i]=rl*wl+rr*wr;
			}
		}
		
		long Max=0;
		for(int i=0;i<N;i++)if(Max<Weight[i])Max=Weight[i];
		
		Console.WriteLine("{0}",Max);
		
	}

	int N;
	long[][] Mob;
	public Sol(int n){
		N=n;
		Mob=new long[N][];
		for(int i=0;i<N;i++)Mob[i]=rla();
	}

	long gcd(long a,long b){
		if(b==0)return a;
		return gcd(b,a%b);
	}


	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}

Measured memory_bytes: 5884
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

const int MAX_N = 2e3 + 6, MOD = 1e9 + 7;
int n, k;
int F[MAX_N * MAX_N];
int D[MAX_N * MAX_N];
int dp[MAX_N][MAX_N];

int _sum(int a, int b) {
	int c = a + b;
	if (MOD <= c)
		c -= MOD;

	return c;
}

int _mul(int a, int b) {
	int res = 1LL * a * b % MOD;
	return res;
}

int _pow(int a, int b) {
	if (!b)
		return 1;

	int res = _pow(a, b >> 1);
	res = _mul(res, res);

	if (b & 1)
		res = _mul(res, a);

	return res;
}

int choose(int a, int b) {
	if (b < a || min(a, b) < 0)
		return 0;

	return _mul(F[b], _mul(D[a], D[b - a]));
}

void pre_process() {
	F[0] = 1;
	for (int i = 1; i < MAX_N * MAX_N; i++)
		F[i] = _mul(F[i - 1], i);

	D[0] = 1;
	for (int i = 1; i < MAX_N * MAX_N; i++)
		D[i] = _pow(F[i], MOD - 2);
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	pre_process();
	cin >> n >> k;
	
	if (k == 1) {
		cout << "1\n";
		return 0;
	}

	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		dp[i][0] = 1;
		for (int j = 1; j <= i; j++)
			dp[i][j] = _sum(_mul(dp[i][j - 1], choose(k - 2, n * k - i - (j - 1) * (k - 1) - 1)), dp[i - 1][j]);
	}

	cout << _mul(dp[n][n], F[n]) << "\n";
	return 0;
}

Measured memory_bytes: 46592
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var func = new Function();
            var N = cin.ReadInt;
            
            WriteLine(N % func.findSumOfDigits(N) == 0? "Yes":"No");
            
        }
        
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
    
    public class Function
    {
        public int findSumOfDigits(int n) {
            int sum = 0;
            while (n > 0) { // n が 0 になるまで
            sum += n % 10;
            n /= 10;
                
            }
            return sum;
            
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

 int main() {
    int ans = 0;
    int n;
    cin >> n;

    vector<int> S(n);

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

    }

    int q;
    cin >> q;

    vector<int> T(q);

    for(int j = 0; j < q; j++) {
        cin >> T[j];
    }

    for(int j = 0; j < q; j++) {
      for(int i = 0; i < n; i++) {
        if(S[i] == T[j]) {
          ans++;
          break;
        }
      }
    }
    cout << ans << endl;

 }




Measured memory_bytes: 3124
n = gets.to_i
a = gets.split(' ').map(&:to_i)

hash = {}
a.each do |x|
  hash[x] ||= 0
  hash[x] += 1
end

total = 0
hash.each do |key, val|
  total += val * (val - 1) / 2
end

a.each do |x|
  i1 = hash[x] * (hash[x] - 1) / 2
  i2 = (hash[x] - 1) * (hash[x] - 2) / 2
  diff = i1 - i2
  puts total - diff
end


Measured memory_bytes: 28676
#include<cstdio>
#include<iostream>
#include<vector>
using namespace std;

int main(void) {
	int N;
	scanf("%d", &N);
	long long ans = 0;
	for (int i = 1; i <= N; i++) {
		if (i % 3 != 0 && i % 5 != 0 ) ans += i;
	}
	printf("%lld", ans);

	return 0;
}


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

int main(){
  string a, b, c;
  cin >> a >> b >> c;
  transform(a.begin(), a.end(), a.begin(), ::toupper);
  transform(b.begin(), b.end(), b.begin(), ::toupper);
  transform(c.begin(), c.end(), c.begin(), ::toupper);
  cout << a[0] << b[0] << c[0]<< endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define f first
//#define s second
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define loop(i,n) for(int i=0; i<(n); i++)
#define loop3(i,a,n) for(int i=a; i<(n); i++)
const int mod =1e9 + 7;
ll mini(ll a, ll b)
{
    if(a>=b) return b;
    else return a;
}
int main()
{
    fast
    ll n,w;
    cin>>n>>w;
    ll wgt[n],val[n],sum=0;
    for(int i=0; i<n; i++)
    {
        cin>>wgt[i]>>val[i];
        sum+=val[i];
    }

vector<vector<ll>>dp(n+1,vector<ll>(sum+1,INT_MAX));
    for(int i=0; i<=n; i++) dp[i][0]=0;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=sum; j++)
        {
            if(j>=val[i-1]) dp[i][j]=mini(wgt[i-1]+dp[i-1][j-val[i-1]], dp[i-1][j]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    int ans=0;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=sum; j++)
        {
            if(dp[i][j]<=w)
            {
                ans=max(ans,j);
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 83144
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,sum=0;
  cin>>n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
    sum+=p[i];
  }
  sort(p.begin(),p.end());
  sum-=p[n-1];
  sum+=p[n-1]/2;
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 3624
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int[] arr = new int[n];
		HashMap<Integer, Integer> hmap = new HashMap<>();

		for (int i = 0; i < n; i++) {
			arr[i] = scn.nextInt();
			hmap.put(arr[i], i);

		}
		System.out.println(solve(hmap, arr, 0, n - 1));
	}

	public static int solve(HashMap<Integer, Integer> hmap, int[] arr, int i, int j) {
		if (i > j) {
			//System.out.println("pp " + i + " " + j);
			return 0;
		}
		int min = Integer.MAX_VALUE, idx = 0;
		//System.out.println(hmap + " " + i + " " + j);
		for (int k = i; k <= j; k++) {
			if (arr[k] < min) {
				min = arr[k];
				idx = k;
			}
		}
		HashMap<Integer, Integer> map = new HashMap<>();
		for (int k = i; k <= j; k++) {
			arr[k] -= min;
		}

		for (int k = i; k <= idx - 1; k++) {
			map.put(arr[k], k);
		}
		int x = solve(map, arr, i, idx - 1);

		map = new HashMap<>();

		for (int k = idx + 1; k <= hmap.get(min) - 1; k++) {
			map.put(arr[k], k);
		}
		int y = solve(map, arr, idx + 1, hmap.get(min) - 1);
		
		map = new HashMap<>();

		for (int k = hmap.get(min) + 1; k <= j; k++) {
			map.put(arr[k], k);
		}

		int z = solve(map, arr, hmap.get(min) + 1, j);
		
		return x + y + z + min;
	}

}


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

int main() {
    int a[5],i;
    for (i = 0; i < 5; i++) { cin >> a[i]; }
    if ((a[4] <= a[2] && a[2] <= a[0] - a[4]) && (a[4] <= a[3] && a[3] <= a[1] - a[4])){cout<<"Yes" << endl; }
    else { cout << "No"<<endl; }
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 9223372036854775807
#define MOD 1000000007

int gcd(int a, int b){
    if(a<b)
        swap(a, b);
    int r = a % b;
    if(r==0)
        return b;
    else
        return gcd(b, r);
}

    int main(void)
{
    ll sum = 0;
    int k;
    cin >> k;
    rep(i,k){
        rep(j,k){
            rep(l,k){
                sum += gcd(gcd(i + 1, j + 1), l + 1);
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#if defined(_MSC_VER)
#pragma warning(disable : 4996)  // VSでscanfを使う．
#endif

signed main() {
  string s;
  cin >> s;

  if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
# frozen_string_literal: true

land = gets
downs = []
lakes = []
land.chars.each.with_index do |c, i|
  case c
  when '\\'
    downs.push(i)
  when '/'
    area = 0
    next unless downs.any?

    new_shore = downs.pop
    while lakes.any? && lakes.last[0] > new_shore
      point = lakes.pop
      area += point[1]
    end
    area += i - new_shore
    lakes.push([i, area])
  end
end
results = lakes.map { |l| l[1] }
puts results.sum
results.unshift(results.count)
puts results.join(' ')



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

#include <boost/algorithm/string/classification.hpp>  // is_any_of
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/math/tools/minima.hpp>
#include <boost/multi_array.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>

const int MOD = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < (n); ++i)

namespace adaptor = boost::adaptors;
using namespace std;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::replace_all;
using boost::algorithm::split;
using boost::math::tools::brent_find_minima;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

// TOP
void Main()
{
	string s;
	cin >> s;

	int n;
	n = s.size();
	n -= 2;
	while (n)
	{
		s = s.substr(0, n);
		if (s.substr(0, n / 2) == s.substr(n / 2, n / 2))
		{
			cout << n << endl;
			return;
		}
		n -= 2;
	}
}
// END

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};
use std::collections::HashMap;

fn main() {
	input! {
		n: usize,
		a: [usize; n],
	}

	// xがx個未満なら全部取り除く
	// xがx個より大きいならx個になるように取り除く
	// HashMapを使う

	let mut map = HashMap::new();
	for i in 0..n {
		let count = map.entry(a[i]).or_insert(0);
		*count += 1;
	}

	let mut ans = 0;
	for (key, value) in &map {
		//println!("{}: {}", key, value);
		if value < key {
			ans += value;
		}
		if value > key {
			ans += value - key;
		}
	}
	println!("{}", ans);
}



Measured memory_bytes: 7148
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/

	coding: utf-8
	lang: C (GCC 5.4.1)
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n;
	char s[100003];
	TLong ans = 1, charcnt[26] = { 0 };

	scanf("%d", &n);
	scanf("%s", s);

 	for(int i = 0; i < n; ++i)	++charcnt[s[i] - 'a'];
 	for(int i = 0; i < 26; ++i) ans = (TLong)ans * (charcnt[i] + 1) % TBMod;
 	printf("%lld\n", (ans + TBMod - 1) % TBMod);
}


Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#include <bits/stdc++.h>

#define int long long
#define double long double 

using namespace std;

const int INF = 1e+18;
const int MAXN = 100000;
const int LOGN = 20;
const int mod = 1e9+7;



signed main() {
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, k;
    cin >> n >> k;
    int h[n];
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    int dp[n];
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        dp[i] = INF;
        for (int j = 1; j <= k; j++) {
            if (i - j >= 0) {
                dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
            }
        }
    }
    
    cout << dp[n - 1];
}

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



int main(){
    #define int long long
    int N;
    string S;

    cin >> N >> S;
    int cnt1=0;
    int cnt2=0;
    int cnt3=0;

    for(int i=0;i<N;i++){
        if(S[i]=='R')cnt1++;
        if(S[i]=='G')cnt2++;
        if(S[i]=='B')cnt3++;
    }

    int ans=0;

    ans+=cnt1*cnt2*cnt3;
    int dis=0;
    for(int a=0;a<N;a++){
        for(int b=0;b<N;b++){
            if(a-b<0||a+b>=N){
                continue;
            }
            if(S[a]!=S[a+b]&&S[a-b]!=S[a]&&S[a+b]!=S[a-b]){
                ans--;
            }
            
    }}

    cout << ans << endl;
}

Measured memory_bytes: 3596
#define _CRT_NONSTDC_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>
#include <vector>

using namespace std;
using ll = long long;
const int INTMAX = numeric_limits<int>::max();
const int INTMIN = numeric_limits<int>::min();
const ll LLMAX = numeric_limits<long long>::max();
const ll LLMIN = numeric_limits<long long>::min();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

signed main() {

	int n;
	int sum = 0;
	cin >> n;
	vector<int> a(n);
	vector<int> x(n);
	for (auto&& e : a) {
		cin >> e;
		sum += e;
	}

	int xsum = 0;
	x[0] = 0;
	for (int i = 0; i < n - 1; i++) {
		x[i + 1] = 2 * a[i] - x[i];
		xsum += x[i + 1];
	}

	int diff = sum - xsum;
	for (int i = 0; i < n; i++) {		
		cout << x[i] + diff  << ' ';
		diff *= -1;
	}

	return 0;
}



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




int main(){
int L,D;
cin>>L>>D;

if(D-L>=2018) {
cout<<0;
return 0;
}


int min=2018;

int l=L%2019;
int d=D%2019;
if(d-l<=0) {
cout<<0;
return 0;
}

for(int i=0;i<(d-l);i++){
for(int j=i+1;j<=(d-l);j++){
if(((l+i)*(l+j))%2019<=min) min=((l+i)*(l+j))%2019;
}
}

cout<<min;
 return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = 2 * pow(10, 9) + 1;//+1しないとREになるかも(out of rangeになるんかな?? )

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };

ll max(ll a, ll b) { return (a > b) ? a : b; }
ll min(ll a, ll b) { return (a < b) ? a : b; }

////////////////////////////////////////////////////////////////

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = pow(10, 9) + 7;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
};



template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

vector<ll> enum_divisor(ll x){
	ll tmp = x;
	vector<ll> res;
	for(ll i=1; i*i<=x; i++){
		if(tmp%i == 0){
			res.push_back(i);
			if(i*i != tmp) res.push_back(tmp/i);//iが√tmpのときは重複して数えないようにする
		} 
	}
	return res;
}

////////////////////////////////////////////////////////////////
#define PI 3.14159265359
int main(void) {
	
	int N;
	cin >> N;
	vector<int> A(N-1);
	int tmp = 0;
	for(int i=0; i<N-1; i++){
		cin >> tmp;
		tmp--;
		A[i] = tmp;
	}

	vector<int> ans(N, 0);
	for(int i=0; i<N-1; i++){
		ans[A[i]]++;
	}

	for(int i=0; i<N; i++){
		cout << ans[i] << endl;
	}
}



Measured memory_bytes: 4844
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
int main(void) {	
	long long N, mod = 1000000007;
	cin >> N;
	vector<long long> A(N);
	for (int i = 0; i < N; ++i) cin >> A[i];

	long long ans = 0;
	for (long long i = 0; i < 60; ++i) {
		unsigned long long res = 0;
		long long ones = 0;
		for (long long j = 0; j < N; ++j) {
			if (A[j] & 1) ++ones;
			A[j] >>= 1;
		}
		long long zeroes = N - ones;
		res = (long long)pow(2, i) % mod * ones % mod * zeroes % mod;
		ans += res;
		ans %= mod;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 2560
n, k = gets.chomp.split.map(&:to_i)
arr = gets.chomp.split.map(&:to_i)

del = 0
y = 0
while y < n
    x = y - 1
    x -= 1 while x >= 0 && !arr[x]
    while x >= 0 && arr[x] < arr[y]
        arr[x] = nil
        x -= 1 while x >= 0 && !arr[x]
        del += 1
        break if del == k
    end
    y += 1
    break if del == k
end

if del == k
    puts (arr.compact)[0, n - k].join
else
    y = n - 1
    y -= 1 while y > 0 && !arr[y]
    while y > 0
        x = y + 1
        while x <= n - 1 && arr[x] && arr[y] > arr[x]
            arr[x] = nil
            x += 1
            del += 1
            break if del == k
        end
        y -= 1
        y -= 1 while y > 0 && !arr[y]
        break if del == k
    end
    puts (arr.compact)[0, n - k].join
end



Measured memory_bytes: 23452
#include<iostream>
#include<queue>
#include<utility>
#include<cstring>
#define MP make_pair
using namespace std;
typedef pair<int, int> PII;

int w, h;
bool field[70][35];
int cost[35][35];
queue<PII> Q;

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
bool judge(int x, int y)
{
  if(0 <= x && x < h && 0 <= y && y < w)
    return true;
  return false;
}

int main()
{
  while(true){
    cin >> w >> h;

    if(!w && !h)
      break;

    memset(field, false, sizeof field);
    memset(cost, 0, sizeof cost);

    for(int i = 0; i < 2 * h - 1; i++)
      for(int j = 0; j < (i % 2 ? w : w - 1); j++)
	cin >> field[i][j];

    Q.push(MP(0, 0));
    cost[0][0] = 1;

    int nowcost = 0;
    while(!Q.empty()){
      int sz = Q.size();
      nowcost++;

      for(int i = 0; i < sz; i++){
	PII now = Q.front();
	Q.pop();

	for(int j = 0; j < 4; j++){
	  PII next = MP(now.first + dx[j], now.second + dy[j]);

	  if(judge(next.first, next.second) && !field[2 * now.first + dx[j]][dy[j] == -1 ? now.second - 1 : now.second] && cost[next.first][next.second] == 0){
	    cost[next.first][next.second] = nowcost + 1;
	    Q.push(next);
	  }
	}
      }
    }

    cout << cost[h - 1][w - 1] << endl;
  }

  return 0;
}

Measured memory_bytes: 1224
#include <cstdio>
#include <algorithm>
#include <climits>

#define ll long long
#define MAXN 200000
#define MAXL 1000000000



ll f[MAXN + 1];

int main() {
    ll n, total = 0, sum = 0, rez = LONG_LONG_MAX;
    ll dif;
    scanf("%lld", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &f[i]);
        total += f[i];
    }
    for (int i = 1; i <= n; i++) {
        sum += f[i];
        if (total - 2 * sum > 0)
            dif = total - 2 * sum;
        else
            dif = 2 * sum - total;
        if (i < n)
            rez = std::min(rez, dif);
    }
    printf("%lld", rez);
    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=100010;

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

    ll n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    ll ans=0;
    for(ll i=0;i<n;++i)
    {
        if(s[i]=='L'&&i-1>=0&&s[i-1]=='L'){++ans;}
        if(s[i]=='R'&&i+1<n&&s[i+1]=='R'){++ans;}
    }

    ans=min(ans+2*k,n-1);
    cout<<ans;

	return(0);
}


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

const int N = 505;
int n, a[N * N];
struct node { int x, pos; }e[N];

bool cmp(node a, node b) { return a.x < b.x; }

int main() {
    cin >> n;
    rep(i, 1, n) {
        cin >> e[i].x;
        if (a[e[i].x]) return puts("No"), 0;
        a[e[i].x] = i, e[i].pos = i;
    }
    sort(e + 1, e + n + 1, cmp);
    int now = 1;
    rep(i, 1, n) {
        rep(j, 1, e[i].pos - 1) {
            while (a[now]) ++now;
            a[now] = e[i].pos;
        }
        if (now > e[i].x) return puts("No"), 0;
    }
    rep(i, 1, n) {
        if (e[i].pos == n) continue;
        int now = e[i].x + 1;
        rep(j, 1, n - e[i].pos) {
            while (a[now]) ++now;
            a[now] = e[i].pos;
        }
        if (now > n * n) {
            // printf("%d !!\n", e[i].pos);
            return puts("No"), 0;
        }
    }
    puts("Yes");
    rep(i, 1, n * n) printf("%d ", a[i]); puts("");
    return 0;
}


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

int main() {
  int64_t X, K, D;
  cin >> X >> K >> D;
  if (X < 0) X = -X;
  if (X / D < K) {
    K = K - X / D;
    X = X % D;
    if (K % 2 == 0) {
      cout << X << endl;
    } else {
      cout << abs(X-D) << endl;
    }
  } else {
    cout << abs(X - K*D) << endl;
  }
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <map>
using namespace std;

int main() {
	int N; cin >> N;
	vector<int> H(N);
	for (int i = 0; i < N; i++)
		cin >> H.at(i);
	
	int ans = 1, joi = 0;
	for (int i = 1; i < N; i++) {
		for (int j = 0; j < i; j++) {
			if (H.at(j) <= H.at(i)) joi++;
		}
		if (joi == i) ans++;
		joi = 0;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

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

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int T, X;

int main(int argc, const char * argv[]) {
    T = inputValue();
    X = inputValue();
    output(T*1.0/X);

    return 0;
}

Measured memory_bytes: 888
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

ll safemod(ll a,ll m){
	return (a%m+m)%m;
}

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

	int N=in(),K=in();
	ll S=0;

	for(int i=K;i<N+2;i++){
		ll P=i;
		ll L=(i-1);
		ll R=N-(i-1)+N;
		if(P%2){
			L/=2;
			R/=2;
		}
		else P/=2;
		
		L = (L*P)%atcoder_mod;
		R = (R*P)%atcoder_mod;

		S += safemod(R-L+1LL,atcoder_mod);
		S%=atcoder_mod;
	}

	out(S);
	return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

#define INF (1<<29)
#define INFL (1ll<<60)
#define EPS (1e-8)
#define PI (acos(-1))
#define MOD 1000000007ll

template<class A, class B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<class A, class B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;

int main() {
	ll n;
	cin >> n;
	ll ans = 1;
	bool done[1001] = {};
	done[0] = done[1] = true;
	REP(i, n + 1) {
		int cnt = 0;
		if (done[i]) continue;
		for (int j = i; j <= n; j += i) {
			done[j] = true;
			int now = j;
			while (now % i == 0) {
				now /= i;
				cnt++;
			}
		}
		ans = (ans * (cnt + 1)) % MOD;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define out(S) cout<<(S)<<endl;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define beginend(v) v.begin(),v.end()

using pii=pair<int,int>;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vvc=vector<vector<char>>;
using ti3=tuple<int,int,int>;
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }


int solve(int n,int m){
  vi w(m+1,0),h(n+1,0);
  rep(i,n) cin>>h[i+1];
  rep(i,m) cin>>w[i+1];

  rep(i,n) h[i+1]+=h[i];
  rep(i,m) w[i+1]+=w[i];


  map<int,int> hm,wm;
  rep(i,n+1) for(int j=i+1;j<=n;++j) hm[h[j]-h[i]]++;
  rep(i,m+1) for(int j=i+1;j<=m;++j) wm[w[j]-w[i]]++;


  int ans=0;
  rep(i,max(h[n],w[n])+1) ans+=(hm[i]*wm[i]);
  return ans;
}

int main(){
  int N,M;
  while(cin >> N >> M,N|M){
    out(solve(N,M));
  }
}



Measured memory_bytes: 50780
#include <iostream>

int main()
{
	long long a, b, c, count = 0;

	std::cin >> a >> b >> c;

	if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
		std::cout << 0 << std::endl;
		return 0;
	}

	long long sum = a + b + c;

	while (a % 2 != 1 && b % 2 != 1 && c % 2 != 1) {
		a = (sum - a) / 2;
		b = (sum - b) / 2;
		c = (sum - c) / 2;

		count++;

		if (a == b && a == c) {
			std::cout << -1 << std::endl;
			return 0;
		}
	}

	std::cout << count << std::endl;

	return 0;
}

Measured memory_bytes: 256
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

string s,t;
int ans = 0;

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
	
	cin >> s >> t;
	for(int i=0;i<s.size();i++){
		if(s[i]==t[i])ans++;
	}
	cout << ans << endl;

return 0;
}
///....


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define endl "\n"
typedef long long ll;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl
#define MOD 1000000007

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

  string S; cin>>S;

  if(S[2]==S[3] && S[4]==S[5]) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

N = int(readline())
S = [list(map(int, readline().strip())) for _ in range(N)]

ans = -1
for st in range(N):
    level = [None]*N
    level[st] = 0
    used = set([st])
    stack = [st]
    flag = True
    while len(used) < N:
        stack2 = []
        for vn in stack:
            used.add(vn)
            for vf in range(N):
                if S[vn][vf]:
                    if level[vf] is None:
                        level[vf] = level[vn]+1
                        stack2.append(vf)
                    elif level[vf] == level[vn]-1 or level[vf] == level[vn]+1:
                        continue
                    else:
                        flag = False
        stack = stack2[:]
    if flag:
        ans = max(ans, max(level)+1)
print(ans)
    
            

Measured memory_bytes: 43996
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
string a,b;
int main()
{
    cin>>a>>b;
    a+=b;
    char s[6];
    for(int i=1;i*i<=100200;i++)
    {
        sprintf(s,"%d",i*i);
        if(s==a)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<char> vec(6);
  for(int i=0;i<6;i++)
   cin>>vec.at(i);
  if(vec.at(0)==vec.at(5) && vec.at(1)==vec.at(4) && vec.at(2)==vec.at(3))
    cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
import sys
N = int(sys.stdin.readline().rstrip())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    divisors.sort()
    return divisors

def prime_judge(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    a = set(a)
    if len(a) == 1:
        return True
    else:
        return False

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    a = set(a)
    if len(a) == 1 and prime_judge(list(a)[0]):
        return True
    else:
        return False

divisors = make_divisors(N)
ans = 0
for d in divisors:
    if prime_factorize(d) and N % d == 0 and N // d > 0:
            N //= d
            ans += 1
print(ans)


Measured memory_bytes: 9500
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e9+7;
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }



int main(){
  ll A,B,C;
  cin>>A>>B>>C;
  
  ll F=max(A,max(B,C));//一番目大きい
  ll T=min(A,min(B,C));//三番目に大きい
  ll S=A+B+C-F-T;//二番目に大きい
  
  ll ans=0;
  ans+=(F-S);
  
  if((F-T-ans)%2==0){
    ans+=((F-T-ans)/2);
  }
  else{
    ans+=((F-T-ans)/(2)+2);
  }
  
  cout<<ans<<endl;
}


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

using ll = long long;

int main(){
  ll k;
  std::string s;
  std::cin>>s>>k;
  int sign=0;
  for(int i=0;i<s.size();++i){
    if(s[i]!='1'){
      sign=i;
      break;
    }
  }
  if(sign>k-1){
    std::cout<<1<<std::endl;
  }else{
    std::cout<<s[sign]<<std::endl;
  }
}

Measured memory_bytes: 256
#coding:utf-8

import sys
S=map(int,raw_input())

st=[]

ans=0
for s in S:
    st.append(s)
    if len(st)>=2:
        a=st.pop()
        b=st.pop()
    else:
        continue
    if (a==0 and b==1) or (a==1 and b==0):
        ans+=2
    else:
        st.append(a);st.append(b)
print(ans)

Measured memory_bytes: 4228
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  if(a % b == 0){
    cout << "0\n";
    return 0;
  }
  cout << "1\n";
}


Measured memory_bytes: 3600
#include <stdio.h>
int main()
{
    int A,B;
    scanf("%d %d",&A,&B);
        if(A<=B){
            printf("0");
        }
        else if(A<=2*B){
        printf("0");
        }
        else{
        printf("%d",A-2*B);
        }
    return 0;
}

Measured memory_bytes: 128