akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
	"strconv"
)

func main() {

	var strN string
	fmt.Scanf("%s", &strN)
	N, _ := strconv.Atoi(strN)

	cnt := 0
	for A := 1; A < N; A++ {
		for B := 1; B < N; B++ {
			if A*B >= N {
				break
			}
			C := N - (A * B)
			if (A*B)+C == N {
				cnt += 1
			}
		}
	}

	fmt.Println(cnt)
}


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

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

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m, p; cin >> n >> m >> p;
  vector<int> us(m), vs(m), ws(m);
  rep(i, m) {
    cin >> us[i] >> vs[i] >> ws[i]; us[i]--; vs[i]--; ws[i] -= p;
  }
  const ll inf = 1e18;
  vector<ll> dist(n, -inf);
  dist[0] = 0;
  rep(k, n*2) rep(i, m) if (dist[ us[i] ] != -inf) {
    if (dist[ vs[i] ] < dist[ us[i] ] + ws[i]) {
      if (k < n - 1) {
        dist[ vs[i] ] = dist[ us[i] ] + ws[i];
      } else {
        dist[ vs[i] ] = inf;
      }
    }
  }
  if (dist[n - 1] >= inf) {
    cout << -1 << endl;
  } else {
    cout << max(0LL, dist[n - 1]) << endl;
  }
}

Measured memory_bytes: 384
while 1:
	N = input()
	if N == 0: break
	M = [map(int,raw_input().split()) for i in range(N)]
	K = set(map(int,raw_input().split())[1:])
	c,id = 0,0
	for i in range(N):
		if set(M[i][1:]) >= K:
			c += 1
			id = i + 1
			if c > 1:
				break
	print id if c == 1 else -1

