akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll md=1e9+7;
ll dp[2010][2010];
ll su[2010][2010];
int s[2010],t[2010];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	memset(dp,0,sizeof(dp));
	memset(su,0,sizeof(su));
	for(int i=1;i<=n;i++){
		scanf("%d",&s[i]);
	} 
	for(int i=1;i<=m;i++){
		scanf("%d",&t[i]);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s[i]==t[j]){
				dp[i][j]=(su[i-1][j-1]+1)%md;
				su[i][j]=(su[i-1][j]+su[i][j-1]-su[i-1][j-1]+dp[i][j]+md)%md;
			}
			else{
				dp[i][j]=0;
				su[i][j]=(su[i-1][j]+su[i][j-1]-su[i-1][j-1]+md)%md;
			}
		}
	}
	printf("%lld\n",(su[n][m]+1)%md);
	return 0;
}


Measured memory_bytes: 63360
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  string X;
  cin >> A >> B >> X;
  if (X.at(A)=='-'){
    for(int i=0;i<A+B+1;i++){
      if(i==A){
        continue;
      }
      else{
        if(X.at(i)=='-'){
          cout << "No" << endl;
          break;
        }
        if(i==A+B&&X.at(i)!='-'){
          cout << "Yes" << endl;
        }
      }
    }
  }
  else{
    cout << "No" << endl;
  }
}
        

Measured memory_bytes: 256
pub 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()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn f(u: usize, p: usize, c: u64, edges: &Vec<Vec<(usize, u64)>>, depth: &mut Vec<u64>) {
    depth[u as usize] = c;
    for v in &edges[u] {
        if v.0 == p {
            continue;
        }
        f(v.0, u, c + v.1, edges, depth);
    }
}

fn main() {
    let n: usize = read();
    let abcvec: Vec<Vec<usize>> = read_vec2(n - 1);
    let mut edges: Vec<Vec<(usize, u64)>> = vec![vec![]; n];
    for abc in abcvec {
        let a = abc[0] - 1;
        let b = abc[1] - 1;
        let c = abc[2];
        edges[a as usize].push((b, c as u64));
        edges[b as usize].push((a, c as u64));
    }
    let qk: Vec<usize> = read_vec();
    let q = qk[0];
    let k = qk[1] - 1;

    let mut depth: Vec<u64> = vec![0; n];
    for v in &edges[k] {
        f(v.0, k, v.1, &edges, &mut depth);
    }

    let xyvec: Vec<Vec<usize>> = read_vec2(q);

    for xy in xyvec {
        println!("{}", depth[xy[0] - 1] + depth[xy[1] - 1]);
    }
}


Measured memory_bytes: 28540
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int a, b, t;

	cin>>a>>b>>t;

	int i=a, ans=0;
	while((double)i<=(t+0.5)){
		ans+=b; i+=a;
	}
	cout<<ans<<endl;
}


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

const int MAX_N=100010;
int N;
long int h[MAX_N];
long int dp[MAX_N];

int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%ld",&h[i]);
	}
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(int i=2;i<N;i++){
		dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
	}
	printf("%ld\n",dp[N-1]);
}

Measured memory_bytes: 1792
def INT_(n): return int(n)-1
def MI(): return map(int, input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_, input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n: int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split())) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')


