akhauriyash/Code-Regression huggingface dataset:
use std::io::Read;
// use std::collections::VecDeque;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let m: usize = iterator.next().unwrap().parse().unwrap();

    let mut graph: Vec<Vec<usize>> = vec![Vec::new(); n];
    for _ in 0..m {
        let s: usize = iterator.next().unwrap().parse().unwrap();
        let t: usize = iterator.next().unwrap().parse().unwrap();
        graph[s].push(t);
        graph[t].push(s);
    }

    let mut colors: Vec<usize> = vec![0; n];
    let mut color = 1;
    for i in 0..n {
        if colors[i] != 0 {
            continue;
        }

        // bfs
        // let mut queue: VecDeque<usize> = VecDeque::new();
        // queue.push_back(i);
        // while !queue.is_empty() {
        //     let node = queue.pop_front().unwrap();
        //     colors[node] = color;
        //     for linked in graph[node].iter() {
        //         if colors[*linked] == 0 {
        //             queue.push_back(*linked);
        //         }
        //     }
        // }

        // dfs
        let mut stack: Vec<usize> = Vec::new();
        stack.push(i);
        while !stack.is_empty() {
            let node = stack.pop().unwrap();
            colors[node] = color;
            for linked in graph[node].iter() {
                if colors[*linked] == 0 {
                    stack.push(*linked);
                }
            }
        }

        color += 1;
    }

    let mut result = String::new();

    let q: usize = iterator.next().unwrap().parse().unwrap();
    for _ in 0..q {
        let s: usize = iterator.next().unwrap().parse().unwrap();
        let t: usize = iterator.next().unwrap().parse().unwrap();
        if colors[s] == colors[t] {
            result.push_str("yes\n");
        } else {
            result.push_str("no\n");
        }
    }

    return result.trim().to_string();
}



Measured memory_bytes: 15172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
ll fac[2000005];
void init()
{
    fac[0]=fac[1]=1;
    for(int i=2;i<=2000000;i++)
    {
        fac[i]=fac[i-1]*i%mod;
    }
    return ;
}
ll pow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1)
        {
            ans=ans*a%mod;
        }
        a=a*a%mod;
        n=n>>1;
    }
    return ans;
}
ll work(ll m,ll n)
{
    ll ans=fac[m+n-2];
    ans=ans*pow(fac[n-1],mod-2)%mod;
    ans=ans*pow(fac[m-1],mod-2)%mod;
    return ans;
}
int main()
{
    ll h,w,a,b;
    cin>>h>>w>>a>>b;
    init();
    ll ans=0;
    for(int i=b+1;i<=w;i++)
    {
        ll cnt=work(h-a,i);
        ll tmp=cnt*work(a,w-i+1)%mod;
        ans=(ans+tmp)%mod;
    }
    printf("%lld\n",ans);
}


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

