akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"

#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)


using ll = long long;
using namespace std;


void solve();

int main() {

   solve();
   return 0;

}

void solve() {
	ll k;
	cin >> k;
	ll n=50;
	vector<ll> v(50);
	ll q = k / n;
	ll invmod =n-(k % n);
	REP(i, n) {
		v[i] = i + q;
		if (i >= invmod)v[i]++;
	}
	
	cout << n << endl;

	REP(i, n) {
		if (i)cout << " ";
		cout << v[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.Array.IArray
import Data.Array.ST
import Control.Monad.ST
import Debug.Trace

type Graph = Array Int [Int]
type UFTree = Array Int Int
type STUFTree s = STArray s Int Int

main :: IO ()
main = do
  [n, m] <- getInts
  ns <- replicateM m $ do
    [a, b] <- getInts
    return [(a, b), (b, a)]
  q <- readLn :: IO Int
  qs <- replicateM q $ do
    [a, b] <- getInts
    return (a, b)
--  let uf = (makeUF n . concat) ns
--  print uf
  mapM_ putStrLn $ solve n (concat ns) qs

getInts :: IO [Int]
getInts = map read . words <$> getLine

solve :: Int -> [(Int, Int)] -> [(Int, Int)] -> [String]
solve n graph query = runST $ do
  uf <- makeUF n graph
  ans' <- mapM (hasSamePar' uf) query
  let ans = map (\b ->
                   if b then "yes" else "no") ans'
  return ans

makeUF n graph = do
  res <- newArray (0, n-1) 0 :: ST s (STUFTree s)
  forM_ [0..n-1] (\i -> writeArray res i i)
  forM_ graph (upd res)
  return res
  where
    upd :: STUFTree s -> (Int, Int) -> ST s ()
    upd res (x, y) = do
      parX <- findParent res x
      parY <- findParent res y
      unless (x == y) $ writeArray res parX parY

findParent :: (Show e, MArray a e m, Ix e) =>
              a e e -> e -> m e
findParent arr x = do
  parX <- readArray arr x
--  trace (show (x, parX)) (return ())
  if parX == x
    then return x
    else do
    parX' <- findParent arr parX
    writeArray arr x parX'
    return parX'

hasSamePar' :: (Show e, MArray a e m, Ix e)
               => a e e -> (e, e) -> m Bool
hasSamePar' arr (x, y) = do
  parX <- findParent arr x
  parY <- findParent arr y
  return (parX == parY)

Measured memory_bytes: 116732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int b[1000];
int main(void){
    int n; cin>>n;
    b[0]=1;
    for(int i=1;i<10;i++){
        b[i]=b[i-1]*2;
    }
    for(int i=0;i<10;i++){
        if(b[i]>n){
            cout<<b[i-1]<<endl;
            return 0;
        }
    }
    
    
}


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

typedef struct s{
    string name;
    int time;
    int endtime;
}S;

const int n = 100000;
S q[n];
int top = 0;
int bottom = 0;
bool flag = false;

int isEmpty(){
    return top == bottom;
}

int isFull(){
    if(flag){
        return top == bottom;
    }else{
        return top == 0 && bottom == n-1;
    }
}

void enqueue(S x){
    if(isFull()){
        cout << "isFull" << endl;
        exit(-1);
    }
    q[bottom++] = x;
    if(bottom == n){
        if(top > 0){
            flag = !flag;
            bottom = 0; 
        }else{
            cout << "isFull" << endl;
            exit(-1);
        }
    }
}

S dequeue(){
    S tmp;
    if(isEmpty()){
        cout << "isEmpty" << endl;
    }
    tmp = q[top++];
    if(top == n){
        if(bottom > 0){
            flag = !flag;
            top = 0; 
        }else{
            cout << "isEmpty" << endl;
            exit(-1);
        }
    }
    return tmp;
}

int main(){
    int m, q, elapse = 0;
    cin >> m >> q;
    S box[m];
    for(int i = 0; i < m; i++){
        cin >> box[i].name >> box[i].time;
        enqueue(box[i]);
    }

    while(!isEmpty()){
        S tmp = dequeue();
        tmp.time -= q;
        elapse += q;
        if(tmp.time <= 0){
            elapse -= abs(tmp.time);
            tmp.endtime = elapse;
            cout << tmp.name << " " << tmp.endtime << endl;
        }else{
            enqueue(tmp);
        }
        
    }
}


Measured memory_bytes: 7836
// Union-Find木, Union-Findデータ構造
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

#include<queue>

using namespace std;

class DisjointSet
{
    public:
        // 木の高さ
        // 各ノード x を根とした時の木の高さが rank[x] となる
        vector<int> rank;
        // 親のNo.
        vector<int> p;

        // コンストラクタ
        DisjointSet() {}
        DisjointSet(int size)
        {
            rank.resize(size, 0);
            p.resize(size, 0);

            for(int i = 0; i < size; i++)
            {
                // 要素が 1つの集合を作る
                makeSet(i);
            }
        }

        // 要素が x ただ1つである新しい集合を作る
        void makeSet(int x)
        {
            // 根は自分自身を指すようにする
            p[x] = x;
            // 要素が 1 つの時は, rankは 0 とする
            rank[x] = 0;
        }

        // x と y が同じ集合に属するかの判定
        bool same(int x, int y)
        {
            return findSet(x) == findSet(y);
        }

        // 指定された2つの要素x, yを合併する
        void unite(int x, int y)
        {
            link(findSet(x), findSet(y));
        }

        // 2つの木を併合する処理
        void link(int x, int y)
        {
            // 低い木を高い木に合併する
            if( rank[x] > rank[y] )
            {
                p[y] = x;
            }
            else
            {
                p[x] = y;

                if( rank[x] == rank[y] )
                {
                    // 併合する木の高さが同じ時は,
                    // 合併される側の木の高さを 1 だけ増やす
                    rank[y]++;
                }
            }
        }

        // 要素 x が属する集合の"代表"の要素を求める
        // ( 戻り値は, 指定要素が属する木の親のNo. )
        int findSet(int x)
        {
            if( x != p[x] )
            {
                // ----------------
                // 経路圧縮を実施する
                // ----------------
                p[x] = findSet(p[x]);
            }

            // 根の値を返す ( x == p[x]の時は, 根である )
            return p[x];
        }
};

int main(void)
{

    int n, a, b, q;
    int t;

    cin >> n >> q;

    DisjointSet ds = DisjointSet(n);

    for(int i = 0; i < q; i++)
    {
        cin >> t >> a >> b;

        if( t == 0 )
        {
            // 集合の合併
            ds.unite(a, b);
        }
        else if( t == 1)
        {
            // 同じ集合に属するかの検索
            if( ds.same(a, b) )
            {
                cout << 1 << endl;
            }
            else
            {
                cout << 0 << endl;
            }
        }
    }

    return 0;
}



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

int main() {
    int n, A, B;
    cin >> n >> A >> B;
    int sum = 0;
    for (int i=1; i<=n; i++) {
        int a = i / 10000;
        int b = i / 1000 - a*10;
        int c = i / 100 - a*100 - b*10;
        int d = i / 10 - a*1000 - b*100 - c*10;
        int e = i - a*10000 - b*1000 - c*100 - d*10;
        int t = a + b + c + d + e;
        if (t >= A && t <= B) sum += i;
    }
    cout << sum << endl;

    return 0;
}


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

using namespace std;

int main(){
    int N,ans=0;
    bool last = false;
    cin >> N;
    for(int i=0;i<N;i++){
        int p;
        cin >> p;
        if(p==i+1){
            if(!last){
                ans++;
                last = true;
            }else{
                last = false;
            }
        }else{
            last = false;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 768
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
L = [0] * (A[-1]+1)
for a in A:
    L[a] = 1

for p in A:
    if not L[p]: continue 
    L[p] += 1
    n = 2
    while p*n <= A[-1]:
        L[p*n] = 0
        n += 1

ans = L.count(2)
print(ans)

Measured memory_bytes: 32168
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
  int k,t;
  cin>>k>>t;
  int a[100];
  for(int i = 0;i<t;i++){
    cin>>a[i];
  }
  sort(a,a+t);
  int s,g;
  s=0;g=t-1;
  while(true){
    if(s==g)
      break;
    if(a[g]-a[s]>=0){
      a[g] -= a[s];
      a[s++]=0;

    }
    /*
    for(int i = 0;i<t;i++){
      cout<<a[i]<<" ";
    }
    */
    sort(a,a+t);
    //cout<<endl;
  }
  if(a[g]-1>=0)
    cout<<a[g]-1<<endl;
  else
    cout<<"0"<<endl;
  return 0;
}


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

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

    unordered_map<int, bool> mp;

    int ans = true;
    for (size_t i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if (mp[a] == false) {
            mp[a] = true;
        } else {
            ans = false;
            break;
        }
    }

    if (ans) {
        cout << "YES" << endl;
    }else {
        cout << "NO" << endl;
    }
    
}

Measured memory_bytes: 8520
s = input()
# ans = 0
# while '01' in s or '10' in s:
#     # print('yes')
#     if '01' in s:
#         s = s.replace('01', '', 1)
#         ans += 2
#     if '10' in s:
#         s = s.replace('10', '', 1)
#         ans += 2
#     # print(s, ans)

# # print(ans)

ans = min(s.count('0'), s.count('1'))*2
print(ans)

Measured memory_bytes: 3188
data = input().split()

a = int(data[0])
b = int(data[1])

n = min(int(a / 0.08), int(b / 0.1))

def lookup():    
    for i in range(n, 10000):
        tax_a = int(i * 0.08)
        tax_b = int(i * 0.1)
        if tax_a == a and tax_b == b:
            print(i)
            return
    print(-1)

lookup()


Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    h,w=map(int,input().split())
    grid=[list(map(int,input().split())) for _ in range(h)]

    ans=[]
    for i in range(h):
        for j in range(w-1):
            if(grid[i][j]%2):
                ans.append((i+1,j+1,i+1,j+2))
                # print(i+1,j+1,i+1,j+2)
                grid[i][j+1]+=1

    for i in range(h-1):
        if(grid[i][w-1]%2):
            ans.append((i+1,w,i+2,w))
            # print(i+1,w,i+2,w)
            grid[i+1][w-1]+=1

    print(len(ans))
    for a in ans:
        print(*a)
resolve()

Measured memory_bytes: 72924
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>


/* 
*    coder :: ATUL_PANDEY_2608
*        >>> INDIA <<<
*/
using namespace std;
using namespace __gnu_pbds;

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end() 
#define mod 1000000007
//#define maxx 200006
#define ll long long 
#define quick    ios_base::sync_with_stdio(NULL),cin.tie(0);
#define listll vector< long long > 
#define listi vector< int> 
#define pii   pair<int , int> 
#define pll pair<long long , long long > 
#define minheap priority_queue<long long , vector< long long >, greater<long long > >
#define rep(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


template < class T > using oset = tree< T , null_type, less  < T  > , rb_tree_tag , tree_order_statistics_node_update > ;


// end of #define 

// define globals ...
const int maxx = 2e5+26;

//write function from here ...







int Main(){


int n;
string s;
cin>>s;
n = s.length();

ll dp[n+2][2];

memset(dp,0,sizeof(dp));

dp[n+1][1] = 100000000;



for( int i = n ;  i >=1; i--){
	
	int x = s[i-1] -'0';
	
	dp[i][0] = min(dp[i+1][0], dp[i+1][1] +1 ) +x;
	dp[i][1] = min(dp[i+1][0] , dp[i+1][1]-1)+10-x;
	
	
}


cout<<min(dp[1][0],dp[1][1]+1);


return 0;

}






int main(){
 quick;
int t =1; 
//cin>>t;
while(t-- )
 Main();

 return 0;


}


Measured memory_bytes: 19784
n=int(input())
t,a=list(map(int,input().split()))
h=list(map(int,input().split()))
m=abs(a-(t-h[0]*0.006))
idx=1
for i in range(1,n):
    tp=abs(a-(t-h[i]*0.006))
    if m>tp:
        m=tp
        idx=i+1
print(idx)

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define INF             1e9
#define INFL            8e18
#define XX              first
#define YY              second
#define PB              push_back
#define MP              make_pair

#define NEWLINE         cerr << "\n";
#define HOISE           cerr << "hoise " << __LINE__ << "\n"
#define PAUSE           system("pause")
#define DEBUG(x)        cerr << #x << " = " << x << "\n"
#define READ            freopen("D:\\moidda CPP\\alu.txt", "r", stdin)
#define WRITE           freopen("D:\\moidda CPP\\vorta.txt", "w", stdout)
#define FASTIO          ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MASK(x)         for(int i = 0; i < 8; i++){ if(x&(1<<i)){ cout << i << " "; } } cout << endl;

typedef long long ll;
typedef pair<int, int > pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pff;

const int MAX = 30 + 10;
const int MAX_VALUE = 2e6 + 10;
const int MAXLOG = log2(MAX) + 2;
const int MOD = 10007;
const double PY = acos(-1.0);
const double EPS = 1E-9;

int32_t main()
{
#ifndef ONLINE_JUDGE
//    READ;
//    WRITE;
#endif

    FASTIO;

    int n;
    string s;
    cin >> n >> s;
    if(s.size() <= n) cout << s;
    else cout << s.substr(0, n) << "...";

    return 0;
}



Measured memory_bytes: 3660
N,M = list(map(int,input().split(' ')))
konomi = []
for i in range(N):
  K,*A =list(map(int,input().split(' ')))
  konomi.append(A)
  
#import numpy as np
#print(konomi)
#konomi = sum(konomi,[])
n = konomi[0]
for i in konomi:
  x = set(i) & set(n)
  n = x
  
print(len(x))

Measured memory_bytes: 3060
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;

int main()
{
	int r;
	cin >> r;
	cout << r * r << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
#define inf 1e18+9
using namespace std;
int32_t main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	string st;
	cin >> st;
	int n=st.size();
	if(n%2){
		cout << "No";
		return 0;
	}
	int f=1;
	for(int i=0;i<n;i++){
		if(i%2 and st[i]!='i')
			f=0;
		if(i%2==0 and st[i]!='h')
			f=0;
	}
	if(f)cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

struct UnionFind{
  vector<int>d;
  UnionFind(int n):d(n,-1){}
  int root(int x){
    if(d[x]<0){return x;}
    return d[x]=root(d[x]);
  }
  bool unite(int x,int y){
    x=root(x);y=root(y);
    if(x==y){return false;}
    if(d[x]>d[y]){swap(x,y);}
    d[x]+=d[y];
    d[y]=x;
    return true;
  }
  bool same(int x,int y){return root(x)==root(y);}
  int size(int x){return -d[root(x)];}
};

int main() {
  int N,M,K;
  cin>>N>>M>>K;
  vector<int>frend(N);
  vector<vector<int>>block(N);
  UnionFind uf(N);
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    frend[a]++;
    frend[b]++;
    uf.unite(a,b);
  } 
  for(int i=0;i<K;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    block[a].push_back(b);
    block[b].push_back(a);
  }
  for(int i=0;i<N;i++){
    int ans=uf.size(i)-1-frend[i];
    for(int u:block[i]){
      if(uf.same(i,u)){ans--;}
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 8884
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define debug(x) cerr << #x " = " << (x) << endl;
#define P(x) cerr << #x << endl;    
#define int long long
typedef pair<int, int> pii;
const int mod = 1000000007;

const int inf = 1e12;

struct cmp
{
	bool operator()(pii const &p1, pii const &p2)
	{
		if(p1.first == p2.first)
			return p1.second > p2.second;
		return p1.first > p2.first;
	}
};
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(9);
    
    
    int n, m;
	cin >> n >> m;
	string s;
	cin >> s;
	
	priority_queue<pii, vector<pii>, cmp> pq;
	
	vector<int> dp(n + 10, 0);
	vector<int> steps(n + 10, inf);
	for(int i = 0; i < s.length(); ++ i)
		if(s[i] == '1')
			dp[i] = inf;
		else
			dp[i] = 0;
	dp[n] = 0;
	pq.push({dp[n], n});
	for(int i = n - 1; i >= 0; -- i)
	{
		if(dp[i] == inf) continue;
		while(!pq.empty() && pq.top().second > i + m)
			pq.pop();
		if(!pq.empty())
		{
			dp[i] = pq.top().first + 1;
			pq.push({dp[i], i});
			steps[i] = pq.top().second - i;
			
		}
		else
		{
			break;
		}
	}
	if(steps[0] == inf)
		cout << -1 << '\n';
	else
	{
		int ind = 0;
		while(ind != n)
		{
			cout << steps[ind] << " ";
			ind = ind + steps[ind];			
		}
		cout << '\n';
	}
    
    return 0;
}






Measured memory_bytes: 3956
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};


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

    int n;
    cin >> n;
    vector<int> b(n);
    rep(i,n){
        cin >> b[i];
    }
    int a;
    if(n % 2 == 0){
        a = n/2;
    }else {
        a = (n-1)/2;
    }
    int sum = 0;
    int tmp = 0;
    rep(i,n){
        if(b[i] % 4 == 0){
            sum++;
        }
        else if(b[i] % 2 == 0){
            tmp++;
        }
    }
    sum += tmp/2;
    if(sum >= a){
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }


    cout << endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
void re(int ,int);
void solve(int,int);
int pre[100],in[100],n,pos,post[100],k;
int main(){
  int i,root;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&pre[i]);
  for(i=0;i<n;i++)scanf("%d",&in[i]);
  solve(0,n);
  printf("\n");
  return 0;
}

void re(int l,int r){
  int m,c,i;
  if(l>=r)return;
  c=pre[pos++];
  for(i=0;i<n;i++){
    if(c==in[i]){
      m=i;
    }
  }
  re(l,m);
  re(m+1,r);
  post[k++]=c;
}

void solve(int l,int r){
  re(l,r);
  int i;
  for(i=0;i<n;i++){
    if(i!=0)printf(" ");
    printf("%d",post[i]);
  }
}



Measured memory_bytes: 2108
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)



int main(){
	string s;
	cin >> s;
	
	if(s[0]==s[1]&&s[1]==s[2]){
		cout << "Yes\n";
	}else if(s[1]==s[2]&&s[2]==s[3]){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}
	
	
	return 0;
	
}

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

int main() {
  ll n,a,b;
  cin>>n>>a>>b;
  ll ans;
  if((b-a)%2==0){
    ans=(b-a)/2;
  }else{
    ll ans1=n-b;
    ans=a+((b-a-1)/2);
    ans1=n-b+1+((n-(a+(n-b+1)))/2);
    ans=min(ans,ans1);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S, T;
    cin >> S >> T;

    int rev = 0;
    rep(i, 3) {
        if (S[i] == T[i]) rev++;
    }

    cout << rev << endl;

    return 0;
}

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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#pragma endregion Macros

ll solv(int N, vector<ll> &A){
    ll mod = 1e9+7;

    vector<ll> s(N+1,0);
    rep(i,N) {
        s[i+1] = s[i] + A[i];
        s[i+1] %= mod;
    }

    ll ans = 0;
    rep(i,N-1){
        ans += A[i] * (mod+s[N]-s[i+1]); 
        ans %= mod;
    }

    return ans;
}

ll simple(int N, vector<ll> &A){
    ll mod = 1e9+7;
    ll ans = 0;

    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            ans += (A[i]*A[j])%mod; 
            ans %= mod;
        }
    }
    return ans;
}

void input(int &N, vector<ll> &A){
    cin >> N;
    A.resize(N);
    rep(i,N) cin >> A[i];
}

void input2(int &N, vector<ll> &A){
    random_device rnd;
    N = 2000;
    A.resize(N);
    rep(i,N){
        A[i] =  rnd()%1000000000;
    }
}



int main()
{
    int N;
    vector<ll> A;

    input(N,A);
//    input2(N,A);
    ll ans = solv(N,A);
//    ll ans = simple(N,A);

/*    if(solv(N,A) != simple(N,A)){
        cerr << join(A) << endl;
        cerr << solv(N,A) << endl;
        cerr << simple(N,A) << endl;
    }*/

    cout << ans << endl;

}


Measured memory_bytes: 6432
import itertools

n,m,q = map(int, input().split(" "))
a,b,c,d = [],[],[],[]
for i in range(q):
  inpu = input()
  a.append((int)(inpu.split(" ")[0]))
  b.append((int)(inpu.split(" ")[1]))
  c.append((int)(inpu.split(" ")[2]))
  d.append((int)(inpu.split(" ")[3]))

balls = list(itertools.combinations_with_replacement(range(1, m + 1), n))
#print(balls)
max = 0
for i in range(len(balls)):
  temp = 0
  for j in range(q):
    if balls[i][b[j] - 1] - balls[i][a[j] - 1] == c[j]:
      temp += d[j]
  if temp > max:
    max = temp
print(max)

Measured memory_bytes: 21544
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var H = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var current = 0;
            var max = 0;
            for (int i = 1; i < N; i++)
            {
                if (H[i] <= H[i - 1])
                {
                    current++;
                }
                else
                {
                    max = Math.Max(current, max);
                    current = 0;
                }
            }
            max = Math.Max(current, max);
            current = 0;

            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 25052
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
ll dp[100005][13];

int main() {
  string s;
  cin >> s;
  ll n = s.length();
  //string s; 
  //for(int i=0; i<n; i++) s[i] = tmp[n-1-i];
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    int c;
    if (s[i] == '?') c = -1;
    else c = s[i] - '0';
    
    for (int j = 0; j < 10; j++) {
      if (c != -1 && c != j) continue;
      for (int ki = 0; ki < 13; ki++) {
        dp[i + 1][(ki * 10 + j) % 13] += dp[i][ki];
      }
    }
    for (int j = 0; j < 13; j++) dp[i + 1][j] %= 1000000007;
  }
  cout << dp[n][5] << endl;
}

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

