akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

const int dx[]={-1,0,1,-1,1,-1,0,1};
const int dy[]={-1,-1,-1,0,0,1,1,1};

int H,W;
char fld[50][50];
void solve(){
    rep(i,H)cin>>fld[i];
    map<string,int>M;
    rep(i,H)rep(j,W)rep(d,8){
        int y=i,x=j;
        string hoge;
        do{
            hoge.pb(fld[y][x]);
            if(hoge.size()>1)M[hoge]++;
            y=(y+dy[d]+H)%H;
            x=(x+dx[d]+W)%W;
        }while(x!=j||y!=i);
    }
    string ans;
    each(it,M){
        if(it->se<=1)continue;
        if(ans.size()<it->fi.size())ans=it->fi;
        else if(ans.size()==it->fi.size())chmin(ans,it->fi);
    }
    if(ans=="")cout<<0<<endl;
    else cout<<ans<<endl;
}

signed main(){
    while(cin>>H>>W,H||W)solve();
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for(int i=0; i<N; i++){
    cin >> S.at(i);
  }

  int AC=0;
  int WA=0;
  int TLE=0;
  int RE=0;

  for(int i=0; i<N; i++){
    if(S.at(i)=="AC"){
      AC++;
    }
    else if(S.at(i)=="WA"){
      WA++;
    }
    else if(S.at(i)=="TLE"){
      TLE++;
    }
    else if(S.at(i)=="RE"){
      RE++;
    }
  }

  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;

return 0;
}


Measured memory_bytes: 6420
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpll vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
#define modA(cccc,bbbb ,p) (((cccc+bbbb)%p+p)%p)
#define modS(cccc,bbbb ,p) (((cccc-bbbb)%p+p)%p)
#define modM(cccc,bbbb ,p) ((((cccc%p)*(bbbb%p))%p+p)%p)

long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

/*lld fac[100001]; 

void getfac(lld p)
{
    fac[0] = 1; 
    for (lld i=1 ; i<=100000; i++) 
        fac[i] = fac[i-1]*i%p; 
}    

long long int nCrmodp(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}*/


lld p1=1e9 + 7,p2=998244353;
lld l,r,mid,ans;
lld n,i,j,k,g,m;
lld x,y,n1,n2,h,z,c;
lld aa=1;