int main(){
  int n; cin >> n;
  vector<pair<int, int>> job(n);
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    int b; cin >> b;
    job[i] = make_pair(b, a);
  }
  sort(job.begin(), job.end());
  int t = 0;
  rep(i, n){
    t += job[i].second;
    if(t > job[i].first){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

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

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<pair<int, int>, int> PP;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

int main(void) {
    ll N, M;
    cin >> N >> M;
    vector<P> V(N);
    for(int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        V[i] = {a, b};
    }
    sort(V.begin(), V.end());
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        if (M <= 0) break;
        ll p = min(M, V[i].second);
        ans += V[i].first*p;
        M -= p;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(){
  int a,b;
  scanf("%d%d",&a,&b);
  if(a+b>=a-b && a+b>=a*b)
    printf("%d\n",a+b);
  else if(a-b>=a+b && a-b>=a*b)
    printf("%d\n",a-b);
  else if(a*b>=a+b && a*b>=a-b)
    printf("%d\n",a*b);
  return 0;
}

Measured memory_bytes: 128
l1 = [1,3,5,7,8,10,12]
l2 = [4,6,9,11]
l3 = [2]

x, y = map(int, input().split())

if x in l1 and y in l1:
    print('Yes')
elif x in l2 and y in l2:
    print('Yes')
elif x in l3 and y in l3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 61920
import sys
INF = 10 ** 10
MOD = 10 ** 9 + 7
from functools import lru_cache
sys.setrecursionlimit(100000000)

def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    ans = 0
    for i in range(n):
        ans += a[i]//2
        if i != n - 1:
            if a[i]%2 == 1 and a[i + 1] > 0:
                ans += 1
                a[i + 1] -= 1
    
    print(ans)
if __name__ =='__main__':
    main()    

Measured memory_bytes: 7548
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> H;
	for (int i = 0; i < N; i++)
	{
		int x;
		cin >> x;
		H.push_back(x);
	}
	vector<int> dp;
	dp.push_back(0);
	for (int i = 1; i < min(K,N); i++)
	{
		int x = dp[0] + abs(H[i] - H[0]);
		for (int j = 1; j < i; j++)
		{
			int x1 = dp[j] + abs(H[i] - H[j]);
			if (x1 < x)
			{
				x = x1;
			}
		}
		dp.push_back(x);
	}
	if (N > K)
	{
		for (int i = K; i < N; i++)
		{
			int x = dp[0] + abs(H[i] - H[i - K]);
			for (int j = 0; j < K; j++)
			{
				int x1 = dp[j] + abs(H[i] - H[i - K + j]);
				if (x1 < x)
				{
					x = x1;
				}
			}
			for (int i = 0; i < K-1; i++)
			{
				dp[i] = dp[i + 1];
			}
			dp[K - 1] = x;
		}
	}
	cout << dp[min(K,N) - 1] << endl;
}

Measured memory_bytes: 892
#include <bitset> // compact STL for Sieve, better than vector<bool>!
#include <vector>
#include <cstdio>
#include <iostream>
#define ll long long 
#define vi vector<int>

using namespace std;

ll _sieve_size; 
bitset<10000010> bs; 
vi primes; 
void sieve(ll upperbound) { 
_sieve_size = upperbound + 1; 
bs.set(); 
bs[0] = bs[1] = 0; 
for (ll i = 2; i <= _sieve_size; i++) if (bs[i]) {
for (ll j = i * i; j <= _sieve_size; j += i) bs[j] = 0;
primes.push_back((int)i);
} } 
bool isPrime(ll N) { 
if (N <= _sieve_size) return bs[N]; 
for (int i = 0; i < (int)primes.size(); i++)
if (N % primes[i] == 0) return false;
return true; 
} 

int tc,a;
int TestCase,x;

int main()
{
	sieve(1000100); 
	while(scanf("%d",&tc)!=EOF)
    {
        x=0;
        while(tc >= primes[x])
        {
            x++;
        }
        printf("%d\n",x);
    }
    return 0;
}

Measured memory_bytes: 2808
#include <cstdint>
#include <vector>

using namespace std;

static vector<uint32_t> trees;
static vector<uint32_t> ranks;

void union_find_tree_init(size_t len)
{
  trees.resize(len, 0);
  for (uint32_t i = 0; i < trees.size(); i++) {
    trees[i] = i;
  }
  ranks.resize(len, 0);
}

static uint32_t find_set(uint32_t x)
{
  uint32_t index = x;

  while (trees[index] != index) {
    index = trees[index];
  }

  return index;
}

void union_find_tree_unite(uint32_t x, uint32_t y)
{
  uint32_t set_x = find_set(x);
  uint32_t set_y = find_set(y);

  if (ranks[set_x] < ranks[set_y]) {
    trees[set_x] = set_y;
  } else {
    trees[set_y] = set_x;
  }
}

bool union_find_tree_same(uint32_t x, uint32_t y)
{
  return find_set(x) == find_set(y);
}

#include <iostream>

int32_t main()
{
  uint32_t n, q;
  cin >> n >> q;

  union_find_tree_init(n);

  for (uint32_t i = 0; i < q; i++) {
    uint32_t com, x, y;
    cin >> com >> x >> y;
    if (com == 0) {
      union_find_tree_unite(x, y);
    } else {
      if (union_find_tree_same(x, y)) {
        cout << "1" << endl;
      } else {
        cout << "0" << endl;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 3180
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    double n,ans,a;
    string b;
    cin>>n;
    ans=0;
    for (int i=0; i<n; i++){
        cin>>a>>b;
        if(b=="BTC") a=a*380000;
        ans+=a;
    }cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[] pri = new int[50002];
		for(int i=2;i<=50000;i++){
			pri[i] = i;
		}
		for(int i=2;i<=100000;i++){
			for(int j=i+i;j<=50000;j+=i){
					pri[j]=0;
			}
		}
		
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int count = 0;
			for(int i=0;i<=n/2;i++){
				if(pri[i]>0 && pri[n-pri[i]]>0)count++;
			}
			System.out.println(count);
		}
	}	
}

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

int main(){
    int x, y;
    while(1){
        cin >> x >> y;
        if (x == 0 && y== 0) break;
            if (x < y){
                cout << x << " " << y << endl;    
            } else {
                cout << y << " " << x << endl;
            }
    }
    return 0;
}


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

int main()
{
  int i,n;
  string s;
  cin>>n;
  cin>>s;
  stack<char> st;
  for(i=0;i<n;i++)
  {
    if(st.empty() or st.top()!=s[i])
      st.push(s[i]);
    else if(st.top()==s[i])
      continue;
  }
  cout<<st.size();
  return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <random>
#include <string>
#include <vector>

int main()
{
    int n;
    long long a;
    std::cin >> n;

    std::vector<long long> vec;
    for (int i = 0; i < n; i++)
    {
        std::cin >> a;
        vec.push_back(a);
    }
    long long x = -1, y = -1;
    bool flag = false;
    std::sort(vec.begin(), vec.end(), [](long long l, long long r) { return l > r; });
    for (int i = 0; i < n - 1; i++)
    {
        if (vec[i] == vec[i + 1])
        {
            if (x != -1 && y == -1)
            {
                y = vec[i];
                flag = true;
                break;
            }
            if (x == -1)
            {
                x = vec[i];
                i++;
            }
        }
    }
    if (flag) { std::cout << x * y << std::endl; }
    else
    {
        std::cout << 0 << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1400
#include<stdio.h>

int main(void){
	int A,B,C;
	scanf("%d %d %d", &A, &B, &C);
	if(A==5 || A==7){
	    if(A==5 && (B==5 || B==7)){
	        if(B==5 && C==7)
		        printf("YES\n");
		    else if(B==7 && C==5)
		        printf("YES\n");
		    else
		        printf("NO\n");
	    }
		else if(A==7 && B==5 && C==5)
		    printf("YES\n");
		else
		    printf("NO\n");
	}
    else
        printf("NO\n");

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

typedef pair<int,char> P;

string in;

char c;
int num;

vector<P> ren;

int main(void)
{
	cin >> in;
	in += '*';
	c = in[0];
	num = 1;

	for(int i = 1; i < in.length(); i++){
		if(in[i] == c){
			num++;
		}
		else {
			ren.push_back(P(num,c));
			c = in[i];
			num = 1;
		}
	}

	int res = 0;

	for(int i = 1; i < ren.size()-1; i++){
		if(ren[i].first <= ren[i-1].first && ren[i].first <= ren[i+1].first){
			if(ren[i-1].second == 'J' && ren[i].second == 'O' && ren[i+1].second == 'I')
				res = max(res,ren[i].first);
		}
	}

	cout << res << endl;

/*
	for(int i = 0; i < ren.size(); i++){
		cout << ren[i].first << ' ' << ren[i].second << endl;
	}
*/

	return 0;
}


		

Measured memory_bytes: 12176
n = gets.chomp.to_i
h = gets.chomp.split.map(&:to_i).reverse
dp = Array.new(n, 0)
(n-1).times do |i|
    if h[i] <= h[i+1] then
        dp[i] = dp[i-1] + 1
    else
        dp[i] = 0
    end
end

puts dp.max

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

int main(){    
  string S;
  cin >> S;
  
  if(S.at(0) == S.at(1) && (S.at(2) == S.at(3) && S.at(0) != S.at(2))){
    cout << "Yes" << endl;
  }
  else if(S.at(0) == S.at(2) && (S.at(1) == S.at(3) && S.at(0) != S.at(1))){
    cout << "Yes" << endl;
  }
  else if(S.at(0) == S.at(3) && (S.at(1) == S.at(2) && S.at(0) != S.at(2))){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define F first
#define S second
#define pb push_back
#define bit __builtin_popcount
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define mkp make_pair
#define ffs fflush(stdout)

using namespace std;
using namespace __gnu_pbds;

//order_of_key(k) : Number of items strictly smaller than k
//find_by_order(k) : K-th element in a set (counting from 0)

template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef vector <int> lnum;
typedef pair <int, int> pii;

const int N = (int)1e6 + 5;
const int MOD = (int)1e9 + 7;
const int inf = (int)1e18;
const int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};
const ld eps = 1e9 - 7;
const int pp[] = {29, 31, 53, 67, 71};
const double pi = acos(-1.0);

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

signed main() {
  ios_base :: sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < sz(s); ++i) {
    for (int j = 0; j < n; ++j) {
      if (s[i] == 'Z')
        s[i] = 'A';
      else
        ++s[i];
    }
    cout << s[i];
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
ll po(ll a,int n){ll x=1;while(n--)x*=a;return x;}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invp(a,p)pom(a,p-2,p)


//きたまさ法（線形漸化式の第n項(0-based)をmodmで高速に求める）
int kitamasa(ll*coe,ll*A,int size,ll n,int m){
	/*
	例：フィボナッチ数列
	size=2;//特性方程式の次数
	coe[]={1,1};//特性方程式の最高次の係数を-1にして、消したもの
	A[]={0,1};//初期値
	*/

	ll*temp=(ll*)calloc(2*size,sizeof(ll));
	ll*s=(ll*)calloc(size,sizeof(ll));
	ll*ans=(ll*)calloc(size,sizeof(ll));

	s[1]=1;
	ans[0]=1;

	while(n){
		if(n%2){
			rep(i,0,2*size)temp[i]=0;
			rep(i,0,size)rep(j,0,size)temp[i+j]=(temp[i+j]+ans[i]*s[j])%m;
			for(ll i=2*size-2;i>=size;i--)rep(j,0,size)temp[i-size+j]=(temp[i-size+j]+temp[i]*coe[j])%m;
			rep(i,0,size)ans[i]=temp[i];
		}
		rep(i,0,2*size)temp[i]=0;
		rep(i,0,size)rep(j,0,size)temp[i+j]=(temp[i+j]+s[i]*s[j])%m;
		for(ll i=2*size-2;i>=size;i--)rep(j,0,size)temp[i-size+j]=(temp[i-size+j]+temp[i]*coe[j])%m;
		rep(i,0,size)s[i]=temp[i];
		n/=2;
	}
	ll ss=0;
	rep(i,0,size)ss=(ss+ans[i]*A[i])%m;
	free(temp);
	free(s);
	free(ans);
	return ss;
}

ll coe[3];
ll ini[3];
ll L,A,B,M;
char s[20];
int main(){
	ll ans=0;
	scanf("%lld%lld%lld%lld",&L,&A,&B,&M);
	ll l=sprintf(s,"%lld",A);
	ll r=sprintf(s,"%lld",A+(L-1)*B);
	rep(k,l,r+1){
		ll x,y,n;
		//初項xと項数nを求める
		if(k==l)x=A;
		else{
			x=po(10,k-1)/B*B+(A%B);
			if(x<po(10,k-1))x+=B;
			if(x>=po(10,k))continue;
		}
		
		if(k==r)y=A+(L-1)*B;
		else{
			y=po(10,k)/B*B+(A%B);
			if(y>=po(10,k))y-=B;
		}
		n=(y-x)/B+1;
		
		coe[0]=pom(10,k,M);
		coe[1]=(-2*pom(10,k,M)-1)%M;
		coe[2]=pom(10,k,M)+2;
		ini[0]=x%M;
		ini[1]=(ini[0]*pom(10,k,M)+x+B)%M;
		ini[2]=(ini[1]*pom(10,k,M)+x+B+B)%M;
		ll temp=kitamasa(coe,ini,3,n-1,M);
		ans=(ans*pom(pom(10,n,M),k,M)+temp)%M;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 128
use std::io::{self, Read};

fn main() {
    let mut buf = String::new();
    io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf = buf.split_ascii_whitespace();
    let x = buf.next().unwrap().parse::<u64>().unwrap();
    let y = buf.next().unwrap().parse::<u64>().unwrap();
    assert!(buf.next().is_none());

    if y < 2 * x || y > 4 * x || y % 2 == 1 {
        println!("No");
    } else {
        println!("Yes");
    }
}


Measured memory_bytes: 2172
n = int(input())
import queue
dq = queue.deque()
a_list = list(map(int,input().split()))

for i in range(n):
    if i%2 == 0:
        dq.append(a_list[i])
    else:
        dq.appendleft(a_list[i])
        
if n %2 == 0:
    print(*dq)
    
else:
    dq.reverse()
    print(*dq)

Measured memory_bytes: 27072
h,*s=open(0)
h,w=map(int,h.split())
dp=[[9e9]*w for _ in s]
dp[0][0]=s[0][0]<'.'
for i in range(h*w):
  i,j=i//w,i%w
  for y,x in((i+1,j),(i,j+1)):
    if y<h and x<w:dp[y][x]=min(dp[y][x],dp[i][j]+(s[i][j]=='.'>s[y][x]))
print(dp[-1][-1])

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

int main() {
    long long n, x, t;
    vector<long long> ara;
    long long arr[100007];
    cin >> n;
    t = n;
    while(n--){
        cin >> x;
        ara.push_back(x);
    }
    arr[0] = 0;
    for (int i = 1; i < t; i++){
        i==1? arr[i] = abs(ara[i]-ara[i-1]) : arr[i] = min(arr[i-2]+abs(ara[i]-ara[i-2]), arr[i-1]+abs(ara[i]-ara[i-1]));
    }
    //for(int j = 0; j<t; j++) printf("%lld %lld\n", ara[j], arr[j]);
    cout << arr[t-1] << endl;
    return 0;
}


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

#define ll long long int 

void solve()
{
     int n;
     cin>>n;
     vector<pair<int, int>>v;
     int x, y;
     for(int i=0;i<n;i++)
     {
         cin>>x>>y;
         v.push_back(make_pair(x, y));
     }
     bool yes=false;
     int cnt=0;
     for(int i=0;i<n;i++)
     {
         if(v[i].first==v[i].second)
         {
             cnt++;
             if(cnt==3)
             {
                 yes=true;
                 break;
             }
         }
         else
         {
             cnt=0;
         }
     }
     if(yes)
     {
         cout<<"Yes"<<endl;
     }
     else{
         cout<<"No"<<endl;
     }
}

int main()
{
    
    solve();
    
    
    
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

ll n;
ll a[1000000],b[1000000],p[1000000];

int main(){
  cin>>n;
  rep(i,n){
    a[i]=1+i*n;
    b[n-i-1]=1+i*n;
    cin>>p[i];
  }
  rep(i,n){
    b[p[i]-1]+=i;
  }




  rep(i,n){
    if(i!=0) cout<<" ";
    cout<<a[i];
  }
  cout<<endl;
  rep(i,n){
    if(i!=0) cout<<" ";
    cout<<b[i];
  }
  cout<<endl;

  return 0;
}



Measured memory_bytes: 4864
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int num = new Integer(in.readLine());
		if(num < 1 || num > 100) {
			return;
		}
		System.out.println(num * num * num);

	}

}



Measured memory_bytes: 24256
#include<iostream>
#include <cstdio>
using namespace std;
 
const int n_MAX = 100;
const int m_MAX = 100;
int A[n_MAX][m_MAX];
int B[m_MAX];
 
int main(){
    int n, m;
    cin >> n >> m;
 
    for (int N = 0; N < n; N++){
        for (int M = 0; M < m; M++){
            cin >> A[N][M];
        }
    }
    for (int M = 0; M < m; M++){
        cin >> B[M];
    }
 
    for (int i = 0; i < n; i++){
        int c = 0;
        for (int j = 0; j < m; j++){
            c += A[i][j] * B[j];
        }
        cout << c << endl;
    }
 
    return 0;
}


Measured memory_bytes: 3108
import java.util.Scanner;

public class Main {
    private int m;  // mod
    private String[] H;

    public Main() {
        this.m = 1046527; // 大于1000000的质数
        this.H = new String[m];
    }

    public static void main(String[] args) {
        Main test = new Main();
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        in.nextLine();
        for (int i = 0; i < n; i++) {
            String cmd = in.next();
            String str = in.next();

            if(cmd.equals("insert")) test.insert(str);
            else {
                if(test.find(str)) System.out.println("yes");
                else System.out.println("no");
            }
        }
    }

    public int getChar(char ch) {
        switch (ch) {
            case 'A':
                return 1;
            case 'C':
                return 2;
            case 'G':
                return 3;
            case 'T':
                return 4;
            default:
                return 0;
        }
    }

    public int getKey(String str) {
        int sum = 0, p = 1;
        for (int i = 0; i < str.length(); i++) {
            sum += p * getChar(str.charAt(i));
            p *= 5;
        }
        return sum;
    }

    public int h1(int key) {
        return key % m; // 令m为质数
    }

    public int h2(int key) {
        return 1 + (key % (m - 1)); // 令h2为一个小于m的值，避免无法生成下标（h2和h1的模数应互质）
    }

    public void insert(String str) {
        int key = getKey(str);
        int h;
        for (int i = 0; i < 1000000; i++) {
            h = (h1(key) + i * h2(key)) % m;
            if (H[h] == null) {
                H[h] = str;
                break;
            } else continue;
        }
    }

    public boolean find(String str) {
        int key = getKey(str);
        int h;
        boolean flag = false;
        for (int i = 0; i < 1000000; i++) {
            h = (h1(key) + i * h2(key)) % m;
            if (H[h] == null) {
                flag = false;
                break;
            } else if (H[h].equals(str)) {
                flag = true;
                break;
            }
        }
        return flag;
    }
}



Measured memory_bytes: 257448
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll N, A, B;
    cin >> N >> A >> B;
    if (N < A + B - 1) {
    	cout << -1 << endl;
    	return 0;
    }
    if (N > A * B) {
    	cout << -1 << endl;
    	return 0;
    }
    for (int j = B;j >= 1;j--) {
    	if (j != B) cout << ' ';
    	cout << j;
    }
    int crt = B + 1;
    for (int i = 1;i < A;i++) {
    	int rem = A - i - 1;
    	int ed = min(crt + B - 1, N - rem);
    	for (int j = ed;j >= crt;j--) {
    		cout << ' ' << j;
    	}
    	crt = ed + 1;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2176
n,k = map(int,input().split())
r,s,p = map(int,input().split())
raw = input()
new = []
for i in range(n):
  if raw[i] == 'r':
    new.append(0)
  elif raw[i] == 's':
    new.append(1)
  else:
    new.append(2)
#print(new)
ans = 0
for i in range(n):
  if i - k >= 0:
    if new[i] == new[i-k]:
      new[i] = 3
      #print(i,'c')
      continue
  if new[i] == 0:
    ans += p
  elif new[i] == 1:
    ans += r
  else:
    ans += s
  #print(i,ans)
print(ans)

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

int main() {
    int n;
    cin >> n;
    int a[100001];
    rep(i, n) cin >>a[i];
    int ans=0;
    rep(i, n) {
        ans++;
        while (i+1<n and a[i] == a[i+1]) ++i;
        if (a[i] > a[i+1]) {
            while (i+1<n and a[i] >= a[i+1]) ++i;
        }
        else {
            while (i+1<n and a[i] <= a[i+1]) ++i;
        }
    }
    cout << ans << endl;
}


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

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

const int MAX = 1e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int N, M, A[MAX];
ll sum[MAX];

int main(){
    cin >> N >> M;
    rep(i, N) cin >> A[i];

    rep(i, N) sum[i + 1] = (sum[i] + A[i]) % M;

    ll ans = 0;
    map<int, int> m;
    for(int i = 1; i <= N; ++i){
        if(sum[i] == 0) ans++;
        ans += m[ sum[i] ];
        m[ sum[i] ]++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4352
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

int main(){
  int n,i,j;
  long long m=0;
  cin >> n;
  vector<pair<int,int> > v;
  if(n%2==1){
    for(i=1;i<n;i++){
      v.push_back(make_pair(i,n));
    }
    n--;
  }
  int x = 1+n;
  for(i=1;i<=n;i++){
    for(j=i+1;j<=n;j++){
      if(i+j!=x)v.push_back(make_pair(i,j));
    }
  }
  m = v.size();
  cout << m << endl;
  for(i=0;i<(int)v.size();i++){
    cout << v[i].first << " " << v[i].second << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int NMAX = 200000;
const ll P = 1e9+7;
int car_uf[NMAX+1];
int train_uf[NMAX+1];
int car_root[NMAX+1];
int train_root[NMAX+1];
void uf_init(int uf[]) {
  for(int i=0; i<=NMAX; i++) uf[i] = i;
}
int uf_root(int uf[], int x) {
  if(uf[x]==x) return x;
  return uf[x] = uf_root(uf, uf[x]);
}
void uf_unite(int uf[], int a, int b) {
  a = uf_root(uf, a);
  b = uf_root(uf, b);
  if(a==b) return;
  uf[a] = b;
}
void print_uf(int uf[], int n) {
  for(int i=1; i<=n; i++) {
    if(i==1) {
      cout << uf[i];
    } else {
      cout << " " << uf[i];
    }
  }
  cout << endl;
}
int main() {
  uf_init(car_uf);
  uf_init(train_uf);
  int n,k,l;
  cin >> n >> k >> l;
  for(int i=0; i<k; i++) {
    int p,q;
    cin >> p >> q;
    uf_unite(car_uf, p, q);
  }
  for(int i=0; i<l; i++) {
    int r,s;
    cin >> r >> s;
    uf_unite(train_uf, r,s);
  }
  for(int i=1; i<=n; i++) {
    car_root[i]=uf_root(car_uf, i);
    train_root[i]=uf_root(train_uf, i);
  }
  map<ll, int> m;
  for(int i=1; i<=n; i++) {
    ll k = car_root[i]*P+train_root[i];
    auto it = m.find(k);
    if(it!=m.end()) {
      m[k]++;
    } else {
      m[k]=1;
    }
  }
  for(int i=1; i<=n; i++) {
    ll k = car_root[i]*P+train_root[i];
    if(i==1) {
      cout << m[k];
    } else {
      cout << " " << m[k];
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 15104
N,M=map(int,input().split())
numbers=[]
for _ in range(M):
    a,b=input().split()
    numbers.append([int(b),int(a)])
new_numbers=sorted(numbers)
answers=[]
while new_numbers:
    large = new_numbers[0][0]
    if  not new_numbers[0] in answers:
        answers.append(new_numbers[0])
    new_numbers=[a for a in new_numbers if a[1]>=large]
print(len(answers))


Measured memory_bytes: 118872
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
#define fst first
#define snd second
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << endl; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll h, w, n; cin >> h >> w >> n;

  map<P, int> cnt;

  rep(_, n) {
    int a, b; cin >> a >> b;
    --a; --b;
    rep(i, 3) rep(j, 3) {
      if (a-i >= 0 && a-i < h-2 && b-j >= 0 && b-j < w-2) ++cnt[P(a-i, b-j)];
    }
  }

  Vll ans(10);
  for (auto &e : cnt) ++ans[e.snd];
  ans[0] = (w-2) * (h-2);
  rep2(i, 1, 10) ans[0] -= ans[i];

  cout << ans;
  return 0;
}


Measured memory_bytes: 56448
n, k = map(int, input().split())
s = input()
seq = []
pre = '1'
count = 0
for c in s:
    if c == pre:
        count += 1
    else:
        pre = c
        seq.append(count)
        count = 1
seq.append(count)

n = len(seq)
sum = sum(seq[:2*k + 1])
ans = sum
seq.append(0)
for i in range(0, n - 2*k - 1, 2):
    sum -= seq[i] + seq[i + 1]
    sum += seq[i + 2*k + 1] + seq[i + 2 * k + 2]
    ans = max(ans, sum)
print(ans)

Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    ll k,n;cin>>k>>n;
    ll a[n];
    f(i,0,n)cin>>a[i];
    sort(a,a+n);
   
    ll mn=INT_MAX;
    f(i,0,n){
        ll one,two;
        if(i==0)one=abs(a[n-1]-a[i]);
        else one=abs(a[i]-a[n-1])+abs(a[n-1]-k)+abs(0-a[i-1]);
        if(i==n-1)two=abs(a[i]-a[0]);
        else two=abs(a[i]-0)+abs(k-a[n-1])+abs(a[n-1]-a[i]);
        // cout<<"one>"<<one<<endl;
        // cout<<"two>"<<two<<endl;
        mn=min({mn,two,one});
    }
    cout<<mn<<endl;
    return 0;  
} 





Measured memory_bytes: 1792
n=97
r=range
L='<'
P='+'
l=[3933,P,0,1,n,L,2,n,n,P,0,n,3,P,1,n,4]
a=lambda i,j:[P,i,j,i]
b=lambda i:[P,i,i,i+1]
def d(x,i,j):
	return sum([sum([b(j+t-1),a(j+t,n),*(b(s)for s in r(j+t,j+29)),[L,j+29,x,i+t],b(j+t-1),a(j+t,i+t)],[])for t in r(30)],[])
l+=d(3,5,36)
l+=d(4,36,67)
for t in r(59):
	l+=a(2,2)
	for s in r(t+1):
		if t-30<s<30:l+=[P,5+t-s,36+s,98];l+=[L,n,98,99];l+=a(2,99)
print(*l)








































Measured memory_bytes: 74912
import copy


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    field = []
    for row in inputs:
        line = []
        for c in row:
            line.append(c)
        field.append(line)

    replaced_field = []
    for i, row in enumerate(field):
        replaced_line = []
        for j, value in enumerate(row):
            if value == "#":
                replaced_line.append(value)
            else:
                count = 0
                if (i - 1) >= 0:
                    if (j - 1) >= 0:
                        count = (count + 1) if field[i - 1][j - 1] == "#" else count
                    if (j + 1) < len(row):
                        count = (count + 1) if field[i - 1][j + 1] == "#" else count
                    count = (count + 1) if field[i - 1][j] == "#" else count
                if (j - 1) >= 0:
                    count = (count + 1) if field[i][j - 1] == "#" else count
                if (j + 1) < len(row):
                    count = (count + 1) if field[i][j + 1] == "#" else count
                if (i + 1) < len(field):
                    if (j - 1) >= 0:
                        count = (count + 1) if field[i + 1][j - 1] == "#" else count
                    if (j + 1) < len(row):
                        count = (count + 1) if field[i + 1][j + 1] == "#" else count
                    count = (count + 1) if field[i + 1][j] == "#" else count
                replaced_line.append(str(count))

        replaced_field.append(replaced_line)

    result = ""
    for row in replaced_field:
        result += "".join(row) + "\n"
    return result.strip("\n")


if __name__ == "__main__":
    n = list(map(lambda x: int(x), input().split()))
    ret = solve(inputs(n[0]))
    print(ret)


Measured memory_bytes: 3700
class Line:
    def __init__(self,p1,p2):
        if p1[1] < p2[1]:self.s=p2;self.e=p1
        elif p1[1] > p2[1]:self.s=p1;self.e=p2
        else:
            if p1[0] < p2[0]:self.s=p1;self.e=p2
            else:self.s=p2;self.e=p1
def dot(a,b):return a[0]*b[0] + a[1]*b[1]
def cross(a,b):return a[0]*b[1] - a[1]*b[0]
def dif(a,b):return [x-y for x,y in zip(a,b)]
def InterSection(l,m):
    a = dif(l.e,l.s);b = dif(m.e,l.s);c = dif(m.s,l.s)
    d = dif(m.e,m.s);e = dif(l.e,m.s);f = dif(l.s,m.s)
    g = lambda a, b : cross(a,b)==0 and dot(a,b)>0 and dot(b,b)<dot(a,a)
    if g(a,b) or g(a,c) or g(d,e) or g(d,f):return True
    elif l.s == m.e or l.s == m.s or l.e == m.e or l.e == m.s:return True
    elif cross(a,b) * cross(a,c) >= 0 or cross(d,e) * cross(d,f) >= 0:return False
    else:return True

q = int(input())
for i in range(q):
    x0,y0,x1,y1,x2,y2,x3,y3 = [int(i) for i in input().split()]
    a = [x0,y0] ; b = [x1,y1] ; c = [x2,y2] ; d = [x3,y3]
    l1 = Line(b,a) ; l2 = Line(d,c)
    if InterSection(l1,l2):print(1)
    else:print(0)

Measured memory_bytes: 7864
#include<bits/stdc++.h>
using namespace std;
const int maxn =2e5+100;
int main()
{
	std::ios::sync_with_stdio(false);
	int n,a,b;
	cin>>n>>a>>b;
	int ans=min(n*a,b);
	cout<<ans;
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int fn[10010];

int main() {
    memset(fn, 0, sizeof(fn));
    FOR(x, 1, 100) FOR(y, 1, 100) FOR(z, 1, 100) {
        int num = x*x + y*y + z*z + x*y + y*z + z*x;
        if (num>(int)1e4) continue;
        fn[num]++;
    }
    int n; cin >> n;
    FOR(i, 1, n+1) {
        cout << fn[i] << endl;
    }
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e5 + 5, M = 1e9 + 7;
ll h[N], dp[N];
int main()
{
    ios::sync_with_stdio(0), cin.tie(0);
    ll n, k = 2;
    cin >> n;
    for (ll i = 1; i <= n; i++)
        cin >> h[i], dp[i] = M;
    dp[n] = 0;
    for (ll i = n; i; i--)
        for (ll j = 1; j <= k; j++)
            if (i + j <= n)
                dp[i] = min(dp[i], dp[i + j] + abs(h[i] - h[i + j]));
    cout << dp[1];
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
 
using namespace std;
 
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;


string str[]={"lunch ", "dinner ", "midnight "};

int main(){
	int n;
	while(cin>> n && n){
		int h, m1, m2; char c;
		int a, b;
		vi v(3, 0), u(3, 0);
		while(n--){
			cin>>h>>c>>m1>>m2;
			a = b = h*60;
			a += m1; b += m2 + (m1>m2?60:0);
			if(11*60<=a&&a<=14*60+59){
				u[0]++;
				if(b-a<=8) v[0]++;
			}
			else if(18*60<=a&&a<=20*60+59){
				u[1]++;
				if(b-a<=8) v[1]++;
			}
			else if(21*60<=a||a<=60+59){
				u[2]++;
				if(b-a<=8) v[2]++;
				//cout<<m1<<" "<<m2<<endl;
			}
		}
		rep(i, 3){
			cout<<str[i];
			if(u[i]==0) cout<<"no guest"<<endl;
			else cout<<v[i]*100/u[i]<<endl;
		}
	}
}

Measured memory_bytes: 1204
def valid_check(n, a, b, c, d, s):
    if not two_rocks(s[b:d]):
        return 0
    # if not two_rocks()
    if c < d:
        return two_rocks(s[a:c])
    else:
        return three_spaces(s[b-1:d+2]) and two_rocks(s[a:c])


def three_spaces(s):
    for i in range(len(s)-2):
        if s[i]=='.' and s[i+1]=='.' and s[i+2]=='.':
            return 1
    return 0

# def enumerate_possibilities(b, d, s):
#     possibilities = []
#     for i in range(d-b+1):
#         if s[b+i]=='.':
#             tmp = s.copy()
#             tmp[b+i] = '#'
#             possibilities.append(tmp)
#     return possibilities


def two_rocks(s):
    for i in range(len(s)-1):
        if s[i]=='#' and s[i+1]=='#':
            return 0
    return 1

n, a, b, c, d = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s = list(input())


if valid_check(n, a, b, c, d, s):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 6780
#include <iostream>
#include <math.h>
using namespace std;

int main() {
    int n, d, x, y, cnt;
    cin >> n >> d;

    cnt = 0;

    for (int i = 0; i < n; ++i) {
        cin >> x >> y;
        if (sqrt(pow(x, 2.0) + pow(y, 2.0)) <= d) cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3672
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
//#define INF 1100000000000000000LL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=2050;
//ここまでテンプレ
int main(){
	char N[10];
	cin>>N;
	if((N[0]==N[1] && N[1]==N[2]) || (N[2]==N[3] && N[1]==N[2])){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}

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

int main() {
  string s,d;
  cin >> s>>d;
  if(s[0]==d[2]&&s[1]==d[1]&&s[2]==d[0]){
    cout<<"YES"<<endl;
  }
    else{
      cout<<"NO"<<endl;
    }
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
constexpr int inf=1e9+7;
constexpr ll longinf=1LL<<60 ;
constexpr ll mod=1e9+7 ;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<ll> x(n), y(n);
    rep(i,n)cin>>x[i]>>y[i];
    ll ma1 = -longinf, mi1=longinf, ma2=-longinf, mi2=longinf;
    rep(i,n){
        ma1=max(ma1, x[i]+y[i]);
        mi1=min(mi1, x[i]+y[i]);
        ma2=max(ma2, x[i]-y[i]);
        mi2=min(mi2, x[i]-y[i]);
    }
    cout<<max(ma1-mi1, ma2-mi2)<<endl;
    return 0;
}

Measured memory_bytes: 6364
package main

import "fmt"

func main() {
	var n, sum int

	fmt.Scan(&n)

	d := make([]int, n)
	for i := range d {
		fmt.Scan(&d[i])
	}

	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			sum += d[i] * d[j]
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>

long long a[200001],v[200001],s;int n;
inline void add(int p){ while(p<=n)v[p]++,p+=p&-p; }
inline int sum(int p){ int r=0;while(p)r+=v[p],p-=p&-p;return r; }
int main()
{
	int i,m;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)scanf("%lld",a+i),v[i]=a[i]=a[i]-m+a[i-1];

	std::sort(v+1,v+n+1);
	m=std::unique(v+1,v+n+1)-v-1;
	for(i=1;i<=n;i++)
		a[i]=std::lower_bound(v+1,v+m+1,a[i])-v;
	for(v[0]=-1;v[m]>=0;m--);

	for(i=1;i<=n;i++)v[i]=0;
	for(i=1;i<=n;i++)
		s+=sum(a[i])+(a[i]>m),add(a[i]);
	printf("%lld\n",s);
}
//😁😂😃😄😅😆😉😊😍😞

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

using namespace std;

int main() {
  int N;
  cin >> N;
  unordered_set<int> S;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    S.insert(A);
  }

  if (S.size() == N) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


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

int main() {
	char c;
    cin >> c ;
    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    	cout << "vowel" << endl;
    }else{
    	cout << "consonant" << endl;
    }
}


Measured memory_bytes: 256
//code by PARTH_4399 for competitive programming
#include<bits/stdc++.h>
using namespace std;
#define l long // -2^31 to +2^31-1 (upper limit ~ 2*(10^9))
#define ul unsigned long // 0 to +2^32-1
#define ll long long // -2^63 to +2^63-1 (upper limit ~ 9*(10^18))
#define ull unsigned long long // 0 to +2^64-1
#define mod(x, m) ((((x)%(m))+(m))%(m))
#define vi vector<int>
#define pi pair<int,int>
#define F first
#define S second
#define PB push_back
#define MP make_pair
//const double pi=acos(-1.0); // cout<<fixed<<setprecision(n)<<pi; - for n decimal digits, use <iomanip.h>
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//code
	ll int n,i;
	cin>>n;
	ll int a[n+1],b[n];
	for(i=0;i<n+1;i++)
	{
		cin>>a[i];
	}
	for(i=0;i<n;i++)
	{
		cin>>b[i];
	}
	ll int count=0;
	for(i=0;i<n;i++)
	{
		//cout<<a[i]<<" "<<b[i]<<"\n";
		if(a[i]>=b[i])
		{
			count+=b[i];
			a[i]=a[i]-b[i];
			b[i]=0;
		}
		else
		{
			count+=a[i];
			b[i]=b[i]-a[i];
			a[i]=0;
		}
		//cout<<a[i+1]<<" "<<b[i]<<"\n";
		if(a[i+1]>=b[i])
		{
			count+=b[i];
			a[i+1]=a[i+1]-b[i];
			b[i]=0;
		}
		else
		{
			count+=a[i+1];
			b[i]=b[i]-a[i+1];
			a[i+1]=0;
		}
		//cout<<count<<" ";
	}
	cout<<count;
	return 0;
}

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

int main()
{

        string s;
        cin >> s;

        int n;
        cin >> n;

        for (int i = 0; i < n; ++i) {
                string o;
                cin >> o;
                int a, b;
                cin >> a >> b;
                string p;
                if (o == "replace") {
                        cin >> p;
                }
                if (o == "print") {
                        cout << s.substr(a, b-a+1) << endl;
                }
                else if (o == "reverse") {
                        string tmp = s.substr(a, b-a+1);
                        int cnt = a;
                        for (int i = b-a; i >= 0; --i) {
                                s[cnt] = tmp[i];
                                cnt++;
                        }
                }
                else {
                        string tmp = p;
                        int cnt = a;
                        for (int i = 0; i <= b-a; ++i) {
                                s[cnt] = tmp[i];
                                cnt++;
                        }
                }
        }
}



Measured memory_bytes: 3224
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,ans,count=0,sum=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>ans;
    sum+=ans;
    if(ans>count){
      count=ans;
    }
  }
  if(count<sum-count){
    cout<<"Yes"<<endl;
  }
  else
    cout<<"No"<<endl;
}

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

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

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

def main():
  s=S()
  t=S()

  ns=len(s)
  nt=len(t)

  dp=[[0]*(ns+1) for _ in range(nt+1)]

  for i in range(nt):
    for j in range(ns):
      if t[i]==s[j]:
        dp[i+1][j+1]=dp[i][j]+1
      else:
        dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])

  ans=[]
  i=nt
  j=ns
  while dp[i][j]!=0:
    if dp[i][j]==dp[i-1][j]:
      i-=1
    elif dp[i][j]==dp[i][j-1]:
      j-=1
    elif dp[i][j]==dp[i-1][j-1]:
      i-=1
      j-=1
    elif dp[i][j]==dp[i-1][j-1]+1:
      i-=1
      j-=1
      ans.append(t[i])

  ans.reverse()
  return ''.join(ans)

# main()
print(main())


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

using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  
  vector<int> c(n, 0);
  for(int i = 0; i < m; i++){
    int k;
    cin >> k;
    for(int j = 0; j < k; j++){
      int s;
      cin >> s;
      c[s - 1] |= (1 << i);
    }
  }
  
  int p = 0;
  for(int i = 0; i < m; i++){
    int q;
    cin >> q;
    if(q == 1){
      p |= (1 << i);
    }
  }
  
  int count = 0;
  for(int i = 0; i < (1 << n); i++){
    int on = 0;
    for(int j = 0; j < n; j++){
      if(i & (1 << j)){
        on ^= c[j];
      }
    }
    if(on == p){
      count++;
    }
  }
  
  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
int main(){
  int64_t x, k, d, a, b, c;
  cin >> x >> k >> d;
  a=abs(x/d);
  b=x%d;
  c=k-a;
  //cout << a << endl;
  if(c>0){
  if(c%2==0) cout << abs(b) << endl;
  else {
      if(b<0) cout << b+d << endl;
      if(b>=0) cout << d-b << endl;
  }
  }
  else{
    if(x>=0) cout << x-k*d << endl;
    else if(x<0) cout << abs(x+k*d) << endl;
  }
}

Measured memory_bytes: 3628
#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
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    debug("size %ld: ", arr.size()); \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif


int main(void) {
    int row, col, k;
    cin >> row >> col >> k;
    int ans = 0;
    for(int i = 0; i <= row; i++) {
        for(int j = 0; j <= col; j++) {
            int val = i * j + (row-i)*(col-j);
            if(val == k) { ans = 1; break; }
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3676
# abc116_b.py
def f(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n+1
ans = []
s = int(input())
for i in range(1000000):
    if ans.count(s)<1:
        ans.append(s)
        s = f(s)
    else:
        print(i+1)
        break


Measured memory_bytes: 2940