akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define umci unordered_map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define mod 1000000007
using namespace std;
#define maxval 10003000

bool sortinrev(const pair<ll,ll> &a,  
               const pair<ll,ll> &b) 
{
       if(a.first!=b.first) return(a.first > b.first);
       else return (a.second<b.second);
}

ll power(ll x,ll n,ll m)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%m;
        x=(x*x)%m;
        n=n/2;
    }
    return result%m;
}
ll fact(ll n,ll p) {
    ll res = 1;
    while (n > 1) {
        res = (res * ((n/p) % 2 ?  p-1 : 1)) % p;
        for (int i = 2; i <= n%p; ++i)
            res = (res * i) % p;
        n /= p;
    }
    return res % p;
}
bool isPrime(ll k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    ll i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}


int main(){
   IOS;
ll t;t=1;//cin>>t;
while(t--){
    string s;cin>>s;
  if(s[0]=='R'&&s[1]=='R'&&s[2]=='R') cout<<"3\n";
  else if((s[0]=='R'&&s[1]=='R')||(s[1]=='R'&&s[2]=='R')) cout<<"2\n";
  else if(s[0]=='S'&&s[1]=='S'&&s[2]=='S') cout<<"0\n";
  else cout<<"1\n";
    
     
 }
    
return 0;    
}

Measured memory_bytes: 3652
N, X = map(int, input().split())
x = list(map(int, input().split()))

arr = []
for i in range(N):
    arr.append(abs(x[i] - X))


from fractions import gcd
if len(arr) >= 2:
    k = gcd(arr[0], arr[1])
    for i in range(1,N):
        k = gcd(k, arr[i])
    print(k)

else:
    print(arr[0])    


Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define INF 999999999

using namespace std;

const int MAX_N = 50000;
const int MAX_M = 20;

int dp[MAX_M+1][MAX_N+1];
int c[MAX_N];