void solve()
{
    cin>>x>>n;
    vector<lld> v(102);
    for(i=0;i<n;i++)
    {
        cin>>l;

        
        v[l]=1;
    }
    ans=0;
    for(i=0;i<102;i++)
    {
        if(v[i]==0)
        {
            if(abs(ans-x) > abs(i-x))
            {
                ans=i;
            }
            
        }
    }
    cout<<ans;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
    //cin>>t;
    //cout<<t;
   //  getfac(p2);
    //check the value by which modulo is to be taken
    lld ans=0;
    for(int i=0;i<t;i++)
    {
   //     cout<<"Case #"<<i+1<<": ";
                  solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3660
from fractions import gcd
A, B, C, D = map(int, input().split())
ans = B - A + 1
ans -= (B // C - (A - 1) // C)
ans -= (B // D - (A - 1) // D)
x = C * D // gcd(C, D)
ans += (B // x - (A - 1) // x)
print(ans)

Measured memory_bytes: 5344
import math

N,M = list(map(int,input().split()))
sc = [list(map(int,input().split())) for i in range(M)]
if N == 1:
    for i in range(10):
        for s,c in sc:
            if str(i)[s-1] != str(c):
                break
        else:
            print(i)
            break
    else:
        print(-1)
elif N == 2:
    for i in range(10,100):
        for s,c in sc:
            if str(i)[s-1] != str(c):
                break
        else:
            print(i)
            break
    else:
        print(-1)
else:
    for i in range(100,1000):
        for s,c in sc:
            if str(i)[s-1] != str(c):
                break
        else:
            print(i)
            break
    else:
        print(-1)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
using namespace std;

const int MX = 1000001;
int n, x;
bool tbl[MX], sieve[MX];
int v[30];

void makeSieve() {
    memset(sieve, false, sizeof sieve);
    sieve[0] = sieve[1] = true;
    for (int i=2; i*i<MX; ++i) {
        if ( ! sieve[i]) {
            for (int j=i*i; j<MX; j+=i) {
                sieve[j] = true;
            }
        }
    }
}

int main() {
    makeSieve();
    while (cin >> n >> x, n) {
        for (int i=0; i<n; ++i) {
            cin >> v[i];
        }
        for (int i=0; i<=x; ++i) {
            tbl[i] = false;
        }
        tbl[0] = true;
        for (int i=0; i<n; ++i) {
            for (int j=v[i]; j<=x; ++j) {
                tbl[j] |= tbl[j-v[i]];
            }
        }
        int ans = -1;
        for (int i=x; i>=0; --i) {
            if (tbl[i] && ! sieve[i]) {
                ans = i;
                break;
            }
        }
        if (0 < ans) {
            cout << ans << endl;
        } else {
            cout << "NA" << endl;
        }
    }
    return 0;
}

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

cnt = 0
ALL = set()
for a in A:
    c = a//400
    if c >= 8:
        cnt+= 1
    else:
        ALL.add(c)

if len(ALL) == 0:
    print(1,cnt)
else:
    print(len(ALL),len(ALL)+cnt)


Measured memory_bytes: 2940
use proconio::input;
use proconio::marker::Chars;

fn main() {
	input! {
		s: Chars,
	}
	println!(
		"{}",
		if s[2] == s[3] && s[4] == s[5] {
			"Yes"
		} else {
			"No"
		}
	);
}


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

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

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    let mut v2 = Vec::new();
    for _ in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        let v = s.trim().split_whitespace()
            .map(|e| e.parse().ok().unwrap()).collect();
        v2.push(v);
    }
    v2
}


fn a174() {
    let x : isize = read();
    if x >= 30 { println!("{}", "Yes")} else { println!("{}","No")}

}

fn b174(){

    let data1:Vec<u32> = read_vec();
    let n = data1[0];
    let d = data1[1];

    let data2:Vec<Vec<i64>> = read_vec2(n);

    println!("{}",
    data2.iter()
        .map(|p| ((p[0]*p[0] +p[1]*p[1]) as f64).sqrt() )
        .filter(|l| l <= &(d as f64))
        .count()
    );

}
fn main() {
    b174();


}

Measured memory_bytes: 12916
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
using namespace std;

int main(void) {
	int N, M, i, j, k, l, count = 0, flag = 0;
	cin >> N >> M;
	vector<vector<char>> NN(N, vector<char>(N));
	vector<vector<char>> MM(M, vector<char>(M));

	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++)
			cin >> NN[i][j];
	}
	for (i = 0; i < M; i++) {
		for (j = 0; j < M; j++)
			cin >> MM[i][j];
	}

	for (i = 0; i < N+1-M; i++){
		for (j = 0; j < N + 1 - M; j++) {
			count = 0;
			if (NN[i][j] == MM[0][0]) {
				for (k = 0; k < M; k++) {
					for (l = 0; l < M; l++) {
						if (NN[k+i][l+j] == MM[k][l]) {
							count++;
						}
					}
				}
			}
			if (count == M*M) {
				cout << "Yes" << endl;
				flag = 1;
				break;
			}
		}
		if (flag==1)break;
	}
	if (flag == 0)cout << "No" << endl;
	return 0;
}

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

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

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

    for(int i=0;i<n-1;i++) cout << r[i] << " ";
    cout << r[n-1] << endl;

    for(int i=1;i<=n-1;i++){
        int v = r[i];
        int j = i-1;
        while(j>=0 && r[j]>v){
            r[j+1] = r[j];
            j--;
        }
        r[j+1] = v;
        for(int i=0;i<n-1;i++) cout << r[i] << " ";
        cout << r[n-1] << endl;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define out(a) cout<<fixed<<setprecision((a))


int main(){
	
	ll N;
	cin >> N;
	vector<ll> p(N);
	FOR(i,0,N)cin>>p[i];
	bool ok = true;
	FOR(i,0,N-1)if(p[i]>p[i+1])ok = false;
	if(ok){
		cout << "YES" << endl;
		return 0;
	}
	FOR(i,0,N){
		FOR(j,i+1,N){
			ll k = p[i];
			p[i] = p[j];
			p[j] = k;
			ok = true;
			FOR(l,0,N-1)if(p[l]>p[l+1])ok = false;
			if(ok){
				cout << "YES" << endl;
				return 0;
			}
			k = p[i];
			p[i] = p[j];
			p[j] = k;
		}
	}
	cout << "NO" << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

l=ii()
print((l/3)**3)







Measured memory_bytes: 65388
#include <stdio.h>

int main()
{
  int num;
  int tmp;
  int flag = 0;
  int i;
  
  scanf("%d", &num);
  
  for (i = 0; i < num; i++) {
    scanf("%d", &tmp);
    if (tmp % 2 == 0) {
      if (!(tmp % 3 == 0 || tmp % 5 == 0)) {
        flag = 1;
      }
    }
  }
  
  if (flag) {
    printf("DENIED");
  } else {
  	printf("APPROVED");
  }
  
  return 0;
}
  


Measured memory_bytes: 1732
#D
from queue import Queue

N,M=map(int,input().split())
Friend=[[] for i in range(N+1)]

for i in range(M):
    a,b=map(int,input().split())
    Friend[a].append(b)
    Friend[b].append(a)
    

Flag=[False for i in range(N+1)]
ans=1

for i in range(1,N+1):
    if Flag[i]:
        continue
    q=Queue()
    q.put(i)
    cnt=1
    while not q.empty():
        st=q.get()
        Flag[st]=True
        for j in Friend[st]:
            if Flag[j]:
                continue
            cnt+=1
            Flag[j]=True
            q.put(j)
            
        ans=max(ans,cnt)
print(ans)

Measured memory_bytes: 123824
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a[ohara],b[ohara],c,d[ohara],tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
bool fl;
struct edge{ll to,cost;};
vector<edge> g[ohara];
pair<ll,ll> p[ohara];
pair<ll,ll> pp[ohara];
map<pair<ll,ll>,ll> mp;

//-------------------------↓↓↓↓↓↓------------------------

void dijkstra(ll s){
    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>>que;
    fill(d,d+n,LINF);
    d[s]=0;
    que.push(pair<ll,ll>(0LL,s));
    while(!que.empty()){
        pair<ll,ll> pp=que.top();que.pop();
        ll v=pp.second;
        if(d[v]<pp.first)continue;
        rep(i,Size(g[v])){
            edge e=g[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(pair<ll,ll>(d[e.to],e.to));
            }
        }
    }
}

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

    cin>>n;
    rep(i,n)cin>>a[i];
    rep(i,n)p[i]=make_pair(a[i],i);
    rep(i,n)cin>>b[i];
    rep(i,n)pp[i]=make_pair(b[i],i);
    sort(p,p+n);
    sort(pp,pp+n);
    rep(i,n-1){
        //pos=min(abs(p[i].first-p[i+1].first),abs(pp[i].first-pp[i+1].first));
        if(mp[{p[i].second,p[i+1].second}]!=0)mp[{p[i].second,p[i+1].second}]=min(abs(p[i].first-p[i+1].first),mp[{p[i].second,p[i+1].second}]),mp[{p[i+1].second,p[i].second}]=mp[{p[i].second,p[i+1].second}];
        else mp[{p[i].second,p[i+1].second}]=abs(p[i].first-p[i+1].first),mp[{p[i+1].second,p[i].second}]=mp[{p[i].second,p[i+1].second}];
        if(mp[{pp[i].second,pp[i+1].second}]!=0)mp[{pp[i].second,pp[i+1].second}]=min(abs(pp[i].first-pp[i+1].first),mp[{pp[i].second,pp[i+1].second}]),mp[{pp[i+1].second,pp[i].second}]=mp[{pp[i].second,pp[i+1].second}];
        else mp[{pp[i].second,pp[i+1].second}]=abs(pp[i].first-pp[i+1].first),mp[{pp[i+1].second,pp[i].second}]=mp[{pp[i].second,pp[i+1].second}];
    }
    rep(i,n-1){
        pos=mp[{p[i].second,p[i+1].second}];
        g[p[i].second].push_back({p[i+1].second,pos});
        g[p[i+1].second].push_back({p[i].second,pos});
    }
    rep(i,n-1){
        pos=mp[{pp[i].second,pp[i+1].second}];
        g[pp[i].second].push_back({pp[i+1].second,pos});
        g[pp[i+1].second].push_back({pp[i].second,pos});
    }
    dijkstra(0);
    rep(i,n){
        Cout(d[i]);
    }
    return 0;
}



Measured memory_bytes: 66944
import java.util.*;

public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int max = 0;
		int sum = 0;
		for(int i = 0; i < 3; i++) {
			int x = sc.nextInt();
			max = Math.max(max, x);
			sum += x;
		}
		System.out.println(sum - max);
	}
}