using namespace std;
int n, k;
int f[5020][5020];
void add(int lx, int ly, int rx, int ry) {
    if (lx > rx) return;
    if (ly > ry) return;
    for (int i = lx; i <= rx; i++) {
        f[i][ly]++;
        f[i][ry + 1]--;
    }
}
int main() {
    ios_base::sync_with_stdio(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        int x, y, cr;
        char c;
        cin >> x >> y >> c;
        int q = (x / k) + (y / k);
        q %= 2;
        if (c == 'W') cr = 0;
        else cr = 1;
        x %= k; y %= k;
        if (q == cr) {
            add(0, 0, k - x - 1, k - y - 1);
            add(2 * k - x, 0, 2 * k - 1, k - y - 1);
            add(0, 2 * k - y, k - x - 1, 2 * k - 1);
            add(k - x, k - y, 2 * k - x - 1, 2 * k - y - 1);
            add(2 * k - x, 2 * k - y, 2 * k - 1, 2 * k - 1);
        }
        else {
            add(0, k - y, k - x - 1, 2 * k - y - 1);
            add(k - x, 0, 2 * k - x - 1, k - y - 1);
            add(2 * k - x, k - y, 2 * k - 1, 2 * k - y - 1);
            add(k - x, 2 * k - y, 2 * k - x - 1, 2 * k - 1);
        }
    }
    int ans = 0;
    for (int i = 0; i < 2 * k; i++)
    for (int j = 0; j < 2 * k; j++) {
        if (j > 0) f[i][j] += f[i][j - 1];
        ans = max(ans, f[i][j]);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 40576
from sys import stdin as I
from sys import stdout as O
N = int(I.readline())
H = [None] + list(map(int,I.readline().split()))
DP = [None for i in range(N+1)]
DP[1] = 0
DP[2] = abs(H[2]-H[1])
for i in range(3,N+1):DP[i] = min(DP[i-2]+abs(H[i]-H[i-2]),DP[i-1]+abs(H[i]-H[i-1]))
print(DP[N])

Measured memory_bytes: 13592
#include<stdio.h>
#define MAX 2000010
#define NIL -2000000001
int k[MAX],size;

int Parent(int i){
  return i/2;
}

int Left(int i){
  return i*2;
}

int Right(int i){
  return i*2+1;
}


int maxHeapify(int i){
  int l,r,largest=NIL,e;
  l=Left(i);
  r=Right(i);
  if(l<=size && k[l]>k[i])
    largest=l;
  else largest=i;
  if(r<=size && k[r]>k[largest])
    largest=r;
  if(largest!=i){
    e=k[i];
  k[i]=k[largest];
  k[largest]=e;
  maxHeapify(largest);
  }
    }

int buildMaxHeap(){
  int i;
  for(i=size/2;i>=1;i--){
    maxHeapify(i);
  }    
}


int maxHeapInsert(int key){
  size=size+1;
  k[size]=NIL;
  heapIncreaseKey(size,key);
}

int heapIncreaseKey(int i, int key){
  int e;
  if(key<k[i]){
    return -1;
}
  k[i]=key;
  while(i>1 && k[Parent(i)]<k[i]){
    e=k[i];
  k[i]=k[Parent(i)];
  k[Parent(i)]=e;
  i=Parent(i);
  }
  
}

int heapExtractMax(){
  int max;
  if(size<1)
    return -1;
  max=k[1];
  k[1]=k[size];
  size=size-1;
  maxHeapify(1);
  return max;
}

main(){
  size=1;
  
  int i,j;
  char a[20];
  for(i=0;i<MAX;i++)
    k[i]=-(1<<29);

  while(1){

    scanf("%s", a);

    if(a[0]=='i')
      {
	scanf("%d",&j);

      maxHeapInsert(j);
      }
    else if(a[0]=='e' && a[1]=='x')
      printf("%d\n", heapExtractMax());
    else break;
  }

  return 0;
 
}

Measured memory_bytes: 8416
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#define ll long long
#define ull unsigned long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define lowbit(x) (x& -x)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define eps 1e-18
#define maxn 100010
inline ll read(){ll tmp=0; char c=getchar(),f=1; for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1; for(;'0'<=c&&c<='9';c=getchar())tmp=(tmp<<3)+(tmp<<1)+c-'0'; return tmp*f;}
inline ll power(ll a,ll b){ll ans=1; for(;b;b>>=1){if(b&1)ans=ans*a%mod; a=a*a%mod;} return ans;}
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline void swap(int &a,int &b){int tmp=a; a=b; b=tmp;}
using namespace std;
int a[maxn];
int n,k;
int main()
{
	n=read(); k=read();
	for(int i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1);
	int ans=inf;
	for(int i=k;i<=n;i++)
		if((a[i]>0)^(a[i-k+1]>0))ans=min(ans,min(abs(a[i]),abs(a[i-k+1]))+a[i]-a[i-k+1]);
		else ans=min(ans,max(abs(a[i]),abs(a[i-k+1])));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 888
//Name: Strange Mathematical Expression
//Level: 1
//Category: 逆ポーランド記法,やるだけ
//Note:

#include <iostream>
#include <stack>
#include <string>
#include <sstream>
#include <cstdlib>
#include <cctype>
#include <cstdio>

using namespace std;

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

    string line;
    while(getline(cin, line) && !cin.eof()) {
        istringstream is(line);
        stack<double> stk;
        string token;
        while(is >> token) {
            if(isdigit(token[0]) || token.size() >= 2) {
                stk.push(atof(token.c_str()));
            } else {
                double b = stk.top(); stk.pop();
                double a = stk.top(); stk.pop();
                switch(token[0]) {
                    case '+':
                        stk.push(a+b);
                        break;
                    case '-':
                        stk.push(a-b);
                        break;
                    case '*':
                        stk.push(a*b);
                        break;
                    case '/':
                        stk.push(a/b);
                        break;
                }
            }
        }
        printf("%.10f\n", stk.top());
    }
    return 0;
}

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



int main(void){
    int H,W;
    cin>>H>>W;
    vector<vector<char>>a(H,vector<char>(W));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>a[i][j];
        }
    }
    vector<bool> judge1(H,false);
    vector<bool> judge2(W,false);
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(a[i][j]=='#') {
                judge1[i]=true;
                judge2[j]=true;
            }
        }
    }
    for(int i=0;i<H;i++){
        if(judge1[i]){
            for(int j=0;j<W;j++){
                if(judge2[j]){
                cout<<a[i][j];
                }
            }
            cout<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String[] S = sc.nextLine().split(" ");
    int[] dam = new int[N];
    int sum = 0;
    for(int i = 0; i < N; i++){
      dam[i] = Integer.parseInt(S[i]);
      sum += dam[i];
    }
    
    int[] mt = new int[N];
    int as = 0;
    for(int i = 1; i < N; i+=2){
      as += dam[i];
    }
    mt[0] = sum - as*2;
    
    for(int i = 1; i < N; i++){
      mt[i] = dam[i-1]*2 - mt[i-1];
    }
    
    for(int i = 0; i < N; i++){
      if(i == N-1){
    	System.out.println(mt[i]);
      }else{
        System.out.print(mt[i]);
        System.out.print(" ");
      }
    }
  }
}

