akhauriyash/Code-Regression huggingface dataset:
import math
import fractions
import collections
import itertools
import pprint
from collections import deque
N,K=map(int,input().split())
A=list(map(int,input().split()))
plist=[]
mlist=[]
ans=1
p=10**9+7
for i in range(N):
    if A[i]>=0:
        plist.append(A[i])
    else:
        mlist.append(A[i])
if len(plist)==0:
    if K%2==1:
        A.sort(reverse=True)
    else:
        A.sort()
    for i in range(K):
        ans=(ans*A[i])%p
    print(ans%p)

else:
    ans=1
    plist.sort(reverse=True)
    mlist.sort()
    pmap=deque()
    mmap=deque()
    if K%2==1:
        ans=plist[0]%p
        plist.pop(0)
        K=K-1
    #print(plist,mlist)
    for i in range(0,len(plist)-1,2):
        pmap.append(plist[i]*plist[i+1])
    if len(plist)>0:
        pres=plist[len(plist)-1]
    if len(mlist)>0:
        mres=mlist[len(mlist)-1]
    for i in range(0,len(mlist)-1,2):
        mmap.append(mlist[i]*mlist[i+1])
    #print(K)
    mapnum=K//2
    #print(mapnum)
    #print(pmap,mmap,ans)
    for i in range(mapnum):
        if (len(pmap)>0)and(len(mmap)>0):
            pl=pmap.popleft()
            mi=mmap.popleft()
            if pl>mi:
                ans=(ans*pl)%p
                mmap.appendleft(mi)
            else:
                ans=(ans*mi)%p
                pmap.appendleft(pl)
        elif (len(pmap)==0)and(len(mmap)>0):
            mi=mmap.popleft()
            ans = (ans *mi) % p
        elif (len(mmap)==0)and(len(pmap)>0):
            pl=pmap.popleft()
            ans = (ans *pl) % p
        else:
            ans=(ans*pres*mres)%p
    print(ans)



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

using namespace std;