Measured memory_bytes: 23892
from collections import Counter
import sys
n=int(input())
lst=[]
for i in range(n):
  X,Y=map(int,input().split())
  lst.append([X,Y])
lst_2=sorted(lst,key=lambda x: x[0])
lst_3=sorted(lst,key=lambda x: x[1])
z=[]
if n==1:
  print(1)
  sys.exit()
else:
  for j in range(n):
    for k in range(j+1,n):
      z.append((lst_2[j][0]-lst_2[k][0],lst_2[j][1]-lst_2[k][1]))
u=[]
if n==1:
  print(1)
  sys.exit()
else:
  for j in range(n):
    for k in range(j+1,n):
      u.append((lst_3[j][0]-lst_3[k][0],lst_3[j][1]-lst_3[k][1]))
Z=Counter(z)
U=Counter(u)
m=max(Z.most_common()[0][1],U.most_common()[0][1])
print(n-m)


    
    
    


Measured memory_bytes: 3820
import {stdin} from 'process';
let input = "";
stdin.on('data', x => {input += x});
stdin.on('end', () => {
    let [a, b] = input.split(' ')
        .map(x=>x.trim()).map(x=>parseInt(x));
    if (8 < a || 8 < b) {
        console.log(':(');
    }
    else {
        console.log('Yay!');
    }
});

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

    using namespace std;

    const int MOD=1e9+7;
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        int n,k;
        cin>>n>>k;
        vector<int>a(n);
        for(int i=0;i<n;i++)
            cin>>a[i];
        vector<int>dp(k+1);
        for(int i=1;i<=k;i++){
            for(int j=0;j<n;j++){
                if(a[j]>i)
                    continue;
                if(dp[i-a[j]]==0)
                    dp[i]=1;
            }
        }
        if(dp[k])
            cout<<"First";
        else
            cout<<"Second";
        return 0;
    }


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn = 1e3 + 7;
ll n,a[maxn],dp[100][maxn][20],ans;
ll f(ll ans , int x, int y){
    ll  s = ans / x;
    return ans - s * x + s * y;
}
int main(){
    scanf("%lld",&n);
    ans=1000;
    for(int i = 1; i <= n; i ++){
        scanf("%lld",&a[i]);
    }
    ll mi = a[1];
    for(int i = 2; i <= n; i++){
        if(a[i] > mi){
          ans = f(ans,mi,a[i]);
          mi = a[i];
        }
        else mi=a[i];
    }
    printf ("%lld\n",ans);

   

}

Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod
#define AddMult(x, y, z) x = (x + (y) * (z)) % mod