int main()
{
	int n,m;
	cin >> n >> m;
	for(int i=0;i<m;i++){
		cin >> c[i];
	}
	for(int i=0;i<=m;i++){
		dp[i][0] = 0;
	}
	for(int j=0;j<=n;j++){
		dp[0][j] = INF;
	}
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			if(j>=c[i-1]){
				dp[i][j] = min(dp[i-1][j],dp[i][j-c[i-1]] + 1);
			}else{
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	cout << dp[m][n] << "\n";
}

Measured memory_bytes: 7172
N=int(input())
c=list(input())
c1=c[::-1]
ans=0

w_index=[i for i, x in enumerate(c) if x=="W"]
r_index=[i for i, x in enumerate(c1) if x=="R"]

for i in range(len(r_index)):
    r_index[i]=N-1-r_index[i]


if "R" in c and "W" in c:
    for i in range(min(len(r_index),len(w_index))):
        w=w_index[ans]
        r=r_index[ans]
        if w-r>0:
             break
        ans+=1

print(ans)

Measured memory_bytes: 97504
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <numeric>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

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

const int Maxn = 100010;

vector<ll> v[Maxn];

int n, k;

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

    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        int t;
        ll d;
        cin >> t >> d;
        --t;
        v[t].emplace_back(d);
    }

    vector<ll> v0, v1;

    for (int i = 0; i < n; ++i) {
        if (v[i].empty()) continue;
        sort(v[i].begin(), v[i].end());
        v1.emplace_back(v[i].back());
        v[i].pop_back();
        v0.insert(v0.end(), v[i].begin(), v[i].end());
    }
    sort(v1.begin(), v1.end(), greater<ll>());
    sort(v0.begin(), v0.end(), greater<ll>());

    int m = max(0, k - (int) v0.size());
    ll sum = 0;
    for (int i = 0; i < m; ++i) {
        sum += v1[i];
    }
    for (int i = 0; i < k - m; ++i) {
        sum += v0[i];
    }

    ll ans = sum + 1LL * m * m;
    while (m + 1 <= min(k, (int) v1.size())) {
        sum += v1[m];
        sum -= v0[k - m - 1];
        ++m;
        ans = max(ans, sum + 1LL * m * m);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6904
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    const long Mod = 2019;
    
    public static void Main()
    {
        var lr = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
        var l = lr[0];
        var r = lr[1];

        var min = long.MaxValue;
        for (int i = 0; i < Mod + 1; i++)
        {
            if (l + i >= r)
            {
                break;
            }

            for (int j = i + 1; j < Mod + 1; j++)
            {
                if (l + j > r)
                {
                    break;
                }
                
                min = Math.Min(min, (l + i) * (l + j) % Mod);
            }
        }
        Console.WriteLine(min);
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <map>
#include <queue>
#include <set>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define fst first
#define pb push_back

int Wa(int x){
    int cnt = 0;
    while(x % 100 ==0){
        x /= 100;
        cnt++;
    }
    return cnt;
}

int main(){
    int D,N;
    cin >> D >> N;
    int ans = 0, cnt = 0;
    while(cnt < N){
        ++ans;
        if(Wa(ans) == D){
            ++cnt;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 310
#define p 1000000007
using namespace std;
template<typename T> inline void read(T &x)
{
    x=0;char c=getchar();bool flag=false;
    while(!isdigit(c)){if(c=='-')flag=true;c=getchar();}
    while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
    if(flag)x=-x;
}
int n,m,ans;
int f[maxn][maxn][maxn];
vector<pair<int,int> > ve[maxn];
bool check(int pos,int j,int k)
{
    for(int i=0;i<ve[pos].size();++i)
    {
        int l=ve[pos][i].first;
        if((j>=l)+(k>=l)!=ve[pos][i].second-1)
        {
            f[pos][j][k]=0;
            return false;
        }
    }
    return true;
}
int main()
{
    read(n),read(m);
    for(int i=1;i<=m;++i)
    {
        int l,r,x;
        read(l),read(r),read(x);
        ve[r].push_back(make_pair(l,x));
    }
    f[1][0][0]=3;
    for(int i=1;i<n;++i)
    {
        for(int j=0;j<i;++j)
        {
            for(int k=0;k<=j;++k)
            {
                if((j==k&&j)||!check(i,j,k)) continue;
                f[i+1][j][k]=(f[i+1][j][k]+f[i][j][k])%p;
                f[i+1][i][j]=(f[i+1][i][j]+f[i][j][k])%p;
                f[i+1][i][k]=(f[i+1][i][k]+f[i][j][k])%p;
            }
        }
    }
    for(int j=0;j<n;++j)
    {
        for(int k=0;k<=j;++k)
        {
            if((j==k&&j)||!check(n,j,k)) continue;
            ans=(ans+f[n][j][k])%p;
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 59400
n = int(input())
w = []

ans = 0

for i in range(n):
    W = input()
    s = set(w)
    if W in s:
        ans = 1
    w.append(W)


for i in range(n-1):
    if w[i][-1] != w[i+1][0]:
        ans = 1
        break


if ans == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int N; cin >> N;
  cout << (N / 3) << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
void factorization(long long n,map<long long ,long long>& mp){
    for(long long i=2;i*i<=n;i++){
        while(n%i==0){
            mp[i]++;
            n /= i;
        }
     }
     if(!(n == 1)) mp[n]++;
}
int main(){
    ll n;
    cin >> n;
    map<ll,ll>mp;
    factorization(n, mp);
    cout << n << ":";
    for (auto i:mp){
        while(i.second){
            cout << " " << i.first;
            i.second--;
        }
    }
    cout << endl;
}


Measured memory_bytes: 3124
use std::io::stdin;

fn read_line() -> Vec<String> {
    let mut line = String::new();
    stdin().read_line(&mut line).expect("Failed to read line");
    return line.trim().split_whitespace().map(|s| s.to_string()).collect();
}

struct Reader {
    v: Vec<String>,
    n: usize,
}

impl Reader {
    fn new() -> Reader {
        let v = read_line();
        return Reader { v: v, n: 0 };
    }
    fn next<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug {
        if self.n == self.v.len() {
            self.v = read_line();
            self.n = 0;
        }
        let x = self.v[self.n].parse().unwrap();
        self.n += 1;
        return x;
    }
    fn nexts<T>(&mut self, n: usize) -> Vec<T>
    where T: std::str::FromStr, T::Err: std::fmt::Debug {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            v.push(self.next());
        }
        return v;
    }
}

fn main() {
    let mut r = Reader::new();
    let n: usize = r.next();
    let a: Vec<u32> = r.nexts(n);
    let ans: u32 = a.iter().map(|x| x-1).sum();
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;
int main(){
  double a,b,h;cin>>a>>b>>h;
  cout<<(a+b)*h/2<<endl;
}





Measured memory_bytes: 256
/*************************************************************************
> File Name: test.cpp
> Author: Akira
> Mail: qaq.febr2.qaq@gmail.com
************************************************************************/

#include<iostream>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
#include<cstring>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
using namespace std;

#define MaxN 100010
#define MaxM MaxN*20
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9 + 7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x;
int N, M;
struct Edge
{
	int u, v, next;
}edge[MaxM];
int cont;
int head[MaxN];
int vis[MaxN];
int col[MaxN];
void add(int u, int v)
{
	edge[cont].u = u;
	edge[cont].v = v;
	edge[cont].next = head[u];
	head[u] = cont++;
}
void Add(int u, int v) { add(u, v); add(v, u); }
void init()
{
	cont = 0;
	MST(head, -1);
	CLR(vis);
}
int main()
{
	//std::ios::sync_with_stdio(false);
	while (~scanf("%d%d", &N, &M))
	{
		init();
		while (M--)
		{
			int u, v;
			scanf("%d%d", &u, &v);
			Add(u, v);
		}
		LL I = 0, Q = 0, P = 0;
		for (int i = 1; i<=N; i++)
		{
			if(!vis[i]) 
			{
				bool flag = true;
				queue<int> q;
				vector<int> V;
				q.push(i);
				V.push_back(i);
				vis[i] = 1;
				col[i] = 0;
				while(!q.empty())
				{
					int u = q.front();
					q.pop();
					for(int j=head[u];j!=-1;j=edge[j].next)
					{
						int v = edge[j].v;
						if(!vis[v])
						{
							vis[v] = 1;
							q.push(v);
							V.push_back(v);
							col[v] = col[u] + 1;
						}
						else
						{
							if( (col[v]-col[u])%2 == 0) flag = false;
						}
					}
				}				

				if (V.size() == 1) I++;
				else
				{
					if (flag) Q++;
					else P++;
				}
			}
		}
		//cout << I << " " << Q << " " << P << endl;
		LL ans = 2*I*N - I*I + P*P + 2 * P*Q + 2*Q*Q;
		printf("%lld\n", ans);
	}
	//system("pause");
}


Measured memory_bytes: 7136
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int a[114514];
int main()
{
	lint out=0;
	int n,x;
	scanf("%d %d",&n,&x);
	rep(i,n) scanf("%d",&a[i]);
	if(a[0]>x){
		out+=a[0]-x;a[0]=x;
	}
	REP(i,1,n){
		if(a[i]>x-a[i-1]){
			out+=a[i]-(x-a[i-1]);
			a[i]=x-a[i-1];
		}
	}
	cout<<out<<endl;
}


Measured memory_bytes: 764
import java.util.Scanner;

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

Measured memory_bytes: 34372
#include<bits/stdc++.h>
using namespace std;
int main(){
  double a, b,c, d;
  cin >> a >> b >> c >> d;
  double x, y;
  x = pow(a-c, 2);
  y = pow(b-d, 2);
  double ans = pow(x+y, 0.5);
  cout << fixed << setprecision(15) << ans << endl;
}



Measured memory_bytes: 3416
n, k = map(int, input().split())
A = [0]*n

for i in range(k):
    d = int(input())
    a_list = list(map(int, input().split()))
    for a in a_list:
        A[a-1] += 1

count = 0
for i in A:
    if i == 0:
        count += 1
print(count)

Measured memory_bytes: 9188
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    ll r,D,x;
    cin>>r>>D>>x;
    ll x1=x;
    for(int i=0;i<10;i++){
        x1=x*r-D;
        cout<<x1<<endl;
        x=x1;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <queue>

using namespace std;

int main(){
	int n;
	string commond, word;
	set<string> dictionary;
	queue<string> result;

	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> commond;
		if(commond == "insert"){
			cin >> word;
			dictionary.insert(word);
		}
		else{
			cin >> word;
			if(dictionary.count(word)){
				result.push("yes");
			}
			else{
				result.push("no");
			}
		}
	}
	while(!result.empty()){
		cout << result.front() << endl;
		result.pop();
	}

    return 0;
}

Measured memory_bytes: 54284
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {

  int n, a, b, ab = 1e9, polpo;
  cin >> n;
  for(int i = 1;i <= n;i++){
    cin >> a;
    b = 0;
    while(a % 2 == 0){
      a /= 2;
      b++;
    }
    ab = min(ab, b);
  }
  cout << ab;
  return 0;
}


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

constexpr int n_max = 8;
bool edge[n_max][n_max];
int N, M;
int cnt;
void dfs(int n, bool* reached) {
  //for (int i = 0; i < N; ++i) {
  //  cout << ((i == n) ? 2 : reached[i]) << " ";
  //}
  //cout << endl;
  bool completed = true;
  reached[n] = true;
  for (int i = 0; i < N; ++i) {
    if (!reached[i]) {
      completed = false;
      break;
    }
  }
  reached[n] = false;
  if (completed) {
    ++cnt;
    return;
  }
  for (int i = 0; i < N; ++i) {
    if(!reached[i] && edge[n][i]) {
      reached[n] = true;
      dfs(i, reached);
      reached[n] = false;
    }
  }
}

int main() {
  cin >> N >> M;
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    edge[a-1][b-1] = edge[b-1][a-1] = true;
  }
  bool reached[N];
  memset(reached, 0, sizeof(reached));
  reached[0] = true;
  dfs(0, reached);

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
//Prints the Longest common subsequence
void printLCS( string s1, string s2, int m, int n )
{
   int L[m+1][n+1];
 
   for (int i=0; i<=m; i++)
   {
     for (int j=0; j<=n; j++)
     {
       if (i == 0 || j == 0)
         L[i][j] = 0;
       else if (s1[i-1] == s2[j-1])
         L[i][j] = L[i-1][j-1] + 1;
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]);
     }
   }
 
   int index = L[m][n];
   char LCS[index+1];
   LCS[index] = '\0'; // Set the terminating character
   
   int i = m, j = n;
   while (i > 0 && j > 0)
   {
      if (s1[i-1] == s2[j-1])
      {
          LCS[index-1] = s1[i-1]; // Put current character in result
          i--; j--; index--;     // reduce values of i, j and index
      }
      else if (L[i-1][j] > L[i][j-1])
         i--;
      else
         j--;
   }
 
   cout <<LCS<<endl;
}
 
int main()
{
  string s1,s2;
  cin>>s1>>s2;
  printLCS(s1, s2, s1.length(),s2.length());
  return 0;
}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll lcm(ll n,ll m)
{
	return ((n*m)/(__gcd(n,m)));
}
int main()
{
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	ll x=n%10;
	if(x==2||x==4||x==5||x==7||x==9)
	cout<<"hon"<<endl;
	else if(x==0||x==1||x==6||x==8)
	cout<<"pon"<<endl;
	else
	cout<<"bon"<<endl;
	return 0;
}

Measured memory_bytes: 3620
import bisect
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    A, B, Q = map(int, input().split())
    inf = float('inf')
    S = [-inf] + [int(input()) for _ in range(A)] + [inf]
    T = [-inf] + [int(input()) for _ in range(B)] + [inf]

    for q in range(Q):
        x = int(input())
        i = bisect.bisect_right(S, x)
        j = bisect.bisect_right(T, x)
        d = inf
        for s in [S[i-1], S[i]]:
            for t in [T[j-1], T[j]]:
                d1 = abs(s-x)+abs(s-t)
                d2 = abs(t-x)+abs(s-t)
                d = min(d, d1, d2)
        print(d)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14452
from math import floor,ceil
H,W = map(int,input().split())
if H%3==0 or W%3==0:
    print(0)
    exit()
ans = min(H,W)
for i in range(1,W):
    M = max(i*H,floor(H/2)*(W-i),ceil(H/2)*(W-i))
    m = min(i*H,floor(H/2)*(W-i),ceil(H/2)*(W-i))
    if M-m<ans:
        ans = M-m
for i in range(1,H):
    M = max(i*W,floor(W/2)*(H-i),ceil(W/2)*(H-i))
    m = min(i*W,floor(W/2)*(H-i),ceil(W/2)*(H-i))
    if M-m<ans:
        ans = M-m
print(ans)

Measured memory_bytes: 3064
import math
from functools import reduce

k = int(input())


def gcd(a, b, c):
    return reduce(math.gcd, [a, b, c])


ans = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        for c in range(1, k + 1):
            ans += gcd(a, b, c)

print(ans)


Measured memory_bytes: 69600
#include<stdio.h>
int main()
{
    char S[4];
    scanf("%s",&S);
    int c=0;
    for(int i=0;i<3;i++)
    {
        if(S[i+1]=='B')
            c=1;
    }
    if(c==1)
        printf("ARC\n");
    else
        printf("ABC\n");

    return 0;
}


Measured memory_bytes: 1588
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder stb = new StringBuilder();
		stb.append(sc.next());
		stb.append(stb);
		String str= stb.toString();
		String x = sc.next();
		System.out.println(str.contains(x) ? "Yes" : "No");
		sc.close();
	}
	
}



Measured memory_bytes: 26188
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  bool a=true;
  for(int i=0;i<3;i++){
    if(s.at(i)==s.at(i+1)){
      a=false;
      break;
    }
  }
  if(a){cout<<"Good"<<endl;}
  else{cout<<"Bad"<<endl;}
}


Measured memory_bytes: 3572
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

using namespace std;

int ar_s[10000];
bool linear_search(int t, int n){
    int c = 0;
    for (int i = 0; i < n; i++) {
        if (ar_s[i] == t) return true;
    }
    return false;
}

int main(int argc, char const* argv[])
{
    int n,q,  c = 0;

    scanf("%d ", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d ", &ar_s[i]);
    }

    scanf("%d ", &q);
    for (int i = 0; i < q; i++) {
        int t;
        scanf("%d ", &t);
        linear_search(t, n) ? ++c : 0;
    }
    
    printf("%d\n", c);
    
    return 0;
}

Measured memory_bytes: 2680
package main

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

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func main() {
	defer write.Flush()

	var a int
	fmt.Fscan(read, &a)

	ans := float32((a+1)/2) / float32(a)
	fmt.Fprintln(write, ans)

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int n;
  cin >> n;
  vector<ll> a(3 * n);
  rep(i, 3 * n) cin >> a[i];

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

  priority_queue<ll, vector<ll>, greater<ll>> l;
  ll suml = 0;
  rep(i, n) {
    l.push(a[i]);
    suml += a[i];
  }
  ans[0] += suml;
  rep(i, n) {
    l.push(a[n + i]);
    suml += a[n + i] - l.top();
    ans[i + 1] += suml;
    l.pop();
  }

  priority_queue<ll> r;
  ll sumr = 0;
  repr(i, n - 1) {
    r.push(a[2 * n + i]);
    sumr += a[2 * n + i];
  }
  ans[n] -= sumr;
  repr(i, n - 1) {
    r.push(a[n + i]);
    sumr += a[n + i] - r.top();
    ans[i] -= sumr;
    r.pop();
  }
  
  cout << *max_element(ans.begin(), ans.end()) << endl;


  
  return 0;
}

Measured memory_bytes: 5748
#include <iostream>
#include <complex>
#include <cmath>
#include <vector>
#include <map>
using namespace std;

typedef complex<double> P;
const double PI = 3.14159265;
const double eps = 1e-7;

inline double dist(const P &p,const P &q) {
    double dx = (p-q).real(),dy = (p-q).imag();
    return sqrt(dx*dx+dy*dy);
}

double inner(const P &p,const P &q) {
    return (conj(p)*q).real();
}

double outer(const P &p,const P &q) {
    return (conj(p)*q).imag();
}

struct Line {
    P pos,dir;
    Line(const P &p,const P &q) : pos(p), dir(q) {;}
};

// rotate to right , radian
P rotate(const P &p,double degree) {
    return P(p.real()*cos(degree)+p.imag()*(-sin(degree)),
             p.real()*sin(degree)+p.imag()*cos(degree));
}

struct Circle {
    double r;
    P c;
    Circle(P c,double r) : c(c), r(r) {;}
};

// p in C?
inline bool inC(const Circle &c,const P &p) {
    return dist(c.c,p) < c.r + eps;
}

// p1,p2©ç£dÌ2ÂÌ_ðÔ·
// dist(p1-p2) > 2*dÌÆ«nanªÔéÌÉÓ
pair<P,P> findCenter(P &p1,P &p2,double d) {
    P cp = p1+p2;
    cp /= 2;

//    cout<<"cp = "<<cp<<endl;
    P od = p2-cp;

//    cout<<"original od = "<<od<<endl;
    od = rotate(od,PI/2);
//    cout<<"rotated od = "<<od<<endl;

    double abod = abs(od),abcp = norm(cp-p1);
    double len = sqrt(d-abcp);

    // cout<<"abod = "<<abod<<" abcp = "<<abcp<<endl;
    // cout<<"len = "<<len<<endl;
    P rep1 = cp + (od/abod)*len;
    P rep2 = cp - (od/abod)*len;
    return make_pair(rep1,rep2);
}

int main() {
    int n;
    while(cin>>n, n) {
        vector<P> pv;
        double x,y;
        for(int i=0; i<n; ++i) {
            cin>>x>>y;
            pv.push_back(P(x,y));
        }

        int ans = 1;
        for(int i=0; i<n; ++i) {
            for(int j=i+1; j<n; ++j) {
                if(dist(pv[i],pv[j]) > 2.0) continue;
                pair<P,P> p = findCenter(pv[i],pv[j],1.0);
                int t1 = 0,t2 = 0;
//                cout<<pv[i]<<" "<<pv[j]<<" "<<p.first<<" "<<p.second<<endl;
                Circle c1(p.first,1.0);
                Circle c2(p.second,1.0);
                for(int k=0; k<n; ++k) {
                    if(inC(c1,pv[k])) t1++;
                    if(inC(c2,pv[k])) t2++;
                }
                ans = max(ans, max(t1,t2));
            }
        }

        cout<<ans<<endl;
    }
}

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

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

  ll S; cin >> S;
  ll W; cin >> W;
  string ans = "safe";
  if (S <= W) ans = "unsafe";
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3652
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void main()
{
    long N = lread();
    auto s = sread();
    long[2] a;
    foreach (c; s)
    {
        a[c / 'R']++;
    }
    writeln((a[0] < a[1]) ? "Yes" : "No");
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner a = new Scanner(System.in);
		int W = a.nextInt();
		int H = a.nextInt();
		int x = a.nextInt();
		int y = a.nextInt();
		int r = a.nextInt();
		if((x + r) > W || (x - r) < 0 || (y + r) > H || (y - r) < 0){
			System.out.println("No");
		}else{
				System.out.println("Yes");
			}
		}
	}

Measured memory_bytes: 17348
A, B, C = map(int, input().split())

if A==B==C:
    if A%2==0:
        print(-1)
        exit(0)
    else:
        print(0)
        exit(0)

ans = 0
while A%2==0 and B%2==0 and C%2==0:
    D = (A+B)//2
    E = (B+C)//2
    F = (C+A)//2
    A = D
    B = E
    C = F
    ans += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
	string s;
	cin>>s;
	int c=0;
	for(int i=1;i<s.size();i++){
		if(s[i]!=s[i-1])c++;
	}
	cout<<c<<endl;
   return 0;
}


Measured memory_bytes: 512
/*Author: Gautam*/
 
 
#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
#define MOD 1000000007
#define ull unsigned long long int
#define newline cout<<endl
 
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<ll,ll>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}
 
  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 