def main():
    a, b = MI()
    if (a + b) % 2 == 0:
        print((a + b) // 2)
    else:
        print('IMPOSSIBLE')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
H,W=map(int,input().split())
sq=[list(input()) for i in range(H)]
ans=False
c=H*W
pos=[[0,0,0]]

while pos!=[]:
    y,x,depth=pos.pop(0)

    if x==W-1 and y==H-1:
        ans=True
        break

    if 0<=x+1<=W-1:
        if sq[y][x+1]==".":
            pos.append([y,x+1,depth+1])
            sq[y][x+1]="!"
            
    if 0<=x-1<=W-1:
        if sq[y][x-1]==".":
            pos.append([y,x-1,depth+1])
            sq[y][x-1]="!"
            
    if 0<=y+1<=H-1:
        if sq[y+1][x]==".":
            pos.append([y+1,x,depth+1])
            sq[y+1][x]="!"
            
    if 0<=y-1<=H-1:
        if sq[y-1][x]==".":
            pos.append([y-1,x,depth+1])
            sq[y-1][x]="!"
    
    
for j in range(H):
    for k in range(W):
        if sq[j][k]=="#":
            c-=1

if ans==True:
    print(c-depth-1)
else:
    print(-1)


Measured memory_bytes: 9280
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <sstream>

using namespace std;

int N; // ???????????°???????????§??????2^n???????????§????????°?????\????????¨??????
int BIT[1000000];

void add(int a, int w){
	
	// a?????????????´????w????¶???? O(log N)
	
	for(int x = a; x <= N; x += x & -x){
		BIT[x] += w;
	}
}

int sum(int a){
	
	// 1??????a?????§???????´????????¨?????????? O(log N)
	
	int ret = 0;
	for(int x = a; x > 0; x -= x & -x){
		ret += BIT[x];
	}
	return ret;
}

void init(){
	for(int i = 0; i < N; i++){
		BIT[i] = 0;
	}
}

// BIT ??????????¢?????????????????????????????´???????????????§????????¨???????????????
int lowerBound(int w){
	if(w <= 0){
		return 0;
	}
	int x = 0;
	for (int k = 262144; k > 0; k /= 2) { // k ??????????????? N ??\???????????§??? 2 ????????¨????????¨??????????°??????§?????????????????????
		if (x + k <= N && BIT[x + k] < w) {
			w -= BIT[x + k];
			x += k;
		}
	}
	return x + 1;
}

int main(){
	
	int q, lim;
	
	while(true){
		
		cin >> q >> lim;
		
		if(q == 0 && lim == 0){
			break;
		}
		
		N = 1000000 - 1;
		
		init();
		
		map<int, int> m1; // ID -> index
		map<int, int> m2; // index -> ID
		
		int index_ref = 1;
		int count = 0;
		
		for(int loop = 0; loop < q; loop++){
			int query, x;
			cin >> query >> x;
			if(query == 0){
				add(index_ref, 1);
				m1[x] = index_ref;
				m2[index_ref] = x;
				index_ref++;
				count++;
			}else if(query == 1){
				int index = lowerBound(x);
				add(index, -1);
				count--;
			}else if(query == 2){
				int index = lowerBound(x);
				cout << m2[index] << endl;
			}else{
				add(m1[x], -1);
				count--;
			}
			if(count > lim){
				int index = lowerBound(1);
				add(index, -1);
				count--;
			}
		}
		cout << "end" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 44488
import math

a, b, x = [int(x) for x in input().split()]

# 横から見たときに三角形か台形かで分岐してみる。
maxtriangle = a * b / 2
side_area = x / a
if side_area <= maxtriangle:
    # Triangle
    sub = side_area * 2 / b
    # b/sub == tan θ: arctan(b/sub) == θ
    rad = math.atan(b/sub)
else:
    # Trapezoid
    sub = (b - side_area / a) * 2
    # sub/a == tan θ: arctan(sub/a) == θ
    rad = math.atan(sub/a)

print(math.degrees(rad))


Measured memory_bytes: 3060
s=list(input())
t=list(input())
start=[-1]*26
goal=[-1]*26
for i in range(len(s)):
    a=ord(s[i])-ord("a")
    b=ord(t[i])-ord("a")

    if start[a]!=-1 or goal[b]!=-1:
        if start[a]!=b or goal[b]!=a:
            print("No")
            exit()

    start[a]=b
    goal[b]=a
print("Yes")


Measured memory_bytes: 70476
#include<iostream>
#include<algorithm>
#include<utility>
using namespace std;
int n;
int a[2<<17],b[2<<17];
int sum[1<<17],L[1<<17],R[1<<17];
main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
		sum[a[i]]++;
		sum[b[i]]--;
		L[b[i]]++;
		R[a[i]]++;
	}
	for(int i=1;i<1<<17;i++)sum[i]+=sum[i-1];
	for(int i=1;i<1<<17;i++)L[i]+=L[i-1];
	for(int i=1<<17;--i;)R[i-1]+=R[i];
	int ansa=0,ansb=0;
	for(int i=0;i<1<<17;i++)ansa=max(ansa,sum[i]);
	for(int i=0;i<n;i++)
	{
		ansb=max(ansb,n-L[a[i]]-R[b[i]]);
	}
	cout<<ansb<<" "<<ansa<<endl;
}



Measured memory_bytes: 6184
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
const double PI = acos(-1);
#define INF 1000000000000 
#define MOD 1000000007 

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

    if (S.size() <= K) {
        cout << S << endl;
    } else {
        string S2 = S.substr(0, K);
        S2 = S2 + "...";
        cout << S2 << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1; 
    while(t--){
	    int n;
	    cin>>n;
	    vector<int> a(n);
	    for(auto &it : a) cin>>it;
	    int q;
	    cin>>q;
	    int b,c;
	    //ll sum=accumulate(a.begin(),a.end(),0);
	    ll sum=0;
	    for(auto i : a)
		    sum=(ll)sum+i;
	    unordered_map<int,int>mp;
	    for(auto i:a)
		    mp[i]++;
            for(int i=0;i<(int)q;i++){
		    cin>>b>>c;
		    //replace(a.begin(),a.end(),b,c);
		    if(mp.count(b)){
		    //sum=(sum-mp[b]*b+mp[b]*c);
		    sum-=1LL*mp[b]*b;
		    sum+=1LL*mp[b]*c;
		    mp[c]+=mp[b];
		    mp[b]-=mp[b];

		   
		    }
                    cout<<(ll)sum<<endl;
		   //for(auto j : a)
		     //  cout<<j<<" ";
		  //  cout<<<<endl;
	    }

    
    }
    return 0;
} 


Measured memory_bytes: 7196
#include <iostream>
#include <sstream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
	int N;
	cin >> N;
	if(N < 1000){
		cout << "ABC";
	}else{
		cout << "ABD";
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	long A = sc.nextLong();
    	long B = sc.nextLong();
    	long C = sc.nextLong();
    	if (0 < C-A-B && 4*A*B < (C-A-B)*(C-A-B)) {
    		System.out.println("Yes");
    	} else {
    		System.out.println("No");
    	}
    }
}

Measured memory_bytes: 23124
// Author: πα

#include <bits/stdc++.h>
using namespace std;
#define long int64_t
const int MOD = 1000000007;

const int N = 2e3 + 5;
int c[N][N];

void calc()
{
    for(int n = 0; n < N; ++n)
    {
        c[n][0] = c[n][n] = 1;
        for(int k = 1; k < n; ++k)
            c[n][k] = (c[n-1][k-1] + c[n-1][k]) % MOD;
    }
}