signed main(){

    int N; cin >> N;
    string S; cin >> S;
    vec cnt(26, 0);
    REP(i, N) cnt[S[i] - 'a']++;
    int ans = 1;
    REP(i, 26) Mult(ans, cnt[i] + 1);
    ans = (ans - 1 + mod) % mod;
    cout << ans << endl;

    return 0;
}


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

using namespace std;

//#define MD 100010

int main(){
    long int a,b,c,x,y,ans=0;
    cin>>a>>b>>c>>x>>y;
    if(c>=a && c>=b){
        ans+=(a*x);
        ans+=(b*y);
    }else{
        if(min(x,y)==x){
            long int tmp1=(2*c*x+(y-x)*b);
            long int tmp2=(2*c*y);
            long int tmp3=(a*x+b*y);
            ans=min(tmp1,min(tmp2,tmp3));
        }else{
            long int tmp1=(2*c*y+(x-y)*a);
            long int tmp2=(2*c*x);
            long int tmp3=(a*x+b*y);
            ans=min(tmp1,min(tmp2,tmp3));
        }
    }
    
    /*else if(c<a && c<b){
        if(min(a,b)==a){
            ans+=(2*y*c);
        }else{
            ans+=(2*x*c);
        }*/
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

//Girls' Party
public class Main{

	int N, res, NB, NG;
	Set<String>[] v;
	
	void dfs(int nb, int ng, int z, String s){
//		System.out.println(s);
		if(nb<=res)return;
		if(ng==0){
			res = nb; return;
		}
		if(v[z].contains(s))return;
		v[z].add(s);
		int n = s.length(), d = (N-1)%n;
		if(s.charAt(d)=='B'){
			dfs(nb-1, ng, z, s.substring(d+1)+s.substring(0, d));
		}
		else{
			dfs(nb, ng-1, z, s.substring(d+1)+s.substring(0, d));
		}
		if(z==1)return;
		d = N%n;
		if(s.charAt(d)=='B'){
			dfs(nb-1, ng, 1, s.substring(d+1)+s.substring(0, d));
		}
		else{
			dfs(nb, ng-1, 1, s.substring(d+1)+s.substring(0, d));
		}
	}
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		while(T--!=0){
			N = sc.nextInt();
			String s = sc.next();
			v = new Set[2];
			v[0] = new HashSet<String>(); v[1] = new HashSet<String>();
			res = 0;
			NB = NG = 0;
			for(char c:s.toCharArray())
				if(c=='B')NB++; 
				else NG++;
			dfs(NB, NG, 0, s);
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e2+5;
const int INF = 0x3f3f3f3f;

int main( )
{
    std::ios::sync_with_stdio(0);cin.tie(0); 
	
	double n;
	cin >> n;
	n /= 3.0;
	printf("%.8f",(n*n*n));
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;


struct S {
	int i;
	int j;
	int s;
};


constexpr int64_t kRem = 998244353;


template<int64_t M = 1000000007>
class ModInt {
public:
	ModInt() : val_(0) {};

	ModInt(int64_t val) {
		this->val_ = val;
		this->val_ %= M;
		while (this->val_ >= M) this->val_ -= M;
	}

	operator int64_t() const {
		return this->val_;
	}

	ModInt& operator += (int64_t val) {
		this->val_ += val;
		this->val_ %= M;
		if (this->val_ >= M) this->val_ -= M;

		return *this;
	}

	ModInt& operator -= (int64_t val) {
		this->val_ -= val;
		this->val_ %= M;
		if (this->val_ < 0) this->val_ += M;

		return *this;
	}

	ModInt& operator *= (int64_t val) {
		this->val_ *= val;
		this->val_ %= M;

		return *this;
	}

	ModInt& operator /= (int64_t val) {
		ModInt v = ModInt(val).pow(M - 2);
		*this *= v;

		return *this;
	}

	ModInt operator + (int64_t v) const {
		ModInt ret = *this;
		return (ret += v);
	}

	ModInt operator - (int64_t v) const {
		ModInt ret = *this;
		return (ret -= v);
	}

	ModInt operator * (int64_t v) const {
		ModInt ret = *this;
		return (ret *= v);
	}

	ModInt operator / (int64_t v) const {
		ModInt ret = *this;
		return (ret /= v);
	}

	ModInt pow(int64_t m) const {
		if (m == 0) {
			ModInt ret(1);
			return ret;
		}
		if (m == 1) {
			ModInt ret(*this);
			return ret;
		}

		ModInt v = this->pow(m / 2);
		ModInt ret = v * v;
		if (m & 1) {
			ret *= (*this);
		}
		return ret;
	}

	ostream& operator << (ostream & out) {
		out << this->val_;
		return out;
	}

private:
	int64_t val_;
};

ModInt<kRem> dp[3001][3001][3] = {};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n, s; cin >> n >> s;
	vector<int> as(n); for (auto& a : as) cin >> a;
	dp[0][0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= s; j++) {
			(dp[i + 1][j][0] += dp[i][j][0]);
			(dp[i + 1][j][1] += dp[i][j][0] + dp[i][j][1]);
			(dp[i + 1][j][2] += dp[i][j][0] + dp[i][j][1] + dp[i][j][2]);
			if (j + as[i] <= s) {
				(dp[i + 1][j + as[i]][1] += dp[i][j][0] + dp[i][j][1]);
				(dp[i + 1][j + as[i]][2] += dp[i][j][0] + dp[i][j][1]);
			}
		}
	}

	cout << dp[n][s][2] << endl;

	return 0;
}

Measured memory_bytes: 211328
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb2l(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;

#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
#define  mat vector<vector<ll>>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

bool isp(string &s,ll i,ll j){
    ll f=1;
    while(i<=j && f){
        if(s[i]!=s[j])
        f=0;
        i++,j--;
    }
    return f;
}
void solve(){
    
  string s;
  cin>>s;
  ll i=0,n=s.size();
ll m=n/2,f=0;
  if(isp(s,i,m-1) && isp(s,m+1,n-1) && isp(s,0,n-1))
  f=1;
  if(f)
  cout<<"Yes";
  else cout<<"No";
  }
int main(){
    ll t=1;
   // cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Long> a = new ArrayList<>();
        List<Long> b = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            a.add(sc.nextLong());
            b.add(sc.nextLong());
        }

        long cnt = 0;
        for (int i = n - 1; i >= 0; i--) {
            long aIndex = a.get(i) + cnt;
            if(aIndex % b.get(i) == 0){
                continue;
            }
            cnt += b.get(i) - aIndex % b.get(i);
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 96608
from collections import Counter

N = int(input())

S = [input() for _ in range(N)]

c = Counter(S[0])

for i in range(1,N):
    c_tmp = Counter(S[i])
    for k in c.keys():
        if k in c and k in c_tmp:
            c[k] = min(c[k], c_tmp[k])
        else:
            c[k] = 0

ans = ""
for k in c:
    ans += k*c[k]

ans = list(ans)
ans.sort()
print("".join(ans))


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

// # DEFINES # //
#define ll long long
#define M (ll)1e9+7
#define EPS 1e-9

using namespace std;

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

    int a, b;

    cin >> a >> b;

    if(a >= 13)
        cout << b << endl;
    else if(a >= 6 && a <= 12)
        cout << b/2 << endl;
    else 
        cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int, input().split()))
    l1 = [0] * (max(a) + 3)
    for ea in a:
        l1[ea] += 1
        l1[ea+1] += 1
        l1[ea+2] += 1
    print(max(l1))

if __name__ == '__main__':
    main()

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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
  int n, k;
  cin >> n >> k;
  map<int, int> mp;
  for (int i = 1; i <= n; i++)
  {
    int tmp;
    cin >> tmp;
    mp[i] = tmp;
  }
  pair<int, int> idx[200100] = {};
  int cnt = 0;
  int next = 1;
  while (!idx[next].first)
  {
    // cout << next << "," << idx[next] << endl;
    cnt++;
    idx[next] = make_pair(mp[next], cnt);
    next = mp[next];
  }
  cnt++;
  // cout << cnt << endl;
  // cout << "next" << next << endl;
  int idx__ = idx[next].second;
  // cout << "idx::" << idx__ << endl;
  int current;
  if (k < cnt)
    current = 1;
  else
  {
    k = (k - idx__) % (cnt - idx__);
    current = mp[next];
  }
  // cout << "current" << current << endl;
  // cout << "k" << k << ":" << cnt - idx__ << endl;

  for (int i = 0; i < k; i++)
  {
    current = mp[current];
  }
  cout << current << endl;
}


Measured memory_bytes: 19260
//パリティに注目する
#include<iostream>
#include<algorithm>
using namespace std;

int main(void){
    int N;
    cin >> N;
    int t[110000];
    int x[110000];
    int y[110000];
    //first index always 0!
    t[0] = x[0] = y[0] = 0;
    for(int i = 0; i < N; i++) cin >> t[i+1] >> x[i+1] >> y[i+1];

    bool ans = true;
    for(int i = 0; i < N; i++){
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        int dt = t[i+1] - t[i];
        if(dist > dt) ans = false;
        if(dist % 2 != dt % 2) ans = false;
    }

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;




}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<set>
using namespace std;
int main()
{
	int num, new_n, sum = 0;
	set<int> score;
	cin >> num;
	for (int i = 0; i < num; i++) {
		cin >> new_n;
		if (score.end() == score.find(new_n)) {
			score.insert(new_n);
			continue;
		}
		score.erase(new_n);
	}
	cout << score.size();
}

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

using namespace std;

int main(void){
    string vowel = "aeiou";
    char c;
    cin >> c;
    for(int i = 0; i < vowel.length(); i++){
        if(vowel[i] == c){
            cout << "vowel" << endl;
            return 0;
        }
    }
    cout << "consonant" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	static long mod = 1000000007;
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		long N = scn.nextLong();
		long M = scn.nextLong();
		if(N-M >1 || N-M < -1) {
			System.out.println(0);
		}else {
			long ans = 1;
			ans*=nyan(N);
				ans%=mod;
				ans*=nyan(M);
				ans%=mod;
			if(N==M) {
				ans*=2;
				ans%=mod;
			}
			System.out.println(ans);
		}
	}

	public static long nyan(long n) {
		long ans = 1;
		for(int i = 1; i <= n;i++) {
			ans *= i;
			ans %=mod;
		}
		return ans;
	}
}


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