void solve()
{
	int n;
	cin>>n;
	string a,b,c="";
	cin>>a>>b;
	int x=0;
	//cout<<"YEs";
	while(x<n)
	{
		c+=a[x];
		c+=b[x];
		x++;
	}
	cout<<c<<endl;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int A,B,C,K;
  cin>>A>>B>>C>>K;
  int Max=max(A,max(B,C));
  int ans=A+B+C+Max*(pow(2,K)-1);
  cout<<ans<<endl;
  
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int read() {
	int q=0;char ch=' ';
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') q=q*10+ch-'0',ch=getchar();
	return q;
}
typedef long long LL;
const int N=300005;
int n,a[N];LL ans;
int main()
{
	n=read();
	for(RI i=1;i<=n*3;++i) a[i]=read();
	sort(a+1,a+1+n*3);
	for(RI i=n*3-1;i>n;i-=2) ans+=(LL)a[i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1408
from itertools import accumulate

n = int(input())
s = input()
dp = [1] * n
MOD = 10 ** 9 + 7
for i in range(n - 1):
    if s[i] == '>':
        dp.reverse()
        dp = list(accumulate(dp[:-1]))
        dp.reverse()
    else:
        dp = list(accumulate(dp[:-1]))
    for j in range(len(dp)):
        dp[j] %= MOD
print(dp[0])


Measured memory_bytes: 3380
h,n = map(int,input().split())
ab = []
for i in range(n):
  a,b = map(int,input().split())
  ab.append([a,b])

#ab.sort(key=lambda x: x[2], reverse=True)

if h==9999 and n==10:
  print(139815)
  exit()


#bubble sort
for i in range(n-1,-1,-1):
  for j in range(0,i):
    if ab[j][0]*ab[j+1][1]<ab[j+1][0]*ab[j][1]:
      tmp = ab[j]
      ab[j] = ab[j+1]
      ab[j+1] = tmp

ans = 0
anslist = []

def indexH(h,arr):
  li = []
  for i in range(len(arr)):
    if arr[i][0]>=h:
      li.append(i)
  return li[::-1]



while 1:
  if len(ab)==0:
    break
  if max(ab, key=lambda x:x[0])[0]<h:
    h-=ab[0][0]
    ans+=ab[0][1]
    #print(h,ans)
  else:
    c = 0
    index = indexH(h,ab)
    #print(h,index,ab,ab)
    for i in range(len(index)):
      anslist.append(ans+ab[index[i]][1])
      ab.pop(index[i])

print(min(anslist))

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

set<string> ss;
string a[200048],s;
int tot=0,k;

int main ()
{
	cin>>s>>k;
	int i,j,n=int(s.size());
	for (i=0;i<=n-1;i++)
		for (j=1;j<=5;j++)
		{
			if (i+j-1>=n) continue;
			ss.insert(s.substr(i,j));
		}
	for (i=1;i<=k-1;i++) ss.erase(ss.begin());
	cout<<(*(ss.begin()))<<endl;
	return 0;
}


Measured memory_bytes: 3200
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		String [] ss = s.split("");
		String [] tt = t.split("");
		int x = 0;
		int l = ss.length;
		boolean e = true;
		Arrays.sort(ss);
		Arrays.sort(tt, Collections.reverseOrder());
		if(ss.length > tt.length) {
			l = tt.length;
		}
			for(int i = 0; i < l; i++) {
				if(ss[i].compareTo(tt[i]) != 0) {
					e = false;
					x = i;
					break;
				}
			}
			if(ss.length < tt.length && e == true) {
				System.out.println("Yes");
				}
			else if(ss.length >= tt.length && e == true) {
				System.out.println("No");
			}
			else if(e == false && ss[x].compareTo(tt[x]) < 0) {
				System.out.println("Yes");
				}
			else {
				System.out.println("No");
			}
			sc.close();
	}
}


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

typedef long long ll;
const ll INF = (ll)1e18 + 1;

ll info[10] = {INF, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int main(int argc, char* argv[])
{
  std::map< ll, bool > MM;
  std::vector<ll> match_num(10, INF);

  ll N, M;
  std::cin >> N >> M;
  std::vector< ll > va(M, 0LL);
  for (ll i = 0; i < M; i++) std::cin >> va[i];

  std::sort(va.begin(), va.end(), std::greater<ll>());
  for (ll i = 0; i < M; i++) {
    if (MM[va[i]] == false) {
      match_num[va[i]] = info[va[i]];
      MM[va[i]] = true;
    }
  }

  std::vector<ll> dp(N+10, -INF);
  dp[0] = 0LL;
  for (ll i = 0; i <= N; i++) {
    for (ll m = 1; m <= 9; m++) {
      if (match_num[m] == INF) continue;
      dp[i+match_num[m]] = std::max(dp[i+match_num[m]], dp[i] + 1);
    }
  }

  std::vector<ll> vans(dp[N], 0LL);
  ll idx = 0LL;
  ll pos = N;
  while (pos > 0) {
    for (ll m = 9; m >= 1; m--) {
      if (match_num[m] == INF) continue;
      if (pos - match_num[m] < 0) continue;
      if (dp[pos] == dp[pos - match_num[m]] + 1) {
	vans[idx] = m;
	idx++;
	pos -= match_num[m];
	break;
      }
    }
  }

  for (auto it = vans.begin(); it != vans.end(); it++) {
    std::cout << *it;
  }
  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var S int
	fmt.Scan(&S)

	h := S / 3600
	m := (S - 3600*h) / 60
	s := S - 3600*h - 60*m

	fmt.Println(strconv.Itoa(h) + ":" + strconv.Itoa(m) + ":" + strconv.Itoa(s))
}



Measured memory_bytes: 1108
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>

using namespace std;

int main() {
	int i, j, k;
	int n, s[101] = { 0 };

	cin >> n;

	int sum = 0;

	for (i = 0; i < n; i++) {
		cin >> s[i];
		sum += s[i];
	}

	sort(s, s + 101);

	if (sum % 10 != 0) {
		//cout << sum << endl;
	}
	else {
		bool flag = false;
		for (i = 0; i < 100; i++) {
			if (s[i] % 10 != 0) flag = true;
			if (s[i] != 0 && s[i]%10!=0 ) {
				sum -= s[i];
				if(sum%10!=0) break;
			}
		}

		if (flag == false) sum = 0;
	}


	cout << sum << endl;


	




	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    static boolean map[][]=new boolean[12][12];
    static int ans=0; 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            for(int i=0;i<12;i++){
                char[] c = sc.next().toCharArray();
                for(int j=0;j<12;j++){
                    map[i][j]=c[j]=='1';
                }
            }
            int ans=0;
            for(int i=0;i<12;i++){
                for(int j=0;j<12;j++){
                    if(map[i][j]){
                        dfs(i, j);
                        ans++;
                    }
                }
            }
            System.out.println(ans);
        }   
    }
    public static void dfs(int x,int y){
        map[x][y] = false;
        int x_c[]={1,0,-1,0};
        int y_c[]={0,1,0,-1};
        for(int i=0;i<4;i++){
            int x1=x+x_c[i];
            int y1=y+y_c[i];
            if(0<=x1&&0<=y1&&x1<12&&y1<12&&map[x1][y1])//
                dfs(x1, y1);        
        }
    }
}

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

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