int main(int argc, char *argv[]) {
    int N;
    cin >> N;

    int64_t cur;
    map<int64_t, int64_t> m;
    for (int i = 0; i < N; i++) {
        cin >> cur;
        m[cur] += 1;
    }

    int64_t ans = 0;
    for (auto p: m) {
        if (p.second % 2 == 1) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(void){
    int n;
    cin >> n;
    int a[n],ans = 0;
    ans = pow(3,n);
    for(int i = 0;i < n;i++)cin >> a[i];
    int b = 1;
    for(int i = 0;i < n;i++){
        if(a[i] % 2 == 0)b *= 2;
    }
    cout << ans - b;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
#define over(A) {cout<<A<<endl;exit(0);}
typedef unsigned long long ull;
const int inf=103974182;
using namespace std;

int main()
{
//	freopen("input.txt","r",stdin);
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	ll res;
	if(k&1)
	{
		res=b-a;
	}
	else
	{
		res=a-b;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
const double PI = acos(-1);  // PI = 3.141593...

int gcd(int x, int y) {
    if(x < y) swap(x, y);
    while(y > 0) {
        int tmp = x;
        x = y;
        y = tmp % y;
    }
    return x;
}
int main() {
    int K, ans = 0;
    cin >> K;
    for(int i = 1; i <= K; ++i) {
        for(int j = 1; j <= K; ++j) {
            for(int k = 1; k <= K; ++k) {
                if(i == j && j == k) {
                    ans += i;
                }
                else if(i == k || j == k) {
                    continue;
                }
                else if(i == j && j != k) {
                    ans += gcd(k, gcd(i, j)) * 3;
                }
                else if(i < j && j < k) {
                    ans += gcd(k, gcd(i, j)) * 6;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //e
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto& x : a) cin >> x;
  int g = 0;
  for (auto& x : a) g = __gcd(g, x);
  if (g != 1) {
    cout << "not coprime" << endl;
    return 0;
  }  
  vector<int> b((int) 1e6 + 10);
  for (auto& x : a) b[x]++;
  bool found = false;
  for (int i = 2; i <= (int) 1e6 && !found; i++) {
    int cnt = b[i];
    for (int j = i + i; j <= (int) 1e6; j += i) {
      cnt += b[j];
    }
    if (cnt >= 2) found = true;
  }
  cout << (found ? "setwise coprime" : "pairwise coprime") << endl;
  return 0;
}

Measured memory_bytes: 11100
h,a,*m=open(0)
h,w,k,a,b,f,g=map(int,(h+a).split())
I=h*w
d=[I]*I
m+=d,
a=~w+a*w+b
q=[a]
d[a]=1
for s in q:
 for x in 0,1,2,3:
  for z in range(k):
   y=~z,0,z+1,0;i,j=s//w+y[x],s%w+y[~x];t=i*w+j;p=d[s]+1
   if'.'!=m[i][j]or d[t]<p:break
   if d[t]>p:q+=t,;d[t]=p
print(d[~w+f*w+g]%I-1)

Measured memory_bytes: 132624
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a, b;
    cin >>a >>b;
    cout <<max(max(a+b, a-b), a*b);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int x; cin >> x;
   if (x >= 30)cout << "Yes" << endl;
   else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main() {

	int a, b;

	cin >> a >> b;

	if (a < b) {
		cout << "a < b" << endl;
	}
	else if (a > b) {
		cout << "a > b" << endl;
	}
	else if (a == b) {
		cout << "a == b" << endl;
	}

	return 0;

}

Measured memory_bytes: 3096
a=gets.split.map(&:to_i).sort
d=a.map{ |e| e=a[2]-e}
if d[0]%2==0 && d[1]%2==0
  p d[0]/2+d[1]/2
elsif d[0]%2==1 && d[1]%2==1
  p d[0]/2+d[1]/2+1
else
  p d[0]/2+d[1]/2+2
end


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main
{
    private final static Main main = new Main();

    public static void main(String[] args)
    {
        long l = System.currentTimeMillis();
        main.contest();
        //System.out.println("処理時間：" + (System.currentTimeMillis() - l));
    }

    private void contest()
    {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int res = s.length();
        int S = 0;
        for(int i=0; i<s.length(); ++i)
        {
            if(s.charAt(i) == 'S')
            {
                ++S;
            }
            else
            {
                if(S > 0)
                {
                    --S;
                    res -= 2;
                }
            }
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 15152
#include <iostream>
#include <map>

using namespace std;

int main(){
  int N;
  cin >> N;
  map<int,int> m;
  for(int i=0;i<N;++i){
    int a;
    cin >> a ;
    m[a-1]++;
    m[a]++;
    m[a+1]++;
  }

  int max_num = 0;
  for( const auto &p: m ){
    if(max_num < p.second){
      max_num = p.second;
    }
  }
  cout << max_num << endl;

}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  rep(i, n-2) {
    bool flag = true;
    rep(j, 3) {
      if (a[i+j] != b[i+j])
        flag = false;
    }
    if (flag) {
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
  return 0;
}

Measured memory_bytes: 3672
#include<stdio.h>
#include<limits.h>
#define MAX 2000001
 
int size=0;
int A[MAX];
 
void MaxHeapInsert(int);
void HeapIncreaseKey(int ,int);
void MaxHeapify(int);
int HeapExtractMax();
int Parent(int);
int Left(int);
int Right(int);
 
int main(){
 
  int n,i,tmp,x;
  char com[20];
 
  while(1){
    scanf("%s",com);
    if(com[0] == 'i'){
      scanf("%d",&x);
      MaxHeapInsert(x);
    }
    else if(com[0] == 'e' && com[1] == 'x'){
      printf("%d\n",HeapExtractMax());
    }
    else if(com[0] == 'e' && com[1] == 'n')
      break;
  }
 
  return 0;
}
 
void MaxHeapInsert(int key){
 
  size++;
  A[size] = INT_MIN;
  HeapIncreaseKey(size,key);
}
 
void HeapIncreaseKey(int i, int key){
 
  int tmp;
 
  if(key < A[i])
    printf("error\n");
  A[i] = key;
  while(i > 1 && A[Parent(i)] < A[i]){
    tmp = A[i];
    A[i] = A[Parent(i)];
    A[Parent(i)] = tmp;
    i = Parent(i);
  }
}
 
int HeapExtractMax(){
 
  int max;
 
  max = A[1];
  A[1] = A[size];
  size--;
  MaxHeapify(1);
  return max;
}
 
int Parent(int i){
  return i / 2;
  }
 
int Left(int i){
    return 2 * i;
}
  
int Right(int i){
    return 2 * i + 1;
}
 
void MaxHeapify(int i){
    int left,right,largest,tmp;
  
    left = Left(i);
    right = Right(i);
    if(left <= size && A[left] > A[i])
        largest = left;
    else
        largest = i;
    if(right <= size && A[right] > A[largest])
        largest = right;
    if(largest != i){
        tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        MaxHeapify(largest);
    }
}

Measured memory_bytes: 4696
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
#define ld long double
using namespace std;

int main()
{ 


fast;

ll k,a,b;

cin>>k>>a>>b;
if(a>b)swap(a,b);
a--;

ll z=b/k-a/k;

if(z)
	cout<<"OK"<<endl;
else cout<<"NG"<<endl;




}

Measured memory_bytes: 3608
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        n: usize,
        m: usize,
        aabb: [(Usize1, Usize1); m]
    };
    let mut arr = [0; 50];
    for (a, b) in aabb {
        arr[a] += 1;
        arr[b] += 1;
    }
    for i in 0..n {
        println!("{}", arr[i]);
    }
}


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

using namespace std;

int main(void) {
	int num, i, ok = true;
	cin >> num;
	vector<int> d(num);
	for (i = 0; i < num; i++)
		scanf("%d", &d[i]);
	d[0]--;
	for (i = 1; i < num; i++) {
		if (d[i - 1] < d[i])
			d[i]--;
		else if (d[i - 1] > d[i]) {
			ok = false;
			break;
		}
	}
	if (ok)
		printf("Yes");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;

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

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


    return 0;
}

Measured memory_bytes: 256
//  Copyright © 2020 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
#define what_is(x) cerr << #x << " is " << x << endl;
#define pii pair < int , int >
#define fi first
#define se second
using namespace std;
typedef long long ll;

ll h, m, H, M, K, mins;

int main()
{
    optimiza_io
    cin >> h >> m >> H >> M >> K;
    mins = (60 * H + M) - (60 * h + m);
    if(mins < 0)
        mins += 1440;
    mins -= K;
    cout << mins;
    return 0;
}

// CHECAR LIMITES 

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 1; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (abs(a - x) < abs(b - x)) P("A");
  else P("B");
  return 0;
}

Measured memory_bytes: 256
# for i in range(10):
# 	print( 10 ** i % 2019)



s = list(map(int, list(input())))
n = len(s)
MODULO = 2019

power = 1
prefix_ = [0 for _ in range(n+1)]
for i in range(n-1, -1, -1):
	prefix_[i] = (prefix_[i+1] + power*s[i]) % MODULO
	power *= 10
	power %= MODULO

seen = {}
ans = 0
for item in prefix_:
	ans += seen.get(item, 0)
	seen[item] = seen.get(item, 0) + 1

# print(s)
# print("prefix_", prefix_)
# print("unique", len(set(prefix_)))
# print("all", len(prefix_))
print(ans)

Measured memory_bytes: 99884
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n, x, m = na()
hit = {}
hit[x] = 0
a = [x]

pe = -1
while True:
    v = a[-1] * a[-1] % m
    if v in hit:
       pe = len(a)-hit[v]
       break
    a.append(v)
    hit[v] = len(a)-1
ta = len(a) - pe
if n <= len(a):
    print(sum(a[0:n]))
else:
    cy = (n-ta) // pe
    u = (n-ta) % pe + ta
    print(sum(a[0:u]) + cy*sum(a[ta:]))


Measured memory_bytes: 77712
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long w = sc.nextLong();
		long h = sc.nextLong();
		long x = sc.nextLong();
		long y = sc.nextLong();
		double ans = (double)w*(double)h/2;
		boolean jdg = false;
		if(w%2 == 0 && h%2 == 0) {
			if(w/2 == x && h/2 == y) {
				jdg = true;
			}
		}
		
		System.out.print(ans);
		System.out.print(" "); 
		if(jdg) {
			System.out.println(1);
		}else {
			System.out.println(0);
		}
		sc.close();
	}


}


Measured memory_bytes: 22228
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
dif = 10 ** 10
dif_n = 0

for i in range(len(H)) : 
    if abs(A -(T -0.006 * H[i])) < dif : 
        dif = abs(A -(T -0.006 * H[i]))
        dif_n = i +1
        
print(dif_n)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  ll n;
  cin >> n;
  int ans = 1001001001;
  for(ll i = 1; i * i <= n; i++){
    if(n % i != 0) continue;
    ll j = n / i;
    string si = to_string(i), sj = to_string(j);
    int add = max(si.size(), sj.size());
    ans = min(ans, add);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;



int main(void) {
  int n;
  cin >> n;
  ll ans = 1;
  rep(i,n){
    ll p;
    cin >> p;
    ans = ans/__gcd(ans,p)*p;
  }
  cout << ans << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
int solution(string s, char e)
{
	int c=0;
	for(int i=0; i<s.size(); i++)
	{
		if(e==s[i])
		{
			s[i]='1';
			c++;
		}
	}
	return c;
}
void solution2(string s)
{
	bool flag=true;
	int i=0;
	while(i<s.size())
	{
		int p=solution(s,s[i]);
		if(p%2!=0)
		{
			flag=false;
			i=s.size();
		}
		else
		{
			i++;
		}
	}
	if(flag)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
}
int main()
{
	string s;
	cin>>s;
	solution2(s);
	return 0;
}

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

int64_t MOD;

int64_t modpow(int64_t a,int64_t n){
  int64_t res=1;
  if(n==0) return res;
  while(n>0){
    if(n&1) res=(res*a)%MOD;
    a=(a*a)%MOD;
    n >>= 1;
  }
  return res;
}


int main(){
  int N;
  cin>>N>>MOD;
  
  string S;
  cin>>S;

  vector<int64_t> res(N+1);
  res[0]=0;
  for(int i=1;i<=N;++i){
    int64_t a=S[N-i]-'0';
    res[i]=res[i-1]+modpow(10,i-1)*a;
    res[i] %= MOD;
  }

  map<int,int64_t> m;
  for(int i=0;i<=N;++i){
    ++m[res[i]];
  }

  if(MOD!=2 && MOD!=5){
    int64_t ans=0;
    for(auto p:m){
      ans += (p.second*(p.second-1))/2;
    }
    cout<<ans<<endl;
  }
  if(MOD==5){
    int64_t ans=0;
    for(int i=0;i<N;++i){
      int a=S[i]-'0';
      if(a==5 || a==0) ans += i+1;
    }
    cout<<ans<<endl;
  }
  if(MOD==2){
    int64_t ans=0;
    for(int i=0;i<N;++i){
      int a=S[i]-'0';
      if(a%2==0) ans += i+1;
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 2564
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n, k;
  cin >> n >> k;
  if (((n - 1) * (n - 2) / 2) < k) {
    cout << -1 << endl;
    return 0;
  }
  vector<P> vec;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      vec.push_back(P(i, j));
    }
  }
  while (k--) {
    vec.pop_back();
  }
  cout << vec.size() << endl;
  for (int i = 0; i < vec.size(); ++i) {
    cout << vec[i].first << " " << vec[i].second << endl;
  }
  return 0;
}

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

int main() {
  int k; cin >> k;
  rep(i,k) cout << "ACL";
  cout << endl;

  return 0;
}

Measured memory_bytes: 3632
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimze("02")
using namespace std;
using ll =long long;
const ll maxn=1e5+5,inf=1e18+5;
ll n,m,x,y;
string s,t;
bool  b;
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>s>>t;
	for(int i=0;i<s.size();i++){
		if(s[i]!=t[i])b=1;
	}
	if(b)cout<<"No";
	else{
		cout<<"Yes";
	}
}


Measured memory_bytes: 3668
/*
Though leaves are many, the root is one;
Through all the lying days of my youth
I swayed my leaves and flowers in the sun,
Now may I wither into the truth.

- William Butler Yeats
*/
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
#include <bitset>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;

#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)
/**==Info==
*Program:1
*Problem:Shortest Path on a Line
*Date:2019-11-11
*Algorithm:My Set
*Status:AC*/

bool debug=false;

template<typename T> struct pq_small{
	priority_queue<T,vector<T>,greater<T> > pq;
	void push(T x){
		pq.push(x);
	}

	void pop(){
		pq.pop();
	}

	int size(){
		return pq.size();
	}

	bool empty(){
		return pq.empty();
	}

	T top(){
		return pq.top();
	}
};

int n,m;

vector<pair<int,ll>> ra[100005];

ll dis[100005];

pq_small<pair<int,ll>> kill;
multiset<ll> val;

const ll inf=1e18;

int main(int argc,char* argv[]){
	qi;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		ra[a].push_back(make_pair(b,c));
	}
	
	for(int i=0;i<n;i++){
		
//		cout<<"Current at "<<i<<endl;
//		for(int j:val){
//			cout<<j<<" ";
//		}
//		cout<<endl;
		
		//value
		if(i==0){
			dis[i]=0;
		}else{
			if(val.empty()){
				dis[i]=inf;
			}else{
				dis[i]=*val.begin();	
			}
			
		}
		
		//remove
		while(!kill.empty()){
			pair<int,ll> last=kill.top();
			if(last.first==i){
				val.erase(val.find(last.second));
//				val.erase(last.second);
				kill.pop();
//				cout<<"Remove:"<<last.second<<endl;
			}else{
				break;
			}
		}
		
		//shoot the bullet
		for(pii x:ra[i]){
			ll v=0ll+x.second+dis[i];
//			cout<<"INsert "<<x.first<<" "<<v<<endl;
			kill.push(make_pair(x.first,v));
			val.insert(v);
		}
		
		
	}
	
	if(dis[n-1]>=inf){
		cout<<"-1";
	}else{
		cout<<dis[n-1]<<endl;	
	}
	
	return 0;
}



Measured memory_bytes: 9080
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, d int
	fmt.Scan(&n, &d)
	var nums [][]int
	var num int
	for i := 0; i < n; i++ {
		var col []int
		for j := 0; j < d; j++ {
			fmt.Scan(&num)
			col = append(col, num)
		}
		nums = append(nums, col)
	}
	count := 0
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			abssum := 0.0
			for k := 0; k < d; k++ {
				abssum += math.Pow(math.Abs(float64(nums[i][k] - nums[j][k])),2) 
			}
			abssum = math.Sqrt(abssum)
			if abssum  == float64(int64(abssum)) {
				count++
			}
		}
	}
	fmt.Print(count)
}


Measured memory_bytes: 512
H, W, K = gets.split.map(&:to_i)
board = H.times.map { gets.chomp.chars }
h_pos = Array.new(H) { [] }
H.times do |i|
  W.times do |j|
    if board[i][j] == '#'
      h_pos[i].push(j)
    end
  end
end

top_blank_count = h_pos.take_while { |row| row.size == 0 }.size

ans = Array.new(H) { Array.new(W) }
k = 1
h_pos.each.with_index do |list, i|
  list.each.with_index do |j, li|
    left = li == 0 ? 0 : list[li - 1] + 1
    right = li == list.size - 1 ? W - 1 : list[li + 1] - 1
    top = top_blank_count >= i ? 0 : i
    bottom = i
    while bottom + 1 < H
      if h_pos[bottom + 1].size == 0
        bottom += 1
      else
        break
      end
    end
    (top..bottom).each do |i|
      (left..right).each do |j|
        ans[i][j] = k
      end
    end
    k += 1
  end
end
puts ans.map { |row| row.join(' ') }.join("\n")


Measured memory_bytes: 12796
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = 0;
            while ((n = int.Parse(Console.ReadLine())) != 0)
            {
                n = 1000 - n;
                var c = new int[] { 500, 100, 50, 10, 5, 1 };
                var r = 0;
                while (n != 0)
                {
                    n -= c.Where(i => i <= n).First();
                    r++;
                }
                Console.WriteLine(r);
            }
        }
    }
}

Measured memory_bytes: 16096
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0, _n = (int)(n); i < _n; ++i)
const int N = (int) 1e6 + 6, mod = (int) 0;
int a[N];
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, l, r;
    cin >> n >> l >> r; r--;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    sort(a, a + n);
    cout << (n - (upper_bound(a, a + n, r) - lower_bound(a, a + n, l))) << endl;

}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String line = br.readLine();
		Scanner scan = new Scanner(System.in);
		int a = Integer.parseInt(scan.next());
		int b = Integer.parseInt(scan.next());
		
		if(a==b)
			System.out.println("Draw");
		else if(a==1)
			System.out.println("Alice");
		else if(b==1)
			System.out.println("Bob");
		else if(a>b)
			System.out.println("Alice");
		else 
			System.out.println("Bob");

	}
}

