akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.math.BigDecimal;



public class Main{
       public static void main(String[] args){
       int i,j,a,b,c,d,e,f;
       double s,t;
    	double[] x = new double[1000];
    	double[] y = new double[1000];
    
        Scanner scan = new Scanner(System.in);
        

       
        i = 0;
        while(scan.hasNextInt()){
        	a = scan.nextInt();
        	b = scan.nextInt();
        	c = scan.nextInt();
        	d = scan.nextInt();
        	e = scan.nextInt();
        	f = scan.nextInt();
        	
        	x[i] = (double)(b*f-c*e)/(b*d-a*e);
        	y[i] = (double)(a*f-c*d)/(a*e-b*d);
        	
        	BigDecimal bx = new BigDecimal(String.valueOf(x[i]));
			BigDecimal by = new BigDecimal(String.valueOf(y[i]));
        	x[i] = bx.setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
        	y[i] = by.setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();

        	
     		
        	i++;
        }
      
        
        j = 0;
        while(j < i){
        	System.out.printf("%.3f",x[j]);
     		System.out.print(" ");
     		System.out.printf("%.3f",y[j]);
     		System.out.println();
        	j++;
       		}
       		}
}

Measured memory_bytes: 26528
a=input()

i = 0
j = 0

while a != a[::-1]:
	if(a[i]!=a[len(a) - i - 1]):
		sList = list(a)
		sList[i] = sList[len(a) - i - 1]
		a = "".join(sList)
		j += 1
	i += 1

print(j)

Measured memory_bytes: 2940
# -*- coding: utf-8 -*-

def solve(N, S):
    x = 0
    X = []
    for i in range(N):
        if(S[i]=="I"):
            x += 1
            X.append(x)
        else:
            x -= 1
            X.append(x)
    print(max(X) if max(X)>0 else 0)
    

if __name__ == '__main__':
    N = int(input())
    S = input()
    
    solve(N, S)

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt(), H = sc.nextInt(), x = sc.nextInt(), y = sc.nextInt(), r = sc.nextInt();


        if (x - r < 0 || y - r < 0 || W < x + r || H < y + r) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 26384
#include<stdio.h>

int main()
{
int i,i2,a=1,b=1,c=0;
for(i2=1;i2<=9;i2++)
{
for(i=1;i<=9;i++)
 {
c=a*b;
printf("%dx%d=%d\n",a,b,c);

b=b+1;
}
b=1;
a=a+1;
}
    return 0;
}

Measured memory_bytes: 524
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
using namespace std;

typedef long long ll;

ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

