akhauriyash/Code-Regression huggingface dataset:
using namespace std;
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define debug(x) cout << #x <<" = " << x << endl
void solve()
{
string s;
cin>>s;
int l=s.length();
if(s[l-1]=='s')
{
    s+="es";
}
else
s+='s';
cout<<s<<endl;
}
int main()
{
//      #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
FASTIO
 long long int t=1;
// cin>>t;
 while(t--)
  solve();
  return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#define ll long long
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)


using namespace std;

ll Ha, Hb, Hc, Hx, Hy, Hz, Hmax, Hmin;
ll ans;

int n;

int main() {
	cin >> n;
	ans = n / 2 + n % 2;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  long long x;
  cin>>x;
  long long sum=100;
  for(long long i=0;i<1e9;i++){
    sum*=1.01;
    if(sum>=x){
      cout<<i+1<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void){
    ll X, A, B;
    cin>>X>>A>>B;
    X-=A;
    cout<<X%B<<endl;
    return 0;
}


Measured memory_bytes: 3612
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  vector<int> a(4); rep(i, 4) cin >> a[i];
  sort(a);
  if (a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9) YES();
  else NO();
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

int main() {
    int H, W;

    while(-1) {
        cin >> H >> W;

        if(H==0&&W==0) break;

        for(int h=0; h < H; h++) {
            for(int w=0; w < W; w++) {
                if(h%2 == 0 && w%2 ==0) {
                    cout << '#';
                } else if(h%2 != 0 && w%2 != 0) {
                    cout << '#';
                } else {
                    cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}



Measured memory_bytes: 3100
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <queue>
#include <sstream>
#include <climits>
#include <cmath>
#include <list>
#include <functional>
#include <map>
#include <stack>
using namespace std;
#define M_PI 3.141592
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define FORI(i,k,n) for(int i=k;i<(int)n;i++)
#define toRad 2.0*M_PI/360.0
#define inin(x) int x;cin>>x;
#define all(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define EPS 1e-12
#define pri_max 60000
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;

int m[15][15] = {};
int blur[3][5][5] = {
	{
		{0,0,0,0,0},
		{0,0,1,0,0},
		{0,1,1,1,0},
		{0,0,1,0,0},
		{0,0,0,0,0}
	},
	{
		{ 0,0,0,0,0 },
		{ 0,1,1,1,0 },
		{ 0,1,1,1,0 },
		{ 0,1,1,1,0 },
		{ 0,0,0,0,0 }
	},
	{
		{ 0,0,1,0,0 },
		{ 0,1,1,1,0 },
		{ 1,1,1,1,1 },
		{ 0,1,1,1,0 },
		{ 0,0,1,0,0 }
	}

};

void deb()
{
	for (int y = 1; y <= 10; y++)
	{
		for (int x = 1; x <= 10; x++)
		{
			cout<< m[y][x];
		}
		cout << endl;
	}
}

bool check(int y, int x, int k)
{
	for (int Y = 0; Y < 5; Y++)
	{
		for (int X = 0; X < 5; X++)
		{
			if (blur[k][Y][X])
			{
				if (y + Y > 10 || x + X > 10)return false;
				if (m[y + Y][x + X] - 1 < 0)return false;
			}
		}
	}
	return true;
}
void paint(int y, int x, int k, int p)
{
	for (int Y = 0; Y < 5; Y++)
	{
		for (int X = 0; X < 5; X++)
		{
			if (blur[k][Y][X])
			{
				m[y + Y][x + X] += p;
			}
		}
	}
}

bool dfs(int y, int x, int s)
{
	
	if (x == 11)return dfs(y + 1, 0, s);
	if (y == 11)return s == 0;
	if (m[y][x] != 0)return false;
	for (int i = 0; i < 3; i++)
	{
		if (check(y, x, i))
		{
			paint(y, x, i, -1);
			if (dfs(y, x, s - 1))
			{
				cout << x+1 << " " << y+1 << " " << i + 1 << endl;
				return true;
			}
			paint(y, x, i, 1);
		}
	}
	return dfs(y, x + 1, s);
}

int main()
{
	int n;
	cin >> n;
	for (int y = 1; y <= 10; y++)
	{
		for (int x = 1; x <= 10; x++)
		{
			cin >> m[y][x];
		}
	}
	dfs(0, 0, n);

}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define re register
#define ll long long
#define inc(i,j,k) for(re int i=j;i<=k;i++)
#define dec(i,j,k) for(re int i=j;i>=k;i--)
#define edge(u) for(re int i=head[u];i;i=e[i].nxt)
#define pb push_back
#define mp make_pair
#define In inline
#define fi first
#define se second
#define db double
#define ui unsigned int
#define ull unsigned long long 
using namespace std; 
inline int read(){
	int x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while('0'<=ch&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x;
}
char s[25]; 
int main(){ 
	scanf("%s",s+1);
	inc(i,1,3) printf("%c",s[i]);
}

Measured memory_bytes: 3760
#include <iostream>
#include <cstring>
#define MAX_LENGTH 105
using namespace std;

char str[MAX_LENGTH] = {0};
int main(int argc, char const *argv[])
{
	scanf("%s", str);
	int len = strlen(str);
	// cout << len  << "\n" << str << "\n" << ((len - 1) << 1) << "\n";
	int res = 0;
	for (int i = 0; i <= ((len - 1) >> 1); ++i)
	{
		// printf("%c %c\n", str[i], str[len - i - 1]);
		if (str[i] != str[len - i - 1]) res ++;
	}
	cout << res;
	return 0;
}

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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if((10*b+c)%4==0)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod  = 998244353;
ll n,m,k;
ll fac[200005];
ll ans = 0;
ll qpow(ll x,ll n){
	ll res = 1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
ll C(int n,int m){
	return fac[n]%mod*qpow(fac[m],mod-2)%mod*qpow(fac[n-m],mod-2)%mod;
}
int main(){
	cin>>n>>m>>k;
	for(ll i=0;i<n+2;i++) fac[i] = 1;
	for(ll i=1;i<n+2;i++) fac[i] = i*fac[i-1]%mod;
	for(ll i=0;i<=k;i++){
		ans = ans + m*C(n-1,i)%mod*qpow(m-1,n-1-i)%mod;
	}
	cout<<(ans+mod)%mod<<endl;
	return 0;
}

Measured memory_bytes: 5116
# coding: utf-8
# Your code here!

import bisect

n,q = [int(i) for i in input().split()]


a = [int(i) for i in input().split()]
if n%2 == 1:
    n+=1
    a.insert(0, 0)


sikiri = [(a[2*i+1] + a[i+n//2])//2 for i in range(n//2-1)]

s = sum(a[n//2:])
ans = [s]
for i in range(n//2-1):
    s = s - a[i+n//2] + a[2*i+1]
    ans.append(s)



#print(a)
#print(sikiri)
#print(ans)


for _ in range(q):
    x = int(input())
    i = bisect.bisect_left(sikiri,x)
    print(ans[i])
    
    
    

Measured memory_bytes: 14456
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

int main() {
	string S;  cin >> S;
	bool app[26];
	rep(i, 26) app[i] = false;

	for (int i = 0; i < S.length(); i++) app[S[i] - 'a'] = true;

	for (int i = 0; i < 26; i++) {
		if (!app[i]) {
			cout << (char)(i + 'a');
			return 0;
		}
	}

	cout << "None" << endl;
}

Measured memory_bytes: 512
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <regex>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1000000007;

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//myfuncs
//素数判定
template<class T> inline T isPrime(T x) {
	bool ret = true;
	if (x < 2) {
		ret = false;
	}
	for (LL i = 2; i <= sqrt(x); i++) {
		if (x%i == 0) {
			ret = false;
		}
	}
	return ret;
}

//Union FInd
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	int ma=0,mi=1000000009;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		ma = max(ma,tmp);
		mi = min(mi,tmp);
	}
	cout << ma-mi << endl;
	return 0;
}


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

string str;
ll tsum=0,tmul=1;
vector<ll> t;
unordered_map<ll,ll> mem[20][200][3];

ll rec(int p,ll sum,ll mul,int flg){
  if(sum>tsum)return 0;

  if(p==(int)t.size()){
    if(sum<tsum)return 1;
    if(sum==tsum&&mul<tmul)return 1;
    if(sum==tsum&&mul==tmul&&flg==1)return 1;
    return 0;
  }

  if(mem[p][sum][flg].count(mul)>0){
    return mem[p][sum][flg][mul];
  }

  ll l=0,r=9,res=0;

  for(ll i=l;i<=r;i++){
    int nflg=flg;
    if(flg==0){
      if(i<t[p])nflg=1;
      if(i>t[p])nflg=2;
    }
    res+=rec(p+1,sum+i,mul*(i+1),nflg);
  }
  
  return mem[p][sum][flg][mul]=res;
}

int main(){
  cin>>str;
  for(int i=0;i<(int)str.size();i++){
    ll A=str[i]-'0';
    tsum+=A;
    tmul*=(A+1);
    t.push_back(A);
  }
  cout<<rec(0,0,1,0)<<endl;
  return 0;
}

Measured memory_bytes: 30068
#pragma comment(linker, "/stack:200000000")
        #pragma GCC optimize ("Ofast")
        #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
        #include <iostream>
        #include <iomanip>
        #include <sstream>
        #include <cstring>
        #include <vector>
        #include <deque>
        #include <queue>
        #include <set>
        #include <map>
        #include <valarray>
        #include <iterator>
        #include <functional>
        #include <limits>
        #include <algorithm>
        #include <numeric>
        #include <cmath>
        #include <cassert>
        #include <unordered_map>
        #include <unordered_set>
        #include <stack>
        using namespace std;
        #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
         #define trace(x) cerr << #x << ": " << x << " " << endl;
     
        typedef int64_t ll;
     
        #define endl '\n'
        #define int ll
        ll mod=1e9+7;
        ll mod1=1e9+5;
        ll power(ll a,ll b)
        {
            if(b==0) return 1;
            else if(b%2==0)
                return power((((a%mod)*(a%mod))%mod),b/2)%mod;
            else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
        }
        bool is(int n)
        {
            for(int i=2;i<=sqrt(n);++i)
            {
                if(n%i==0)
                    return false;
            }
            return true;
        }
     int32_t main()
        {
            IOS
        
        
            int n;
            cin>>n;
            vector<int> v;
            for(int i=2;i<=55555;++i)
            {
                if((int)v.size()==n)
                    break;
                if(is(i) and i%5==1)
                {
                    v.push_back(i);
                }
            }
            for(int i=0;i<v.size();++i)
                cout<<v[i]<<" ";

        }

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

#include <algorithm>
#include <string>
#include <vector>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<int> ans;
    while (N != 0)
    {
        N--;
        ans.push_back(N % 26);
        N /= 26;
    }
    reverse(ans.begin(), ans.end());
    rep(i, ans.size()) { cout << (char)(ans[i] + 'a'); }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  cout<<fixed<<setprecision(12);
  int n,dinf=0;
  int x[1000];
  int y[1000];
  int dif[1000];
  double sum=0,d2=0,d3=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x[i];
  }
  for(int i=0;i<n;i++){
    cin>>y[i];
  }
  for(int i=0;i<n;i++){
    dif[i]=abs(x[i]-y[i]);
    sum+=dif[i];
  }
  cout<<sum<<endl;
  for(int i=0;i<n;i++){
    d2+=pow(dif[i],2);
    d3+=pow(dif[i],3);
    dinf=max(dinf,abs(x[i]-y[i]) );
  }
  cout<<sqrt(d2)<<endl<<pow(d3,(double)1.0/(double)3)<<endl<<dinf<<endl;
  return 0;
}



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

N=int(readline())
A=list(map(int,readline().split()))
if 0 in A:
  print(0)
  exit(0)
limit = 10 ** 18

ans = 1
for a in A:
  ans *= a
  if ans > limit:
    print(-1)
    exit(0)
else:
  print(ans)

Measured memory_bytes: 21592
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if (b-a) <= k and (c-a) <= k and (d-a) <= k and (e-a) <= k and (c-b) <= k and (d-b) <= k and (e-b) <= k and (d-c) <= k and (e-c) <= k and (e-d) <= k:
  print("Yay!")
else:
  print(":(")



Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;

namespace mod {
  ll power(ll x, ll e) {
    ll v = 1;
    for (; e > 0; e >>= 1) {
      if (e & 1) {
        v = v * x % MOD;
      }
      x = x * x % MOD;
    }
    return v;
  }

  ll inverse(ll x) {
    return power(x, MOD - 2);
  }

  vector<ll> fact, factInv;
  void initFact(int N) {
    fact.resize(N + 1); factInv.resize(N + 1); 
    fact[0] = 1;
    for (int i = 1; i <= N; i++) {
      fact[i] = fact[i-1] * i % MOD; 
    }
    factInv[N] = inverse(fact[N]);
    for (int i = N - 1; i >= 0; i--) {
      factInv[i] = factInv[i + 1] * (i + 1) % MOD;
    }
  }

  ll choose(int n, int k) {
    if (k > n) {
      return 0;
    } else {
      return fact[n] * factInv[k] % MOD * factInv[n-k] % MOD;
    }
  }

  ll multiChoose(int n, int k) {
    if (n == 0 && k == 0) {
      return 1;
    } else {
      return choose(n + k - 1, k);
    }
  }
}

int main() {
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  mod::initFact(N);
  vector<vector<ll>> dp(B + 1, vector<ll>(N + 1, 0));
  dp[A-1][N] = 1;
  for (int k = A; k <= B; k++) {
    for (int n = 0; n <= N; n++) {
      (dp[k][n] += dp[k-1][n]) %= MOD;
      ll y = 1;
      for (int m = 1; m <= D && k * m <= n; m++) {
        y = y * mod::choose(k * m, k) % MOD;
        if (m >= C) {
          ll coef = mod::choose(n, k * m) * y % MOD * mod::factInv[m] % MOD;
          (dp[k][n-k*m] += dp[k-1][n] * coef % MOD) %= MOD;
        }
      }
    }
  }
  cout << dp[B][0] << endl;
  return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define Inf 1000000000
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int main() {
	int N;
	cin >> N;
	vi P(N);
	rep(i, N)
		cin >> P[i];
	int ans = 0;
	int Pmin = Inf;
	rep(i, N) {
		if (P[i] < Pmin) {
			ans++;
			Pmin = P[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
s = list(input())
t = input()

for i in range(len(s) - len(t), -1, -1):
    for j in range(len(t)):
        if s[i+j] != t[j] and s[i+j] != '?':
            break
    else:
        for j in range(len(t)):
            s[i+j] = t[j]
        for j in range(len(s)):
            if s[j] == '?':
                s[j] = 'a'
        print(''.join(s))
        exit()

print('UNRESTORABLE')

Measured memory_bytes: 61820
#include <iostream>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
#define MOD(i) ((i) % 1000000007LL)
using namespace std;
typedef long long ll;

int N, M;
ll X[100000], Y[100000];

int main(void) {
  cin >> N >> M;
  REP(i, 0, N) cin >> X[i];
  REP(i, 0, M) cin >> Y[i];

  ll p = 0;
  REP(i, 0, N - 1) {
    ll n = MOD(((ll) i + 1) * ((ll) N - i - 1));
    ll x = MOD(X[i + 1] - X[i]);
    p = MOD(p + MOD(n * x));
  }

  ll q = 0;
  REP(j, 0, M - 1) {
    ll m = MOD(((ll) j + 1) * ((ll) M - j - 1));
    ll y = MOD(Y[j + 1] - Y[j]);
    q = MOD(q + MOD(m * y));
  }

  cout << MOD(p * q) << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <fstream>
#include <deque>
#include <queue>
#include <iomanip>

#ifdef MYDEBUG
#define debug(value) (cerr << __func__ << " - line #" << __LINE__ << " : " << (#value) << " = " << (value) << endl)
#else // MYDEBUG
#define debug(x) (void)0
#endif // MYDEBUG
using namespace std;

class Init {
public:
    Init() noexcept try {
#ifdef JAEYONG
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
#endif // JAEYONG
        ios_base::sync_with_stdio(false);
        cin.tie(nullptr);

        /// @add more codes to execute before program begins ...
    } catch (...) {
        cerr << "Init constructor threw an exception" << endl;
        terminate();
    }
} __init __attribute__((unused));

///==========---------- For CP ----------==========///

#define endl "\n"
#define all(v) (v).begin(), (v).end()
#define TC int tt;cin>>tt;for(int t=1;t<=tt;t++)

#ifndef JAEYONG
#define __int128 long long
#endif // JAEYONG

typedef long long ll;

template<class T>
istream& operator>>(istream& in, vector<T>& v);

template<class U, class V>
istream& operator>>(istream& in, pair<U, V>& p);

template<class T>
istream& operator>>(istream& in, vector<T>& v) { for(T &i: v) in >> i; return in; }

template<class U, class V>
istream& operator>>(istream& in, pair<U, V>& p) { return in >> p.first >> p.second; }

template<class T>
ostream& operator<<(ostream& out, const vector<T>& v);

template<class U, class V>
ostream& operator<<(ostream& out, const pair<U, V>& p);

template<class T>
ostream& operator<<(ostream& out, const vector<T> &v)
{ auto it = v.begin(); if(!v.empty()) out << *it++; while(it != v.end()) out << *it++; return out; }

template<class U, class V>
ostream& operator<<(ostream& out, const pair<U, V>& p) { return out << p.first << " " << p.second; }

///==========---------- End of Pre-Code ----------==========///

int main() {
	vector<int> v(4);
	cin >> v;
	sort(all(v));
	
	if(v == vector<int>{1, 4, 7, 9}) cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

int main() {
    int n,m,count=0;cin >> n >> m;
    vector<int> h(n);
    for (int i=0;i<n;i++) cin >> h[i];

    vector<vector<int>> G(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    for (int i=0;i<n;i++) {
      int r=0;
      for (int x : G[i]) {
        if (h[i]<=h[x]) r++;
      }
      if (r==0) count++;
    }
  cout << count << endl;
}

Measured memory_bytes: 8740
#include <stdio.h>

int main(){

	int N, flag=1, cnt=0, temp, i;
	int A[100];

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

	while(flag){
		flag = 0;
		for(i=N-1; i>=1; i--){
			if(A[i]<A[i-1]){
				temp = A[i];
				A[i] = A[i-1];
				A[i-1] = temp;
				cnt++;
				flag = 1;
			}
		}

	}

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

	return 0;
}

Measured memory_bytes: 604
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (int i = head[x]; i; i = edge[i].nex)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, cnt) memset(a, cnt, sizeof(a))
#define cop(a, b) memcpy(a, b, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter cout << endl
#define siz(x) ((int)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int maxn = 5e5 + 5 ;
const int inf = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const ll mod = 998244353 ;
const double eps = 1e-7 ;
template <class T> void read(T &a)
{
	int f = 1 ; a = 0;
	char ch = getchar() ;
	while (!isdigit(ch)) { if (ch == '-') f = -1 ; ch = getchar() ; }
	while (isdigit(ch)) { a =  (a << 3) + (a << 1) + ch - '0' ; ch = getchar() ; }
	a *= f ;
}

int n, k;

char s[maxn], ans[maxn], t[maxn];

bool cmp(char *a, char *b)
{
	rep(i, 1, n)
	{
		if(a[i] < b[i]) return 1;
		if(a[i] > b[i]) return 0;
	}
	return 0;
}

signed main()
{
	scanf("%d %d", &n, &k);
	scanf("%s", s + 1);
	rep(i, 1, n) ans[i] = s[i];
	rep(i, 2, n)
	{
		int cnt = 0;
		rep(j, i, n) t[++cnt] = s[j];
		per(j, n, 1)
		{
			t[++cnt] = s[j];
			if(cnt == n) break;
		}
		if(cmp(t, ans)) rep(j, 1, n) ans[j] = t[j];
	}
	rep(i, 1, k - 1)
	{
		int cnt = 1;
		rep(j, 2, n) if(ans[j] == ans[j - 1]) cnt ++; else break;
		if(cnt == n) break;
		per(j, n, cnt + 1) ans[j] = ans[j - cnt];
	}
	rep(i, 1, n) putchar(ans[i]);
	return 0;
}

Measured memory_bytes: 256
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let n : usize = s.trim().parse().ok().unwrap();
    let mut v : Vec<i64> = Vec::new();

    v.push(2);
    v.push(1);
    for i in 2..(n+1) {
        let x = v[i-1] + v[i-2];
        v.push(x);
    }
    println!("{}", v[n]);
}


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

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

    size_t sz = s.size() / 2;
    string s2(sz, '0');

    if (s.size() % 2 != 0)
        s2 = s2 + '0';

    size_t j = 0;
    for (size_t i=0; i<s.size(); ++i) {
        if ((i + 1) % 2 != 0) {
            s2[j] = s[i];
            ++j;
        }
    }
    cout << s2 << endl;
}


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

int main() {
  string x;
  cin >> x;
  
  if (x=="SUN")
    cout << 7 << endl;
  
  else if (x=="MON")
    cout << 6 << endl;
  
  else if (x=="TUE")
    cout << 5 << endl;
  
  else if (x=="WED")
    cout << 4 << endl;
  
  else if (x=="THU")
    cout << 3 << endl;
  
  else if (x=="FRI")
    cout << 2 << endl;
  
  else if (x=="SAT")
    cout << 1 << endl;
}


Measured memory_bytes: 256
<?php
  
  list($x) = explode(" ", trim(fgets(STDIN)));

  $ans = intdiv($x, 11);

  $m = $x % 11;

  if($m == 0){
    echo $ans * 2;
  }else if($m > 6){
    echo $ans * 2 + 2;
  }else{
    echo $ans * 2 + 1;
  }

Measured memory_bytes: 16260
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}


Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

void y() {
    cout << "Yes" << endl;
    exit(0);
}

void n() {
    cout << "No" << endl;
    exit(0);
}

void Y() {
    cout << "YES" << endl;
    exit(0);
}

void N() {
    cout << "NO" << endl;
    exit(0);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}

/*   kokomade  */

int cnt = 0;
bool is_prime[ 50000 + 1 ];
vector<int> P;
void Eratosthenes( const int N )
{
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;//初期化
    }
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
}

int main() {
    IOS;
    string str;cin>>str;
    for (int i = 0; i < str.size(); ++i) {
        if (i%2==0){
            if (str[i]=='L'){
                n();
                return 0;
            }
        }
        if (i%2==1){
            if (str[i]=='R'){
                n();
                return 0;
            }
        }
    }
    y();



    cout<<endl;
    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


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

using namespace std;

const int INF = 1e9 + 7;

int i;
long long n;

int dig(long long v){
	int cnt = 0;
	long long now = 1;
	while(now <= v){
		now = now * 10;
		cnt++;
	}
	return cnt;
}

int main(){
	scanf("%lld", &n);
	
	int res = INF;
	
	for(i = 1; i <= sqrt(n); i++){
		if(n % i == 0)
		res = min(res, max(dig(i), dig(n / i)));
	}
	
	printf("%d\n", res);
}


Measured memory_bytes: 256
s = raw_input()

n = len(s)
K = 0
s_i1=""
size=1

#while len(s.strip(s[0]))>0 or len(s)>2:
while len(s)>2:
    s_i=s[0:size]

    if s_i1 == s_i:
        size = size + 1
    else:
        s_i1=s_i
        s = s[size:]
        size = 1
        K = K + 1
if not s_i1==s[0]:
    if len(s.strip(s[0]))>0:
        K=K+1
K=K+1
print K


Measured memory_bytes: 3176
while True:
    i,e,r = map(int,raw_input().split())

    if i == e == r == -1:
        break
    if i == -1 or e == -1 :
        print 'F'
    elif i+e >= 80 :
        print 'A'
    elif i+e >= 65 :
        print 'B'
    elif i+e >= 50 :
        print 'C'
    elif i+e >= 30 :
        if r >= 50 :
            print 'C'
        else :
            print 'D'
    else :
        print 'F'

Measured memory_bytes: 6440
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define _               ios_base::sync_with_stdio(0);cin.tie(0)
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define ll              long long
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define mk(arr,n,type)  type *arr=new type[n];
#define vpii            vector<pair<int,int> >
#define umii            unordered_map<int,int>
#define lli             list<int>
#define gcd(m,n)        __gcd(m,n)
#define mib             map<int,bool>


int main(){
  int n,w;
  cin >> n >> w;
  vpii items(n);
  for(int i = 0;i < n;i++){
    cin >> items[i].first >> items[i].second;
  }

  ll dp[n][w + 1];
  
  for(int j = 0;j <= w;j++){
    dp[0][j] = j >= items[0].first ? items[0].second : 0;
  }

  for(int i = 1;i < n;i++){
    int v = items[i].first, c = items[i].second;
    for(int j = 0;j <= w;j++){
      if(j < v){
        dp[i][j] = dp[i - 1][j];
      }else{
        dp[i][j] = max(dp[i - 1][j] ,dp[i - 1][j - v] + c);
      }
    }
  }

    
  cout << dp[n - 1][w];
  return 0;
}

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

using namespace std;

int main()
{
	int N, M;

	cin >> N >> M;

	vector<int> A(M);
	vector<int> S(N, 0);

	int B, H;

	for (int i = 0; i < M; i++)
		cin >> A[i];

	for (int i = 0; i < M; i++)
	{
		H = 0;

		for (int j = 0; j < N; j++)
		{
			cin >> B;

			if (B == A[i])
			{
				S[j]++;
			}
			else
			{
				H++;
			}
		}

		S[A[i] - 1] += H;
	}

	for (int i = 0; i < N; i++)
		cout << S[i] << endl;

	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int n; cin >> n;
  vi score(n);
  rep(i,n) cin >> score[i];
  rep(i,n/2) score[i] = (score[n-1-i] += score[i]);

  ll ans = 0;
  for (int i=1; i<n/2; ++i) {
    int last = (n-1)%i == 0 ? n/2 : n-1-i;
    ll sum = 0;
    for (int j=0; j<last; j+=i) {
      sum += score[j];
      ans = max(ans, sum);
    }
  }

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


Measured memory_bytes: 768
PROGRAM piyo
      IMPLICIT NONE
      INTEGER,PARAMETER :: p = 16
      integer(p) :: n,ans, i,j,k,sumVal,maxVal
      integer(p),allocatable :: l(:)
      
      read*,n
      allocate(l(n))
      read*,l
      
      if( n==1.or.n==2 )then
        print*,0
        stop
      end if
      
      ans = 0
      do i = 1,n-2
        do j = i+1,n-1
          do k = j+1,n
            
            if( l(i)==l(j).or.l(j)==l(k).or.l(k)==l(i) ) cycle
            
            sumVal = l(i) + l(j) + l(k)
            maxVal = max(l(i),l(j),l(k))
            if( sumVal-maxVal<=maxVal ) cycle
            
            ans = ans + 1
          end do
        end do
      end do
      
      print*,ans
      
      
      
      stop
      !debugg
      
      
      
      END PROGRAM

Measured memory_bytes: 2860
#include <stdio.h>
#include <string.h>
int main(void){
    int N,X;
    int i;
    int m[1000];
    int min;
    int sum;
    scanf("%d",&N);
    scanf("%d",&X);
    for(i=0;i<N;i++){
        scanf("%d",&m[i]);
        X=X-m[i];
        if(i==0){
            min=m[0];
        }
        if(min>m[i]){
            min=m[i];
        }
    }

    X=X/min;
    sum=N+X;
    printf("%d\n",sum);

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main()
{
  char w[100];
  scanf("%s", w);
  
  if(strlen(w) % 2 != 0){
    printf("No\n"); 
    return 0;
  }

  int hist[32] = {};
  for(int j=0; w[j] != '\0'; j++){
    for(int i=0; i<32; i++){
      if(w[j] == 'a' + i)
        hist[i]++;
    }
  }
  for(int i=0; i<32; i++){
    if(hist[i] % 2 != 0){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main(){
  int sx,sy,tx,ty,i=0;
  scanf("%d %d %d %d",&sx,&sy,&tx,&ty);
  
  for(int j=sy;j<ty;j++) putchar('U');
  for(int i=sx;i<tx;i++) putchar('R');
  for(int j=ty;j>sy;j--) putchar('D');
  for(int i=tx;i>sx;i--) putchar('L');
  putchar('L');
  for(int i=sy;i<ty+1;i++) putchar('U');
  for(int j=sx-1;j<tx;j++) putchar('R');
  putchar('D');
  putchar('R');
  for(int j=ty+1;j>sy;j--) putchar('D');
  for(int i=tx+1;i>sx;i--) putchar('L');
  putchar('U');
  return 0;
}

Measured memory_bytes: 128
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")



#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include <ext/rope>
// using namespace __gnu_pbds;
// using namespace __gnu_cxx;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define Find order_of_key
// #define at find_by_order
#define x first
#define y second
#define ll long long
#define lll __int128
#define ull unsigned long long
#define ulll unsigned __int128
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#define gu getchar_unlocked()
#define pu putchar_unlocked()
#define all(x) x.begin(),x.end()
#define endl '\n'

pii arr[100010];
int n;
int main()
{
	fast;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>arr[i].x;
		arr[i].y=i;
	}
	sort(arr+1,arr+1+n);
	for(int i=1;i<=n;i++)cout<<arr[i].y<<" \n"[i==n];
	return 0;
}

Measured memory_bytes: 4428
n=int(input())
csf=[list(map(int,input().split())) for _ in range(n-1)]

ans_list=[]

for i in range(n):
    now=0
    for g in range(i,n-1):
        c,s,f=csf[g]
        if now<=s:
            now=s
        if now%f==0:
            now+=c
        else:
            now+=(f-now%f)+c
    ans_list.append(now)

for l in range(n):
    print(ans_list[l])


Measured memory_bytes: 3188
import java.util.*;
public class Main{
    public static void main(String[] args){
        final long mod = 1000000007;
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long a = 1;
        long b = 1;
        long c = 1;
        long d = 1;
        for(int i = 0; i < n; i++){
            //0~9のいずれかをN個並べてできる数列の数
            a *= 10;
            a %= mod;
            //1~8のいずれかをN個並べてできる数列の数
            b *= 8;
            b %= mod;
            //0~8のいずれかをN個並べてできる数列の数
            c *= 9;
            c %= mod;
            //1~9のいずれかをN個並べてできる数列の数
            d *= 9;
            d %= mod;
        }
        //条件を満たす数列の数
        long ans = (a - (c + d - b)) % mod;
        if(ans < 0){
            ans += mod;
        }
        
        System.out.println(ans);
    }
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  string s;cin>>s;
  for(i=2;i<s.size();i++){
    ll j=s.size()/2;
    if(i%2==0){
    if(s.substr(0,j-i/2)==s.substr(j-i/2,j-i/2)){
      res=2*j-i;
      break;
    }
    }

  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
  int n,m,i;
  cin>>n>>m;
  vector<int> x(n+1),y(m+1);
  cin>>x[n]>>y[m];
  for(i=0;i<n;i++)cin>>x[i];
  for(i=0;i<m;i++)cin>>y[i];
  if(*max_element(x.begin(),x.end())<*min_element(y.begin(),y.end()))cout<<"No ";
  cout<<"War";
}

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

const int NUM = 1000000001;

int main(){
  int N;  
  cin >> N;
  
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  
  int max_n=0,min_n=NUM;
  for(int i=0; i<N; i++){
    if(A.at(i) > max_n){
      max_n=A.at(i);
    }
    if(A.at(i) < min_n){
      min_n=A.at(i);
    }
  }
  
  cout << max_n - min_n << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;
static const int MAX = 100005;

int ans;
int Q, S[MAX];
bool isprime[MAX];
int x[MAX];

void eratosthenes_seive() {

	for (int i = 2; i <= MAX; i++) isprime[i] = true;

    for (int i = 2; i <= MAX; i++) {
    	if ( isprime[i] == true ) {
    		for (int j = i + i; j <= MAX; j += i) isprime[j] = false;
    	}
    }
}


int main(void) {
    scanf("%d", &Q);
    eratosthenes_seive();

    
    rep(i, 2, MAX) {
        if (isprime[i] && isprime[(i+1)/2]) x[i] = 1;
    }
    rep(i, 1, MAX) {
        S[i] = S[i-1] + x[i];
    }

    rep(i, 0, Q) {
        int l, r;
        scanf("%d %d", &l, &r);
        printf("%d\n", S[r]-S[l-1]);
    }

	return 0;
}


Measured memory_bytes: 1536
n, k= list(map(int, input().split()))
v=list(map(int, input().split()))


res = 0
minNK = min(n, k)

for i in range(minNK + 1):
    for j in range(minNK - i + 1):
        tempList = []
        tempList.extend(v[:i])
        if j!=0:
            tempList.extend(v[-j:])
        tempList.sort()
        tempSum = sum(tempList)
        for idx, val in enumerate(tempList):
            if val < 0 and idx < min(k - i - j, len(tempList)):
                tempSum -= val
        res = max(res, tempSum)

print(res)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N,K;
  scanf("%d %d",&N,&K);
  vector<int> v(N);
  for(int i=0;i<N;i++) scanf("%d",&v[i]);
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  int ans=0;
  for(int i=0;i<K;i++) ans+=v[i];
  cout<<ans<<endl;
}


Measured memory_bytes: 256
///
// File:  alds1_6_c.cpp
// Author: ymiyamoto
//
// Created on Mon Oct  9 21:48:05 2017
//

#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

static vector<pair<char, uint32_t>> array;
static vector<pair<char, uint32_t>> array1;

static void merge(int32_t left, int32_t mid, int32_t right)
{
  vector<pair<char, uint32_t>> lefts;
  vector<pair<char, uint32_t>> rights;

  for (int32_t i = left; i < right; i++) {
    if (i < mid) {
      lefts.push_back(array1[i]);
    } else {
      rights.push_back(array1[i]);
    }
  }

  lefts.push_back({'-', UINT32_MAX});
  rights.push_back({'-', UINT32_MAX});

  uint32_t left_index = 0, right_index = 0;
  for (int32_t i = left; i < right; i++) {
    if (lefts[left_index].second <= rights[right_index].second) {
      array1[i] = lefts[left_index];
      left_index++;
    } else {
      array1[i] = rights[right_index];
      right_index++;
    }
  }
}

static void merge_sort(uint32_t left, uint32_t right)
{
  if (left + 1 < right) {
    uint32_t mid = (left + right) / 2;
    merge_sort(left, mid);
    merge_sort(mid, right);
    merge(left, mid, right);
  }
}

static uint32_t partition(int32_t left, int32_t right)
{
  uint32_t index = left;
  for (int32_t i = left; i < right; i++) {
    if (array[i].second <= array[right].second) {
      swap(array[i], array[index]);
      index++;
    }
  }

  swap(array[index], array[right]);

  return index;
}

static void quick_sort(int32_t left, int32_t right)
{
  if (left < right) {
    int32_t mid = partition(left, right);
    quick_sort(left, mid - 1);
    quick_sort(mid + 1, right);
  }
}

int32_t main()
{
  uint32_t n;
  cin >> n;

  for (uint32_t i = 0; i < n; i++) {
    char c;
    uint32_t val;
    cin >> c >> val;
    array.push_back({c, val});
    array1.push_back({c, val});
  }

  merge_sort(0, array.size());
  quick_sort(0, array.size() - 1);

  bool stable = true;
  for (uint32_t i = 0; i < array.size(); i++) {
    if (array[i].first != array1[i].first) {
      stable = false;
    }
  }

  if (stable) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }

  for (uint32_t i = 0; i < array.size(); i++) {
    cout << array[i].first << " " << array[i].second << endl;
  }

  return 0;
}

Measured memory_bytes: 5656
#include<iostream>
using namespace std;
int main(){
  double d[1000]={0},max=0,min=100000;
  for(int i=0;cin>>d[i];i++){
    if(max<d[i])max=d[i];
    if(min>d[i])min=d[i];
  }
  cout<<max-min<<endl;
  return 0;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
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 long long INF = 1LL << 60;
const int inf = 1001001001;
 
template <typename T>
struct UnionFind {
   vector<T> par; 
 
   UnionFind(T N) : par(N) { 
        for(T i = 0; i < N; i++) par[i] = i;
   }
 
   int root(T x) { 
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
   }
 
   void unite(T x, T y) { 
       T rx = root(x); 
       T ry = root(y); 
       if (rx == ry) return; 
       par[rx] = ry; 
   }
 
   bool same(T x, T y) { 
       T rx = root(x);
       T ry = root(y);
       return rx == ry;
   }
};
 
int main(){

    int n,k;
    cin >> n >> k;
    vector<int> data(n);
    rep(i,n) cin >> data.at(i);
    cout << ((n-3+k)/(k-1)) << endl;
    


 
}

Measured memory_bytes: 768
import java.util.Scanner;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int h, w;
		while(true)
		{
			h = sc.nextInt();
			w = sc.nextInt();
			if(h == 0 && w == 0)
			{
				break;
			}
			for (int i = 0; i < h; i++)
			{
				for (int j = 0; j < w; j++)
				{
					if(i == 0 || j == 0 || i == h - 1 || j == w - 1)
					{
						System.out.print("#");
					}
					else
					{
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}
		sc.close();
	}
}


Measured memory_bytes: 37020
N,W=map(int,input().split())
VW=[tuple(map(int,input().split())) for _ in range(N)]

dp=[[0]*(W+1) for _ in range(N+1)]
for n in range(1,N+1):
    for m in range(1,W+1):
        if VW[n-1][1]>m:
            dp[n][m]=dp[n-1][m]
        else:
            dp[n][m]=max(dp[n-1][m],dp[n-1][m-VW[n-1][1]]+VW[n-1][0])
print(dp[-1][-1])


Measured memory_bytes: 25500
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
    cin >> c;
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
    
    return 0;
}

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

int main(void){

    int S; cin>>S;
    set<int> a;

    while(!a.count(S)){

        a.insert(S);
        if(S%2==0){
            S /= 2;
        }else{
            S = 3*S+1;
        }
    }

    cout<<a.size()+1<<endl;

    return 0;
}

Measured memory_bytes: 256