Measured memory_bytes: 4356
#include<bits/stdc++.h>
using namespace std;
const int N=505,dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int n,a[N][N],dp[N][N],x[N*N],y[N*N],qx[N*N],qy[N*N],v[N][N],ans;
void bfs(int bx,int by)
{
	dp[bx][by]--;
	int b=0,e=1;
	qx[0]=bx,qy[0]=by;
	while(b<e)
	{
		int kx=qx[b],ky=qy[b];
		b++;
		for(int i=0;i<4;i++)
		{
			int x=kx+dx[i],y=ky+dy[i];
			if(x<1||x>n||y<1||y>n||dp[x][y]<=dp[kx][ky]+v[x][y])
				continue;
			dp[x][y]=dp[kx][ky]+v[x][y];
			qx[e]=x,qy[e]=y;
			e++;
		}
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n*n;i++)
	{
		int p;
		scanf("%d",&p);
		x[i]=(p-1)/n+1;
		y[i]=(p-1)%n+1;
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			dp[i][j]=min(min(i,n-i+1),min(j,n-j+1)),v[i][j]=1;
	for(int i=1;i<=n*n;i++)
	{
		ans+=dp[x[i]][y[i]]-1;
		v[x[i]][y[i]]=0;
		bfs(x[i],y[i]);
	}
	printf("%d\n",ans);
	return 0;
}

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

#define ALL(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0, __##i##_length = (n); i < __##i##_length; i++)
#define rep_reverse(i, n) for (ll i = (n)-1; 0 < i; i--)
#define FOR(i, from, to)                                                       \
  for (ll i = (from), __##i##_end = (to); i < __##i##_end; i++)
#define FOR_REVERSE(i, from, to)                                               \
  for (ll i = (to)-1, __##i##_end = (from); __##i##_end <= i; i--)
#define foreach(e, v) for (const auto e : (v))
#define vfree(v) std::vector<int>().swap(v)
#define DEBUG(x) cout << #x << " = " << (x) << endl

using namespace std;
typedef int64_t ll;
typedef vector<ll> llv;
typedef vector<llv> llvv;

#define MOD (ll)1000000007

int main() {
  ll n;
  cin >> n;
  cout << (n + 1) / 2 << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int tic[] = {6000,4000,3000,2000};

int main(){
  for(int i = 0; i < 4; i++){
    int t,n;
    cin >> t >> n;
    cout << tic[t-1]*n << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int main()
{
int a;
cin>>a;
if(a<1200)
{
cout<<"ABC"<<endl;
}
else if(a<2800&&a>=1200)
{
cout<<"ARC"<<endl;
}
else
{
cout<<"AGC"<<endl;
}
system("pause");
return 0;
}
 

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
/*
long long GetDigit(long long num){
    return log10(num)+1;
}
*/

long long GetDigit(long long num){
    long long digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  
  for(int i = 0; i < s.size(); i++){
    if(((int)s.at(i) + n) > 90)
      cout << (char)(65 + (n - (91 - (int)s.at(i))));
    else
      cout << (char)((int)s.at(i) + n);
  }
  
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES




int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  //  freopen("input.txt","r",stdin);
  //  freopen("output.txt","w",stdout);
    long long int n;
    cin>>n;
    long long int ans =0;
    for(long long int i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            long long int k,m;
            k = i;
            m = (n/k) - 1;
            if(k<m)
                ans+=m;
        }
    }
    cout<<ans;
}

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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);

  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &h[i]);
  }
  // cout << h[1] << endl;

  bool r = true;

  for (int i = n - 2; i >= 1; i--) {
    if (h[i] > h[i + 1]) {
      if (h[i] == h[i + 1] + 1) {
        h[i]--;
      } else {
        r = false;
        break;
      }
    } else {
      // NOP
    }
  }

  cout << (r ? "Yes" : "No") << endl;
}


Measured memory_bytes: 640
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    s = IS()
    t = IS()
    cnt = 0
    for si,ti in zip(s,t):
        if si != ti:
            cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

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

int main() {
	int n;
	cin >> n;
	int arr[n];
	for(int i = 0; i < n; i++){
		cin >> arr[i];
	}
	
	int mx = 0;
	int count = 0;
	
	for(int i = 1; i < n; i++){
		if(arr[i] <= arr[i - 1]){
			count++;
		}
		else{
			mx = max(mx, count);
			count = 0;
		}
	}
	mx  = max(mx, count);
	cout << mx;
	return 0;
}

Measured memory_bytes: 640
#define i(a,b) a=a<b?a:b;
d,a[100][100],b[100][100],u=-1,v,c;
main(n)
{
	for(scanf("%d%*d",&n);++u<n;)for(v=0;v<n;)b[u][v++]=1<<28;
	for(;~scanf("%d%d%d",&u,&v,&c);a[--u][--v]=a[v][u]=b[u][v]=b[v][u]=c);
	for(u=0;u<n;u++)for(v=0;v<n;v++)for(c=0;c<n;c++)i(b[v][c],b[v][u]+b[u][c])
	for(u=-1;++u<n;)for(c=u;c<n;)a[u][c]>b[u][c++]?d++:0;
	printf("%d\n",d);
}


Measured memory_bytes: 256
/************************Code by Hardik Aggarwal!!!!***********************************/

#include<bits/stdc++.h>
using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const int maxn=200001;
ll t[4*maxn];
map< ll ,ll > m;
ll rm[maxn];
void build(ll id,ll l,ll r)
{
  if(l>r)
    return ;
  if(l==r)
    {
      t[id]=-mod*mod;
      
      return ;
    }

  ll mid=(l+r)>>1;

  build(2*id,l,mid);
  build(2*id+1,mid+1,r);
  t[id]=max(t[2*id],t[2*id+1]);


}
void update(ll id,ll l,ll r,ll k,ll val)
{
	if(k<l||k>r||l>r)
		return ;
	if(l==r&&l==k)
		{
			t[id]=val;
			return ;
		}

	ll mid=(l+r)>>1;

	update(2*id,l,mid,k,val);
	update(2*id+1,mid+1,r,k,val);
	t[id]=max(t[2*id],t[2*id+1]);


}
ll counter(ll id,ll l,ll r,ll lq,ll rq)
{
	if(l>r||l>rq||lq>r||lq>rq)
		return 0;
	if(lq<=l&&r<=rq)
		return t[id];
	ll mid=(l+r)>>1;

	return max(counter(2*id,l,mid,lq,rq),counter(2*id+1,mid+1,r,lq,rq));
}

int main()
{	
	
	IOS
	ll n;
	cin>>n;
	ll h[n+1],a[n+1];
	for(ll i=1;i<=n;i++)
		cin>>h[i];
	for(ll i=1;i<=n;i++)
		cin>>a[i];

	build(1,1,n);
	for(ll i=1;i<=n;i++)
	{
		ll val=counter(1,1,n,1,h[i]-1);
		update(1,1,n,h[i],val+a[i]);
	}

	ll ans=counter(1,1,n,1,n);
	cout<<ans<<endl;
}
    
 
    
    


Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
                    
                    
int main(){
    int k, s;
    cin >> k >> s;

    int ans = 0;

    for(int z = 0;z <= k;z++){
        for(int y = 0;y <= k;y++){
            int x = s - z - y;
            if(x >= 0 & x <= k){
                ans += 1;
            }
        }
    }    
    
    printf("%d",ans);
    printf("\n");
}

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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using pll = pair<ll, ll>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i, a, b) for(ll i=(a); i<(b); i++)
#define FORD(i, a, b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

ll n;