using ll = long long;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string S; cin >> S;
	int N = int(S.size());
	ll K; cin >> K;

	if (S == string(N, S[0])) {
		cout << (N * K) / 2 << '\n';
	} else {
		int prefLen = 0;
		for (int i = 0; S[i] == S[0]; i++) {
			prefLen ++;
		}
		int suffLen = 0;
		for (int i = N-1; S[i] == S[N-1]; i--) {
			suffLen ++;
		}
		int midVal = 0;
		for (int i = prefLen+1; i < N-suffLen; i++) {
			if (S[i] == S[i-1]) {
				midVal++;
				i++; // extra ++ to skip the next
			}
		}

		ll ans = midVal * K + (prefLen / 2) + (suffLen / 2) + (S[0] == S[N-1] ? (prefLen + suffLen) / 2 : prefLen/2 + suffLen / 2) * (K-1);
		cout << ans << '\n';
	}

	return 0;
}


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

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int H = sc.nextInt();
		int W = sc.nextInt();
		int[] left = new int[H];
		int[] right = new int[H];
		Arrays.fill(left, -1);
		Arrays.fill(right, -1);
		for (int i = 0; i < H; i++) {
			char[] row = sc.next().toCharArray();
			for (int j = 0; j < W; j++) {
				if (row[j] == 'B') {
					if (left[i] == -1) left[i] = j;
					right[i] = j;
				}
			}
		}
		int ans = 0;
		for (int i = 0; i < H; i++) {
			if (left[i] == -1) continue;
			for (int j = i; j < H; j++) {
				if (left[j] == -1) continue;
				ans = Math.max(ans, j - i + Math.abs(left[i] - right[j]));
				ans = Math.max(ans, j - i + Math.abs(right[i] - left[j]));
			}
		}
		System.out.println(ans);
	}

}



