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

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var d = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        var ans = 0;
        for (int x = 0; x < d.Length - 1; x++)
        {
            for (int y = x + 1; y < d.Length; y++)
            {
                ans += d[x] * d[y];
            }
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13268
#include <stdio.h>
#include <math.h>

int main(void)
{
	int a[10000],c=0,d=0,k=3,n,i;
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		//printf("%d\n",a[i]);
	}
	
	for(i=0;i<n;i++){
		if(a[i]==2){
			c++;
		}
		
		else if(a[i]==1){
		}
		
		else if(a[i]%2!=0){
			while(k<=sqrt(a[i])){
				if(a[i]%k==0){
					k=3;
					d=1;
					break;
				}
				k=k+2;
			}
			if(d==0){
				c++;
			}
			d=0;
			k=3;
		}
	}
	printf("%d\n",c);
	return 0;
}


Measured memory_bytes: 2056
use proconio::input;
use std::collections::VecDeque;

const INF: usize = 1001001001;

fn main() {
    input! {
        n: usize,
        m: usize,
        mut a_b: [(usize, usize); m],
    }

    let mut to = vec![Vec::new(); n];
    for (a, b) in a_b {
        to[a - 1].push(b - 1);
        to[b - 1].push(a - 1);
    }

    let mut q = VecDeque::<usize>::new();
    let mut dist = vec![INF; n];
    let mut pre = vec![INF; n];

    dist[0] = 0;
    q.push_front(0);

    while !q.is_empty() {
        let v = q.pop_front().unwrap();
        for target in to[v].iter() {
            if dist[*target] != INF { continue; }
            dist[*target] = dist[v] + 1;
            pre[*target] = v;
            q.push_back(*target);
        }
    }

    println!("Yes");
    for i in 1..n {
        let mut ans = pre[i];
        ans += 1;
        println!("{}", ans);
    }
    print!("\n");
}


Measured memory_bytes: 15980
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1

def main():
    n=int(input())
    cc=[0]*5
    for _ in range(n):
        c=input()[0]
        if c=="M":cc[0]+=1
        if c == "A": cc[1] += 1
        if c == "R": cc[2] += 1
        if c == "C": cc[3] += 1
        if c == "H": cc[4] += 1
    ans=0
    for k in range(5):
        for j in range(k):
            for i in range(j):
                ans+=cc[i]*cc[j]*cc[k]
    print(ans)

main()

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ld long double
#define mem(a,b) memset(a,b,sizeof(a) )
#define M 4000010
#define md 1000000007
 
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}
/*inline ll add(ll a,ll b){return (a+b)%md;}
inline ll mul(ll a,ll b){return (a*b)%md;}
ll f[M],iv[M];
ll C(ll n,ll r){return mul(f[n],mul(iv[r],iv[n-r]));}
void prep_fac(){
    f[0]=1;
    rep(i,1,M)f[i]=mul(i,f[i-1]);
    iv[M-1]=power(f[M-1],md-2,md);
    for(ll i=M-2;i>=0;--i)iv[i]=mul(i+1,iv[i+1]);
}*/

int main()
{
	IOS;
	int n;
	cin>>n;
	int a[n],b[n];
	rep(i,0,n)cin>>a[i]>>b[i];
	for(int i=0;i<n-2;i++){
		if(a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2]){
			return cout<<"Yes",0;
		}
	}
	cout<<"No";
}