Measured memory_bytes: 52324
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;


int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	ll i,a,b,x,one,two;
	cin>>a>>b>>x;
	if(a-1>=0)one=(a-1)/x+1;else one=0;
	if(b>=0)two=b/x+1;else two=0;
	cout<<two-one<<endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const int MOD = 1e9 + 7;

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

	int ans;

	if (N >= 10) {
		ans = R;
	} else {
		ans = R + 100 * (10 - N);
	}

	cout << ans << endl;

	return 0;
}

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

typedef long double lf;

int P[6], Q[6];

lf f(lf x) {
    lf ret = 0;
    for(int i = 0; i < 6; i++) {
        ret += max(x * P[i] / 100, (1 - x) * Q[i] / 100);
    }
    return ret;
}

int main() {
    for(int i = 0; i < 6; i++) {
        scanf("%d", &P[i]);
    }
    for(int i = 0; i < 6; i++) {
        scanf("%d", &Q[i]);
    }

    lf s = 0, e = 1;
    for(int i = 0; i < 60; i++) {
        lf m = (s + e) / 2;

        if(f(m) > f(m + 1e-12)) s = m;
        else e = m;
    }

    cout<<fixed;
    cout.precision(20);
    cout << f(e);
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**6)

a,b,c = map(int, input().split())
k = int(input())