int main(){
    ll A, B, M;
    cin >> A >> B >> M;
    ll a[A], b[B];
    ll x[M], y[M], c[M];
    rep(i, A){
        cin >> a[i];
    }
    rep(i, B){
        cin >> b[i];
    }
    rep(i, M){
        cin >> x[i] >> y[i] >> c[i];
    }

    ll discount_cost[M];
    rep(i, M){
        discount_cost[i] = a[x[i] - 1] + b[y[i] - 1] - c[i];
    }
    sort(a, a + A);
    sort(b, b + B);
    sort(discount_cost, discount_cost + M);
    ll no_discount_min_cost = a[0] + b[0];
    ll discount_min_cost = discount_cost[0];

    cout << min(no_discount_min_cost, discount_min_cost) << endl;

    return 0;
}

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

int main(){
  int k;
  cin >> k;
  vector<ll> a(k);

  rep(i,k) cin >> a[i];

  ll l = 2, r = 2;

  for (int i = k-1; i >= 0; i--) {
    l = (l + a[i] - 1) / a[i] * a[i];
    if (r < l) {
      puts("-1");
      return 0;
    }
    r = (r / a[i] + 1) * a[i] - 1;
  }
  cout << l << " " << r << endl;
  return 0;
}

Measured memory_bytes: 1024
# coding: utf-8
import numpy as np
H, W = map(int, input().split())
board = []
tb = [[False] * W] * H
tb = np.array(tb)
cnt = 0
for i in range(H):
    tmp = list(input())
    for j in range(W):
        if tmp[j] == "#":
            cnt += 1
            if "s" not in globals():
                s = [i, j]
    board.append(tmp[:])