int main(){
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	for(int i=0;i<n;i++){
		cout<<s[i]<<t[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 384
//AtCoder1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream> 
#include <algorithm>
#include <math.h> 
#include <vector>
#include <string>
using namespace std;

int main()
{
    int n; 
    string a;
    cin >> n;
    a = to_string(n);
    for (int i = 0; i <= 2; i++) {
        if (a[i] == '1') {
            a[i] = '9';
            
        }
        else if (a[i] == '9') { a[i] = '1';}
       
    }
    cout << a << endl;
}


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

struct SpecialNum{
    long long value;
    bool index3;
    bool index5;
    bool index7;
    SpecialNum(long long v,bool i3,bool i5,bool i7): value(v),index3(i3),index5(i5),index7(i7) {}
};


void LianXianDan(int &sum,SpecialNum x,int T){
    long long v=x.value;
    bool index3=x.index3;
    bool index5=x.index5;
    bool index7=x.index7;
    if(v>T){
        return;
    }
    else if(v<=T){
        if(index3 && index5 && index7)
            sum++;
        long long v3=v*10+3;
        SpecialNum x3=SpecialNum(v3,true,index5,index7);
        long long v5=v*10+5;
        SpecialNum x5=SpecialNum(v5,index3,true,index7);
        long long v7=v*10+7;
        SpecialNum x7=SpecialNum(v7,index3,index5,true);
        LianXianDan(sum,x3,T);
        LianXianDan(sum,x5,T);
        LianXianDan(sum,x7,T);
        return;
    }
}

int main()
{
    int T;
    while(cin>>T){
        SpecialNum x1=SpecialNum(0,false,false,false);
        int sum=0;
        LianXianDan(sum,x1,T);
        cout<<sum<<endl;
    }
    return 0;
}



Measured memory_bytes: 888
#pragma GCC optimize (3)
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define PII pair<int,int>
#define ll long long
#define ull unsigned long long
#define INFI 2147483647
#define INFL 9223372036854775807
#define INFU 18446744073709551615
#define maxn 3010
using namespace std;
using namespace __gnu_pbds;
const double PI=acos(-1.0);
const double eps=1e-6;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0' || ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
int l[maxn];
int main()
{
	//ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    int n;
    while(cin>>n){
        memset(l,0,sizeof(l));
        for(int i=0;i<n;i++) scanf("%d",&l[i]);
        sort(l,l+n);
        //for(int i=0;i<n;i++) printf("%d ",l[i]);
        //cout<<endl;
        int ans=0;
        for(int i=0;i<=n-3;i++){
            for(int j=i+1;j<=n-2;j++){
                int sum=l[i]+l[j];
                int pos=lower_bound(l+j+1,l+n,sum)-l;
                //printf("sum=%d,pos=%d\n",sum,pos);
                if(pos==0);
                else ans+=(pos-j-1);
            }
        }
        cout<<ans<<endl;
    }
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-07-29 16:31:41 +0900
# LastModified: 2020-07-29 16:49:31 +0900
#


def main():
    S = sorted(input())
    T = sorted(input(), reverse=True)
    sorted_S = ""
    sorted_T = ""
    for s in S:
        sorted_S += s
    for t in T:
        sorted_T += t
    if sorted_S < sorted_T:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(5e2 + 5);
const int MAX_M = (int)(2e5 + 5);
const int MAX_Q = (int)(1e5 + 5);

int n, m, q;

int s[MAX_N][MAX_N];

int main(void) {
  // Here your code !
  scanf("%d %d %d", &n, &m, &q);

  for (int i = 0; i < m; ++i) {
    int l, r;
    scanf("%d %d", &l, &r);
    s[l][r] += 1;
  }

  // for (int i = 0; i <= n; ++i) {
  //   for (int j = 0; j <= n; ++j) {
  //     printf("%d ", s[i][j]);
  //   }
  //   printf("\n");
  // }

  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) {
      s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + s[i][j];
    }

  // for (int i = 0; i <= n; ++i) {
  //   for (int j = 0; j <= n; ++j) {
  //     printf("%d ", s[i][j]);
  //   }
  //   printf("\n");
  // }

  for (int i = 0; i < q; ++i) {
    int p, q;
    scanf("%d %d", &p, &q);

    int ans = s[q][q] - s[p - 1][q] - s[q][p - 1] + s[p - 1][p - 1];

    printf("%d\n", ans);
  }

  return 0;
}


Measured memory_bytes: 1920
from itertools import accumulate
from collections import deque

N, K, *P = map(int, open(0).read().split())

mi = []
Q = deque()
for i, p in enumerate(P):
    while Q and P[Q[-1]] > p:
        Q.pop()
    Q.append(i)
    if Q[0] == i - K:
        Q.popleft()
    mi.append(Q[0])

ma = []
Q = deque()
for i, p in enumerate(P):
    while Q and P[Q[-1]] < p:
        Q.pop()
    Q.append(i)
    if Q[0] == i - K:
        Q.popleft()
    ma.append(Q[0])

mi = mi[K - 1:]
ma = ma[K - 1:]

B = [mi[i] != i or ma[i + 1] != i + K for i in range(N - K)]

A = [0] + list(accumulate(x < y for x, y in zip(P, P[1:])))
S = [y - x != K - 1 for x, y in zip(A, A[K - 1:])]

ans = 1 + sum(b for b, s in zip(B, S[1:]) if s)
if S[0] and not all(S):
    ans += 1
print(ans)


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

int main() {
    string s; cin >> s;
    set<char> st;
    int dif = 1;
    int cnt = 0;

    rep(i, 4) {
        st.insert(s.at(i));
    } 
    if (st.size() != 2) {
        cout << "No" << endl;
        return 0;
    }
    cnt = 0;
    for (int i = 0; i < 4; i++) {
        if (s.at(0) == s.at(i))
            cnt++;
    }
    if (cnt == 2) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll h,w,a,b;
  cin >> h >> w >> a >> b;

  cout << h*w-a*w-b*h+a*b << endl;



}

Measured memory_bytes: 3568
//
//  main.cpp
//  ITP1_1
//
//  Created by Saicj on 2015/07/13.
//  Copyright (c) 2015??´ saicj. All rights reserved.
//

#include <iostream>

int main()
{

    int second;
    
    std::cin >> second;
    
    //1h??? 3600s
    
    
    
    int time = second / 3600;
    int minute = (second - time * 3600) / 60;
    second = second % 60;
    
    std::cout << time << ":" << minute << ":" << second << "\n";
    return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <stack>
#include <queue>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using ld = long double;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll K, N, i, A[200001], max=0, a;

    cin >> K >> N;

    for(i=1; i<=N; i++){
        cin >> A[i];
    }

    for(i=1; i<=N-1; i++){
        a = labs(A[i]-A[i+1]);
        chmax(max, a);
    }
    a = A[1]+K-A[N];
    chmax(max, a);

    cout << K-max << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>

int main() {
  int n; std::cin >> n;
  std::vector<int> d(n, 0);
  for (int i = 0; i < n; ++i) {
    int a, b; std::cin >> a >> b;
    d[i] = (a == b);
  }
  bool ok = false;
  for (int i = 0; i < n-2; ++i) {
    if (d[i] + d[i+1] + d[i+2] == 3) ok = true;
  }
  if (ok) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  
  return 0;
} 

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define rev(a,b,c) for(int a=b;a>=c;a--)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define F first
#define S second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define get(a) cin>>a
#define nextl cout<<"\n"
#define deb(x) cout<<#x<<"="<<x<<"\n";
const ll mod = 1000000007;
const ll maxn = 500005;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
ll ncr(ll n, ll k)
{
    ll C[k+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, k); j > 0; j--)
            C[j] = (C[j] + C[j-1])%mod;
    }
    return C[k];
}
void solve()
{
    string s;
    cin>>s;
    int n=s.len;
    int x=0;
    rep0(i,n/2){
        if(s[i]!=s[n-1-i]) x++;
    }
    pr(x);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nextl;
    }
    return 0;
}


Measured memory_bytes: 256
s = input()

# https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2019/0817_agc037

ans = 0
prev = ''
i = 0
while i < len(s):
    c = s[i]
    # 前の文字と現在の文字が同じ
    if c == prev:
        i += 1
        if i == len(s):
            break
        # 2文字になる
        c += s[i]
    prev = c
    i += 1  # 次の文字へ進む
    ans += 1

print(ans)


Measured memory_bytes: 3500
fn main() {
    let input = read::<String>();
    let input = input.replace("eraser", "");
    let input = input.replace("erase", "");
    let input = input.replace("dreamer", "");
    let input = input.replace("dream", "");
    if input == "" {
        println!("YES");
    } else {
        println!("NO");
    }
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

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

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int ans = 1;
int dsu[MAXn],sz[MAXn];
int fnd(int x){
    if (dsu[x] == x) return x;
    return dsu[x] = fnd(dsu[x]);
}
void mrg(int x,int y){
    x = fnd(x), y = fnd(y);
    if (x == y) return;
    if (sz[x] < sz[y]) swap(x,y);
    dsu[y] = x;
    sz[x] += sz[y];
    ans = max(ans,sz[x]);
}
int main(){
    IOS();
    int n,m;
    cin >> n >> m;
    for (int i=0;i<n;++i) {
        dsu[i] = i, sz[i] = 1;
    }
    for (int i=0;i<m;++i) {
        int u,v;
        cin >> u >> v;
        u--, v--;
        mrg(u,v);
    }
    cout << ans << endl;
}


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

typedef long long ll;

int main(){
	ll n;
	scanf("%lld", &n);
	ll ans = n-1;
	for (ll i=2; i*i<=n; i++){
		if(n%i == 0){
			ans = min(ans, (i-1 + n/i-1));
		}
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BC
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  [a, b] <- map readInt . BC.words <$> BC.getLine
  print $ solve a b

solve :: Int -> Int -> Int
solve a b = h - a where
  h = ts !! (b - a - 2)
  ts = scanl1 (+) [1 .. 999]

readInt :: BC.ByteString -> Int
readInt = fst . fromJust . BC.readInt


Measured memory_bytes: 636
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <string.h>
 
#define rep(i,n)    for(ll i=0;i<n;i++)
#define repu(i,k,n) for(ll i=k;i<=n;i++)
#define repd(i,k,n) for(ll i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl "\n"
#define INF (ll)ll_MAX
 
typedef long long ll;
typedef long double ld;
typedef std::pair<ll, ll> pii;
typedef std::vector< ll > vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, ll > > vpp;
 
const ll N = 3*1e5 +5 ;
const long long MOD = 1000000007;
const long long MOD2 = 998244353;
const long long inf = 1e18;
 
using namespace std;

// ll g[200000], ig[200000];



bool ok;

void dfs1(ll u, bool vis[], ll tot[], ll p[],ll h[], vll v[]){
    if(vis[u]==1) return;
    vis[u] = 1;

    ll sum = 0;

    sum += p[u];

    ll sorr = 0;

    for(ll i=1;i<v[u].size();i++){
        // cout<<'a';
        dfs1(v[u][i],vis,tot,p,h,v);
        sum+= tot[v[u][i]];
        sorr = sorr +  tot[v[u][i]] - h[v[u][i]];
    }

    // cout<<sum;

    tot[u] = sum;

    // if(tot[u]-h[u]>sorr){
    //     cout<<tot[u]-h[u]<<' '<<sorr<<'\n';
    //     ok = false;
    //     // cout<<"NOOOOO";
    // }

    return;

}

void dfs2(ll u, bool vis[], ll tot[], ll p[],ll h[], vll v[]){
    if(vis[u]==1) return;
    vis[u] = 1;

    // ll sum = 0;

    // sum += p[u];

    ll sorr = 0;

    for(ll i=1;i<v[u].size();i++){
        // cout<<'a';
        dfs2(v[u][i],vis,tot,p,h,v);
        // sum+= tot[v[u][i]];
        sorr = sorr +  tot[v[u][i]] - h[v[u][i]];
    }

    // cout<<sum;

    // tot[u] = sum;

    // cout<<sorr<<endl;

    if(tot[u]-h[u]>sorr + 2*p[u]){
        // cout<<u<<' '<<tot[u]-h[u]<<' '<<sorr<<'\n';
        ok = false;
        // cout<<"NOOOOO";
    }

    if((tot[u]-h[u])%2==1){
        ok = false;
    }

    if(h[u]>(tot[u]) or h[u]<(-tot[u])){
        ok = false;
    }

    return;

}


int dfs(int u,vector< vector< ll> > &v, bool vis[], vector <ll> &ans, int n){
    if(vis[u]==1)
        return 0;
    vis[u] = 1;

    int num = 0;
    for(int i=0;i<v[u].size();i++){
        int y = dfs(v[u][i],v,vis,ans,n);
        if(y) ans.pb(y);
        num+= y;
    }
    num++;

    return num;
}


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

    for(auto i:s){
        ans += i-'0';
        ans %= 9;
    }

    if(ans){
        cout<<"No";
    }
    else{
        cout<<"Yes";
    }

}

int main() {


    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif


    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll t = 1;
    // cin>>t;
    ll ctr=0;
    while(t--)
    {   
        ctr++;
        // cout<<"Case #"<<ctr<<": ";
        solve();    
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
 
}

Measured memory_bytes: 3868
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)2e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

int main(){
	int n;
	cin >> n;
	int k;
	cin >> k;
	int ans = 0;
	rep(i, n){
		int d;
		cin >> d;
		if(d>=k)++ans;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
S = input()

if len(S) % 2 == 0:
    l = len(S) // 2
    o = l
else:
    l = (len(S) // 2) + 1
    o = l - 1 
ans = 0
R = S[:o]
L = S[l:][::-1]
for i in range(o):
    if R[i] != L[i]:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#define max(a,b) ((a)>(b) ? (a) : (b))
#define max3(a,b,c) max(max((a), (b)),(c))
main(){
    int n,m,N;
    int i,j;
    int h,r;
    int map[1000][1000]={{0,},};
    while(scanf("%d",&n)==1){
        for(i=0;i<1000;i++)
            for(j=0;j<1000;j++)
                map[i][j]=0;
        if(!n)break;
        for(i=0;i<n;i++){
            scanf("%d %d",&h,&r);
            map[h][r]=1;
        }
        scanf("%d",&m);
        for(;i<n+m;i++){
            scanf("%d %d",&h,&r);
            map[h][r]=1;
        }
        for(i=1;i<1000;i++){
            for(j=1;j<1000;j++){
                map[i][j]=max3(map[i][j]+map[i-1][j-1],map[i-1][j],map[i][j-1]);
            }
        }
        printf("%d\n",map[999][999]);
    }
    return 0;
}

Measured memory_bytes: 4512
import fractions
from functools import reduce

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

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def count_factorize(n):
    counter = 0
    while n % 2 == 0:
        counter += 1
        n //= 2
    return counter

mod = count_factorize(a[0])
for i in range(1, n):
    if count_factorize(a[i]) != mod:
        print(0)
        exit()
lcm_a = lcm(*a)
print(m // (lcm_a//2) - m // lcm_a)


Measured memory_bytes: 16344
#include<iostream>
#include<vector>
#include<queue>
#include<cstdio>

using namespace std;

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

typedef pair<double, pair<int, int> > State;

int main() {
  while (true) {
    int n, m, p, a, b, t[10];
    cin >> n >> m >> p >> a >> b;
    if (n == 0 && m == 0 && p == 0 && a == 0 && b == 0) break;
    --a; --b;
    rep (i, n) cin >> t[i];
    vector<pair<int, double> > edge[m];
    rep (i, p) {
      int x, y, z;
      cin >> x >> y >> z;
      --x; --y;
      edge[x].push_back(make_pair(y, z));
      edge[y].push_back(make_pair(x, z));
    }
    priority_queue<State, vector<State>, greater<State> > que;
    que.push(make_pair(0, make_pair(a, (1 << n) - 1)));
    double dis[30][1 << 8];
    rep (i, 30) rep (j, 1 << 8) dis[i][j] = 1e100;
    while (!que.empty()) {
      State now = que.top();
      que.pop();
      if (dis[now.second.first][now.second.second] <= now.first) continue;
      dis[now.second.first][now.second.second] = now.first;
      rep (i, edge[now.second.first].size()) {
	rep (j, n) if (now.second.second & 1 << j) {
	  State state;
	  state.first = now.first + edge[now.second.first][i].second / t[j];
	  state.second.first = edge[now.second.first][i].first;
	  state.second.second = now.second.second ^ 1 << j;
	  que.push(state);
	}
      }
    }
    double res = 1e99;
    rep (i, 1 << 8) res = min(res, dis[b][i]);
    if (res == 1e99) cout << "Impossible" << endl;
    else printf("%.12f\n", res);
  }
  return 0;
}

Measured memory_bytes: 19068
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<(int)N;i++)
int main()
{
  int A,B,C,D;
  string x,op1,op2,op3;
  queue<int> q;
  cin>>x;
  rep(i,x.size()){q.push(x.at(i)-'0');}
  A=q.front();q.pop();
  B=q.front();q.pop();
  C=q.front();q.pop();
  D=q.front();q.pop();
  rep(i,2){rep(j,2){rep(k,2){
    if(i==1){op1="-";}else{op1="+";}
    if(j==1){op2="-";}else{op2="+";}
    if(k==1){op3="-";}else{op3="+";}
    if(A+pow(-1.0,(float)i)*B+pow(-1.0,(float)j)*C+pow(-1.0,(float)k)*D==7.0){cout<<A<<op1<<B<<op2<<C<<op3<<D<<"=7"<<endl;return 0;}
  }}}
}

Measured memory_bytes: 256
<?php
  $n = trim(fgets(STDIN));
  $array = explode(' ', trim(fgets(STDIN)));
  $max = $n - 1;
  $total = 0;
  for ($i = 0; $i < $max; $i++) {
    $x = $array[$i];
    if ($x == 0) {
      continue;
    }
    for($j = $i+1; $j < $n; $j++) {
      $total += $x * $array[$j];
    }
  }
  echo $total . PHP_EOL;

Measured memory_bytes: 4604
import math

N,A,B=map(int,input().split())
total=(10 ** 100) + 1

firstCnt=math.floor(N/(A+B))

for i in range(firstCnt,total):
  if N <= i*A + i*B :
    if N >= i*A + (i-1)*B :
      ans=i*A
      break
    else :
      ans=i*A - (i*A+(i-1)*B - N)
      break
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;



int L;

int main() {
	ios_base::sync_with_stdio(false);
	cin >> L;
	L--;
	vector<int> decomp3;
	int val = L;
	while (val) {
		decomp3.pb(val % 3);
		val /= 3;
	}
	vector<pair<pair<int, int>, int> > ret;
	
	int N = 20;
	int idx = N - decomp3.sz;
	
	LL pow3[20];
	pow3[0] = 1;
	ffor (i, 1, 20)
		pow3[i] = pow3[i - 1] * 3;


	int len = decomp3.sz;
	int weight = decomp3[len - 1] * pow3[len - 1];
	
	ret.pb(make_pair(make_pair(1, idx), 0));
	ret.pb(make_pair(make_pair(1, idx + 1), 0));
	if (decomp3[len - 1] > 1)
		ret.pb(make_pair(make_pair(1, idx + 1), pow3[len - 1]));

	
	int lastPow = 1;
	for (int pos = N - 1; pos > idx; pos--)	{
		ret.pb(make_pair(make_pair(pos, pos + 1), 0));
		ret.pb(make_pair(make_pair(pos, pos + 1), lastPow));
		ret.pb(make_pair(make_pair(pos, pos + 1), lastPow * 2));
		
		lastPow *= 3;
	}
	
/*	FOR (i, decomp3.sz)
		cout << decomp3[i];
	cout << endl;*/
	
	lastPow = pow3[len - 1] / 3;
	int add = 2;
	for (int i = len - 2; i > -1; i--) {
		if (decomp3[i] > 0)
			ret.pb(make_pair(make_pair(idx, min(N, idx + add)), weight));
		
		if (decomp3[i] > 1)
			ret.pb(make_pair(make_pair(idx, min(N, idx + add)), weight + lastPow));
		
		weight += decomp3[i] * lastPow;
		lastPow /= 3;
		add++;
	}
	ret.pb(make_pair(make_pair(idx, N), weight));	
	
	int M = ret.sz;
	
	cout << N << " " << M << endl;
	FOR (i, M)
		cout << ret[i].first.first << " " << ret[i].first.second << " " << ret[i].second << endl;
	return 0;
}

Measured memory_bytes: 256
w = input()
d = {}
for i in range(len(w)):
  if w[i] not in d.keys():
    d[w[i]] = 1
  else:
    d[w[i]] += 1

for v in d.values():
  if v%2 != 0:
    print("No")
    exit()
print("Yes")


Measured memory_bytes: 9032
#include <stdio.h>

int main(){
   char s[11];
   int i,j,m;

   scanf("%s",s);
   for (m=j=i=0;s[i]!='\0';i++)
      if (s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T') j++;
      else {
         if (j>m) m=j;
         j=0;
      }
   if (j>m) m=j;
   printf("%d\n",m);
   return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
pair<int,int> a[200000];
int main(){
    int n;
    cin>>n;
    for(int i =1;i<=n;i++){
        cin>>a[i].first;
        a[i].second = i;
    }
    sort(a+1,a+n+1);
    for(int i = 1;i<=n;i++){
        cout<<a[i].second<<" ";
    }
}

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

int main() {
   int N, min_j;
   cin >> N;
   vector<int> A(N);
   int count = 0;

   for(int i=0; i<N; i++) cin >>A[i];
   
   for(int i=0; i<N-1; i++) {
      min_j=i;
      for(int j=i; j<N; j++) {
         if(A[j] < A[min_j]) min_j = j;
      }
      swap(A[i], A[min_j]);
      if(i != min_j) count++;
   }

   if (count <= 1) {
      cout << "YES" << endl;
   }
   else cout<< "NO" << endl;
}

Measured memory_bytes: 3628
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 500005;

int n;
char a[MAX];

int main(void) {
//	in = fopen("A.in", "rt");
	
	fscanf(in, "%s", a);
	n = (int)strlen(a);
	
	int lastValue = 0;
	long long sum = 0;
	for (int i = 0; i < n; i++) {
	    if (a[i] == '<') {
	        int cntInc = 1;
	        while (i + 1 < n && a[i + 1] == '<') {
	            i++;
	            cntInc++;
            }
            sum += (long long)cntInc * (cntInc + 1) / 2;
            lastValue = cntInc;
        } else {
            int cntDec = 1;
            while (i + 1 < n && a[i + 1] == '>') {
                i++;
                cntDec++;
            }
            sum += (long long)cntDec * (cntDec + 1) / 2;
            sum -= min(cntDec, lastValue);
            lastValue = 0;
        }
    }
    fprintf(out, "%lld\n", sum);
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
//*******************
// Mahmoud Magdy    *
//*******************
#define ll long long
#define endl "\n"

void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m ;
    cin>>m;
    return m ;
}
int main()
{
    ll a=lD(),b=lD(),x=lD();
    ll sum=(b/x)-(a/x);
    if(a%x==0)
        sum++;
    cout<<sum<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int m;
	cin >> m;
	cout << 24 + 24 - m << endl;
	return 0;
}

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

ll a[85], dp[85]={};

int main() {
	int N;
	cin >> N;
	for(int i=0; i<N; ++i) cin >> a[i];
	dp[0]=1000;
	for(int i=0; i<N; ++i){
		ll p=dp[i]/a[i], q=dp[i]%a[i];
		dp[i+1]=max(dp[i+1], dp[i]);
		for(int j=i+1; j<N; ++j){
			dp[j+1]=max(dp[j+1], a[j]*p+q);
		}
	}
	cout << dp[N] << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define INF 1145141919
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long int ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}

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;
}

////////////////////////////////////////////////////////////////////
int main()
{

    int N; cin >> N;
    vector<int> h(N);
    REP(i,N) cin >> h[i];

    ll dp[100001];
    for(int i=0; i<100001; ++i) dp[i]=INF;

    dp[0]=0;
    REP(i,N){

        chmin(dp[i], dp[i-1]+abs(h[i]-h[i-1]));
        chmin(dp[i], dp[i-2]+abs(h[i]-h[i-2]));

    }

    cout << dp[N-1] << endl;

    return 0;
}


Measured memory_bytes: 1408
#define _USE_MATH_DEFINES
#define INF 100000000
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double EPS = 1e-8;

int path[101][101];

int dijkstra(int s,int g,int n){
	int d[101];
	bool used[101];
	memset(d,0x3f,sizeof(d));
	memset(used,0,sizeof(used));
	d[s] = 0;
	
	while(1){
		int v=-1;
		for(int u=1;u<=n;u++){
			if(!used[u] && (v==-1 || d[u] < d[v])) v=u;
		}

		if(v==-1) break;

		used[v] = true;

		for(int u=1;u<=n;u++){
			d[u] = min(d[u],d[v] + path[v][u]);
		}
	}

	return d[g];
}

int main(){
	int n,k;

	while(~scanf("%d %d",&n,&k)){
		if(n==k && k==0) break;
		memset(path,0x3f,sizeof(path));
		for(int i=0;i<k;i++){
			int ch;
			scanf("%d",&ch);
			if(ch){
				int a,b,val;
				scanf("%d %d %d",&a,&b,&val);
				path[a][b] = path[b][a] = min(val,path[a][b]);
			}
			else{
				int a,b,res;
				scanf("%d %d",&a,&b);
				res = dijkstra(a,b,n);
				printf("%d\n",res > INF ? -1 : res);

			}
		}
	}
}

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

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

using namespace std;

void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int a, b;
	string s, t;
	cin>> s >> t;

	if(s.size()+1==t.size()){
		t.pop_back();
		if(s==t){
			cout<< "Yes" << endl;
			return 0;
		}
	}

	cout<< "No" << endl;
 
	return 0;
}

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

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

class Dice{
private:
  int tmp;
public:
  int d[6];
 
  void rollN(){
    tmp = d[0];
    d[0] = d[1];
    d[1] = d[5];
    d[5] = d[4];
    d[4] = tmp;
  }
  
  void rollE(){
    tmp = d[0];
    d[0] = d[3];
    d[3] = d[5];
    d[5] = d[2];
    d[2] = tmp;
  }
 
  void rollS(){
    tmp = d[0];
    d[0] = d[4];
    d[4] = d[5];
    d[5] = d[1];
    d[1] = tmp;
  }
 
  void rollW(){
    tmp = d[0];
    d[0] = d[2];
    d[2] = d[5];
    d[5] = d[3];
    d[3] = tmp;
  }

  void rotation(){
    tmp = d[1];
    d[1] = d[3];
    d[3] = d[4];
    d[4] = d[2];
    d[2] = tmp;
  }

  int getRight(int top,int front){
    rep(i,3){
      rollN();
      if(top == d[0]){
        break;
      }
      rollW();
      if(top == d[0]){
        break;
      }
    }
    rep(i,3){
      if(front == d[1]){
        break;
      }
      rotation();
    }

    return d[2];
  }

  bool judge(Dice &D){
    rep(i,6){
      if(d[i] != D.d[i]){
        return false;
      }
    }
    return true;
  }

  bool equals(Dice &D){
    rep(i,3){
      rollN();
      if(d[0] == D.d[0]){
        break;
      }
      rollW();
      if(d[0] == D.d[0]){
        break;
      }
    }
    rep(i,4){
      if(judge(D)){
        return true;
      }
      rotation();
    }
    return false;
  }
};
 
int main(){
  Dice dice1,dice2;
 
  rep(i,6){
    cin >> dice1.d[i];
  }
  rep(i,6){
    cin >> dice2.d[i];
  }
  cout << (dice1.equals(dice2) ? "Yes" : "No") << endl;
 
  return 0;
}

Measured memory_bytes: 1160
using System;

namespace abc115
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var x = new int[n];
            var y = new int[n];
            var h = new int[n];
            for (int i = 0; i < n; i++)
            {
                var xyh = Console.ReadLine().Split();
                x[i] = int.Parse(xyh[0]);
                y[i] = int.Parse(xyh[1]);
                h[i] = int.Parse(xyh[2]);
            }

            for (int cx = 0; cx <= 100; cx++)
            {
                for (int cy = 0; cy <= 100; cy++)
                {
                    var ch = m1(cx, cy, x[0], y[0], h[0]);
                    for (int k = 1; k < n; k++)
                    {
                        var _ch = m1(cx, cy, x[k], y[k], h[k]);
                        ch = m2(ch, _ch);
                    }

                    if (ch.Item1 == 1)
                    {
                        Console.WriteLine($"{cx} {cy} {ch.Item2}");
                        return;
                    }
                }
            }
        }

        static Tuple<int, int> m2(Tuple<int, int> x, Tuple<int, int> y)
        {
            if (x.Item1 == -1) return x;

            if (x.Item1 == 0 && y.Item1 == 0)
            {
                return Tuple.Create(0, Math.Min(x.Item2, y.Item2));
            }
            if (x.Item1 == 0 && y.Item1 == 1)
            {
                if (y.Item2 <= x.Item2)
                {
                    return y;
                }
                else
                {
                    return Tuple.Create(-1, 0);
                }
            }
            if (x.Item1 == 1 && y.Item1 == 0)
            {
                if (x.Item2 <= y.Item2)
                {
                    return x;
                }
                else
                {
                    return Tuple.Create(-1, 0);
                }
            }
            if (x.Item1 == 1 && y.Item1 == 1)
            {
                if (x.Item2 == y.Item2)
                {
                    return x;
                }
                else
                {
                    return Tuple.Create(-1, 0);
                }
            }

            throw new Exception();
        }

        static Tuple<int, int> m1(int cx, int cy, int x, int y, int h)
        {
            var ch = h + Math.Abs(cx - x) + Math.Abs(cy - y);
            if (h == 0)
            {
                return Tuple.Create(0, ch);
            }
            else
            {
                return Tuple.Create(1, ch);
            }
        }
    }
}


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

using namespace std;

#define maxn 100005
#define ll long long int
#define db(x) cout<<#x<<" -> "<<x<<endl
#define db2(x,y) cout<<#x<<" -> "<<x<<" , "<<#y<<" -> "<<y<<endl
#define db3(x,y,z) cout<<#x<<" -> "<<x<<" , "<<#y<<" -> "<<y<<" , "<<#z<<" -> "<<z<<endl
#define prt(x) for(auto it = x.begin(); it!=x.end(); it++){cout<<*it<<" " ;}cout<<endl
#define IN freopen("input.txt","r",stdin)

double dp[3005][3005];
double P[3005];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
//    IN ;
    int n;
    cin>>n;
    for(int i=1; i<=n; i++){
        cin>>P[ i ];
    }
    dp[0][0] = 1.00000000;
    for(int i=1; i<=n; i++){
        for(int j=0; j<=i; j++){
            dp[i][j]+=(dp[i-1][j] * (1-P[i]) * 1.00 );
            if( j <= 0 ){ continue; }
            dp[i][j]+=(1.00 * dp[i-1][j-1] * P[i]);
        }
    }
//    db(dp[3][3]);
    double ans = 0.0;
    for(int i=( (n>>1) + 1)  ; i<=n; i++){
        ans+=dp[n][i];
    }
    cout<<fixed<<setprecision(15)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 69120
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception{
		new Main(new Scanner(System.in), System.out, System.err).exec();
	}
	public final Scanner sc;
	public final PrintStream out, err;
	public Main(final Scanner sc, final PrintStream out, final PrintStream err) {
		this.sc = sc;this.out = out;this.err = err;
	}
	static public final long pair(int a, int b) {return (((long)a) << 32) + b;}
	static public final int getPair1(long v) {return (int)(v >> 32);}
	static public final int getPari2(long v) {return (int)(v & 0xFFFFFFFF);}

	static public final long quad(long a, long b, long c, long d) {
		return ((a&0xFFFF)<< 48) + ((b&0xFFFF)<< 32) + ((c&0xFFFF)<< 16) +(d&0xFFFF);}
	static public final int getQuad1(long v) {return (int)( v >> 48          );}
	static public final int getQuad2(long v) {return (int)((v >> 32) & 0xFFFF);}
	static public final int getQuad3(long v) {return (int)((v >> 16) & 0xFFFF);}
	static public final int getQuad4(long v) {return (int)( v        & 0xFFFF);}

	static public final long record(int e, int m, int i) {
		return quad(-1, e, m, i);
	}
	static public final int re(long record) {
		return getQuad2(record);
	}
	static public final int rm(long record) {
		return getQuad3(record);
	}
	static public final int ri(long record) {
		return getQuad4(record);
	}

	//------------------------------------------

	private int p;
	private int[] inv;
	private int[] fact;
	private int[] finv;
	public final int mod(long v) {
		v %= p;
		return (int)(v < 0 ? v+p : v);
	}
	public final int mul(long a, long b) {
		return mod(a*b);
	}
	public final void initFact(double limit, double p) {
		initFact((int)limit, (int)p);
	}
	public final void initFact(int limit, int p) {
		this.p = p;
		this.inv = new int[limit+1];
		this.fact = new int[limit+1];
		this.finv = new int[limit+1];
		fact[1] = finv[1] = inv[0] = inv[1] = 1;
		for(int i=2;i<=limit;i++) {
			int a = p / i;
			int b = p % i;
			inv[i]  = mul(-a, inv[b]);
			fact[i] = mul(fact[i-1], i);
			finv[i] = mul(finv[i-1], inv[i]);
		}
	}
	public final int comb(int m, int n) {
		return mul(mul(fact[m], finv[n]), finv[m-n]);
	}
	//------------------------------------------
	static long lcm (long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return (long)(c/b);
	}

	//------------------------------------------



	public void exec() throws Exception{
		final int N = sc.nextInt();
		final int K = sc.nextInt();
		final int[] p = new int[N];
		for(int i=0;i<N;i++) {
			p[i] = sc.nextInt();
		}

		int max = 0;
		int sum = 0;
		for(int i=0;i<K;i++) {
			sum += p[i];
		}
		max = sum;
		for(int i=K;i<N;i++) {
			sum = sum - p[i-K] + p[i];
			max = Math.max(sum, max);
		}

		out.println((max+K)/2.0);
	}
}


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


int main(){
  string  a,b;
  cin>>a>>b;
  int c=stoi(a+b);
  for(int i=0;i<100000;i++){
    if(i*i == c){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}



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

using namespace std;
typedef long long ll;

ll dp[101][101];
ll n,m;
ll g[101][101];

int main()
{
    for(ll i=0;i<101;i++)
        for(ll j=0;j<101;j++)
            if(i!=j)
                dp[i][j]=1e15;

    cin>>n>>m;
    for(ll i=0;i<m;i++)
    {
        ll x,y,w;
        cin>>x>>y>>w;
        g[x][y]=w;
        dp[x][y]=w;
    }

    for(int k=0;k<n;k++)
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);

    bool nc=0;
    for(int k=0;k<n;k++)
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
                if(dp[i][k]+dp[k][j]<dp[i][j])
            {
                nc=1;
                break;
            }
    if(nc)
        cout<<"NEGATIVE CYCLE\n";
    else
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
        {
            if(dp[i][j]>=1e13)
                cout<<"INF";
            else
                cout<<dp[i][j];
            if(j==n-1)
                cout<<endl;
            else
                cout<<" ";
    }
}

Measured memory_bytes: 1320
#include<iostream>
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<n;i++)
#include <map> 
#include<algorithm>
#include <numeric>
#include<deque>
#include<queue>
#include<string>
#include <iomanip>

using namespace std;
typedef long long ll;

int main(void){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i, n){
        cin>>a[i];
    }
    vector<int> b(n);
    rep(j, n){
        cin>>b[j];
    }
    vector <int>c(n);
    rep(i, n-1){
        cin>>c[i];
    }
    int ans=0;
    rep(i, n){
        ans+=b[a[i]-1];
        
        if(a[i+1]-a[i]==1){
            ans+=c[a[i]-1];
            
        }
    }

    cout<<ans<<endl;


    
}

Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))
a=list(map(bin, a))
b=list(map(len, a))
M=max(b)-2
for i in range(N):
    a[i] = '0'*(M-len(a[i])+2)+a[i][2:]