m = [[] for _ in range(8)]
m[0].append([a,b,c])

for i in range(k):
    for j in m[i]:
        m[i+1].append([j[0]*2, j[1],j[2]])
        m[i+1].append([j[0], j[1]* 2, j[2]])
        m[i+1].append([j[0], j[1], j[2]* 2])

ans = 'No'

for t in m[k]:
    if t[0] < t[1] and t[1] < t[2]:
        ans = 'Yes'
        break
print(ans)

Measured memory_bytes: 9336
#include <bits/stdc++.h>
using namespace std;  
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define Rep(i, a, b) for(ll i = a; i <= b; i++)
#define repr(i, a, b) for(ll i = b-1; i >= a; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
// const ll INF = 1LL << 60;
const ll INF = 100000000000;
#define pp pair<ll, pair<ll, ll>> 
// #define fi first
// #define se second
 
/*--------------------------------------------------------------------------------
パーを出せるとき
１．相手がパー　得点+=0
２．相手がグー  得点+=1
--------------------------------------------------------------------------------*/


int main(){
     string s; cin >> s;
     ll t = 0;
     ll ans = 0;
     rep(i, 0, sz(s)){
         if(t==0){
             if(s[i]=='p') ans--;
             t++;
         }else{
             if(s[i]=='g') ans++, t--;
             else t--;
         }
     }
     co(ans);

    return 0;
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  
  cout << s[0] << n-2 << s[n-1] << endl;
  return 0;
}


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