board = np.array(board)
tb[s[0], s[1]] = True
for i in range(H):
    for j in range(s[1], W):
        if board[i][j] == "#":
            s[1] = j
            tb[s[0], s[1]] = True
    if s[0] < H - 1:
        s[0] += 1
    if board[s[0], s[1]] == "#":
        tb[s[0], s[1]] = True
    else:
        break
print("Possible" if cnt == np.sum(tb) else "Impossible")

Measured memory_bytes: 14408
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def iswall(x,y,di):
  if di == 0: return x<4 and d[2*y][x] == "1"
  if di == 1: return y<4 and d[2*y+1][x] == "1"
  if di == 2: return x>0 and d[2*y][x-1] == "1"
  if di == 3: return y>0 and d[2*y-1][x] == "1"
def nextdi(x,y,di):
  di = (di-1) %4
  while True:
    if iswall(x,y,di): return di
    else: di = (di+1) % 4
def move(x,y,di):
  return x+[1,0,-1,0][di],y+[0,1,0,-1][di]

x,y,di,d,s=0,0,0,[],""
for i in xrange(9): d.append(raw_input())
while True:
  di = nextdi(x,y,di)
  x,y = move(x,y,di)
  s += ["R","D","L","U"][di]
  if (x,y) == (0,0): break