int main()
{
    int n, k;
    cin >> n >> k;
    calc();
    for(int i = 1; i <= k; ++i)
        cout << (1LL * c[n-k+1][i] * c[k-1][i-1]) % MOD << '\n';
    return 0;
}


Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
int a[5],f[11];
int x,y;
int main()
{
    for (int i=1;i<=3;i++) {
    	scanf("%d%d",&x,&y);
    	a[x]++; a[y]++;
	}
	for (int i=1;i<=4;i++)
	 f[a[i]]++;
	if (f[1]==2&&f[2]==2) cout << "YES" << endl; else cout << "NO" << endl;
} 

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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

int main()
{
	ll a,b,c,d,e,f;
	cin >>a >>b >>c >>d >>e >>f;
	

	VI ab, cd;
	vector<bool> ck(3005,0);
	rep(i,f+1) rep(j,f+1){
		ll w = a*100*i + b*100*j;
		if(w > f) continue;
		if(!ck[w] ) ab.push_back(w);
	}
	fill(all(ck), 0);
	rep(i,f+1) rep(j,f+1){
		ll w = c*i + d*j;
		if(w > f) continue;
		if(!ck[w] ) cd.push_back(w);
	}

	ll mx1 = -1, mx2=1;  //mx = mx1 /mx2
	for(auto pa: ab) for(auto pb: cd){
		if(pa + pb > f || pa + pb ==0) continue;
		if(pb*(100+e)   > e * (pa + pb)) continue;
		//tgt = pb / (pa+pb)
		if( pb * mx2 > mx1 * (pa+pb)){
			mx1  = pb; mx2 = pa+pb;
		}
	}
	
	if(mx1 == -1){mx1 = a*100; mx2=0;}
	cout << mx2 <<" " << mx1<<"\n";
	return 0;
}


Measured memory_bytes: 1400
a = input()
l =list(map(int, input().split()))
t = 0
for i , j in zip(l,l[1:]):
    if i - j == 1:
        t += 1
    elif i - j > 1:
        t+=2
    elif j - i > 0:
        t = 0
    if t >1:
        print("No")
        exit(0)
    

if t > 1:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 11;
const ll MOD = 1000000007;

int tb[MAXN][MAXN];

int checker (const array<int, 5> &data) {
    int s = 0;
    REP (i, 5) {
        s = tb[s][data[i]];
    }
    return s;
}

void fll (array<int, 5> &data) {
    int e = 0;
    REP (i, 4) {
        e = tb[e][data[i]];
    }
    data[4] = e;
}

int ans;
void dfs (int idx, array<int, 5> &cur) {
    if (idx == 4) {
        fll(cur);
        assert(checker(cur) == 0);
        bool flag = false;
        REP (i, 4) {
            if (cur[i] != cur[i+1]) {
                swap(cur[i], cur[i+1]);
                flag |= checker(cur) == 0;
                swap(cur[i], cur[i+1]);
            }
        }

        REP (i, 5) {
            REP (j, 10) {
                if (j != cur[i]) {
                    int tmp = cur[i];
                    cur[i] = j;
                    flag |= checker(cur) == 0;
                    cur[i] = tmp;
                }
            }
        }

        ans += flag;
    } else {
        REP (i, 10) {
            cur[idx] = i;
            dfs(idx + 1, cur);
        }
    }
}
/*********************GoodLuck***********************/
int main () {
    IOS();

    REP (i, 10) {
        REP (j, 10) {
            cin >> tb[i][j];
        }
    }

    array<int, 5> cur;
    dfs(0, cur);

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



Measured memory_bytes: 3212
#include <stdio.h>

int main(){
    
    int i;
    int num;
    int ary[1000];

    scanf("%d",&num);

    for(i=1;i<=num;i++){
        scanf("%d",&ary[i]);
    }

    for(i=num;i>=1;i--){
        if(i==1){
            printf("%d",ary[i]);
        }else{
            printf("%d ",ary[i]);
        }
    }
    printf("\n");
}



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

int main() {
	
	int h,w;
	cin >> h >> w;
	vector<vector<char>> s(h+2,vector<char>(w+2,'.'));
	for(int i=1; i<=h; i++) for(int j=1; j<=w; j++) cin >> s.at(i).at(j);
	bool flg=1;
	for(int i=1; i<=h; i++) {
		for(int j=1; j<=w; j++){
			if(s.at(i).at(j)=='#'&&s.at(i-1).at(j)=='.'&&s.at(i+1).at(j)=='.'&&s.at(i).at(j-1)=='.'&&s.at(i).at(j+1)=='.') flg=0;
		}
	}
	cout << (flg?"Yes":"No") << endl;
}


Measured memory_bytes: 256
N =int(input())
a = list(map(int, input().split()))
k_p = a[0]
a_p = sum(a[1:])
m = abs(k_p - a_p)
for i in range(1, N-1):
    k_p += a[i]
    a_p -= a[i]
    if abs(k_p - a_p) < m:
        m = abs(k_p - a_p)
print(m)

Measured memory_bytes: 24812
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=61
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef pair<int,int> pairii;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
  ll h,w;cin>>h>>w;
  if(h==1||w==1){cout<<1<<endl;
  return 0;}
  cout<<h*w/2+(h*w)%2<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
typedef long long ll;
const int MAX_N=2e5;
int N;
ll A[MAX_N];
bool C(ll x){
	map<int,ll> mp;
	REP(i,N-1){
		if (A[i]>=A[i+1]){
			auto ite=mp.lower_bound(A[i+1]);
			while(ite!=mp.end()){
				auto ite2=ite;
				ite2++;
				mp.erase(ite);
				ite=ite2;
			}
			ll inx=A[i+1]-1;
			do{
				if (mp[inx]!=x-1){
					mp[inx]++;
					break;
				}else{
					mp[inx]=0;
					inx--;
				}
			}while(inx>=0);
			if (inx<0){
				return false;
			}
		}
	}
	return true;
}
int main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	bool flg=true;
	REP(i,N-1){
		if (A[i]>=A[i+1]){
			flg=false;
		}
	}
	if (flg){
		cout<<1<<endl;
	}else{
		ll lb=1,ub=N;
		while(ub-lb>1){
			ll mid=(lb+ub)>>1;
			if (C(mid)){
				ub=mid;
			}else{
				lb=mid;
			}
		}
		cout<<ub<<endl;
	}
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<" "<<x<<endl;

using namespace std;
ll power(ll x, ll y) 
{ 
    ll res = 1;     // Initialize result 
   
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = res*x; 
   		  res%=mod;
        // y must be even now 
        y = y>>1; // y = y/2 
        x = x*x;  // Change x to x^2
        x%=mod; 
    } 
    return res%mod; 
}	
void run(){
	ll n,m;
	cin>>n;
	ll a[n];
    for(ll i=0;i<n;i++)cin>>a[i];
	ll s1=0;
	ll s2=0;
	for(ll i=0;i<n;i++){
		s1+=a[i];
		s2+=(a[i]*a[i]);
		s1%=mod;
		s2%=mod;
	}
	s1=(s1*s1)%mod;
	s1=(s1-s2+mod)%mod;
	ll z=power(2,mod-2);
	s1=s1*z;
	s1%=mod;
	cout<<s1<<endl;
	
	
}