Measured memory_bytes: 38716
from heapq import heappush, heappop
s=set()
q=[]
x, y, z, k = map(int, input().split())
a=sorted(list(map(int, input().split())), reverse=True)
b=sorted(list(map(int, input().split())), reverse=True)
c=sorted(list(map(int, input().split())), reverse=True)
heappush(q, (-(a[0]+b[0]+c[0]), 0, 0, 0))
def push(d, e, f):
    if (d, e, f) not in s and 0<=d<x and 0<=e<y and 0<=f<z:
        heappush(q, (-(a[d]+b[e]+c[f]), d, e, f))
        s.add((d, e, f))
for i in range(k):
    p, d, e, f =heappop(q)
    print(-p)
    push(d+1, e, f)
    push(d, e+1, f)
    push(d, e, f+1)
        

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

using namespace std;
typedef long long ll;
int main()
{
    cin.tie(0);
    cin.sync_with_stdio(0);

    ll a,b,c,d,ans=0;
    cin>>a>>b>>c>>d;
    if(d>a)
    {
        ans+=a;
        if(b+a<d)
        {
            ans-=(d-a-b);
        }
    }
    else ans+=d;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3652
s = input()
n = len(s)


ans = 0
t_list = []
for i in range(2**(n-1)):
    t = ['' for _ in range(n)]
    for j in range(n-1):
        if (i >> j) & 1:
            t[j] = '+'
    t_list.append(t)


for i in range(2**(n-1)):
    formula = [i+j for i,j in zip(s,t_list[i])]
    formula = ''.join(formula)
    ans += eval(formula)
    
print(ans)
            


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/

int n, k, w[114514], d[114514];
signed main() {
	cin >> n >> k;
	rep(i, n)cin >> w[i] >> d[i];
	int ng = 0, ok = inf;
	while (ok - ng > 1) {
		int mid = (ok + ng) / 2;
		int memo = 0;
		rep(i, n) {
			if (mid >= w[i]) {
				memo += (mid - w[i]) / d[i] + 1;
			}
		}
		if (memo >= k)ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
const int mod = 1e9 + 7;
void reverseS(string &s, int n)
{
	for (int i = 0; i < n/2; ++i)
	{
		char ch = s[i];
		s[i] = s[n-i-1];
		s[n-i-1] = ch;
	}
}
int main()
{
	SPEED
	string s;
	cin >> s;
	int n = s.size();
	reverseS(s,n);

	int k = 2019;
	vector<int> dp(k, 0);

	int ans = 0;

	int tensmod2019[200001];
	tensmod2019[0] = 1;
	for (int i = 1; i <= 200000; ++i)
	{
		int num = tensmod2019[i-1]*10;
		tensmod2019[i] = num%k;
	}

	int prev = 0;
	for (int i = 0; i < n; ++i)
	{
		int digit = s[i]-'0';
		int remainder = (prev + (digit*tensmod2019[i]))%k;
		dp[remainder]++;
		prev = remainder;
	}

	ans += dp[0];

	for (int i = 0; i < k; ++i)
	{
		ans += (dp[i]*(dp[i]-1))/2;
	}

	cout << ans;

	return 0;
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int z, x;
    z = max(a, max(b, c));
    x = a + b + c - z;
    if (a == b && b == c)
    {
        cout << "Yes";
    } else {
        cout << "No";
    }
    cout << endl;
}

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

int main(){

	int n, m, cnt, h[1000001], p[1000001];

	fill(h, h+1000001, 0);

	for(int i=1; i<=1000000; i*=2){
		for(int j=1; i*j<=1000000; j*=3){
			for(int k=1; i*j*k<=1000000; k*=5){
				h[i*j*k] = 1;
			}
		}
	}
	
	cnt = 0;
	for(int i=0; i<=1000000; i++){
		if(h[i] == 1) cnt++;
		p[i] = cnt;
	}
	
	while(cin >> m){
		if(m == 0) break;
		cin >> n;
		if(h[m] == 1) cout << p[n] - p[m] + 1 << endl;
		else cout << p[n] - p[m] << endl;
	}

	return 0;

}

Measured memory_bytes: 8972
#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;

int main () {
	char  Nstr[7];
	int N;
	cin >> Nstr;
	N = atoi (Nstr);
	int len = strlen (Nstr);
	switch (len) {
		case 1:
			cout << N << endl;
			break;
		case 2:
			cout << 9 << endl;
			break;
		case 3:
			cout << (N-90) << endl;
			break;
		case 4:
			cout << 909 << endl;
			break;
		case 5:
			cout << N-9090 << endl;
			break;
		case 6:
			cout << 90909 << endl;
			break;
	}
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    string a,b,c;
    cin>>a>>b;
    for(int i=0;i<2*n;i++){
        if(i%2==0){
            cout<<a[i/2]<<flush;
        }
        else{
            cout<<b[i/2]<<flush;
        }
    }
    cout<<endl;
    return 0;
}








Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;


int main(){
    int x,y,z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y;    
}

Measured memory_bytes: 256
import collections
n, k, q = map(int, input().split())
A = [int(input()) for _ in range(q)]
a_c = collections.Counter(A)
cnt = 0
x = ['No'] * n
if q-k < 0:
	for a in range(n):
		print('Yes')
	exit()
for i,j in a_c.items():
  if j > q-k:
    x[i-1] = 'Yes'
for k in x:
	print(k)

Measured memory_bytes: 11904
n = int(input())
lst =[list(map(int,input().split())) for i in range(2)]

ans = []
for i in range(n):
    if i != n-1:
        ans = ans + [sum(lst[0][:i+1]) + sum(lst[1][i:])]
    else:
        ans = ans + [sum(lst[0][:]) + lst[1][-1]]
print(max(ans))

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader breader = getReader();

		int[] ary = getAry(breader);
		while( ary[0] != 0 || ary[1] !=0 ) {
			for( int i = 0 ;  i < ary[0] ; i++ ) {
				for( int j = 0 ; j < ary[1] ; j++ ) {
					System.out.print("#");
				}
				System.out.println("");
			}
			System.out.println("");
			ary = getAry(breader);
		}
	}
	public static BufferedReader getReader() {
		return( new BufferedReader(new InputStreamReader(System.in)));
	}
	public static int[] getAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		int[] n = new int[nstr.length];
		for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		}
		return n;
	}

}