vl primes(1000007, true);

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);

    vl numbers = vl(1000007, 0);
    cin >> n;

    bool noPairwise = false;
    bool noSetwise = false;

    FOR(i, 0, n) {
        ll next; cin >> next;
        numbers[next]++;
    }

    FOR(i, 2, 1000007) {
        if(!primes[i]) continue;
        
        ll hits = 0;
        for(ll j = i; j < 1000007; j += i) {
            primes[j] = false;

            hits += numbers[j];
        }
        if(hits >= 2) noPairwise = true;
        if(hits >= n) {
            cout << "not coprime" << endl;
            return 0;
        }
    }

    if(noPairwise) {
        cout << "setwise coprime" << endl;
    } else {
        cout << "pairwise coprime" << endl;
    }
}

Measured memory_bytes: 18712
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 5005;
const int P = 1e9 + 7;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
int power(int x, int y) {
	if (y == 0) return 1;
	int tmp = power(x, y / 2);
	if (y % 2 == 0) return 1ll * tmp * tmp % P;
	else return 1ll * tmp * tmp % P * x % P;
}
int dp[MAXN][MAXN];
int main() {
	int n, m; read(n), read(m);
	for (int i = 1; i <= m; i++)
		dp[0][i] = 1;
	for (int i = 1; i <= n; i++) {
		int sum = 0;
		for (int j = 1; j <= m; j++) {
			update(dp[i][j], 1ll * dp[i - 1][j] * (j + 1) % P);
			update(dp[i][j], sum);
			sum = (2ll * sum + 1ll * dp[i - 1][j] * j) % P;
		}
	}
	cout << dp[n][m] << endl;
	return 0;
}


Measured memory_bytes: 101344
h, w, k = gets.split.map(&:to_i)

s = []
h.times {s << gets.chomp}

ans = h + w
(2 ** (h-1)).times do |n|
    sum = 0
    idx = Array.new(h, 0)
    (h-1).times do |j|
        sum += n[j]
        idx[j+1] = idx[j] + n[j]
    end

    c = true
    arr = Array.new(h, 0)

    w.times do |i|
        h.times {|j| arr[idx[j]] += s[j][i].to_i}

        if arr.any?{|e| e > k}
            if c
                sum = h + w
                break
            end

            arr.fill(0)
            sum += 1
            break if sum >= ans
            c = true
            redo
        end

        c = false
    end

    ans = sum if ans > sum
end

puts ans

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
const int maxn = 18;//, mod = 1e9 + 7;
int n, a[maxn];
map<pi, ll> dp[maxn][maxn];
ll f(ll l, ll r, ll xl, ll xr) {
	if(l>r) return 0;
	if(dp[l][r].count({xl, xr})) return dp[l][r][{xl, xr}];
	ll ans = 1ll<<60;
	for(int i = l; i <= r; i++) {
		ans = min(ans, f(l, i-1, xl, xl+xr) + f(i+1, r, xl+xr, xr) + (xl+xr)*a[i]);
	}
	return dp[l][r][{xl, xr}] = ans;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	cout << f(1, n-2, 1, 1)+a[0]+a[n-1];
}



Measured memory_bytes: 16512
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
using ll = long long;
using itn = int;
const ll MOD = 1000000007;

int main() {

    int n;
    cin >> n;

    if (n == 1) {
        cout << "Hello World" << endl;
    } else {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
    

}

Measured memory_bytes: 256
/*
Original problem: https://atcoder.jp/contests/abc136/tasks/abc136_b
Author: sammochen
*/

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)

#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef vector<ll> VLL;
typedef vector<int> VI;

const ll mod = 1e9+7;

namespace SOLVE {
    void main() {
    	// brute force
    	int n, ans = 0;
    	cin >> n;
    	REP(i, 1, n + 1) {
			if (to_string(i).length() % 2 == 1) {
				ans++;
			}
    	}
		cout << ans << endl;
    }
}