Measured memory_bytes: 3620
#include <iostream>
#include<vector>
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
char grid[1002][1002];
int solve(int n,int m)
{
    int dp[n+1][m+1];
    //cout<<n<<" "<<m<<endl;
    dp[n][m] = 1;
    //cout<<"dp[n][m] = "<<dp[n][m]<<endl;
    /*for(int i = n;i >= 1;i--)
    {
        for(int j = m;j >= 1;j--)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    for(int i = n;i >= 1;i--)
    {
        for(int j = m;j >= 1;j--)
        {
            if(i==n && j==m)
            {
                //cout<<"Inside last element las row last column i:"<<i<<" j: "<<j<<endl;
                //cout<<dp[i][j]<<endl;
                continue;
            }
            if(grid[i][j] == '#')
            {
                //cout<<"Inside null i:"<<i<<"j: "<<j<<endl;
                dp[i][j] = 0;
                //cout<<dp[i][j]<<endl;
            }
            else
            {
                if(i == n)
                {
                    //cout<<"Inside last row i:"<<i<<" j: "<<j<<endl;
                    dp[i][j] = (dp[i][j+1] + 0)%mod;
                    //cout<<dp[i][j]<<endl;
                }
                else if(j == m)
                {
                    //cout<<"Inside last column i:"<<i<<" j: "<<j<<endl;
                    dp[i][j] = (dp[i+1][j] + 0)%mod;
                    //cout<<dp[i][j]<<endl;
                }
                else
                {
                    dp[i][j] = (dp[i+1][j] + dp[i][j+1])%mod;
                    /*cout<<"Inside others i:"<<i<<" j: "<<j<<endl;
                    cout<<dp[i][j]<<endl;*/
                }
            }
        }
    }
    /*for(int i = n;i >= 1;i--)
    {
        for(int j = m;j >= 1;j--)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    return dp[1][1];
}
int main() {
    int n,m;
    cin>>n>>m;
    for(int i = 1;i <= n;i++)
    {
        for(int j = 1;j <= m;j++)
        {
            cin>>grid[i][j];
        }
    }
    cout<<solve(n,m);
}

Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define allR(x) (x).rbegin(), (x).rend()
using ll = long long;
using P = pair<int, int>;
const int INF = 2'000'000'000;

int main() {
  int a, b;
  cin >> a >> b;
  cout << a*b << endl;

  return 0;
}


Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
	private static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int m = sc.nextInt();
		char[][] a = new char[n][n];
		for (int i = 0;i < n;i++) {
			String s = sc.next();
			a[i] = s.toCharArray();
		}
		char[][] b = new char[m][m];
		for (int i = 0;i < m;i++) {
			String s = sc.next();
			b[i] = s.toCharArray();
		}

		for (int i = 0;i < n-m+1;i++) {
			for (int j = 0;j < n-m+1;j++) {
				boolean ret = true;
				for (int k = 0;k < m;k++) {
					for (int l = 0;l < m;l++) {
						if (a[i+k][j+l]!=b[k][l]) ret = false;
					}
				}
				if (ret) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  int n;cin>>n;
  vector<ll> a(n), ac(n+1);
  rep(i, n)cin>>a[i];

  ac[0]=0;
  rep(i,n)ac[i+1] = ac[i]+a[i];

  map<ll, ll> logger;
  logger[0]=1;
  ll result = 0;
  rep(i,n){
    auto k = ac[i+1];
    result += logger[k];
    logger[k]++;
  }

  cout<<result;

  return 0;
}

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

int main() {
  int n,m,x,y;
  cin>>n>>m>>x>>y;
  vector<int> a(n),b(m);
  for(int i=0; i<n; i++) cin>>a[i];
  for(int i=0; i<m; i++) cin>>b[i];
  sort(a.begin(),a.end(),greater<int>());
  sort(b.begin(),b.end());
  if(a[0]<b[0] && a[0]<y && b[0]>x) cout<<"No War";
  else cout<<"War";
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#include <cstdlib>
#include<bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;
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; }

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

int main(){
    int n; cin >> n;
    vector<double> a(n);
    double a_times = 1.0;
    rep(i, n){
        cin >> a[i];
        a_times *= a[i];
    }

    double a_sum=0.0;
    rep(j, n){
        a_sum += a_times/a[j];
    }
    cout << a_times/a_sum << endl;
}

Measured memory_bytes: 3744
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
#define mkp make_pair
typedef pair<int,int> pii;
int n,f[100004];
pair<pii,int> x[100004];
vector <pair<long long,pii> > g;
int Find(int x){return (f[x]==x)?x:f[x]=Find(f[x]);}
void UNION(int x,int y){x=Find(x),y=Find(y);f[x]=y;}
int main(){
	cin>>n;
	for (int i=0;i<n;i++) f[i]=i;
	for (int i=0;i<n;i++){
		x[i].second=i;
		cin>>x[i].first.first>>x[i].first.second;
	}
	sort (x,x+n);
	for (int i=1;i<n;i++)
		g.push_back(mkp(1ll*x[i].first.first-1ll*x[i-1].first.first,mkp(x[i].second,x[i-1].second)));
	for (int i=0;i<n;i++)
		swap(x[i].first.first,x[i].first.second);
	sort (x,x+n);
	for (int i=1;i<n;i++)
		g.push_back(mkp(1ll*x[i].first.first-1ll*x[i-1].first.first,mkp(x[i].second,x[i-1].second)));
	long long ans=0;
	sort (g.begin(),g.end());
	for (int i=0;i<g.size();i++){
		pair<long long,pii> u1=g[i];
		int o1=u1.second.first,o2=u1.second.second;
		if (Find(o1)==Find(o2)) continue;
		else ans+=u1.first;
		UNION(o1,o2);
	}
	cout<<ans;
}

Measured memory_bytes: 8048
#include<iostream>
using namespace std;
int N,ans;
void rec(long num,int flag){
  if(num>N)return;
  if(flag==7)ans++;
  rec(num*10+3,flag|1);
  rec(num*10+5,flag|2);
  rec(num*10+7,flag|4);
}
int main(){
  cin>>N;
  rec(0,0);
  cout<<ans<<endl;
}


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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    System.out.println(n%1000==0?0:Math.abs(1000-n%1000));
  }
}

Measured memory_bytes: 32440
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

	int sum=0;
	vector< P > ps[2];
	rep(i, n){
		cin>>s;
		int p=0;
		int mn=0;
		rep(j, s.length()){
			if(s[j]=='(') p++;
			else p--;
			mn=min(mn, p);
		}
		if(p>=0) ps[0].push_back(make_pair(mn, p));
		else{
			int rp= -p;
			int rmn= mn-p;
			ps[1].push_back(make_pair(rmn, rp));
		}
	}

	bool ok=true;
	int fc[2];
	rep(k, 2){
		int c=0;
		sort(ps[k].rbegin(), ps[k].rend());
		repit(it, ps[k]){
			int mn=it->first, d=it->second;
			if(c+mn<0) ok=false;
			c+=d;
		}
		fc[k]=c;
	}
	if(fc[0]!=fc[1]) ok=false;

	if(ok) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 11240
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	
	int n,a;
	int A = 0;
	int B = 0;

	vector<int> v[110];

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a;
		v->push_back(a);
	}
	sort(v->begin(), v->end(), std::greater<int>());

	for (int i = 0; i < n; i++) {
		if (i % 2 != 0 ) {
			B += v->at(i);
		}
		else{
			A += v->at(i);
		}
	}

	cout << A - B << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;

ll x,y;

int main(){
    scanf("%lld%lld", &x,&y);

    ll ans = 0;
    while(x <= y){
        ans++;
        x*=2;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 128
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int x,y;
  cin >> x >> y;

  int a,b;
  switch(x)
    {
      case 1:
      case 3:
      case 5:
      case 7:
      case 8:
      case 10:
      case 12:
        a = 1;
        break;
      case 4:
      case 6:
      case 9:
      case 11:
        a = 2;
        break;
      case 2:
        a = 3;
        break;
    }

  switch(y)
    {
      case 1:
      case 3:
      case 5:
      case 7:
      case 8:
      case 10:
      case 12:
        b = 1;
        break;
      case 4:
      case 6:
      case 9:
      case 11:
        b = 2;
        break;
      case 2:
        b = 3;
        break;
    }

    if(a == b) cout << "Yes";
    else cout<<"No";



  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int a = n/2 +1;
		
		if(n % 2 == 0) {
			System.out.println(0.5);
		}

		if(n % 2 == 1 && n!= 1) {
			System.out.println((double)a/n);
		}
		
		
		if(n== 1) {
			System.out.println(1);
		}
		
		
		

		sc.close();
	}
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main(){
  string A;
  cin>>A;
  int ans=0;
  if(A.at(0)!='C')ans++;
  if(A.at(1)!='O')ans++;
  if(A.at(2)!='D')ans++;
  if(A.at(3)!='E')ans++;
  if(A.at(4)!='F')ans++;
  if(A.at(5)!='E')ans++;
  if(A.at(6)!='S')ans++;
  if(A.at(7)!='T')ans++;
  if(A.at(8)!='I')ans++;
  if(A.at(9)!='V')ans++;
  if(A.at(10)!='A')ans++;
  if(A.at(11)!='L')ans++;
  if(A.at(12)!='2')ans++;
  if(A.at(13)!='0')ans++;
  if(A.at(14)!='1')ans++;
  if(A.at(15)!='6')ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 3580
using System;
using System.Linq;

namespace TBCB
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine().ToArray();
            var K = int.Parse(Console.ReadLine());
            

            for(var i = 0; i < N; i++)
            {
                if(S[K-1] != S[i])
                {
                    S[i] = '*';
                }
            }

            Console.WriteLine(S);
        }
    }
}


Measured memory_bytes: 13268
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll x;
int power(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}
main() {
  file("lala");
  ios;
  cin >> x;
  --x;
  fo(len, 1, INF1, 1) {
    if (power(26, len) > x) {
      string ans = "";
//      cerr << "CH " << len << "\n";
      fo(i, 1, len, 1) {
        char d;
        int y;
        for (int j = 0; j < 26; ++j) {
          if (j * power(26, len - i) <= x) {
            d = char(j + 'a');
            y = j;
          }
        }
        x -= (y) * power(26, len - i);
        ans += d;
      }
      cout << ans;
      return 0;
    }
    x -= power(26, len);
  }
  return 0;
}
/**

*/


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define F first
#define S second
#define MK make_pair
#define PB push_back