Measured memory_bytes: 25972
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
int N;
int n;
int dfs(string s)
{
    bool b3 = (int)s.find("3") < 0 ? 0 : 1;
    bool b5 = (int)s.find("5") < 0 ? 0 : 1;
    bool b7 = (int)s.find("7") < 0 ? 0 : 1;
    int res = b3 && b5 && b7;
    if (s.size() == n)
    {
        if (stoi(s) <= N)
        {
            return res;
        }
        else
        {
            return 0;
        }
    }

    return res+dfs(s + "3") + dfs(s + "5") + dfs(s + "7");
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N;
    string S = to_string(N);
    n = S.size();

    cout << dfs("") << endl;
   // system("pause");
    return 0;
}

Measured memory_bytes: 256
n = int(input())
b = [0, 0, 0]

for _ in range(n):
    a = [int(i) for i in input().split()]
    c = [0] * 3
    for i in range(3):
        for j in range(3):
            if i == j:
                continue
            c[i] = max(c[i], b[j] + a[i])
    b = c
print(max(b))


Measured memory_bytes: 46680
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];


int main(){
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    rep(i,1000){
        c=c-b;
        if(c<=0){
            cout<<"Yes"<<endl;
            break;
        }
        a=a-d;
        if(a<=0){
            cout<<"No"<<endl;
            break;
        }

    }
}



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