signed main() {
	int t;
	t = 1;
	// cin >> t;
	while (t--) {
		SOLVE::main();
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N ;
  vector<int> vec(N);
  for(int i = 0 ;i<N; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  int c = 1;
  
  for(int i = 0 ;i < N - 1; i++){
    if(vec.at(i) < vec.at(i+1)){
      c++;
  }
  }
  cout << c << endl;
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

A,B,K=get_i
if B-A<2*K
    A.upto(B) do|i|
        puts i
    end
else
  A.upto(A+K-1) do|i|
      puts i
  end
  (B-K+1).upto(B) do|i|
      puts i
  end
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  set<string> s;
  rep(i, n){
    string in;
    cin >> in;
    s.insert(in);
  }
  cout << s.size() << endl;
  return 0;
}

Measured memory_bytes: 19120
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

ll binpow(ll a, ll b) {
    if (b == 0)
    {
        return 1;
    }
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
    {
        return res * a;
    }
    return res;
}

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

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll a,b,n;
    cin>>a>>b>>n;
    if (b-1<=n)
        cout<<((a*(b-1))/b)-a*((b-1)/b);
    else
        cout<<((a*(n))/b)-a*((n)/b);
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	string s;
	cin>>s;
	if (s.length()==1){
		cout<<s<<endl;
		return 0;
	}
	int ch=9;
	int i;
	int num9=0;
	for (i=0;i<s.length();i++){
		if (s[i]=='9'){
			num9++;
		}
	}
	for (i=0;i<s.length();i++){
		if (s[i]>'0' && s[i]<'9'){
			if (i<s.length()-1){
				bool allIs9=true;
				for (int j=i+1;j<s.length();j++){
					if (s[j]!='9'){
						allIs9=false;
						break;
					}
				}
				if (allIs9){
					ch=s[i]-'0';
				}else{
					ch=s[i]-'0'-1;
				}
			}else{
				ch=s[i-1]-'0'-1;
			}
			break;
		}else if (s[i]=='0'){
			ch=s[i-1]-'0'-1;
			break;
		}
	}
	cout<<ch+9*(s.length()-1)<<endl;

	return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, K = LI()
    h = []
    for i in range(N):
        H = I()
        h.append(H)
    h = sorted(h)
    minGap = inf
    for i in range(N):
        st = i
        en = i + K - 1
        if en >= N:
            break
        minGap = min(minGap, h[en] - h[st])
    print(minGap)

main()



Measured memory_bytes: 10756
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    large_p = 10 ** 9 + 7
    n = int(input())
    r = 1
    for i1 in range(1, n + 1):
        r = (r * i1) % large_p

    print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9096
s=input()

alps="abcdefghijklmnopqrstuvwxyz"
if len(s)==26:
    if s=="zyxwvutsrqponmlkjihgfedcba":
        print(-1)
    else:
        dels=[]
        for i in range(26):
            dels.append(s[25-i])
            for del_i in dels:
                if s<s[:25-i]+del_i:
                    print(s[:25-i]+del_i)
                    exit()
else:
    for alp in alps:
        if s.count(alp)==0:
            print(s+alp)
            exit()


Measured memory_bytes: 9052
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 1000010
#define rep(i, a, b) for (long long i = a; i <= b; ++i)
#define mp make_pair
#define ll long long
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
ll n, m;

void dfs(string s, char ch) {
	if (s.length() == n) {
		cout << s << '\n';
		return;
	}
	for (char c = 'a'; c < ch; ++c) dfs(s + c, ch);
	dfs(s + ch, ch + 1);
}

int main() {
	io(); cin >> n;
	dfs("", 'a');
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
#define INF 0x3f //plus infinite

char a[102][102];

int main(){
  int h,w;
  cin >> h >> w;
  for(int i = 1;i <= h;i++){
    for(int j = 1;j <= w;j++){
      cin >> a[i][j];
    }
  }
  for(int i = 0;i <= h+1;i++){
    for(int j = 0;j <= w+1;j++){
      if(i == 0 || j == 0 || i == h+1 || j == w+1)
	cout << "#";
      else
	cout << a[i][j];
    }cout << endl;
  }
}

/*文字列の辞書順について
 *C++の順序では'0'～'9'→'A'～'Z'→'a'～'z'の順に
 *                       なっていることに注意しましょう。
 */

/*行単位での入力
 * getline(cin,文字列変数);
 */


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String in1 = sc.nextLine().trim();
		String in2 = sc.nextLine().trim();

		char[] inArray = in2.toCharArray();
		int len = in2.length() -1;
		StringBuffer revBuf = new StringBuffer();
		for (int i = len  ; i >= 0 ;i-- ) {
			revBuf.append(Character.toString(inArray[i]));
		}
		if (in1.equals(revBuf.toString())){
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 100005;

string s, t;

int nx[N][26];
int last[26];

int main() {

	FAST;

	cin >> s >> t;
	int l = s.length();
	for (int j = 0; j < 26; j ++) last[j] = -1;
	for (int j = 0; j < 26; j ++) nx[l][j] = -1;
	for (int i = l - 1; i >= 0; i --) {
		last[s[i] - 'a'] = i + 1;
		for (int j = 0; j < 26; j ++) {
			nx[i][j] = last[j];
		}
	}
	int rep = 0, idx = 0;
	for (int i = 0; i < t.length(); i ++) {
		if (nx[idx][t[i] - 'a'] != -1) {
			idx = nx[idx][t[i] - 'a'];
		}
		else {
			rep ++;
			idx = 0;
			if (nx[idx][t[i] - 'a'] != -1) {
				idx = nx[idx][t[i] - 'a'];
			}
			else {
				cout << -1 << '\n';
				return 0;
			}
		}
	}
	intt ans = 1LL * rep * l + idx;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 10704
#include<bits/stdc++.h>
using namespace std;
int main()
{
    typedef long long ll;
    ll a,b,k,l,m;
    cin>> a>> b>> k;
    if((a+b)<k)
    {
        cout<< "0 0"<< endl;
    }
    else if(k>=a)
    {
        l=k-a;
        m=b-l;
        cout<< "0 "<< m;
    }
    else
    {
        l= a-k;
        cout<< l<< " "<< b;
    }
}


Measured memory_bytes: 3624
#include<stdio.h>
int main(){
int a[100001],d,f,n,S,i;
long long e;
scanf("%d",&n);
for(i=0;i<n;i++){
	scanf("%d",&a[i]);
}
S=a[0];
for(i=1;i<n;i++)if(S>a[i]){
S=a[i];
}
d=a[0];
for(i=1;i<n;i++) if(d<a[i]) d=a[i];
e=0;
for(i=0;i<n;i++) e=e+a[i];
printf("%d %d %ld\n",S,d,e);
return 0;
}


Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); 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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  ll res = 1;
  for (ll i = 2; i*i <= n; i++) {
    ll tmp = i*i;
    while (tmp <= n) {
      chmax(res, tmp);
      tmp *= i;
    }
  }
  cout << res << endl;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  if(a % 2 == 0 || b % 2 == 0){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  return 0;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int x = 0;
    for (int j = a; j <= b; j++) {
        int k = c%j;
        if (k == 0) {
            x++;
        }
        else
            continue;
    }
    cout <<x<< endl;
    return 0;
}

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

using namespace std;

int d[15][15];
int f[105][105];

int main() {
   ios_base::sync_with_stdio(false);
   int na, nb;
   cin >> na >> nb;
   for (int i = 1; i <= na; ++i) {
      for (int j = 1; j <= nb; ++j) {
         cin >> d[i][j];
      }
   }
   for (int nx = 0; nx < 105; ++nx) {
      for (int ny = 0; ny < 105; ++ny) {
         for (int i = 1; i <= na; ++i) {
            for (int j = 1; j <= nb; ++j) {
               f[nx][ny] = max(f[nx][ny], d[i][j] - i * nx - j * ny);
            }
         }
      }
   }
   for (int i = 1; i <= na; ++i) {
      for (int j = 1; j <= nb; ++j) {
         bool found = false;
         for (int nx = 0; nx < 105; ++nx) {
            for (int ny = 0; ny < 105; ++ny) {
               if (f[nx][ny] + i * nx + j * ny == d[i][j]) {
                  found = true;
               }
            }
         }
         if (!found) {
            cout << "Impossible\n";
            return 0;
         }
      }
   }
   cout << "Possible\n";
   cout << 210 << " " << 11233 << "\n";
   for (int i = 0; i < 104; ++i) {
      cout << i + 1 << " " << i + 2 << " X\n";
      cout << i + 107 << " " << i + 106 << " Y\n";
   }
   for (int nx = 0; nx < 105; ++nx) {
      for (int ny = 0; ny < 105; ++ny) {
         cout << nx + 1 << " " << ny + 106 << " " << f[nx][ny] << "\n";
      }
   } 
   cout << 1 << " " << 106 << "\n";
}

Measured memory_bytes: 384
/*定义状态为：第i天选择第j件事所能获得的最大喜悦值
状态转移方程为：f[i][j]=max(f[i-1][k])+a[i][j],k枚举1~3天非j的*/
#include<bits/stdc++.h>
#define maxn 100001
using namespace std;
int f[maxn][4];
int main(){
	int n,t;
	cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=3;j++){
			cin>>t; 
			for(int k=1;k<=3;k++)
				if(k!=j) f[i][j]=max(f[i][j],f[i-1][k]+t);
		}
	for(int i=1;i<=2;i++)
		f[n][3]=max(f[n][3],f[n][i]);
	cout<<f[n][3];
	return 0;
}

Measured memory_bytes: 1792
N, M, X, Y = gets.split.map &:to_i
XS = gets.split.map &:to_i
YS = gets.split.map &:to_i

xmax = XS.max
ymin = YS.min

if xmax >= ymin
  puts "War"
else
  z = ymin
  if X < z && z <= Y
    puts "No War"
  else
    puts "War"
  end
end

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

int main()
{
  int K, T;
  cin >> K >> T;
  vector< pair<int, int> > a(T);
  vector<int> ans;

  for(int i = 0; i < T; i++) {
    int tmp;
    cin >> tmp;
    a[i] = make_pair(tmp, i);
  }
  int res = 0;
  //for(int i = 0; i < T; i++) cout << a[i].first << " " << a[i].second << endl;

  sort(a.rbegin(), a.rend());
  ans.push_back(a[0].second);
  a[0].first--;
  for(int i = 1; i < K; i++) {
    bool flag = false;
    for(int j = 0; j < T; j++) {
      if(ans[i-1] != a[j].second && a[j].first > 0) {
	ans.push_back(a[j].second);
	a[j].first--;
	flag = true;
	break;
      }
    }
    if(!flag) {res++; ans.push_back(ans[i-1]);}
    sort(a.rbegin(), a.rend());
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int N;

  cin >> N;

  int odd = (N+1) / 2;

  printf("%.10lf\n", (double)odd / N);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll A, B, g = 0, ans = 1;

int main() {
	cin >> A >> B;
	g = gcd(A, B);
	for (ll i = 2; i * i <= g; i++) {
		if (g % i)continue;
		ans++;
		while (g % i == 0)g /= i;
	}
	if (g != 1)ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
int a[51];
int ans;
int cmp(int x,int y)
{
	return x>y;
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=m;i++)
	ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <ctype.h>
#include <stdio.h>
int main(void){
    char str[1200];
    char alpha[26]="abcdefghijklmnopqrstuvwxyz";
    int num;
    int cnt[26]={0};
    int i=0;
    
    while(scanf("%c",&str[i]) != EOF){
        str[i] = tolower(str[i]);
        num = str[i] - 'a';
        cnt[num]++;
        i++;
    }
    
    for(i=0; i<26; i++){
        printf("%c : %d\n",alpha[i], cnt[i]);
    }
    
    return 0;
}

Measured memory_bytes: 544
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N,A,B;
  cin >> N >> A >> B;
  1 <= N <= 20;
  1 <= A <= 100;
  1 <= B <= 2000;
  
  int c = A * N;
  
  if(c >= B){
    cout << B << endl;
  }
  else{
    cout << c << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

const int mod = 1e9 + 7;
vector<long long int> fac;
long long int mypow(long long int a, long long int b) {
	if (b == 0) return 1;
	if (b == 1) return a;
	long long int res = mypow(a, b / 2);
	res = res * res % mod;
	if (b % 2 == 1) res = res * a % mod;
	return res;
}

long long int myc(long long int a, long long int b) {
	return fac[a] * mypow(fac[b], mod - 2) % mod * mypow(fac[a - b], mod - 2) % mod;
}

int f(int k, int n) {
	return fac[k + n - 1] * mypow(fac[k], mod - 2) % mod * mypow(fac[n - 1], mod - 2) % mod;
}

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

	fac = vector<long long int>(2 * n + 1, 1);
	for (int i = 1; i <= 2 * n; i++) {
		fac[i] = fac[i - 1] * i % mod;
	}
	if (k < n - 1) {
		long long int res = 0;
		for (int kk = 0; kk <= k; kk++) {
			res += myc(n, kk) * f(kk, n - kk) % mod;
			res %= mod;	
		}
		cout << res << endl;
		return 0;
	}
	cout << f(n, n) << endl;
}


Measured memory_bytes: 6348
n = int(input())
a = list(map(int, input().split()))

dp = [[0 for _ in range(1100)] for _ in range(110)]

last = a[-1]

dp[0][0] = 1

for i in range(n):
    for j in range(100):
        if i == 0:
            dp[i + 1][a[i]] = 1

        # +
        if 0 <= j + a[i] <= 20:
            dp[i + 1][j + a[i]] += dp[i][j]
        # -
        if 0 <= j - a[i] <= 20:
            dp[i + 1][j - a[i]] += dp[i][j]

print(dp[n - 1][last])


Measured memory_bytes: 6576
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <math.h>
#include <string>
#include <iomanip>
#include <locale>
#include <list>
#include <bitset>
#include <tuple>
using namespace std;
#define FORN(i,m,n) for(int i=(m); i<int(n); i++)
#define PRINTVEC(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PRINTMAT(m) FORN(j,0,m.size()) {PRINTVEC(m[j]);}
typedef long long ll;

int gcd(int a, int b){ return b ? gcd(b,a%b) : a; }

int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int n; cin>>n;
  ll ans = 0;
  n++;
  FORN(i,1,n) FORN(j,1,n) FORN(h,1,n) ans += gcd(gcd(i,j),h);
  cout<<ans<<endl;
}

Measured memory_bytes: 3192
#include <iostream>
#include <string>
using namespace std;
int main(){
	string str[]={"light fly", "fly", "bantam", "feather", "light", "light welter",
				   "welter", "light middle", "middle", "light heavy", "heavy"
	};
	int w[]={48,51,54,57,60,64,69,75,81,91};
	double a;
	while (cin>>a){
		int i=0;
		for (int j=0; j<10; j++){
			if (w[i]<a) i++;
			else break;
		}
		cout<<str[i]<<endl;
	}
}

Measured memory_bytes: 1232
// ABC153_E
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <cstring>  // std::memset
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> pll;
#define rep(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define rep1(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define repr(i, n) for (ll i=n-1; i >= 0; i++)  // n-1 ~ 0
#define all(vec) (vec).begin(), (vec).end()
#define sum(vec) accumulate(all(vec), 0LL)  // 0 は初期値
#define min_vec(vec) min_element(all(vec))  // iterator: * を先頭につける
#define max_vec(vec) max_element(all(vec))  // iterator: * を先頭につける
#define idx(vec, element_iter) distance((vec).begin(), element_iter)
const ll INF = 1LL<<60;  // 10^18（const int inf = 1<<29;）
const double PI = acos(-1);

template<class T> inline bool chmin(T& a, T b) {
    // chmin: change minimum
    // a より b の方が小さかったら，a の値を b の値に置き換える．
    // 書き換えた場合，true を返す
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    // input(sunippets: inpv, inpn, inps)
    ll H, N;
    cin >> H >> N;
    vector<pll> vec(N);
    rep(i, N) {
        cin >> vec[i].first >> vec[i].second;
    }
    
    // calculation
    ll Hmax = 10010;
    vector<ll> dp(Hmax, INF);
    
    for (ll i = 0; i <= Hmax; ++i) {
        for (ll j = 0; j < N; ++j) {
            if (i - vec[j].first <= 0) {
                chmin(dp[i], vec[j].second);
            } else {
                chmin(dp[i], dp[i - vec[j].first] + vec[j].second);
            }
        }
    }
    
    cout << dp[H] << "\n";
    
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

    ll n; cin >>n;
    vector<string> s(n); REP(i,n) cin >> s[i];
    for (ll i = 0; i < n; i++) {
        sort(s[i].begin(), s[i].end());
    }

    sort(s.begin(), s.end());

    ll res = 0;
    for (ll i = 0; i < (ll)s.size();) {
        ll j = i;
        while (j < (ll)s.size() && s[i] == s[j]) {
            j++;
        }
        res += (j-i)*(j-i-1)/2;
        i = j;
    }

    cout << res << endl;

    return 0;
}





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

#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
#define nrep(i,a,b) for(int i=int(a);i>=int(a);--i)
#define trv(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define watch(x) cout<<"\n"<<#x<<" is "<<x<<"\n"
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define ZERO(box) memset(box, 0, sizeof(box));
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define chkbit(s, b) (s & (1<<b))
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
const int mod=1e9+7;

int main(){
	int n,k;
	cin>>n>>k;
	vi h(n),dp(n);
	trv(i,0,n) cin>>h[i];
	dp[0]=0;
	trv(i,1,n){
		dp[i]=INT_MAX;
		trv(j,1,k+1){
			if(i-j>=0){
				dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
			}
		}
	}
	cout<<dp[n-1];
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;
using ll = long long;

int
main(void){
  int n;
  ll a, b;
  cin >> n >> a >> b;

  ll x[n];
  for(int i=0; i<n; i++) cin >> x[i];
  
  ll sum;
  sum = 0L;
  for(int i=0; i<n-1; i++){
    ll diff = x[i+1] - x[i];
    if( (diff * a) > b ){
      sum = sum + b;
    }else{
      sum = sum + (diff * a);
    }
    //cout << n << " "<< diff * a <<" " << b << " " << sum << endl;    
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1024
#![allow(unused)]

use proconio::input;
use proconio::marker::{Bytes, Chars, Usize1};
use std::cmp::{Reverse, min, max};
use itertools::Itertools;

#[proconio::fastout]
fn main() {
    input! {
        s: String,
    }

    println!("{}", &s[0..3]);
}


Measured memory_bytes: 2148
import bisect

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

a.sort()
b.sort()
c.sort()

ia = [bisect.bisect_left(a, bi) for bi in b]
sa = [0]
for i in range(n):
    sa.append(sa[-1])
    sa[-1] += ia[i]
ib = [bisect.bisect_left(b, ci) for ci in c]

ans = 0
for i in ib:
    ans += sa[i]
print(ans)

Measured memory_bytes: 111924
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;
constexpr double PI = 3.141592653589793;
constexpr ll INF = 1e18 + 10;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

using namespace std;
//    cout << setprecision(20) << ans << "\n";

vector<pair<ll, ll>> primeFactorize(ll N)
{
    vector<pair<ll, ll>> res;
    for (ll a = 2; a * a <= N; ++a)
    {
        if (N % a != 0)
            continue;
        ll ex = 0;

        while (N % a == 0)
        {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }

    if (N != 1)
        res.push_back({N, 1});
    return res;
}

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

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

    sort(a.begin(), a.end());
    int count = 0;
    for (const int &e : a)
    {
        x -= e;
        if (x < 0)
        {
            break;
        }
        count++;
    }
    if (x > 0)
    {
        count--;
    }
    cout << count << "\n";
    return 0;
}


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

ans="U"*(ty-sy)+"R"*(tx-sx)+"D"*(ty-sy)+"L"*(tx-sx)+"L"+"U"*(ty-sy+1)+"R"*(tx-sx+1)+"D"+"R"+"D"*(ty-sy+1)+"L"*(tx-sx+1)+"U"
print(ans)

Measured memory_bytes: 3060
//https://atcoder.jp/contests/agc004/tasks/agc004_b
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-2.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#endif
    ll N,x; cin>>N>>x;
    vector<ll> an(N);
    for(auto&& a:an){
        cin>>a;
    }
    
    ll ans=INT64_MAX;
    vector<ll> mincst(N, INT64_MAX);
    REP(t,N){ //移動回数で全探索
        ll sum=t*x; //移動cost
        REP(i,N){
            ll idx = i-t<0 ? i-t+N : i-t;
            mincst.at(i) = min(mincst.at(i), an.at(idx));
            sum += mincst.at(i);
        }
        ans = min(ans,sum);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
// binary search alg
// input sorted integer list S[] and search elements T[], output number of mutching S[] and T[]
#include<iostream>
bool binarysearch(int*,int,int);
int main(){
  int count=0, n, q;
  std::cin >> n;
  int S[n];
  for(int i=0; i<n; i++) std::cin >> S[i];
  std::cin >> q;
  int T[q];
  for(int i=0; i<q; i++) std::cin >> T[i];
  for(int i=0; i<q; i++) if(binarysearch(S,n,T[i])) count++;
  std::cout << count << std::endl;
  return 0;
}
bool binarysearch(int *A,int n,int key){
  int l=0, r=n, m;
  while(l<r){
    m = (l + r) / 2;
    if(A[m] == key) return true;
    else if(A[m] > key) r = m;
    else if(A[m] < key) l = m + 1;
  }
  return false;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
typedef long long l;
int main(){
    l a,b,x=1,z=0;
    cin>>a>>b;
    l c[b],d[b],y=0,vy=0;
    for(l i=0;i<b;i++){
        cin>>c[i]>>d[i];
        if(y<c[i]) y=c[i];
    }
    while(1){
        vy=y;
        y=0;
        for(l i=0;i<b;i++){
            if(vy>=d[i]){
                c[z]=c[i];
                d[z]=d[i];
                if(y<c[i]) y=c[i];
                z++;
            }
        }
        if(z) x++;
        else break;
        z=0;
    }
    cout<<x<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  cin >> s >> t;
  
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  
  if (s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long long LL;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL H, W, N;
	cin >> H >> W >> N;
	LL ans = 1e9;
	for (LL y = 0; y < H; y++) {
		LL temp = y;
		LL painted = W * y;
		LL left = (painted >= N ? 0 : N - painted);
		temp += ceil((ld)left / (H - y));
		ans = min(ans, temp);
	}
	ans = min(ans, H);
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int d;
vector<int> c(26);
vector<vector<int>> s(400, vector<int>(26));

int get_score(vector<int> t){
    int ans = 0;
    vector<int> last(26, 0);
    rep(i, d){
        ans += s[i][t[i]];
        rep(j, 26){
            if(t[i] == j)last[j] = i+1;
            ans -= c[j] * ((i+1)-last[j]);
        }
    }
    return ans;
}

int main() {
    cin >> d;
    rep(i, 26)cin >> c[i];
    rep(i, d)rep(j, 26)cin >> s[i][j];
    //-----code------// 
    vector<int> t(d, 0);
    int m;
    cin >> m;
    clock_t now = clock();
    while(now < 1950000){
        int D = rand() % d, q = rand() % 26;
        int old = t[D], olds = get_score(t);
        t[D] = q;
        if(get_score(t) < olds)t[D] = old;
        now = clock();
    }
    rep(i, d)cout << t[i]+1 << endl;
}


Measured memory_bytes: 3712
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

// water, sugar
bool dp[3010][3010];

signed main() {
    int A, B, C, D, E, F; cin >> A >> B >> C >> D >> E >> F;
    dp[0][0] = true;

    repq(i,0,F) repq(j,0,F-i) {
        if(i - 100 * A >= 0) dp[i][j] |= dp[i-100*A][j];
        if(i - 100 * B >= 0) dp[i][j] |= dp[i-100*B][j];
        if(j-C >= 0) dp[i][j] |= dp[i][j-C];
        if(j-D >= 0) dp[i][j] |= dp[i][j-D];

        // if(dp[i][j] == 1) printf("dp[%lld][%lld] = %d\n", i, j, dp[i][j]);
    }

    int reca = 0, recb = 1;
    int X = 0, Y = 0;
    repq(i,0,F) repq(j,0,F-i) {
        if(E * i < 100 * j || !dp[i][j]) continue;

        if(reca * (i+j) <= (100*j) * recb) {
            reca = 100 * j, recb = i + j;
            X = i+j, Y = j;
        }
    }
    printf("%lld %lld\n", X, Y);
    return 0;
}

Measured memory_bytes: 8704
# -*- coding: utf-8 -*-
import sys
# リストの準備
daylist = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
# 文字列の入力
s = input()
# indexの検索
if s in daylist:
    a = daylist.index(s)
    print(7 - a)
else:
    print("{} is not day of week".format(s))




Measured memory_bytes: 2940