int main() {
int n, x, t;
cin>>n>>x>>t;
int minutes = 0;
while(n > 0)
{
    minutes += t;
    n -= x;
}
cout<<minutes<<endl;
    return 0;

}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,c=0;
	cin>>n;
	long long a[n],m=1e9+8;
	long long int s=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]<0) c++;
		m=min(m,abs(a[i]));
		s+=abs(a[i]);
	}
	if (c%2==1)
	{
		cout<<s-2*m;
	}
	else
	{
		cout<<s;
	}
	
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(int argc, const char * argv[]) {
    char ch[1200],c[1200];
    int n;
    n=0;
    while(1){
        scanf("%c",&c[n]);
        if(c[n]=='\n')break;
        ch[n] = c[n];
        if('a'<=ch[n]&&ch[n]<='z'){
            c[n] = ch[n] - 32;
        }else if('A'<=ch[n]&&ch[n]<='Z'){
            c[n] = ch[n] + 32;
        }
        n ++;
    }
    for(int i = 0 ; i <= n ; i++){
        printf("%c",c[i]);
    }
    return 0;
}



Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int a=s.nextInt();
		int b=s.nextInt();
		int k=s.nextInt();
		s.close();
		int num=100;
		int count=0;
		while(num>0){
			if((a%num==0)&&(b%num==0)){
				count++;
				if(count==k)break;
			}
			num--;
		}
		System.out.println(num);
	}
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,string> mp;
ll inf =  1e9;