cnt = [0]*M

for i in range(N):
    for j in range(M):
        if a[i][j] == '1':
            cnt[j]+=1
for i in range(M):
    cnt[i]%=2
for i in range(N):
    ans=''
    for j in range(M):
        if int(a[i][j])!=cnt[j]:
            ans=ans+'1'
        else:
            ans=ans+'0'
    print(int(ans, 2), end=' ') 

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

#define PI acos(-1)
#define pb push_back
#define int long long int
#define mp make_pair
#define pi pair<int, int>
#define pii pair<pi, int>
#define fir first
#define sec second
#define MAXN 10001
#define MAXL 20
#define mod 1000000009

int f[MAXN];
signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i <= 100; i++)
  {
    for (int j = 1; j <= 100; j++)
    {
      for (int k = 1; k <= 100; k++)
      {
        int at = (j * j) + (i * i) + (k * k) + (i * j) + (j * k) + (i * k);
        if (at < MAXN)
          f[at]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << f[i] << endl;
  return 0;
}

Measured memory_bytes: 3656
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# GCD -- START --
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x
# GCD --- END ---

# LCM -- START --
def lcm(x,y):
  return x*y//gcd(x,y)
# LCM --- END ---

def main():
  n,m=LI()
  s=S()
  t=S()
  a=lcm(n,m)

  x={}
  for i in range(n):
    x[i*(a//n)]=s[i]

  # print(x)

  for i in range(m):
    if i*(a//m) in x:
      if t[i]!=x[i*(a//m)]:
        return -1

  return a

# main()
print(main())


Measured memory_bytes: 17408
#include<cstdio>
#include<cstring>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    for(int i = 1; i <= b*c; ++i)
    {
        int tem = a * i;
        if(tem % b == c)
        {
            printf("YES");
            return 0;
        }
    }
    printf("NO");
    return 0;
}

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

int main(){
    ll n, a[100100], sum = 0;
    cin >> n;
    rep(i,100100) a[i] = 0;
    rep(i,n){
        ll A;
        cin >> A;
        sum += A;
        a[A]++;
    }
    int q; 
    cin >> q;
    rep(i,q){
        ll b,c;
        cin >> b >> c;
        sum += (c-b)*a[b];
        a[c] += a[b];
        a[b] = 0;
        cout << sum << endl;
    }
}

Measured memory_bytes: 4416
# これほんと納得行かない
N, P = map(int, input().split())
S = list(map(int, input()))
if P==2 or P==5:
    ans = 0
    for i, c in enumerate(S, 1):
        if c%P==0:
            ans += i
    print(ans)
    exit()
L = [0] * P
cum = 0
ans = 0
L[0] += 1
inv10 = pow(10, P-2, P)
base = 1
for c in S:
    cum = (cum + c * base) % P
    base = base * inv10 % P
    ans += L[cum]
    L[cum] += 1
print(ans)


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

int main(){
  string w,t;
  int i,c=0;
  cin>>w;
  while(1){
    cin>>t;
    if (t=="END_OF_TEXT")break;
    for (i=0;i<t.size();i++){
      if (t[i]>='A'&&t[i]<='Z')t[i]-='A'-'a';
    }
    if (t==w)c++;
  }
  cout<<c<<endl;
}



Measured memory_bytes: 3212
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  int a[100010];
  for (int i = 0; i < n; i++) {
    cin >> a[i + 1];
  }
  int c = 0;
  int p = 1;
  for (int i = 0; i < n; i++) {
    c++;
    p = a[p];
    if (p == 2) {
      break;
    }
  }
  if (c == n) {
    cout << "-1" << endl;
  } else {
    cout << c << endl;
  }
  return 0;
}


Measured memory_bytes: 3536