int main() {
	int t=1;
	//cin>>t;
	for(ll i=0;i<t;i++){
	run();
	}
	// your code goes here
	return 0;
}

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

int main(){
	int sx,sy,tx,ty;
	cin >> sx >> sy >> tx >> ty;
	if(tx - sx >= 0){
		for(int i = 0;i < tx - sx;i++) cout << "R";
		if(ty - sy >= 0){
			for(int i = 0;i < ty - sy;i++) cout << "U";
		}
		else{
			for(int i = 0;i < sy - ty;i++) cout << "D";
		}
		for(int i = 0;i < tx - sx;i++) cout << "L";
		if(ty - sy >= 0){
			for(int i = 0;i < ty - sy + 1;i++) cout << "D";
		}
		else{
			for(int i = 0;i < sy - ty + 1;i++) cout << "U";
		}
		for(int i = 0;i < tx - sx + 1;i++) cout << "R";
		if(ty - sy >= 0){
			for(int i = 0;i < ty - sy + 1;i++) cout << "U";
		}
		else{
			for(int i = 0;i < sy - ty + 1;i++) cout << "D";
		}
		cout << "L";
		if(ty - sy >= 0){
			cout << "U";
		}
		else{
			cout << "D";
		}
		for(int i = 0;i < tx - sx + 1;i++) cout << "L";
		if(ty - sy >= 0){
			for(int i = 0;i < ty - sy + 1;i++) cout << "D";
		}
		else{
			for(int i = 0;i < sy - ty + 1;i++) cout << "U";
		}
		cout << "R" << endl;
	}
	else{
		for(int i = 0;i < sx - tx;i++) cout << "L";
		if(ty - sy >= 0){
			for(int i = 0;i < ty - sy;i++) cout << "U";
		}
		else{
			for(int i = 0;i < sy - ty;i++) cout << "D";
		}
		for(int i = 0;i < sx - tx;i++) cout << "R";
		if(ty - sy >= 0){
			for(int i = 0;i < ty - sy + 1;i++) cout << "D";
		}
		else{
			for(int i = 0;i < sy - ty + 1;i++) cout << "U";
		}
		for(int i = 0;i < sx - tx + 1;i++) cout << "L";
		if(ty - sy >= 0){
			for(int i = 0;i < ty - sy + 1;i++) cout << "U";
		}
		else{
			for(int i = 0;i < sy - ty + 1;i++) cout << "D";
		}
		cout << "R";
		if(ty - sy >= 0){
			cout << "U";
		}
		else{
			cout << "D";
		}
		for(int i = 0;i < sx - tx + 1;i++) cout << "R";
		if(ty - sy >= 0){
			for(int i = 0;i < ty - sy + 1;i++) cout << "D";
		}
		else{
			for(int i = 0;i < sy - ty + 1;i++) cout << "U";
		}
		cout << "L" << endl;
	}
	
	return 0;	
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = input()
t = input()
ans = []
for i in range(len(s) - len(t) + 1):
    for j in range(len(t)):
        if s[i + j] not in ('?', t[j]):
            break
    else:
        memo = s[:i] + t + s[i + len(t):]
        ans.append(memo.replace('?', 'a'))
if ans:
    print(min(ans))
    exit()
print('UNRESTORABLE')


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

string xingqi[7] = {
    "SUN",
    "MON",
    "TUE",
    "WED",
    "THU",
    "FRI",
    "SAT",
};

int main(){
    string S;   cin >> S;
    for(int i = 0; i < 7; i++){
        if(S == xingqi[i]){
            cout << 7 - i << endl;
            return 0;
        }
    }  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

int main() {
   int N,M;
   cin >> N >> M;
   vector<int> a(M),b(M);
   for(int i = 0; i < M; i++){
       cin >> a.at(i) >> b.at(i);
   }
   vector<int> vec(N);
   
   for(int i = 0;i < N; i++){
       for(int j = 0;j < M; j++){
           if(i+1 == a.at(j)){
               vec.at(i)++;
           }
            if(i+1 == b.at(j)){
               vec.at(i)++;
           }
       }
   }
   
   for(int i = 0;i < N; i++){
       cout << vec.at(i) << endl;
   }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

ll A[2*100000];

bool isOK(ll X, ll N, ll K){
    ll cnt=0;
    for(ll i=0; i<N; i++){
        if(A[i]%X==0)cnt+=(A[i]/X) - 1;
        else cnt+=A[i]/X; 
    }
    if(cnt<=K)return true;
    else return false;
}

int main(){
    ll N,K;
    cin>>N>>K;
    for(ll i=0; i<N; i++)cin>>A[i];

    ll ng=0, ok=1e18;
    while(abs(ok-ng)>1){
        ll mid=(ng+ok)/2;
        if(isOK(mid,N,K))ok=mid;
        else ng=mid;
    } 
    cout<<ok<<endl;
    return 0;
}

Measured memory_bytes: 5152
use proconio::marker::Chars;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        s: Chars,
        t: Chars,
    }
    println!(
        "{}",
        (0..2 * n)
            .map(|i| if i % 2 == 0 { s[i / 2] } else { t[(i - 1) / 2] })
            .collect::<String>()
    );
}


Measured memory_bytes: 2112
#include<iostream>
using namespace std;
int main(){
    int A[4],op[3];
    int input,ans;
    cin >> input;
    for(int i=3;i>=0;i--){
        A[i] = input%10;
        input /= 10;
    }
    for(op[0]=0;op[0]<2;op[0]++){
        for(op[1]=0;op[1]<2;op[1]++){
            for(op[2]=0;op[2]<2;op[2]++){
                ans = A[0];
                for(int l=0;l<3;l++){
                    if(op[l]) ans += A[l+1];
                    else ans -= A[l+1];
                }
                if(ans == 7){
                    for(int i=0;i<3;i++){
                        cout << A[i];
                        if(op[i]) cout << '+';
                        else cout << '-';
                    }
                    cout << A[3] << "=7"<< endl;
                    return 0;
                }
            }
        }
    }

    return 0;
}


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

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------
int divi[1001];

int main(void) {
  int x;
  cin >> x;

  prt(x<1200 ? "ABC" : "ARC");

}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
 int i,c;
 char moji;
 int counter[26]={};

 for(i=0;scanf("%c",&moji)!=EOF;i++){
                        
                        if(isalpha(moji)) {
                                           c=tolower(moji)-'a';
                                           counter[c]++;
                                          }
                        }
 for(i=0;i<26;i++){
                   printf("%c : %d\n",i+'a',counter[i]);
                   }
 return 0;

}