int main(){
    string s,t;
    cin>>s>>t;
    int n1 = s.size(),n2 = t.size();
    vector<vector<int> > dp(n1+1 , vector<int>(n2+1, 0) );
    for(int i=1;i<=n1;i++){
	for(int j=1;j<=n2;j++){
	    if(s[i-1] == t[j-1] ){
		dp[i][j] = dp[i-1][j-1]+1; 
	    }else{
		dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
	    }
	}
    }
   // cout<<dp[n1][n2]<<endl;
   string ans="";
   int x = n1,y = n2;
   while( x>0 && y>0){
       if( dp[x][y] == dp[x-1][y]){
	   x--;
       }else if(dp[x][y] == dp[x][y-1]){
	   y--;
       }else{
	   x--,y--;
	   ans += s[x];
       }
   }
   reverse(ans.begin(),ans.end());
   cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
vector<int> x4 = {0, 1, 0, -1};
vector<int> y4 = {1, 0, -1, 0};
vector<int> x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


int main() {
  string s; cin >>s;
  string t = "";
  int n = s.size();
  if (n % 2 == 1){
    cout <<"No" <<endl;
  }else{
    n /= 2;
    rep(i, n){
      t += "hi";
    }
    if (s == t) cout <<"Yes" <<endl;
    else cout <<"No" <<endl;
  }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
	static final int MAX = 2_147_483_646; // intMax 
	static final int INF = 1_000_000_000; // 10^9  
	public static void main(String[] args) throws Exception{
		hayami saori = new hayami();
		char a = saori.nextHayami().charAt(0);
		if(Character.isUpperCase(a)){
			System.out.println("A");
		} else {
			System.out.println("a");
		}
		saori.close();
	}
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}


Measured memory_bytes: 32404
#include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>

using namespace std;

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

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

ll DP[2001][2001];

ll F[4000001];
ll I[4000001];

ll MOD = 1E9 + 7;

int power(int a, int b)
{
    int ret=1;
    for(; b>0; b/=2)
    {
        if(b&1)
            ret=1LL*ret*a%MOD;
        a=1LL*a*a%MOD;
    }
    return ret;
}

void init() {
	F[0] = 1;
	for (ll i = 1;i <= 4000000;i++) {
		F[i] = F[i - 1] * i;
		F[i] %= MOD;
	}
	I[4000000] = power(F[4000000], MOD - 2);
    for (ll i = 3999999;i >= 0;i--) {
        I[i] = I[i + 1] * (i + 1);
        I[i] %= MOD;
    }
	return;
}

ll nchoosek(int a, int b) {
	if (b == 0 || a == b) return 1;
	ll up = F[a];
	ll down = I[a - b] * I[b];
	down %= MOD;
	up *= down;
	return up %= MOD;
}

int main() {
    ios::sync_with_stdio(false);
    init();
    memset(DP, 0, sizeof(DP));
    DP[0][0] = 1;
    int N, K, T;
    cin >> N >> K;
    if (K == 1) {
    	cout << 1 << endl;
    	return 0;
    }
    T = N * K;
    for (int i = 0;i <= N;i++) {
    	// Opened Slot.
    	for (int j = 0;j <= i;j++) {
    		// Closed Slot.

    		if (i != N) {
    			// Open a slot.
    			DP[i + 1][j] += DP[i][j];
    			DP[i + 1][j] %= MOD;
    		}

    		if (i != j) {
    			// Close a slot.

    			// Choose One Color.
    			ll ans = (N - j);

    			ll rem = T - j * K - (i - j);

    			ans *= nchoosek(rem - 1, K - 2);
    			ans %= MOD;

    			ans *= DP[i][j];
    			ans %= MOD;

    			DP[i][j + 1] += ans;
    			DP[i][j + 1] %= MOD;
    		}

    	}
    }
    cout << DP[N][N] << endl;
    return 0;
}


Measured memory_bytes: 94080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

void solve() 
{   
    int n;cin>>n;
    vector<int>a(n);REP(i,n)cin>>a[i];
    stack<int>ans;
    REP(i,n){
        for(int j=a.size()-1;j>=0;j--){
            if(a[j]==j+1){ans.push(j+1);a.erase(a.begin()+j);break;}
        }
        if(a.size()==n-i){cout<<-1<<endl;return;}
    }
    while(!ans.empty()){
        cout<<ans.top()<<endl;ans.pop();
    }
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod = 1e9L+7;
int n;
vector<vector<int>> inp;
vector<vector<ll>> dp;
//set<int> taken;

ll recursive_matching(int i=0,int mask=0)
{   
    if(i == n) return 1;
    if(dp[i][mask] != -1) return dp[i][mask];

    ll ans = 0;
    for(int j=0;j<n;j++)
    {
        int f = 1 << j;
        if(inp[i][j] == 1 and (f & mask) == 0)
        {
            ans += recursive_matching(i+1,mask+f);
            ans%=mod;
        }
    }
    return dp[i][mask] = ans;
}

int main()
{
    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    //int k;
    cin>>n;//>>k;
    inp.resize(n+1,vector<int> (n+1));
    dp.assign(n,vector<ll> (1<<n,-1));

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

    //cout<<candp(k)<<'\n';
    cout<<recursive_matching()<<'\n';
    /*for(int i=0;i<n;i++)
    {
        for(int j=0;j<(1<<n);j++)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<'\n';
    }*/
}

Measured memory_bytes: 363812
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
unsigned long long n,a;
void DFS(unsigned long long x) {
        if (x==0) return;
        x--;
        DFS(x/26);
        cout<<(char) (x%26+'a');
        return;
}
signed main()
{
        // char ch;
        cin>>n;
        // n++;
        // a=sum=1;
        DFS(n);
        return 0;
}


Measured memory_bytes: 3088
n, m = map(int, input().split())

MOD = 10**9 + 7
if n == 1:
    print((m+1) % MOD)
else:
    k = m//(n-1)
    res = m+1 + 2*(m*k - k*(k+1)*(n-1)//2+k)
    print(res % MOD)

Measured memory_bytes: 7712
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type Scanner struct {
	reader *bufio.Scanner
}

func (s *Scanner) Next() string {
	s.reader.Scan()
	return s.reader.Text()
}

func (s *Scanner) NextInt() int {
	s.reader.Scan()
	val, err := strconv.Atoi(s.reader.Text())
	if err != nil {
		panic(err)
	}
	return val
}

var sc *Scanner

func init() {
	sc = &Scanner{bufio.NewScanner(os.Stdin)}
	sc.reader.Split(bufio.ScanWords)
}

func main() {
	s := sc.NextInt()
	h := s / 60 / 60
	m := (s / 60) % 60
	s = s % 60

	fmt.Printf("%v:%v:%v\n", h, m, s)
}



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

int r[4004];
int g[4004];
int b[4004];

int n;
unsigned long long int ans = 0;
char s[4004];

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

    int rc = 0, gc = 0, bc = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'R')
            rc++;
        else if (s[i] == 'G')
            gc++;
        else
            bc++;
        r[i] = rc;
        g[i] = gc;
        b[i] = bc;
    }

    for (int i = 0; i < n; i++)
    {
        for (int k = i + 1; k < n; k++)
        {
            if (s[k] == s[i])
                continue;
            if (((s[k] == 'R') && (s[i] == 'G')) ||
                ((s[k] == 'G') && (s[i] == 'R')))
            {
                ans += b[i];
                if (((i + i - k) >= 0) && (s[i + i - k] == 'B'))
                    ans--;
            }
            else if (((s[k] == 'B') && (s[i] == 'G')) ||
                     ((s[k] == 'G') && (s[i] == 'B')))
            {
                ans += r[i];
                if (((i + i - k) >= 0) && (s[i + i - k] == 'R'))
                    ans--;
            }
            else if (((s[k] == 'R') && (s[i] == 'B')) ||
                     ((s[k] == 'B') && (s[i] == 'R')))
            {
                ans += g[i];
                if (((i + i - k) >= 0) && (s[i + i - k] == 'G'))
                    ans--;
            }
            else
            {
            }
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m,ans = 0;
    cin >> n >> m;
    bool ret[m+10]={};
    for(int i=0;i<m;i++){
        ret[i] = true;
    }

    for(int i=0;i<n;i++){
        int k;
        cin >> k;
        int list[k]={};
        cerr << "list" << endl;
        for(int j =0;j<k;j++){
            int a;
            cin >> a;
            a--;
            list[j] = a;
            cerr << list[j] << " ";
        }
        cerr << endl;

        for(int j=0;j<m;j++){
            bool hoge = false;
            for(int l=0;l<k;l++){
                if(list[l] == j){
                    hoge = true;
                }
            }
            if(!hoge){
                ret[j] = false;
            }
        }
    
        cerr << "ret" << endl;
        for(int j =0;j<m;j++){
            cerr << ret[j] << " ";
        }
        cerr << endl;

    }

    for(int i= 0;i<m;i++){
        if(ret[i]){
            ans++;
        }
    }


    cout << ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int N,Q;
string s;
int L[100000],R[100000];
void solve(){
    int ac[N+1];
    ac[0] = 0;
    for(int i=1; i<N+1; i++){
        ac[i] = ac[i-1];
        if(s[i-1] == 'A'){
            if(s[i] == 'C'){
                ac[i+1] = ac[i]+1;
                i++;
            }
        }
    }
    for(int i=0; i<Q; i++){
        cout << ac[R[i]] - ac[L[i]] << endl;
    }
}
int main(){
    cin >> N >> Q >> s;
    for(int i=0; i<Q; i++){
        cin >> L[i] >> R[i];
    }
    solve();
    return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define REP(i,n) for((int)(i)=0;(i)<(int)(n);(i)++)
#define rep(i,n) for((int)(i)=0;(i)<(int)(n);(i)++)
#define forn(i,n,m) for((int)(i)=(n);i<=(int)(m);(i)++)
#define push_back pb
#define make_pair mp
using namespace std;
typedef long long ll;
typedef long double ld;
int N; 
int sum=0;
int main(){
	cin>>N;
	for(int i=1;i<=N;i++)
		if((i>=1&&i<=9)||(i>=100&&i<=999)||(i>=10000&&i<=99999))sum++;
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
// Problem : A - Number of Multiples
// Contest : AtCoder - AIsing Programming Contest 2020
// URL : https://atcoder.jp/contests/aising2020/tasks/aising2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define ios std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mii map<int, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=(int)x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
using namespace std;
const long long MOD=LLONG_MAX; //1e5+7;
int gcd(int x, int y)
{
	if(y==0) return x;
	else return gcd(y,x%y);
}
int power(int x, unsigned int y)  
{  
    int res = 1;
    x = x % MOD;
    if (x == 0) return 0;
  
    while (y > 0)  
    { 
        if (y & 1)  
            res = (res*x) % MOD;
        y = y>>1;
        x = (x*x) % MOD;  
    }  
    return res;  
}
void solve()
{
	float l,r,d;
	cin>>l>>r>>d;
	
	int x=ceil(l/d);
	int x2= r/d;
	
	cout<<max(x2-x+1,0ll)<<endl;
}

int32_t main()
{	
	ios;
	int t=1; 
	//cin>>t;
	while(t--) solve();
}

Measured memory_bytes: 3700
#include<stdio.h>

int main(void) {
	int ans = 0;
	int a;
	scanf("%d", &a);
	char N[51];
	scanf("%s", N);
	//N[a] = '\0';
	for (int m = 0; m < a - 2; m++) {
		if (N[m] == 'A') {
			
			if (N[m+1] == 'B') {
				
				if (N[m+2] == 'C') {
					ans++;
				}
			}
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
n=int(input())
a=list(map(int,input().split()))
a=[0]+a+[0]
cost=[]
for x in range(len(a)-1):
    cost.append(abs(a[x+1]-a[x]))
S=sum(cost)
change=[]
for y in range(1,n+1):
    change.append(abs(a[y+1]-a[y-1])-(cost[y-1]+cost[y]))
for i in range(n):
    print(S+change[i])


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

const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

long double a, b, x;

long double f(long double a, long double b, long double theta) {
    if(theta > PI / 2.0 - EPS) {
        return 0.0;
    }
    long double ret;
    if(a * tan(theta) <= b) {
        ret = a * a * b - a * a * a * tan(theta) / 2.0;
    } else {
        ret = b * b / tan(theta) * a / 2.0;
    }
    return ret;
}


int main() {
    cin >> a >> b >> x;
  	long double ok = PI / 2.0;
    long double ng = 0.0;
    for(int _ = 1; _ <= 100000; _++) {
        long double mid = (ok + ng) / 2.0;
        if(f(a, b, mid) < x) ok = mid;
        else ng = mid;
    }
    cout << fixed << setprecision(10) << ok / PI * 180 << endl;
    
    return 0;
}


Measured memory_bytes: 512
while(True):
    n = int(input())
    if n == -1: break
    p = 1150
    if   n < 10: print(4280-p)
    elif n < 20: p += 125*(n-10); print(4280-p)
    elif n < 30: p += 125*10; p += 140*(n-20); print(4280-p)
    else: p += 125*10; p += 140*10; p += 160*(n-30); print(4280-p)



Measured memory_bytes: 5584
#include <bits/stdc++.h>
#define FLASH ios_base::sync_with_stdio(0);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";
#define MAXN 200010

using namespace std;

ll n,d,a;
vector<pair<ll,ll> >massiv;

ll t[4*MAXN];
ll tadd[4*MAXN];

void build(ll v,ll l,ll r)
{
  if(l==r)
  {
	t[v]=massiv[l-1].second;
	return ;  
  }	
  ll mid=l+(r-l)/2;
  build(v*2,l,mid);
  build(v*2+1,mid+1,r);
  t[v]=min(t[v*2],t[v*2+1]);
}

void push(ll v,ll l,ll r)
{
  if(tadd[v]!=0)
  {
   t[v]+=tadd[v];
   if(l!=r)
   {
	 tadd[v*2]+=tadd[v];
	 tadd[v*2+1]+=tadd[v];   
   }
   tadd[v]=0;
  }
	
}

void update(ll v,ll l,ll r,ll nac,ll konec,ll x)
{
  push(v,l,r);
  if(l>konec || r<nac)return ;
  if(l>=nac && r<=konec)
  {
	tadd[v]+=x;
	push(v,l,r);
	return ;
  }	
  ll mid=l+(r-l)/2;
  update(v*2,l,mid,nac,konec,x);
  update(v*2+1,mid+1,r,nac,konec,x);
  t[v]=min(t[v*2],t[v*2+1]);
}


ll query(ll v,ll l,ll r,ll nac,ll konec)
{
  push(v,l,r);
  if(l>konec || r<nac)return LLONG_MAX;
  if(l>=nac && r<=konec)return t[v];
  ll mid=l+(r-l)/2;
  ll one=query(v*2,l,mid,nac,konec);
  ll two=query(v*2+1,mid+1,r,nac,konec);
  return min(one,two);	
}

int main(){
FLASH;
cin>>n>>d>>a;
for(ll i=1;i<=n;i++)
{
 ll x,y;
 cin>>x>>y;
 massiv.pb(mp(x,y));
}
sort(all(massiv));
build(1,1,n);
ll ans=0;
for(ll i=0;i<n;i++)
{
  ll xp=query(1,1,n,i+1,i+1);
  ll nac=i;
  ll konec=n-1;
  ll maxx=0;
  if(xp<=0)continue;
  while(nac<=konec)
  {
    ll mid=nac+(konec-nac)/2;
    if(massiv[mid].first-massiv[i].first<=2*d)
    {
	  maxx=max(maxx,mid);
	  nac=mid+1;	
    }  
    else konec=mid-1;
  }	
  ll kol;
  if(xp%a==0)kol=xp/a;
  else kol=xp/a+1;
  ans+=kol;
  update(1,1,n,i+1,maxx+1,-(a*kol));
  
}


cout<<ans<<endl;


return 0;
} 


Measured memory_bytes: 16620
#include<iostream>
using namespace std;
int main(){
  int w,a,b;cin >> w >> a >> b;
  if((a<=b && b<=a+w && a+w<=b+w)||(b<=a && a<=b+w && b+w<=a+w)) cout << 0 << endl;
  else if(a+w < b) cout << b-a-w << endl;
  else cout << a-b-w << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
const int Max = 1000;

char s[Max];

int main()
{
    int t = 0;
    stack<int> p;
    while(scanf("%s", s)!=EOF)
    {

        if(s[0]=='-')
        {
            int b = p.top(); p.pop();
            int a = p.top(); p.pop();
            int c = a-b;
            p.push(c);
        }
        else if(s[0]=='+')
        {
            int a = p.top(); p.pop();
            int b = p.top(); p.pop();
            int c = a+b;
            p.push(c);
        }
         else if(s[0]=='*')
        {
            int a = p.top(); p.pop();
            int b = p.top(); p.pop();
            int c = a*b;
            p.push(c);
        }
        else
        {
            int m = atoi(s);
            //cout << s << " " << m << endl;
            p.push(m);
        }
        //cout << p.top() << endl;
    }
    cout << p.top() << endl;
    while(!p.empty())
        p.pop();
    return 0;
}



Measured memory_bytes: 3252
# 正規表現を用いた解法
from re import match


# f = open("./16/input_c2_2.txt")


# def input():
#     return f.readline().rstrip()


def main():
    S = input()

    if match('(dreamer|eraser|erase|dream)+$', S):
        print("YES")
    else:
        print("NO")

        # while True:
        #     result_1 = search('dreamer$', S)
        #     result_2 = search('eraser$', S)
        #     result_3 = search('erase$', S)
        #     result_4 = search('dream$', S)

        #     if result_1:
        #         S = S[:result_1.start()]
        #     elif result_2:
        #         S = S[:result_2.start()]
        #     elif result_3:
        #         S = S[:result_3.start()]
        #     elif result_4:
        #         S = S[:result_4.start()]
        #     else:
        #         print("NO")
        #         break

        #     if len(S) == 0:
        #         print("YES")
        #         break


if __name__ == "__main__":
    main()


Measured memory_bytes: 6516
#include<cstdio>
int main(){
int fir,sec,f,x,n,maxnum;
  scanf("%d",&n);
  fir=0,sec=0;
  f=0;
  for(int i=0;i<n;i++){
  scanf("%d",&x);
    if(x>fir){
      maxnum=i;
      sec=fir;
      fir=x;
      f=0;
    }
    else if(x>sec){
      sec=x;
    }
    else if(x==fir){
      f++;
    }
  }
  if(f>0){
    for(int i=0;i<n;i++){
      printf("%d\n",fir);
    }
  }else{
    for(int i=0;i<n;i++){
      if(i==maxnum)
        printf("%d\n",sec);
      else printf("%d\n",fir);
    }
  }

return 0;}

Measured memory_bytes: 1536
def min_dist(x_b,y_b):
    s=0
    for x,y in zip(x_b,y_b):
        s+=abs(x-y)
    return s

def man_dist(x_b,y_b):
    s=0
    for x, y in zip(x_b,y_b):
        s+=(abs(x-y))**2
    return s**0.5

def che_dist(x_b,y_b):
    s=0
    for x,y in zip(x_b,y_b):
        s+=(abs(x-y))**3
    return s**(1/3)

def anf_dist(x_b,y_b):
    s=[abs(x-y) for x,y in zip(x_b,y_b)]
    return max(s)

n=int(input())
x_b=list(map(int,input().split()))
y_b=list(map(int,input().split()))

print(min_dist(x_b,y_b))
print(man_dist(x_b,y_b))
print(che_dist(x_b,y_b))
print(anf_dist(x_b,y_b))

Measured memory_bytes: 7856
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int binary_search(int n,ll *a,int i,ll trg){
  int l,r,mid;
  l=-1;
  r=n;
  
  if (a[i]>=0){
    while (r-l>1){
      mid=(l+r)/2;
      if (a[i]*a[mid] <= trg) l=mid;
      else r=mid;
    }
    if (l>=i) return l;
    else return l+1;
  }else{
    while (r-l>1){
      mid=(l+r+1)/2;
      if (a[i]*a[mid] <= trg) r=mid;
      else l=mid;
    }
    if (r<=i) return n-r-1;
    else return n-r;
  }
}

int main(void){
  int n,i;
  ll a[200010],k;
  cin >> n >> k;
  for (i=0;i<n;i++) cin >> a[i];
  sort(a,a+n);
  
  ll l,r,mid,s;
  l=-1e18;
  r=1e18;
  while (r-l>1){
    mid=(l+r)/2;
    s=0;
    for (i=0;i<n;i++){
      s+=binary_search(n,a,i,mid);
    }
    s/=2;
    if (s>=k) r=mid;
    else l=mid;
  }
  
  cout << r << endl;
  
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    vector<int> v[2];
    copy_n(istream_iterator<int>(cin), n, back_inserter(v[0]));
    copy_n(istream_iterator<int>(cin), m, back_inserter(v[1]));
    v[0].push_back(x);
    v[1].push_back(y);
    int mx = *(max_element(v[0].begin(), v[0].end()));
    int my = *(min_element(v[1].begin(), v[1].end()));
    cout << ((my > mx) ? "No War" : "War");
}

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

void Main()
{
  int N; cin >> N;
  int res = N%10;
  if (res==3) {cout << "bon" << endl;}
  else if (res==0 || res == 1 || res == 6 || res==8){
    cout << "pon" << endl;
  } else {
    cout << "hon" << endl;
  }
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

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

void dout() { std::cout << std::endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
	#ifdef DESH
		std::cout << H << ' ';
		dout(T...);
	#endif
}

typedef long long Long;

int main() {
	std::string s;
	std::cin >> s;
	
	Long sum = 0;
	
	std::vector<Long> a((int)s.size() + 1, 0);
	
	int i = 0;
	while (i < (int) s.size()) {
		while(i < (int) s.size() && s[i] == '>') {
			i++;
		}
		a[i] = 0;
		while (i < (int) s.size() && s[i] == '<') {
			a[i + 1] = std::max(a[i + 1], a[i] + 1);
			i++;
		}
	}
	
	i = s.size() - 1;
	while (i >= 0) {
		while(i >= 0 && s[i] == '<') {
			i--;
		}
		a[i + 1] = 0;
		while (i >= 0 && s[i] == '>') {
			a[i] = std::max(a[i], a[i + 1] + 1);
			i--;
		}
	}
	
	for (int x : a) {
		sum += x;
	}
	std::cout << sum;

	return 0;
}


Measured memory_bytes: 4740
from itertools import combinations

n=int(input())
d={'M':0,'A':0,'R':0,'C':0,'H':0}
for i in range(n):
  s=input()
  if s[0]=='M':
    d['M']+=1
  if s[0]=='A':
    d['A']+=1
  if s[0]=='R':
    d['R']+=1
  if s[0]=='C':
    d['C']+=1
  if s[0]=='H':
    d['H']+=1

ans=0
for i,j,k in combinations('MARCH',3):
  ans+=d[i]*d[j]*d[k]

print(ans)

Measured memory_bytes: 9136
import math

K = int(input())
li = []
ans = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        li.append(math.gcd(i,j))
for g in li:
    for k in range(1,K+1):
        ans += math.gcd(g,k)
print(ans)

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

int main(){
  int N, X; cin >> N >> X;
  vector<int> don(N);
  int count=0;
  for(int i=0;i<N;i++){
    cin >> don.at(i);
    count+=don.at(i);
  }
  sort(don.begin(), don.end());
  cout << N+(X-count)/don.at(0) << endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll N;
    cin >> N;
    ll a, b;
    for (ll i = sqrt(N); i > 0; i--)
    {
        if (N % i == 0)
        {
            a = N / i;
            break;
        }
    }
    b = N / a;
    cout << a + b - 2;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

var fac, ifac, inv []int

const mod int = int(1e9 + 7)

func main() {
	nmax := int(2e6)
	fac = make([]int, nmax+1)
	ifac = make([]int, nmax+1)
	inv = make([]int, nmax+1)

	fac[0], fac[1] = 1, 1
	ifac[0], ifac[1] = 1, 1
	inv[0], inv[1] = 1, 1
	for i := 2; i <= nmax; i++ {
		v := i % mod
		fac[i] = fac[i-1] * v % mod
		inv[i] = (mod - (mod/v)*inv[mod%v]%mod)
		ifac[i] = ifac[i-1] * inv[i] % mod
	}

	var X, Y int
	fmt.Scan(&X, &Y)
	s := 2*X - Y
	t := -X + 2*Y
	if s%3 != 0 || t%3 != 0 || s < 0 || t < 0 {
		fmt.Println(0)
		return
	}
	s /= 3
	t /= 3
	fmt.Println((fac[s+t] * ifac[s] % mod) * ifac[t] % mod)
}


Measured memory_bytes: 50320
open System

// prelude
let readStr () = stdin.ReadLine()

let read f () = readStr() |> f
let reads f () = readStr().Split() |> Array.map f

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let readPair f g () =
  let (a,b) = readStr().Split() |> pair
  (f a, g b)

let readTriple f g h () =
  let (a,b,c) = readStr().Split() |> triple
  (f a, g b, h c)

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start
let N = read int ()
let A = reads int ()

let k = A |> Set.ofArray |> Set.count

if k%2=0 then k-1 else k
|> printfn "%d"

Measured memory_bytes: 28104
import numpy as np
N, K = map(int, input().split())
P = (np.array(input().split(), dtype=np.int64) + 1) / 2

expect = P[:K].sum()
ans = expect
for i in range(K, N):
    expect += P[i] - P[i - K]
    ans = max(ans, expect)
print(ans)


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

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)

int main() {
  int a,b,x;
  cin>>a>>b>>x;

  double rad;
  double theta;

  if(x>=a*a*b/2){
    rad = atan(((a*a*b-x)*2.0)/(a*a*a));
  }
  else{
    rad = atan(a*b*b*1.0/(2*x));
  }
  
  theta = 180*rad/M_PI;
  cout<<setprecision(10)<<theta<<endl;
  return 0;
}


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

public class Main {
    public static void main(String args[]) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int r = Integer.parseInt(br.readLine());
	System.out.println(r * r);
    }
}

Measured memory_bytes: 21204