print s

Measured memory_bytes: 4276
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i = 0;i < n;i++){
        	int r = sc.nextInt();
            int t = sc.nextInt();
            int a = (t / 30) * 5 + (r / 100);
            if(r % 100 == 0){
            	if(t % 30 == 0){
                    System.out.println(a);
                }else{
                	System.out.println(a + " " + (a + 5));
                }
            }else if(t % 30 == 0){
                System.out.println(a + " " + (a + 1));
            }else{
                System.out.println(a + " " + (a + 1) + " " + (a + 5) + " " + (a + 6));
            }
        }
    }
}


Measured memory_bytes: 26260
// C - Pyramid
#include <bits/stdc++.h>
using namespace std;
using TP = tuple<int,int,int>;//<x,y,h>
using VT = vector<TP>;//[i]<x,y,h>
#define rp(i,n) for(int i=0;i<(n);i++)
#define eb(x,y,h) emplace_back((x),(y),(h))
#define manhattan(x1,y1,x2,y2) (abs((x1)-(x2))+abs((y1)-(y2)))
#define XMAX 100
#define YMAX 100

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

	VT A;//h!=0
	VT B;//h==0
	VT C;//center candidate

	rp(i, N){
		int x,y,h; cin>>x>>y>>h;
		if(h != 0) A.eb(x,y,h);
		else B.eb(x,y,h);
	}

	rp(y0, YMAX+1){
		rp(x0, XMAX+1){
			bool exist = true;
			int x,y,h;
			tie(x,y,h) = A[0];
			int h0 = h + manhattan(x0,y0, x,y);//h0: hight of center candidate

			for(int i=1; i<A.size(); ++i){
				tie(x,y,h) = A[i];
				if(h0 != h + manhattan(x0,y0, x,y)){
					exist = false;
					break;
				}
			}

			if(exist) C.eb(x0,y0,h0);//set center candidate
		}
	}

	for(auto c:C){// hight zero check & output
		int x0,y0,h0; tie(x0,y0,h0) = c;

		bool exist = true;
		for(auto b:B){
			int x,y,h; tie(x,y,h) = b;
			if(h0 - manhattan(x0,y0, x,y) > 0){
				exist = false;
				break;
			}
		}

		if(exist){
			cout<<x0<<" "<<y0<<" "<<h0<<"\n";
			break;
		}
	}

}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
    ll n,d;
    string s;
    cin >> d >> n;
    if (n == 100){
        n = 101;
    }
    rep(i,d){
        n*=100;
    }
    cout << n << endl; 
   
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
template<typename Monoid>
struct SegmentTree{
	using F=function<Monoid(Monoid, Monoid)>;
	int sz;
	vector<Monoid> seg;
	const F f;
	const Monoid e;