Measured memory_bytes: 21716
#include"bits/stdc++.h"
using namespace std;

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long

//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

int formula(string &s, int &i);
int term(string &s, int &i);
int factor(string &s, int &i);
int number(string &s, int &i);

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

int formula(string &s, int &i) {
	int res = term(s, i);
	while(s[i]=='+' || s[i]=='-'){
		char op = s[i];
		i++;
		if (op == '+') {
			res += term(s, i);
		}
		else {
			res -= term(s, i);
		}
	}
	return res;
}

int term(string &s, int &i) {
	int res = factor(s, i);
	while (s[i] == '*' || s[i] == '/') {
		char op = s[i];
		i++;
		if (op == '*') {
			res *= factor(s, i);
		}
		else {
			res /= factor(s, i);
		}
	}
	return res;
}

int factor(string &s, int &i) {
	int res;
	if (s[i] == '(') {
		i++;
		res = formula(s, i);
		i++;
	}
	else {
		res = number(s, i);
	}
	return res;
}

int number(string &s, int &i) {
	int res = 0;
	for (; isdigit(s[i]); i++) {
		res = (s[i]-'0')+ res * 10;
	}
	return res;
}

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

int n, m;
char s[100010];

int main() {
	cin >> (s + 1);
	n = strlen(s + 1);
	if (s[1] == '0' || s[n] == '1') {
		puts("-1");
		return 0;
	}
	for (int i = 1; i < n ; i++) {
		if (s[i] != s[n - i]) {
			puts("-1");
			return 0;
		}
	}
	m = 1;
	for (int i = 1; i < n; i++) {
		cout << i + 1 << " " << m << endl;
		if (s[i] == '1') m = i + 1;
	}
	return 0;
}