Measured memory_bytes: 2048
def solve arr
  arr.each_with_index do |num, ind|
    printf("node %d: key = %d,", ind + 1, num)
    printf(" parent key = %d,", arr[(ind - 1) / 2]) if ind != 0
    printf(" left key = %d,", arr[ind * 2 + 1]) if ind * 2 + 1 < arr.size
    printf(" right key = %d,", arr[ind * 2 + 2]) if ind * 2 + 2 < arr.size
    printf(" \n")
  end
end

def main
  n = gets.to_i
  arr = gets.split(/\s/).map(&:to_i)
  solve(arr)
end

main

Measured memory_bytes: 6120
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp24 {
    class Program {
        static void Main(string[] args) {
            //入力
            int N = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int[] B = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            //回答となる数値
            long ans = 0;

            //検証
            for (int i = 0; i < N; i++) {
                if (A[i] >= B[i]) {
                    //自分の持ち場のモンスターを倒すので精一杯なので、答えにB[i]を追加するだけでその他の操作は何もしなくてよい
                    ans += B[i];
                } else if (A[i] < B[i]) {
                    if (A[i] + A[i + 1] > B[i]) {
                        ans += B[i];
                        A[i + 1] -= B[i] - A[i];
                    } else if (B[i] >= A[i] + A[i + 1]) {
                        ans += A[i] + A[i + 1];
                        A[i + 1] = 0;
                    }
                }
            }

            //出力
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 34908
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <stdio.h>
#include <numeric>
using namespace std;

vector<int> ana(string s) {
	vector<int> res('z' - 'a' + 1);
	for (char c : s) ++res[c - 'a'];
	return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	//freopen("input.txt", "rt", stdin);
	//freopen("out.txt", "wt", stdout);
	int n;
	cin >> n;
	vector<string> s(n);
	for (int i = 0; i < n; ++i) {
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
	}
	sort(s.begin(), s.end());
	long long result = 0;
	for (int i = 0; i < n;) {
		int l = i + 1;
		while (l < n && s[i] == s[l]) ++l;
		long long k = l - i;
		result += k * (k - 1) / 2;
		i = l;
	}
	cout << result << endl;
	/*int n, m, k;
	cin >> n >> m >> k;
	vector <tuple<int, int, int>> edges(m);
	for (int i = 0; i < m; ++i) {
		int x, y, w;
		cin >> x >> y >> w;
		if (x > y) swap(x, y);
		edges[i] = make_tuple(w, x, y);
	}
	sort(edges.begin(), edges.end());
	vector <tuple<int, int, int>> paths;
	int curmin = get<0>(edges[0]);
	int ind = 0;
	int cnt = 0;
	while (get<0>(edges[ind]) == curmin && cnt < k) {
		paths.push_back(edges[ind]);
		++ind;
		++cnt;
	}
	while (cnt < k) {
		curmin = get<0>(edges[ind]);
		bool added = false;
		for (int i = 0; i < paths.size(); ++i)
			for (int j = i + 1; j < paths.size(); ++j) {
				int xi = get<1>(paths[i]);
			}

	}*/
	/*int n, m;
	cin >> n >> m;
	vector<vector<int>> graph(n);
	vector<int> powers(n);
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		graph[a].push_back(b);
		graph[b].push_back(a);
		++powers[a];
		++powers[b];
	}
	vector<pair<int, int>> sorted(n);
	for (int i = 0; i < n; ++i) {
		sorted[i].first = powers[i];
		sorted[i].second = i;
	}
	sort(sorted.begin(), sorted.end());
	if (m % 2) {
		cout << -1 << endl;
		return 0;
	}*/
	//cout << get<0>(paths[k - 1]);
	return 0;
}


Measured memory_bytes: 5760
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, t = map(int, readline().split())
    a = list(map(int, readline().split()))

    cum_max = [0] * n
    cum_max[-1] = a[-1]

    for i in range(n - 2, -1, -1):
        cum_max[i] = max(cum_max[i + 1], a[i])

    profit = [0] * n
    for i in range(n-1):
        profit[i] = cum_max[i+1] - a[i]

    print(profit.count(max(profit)))


if __name__ == '__main__':
    main()


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

using namespace std;

#define PB push_back
#define MP make_pair
#define X first
#define Y second

#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )
#define err(x) cerr << #x << " = " << x << endl;
#define forall(i,a,b) for(int i=a;i<b;i++)
#define foreach(v, c) for(typeof((c).begin())v=(c).begin();v!=(c).end();++v)
#define read(a) freopen(a,"r",stdin)
#define write(a) freopen(a,"w",stdout)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef long long l;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

clock_t start;
void Time(bool timeIt) {
	if (!timeIt) return;
	clock_t end = clock();
	double elapsed_time = ((db)end - (db)start) / (db)CLOCKS_PER_SEC;
	fprintf(stderr, "Time elapsed = %0.4lf\n", elapsed_time); 
}

#define LINF (long long)1e18
#define EPS 1e-9
#define INF 1000000007ll
#define SIZE 300010
#define MAX_A 1000010
#define LIM 30000

int arr[SIZE];
int main() {
	start = clock();

	arr[1] = 2;
	arr[2] = 3;
	arr[3] = 25;
	arr[4] = 30;
	for (int i = 5 ; i < SIZE ; ++i) {
		arr[i] = arr[i - 1] + 30;
	}

	int n;
	cin >> n;

	if (n < 1000) {
		for (int i = 1 ; i <= n ; ++i) {
			cout << arr[i] << " ";
		}
		cout << endl;
	}
	else {
		//cout << 2 << " " << 3 << " ";
		vi num;
		num.PB(2);
		num.PB(3);
		n -= 2;
		ll sum = 5;
		for (int i = 4 ; i <= LIM ; ++i) {
			if (i % 2 == 0 || i % 3 == 0) {
				sum += i;
				num.PB(i);
				--n;
			}
			if (n == 0) break;
		}

		if (sum % 6 == 0) {
			for (int i = 0 ; i < num.size() ; ++i) cout << num[i] << " ";
			cout << endl;
		}
		else if (sum % 6 == 2) {
			for (int i = 0 ; i < num.size() ; ++i) {
				if (num[i] != 8) cout << num[i] << " ";
				else cout << num.back() + 6 - (num.back() % 6) << " ";
			}
			cout << endl;
		}
		else if (sum % 6 == 3) {
			for (int i = 0 ; i < num.size() ; ++i) {
				if (num[i] != 9) cout << num[i] << " ";
				else cout << num.back() + 6 - (num.back() % 6) << " ";
			}
			cout << endl;
		}
		else if (sum % 6 == 4) {
			for (int i = 0 ; i < num.size() ; ++i) {
				if (num[i] != 10) cout << num[i] << " ";
				else cout << num.back() + 6 - (num.back() % 6) << " ";
			}
			cout << endl;
		}
		else if (sum % 6 == 5) {
			for (int i = 0 ; i < num.size() ; ++i) {
				if (num[i] != 9) cout << num[i] << " ";
				else {
					if (num.back() % 6 < 4) cout << num.back() + 4 - (num.back() % 6) << " ";
					else cout << num.back() + 6 - (num.back() % 6) + 4 << " ";
				}
			}
			cout << endl;
		}
	}

	Time(true);
	return 0;
}

Measured memory_bytes: 1792
# a<=b<=cとしてc-aとc-bの差が偶数なら2で割ればいいし奇数ならceil+1
a, b, c = sorted(list(map(int, input().split())))
if (c - a + c - b) % 2 == 0:
    print((c - a + c - b) // 2)
else:
    print((c - a + c - b) // 2 + 2)


Measured memory_bytes: 2940
X,K,D = map(int,input().split())

def sgn(x):
  if x > 0:return 1
  if x < 0:return -1
  return 0

if X > 0:
  x_greedy = X - K*D
else:
  x_greedy = X + K*D
  
if sgn(X) == sgn(x_greedy):
  print(abs(x_greedy))
  exit()
x_r = X%D
x_l = x_r - D

r_parity = (abs(X-x_r)//D)%2

if K%2 == r_parity:
  print(abs(x_r))
else:
  print(abs(x_l))

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
//const int MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    int D[N][2];
    rep(i, N){
        cin >> D[i][0] >> D[i][1];
    }
    rep(i, N-2){
        bool flag = true;
        rep(j, 3){
            if(D[i+j][0] != D[i+j][1]) flag = false;
        }
        if(flag) {cout << "Yes" << endl; return 0;}
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3600
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  let
    f :: Int -> Int
    f k = k * m * (m + 1) `div` 2
      where
        m = n `div` k
  print . sum . map f $ [1..n]

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,a,n) for(int i=a;i<=n;i++)
#define repb(i,a,n) for(int i=a;i>=n;i--)
#define trav(a,x) for(auto a=x.begin();a!=x.end();a++)
#define all(x) x.begin(),x.end()
#define fst first
#define snd second
#define pb push_back
#define mp make_pair
typedef long double ld;
typedef pair <int,int> pii;
typedef vector <int> vi;
typedef long long ll;

void pre(){

}

void solve(){
  int n; cin>>n;
  string s; cin>>s;
  int bit=0;

  rep(i,s.size()){
    if(s[i]=='1') bit++;
  }

  int temp1=bit+1;
  int temp2=bit-1;

  int prev=1;

  int m1[n],m2[n];
  int rem1=0,rem2=0;

  for(int i=n-1;i>=0;i--){
    if(i==n-1){
      int kemp=(1%temp1);
      m1[i]=kemp;
      prev=kemp;
    }
    else{
      int kemp=((prev%temp1)*(2%temp1))%temp1;
      m1[i]=kemp;
      prev=kemp;
    }

    if(s[i]=='1')
      rem1=((rem1%temp1)+(m1[i]%temp1))%temp1;
  }

  prev=1;

  if(temp2>0){
    for(int i=n-1;i>=0;i--){
      if(i==n-1){
        int kemp=(1%temp2);
        m2[i]=kemp;
        prev=kemp;
      }
      else{
        int kemp=((prev%temp2)*(2%temp2))%temp2;
        m2[i]=kemp;
        prev=kemp;
      }

      if(s[i]=='1')
        rem2=((rem2%temp2)+(m2[i]%temp2))%temp2;
    }
  }

  for(int i=0;i<n;i++){
    if(s[i]=='0'){
      ll ans=0;
      ans++;
      int co=bit+1;
      int temp=((rem1%temp1)+(m1[i]%temp1))%temp1;

      while(temp){
        int bhai=__builtin_popcount(temp);
        temp=temp%bhai;
        ans++;
      }

      cout<<ans<<"\n";
    }
    else{
      int co=bit-1;
      if(co==0){
        cout<<0<<"\n";
      }
      else{
        ll ans=0;
        ans++;

        int temp=((rem2%temp2)-(m2[i]%temp2)+temp2)%temp2;

        while(temp){
          int bhai=__builtin_popcount(temp);
          temp=temp%bhai;
          ans++;
        }

        cout<<ans<<"\n";
      }
    }
  }
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  pre();
  int t; t=1;
  rep(i,t) solve();
  return 0;
}

/* Cherry, Please look at the stuff down */

/* 1) Did you checked special case (n==1)?
   2) Look at the code once, check whether there are some typos
   3) Cherry! Is contest over ??
   4) Do something instead of doing notthing
*/


Measured memory_bytes: 5324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll N; cin >> N;
  ll a[N];
  ll sum = 0; 
  bool ok = true;
  for (ll i = 0; i < N; i++) {
    cin >> a[i]; sum+=a[i];
  }
  if (sum % (N*(N+1)/2) != 0) {
    cout << "NO" << endl; return 0;
  }
  ll K = sum/(N*(N+1)/2);
  ll c[N];
  for (ll i = 0; i < N; i++) {
    ll x = a[(i+1)%N]-a[i];
    if (K < x || (K-x)%N != 0) {
      cout << "NO" << endl; return 0;
    }
    c[i] = (K-x)/N;
  }
  ll A = 0;
  for (ll i = 0; i < N; i++) {
    A += (N-i)*c[i];
  }
  if (A != a[0]) {
    cout << "NO" << endl; return 0;
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int[] C = new int[9];
		for(int i = 0;i < N;i++) {
			int r = scn.nextInt();
			if(r >3200) {
				C[8]++;
			}else {
				C[r/400]++;
			}

		}
		int min = 0, max = 0;

		for(int i = 0;i < 8;i++) {
			if(C[i]>0)min++;
		}

		max = min + C[8];
		if(min==0)min++;
		System.out.println(min + " " + max);
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h> 
using namespace std; 
int main() 
{ 
  		int n;
    	cin >> n;
    	string a;
    	cin >> a;
        int dp[n + 1][n + 1];
        memset(dp , 0 , sizeof(dp));
        int ans = 0;
        for(int i = 1 ; i <= n; i++){
            for(int j = i + 1 ; j <= n ; j++ ){
                if(a[i - 1] == a[j - 1] && j - i > dp[i - 1][j - 1])
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                else
                    dp[i][j] = 0;
                ans = max(ans , dp[i][j]);
            }
        }
        cout << ans << endl;
	return 0; 
} 

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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp(a, b) make_pair(a, b)
#define pb push_back

const long long MOD = 1000000007;


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

    vector<vector<ll> > dp(n+1, vector<ll>(n+1, 0));

    ll res = 0;
    for(ll i = n-1; i >= 0; i--){
        for(ll j = n-1; j > i; j--){
            if(s[i] == s[j]){
                dp[i][j] = max(dp[i+1][j+1]+1, dp[i][j]);
            }
            res = max(res, min(dp[i][j], j-i));
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 195840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define F first
#define S second
#define endl '\n'
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define maxp 22
#define EPS (ld)(1e-18)
#define mod (int)(1e9+7)
#define N (int)(1e5+1)
void yesno(bool a){if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
ll power(ll x, ll n, ll m){if(n==0)return 1;ll u=power(x,n/2,m);u=(u*u)%m;if(n%2)u=(u*x)%m;return u;}



int main (){
fastio;


char c;
cin>>c;

if('A'<=c && c<='Z')
    cout<<"A"<<endl;
else
    cout<<"a"<<endl;


}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n, m;
    cin >> n >> m;
    OP(((n - 1) * (m - 1)));

    
    return 0;
}

Measured memory_bytes: 256
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper
print(input().count('1'))

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,sum=0;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            sum=sum+a[i]*a[j];
        }
    }
    cout<<sum;
}


Measured memory_bytes: 256
n =int(input())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))

def distance(X,Y,p):
    l = []
    sum = 0
    
    for xi, yi in zip(X,Y):
        d = abs(xi-yi)
        l.append(d)
        if p != 'inf':
            sum+=d**p
    
    if p == 'inf':
        D = max(l)
    else:
        D = round(sum**(1/p),5)
        
    print(D)
    
P = [1,2,3,'inf']
for p in P:
    distance(X,Y,p)


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

int main(){
    string s;  cin >> s;
    int n = s.length();
    for(int i=0; i<n-1; i++){
        if(s[i] == s[i+1]){
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
    }
    for(int i=0; i<n-2; i++){
        if(s[i] == s[i+2]){
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }

    cout << -1 << " " << -1 << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <deque>
using namespace std;

int main() {
    //input
    long n,p; cin >> n >> p;
    vector<long> a(n + 1);
    for(int i = 1; i < n + 1; i++) cin >> a[i];

    //compute
    long odd = 0;
    long even = 0;

    for(int i = 1; i < n + 1; i++) {
        if(a[i] % 2 == 0){
            even += 1;
        }else{
            odd += 1;
        }
    }

    //output
    long q;
    q = pow(2,even);
    long r;
    r= pow(2,odd - 1);
  
    if(p == 0){
        if(odd == 0){
            cout << q << endl; 
        }else{
            cout << q * r << endl;
        }
    }else{
        if(odd == 0){
            cout << 0 << endl;
        }else{
            cout << q * r << endl;
        }
    }
}



Measured memory_bytes: 4092
#include <iostream>
#include <vector>
#include <set>
#include <climits>
using namespace std;
#include <algorithm>


int main() {
    int n;
    cin >> n;
    vector<string> blues(n);
    for (int i = 0; i < n; i++) cin >> blues.at(i);
    set<string> kinds(blues.begin(), blues.end());
    int m;
    cin >> m;
    vector<string> reds(m);
    for (int i = 0; i < m; i++) cin >> reds.at(i);

    int sum = INT_MIN;
    for (auto elem : kinds) {
        int num = count(blues.begin(), blues.end(), elem) - count(reds.begin(), reds.end(), elem);
        if (sum < num) sum = num;
    }
    cout << max(0, sum) << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;

const int MXN = 2e5, IINF = 1e9 + 10, INF = 1e18 + IINF + 10, MOD = 1000000007;
const ld PI = 4.0 * atanl(1.0), PREC = .000001;
const char nl = '\n';

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)(x).size()
#define ins insert

ull n, m, t, a[MXN];

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

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

ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }

int main() {
  fast();
  cin >> n;
  ull ans = 1;
  FOR(i, 0, n) {
    ans *= (i + 1);
    ans %= MOD;
  }
  cout << ans;
  return 0;
}



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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
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 int MOD = 1000000007;
const int INF = 1000000001;

int main() {
    int n;
    cin >> n;
    cout << fixed << setprecision(10) << (double)((n + 1) / 2) / n << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

int N;
int K;
int h[10000000];
int ans = 0;

int main() {
	cin >> N >> K;
	rep(i, N) {
		cin >> h[i];
		if (h[i] >= K)ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 768
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    X = int(input())
    l = [i ** 5 for i in range(120)]
    for i in l:
        for j in l:
            if i + j == X:
                print(int(i ** (1 / 5)), int(-1 * j ** (1 / 5)))
                break
            elif i - j == X:
                print(int(i ** (1 / 5)), int(j ** (1 / 5)))
        else:
            continue
        break


if __name__ == "__main__":
    main()

    

Measured memory_bytes: 9280
x=input()
if x[0]=="R":
    if x[1]=="R":
        if x[2]=="R":
            print(3)
        else:
            print(2)
    else:
        print(1)
else:
    if x[1]=="R":
        if x[2]=="R":
            print(2)
        else:
            print(1)
    else:
        if x[2]=="R":
            print(1)
        else:
            print(0)


Measured memory_bytes: 8920
import math

z = raw_input()
x1, y1, x2, y2 = z.split()
x1 = float(x1)
x2 = float(x2)
y1 = float(y1)
y2 = float(y2)

d = math.sqrt((x2 - x1) * (x2-x1) + (y2 - y1) * (y2 - y1))

print ("%lf" %(d))

Measured memory_bytes: 6488