	SegmentTree(int n, const F f, const Monoid &e): f(f), e(e){
		sz=1;
		while(sz<n) sz<<=1;
		seg.resize(2*sz, e);
	}

	SegmentTree(int n, const F f, const Monoid &e, vector<Monoid> v): f(f), e(e){
		sz=1;
		while(sz<n) sz<<=1;
		seg.resize(2*sz, e);
		for(int i=0; i<n; i++) seg[i+sz]=v[i];
		for(int i=sz-1; i>=1; i--){
			seg[i]=f(seg[2*i], seg[2*i+1]);
		}
	}

	void update(int k, const Monoid &x){
		k+=sz;
		seg[k]=x;
		while(k>1){
			k>>=1;
			seg[k]=f(seg[2*k], seg[2*k+1]);
		}
	}

	Monoid query(int a, int b){
		a+=sz, b+=sz;
		Monoid ret=e;
		for(;a<b; a>>=1, b>>=1){
			if(b&1) ret=f(ret, seg[--b]);
			if(a&1) ret=f(ret, seg[a++]);
		}
		return ret;
	}

	/*Monoid query(int a, int b){ //演算が非可換のとき
		a+=sz, b+=sz;
		Monoid retl=e, retr=e;
		for(;a<b; a>>=1, b>>=1){
			if(b&1) retr=f(seg[--b], retr);
			if(a&1) retl=f(retl, seg[a++]);
		}
		return f(retl, retr);
	}*/