int main(){
  long long n,m,ans=0;
  cin >> n >> m;
  vector<long long> h(n),a(m),b(m),Mt(n);
  for(long long i=0;i<n;i++){
    cin >> h.at(i);
  }
  for(long long i=0;i<m;i++){
    cin >> a.at(i) >> b.at(i);
    if(h.at(a.at(i)-1) > h.at(b.at(i)-1)) Mt.at(b.at(i)-1) = -1;
    else if(h.at(a.at(i)-1) < h.at(b.at(i)-1)) Mt.at(a.at(i)-1) = -1;
    else {
      Mt.at(a.at(i)-1) = -1;
      Mt.at(b.at(i)-1) = -1;
    }
  }
  
  for(long long i=0;i<n;i++){
    if(Mt.at(i) == 0) ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 6364
package main

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

const mod = 998244353
const facNum = 300001

func main() {
	sc := newScanner(os.Stdin)
	N := sc.i()
	sum := 0
	for i := 1; i <= N; i++ {
		if i%3 == 0 || i%5 == 0 {
			continue
		}
		sum += i
	}
	fmt.Println(sum)
}

// fmt.Println("Yes")
// fmt.Println("No")

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}

//const factorial = new
func Pow(a, n int) int {
	ans := 1
	for n > 0 {
		if (n & 1) == 1 {
			ans = ans * a % mod
		}
		a = a * a % mod
		n = n >> 1
	}
	return ans
}

func Gcd(a, b int) int {
	if a < b {
		return Gcd(b, a)
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

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

func combination(n, k int, fac, ifac []int) int {
	if n < k || n < 0 {
		return 0
	}
	if k == 0 {
		return 1
	}
	//while n != 0
	ans := ifac[k] * ifac[n-k] % mod
	return ans * fac[n] % mod
}

// 階乗: factorial
// コンビネーションを計算する際に前もって計算しておく
// fac[k] => k! (mod M)
// ifac[k] => k!^(M-2) (mod M)
// n: ex. 2 * 10^5 => 200001
// fac, ifac := factorial()
func factorial() (fac []int, ifac []int) {
	fac = make([]int, facNum)
	fac[0] = 1
	ifac = make([]int, facNum)
	ifac[0] = 1
	for i := 1; i < facNum; i++ {
		fac[i] = fac[i-1] * i % mod
		ifac[i] = ifac[i-1] * Pow(i, mod-2) % mod
	}
	return
}

// vs: sorted slice int value
func lowerBound(vs []int, v int) (index int) {
	n := len(vs) / 2
	m := len(vs)
	for m != n {
		if vs[n] < v {
			n = (m-n+1)/2 + n
			//m = m
		} else {
			m = n
			n = n / 2
		}
	}
	return n
}

func IntSlice(n, init int) []int {
	r := make([]int, n)
	for i := range r {
		r[i] = init
	}
	return r
}


Measured memory_bytes: 1756
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define eb emplace_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<30)
#define LLINF (1LL<<60)
#define MOD 998244353
typedef long long ll;
using namespace std;

int main(){
    string n;
    cin>>n;
    if(n[n.length()-1]=='0'||n[n.length()-1]=='1'||n[n.length()-1]=='6'||n[n.length()-1]=='8') cout<<"pon";
    else if(n[n.length()-1]=='3') cout<<"bon";
    else cout<<"hon";
    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++){
		s[i] += n;
		if(s[i] > 'Z') s[i] -= 26;
	}
	cout << s << endl;;
	return 0;
}


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

using ll = long long;

int main()
{
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int n, m; cin >> n >> m;
    string a, b; cin >> a >> b;

    int gcd = __gcd(n, m);
    ll lcm = 1LL*n*m/gcd;

    for(ll i=0; i<lcm; i+=lcm/n)
    {
        if(i%(lcm/n) || i%(lcm/m)) continue;
        int x = i/(lcm/n);
        int y = i/(lcm/m);
        if(a[x] != b[y])
        {
            cout << -1 << endl;
            exit(0);
        }
    }

    cout << lcm << endl;

    return 0;
}


Measured memory_bytes: 640
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);



	void run() {

		char[][] map = new char[5][5];

		for (; sc.hasNextLine();) {

			String buffer = sc.nextLine();

			if (buffer.equals("_"))

				break;

			for (int i = 0; i < 9; i++) {

				map[i / 3 + 1][i % 3 + 1] = buffer.charAt(i);

			}

			int[] dx = { 0, 1, 1, 1 };

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

			char mes = 'd';

			for (int i = 1; i <= 3; i++) {

				for (int j = 1; j <= 3; j++) {

					for (int p = 0; p < 4; p++) {

						if (map[i][j] == map[i + dx[p]][j + dy[p]]) {

							if (map[i][j] == map[i - dx[p]][j - dy[p]]) {

								if (map[i][j] == 'x' || map[i][j] == 'o') {

									mes = map[i][j];

								}

							}

						}

					}

				}

			}

			System.out.println(mes);

		}



	}



	public static void main(String[] args) {

		Main m = new Main();

		m.run();



	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
const ll MOD = 1000000007;

int main() {
    int k,n;
    cin >> k >> n;
    int a[n];
    rep(i, n) {
        cin >> a[i];
    }
    int maxd = 0; //d[0]は1 と 2
    for(int i = 0; i < n - 1;i++) {
        maxd = max(maxd,abs(a[i] - a[i+1]));
    }
    maxd = max(maxd,k + a[0] - a[n - 1]);
    cout << k - maxd;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;


public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		Scanner scan=new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		while(scan.hasNext()){
			int x=scan.nextInt();
			int y=scan.nextInt();
			if(x==0 && y==0)
				break;
			for (int i = 0; i < x; i++) {
				for (int j = 0; j < y; j++) {
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}

	}

}

Measured memory_bytes: 26868
import sys
sys.setrecursionlimit(4100000)
 
import numpy as np
 
 
def resolve():
    N = [int(x) for x in sys.stdin.readline().split()][0]
    a_list = [int(x) for x in sys.stdin.readline().split()]
 
    max_len = len(format(max(a_list), 'b'))
    # print('{} {}'.format(N, a_list))
    bin_array = np.array([[int(b) for b in format(a, 'b').zfill(max_len)]
                          for a in a_list])
 
    # print(bin_array)
 
    sum_array = bin_array.sum(axis=0)
    # print(sum_array)
    minus_array = N - 1.5 * sum_array
    if np.all(sum_array == 0) or (np.all(minus_array >= 0) and np.all(np.mod(minus_array, 3) == 0)):
        print("Yes")
    else:
        print("No")
 
 
if __name__ == "__main__":
    resolve()
 
# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる
 
import sys
from io import StringIO
import unittest
 
 
class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
 
    def test_入力例_1(self):
        input = """3
1 2 3"""
        output = """Yes"""
        self.assertIO(input, output)
 
    def test_入力例_2(self):
        input = """4
1 2 4 8"""
        output = """No"""
        self.assertIO(input, output)

Measured memory_bytes: 72248
import java.util.Scanner;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        float t = sc.nextFloat();
        float x = sc.nextFloat();
        float ans = t / x;
        System.out.printf("%.5f %n", ans);
    }
}