int main(){
  cout << fixed << setprecision(12);

  double r;
  cin>>r;

  double PI = acos(-1);
  double area = r * r * PI;
  double cir = (r + r) * PI;
  cout<<area<<" "<<cir<<endl;

  return 0;

} 




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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#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 repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int first = 0, second = 0, fi = -1;
    rep(i, n) {
        if (a[i] > first) {
            first = a[i];
            fi = i;
        }
        else if (a[i] > second) second = a[i];
    }
    rep(i, n) {
        cout << (i!=fi?first:second) << endl;
    }
    return 0;
}


Measured memory_bytes: 2432
#include <iostream>

void draw( char c, int n )
{
  for ( int i = 0; i < n; i++ )
    std::cout << c;
}

int main()
{
  int sx, sy, tx, ty;
  std::cin >> sx >> sy >> tx >> ty;

  int w = tx - sx;
  int h = ty - sy;

  draw( 'U', h ); draw( 'R', w );
  draw( 'D', h ); draw( 'L', w+1 );
  draw( 'U', h+1 ); draw( 'R', w+1 );
  draw( 'D', 1 ); draw( 'R', 1 );
  draw( 'D', h+1 ); draw( 'L', w+1 );
  draw( 'U', 1 );

  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll num[50][50];

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

    rep(i, n){
        string s;
        cin >> s;
        int idx = s.size()-1;
        int m = s.size();
        rep(j, s.size()) if (s[j] == '.') idx = j;
        if (idx != s.size()-1) s = s.erase(idx, 1);
        ll a = 0;
        rep(j, s.size()) a += ll(pow(10, s.size() - j - 1)) * (s[j] - '0');
        a *= ll(pow(10, 9 - (m-idx-1)));
        ll cnt2 = 0, cnt5 = 0;
        while(a%2 == 0) a /= 2, cnt2++;
        while(a%5 == 0) a /= 5, cnt5++;
        num[cnt2][cnt5]++;
    }

    ll ans = 0;

    rep(i, 50) rep(j, 50){
        ll tmp = 0;
        rep(ii, 50) rep(jj, 50){
            if (i + ii >= 18 && j + jj >= 18){
                if (i == ii && j == jj) tmp += num[i][j] - 1;
                else tmp += num[ii][jj];
            }
        }
        ans += tmp * num[i][j];
    }

    cout << ans / 2 << endl;

    return 0;
}


Measured memory_bytes: 4092
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

private const val MOD = (1e9 + 7).toLong()

private fun pow(value: Long, power: Long): Long {
    var p = power
    var v = value
    var res = 1L
    while (p > 0) {
        if (p % 2 == 1L) {
            res = res * v  % MOD
        }
        v = v * v % MOD
        p /= 2
    }
    return res
}

private fun solve() {
    val n = nextInt()
    val c = Array(n) { nextInt() }
    c.sort()
    var res = 0L
    for (i in 0 until n) {
        val lasts = n - 1L - i
        val count = (pow(2, n - 1L) + pow(2, n - 2L) * lasts % MOD) % MOD
        val next = count * c[i] % MOD
        res = (res + next) % MOD
    }
    res = res * pow(2, n.toLong()) % MOD
    println(res)
}

fun main(args: Array<String>) {
    solve()
    out.close()
}

private var br = BufferedReader(InputStreamReader(System.`in`))
private var st: StringTokenizer? = null
private var out = PrintWriter(System.out)

@Throws(IOException::class)
private fun next(): String {
    while (st == null || !st!!.hasMoreTokens()) {
        st = StringTokenizer(br.readLine())
    }
    return st!!.nextToken()
}

@Throws(IOException::class)
private fun nextInt(): Int {
    return next().toInt()
}

@Throws(IOException::class)
private fun nextLong(): Long {
    return next().toLong()
}


Measured memory_bytes: 61844
void solve();

int main() {
	solve();
	return 0;
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <boost/multiprecision/cpp_int.hpp>
#include <limits.h>
#include <iomanip>
#include <stack>

using namespace std;
using namespace boost::multiprecision;

vector<int> A;
int N, M;
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> q;

void solve() {
	cin >> N >> M;
	A.resize(N);
	for (int n = 0; n < N; n++) {
		cin >> A[n];
	}
	sort(A.begin(), A.end());
	pair<int, int> t(A[0],1);
	for (int n = 1; n < N; n++) {
		if (t.first == A[n])t.second++;
		else {
			q.push(t);
			t.first = A[n];
			t.second = 1;
		}
	}
	q.push(t);
	for (int m = 0; m < M; m++) {
		int B, C;
		cin >> B >> C;
		pair<int, int> t(C, 0);
		bool flag = false;
		while (q.top().first < C && t.second < B) {
			pair<int, int> e = q.top();
			q.pop();
			if (t.second + e.second <= B) {
				t.second += e.second;
			}
			else {
				e.second = e.second - (B-t.second);
				t.second = B;
				q.push(t);
				q.push(e);
				flag = true;
			}
		}
		if (!flag)q.push(t);
	}
	long long ans = 0;
	while (!q.empty()) {
		ans += (long long)(q.top().first)*(long long)(q.top().second);
		q.pop();
	}
	cout << ans << endl;
	return;
}


Measured memory_bytes: 1784