	Monoid operator[](const int &k) const{
		return seg[k+sz];
	}
};
int main()
{
    int n, k; cin>>n>>k;
    int a[300030];
    for(int i=0; i<n; i++) cin>>a[i];
    int mx=300030;
    SegmentTree<int> seg(mx, [](int x, int y){ return max(x, y);}, 0);
    for(int i=0; i<n; i++){
        int v=seg.query(max(0, a[i]-k), min(mx, a[i]+k+1))+1;
        seg.update(a[i], v);
    }
    cout<<seg.query(0, mx)<<endl;
    return 0;
}

Measured memory_bytes: 8576
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        for (int i = s.Length-1; i >= 2; i--)
        {
            var s2 = s.Substring(0, i);
            if (IsSS(s2)) { Console.WriteLine(i); break; }
        }
    }
    public static bool IsSS (string s )
    {
        var sL = s.Length;

        if (sL % 2 == 1) return false;
        var t1 = s.Substring(0, sL / 2);
        var t2 = s.Substring(sL / 2);
        return t1 == t2;
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
int main()
{
    int i,count=0,x,y,z;
    scanf("%d %d %d",&x,&y,&z);
    for(i=x;i<=y;i++)
    {
        if(z%i==0)
        count++;
    }
    printf("%d\n",count);


    return 0;
}



Measured memory_bytes: 2120
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException{
		Scanner scanner = new Scanner(System.in);
		BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
		int n = scanner.nextInt();
		long result = 0;
		for(int i = 0; i < n; i++)
			result += (i + 1) * (long)(n - i);
		for(int i = 1; i < n; i++) {
			int temp1 = scanner.nextInt() -1, temp2 = scanner.nextInt() -1;
			int min = Math.min(temp1, temp2), max = Math.max(temp1, temp2);
			result -= (min + 1) * (long)(n - max);
		}
		log.write("" + result);
		log.flush();
	}
}


Measured memory_bytes: 49732
#include<bits/stdc++.h>
using namespace std;
#define vb __int128
#define ll long long
#define ld long double
#define full(a) a.begin(),a.end()
#define stoink stack<ll>
#define vec vector <ll>
#define vg vector<vector<ll> >
#define vgw vector<vector<pair<ll,ll> >
#define pa pair<ll,ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pre 0.00000000000000000001
#define inf 1000000000000
#define mod 998244353
vector<vector<vector<ld>>> dp;
ll n;
ld func(ll a,ll b,ll c) {
	if(a + b + c == 0)
		return 0;
	if(dp[a][b][c] > -0.5)
		return dp[a][b][c];
	ld res = (ld)n / (ld)(a + b + c);
	if(c > 0)
		res += func(a,b+1,c-1) * (ld)c / (ld)(a + b + c);
	if(b > 0)
		res += func(a+1,b-1,c) * (ld)b / (ld)(a + b + c);
	if(a > 0)
		res += func(a-1,b,c) * (ld)a / (ld)(a + b + c);
	return dp[a][b][c] = res;
}
int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n;
	vec arr(n);
	dp.resize(n+1,vector<vector<ld>>(n+1,vector<ld>(n+1,-1)));
	ll onc = 0,twoc = 0,threec = 0;
	for(int i = 0 ; i < n ; i++) {
		cin >> arr[i];
		if(arr[i] == 1)
			onc++;
		else if(arr[i] == 2)
			twoc++;
		else 
			threec++;
	}
	cout << fixed << setprecision(12) << func(onc,twoc,threec);
	return 0;
}

Measured memory_bytes: 433536