Measured memory_bytes: 23252
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

template <class T>
ostream &operator<<(ostream &os, const set<T> &st) {
	for (const auto &e : st) os << e << " ";
	return os;
}

template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
	for (const auto &e : mp) os << e << " ";
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

class UnionFind {
private:
	vector<int> data;
public:
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	UnionFind(int size) : data(size, -1) { }
	bool is_same(int x, int y) { return root(x) == root(y); }
	int size(int x) { return -data[root(x)]; }

	bool unify(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
			return true;
		}
		return false;
	}
};


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	map<int, vector<int>> X, Y;
	vector<pair<int, int>> XY(N);
	for (int i = 0; i < N; i++) {
		int x, y;
		cin >> x >> y;
		X[x].emplace_back(i);
		Y[y].emplace_back(i);
		XY[i] = { x,y };
	}

	UnionFind uf(N);
	for (const auto &e : X) {
		for (int i = 0; i + 1 < e.second.size(); i++) {
			int u = e.second[i];
			int v = e.second[i + 1];
			uf.unify(u, v);
		}
	}
	for (const auto &e : Y) {
		for (int i = 0; i + 1 < e.second.size(); i++) {
			int u = e.second[i];
			int v = e.second[i + 1];
			uf.unify(u, v);
		}
	}

	map<int, pair<set<int>, set<int>>> mp;
	for (int i = 0; i < N; i++) {
		mp[uf.root(i)].first.emplace(XY[i].first);
		mp[uf.root(i)].second.emplace(XY[i].second);
	}

	lint ans = -N;
	for (const auto &e : mp) ans += e.second.first.size() * e.second.second.size();

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 17152
#include<stdio.h>
int main(void){
    int n,d;
    //ｎは木の本数。各警備員は２ｄ＋１本の木を見る
    scanf("%d %d",&n,&d);
    //nを２ｄ＋１で割って余りが0の時は商が出力値
    //余りが０でないときは商に＋１すればよい
    int x,y,z;
    //xは商yは余りｚは出力地

    y = n % (2*d+1);

    if(y == 0){
    z = n/(2*d + 1);
    }
    if(y != 0){
    z = (n - y) / (2*d+1) + 1;
    }
    printf("%d\n",z);

    return 0;
}

Measured memory_bytes: 128