akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			int q = cin.Int();
			string s = cin.Next();
			var td = new Tuple<char, char>[q];
			for (int i = 0; i < q; i++) {
				string t = cin.Next();
				string d = cin.Next();
				td[i] = new Tuple<char, char>(t[0], d[0]);
			}

			int l = -1;
			int r = n;
			for (int i = q - 1; i >= 0; i--) {
				if (l < n - 1) {
					if (td[i].Item1 == s[l + 1] && td[i].Item2 == 'L') {
						++l;
					} else if(l >= 0) {
						if (td[i].Item1 == s[l] && td[i].Item2 == 'R') {
							--l;
						}
					}
				}

				if (r > 0) {
					if (td[i].Item1 == s[r - 1] && td[i].Item2 == 'R') {
						--r;
					} else if (r < n) {
						if (td[i].Item1 == s[r] && td[i].Item2 == 'L') {
							++r;
						}
					}
				}
			}

			int ans = Math.Max(0, Math.Min(r - l - 1, n));
			Console.WriteLine(ans);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => 
			int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 26300
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    string S;
    cin >> S;

    ll res = 0, pos = 0, ans = 0;
    for (int bit = 0; bit < (1<<S.length()-1); ++bit) {
        //cout << bitset<3>(bit) << endl;

        res = 0, pos = 0;
        REP(i, S.length()-1) {
            pos += int(S[i] - '0');
            if (bit & (1<<i)) {
                res += pos;
                pos = 0;
            }
            else{
                pos = pos * 10;
            }
            //cout << pos << endl;
        }
        pos += int(S[S.length()-1] - '0');
        ans += res + pos;
        //cout << res + pos << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>
typedef long long ll;
int main() {
	ll a, b, x;
	scanf("%lld%lld%lld", &a, &b, &x);
	if (a == 0)
		printf("%lld\n", b / x + 1);
	else
		printf("%lld\n", (b / x + 1) - ((a - 1) / x + 1));
	return 0;
}

Measured memory_bytes: 128
sx,sy,tx,ty=map(int,input().split())

ans=''
for _ in range(ty-sy):
  ans+='U'
for _ in range(tx-sx):
  ans+='R'
for _ in range(ty-sy):
  ans+='D'
for _ in range(tx-sx):
  ans+='L'
ans+='L'
for _ in range(ty-sy+1):
  ans+='U'
for _ in range(tx-sx+1):
  ans+='R'
ans+='DR'
for _ in range(ty-sy+1):
  ans+='D'
for _ in range(tx-sx+1):
  ans+='L'
ans+='U'
print(ans)

Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))

count = [0 for _ in range(10 ** 5 + 1)]
for a in A:
    count[a] += 1

ret = 0

for i in range(1, 10 ** 5):
    ret = max(ret, count[i - 1] + count[i] + count[i + 1])

print(ret)


Measured memory_bytes: 14008
#include <cassert>
#include "limits.h"
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<long double, long double>;

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

  ll n;
  std::cin>>n;

  std::vector<ll> cnt(13,0);
  rep(i,0,n){
    ll temp;
    std::cin>>temp;
    cnt[temp]++;
  }

  if(cnt[0]>=1||cnt[12]>=2){
    std::cout<<0<<"\n";
    return 0;
  }
  rep(i,1,12){
    if(cnt[i]>=3){
      std::cout<<0<<"\n";
      return 0;
    }
  }

  ll ans=0;

  for(ll i=1ll<<11;i>=0;i--){
    std::vector<ll> num;
    num.push_back(0);
    if(cnt[12]==1)num.push_back(12);
    rep(j,1,12){
      if(cnt[j]==2){
        num.push_back(j);num.push_back(-j);
      }else if(cnt[j]==1){
        num.push_back(j*(((i>>(j-1))&1)?1:-1));
      }
    }

    std::sort(all(num));

    ll si=num.size();

    ll val=std::min(num[si-1]-num[0],24ll+num[0]-num[si-1]);
    rep(j,1,si){
      chmin(val,std::min(num[j]-num[j-1],24+num[j-1]-num[j]));
    }

    chmax(ans,val);
  }

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

  return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