Measured memory_bytes: 3728
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = Integer.parseInt(in.next());
		List<Integer> list = new ArrayList<Integer>();
		list.add(0);
		list.add(1);
		list.add(6);
		list.add(8);

		int ph = N%10;
		if(ph == 3) {
			System.out.println("bon");
		}else if(list.contains(ph)) {
			System.out.println("pon");
		}else {
			System.out.println("hon");
		}
	}
}


Measured memory_bytes: 35612
#include <stdio.h>

int main(){
    int i,j,k,n,x,count;

    while(1){
        count=0;
        scanf("%d%d",&n,&x);
        if(n == 0 && x == 0){
            break;
        }

        for(i = 1; i < n; i++){
            for(j = i + 1; j < n; j++){
                for(k = j + 1; k <= n; k++){

                    if(i + j + k == x){
                        count++;
                    }

                }
            }
        }

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

    return 0;
}



Measured memory_bytes: 2128
/*
 * 0295.cc: The Number of Chairs
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int d, c;
  cin >> d >> c;
  printf("%d\n", d * c);
  return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;
template <typename... Args> void dbg(Args &&... args) {
  using expander = int[];
  (void)expander{
      0,
      (static_cast<void>(void(cout << std::forward<Args>(args) << " ")), 0)...};
  cout << endl;
}
void gen() {
  exit(0);
}

int a, b;

void input() {
  scanf("%d %d", &a, &b);
}

void solve() {
  printf("%d\n", a * b - (a + b - 1));
}

int main() {
#ifdef DEBUG
  freopen("input", "r", stdin);
  // freopen("output", "w", stdout);
  // gen();
  while (!feof(stdin)) {
    input();
    solve();
    scanf(" ");
  }
#else
  input();
  solve();
#endif
  return 0;
}


Measured memory_bytes: 256
# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))


def solve():
    x, k, d = map(int, input().split())
    x = abs(x)

    pmin = x - k * d
    if pmin >= 0:
        return pmin

    pmax = x + k * d
    if pmax <= 0:
        return pmax

    dd, dm = divmod(x, d)
    remains = k - dd
    if remains & 1:
        return abs(dm - d)
    else:
        return dm


def main():
    print(solve())


if __name__ == "__main__":
    main()


Measured memory_bytes: 9088
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;

int main()
{
	int r;
	ll ans=0;
	cin>>r;
	cout<<r*r<<endl;
	return 0;
}

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

int main() {
  int64_t n, a, b;
  cin >> n >> a >> b;
  int64_t o = n/(a+b);
  int64_t p = n%(a+b);
  if (p<=a) cout << a*o+p << endl;
  if (p>a) cout << a*(o+1) << endl;
}


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

using namespace std;

#define MAXH 1010
#define MAXW 1010


int dist[MAXH][MAXW];
char mat[MAXH][MAXW];
int h, w;

int dx[4]={-1, 1, 0, 0};
int dy[4]={0, 0, -1, 1};
queue< pair<int, int> > fila;

int isValido(int x, int y) {
    return (x>=1 && x<=h && y>=1 && y<=w);
}

int main() {
    scanf("%d %d", &h, &w);
    int i, j;
    for (i=1; i<=h; i++) {
        scanf("%s", mat[i]+1);
    }
    memset(dist, -1, sizeof(dist));
    for (i=1; i<=h; i++) {
        for (j=1; j<=w; j++) {
            if (mat[i][j]=='#') {
                dist[i][j]=0;
                fila.push(make_pair(i, j));
            }
        }
    }
    int ans = 0;
    int x, y;
    while (!fila.empty()) {
        x = fila.front().first;
        y = fila.front().second;
        fila.pop();
        for (i=0; i<4; i++) {
            int novoX, novoY;
            novoX = x+dx[i];
            novoY = y+dy[i];
            if (isValido(novoX, novoY) && dist[novoX][novoY]==-1 && mat[novoX][novoY]=='.') {
                dist[novoX][novoY]=dist[x][y]+1;
                ans = max(ans, dist[novoX][novoY]);
                fila.push(make_pair(novoX, novoY));
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}








Measured memory_bytes: 13456
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
char t[N];
bool vis[N];
int r,s,p,n,k,ans = 0;
int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin >> n >> k >> r >> s >> p ;
    for(int i = 1;i <= n; ++i) {
        cin >> t[i];
        if(i - k > 0 && vis[i - k] && t[i] == t[i - k]) continue;
        if(t[i] == 'r') ans += p;
        if(t[i] == 's') ans += r;
        if(t[i] == 'p') ans += s;
        vis[i] = 1;
    }
    cout << ans;
    return 0;
}

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

int main() {
    long long int n, k, num, ans = 0;
    cin >> n >> k;
    if(k%2) {
        num = n/k;
        ans = num*num*num;
    } else {
        num = n/k;
        ans = num*num*num;
        if(n%k >= k/2) {
            ans += (num+1)*(num+1)*(num+1);
        } else {
            ans *= 2;
        }
    }
    cout << ans << '\n';
}

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

int main() {
    int N = 0, A = 0;
    int rest = 0;
    
    cin >> N >> A;
    
    if(N >= 500){
        rest = N % 500;
        if (rest <= A){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        rest = N;
        if (rest <= A){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

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

int main() {
  int n,y;
  cin>>n>>y;
  rep(i,n){
    rep(j,n-i){
      if((-10000*i-5000*j+y)/1000==n-j-i){
        cout <<i<<" "<<j<<" "<<n-j-i<<endl;
        return 0;
      }
    }
  }
  cout <<-1<<" "<<-1<<" "<<-1<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 10000


int main(){
  int n = 3;
  int in;
  int ans = 0;

  for(int i=0;i<n;i++){
    scanf("%d",&in);
    ans = ans*2+in;
  }

  if(ans == 1 || ans == 6)
    puts("Open");
  else
    puts("Close");
  
  return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
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; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int N;cin >> N;
    vector<int> P(N);
    vector<int> Q(N);
    rep(i,N)cin >> P[i];
    rep(i,N)cin >> Q[i];

    int ct = 1;
    int a = 0;
    int b = 0;

    vector<int> per(N);
    rep(i,N)per[i] = i+1;
    do{
        bool p = true;
        bool q = true;
        rep(i,N){
            if(P[i] != per[i])p = false;
            if(Q[i] != per[i])q = false;            
        }
        if(p)a = ct;
        if(q)b = ct;
        ct++;
    }while(next_permutation(all(per)));

    cout << abs(a-b) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

vector<pair<int, int>> vp;

struct union_find
{
    vector<ll> par, rk, sz;
    union_find(int N) : par(N), rk(N), sz(N)
    {
        for (int i = 0; i < N; ++i)
        {
            par[i] = i;
            rk[i] = 0;
            sz[i] = 1;
        }
    }

    int root(int x)
    {
        return par[x] == x ? x : par[x] = root(par[x]);
    }

    bool same(int x, int y)
    {
        return root(x) == root(y);
    }

    void unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return;

        if (rk[x] < rk[y])
        {
            sz[y] += sz[x];
            par[x] = y;
        }
        else
        {
            sz[x] += sz[y];
            par[y] = x;

            if (rk[x] == rk[y])
                rk[x]++;
        }
    }
};

int main()
{
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    //cout << fixed << setprecision(7);

    ll N, M;
    cin >> N >> M;

    union_find uf(N);
    ll t = N * (N - 1) / 2;

    vector<ll> ans;
    for (int i = 0; i < M; ++i)
    {
        int A, B;
        cin >> A >> B;
        A--;
        B--;
        vp.push_back({A, B});
    }

    ans.push_back(t);
    for (int i = M - 1; i >= 1; --i)
    {
        if (!uf.same(vp[i].first, vp[i].second))
        {
            t -= (ll)uf.sz[uf.root(vp[i].first)] * uf.sz[uf.root(vp[i].second)];
            uf.unite(vp[i].first, vp[i].second);
        }
        ans.push_back(t);
    }

    reverse(ans.begin(), ans.end());
    for (int i = 0; i < (int)ans.size(); ++i)
    {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5364
#include <iostream>

using namespace std;

int main(){

  int K, N;
  int a, cnt = 0;
  
  cin >> N >> K;

  for(int i = 0; i < N; i++){
    cin >> a;
  }

  cnt++;
  N -= K--;
  
  while(N > 0){
    cnt++;
    N -= K;
  }

  cout << cnt << "\n";
  
  return 0;
}


Measured memory_bytes: 256
def comp(itm):
	a, b, c = itm
	return a*100 + b*10 + c

def resolve():
	n, y = map(int, input().split())
	t = []
	for i in range(n+1):
		for j in range(n-i+1):
			k = n - (i+j)
			if i*10000 + j*5000 + k*1000 == y:
				t.append([i, j, k])
	if not t:
		print(-1, -1, -1)
	else:
		a, b, c = sorted(t, key=lambda x: comp(x), reverse=True)[0]
		print(a, b, c)
resolve()

Measured memory_bytes: 38768
#include "bits/stdc++.h"
using namespace std;
const int maxn=2e5+10;
int n,k,a[maxn],b[maxn],s[maxn];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=k;i++)
	{
		memset(s,0,sizeof(s));
		for(int j=1;j<=n;j++)
		{
			s[max(1,j-a[j])]++;
			s[min(n+1,j+a[j]+1)]--;
		}
		for(int j=1;j<=n;j++)b[j]=b[j-1]+s[j];
		bool flag=true;
		for(int j=1;j<=n;j++)
		{
			a[j]=b[j];
			if(a[j]!=n)flag=false;
		}
		if(flag)break;
	}
	for(int i=1;i<=n;i++)cout<<a[i]<<" ";
	cout<<endl;
	return 0;
}

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

int main(){
  long long int h,w,a,b;
  long long int ans,M,m,X,Y,Z;
  cin>>h>>w;
  if(h*w%3==0){
    cout<<0<<endl;
    return 0;
  }
	
  ans=min(h,w);
  for(int k=0;k<2;++k){
    for(int i=0;i<=1;++i){
      for(int j=0;j<=1;++j){
        a=w/3+i;b=h/2+j;
        X=a*h;
        Y=b*(w-a);
        Z=(w-a)*(h-b);
        M=max(X,Y);
        M=max(M,Z);
        m=min(X,Y);
        m=min(m,Z);
        ans=min(ans,M-m);	
      }
    }
    swap(h,w);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h> 
#include<unordered_map>
#include<bits/stdc++.h>
using namespace std;
int main() 
{ 
	int n;
	cin>>n;
	int a[n];
	for(int i=0; i<n; i++) cin>>a[i];
	int dp[n];
	dp[0]=0;
	dp[1]=fabs(a[1]-a[0]);
	for(int i=2; i<n; i++)
	{
		dp[i]=min( dp[i-1]+fabs(a[i]-a[i-1]), dp[i-2]+fabs(a[i]-a[i-2])    );
	}
	cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n, q, T, cnt, ans = 0;
		int[] S = new int[10001];
		
		n = sc.nextInt();
		for(int i = 0; i < n; i++){
			S[i] = sc.nextInt();
		}
		
		q = sc.nextInt();
		for(int i = 0; i < q; i++){
			T = sc.nextInt();
			S[n] = T;
			
			cnt = 0;
			while(S[cnt] != T){
				cnt ++;
			}
			
			if(cnt < n){
				ans ++;
			}
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 40508
n, k = map(int, input().split())
p_i = list(map(int,input().split()))
answer = 0
sum = 0
for x in range(n):
    if x <= k - 1: 
        sum += p_i[x]
        if x == k - 1: answer = sum
    else:
        sum += p_i[x] - p_i[x - k]
        answer = max(answer, sum)
print((answer + k) / 2)

Measured memory_bytes: 25060
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    N,M = LMIIS()
    uf = UnionFind(N+1)
    for i in range(M):
        a,b = LMIIS()
        uf.union(a,b)
    max_size = 0
    roots = uf.roots()
    for r in roots:
        max_size = max(max_size,uf.size(r))
    print(max_size)

    
main()

Measured memory_bytes: 83340
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

#1

import numpy as np
import bisect
acum=np.cumsum(a).tolist()
bcum=np.cumsum(b).tolist()

ans=0

for i,c in enumerate(acum):
    d=k-c
    if d<0:break
    j=bisect.bisect_right(bcum,d)-1
 
    ans=max(ans,(i+1)+(j+1))
    
for i,c in enumerate(bcum):
    d=k-c
    if d<0:break
    j=bisect.bisect_right(acum,d)-1
 
    ans=max(ans,(i+1)+(j+1))
print(ans)

Measured memory_bytes: 60040
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main(){
    unsigned long long int a;
    string b;
    cin >> a;
    cin >> b;
    //b*100 without error
    int k = b[0]-'0';
    k = k*10 + b[2]-'0';
    k = k*10 + b[3]-'0';

    cout << (a*k)/100 << endl;
    return 0;
}

/*
198 1.10
1 0.01
1000000000000000 9.99
*/

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

using namespace std;

#define vit vector<int>::iterator
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fr first
#define sc second
#define skip continue
#define PI 3.14159265

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

const int INF = 1e9 + 5;
const int MAXN = 3e6 + 123;

void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

bool cmp(const string& a, const string& b) {
	return (a + b) < (b + a);
}

vector<int> Reversed(const vector<int>& s){
   vector<int> d = s;
   reverse(all(d));
   return d;
}

void solve(){
    int a,b,c;
    cin >> a >> b >> c;
    int mx = max({a,b,c});
    int mn = min({a,b,c});
    int md = (a + b + c) - (mx + mn);
    if(mx == (mn + md))
        cout << "Yes";
    else cout << "No";
}

int main(){
    //freopen("lepus.in","r",stdin);
   // freopen("lepus.out","w",stdout);
    //faster();
    int n=1;
    //cin>>n;
    while(n--){
        solve();
        //cout << endl;
    }
    //fclose(stdout);
}


Measured memory_bytes: 256
import sys

def solve(a, b, c, d):
    c_num = b / c - a / c
    if a % c == 0:
        c_num += 1
    d_num = b / d - a / d
    if a % d == 0:
        d_num += 1

    v = c * d / gcd(c, d)
    v_num = b / v - a / v
    if a % v == 0:
        v_num += 1

    return (b - a + 1) - (c_num + d_num - v_num)


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


if __name__ == '__main__':

    a, b, c, d = map(int, sys.stdin.readline().strip().split(" "))
    print solve(a, b, c, d)

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

int main()
{
 int s; cin >> s;
 int a[4];
 for(int i=0;i<4;i++){
     a[i]=(int)s/pow(10,3-i);
     s-=a[i]*pow(10,3-i);
 }
 for(int i=0;i<pow(2,3);i++){
     int tmp=a[0];
     char op[3];
     for(int j=0;j<3;j++){
         if ((i>>j)&1){
             tmp+=a[j+1];
             op[j]='+';
         }
         else{
             tmp-=a[j+1];
             op[j]='-';
         }
     }
     if(tmp==7){
         for(int i=0;i<3;i++){
             cout << a[i] << op[i] ;
         }
         cout << a[3] << '=' << 7;
         break;
     }
 }
 return 0;
}

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

int N , M , T , s[100003] , t[100003] , dis[100003];
bitset < 50003 > now[50003];

namespace sub1{
	void work(){
		for(int i = 1 ; i <= N ; ++i) now[i].set(i);
		for(int i = 1 ; i <= M ; ++i) now[s[i]] = now[t[i]] = now[s[i]] | now[t[i]];
		for(int i = 1 ; i <= N ; ++i)
			if(now[i].count() == N){
				dis[i] = 100000;
				for(int j = M ; j ; --j)
					if(dis[s[j]] && !dis[t[j]]) dis[t[j]] = j;
					else if(dis[t[j]] && !dis[s[j]]) dis[s[j]] = j;
				for(int j = 1 ; j <= M ; ++j)
					putchar(dis[s[j]] < dis[t[j]] ? 'v' : '^');
				return;
			}
		puts("-1");
	}
}

int pot[50003] , f[50003]; char str[100003];
namespace sub2{
	void work(){
		if(N == 2){puts("-1"); return;}
		for(int i = 1 ; i <= N ; ++i) pot[f[i] = i] = 1;
		for(int j = M ; j ; --j)
			if(pot[f[s[j]]] < pot[f[t[j]]]){str[j] = '^'; --pot[f[t[j]]]; ++pot[f[t[j]] = f[s[j]]];}
			else{str[j] = 'v'; --pot[f[s[j]]]; ++pot[f[s[j]] = f[t[j]]];}
		printf("%s\n" , str + 1);
	}
}

int main(){
	ios::sync_with_stdio(0); cin >> N >> M >> T;
	for(int i = 1 ; i <= M ; ++i) cin >> s[i] >> t[i];
	if(T == 1) sub1::work(); else sub2::work();
	return 0;
}


Measured memory_bytes: 306816
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST

main :: IO ()
main = do
  ss <- replicateM 6 $ readLn :: IO [Int]
  putStrLn $ if solve ss then "Yay!" else ":("

solve ss = k >= mx - mn
  where 
    k = last ss
    as = init ss
    mx = maximum as
    mn = minimum as 


Measured memory_bytes: 508