int n, zz[maxn], t, ans;
char s[maxn];

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	int x, y;
	for (x = 1; x <= n; x = y + 1) {
		y = x;
		while(y < n && s[y + 1] == s[y]) ++y;
		zz[++t] = y - x + 1;
	}
	//for (int i = 1; i <= t; ++i) printf("%d ", zz[i]); printf("\n");
	for (int i = 1; i <= t; ++i) {
		ans += (zz[i] / 3) * 2;
		zz[i] %= 3;
		if(zz[i] == 0) continue;
		if(zz[i] == 1) ++ans;
		else if(zz[i] == 2) {
			if(i < t) {
				ans += 2;
				--zz[i + 1];
			}
			else ++ans;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 4484
n,m = map(int, input().split())
d = dict()
cnt = 0
for i in range(n):
  d[i] = []
for x in range(m):
  s = list(map(int, input().split()))
  for i in s[1:]:
    d[i-1].append(x)
p = list(map(int, input().split()))
for bi in range(2**n):
  l = [0]*m
  for k in range(n):
    if bi & 2**k:
      for x in d[k]:
        l[x] = 1-l[x]
  if l == p:
    cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl(1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

bool check(ll mid,ll n,ll k,vector<ll> &A,vector<ll> &F){
  ll num=0;
  rep(i,n){
    //cout<<A[i]<<" "<<F[i]<<endl;
    num+=max((ll)0,A[i]-mid/F[i]);
    //cout<<num<<endl;
  }
  //cout<<num<<endl;
  return num<=k;
}

void solve(){
	ll n,k;cin>>n>>k;
  vector<ll>A(n);
  vector<ll>F(n);
  rep(i,n)cin>>A[i];
  rep(i,n)cin>>F[i];
  sort(all(A));
  sort(all(F),greater<ll>());
  //check(2,n,k,A,F);
  ll right=INF;
  ll left=-1;
  while(right-left>1){
    ll mid=left+(right-left)/2;
    if(!check(mid,n,k,A,F))left=mid;
    else right=mid;
  }
  cout<<right<<endl;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	solve();
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second

signed main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

		int d,t,s;
		cin >> d >> t >> s;

		if(t*s>=d)
			cout << "Yes";
		else
			cout << "No";



	
	

	return 0;
}			

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

int n, k;
string s;
int main() {
    cin.tie(0); cin.sync_with_stdio(0);
    cin >> n >> k >> s;
    vector<int> group;
    int cur = 0;
    for (int i = 0; i < n; i++) {
        if (i > 0 && s[i] != s[i - 1]) {
            group.push_back(cur);
            cur = 0;
        }
        ++cur;
    }
    group.push_back(cur);
    int m = group.size();
    vector<int> sum(m + 1, 0);
    for (int i = 0; i < m; i++) {
        sum[i + 1] = sum[i] + group[i];
    }
    int ans = 0;
    for (int i = 1; i <= m; i++) {
        int x = s[sum[i - 1]] - '0';
        int r;
        if (x == 0) { // ceil
            r = min(m, i + 2 * k - 1);
        } else { // floor
            r = min(m, i + 2 * k);
        }
        ans = max(ans, sum[r] - sum[i - 1]);

    }
    cout << ans;
}

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

int main(){
    int D=0;
    int T=0;
    int S=0;
    cin >> D >> T >> S;
    double Y= (double)D/(double)S;
    if(Y<=T){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

#define FOR(i,n) for(int i=0;i<n;i++)
#define PRINT(a) cout<<a<<"\n"
 
int main(){

	int x;
	cin>>x;

	if(x<1200) PRINT("ABC");
	else PRINT("ARC");
	

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

// i枚目まで見てj枚選んでいてその合計がkである選び方の数
ll dp[60][60][2501];
ll N, A;
ll x[100];

int main() {
  cin >> N >> A;
  rep(i, 0, N) { cin >> x[i]; }

  dp[0][0][0] = 1;
  repe(i, 1, N) {
    repe(j, 0, N) {
      repe(k, 0, 2500) {
        if (j == 0) {
          dp[i][j][k] = dp[i - 1][j][k];
        } else {
          if (k >= x[i - 1]) {
            dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i - 1]];
          } else {
            dp[i][j][k] = dp[i - 1][j][k];
          }
        }
      }
    }
  }

  ll ans = 0;
  repe(j, 1, N) { ans += dp[N][j][A * j]; }
  cout << ans;
}


Measured memory_bytes: 53640
#include <stdio.h>
#include <stdlib.h>
int cmp(const void *a,const void *b){
return *(int *)b-*(int *)a;
}
int main(){
    int n,i,buf,ans=1;
    scanf("%d",&n);
    int d[n];
    for(i=0;i<n;i++)scanf("%d",&d[i]);
    qsort(d,n,sizeof(int),cmp);
    buf=d[0];
    for(i=1;i<n;i++){
    if(buf!=d[i]){
    ans++;
    buf=d[i];
    }
    }
    printf("%d",ans);
}

Measured memory_bytes: 128
H,W = map(int,input().split())
S = [(2+W)*"."]+["."+input()+"." for h in range(H)]+[(2+W)*"."]

for h in range(1,1+H):
  for w in range(1,1+W):
    if S[h][w]!="#":
      s = S[h-1][w-1:w+2]+S[h][w-1]+S[h][w+1]+S[h+1][w-1:w+2]
      S[h]=S[h][:w]+str(s.count("#"))+S[h][w+1:]

for h in range(1,1+H):
  print(S[h][1:1+W])

Measured memory_bytes: 9164
#pragma GCC diagnostic ignored "-Wreturn-type"
#include<bits/stdc++.h>
#include<cstdio>
#include<limits>
#define deb(x) cout<<#x<<'='<<(x)<<endl
#define deb2(x,y) cout<<'['<<#x<<'='<<(x)<<','<<#y<<'='<<(y)<<']'<<endl
#define debmap(v) {cout<<#v<<'=';for(auto p:v)cout<<'('<<p.first<<','<<p.second<<") ";cout<<endl;}
#define debarr(a,n) {cout<<#a<<'='; for(int i=0;i<n;i++) cout << a[i] << ' '; cout<<endl;}
#define deb2darr(a,n,m) {cout<<#a<<"=\n";for(int i=0;i<n;i++){for(int j=0;j<m;j++)cout<<a[i][j]<<' ';cout<<endl;}}
#define debvec(v) {cout<<#v<<'=';for(auto itr=v.begin();itr!=v.end();itr++)cout<<*itr<<' ';cout<<endl;}
#define deb2dvec(v) {cout<<#v<<"=\n";for(auto x:v){for(auto y:x)cout<<y<<' ';cout<<endl;}}
#define ll long long
#define int long long
#define INF numeric_limits<int>::max()
#define NINF numeric_limits<int>::min()
using namespace std;

void solve(){
	int n;
	cin>>n;
	int a,b,c,d;
	a=b=c=d=0;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		if(s=="AC") a++;
		if(s=="WA") b++;
		if(s=="TLE") c++;
		if(s=="RE") d++;
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", a, b, c, d);
}

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

	int T=1;
	while(T--){
		solve();
	}
}



Measured memory_bytes: 3724
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define mp make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1<<60)
#define MOD 1000000007
#define rep(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

ll gcm(ll n, ll m) {
    if (n < m)swap(n, m);
    ll r = n % m;
    while (r != 0) {
        n = m;
        m = r;
        r = n % m;
    }
    return m;
}

ll lcm(ll n, ll m) {
    ll x = n * m;
    ll t=gcm(n, m);
    return x / t;
}

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

    string s;
    cin >> s;
    if (s.length() == 2)cout << s << endl;
    else {
        reverse(s.begin(), s.end());
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
   int a[10000], b[10000], c[10000], A, B, C, i, n;
   scanf("%d", &n);
   for(i = 0; i < n; i++){
      scanf("%d %d %d", &a[i], &b[i], &c[i]);
   }
   for(i = 0; i < n; i++){
      A = a[i] * a[i];
      B = b[i] * b[i];
      C = c[i] * c[i];
      if(A == B + C || B == C + A || C == A + B)
         printf("YES\n");
      else
         printf("NO\n");
   }
   return 0;
}

Measured memory_bytes: 1796
N, M = [int(x) for x in input().split()]

CITYID = 2
PREF = 0
YEAR = 1
city = [[int(x) for x in input().split()] + [i] for i in range(M)]

city.sort()
id = [""] * M
ord = 1 # 同じ県の中の順番

for i in range(M):
    if i > 0 and city[i][PREF] == city[i - 1][PREF]:
        ord += 1
    else:
        ord = 1
    id[city[i][CITYID]] = '{:0>6}{:0>6}'.format(str(city[i][PREF]),  str(ord))

for i in range(M):
    print(id[i])


Measured memory_bytes: 31296
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;


int main(){

  int sx,sy,tx,ty;

  cin >> sx >> sy >> tx >> ty;

  int lenx = tx-sx;
  int leny = ty-sy;


  cout << string(leny,'U') << string(lenx,'R');

  cout << string(leny,'D') << string(lenx,'L');

  cout << 'L' << string(leny+1,'U') << string(lenx+1,'R') << 'D';

  cout << 'R' <<string(leny+1, 'D') << string(lenx+1, 'L') << 'U';

  cout << endl;
  return 0;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int x;
    std::cin >> x;
    if(x==1){
        std::cout << "Hello World" << std::endl;
    }else{
        int a,b;
        std::cin >> a >>b;
        std::cout << a+b << std::endl;
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(x, to) for (int x = 0; x < (to); x++)
#define REP(x, a, to) for (int x = (a); x < (to); x++)
#define EPS (1e-14)
#define _PA(x,N) rep(i,N){cout<<x[i]<<" ";}cout<<endl;
#define _PA2(x,H,W) rep(i,(H)){rep(j,(W)){cout<<x[i][j]<<" ";}cout<<endl;}

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef complex<double> Complex;
typedef vector< vector<int> > Mat;

const ll mod = 1e+9 + 7;
ll N;
ll ans = 1;

ll a[1005];
ll prime[1005];

void solve() {
	for (int i = 0; i < 1005; i++) {
		a[i] = i;
	}
	for (int i = 2; i <= N; i++) {
		if (a[i] == 1) continue;
		prime[i]++;
		for (int j = i + i; j <= N; j += i) {
			while (a[j] % i == 0) {
				a[j] /= i;
				prime[i]++;
			}
		}
	}

	//_PA(prime, 10);

	for (int i = 2; i <= N; i++) {
		ans = (ans * (prime[i] + 1LL)) % mod;
	}
	cout << ans << endl;
}

int main() {
	cin >> N;
	solve();
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n;
    string s,t;
    cin>>n>>s>>t;
    char ans[300]={};
    int k=0;
    for(int i=0;i<n;i++){
        ans[k++]=s[i];
        ans[k++]=t[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>

typedef long long ll;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

int main(){

    ll n,k;
    cin>>n>>k;

    ll min=n;

    if(n%k==0){
        min=0;
    }
    else{
        min=n%k;
        while(true){
            if(SafeAbs(k-min)<min){
                min=SafeAbs(min-k);
            }
            else{
                break;
            }
        }
    }

    cout<<min<<endl;

    return 0;
}


Measured memory_bytes: 256
n=int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
score = a.pop(0)
if n%2==1:
  score += sum(a[:(n-1)//2-1])*2 + a[(n-1)//2-1]
else:
  score += sum(a[:(n-1)//2])*2
print(score)

Measured memory_bytes: 94200
import java.util.Scanner;

public class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();
		long work = 0;
		int A[][] = new int[n][m];
		int B[][] = new int[m][l];
		long C[][] = new long[n][l];
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				A[i][j] = sc.nextInt();
			}
		}
		
		for(int i = 0; i < m; i++){
			for(int j = 0; j < l; j++){
				B[i][j] = sc.nextInt();
			}
		}
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < l; j++){
				for(int k = 0; k < m; k++){
					work += (A[i][k] * B[k][j]);
				}
				C[i][j] = work;
				work = 0;
			}
		}
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < l; j++){
				System.out.print(C[i][j]);
				if(j == l - 1){
					System.out.println("");
				}else{
					System.out.print(" ");
				}
			}
		}
	}
}

Measured memory_bytes: 53568
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
#define Maxn 100010
struct Data{
	int at,val;
	bool operator <(const Data &z)const{return val<z.val;}
}data[Maxn];
int main(){
	scanf("%d",&n);
	int x;
	for(register int i=1;i<=n;++i){
		scanf("%d",&x);
		data[i]=(Data){i,x};
	}
	sort(data+1,data+n+1);
	for(register int i=1;i<=n;++i)printf("%d ",data[i].at);
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <map>
#define ll long long

using namespace std;

int main(void){
    string s, check;
    cin >> s;
    ll ans = 900;
    ll count = 0;
    string comp = "abcdefghijklmnopqrstuvwxyz";
    for(ll i = 0; i < comp.length(); i++){
        check = s;
        count = 0;
        bool b = true, c = true;
        while(b==true){
            for(ll j = 0; j < check.length(); j++){
                if(check[j]==comp[i] && check[j+1]!=comp[i]){
                    check[j+1] = comp[i];
                    j++;
                }
            }
            check.erase(check.begin());
            count++;
            for(ll j = 0; j < check.length(); j++){
                if(check[j]!=comp[i]) break;
                if(j==check.length()-1)
                    b = false;
            }
            if(check.length()==0)
                b = false;
            if(b==false)
                ans = min(ans, count);
        }
    }
    for(ll i = 0; i < s.length()-1; i++){
        if(s[i]!=s[i+1]) break;
        if(i==s.length()-2)
            ans = 0;
    }
    if(s.length()==1)
        ans = 0;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#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 std;
using namespace __gnu_pbds;

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

const int INF = 1e18;
const int mod = 1e9 + 7;
const int N = 2005;

int i, j, k, s, fact[N], ifact[N], dp[N][N], pref[N][N];

int pwr(int x, int y)
{
    int res = 1;
    x %= mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % mod;
        y >>= 1;
        x = (x * x) % mod;
    }
    return res;
}

int modinv(int n)
{
    return pwr(n, mod - 2);
}

int add(int a, int b)
{
    a %= mod, b %= mod;
    return a + b >= mod ? a + b - mod : a + b;
}

int mul(int a, int b)
{
    a %= mod, b %= mod;
    return (a * b) % mod;
}

int C(int n, int r)
{
    if (n < r || r < 0)
        return 0;
    return mul(fact[n], mul(ifact[r], ifact[n - r]));
}

int P(int n, int r)
{
    if (n < r || r < 0)
        return 0;
    return mul(fact[n], ifact[n - r]);
}

void precompute()
{
    fact[0] = 1;
    ifact[0] = 1;
    for (int i = 1; i < N; ++i)
    {
        fact[i] = mul(fact[i - 1], i);
        ifact[i] = mul(ifact[i - 1], modinv(i));
    }
}

void solve()
{
    precompute();
    cin >> s;
    if (s < 3)
    {
        cout << 0;
        return;
    }
    dp[0][0] = 1;
    for (i = 1; i <= s; i++)
    {
        pref[i - 1][0] = dp[i - 1][0];
        for (j = 1; j <= s; j++)
        {
            pref[i - 1][j] = dp[i - 1][j];
            pref[i - 1][j] += pref[i - 1][j - 1];
            pref[i - 1][j] %= mod;
        }
        for (j = 3; j <= s; j++)
        {
            dp[i][j] += pref[i - 1][j - 3];
            dp[i][j] %= mod;
        }
    }
    int ans = 0;
    for (i = 1; i <= s; i++)
    {
        ans += dp[i][s];
        ans %= mod;
    }
    cout << ans;
}

signed main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fastio;
    int t;
    //cin >> t;
    t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}

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

ll inf=1e18;

int main() {
  ll n,k;
  cin >> n >> k;
  vector<ll> x(n);
  ll cn=0,cp=0;
  for(int i=0;i<n;i++) {
    cin >> x[i];
    if(x[i]>0) {
      cp++;
    }
    else if(x[i]<0) {
      cn++;
    }
    else if(x[i]==0) {
      i--;
      n--;
      k--;
    }
  }
  ll ans=inf;
  if(k<=0) {
    cout << 0 << endl;
  }
  else {
    if(cn>=k) {
      ans=min(ans,abs(x[cn-k]));
      for(ll i=0;i<cn;i++) {
        if(cn+i>n-1) {
          break;
        }
        ans=min(ans, min(abs(x[cn-k+i+1]),x[cn+i])+abs(x[cn-k+i+1])+x[cn+i]);
      }
    }
    else {
      for(ll i=0;i<cn;i++) {
        if(k-1+i>n-1) {
          break;
        }
        ans=min(ans, min(abs(x[i]),x[k+i-1])+abs(x[i])+x[k-1+i]);
      }
    }
    if(cp>=k) {
      ans=min(ans,x[cn+k-1]);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

void shuffle(int *cards,int p, int c){
	int *mt1 = new int[p-1];
	for(int i=0;i<p-1;i++){
		mt1[i] = cards[i];
	}	
	int *mt2 = new int[c];
	for(int i=0;i<c;i++){
		mt2[i] = cards[p-1+i];
	}
	for(int i=0;i<c;i++){
		cards[i] = mt2[i];
	}
	for(int i=0;i<p-1;i++){
		cards[c+i] = mt1[i];
	}
	delete[] mt1;
	delete[] mt2;
}

int main(){
	int n,r;//カードの枚数,シャッフルの回数
	while(true){
		cin >> n >> r;
		if(n==0 && r==0){
			break;
		}
		int *cards = new int[n];
		for(int i=0;i<n;i++){
			cards[i] = n-i;
		}
		for(int i=0;i<r;i++){
			int p,c;//上からpの場所からc個
			cin >> p >> c;
			shuffle(cards,p,c);
		}
		int result = cards[0];
		cout << result << endl;
		delete[] cards;
	}
	
	return 0;
}

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

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

    sort (arr,arr+n);

    int a = arr[n-1];
    int sum;
    int mn = 99999999;
    for (int i=0;i<100;i++)
    {
        sum =0;
        for (int j=0;j<n;j++)
        {
            int c = (i-arr[j])* (i-arr[j]);
            sum+=c;
        }
        if (sum<mn)
            mn = sum;
    }

    cout<<mn<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=2e5+10;
const int MAX=410;
const int dx[4]={0,0,1,-1};
const int dy[4]={1,-1,0,0};
int fa[MAXN],sum[MAXN],s[MAXN];
bool w[MAXN];
char a[MAX][MAX];
int n,m;
ll ans;
int getfather(int x)
{
	if (fa[x]==x) return x;
	fa[x]=getfather(fa[x]);
	return fa[x];
}
void adit(int x,int y)
{
	x=getfather(x);
	y=getfather(y);
	if (x!=y) {
		fa[x]=y; sum[y]+=sum[x]; s[y]+=s[x];
	}
}
void solve(int x)
{
	x=getfather(x);
	if (!w[x]) {
		w[x]=1; ans+=(ll)(sum[x]-s[x])*(ll)s[x];
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) {
		scanf("%s",a[i]+1);
	}
	for (int i=1;i<=n*m;i++) fa[i]=i,sum[i]=1;
	for (int i=1;i<=n;i++) {
		for (int j=1;j<=m;j++)
		 if (a[i][j]=='#') s[(i-1)*m+j]=1;
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++) {
			for (int k=0;k<4;k++) {
				int x=i+dx[k];
				int y=j+dy[k];
				if (x<=0||y<=0||x>n||y>m) continue;
				if (a[x][y]!=a[i][j])
				{
 				adit((x-1)*m+y,(i-1)*m+j);}
			}
		}
	}
	for (int i=1;i<=n*m;i++) solve(i);
	cout << ans << endl;
}

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

const int N = 2000010;
int n;
struct  Node
{
	int x, id;
} a[N];

bool operator < (Node a, Node b) {
	return a.x < b.x;
}

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i].x), a[i].id = i;
	sort(a + 1, a + n + 1);
	for(int i = 1; i <= n; ++i) printf("%d ", a[i].id);
}

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

int main()
{
  int n;
  cin >> n;
  
  int p[n-1];
  for(int i=0;i<n;i++)
    cin >> p[i];
  
  int ans=0;
  
  for(int j=0;j<n-2;j++){
    if(p[j]<p[j+1]&&p[j+1]<p[j+2])
      ans++;
    else if(p[j]>p[j+1]&&p[j+1]>p[j+2])
      ans++;
    else
      continue;
  }
  
  cout << ans;
  
  return 0;
}


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

int main() {
	int n;
	cin>>n;
	
	double probs[n];
	for (int k=0; k < n; k += 1)
	{
		cin>>probs[k];
	}
	
	double dp[n + 1][n + 1];
	memset(dp, 0.0, sizeof(dp));
	
	dp[0][0] = 1;

	for (int i=0; i <= n; i += 1)
	{
		for (int j = 0; j <= i; j += 1)
		{
			if (i == 0 && j == 0)
				continue;
			if (j == 0)
			{
				dp[i][j] = dp[i - 1][j] * (1.0 - probs[i - 1]);
			}
			else
			{
				dp[i][j] = dp[i - 1][j] * (1.0 - probs[i - 1]) + dp[i - 1][j - 1] * probs[i - 1];
			}
		}
	}
	
	
	double ans = 0;
	for (int m = (n+1)/2; m <= n; m += 1)
	{
		ans += dp[n][m];
	}
	cout<<fixed<<setprecision(10)<<ans;
	return 0;
}

Measured memory_bytes: 70528
#include<stdio.h>
int main(void){
    int i,n,f,s,t;
    f=0,s=0,t=0;
    for(i=0;i<10;i++){
        scanf("%d",&n);
        if(f<n||f==n){
            t=s;
            s=f;
            f=n;
            continue;
        }else if(s<n||s==n){
            t=s;
            s=n;
            continue;
        }else if(t<n||t==n){
            t=n;
            continue;
        }else continue;
    }
        printf("%d\n%d\n%d\n",f,s,t);



return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  printf("%f\n", sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
  return 0;
}


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

#define vt          vector
#define sz(x)       int((x).size())
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

using ll = long long;
using pii = pair<int, int>;

void solve() {
    int n;
    string s;
    cin >> n >> s;
    for (char &c : s) c = (c - 'A' + n) % 26 + 'A';
    cout << s;
}

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

    int tcs = 1;
    for (int tc = 1; tc <= tcs; tc++) {
        // cout << "Case " << tc << ": ";
        solve();
    }
}


Measured memory_bytes: 3660
function main(arg) {
  const array = arg.trim().split("\n");
  const S = array[0];
  const T = array[1];
  var substLastStr = T.slice(0, -1);

  if (S.length != T.length - 1) {
    console.log("No");
    return;
  }

  if (S == substLastStr) {
    console.log("Yes");
    return;
  } else {
    console.log("No");
    return;
  }
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
// main("snuke\nsnekee");
//https://atcoder.jp/contests/abc167/tasks/abc167_a


Measured memory_bytes: 30320
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<algorithm>
#include<sstream>
#include<deque>
#include<iomanip>
#include<cctype>
#include<vector>
#include<utility>

#define F(i,a,b) for(int (i)=(a);(i)<(b);(i)++)

using namespace std;

int main(void)
{
	char c[100][100];
	F(i,0,3)cin>>c[i];
	cout<<c[0][0]<<c[1][1]<<c[2][2];

	return 0;
}

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

typedef struct _List{
	_List* front;
	_List* rear;
	int data;
}List;

int main(void){
	std::ios_base::sync_with_stdio(false);
	int n;
	string s;
	int d;
	cin >> n;
	List* top;
	List* end;
	List a;
	a.front = NULL;
	a.rear = NULL;
	a.data = 0;
	top = &a;
	end = &a;

	for(int i=0; i<n; i++){
		cin >> s;
		if(s == "insert"){
			cin >> d;
			List* temp = new List;
			
			temp->data = d;
			temp->rear = top;
			temp->front = NULL;
			top->front = temp;
			top = temp;
		}else if(s == "delete"){
			cin >> d;
			List* t = top;

			while(t != NULL && t->rear != NULL){
				if(t->data == d){
					if(t->front != NULL)(t->front)->rear = (t->rear);
					else top = t->rear;
					if(t->rear != NULL)(t->rear)->front = (t->front);
					break;
				}
				t = t->rear;
			}
		}else if(s == "deleteFirst"){
			if(top->rear != NULL)(top->rear)->front = NULL;
			top = top->rear;
		}else if(s == "deleteLast"){
			List* t = end;

			t = t->front;
			t = t->front;
			if(t != NULL)t->rear = end;
			else top = end;
			end->front = t;
		}
	}

	List* t = top;
	while(t->rear != NULL){
		if(t != top) cout << " ";
		cout << t->data;
		t = t->rear;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 35596
#include <stdio.h>

int main(void)
{
	int a,b,c,d[7];
	for(c=0;c<7;c++){
		scanf("%d %d",&a,&b);
		d[c]=a-b;
	}
	for(c=0;c<7;c++){
		printf("%d\n",d[c]);
	}
	return 0;
}


Measured memory_bytes: 2040
#include <stdio.h>

void PrintAll(int A[],int N){
    int i;
    for(i=0; i<N; i++){
        if(i != 0) printf(" "); 
        printf("%d",A[i]);
    }
    printf("\n");
}

void insertionSort(int A[],int N){
    int i,j,v;

    for(i=1; i<N; i++){
        v = A[i];
        j = i-1;
        while(j>=0 && A[j] > v){
            A[j+1] = A[j];
            j--;
            A[j+1] = v;
        }
        PrintAll(A,N);
    }
}

int main(){
    int i,N;
    int A[1000];

    scanf("%d",&N);
    for(i=0; i<N; i++) scanf("%d",&A[i]);

    PrintAll(A,N);
    insertionSort(A,N);

    return 0;
}



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


int main()
{  
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll dp[n][n],s[n][n];
    for(int i=0;i<n;i++)
    {
        for(int j=i;j<n;j++)
        {
            if(i==j)s[i][j]=a[i];
            else s[i][j]=s[i][j-1]+a[j];
        }
    }
    for(int i=n-1;i>=0;i--)
    {
        for(int j=i;j<n;j++)
        {
            if(i==j)dp[i][j]=0;
            else
            {
                dp[i][j]=1e18;
                for(int k=i;k<j;k++)
                {
                    dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+(s[i][k]+s[k+1][j]));
                }
            }
        }
    }
    cout<<dp[0][n-1]<<"\n";
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

ll d;
vector<vl> s;
vl c(26);
vector<set<ll>> st(26, {-1});
ll score;

void add(ll i, ll k) {  // i日目(0-index)、テストk（0-index）
  st[k].insert(i);
  auto pi = st[k].lower_bound(i);
  pi--;
  ll prev, next;
  if(pi == st[k].begin())
    prev = -1;
  else
    prev = *pi;
  auto ni = st[k].upper_bound(i);
  if(ni == st[k].end())
    next = d;
  else
    next = *ni;
  score += c[k] * (i - prev) * (next - i) + s[i][k];
}

void rm(ll i, ll k) {
  auto pi = st[k].lower_bound(i);
  pi--;
  ll prev, next;
  if(pi == st[k].begin())
    prev = -1;
  else
    prev = *pi;
  auto ni = st[k].upper_bound(i);
  if(ni == st[k].end())
    next = d;
  else
    next = *ni;
  score -= c[k] * (i - prev) * (next - i) + s[i][k];
  st[k].erase(i);
}

void eval(vl &t) {
  rep(i, d) {
    ll k = t[i];
    add(i, k);
  }
}

int main() {
  double limit = double(clock()) / double(CLOCKS_PER_SEC) + 1.95;
  // 入力をもらう
  cin >> d;
  rep(i, 26) cin >> c[i];
  s.resize(d, vl(26));
  rep(i, d) rep(j, 26) cin >> s[i][j];

  //// 入力を作るデバッグ用
  // d = 365;
  // s.resize(d, vl(26));
  // rep(i, 26) c[i] = rand() % 101;
  // rep(i, d) rep(j, 26) s[i][j] = rand() % 20001;

  // 初期解をランダムに作って評価、scoreに反映
  score = -accumulate(all(c), 0LL) * d * (d + 1) / 2;
  vl t(d);
  rep(i, d) t[i] = max_element(all(s[i])) - s[i].begin();
  eval(t);

  while(double(clock()) / double(CLOCKS_PER_SEC) < limit) {
    ll xd = rand() % d;
    ll xt = rand() % 26;
    rep(i, 5) {
      ll xd2 = rand() % d;
      if(xd > xd2) xd = xd2;
      ll xt2 = rand() % 26;
      if(c[xt] < c[xt2]) xt = xt2;
    }
    ll old_score = score;
    ll old_test = t[xd];
    if(xt == t[xd]) xt = (xt + 1) % 26;
    rm(xd, t[xd]);
    add(xd, xt);
    if(score < old_score) {
      rm(xd, xt);
      add(xd, old_test);
    } else
      t[xd] = xt;
  }
  rep(i, d) cout << t[i] + 1 << '\n';
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
 
int main() {
  
  int N ;
  cin >> N  ;
  int ans= 0 ;
  vector<int> A(N);
  map<int,int> mp;
  rep(i,N) cin >> A.at(i);
  rep(i,N){
    mp[A.at(i)]++   ;
    mp[A.at(i)-1]++ ;
    mp[A.at(i)+1]++ ;
  }
  for( auto p : mp ){
    int B = p.second ; 
    ans = max(ans,B);
  }
  cout << ans << endl ;
}

    
    


Measured memory_bytes: 5120
import java.util.Scanner;

public class Main {
	
	public static void main(String... ac) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt(), x = sc.nextInt();
		
		int sum = 0, min = (int) 2e9;
		
		for (int i = 0; i < n; i++) {
			int m = sc.nextInt();
			sum += m;
			min = Math.min(min, m);
		}
		
		System.out.println(n + (x - sum) / min);
		
	}
	
}

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

using ll = long long;
const int MOD = 1e9 + 7;

void setIO(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

int main() {
	setIO();
	ll a;
	long double b;
	cin >> a; cin >> b;
	cout << (ll) (a * b) << "\n";
}


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

using namespace std;

int main() {
  string N;
  cin >> N;
  string target = "";
  for (size_t i = 0; i < N.size(); ++i) {
    target += N[0];
  }
  int n = stoi(N);
  int t = stoi(target);
  if (n == t) {
    cout << N << endl;
    return 0;
  } else if (n < t) {
    cout << t << endl;
  } else {
    char c = N[0] + 1;
    for (size_t i = 0; i < N.size(); ++i) {
      cout << c;
    }
    cout << endl;
  }
  return 0;
}


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

int main() {
  int s, w; cin >> s >> w;
  if (s <= w) cout << "unsafe";
  else cout << "safe";
  return 0;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder str = new StringBuilder(in.readLine());
		str.reverse();
		System.out.println(str.toString());
	}
}

Measured memory_bytes: 16856
#include <iostream>

int N,A[100005];
int check[50005];
int main(){
  std::cin>>N;
  for(int i=0;i<N;++i)
    std::cin>>A[i];
  
  for(int i=0;i<N;++i)
    ++check[(N-1-A[i])/2];
  
  long long ans=1;
  int end=(N+2-1)/2;
  for(int i=0;i<end;++i)
    if(check[i]==0||N%2==1&&i==(end-1)&&check[i]!=1||i!=(end-1)&&check[i]!=2){
      std::cout<<"0"<<'\n';
      return 0;
    }
  else
    ans=ans*check[i]%1000000007;
  
  std::cout<<ans<<'\n';
  
  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main () {
  int K;
  string S;
  cin >> S >> K;
  for(int i = 0; i < S.size(); i++){
    if(S.size() - 1 == i){
      S.at(i) = (S.at(i) - 'a' + K) % 26 + 'a';
      break;
    }
    if(26 - (S.at(i) - 'a') <= K && S.at(i) != 'a'){
      K -= 26 - (S.at(i) - 'a');
      S.at(i) = 'a';
    }
  }
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PI 3.14159265358979
#define EPS 1e-8
#define mod 1000000007
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define endl "\n"
	 
const ll INF=(ll)2e18;
		
		
vector<ll> g[200050];
ll ans=0;

ll dfs(ll s,ll par)
{
	ll res1=1,res=1;
	
	vector<ll> v;
	
	for(auto i:g[s])
	{
		if(i==par)
			continue;
		v.pb(dfs(i,s));
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	if(v.size()>0)
		res1+=v[0];
	res=res1;
	if(v.size()>1)
	{
		res1+=v[1];
	}
	ans=max(ans,res1);

	return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
				
	ll n;
	cin>>n;
	
	for(ll i=1;i<n;i++)
	{
		ll u,v;
		cin>>u>>v;
		g[u].pb(v);
		g[v].pb(u);
	}
	dfs(1,0);
	
	if(ans%3==2)
		cout<<"Second";
	else
		cout<<"First";
}


Measured memory_bytes: 29184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

const int mod=1000000007;
vector<bool> a(1001,true);

void Era(int n){
	a.at(0)=false;
	a.at(1)=false;
	int i=2;
	while(i<=n){
		for(int j=i*2;j<=n;j+=i){
			a.at(j)=false;
		}
		for(int j=i+1;j<=n;++j){
			if(a.at(j)==true){
				i=j;
				break;
			}
			if(j>sqrt(n)){
				i=n+1;
				break;
			}
		}
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> P;
	vector<ll> cnt(1001);
	Era(1000);
	rep(i,1001){
		if(a.at(i)) P.pb(i);
	}
	ll ans=1;
	for(int i=2;i<=n;++i){
		for(int j=0;j<P.size();++j){
			int b=i;
			while(b%P.at(j)==0){
				cnt.at(j)++;
				b/=P.at(j);
			}
		}
	}
	rep(i,1001){
		if(cnt.at(i)){
			ans=ans*(cnt.at(i)+1)%mod;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    int ab[a+1][b+1],sum=0;
    memset(ab, 0, sizeof(ab)); 
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++){
            cin >> ab[i][j];
            ab[i][b] +=ab[i][j];
            ab[a][j] += ab[i][j];
        }
        sum+=ab[i][b];
    }
    ab[a][b] = sum;
    for(int i=0;i<a+1;i++){
        for(int j=0;j<b+1;j++){
          if(j==b){
            cout << ab[i][j];
          }
          else{
              cout << ab[i][j] << " ";
          }
        }
        cout << endl;
    }
}


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

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

  string tmp;

  // まずはBの移動経路を確認
  tmp = s.substr(b - 1, d - b + 1);
  if (tmp.find("##", 0) != std::string::npos) {
    cout << "No" << endl;;
    return 0;
  }

  // 次にAを移動させる
  tmp = s.substr(a - 1, c - a + 1);
  if (tmp.find("##", 0) != std::string::npos) {
    cout << "No" << endl;
    return 0;
  }

  if (c < d) {
    cout << "Yes" << endl;
    return 0;
  }

  // AがBを飛び越す必要があるとき
  // Bの初期位置の一つ手前からBの移動先の一つ先までの間に"..."があれば
  // Aは移動できる？
  tmp = s.substr(b - 2, d - b + 3);
  if (tmp.find("...", 0) == std::string::npos) {
    cout << "No" << endl;
    return 0;
  }

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

Measured memory_bytes: 3688
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = Console.ReadLine().Trim();
            int iN = int.Parse(sS);
            List<int> lstInp = new List<int>();
            for (int i = 0; i < iN; i++)
            {
                sS = Console.ReadLine().Trim();
                lstInp.Add(int.Parse(sS));
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            lstInp.Sort(delegate (int mca1, int mca2) { return (int)(mca2 - mca1); });      // 降順
            int iOut = 1;
            int iBak = lstInp[0];                                                           // 比較元
            for (int i = 1; i < lstInp.Count; i++)
            {
                if (iBak <= lstInp[i]) { continue; }                                        // 同じ大きさ以上はスルー
                iOut++;
                iBak = lstInp[i];
            }

            // 出力
            Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int max=0;
  for(int i=0;i<N;i++){
    int sum=0;
    bool a[26]={};
    for(int j=0;j<=i;j++){
      a[S[j]-'a']=true;
    }
    for(int j=i+1;j<N;j++){
      if(a[S[j]-'a']){
        sum++;
        a[S[j]-'a']=false;
      }
    }
    if(sum>max)max=sum;
  }
  cout << max;
}






Measured memory_bytes: 256
def main():
    H, W, K = [int(i) for i in input().split(' ')]
    grid = [list(input()) for i in range(H)]
    res = 0
    for i in range(2**H):
        for j in range(2**W):
            g = grid

            remains_black = 0
            for h in range(H):
                if (i >> h) & 1 == 1:
                    continue
                for w in range(W):
                    if (j >> w) & 1 == 1:
                        continue
                    if grid[h][w] == '#':
                        remains_black += 1

            if remains_black == K:
                res += 1
    return res

if __name__ == '__main__':
   print(main())

Measured memory_bytes: 9112