akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define N 3000
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
#define INF 1e10
using namespace std;
ll dist[N];
ll mp[N];
bool processed[N];
ll n;
vector<pii>adj[N];
void dijk(ll x)
{

    for (ll i = 1; i <= n; i++)
        dist[i] = INF;
    dist[x] = 0;
    priority_queue<pii>q;
    q.push({0,x});
    memset(processed,0,sizeof processed);
    while (!q.empty())
    {
        ll a = q.top().second;
        q.pop();
        if (processed[a])
            continue;
        processed[a] = true;
        for (auto u : adj[a])
        {
            ll b = u.first, w = u.second;
            if (dist[a]+w < dist[b])
            {
                dist[b] = dist[a]+w;
                q.push({-dist[b],b});
            }
        }
    }

    for(ll i=1;i<=n;i++)
    {
        mp[dist[i]]++;
    }
}
void add(ll x,ll y)
{
    adj[x].push_back({y,1});
    adj[y].push_back({x,1});
}
main()
{

    cin>>n;
    ll x,y;
    cin>>x>>y;
    add(x,y);
    for(ll i=1;i<n;i++)
    {
        add(i,i+1);
    }
    for(ll i=1;i<=n;i++)
        dijk(i);
    for(ll i=1;i<=n-1;i++)
        cout<<mp[i]/2<<'\n';
}



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

int main() {
    ll n, k;
    cin >> n >> k;

    ll a = 0, b = 0;
    bool isEven = k % 2 == 0;
    for (ll i = 1; i <= n; i++) {
        if (i % k == 0) a++;
        if (isEven)
            if (i % k == k / 2) b++;
    }

    cout << a * a * a + b * b * b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main(void)
{
	int a, b;		//三角形の辺の長さ
	double c;		//残る辺の長さ
	int C;			//辺a, bの間の角度

	double S;		//三角形の面積
	double L;		//三角形の周の長さ
	double h;		//aを底辺とした時の高さ
	double rad;		//角度をラジアンに変換

	//データ入力
	cin >> a >> b >> C;
	rad = (M_PI/180.0)*C;

	//cの長さ　余弦定理
	c = sqrt(pow(a, 2) + pow(b, 2) - 2*a*b*cos(rad));

	L = a + b + c;
	S = 0.5 * a * b * sin(rad);
	h = b * sin(rad);

	cout << fixed << setprecision(12);
	cout << S << endl;
	cout << L << endl;
	cout << h << endl;

	return 0;
}



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

int main() {
  string s, t;
  bool b = 0;
  cin >> s >> t;
  int n = s.size();
  rep(i, n){
    bool c = 1;
    rep(j, n){
      if(s[(j+i)%n] != t[j]){
        c = 0;
        break;
      }
    }
    if(c){
      b = 1;
      break;
    }
  }
  if(b) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
//When Can We Meet?
#include<bits/stdc++.h>
using namespace std;

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

int main(){
  while(true){
    int N, Q;
    cin>>N>>Q;
    if(N==0&&Q==0)break;
    int a[120];
    memset(a, 0, sizeof(a));
    rep(i,N){
      int M;
      cin>>M;
      rep(j,M){
        int tmp;
        cin>>tmp;
        a[tmp]++;
      }
    }
    int mx=0, ans=0;
    for(int i=1; i<=100; i++){
      if(mx<a[i]){mx=a[i]; ans=i;}
    }
    if(mx>=Q)cout<<ans<<endl;
    else cout<<"0"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
package main

import (
	"fmt"
)

func main() {

	var n, k int
	var s []byte

	fmt.Scan(&n, &s, &k)

	for i := 0; i < n; i++ {
		if s[k-1] != s[i] {
			s[i] = '*'
		}
	}
	fmt.Println(string(s))

}

Measured memory_bytes: 512
#include<iostream>
#include<map>
#include<string>
using namespace std;
int main() {
	int n;
	string s,a;
	while (cin >> n&&n != 0) {
		cin >> s;
		for (int z = 0; z < n; z++) {
			char b = s[0];
			a = "";
			int c = 0, e = 0;
			while (c < s.length()) {
				b = s[c];
				e = c;
				while (s[e] == b) {
					e++;
				}
				a += to_string(e - c);
				a += s[c];
				c = e;
			}
			s = "";
			s = a;
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 3364
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    ll a, b, c;
    cin >> a  >> b >> c;
    cout << (a*b)/2 << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;


public class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int[] h = new int[10];
		for(int i=0;i<10;i++)
		{
			h[i] = sc.nextInt();
		}
		Arrays.sort(h);
		for(int i=h.length-1;i>=7;i--)
		{
			System.out.println(h[i]);
		}
	}
}

Measured memory_bytes: 12000
#!/usr/bin/env python3

n = int(input())

ans = [0]
for i in range(1, n + 1):
    if i % 3 == 0 and 1 % 5 == 0:
        fizzbuzz = 0
    elif i % 3 == 0:
        fizzbuzz = 0
    elif i % 5 == 0:
        fizzbuzz = 0
    else:
        ans.append(i)

print(sum(ans))


Measured memory_bytes: 104640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main() {
  string s; cin >> s;
  bool a = false;
  bool b = false;
  bool c = false;
  if (s[0] == 'A'){
    a = true;
  }
  
  set<char> st;
  for (int i=2; i<=(s.size()-2); i++){
    st.insert(s[i]);
  }
  if (st.count('C') == 1){
    b = true;
  }
  
  int up = 0;
  for (int i=0; i<s.size(); i++){
    if (isupper(s[i]) != 0){
      up ++;
    }
  }
  if (up == 2){
    c = true;
  }
  if (a && b && c){
    cout << "AC" << endl;
    return 0;
  }
  
  cout << "WA" << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#define LEN 100005
using namespace std;

struct P {
    string name;
    int t;
};

P Q[LEN];
int head, tail, n;

void enqueue(P x){
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue(){
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}


int main(){
    int total = 0, c, q;
    P u;
    
    cin >> n >> q;
    for(int i=1;i<=n;i++){
        cin >> Q[i].name >> Q[i].t;
    }
    head = 1; tail = n + 1;
    
    while(head!=tail){
        u = dequeue();
        c = min(q,u.t);
        u.t -= c;
        total += c;
        if(u.t > 0) enqueue(u);
        else{
            cout << u.name << " " << total << endl ;
        }
    }
  
  
  return 0;
}



Measured memory_bytes: 7060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>

#define MOD 1000000007
#define INF INT_MAX
#define LLINF LLONG_MAX
using ll = long long;
using namespace std;

int main() {
    vector<bool> p(100001, true);
    vector<int> c(100001);
    int Q;
    cin >> Q;
    p[0] = p[1] = false;
    for (int i = 2; i <= 100000; i++)
    {
        if (p[i]) {
            for (int j = 2; i*j <= 100000; j++)
            {
                p[i*j] = false;
            }
        }
    }
    c[0] = c[1] = c[2] = 0;
    for (int i = 3; i <= 100000; i++)
    {
        c[i] = c[i - 1];
        if (p[i] && p[(i + 1) / 2]) {
            c[i]++;
        }
    }
    for (int i = 0; i < Q; i++)
    {
        int l, r;
        cin >> l >> r;
        cout << c[r] - c[l - 1] << endl;
    }
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

int main(){
    int m,n;
    cin >> m >> n;
    vector<vector<vector<int> > > cond(m, vector<vector<int> >(n+1, vector<int>(2)));
    for(int i=0; i<m; i++){
        for(int j=1; j<=n; j++){
            cond[i][j][0] = inf;
            cond[i][j][1] = -1;
        }
    }
    
    for(int i=0; i<m; i++){
        int k;
        cin >> k;
        for(int j=0; j<k; j++){
            int s,t;
            string c;
            cin >> s >> c >> t;
            int sl = (c=="<=")? 0: 1;
            if(sl==0){
                cond[i][s][sl] = min(cond[i][s][sl], t);
            }else{
                cond[i][s][sl] = max(cond[i][s][sl], t);
            }
        }
    }
    for(int i=0; i<m; i++){
        for(int j=1; j<=n; j++){
            if(cond[i][j][0] < cond[i][j][1]){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    vector<vector<int> > adj(m, vector<int>(m, inf));
    for(int i=0; i<m; i++){
        for(int j=0; j<m; j++){
            for(int k=1; k<=n; k++){
                if(cond[i][k][0] < cond[j][k][1]){
                    adj[i][j] = 0;
                    break;
                }
            }
        }
    }

	for(int k=0; k<m; k++){
		for(int i=0; i<m; i++){
			for(int j=0; j<m; j++){
				adj[i][j] = min(adj[i][j], adj[i][k]+adj[k][j]);
			}
		}
	}
	
	bool flag = true;
	for(int i=0; i<m; i++){
		for(int j=i+1; j<m; j++){
			if(adj[i][j]==0 && adj[j][i]==0){
				flag = false;
				break;
			}
		}
	}
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int i,j,k,l,m,n;
    cin>>n;
    int a[n+10];
    for(i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    long double res = (long double)a[0] + (long double)a[1];
    res = res/(2.0);
    for(i=2;i<=n-1;i++)
    {
        res = (res) + (long double)a[i];
        res = res/2.0;
    }
    cout<<res<<endl;
}


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

int main()
{
	string str;
	int tmp;
	int ans=1e3;
	
	cin >> str;
	for(int i=2;i<str.size();i++)
	{
		tmp=(str[i-2]-'0')*100+(str[i-1]-'0')*10+(str[i]-'0');
		ans=min(ans,abs(753-tmp));
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 998244353
#define pb push_back
#define ll long long int
#define con 1000000007
using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll i,j,m,n,k;
    ll t;
    cin>>n;
    vector<ll> v(n+1);
    for(i=1;i<=n;i++)
    {
        for(j=1;j*i<=n;j++)
        {
            v[i*j]++;
        }
    }
    ll ans=0;
    for(i=1;i<=n;i++)
        ans+=i*v[i];
    cout<<ans;
}





Measured memory_bytes: 81332
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (a, b, c, d) = (v[0], v[1], v[2], v[3]);
    if ((a - b).abs() <= d && (c - b).abs() <= d) || (a - c).abs() <= d {
        println!("Yes");
    } else {
        println!("No");
    }
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
S = list(input())
flug = True
for i in range(0,len(S),2):
    if i+1 < len(S):
        st = S[i] + S[i + 1]

        if st != "hi":
            flug = False
    else:
        flug = False

if flug == True:
    print("Yes")
else:
    print("No")

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


int main(){
  int a,b,X,Y,ans;

  while(true){
    ans = 0;
    cin >> a >> b;
    if( a + b == 0) break;

    X = max(a,b);
    Y = min(a,b);
    int work;
    while(true){
      X = X % Y;
      work = Y;
      Y = X;
      X = work;
      ++ans;
      if(Y == 0) break;
    }

    cout << X << " " << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

struct P{
  int x, y;
};

signed main(){

  int n; cin >> n;
  vector<P> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i].x >> a[i].y;
  }

  auto dist = [&](double x, double y){
    double Max = 0;
    for(int i = 0; i < n; i++){
      double dx = x - a[i].x, dy = y - a[i].y;
      Max = max(Max, sqrt(dx*dx + dy*dy));
    }
    return Max;
  };

  auto f = [&](double x){
    double left = -1, right = 1000;
    //[left , t1 , t2 , right]
    for(int lim = 0; lim < 100; lim++){
      double t1 = (left * 2 + right) / 3;
      double t2 = (left + right * 2) / 3;
      (dist(x, t1) > dist(x, t2) ? left = t1 : right = t2);
    }
    return dist(x, left);
  };
  
  double left = -1, right = 1000;
  //[left , t1 , t2 , right]
  for(int lim = 0; lim < 100; lim++){
    double t1 = (left * 2 + right) / 3;
    double t2 = (left + right * 2) / 3;
    (f(t1) > f(t2) ? left = t1 : right = t2);
  }
  printf("%.9f\n", f(left));

  return 0;
}

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



int main(){
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    ll ans1=A*X+B*Y;
    ll ans2=C*max(X,Y)*2;
    ll ans3=C*min(X,Y)*2;
    if(min(X,Y)==X){
        ans3+=B*(Y-X);
    }
    else{
        ans3+=A*(X-Y);
    }
    ll ans4=min(ans1,ans2);
    cout << min(ans3,ans4) << endl;
}

Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

class UnionFindTree
    attr_accessor:par,:rank
    def initialize(n)
        @par=Array.new(n){|i| i}
        @rank=array(n,0)
    end

    def find(x)
        return x if @par[x]==x
        @par[x]=find(@par[x])
        return @par[x]
    end

    def union(x,y)
        x=find(x)
        y=find(y)
        return if x==y
        if @rank[x]<@rank[y]
            @par[x]=y
        else
            @par[y]=x
            @rank[x]+=1 if @rank[x]==@rank[y]
        end
    end

    def same?(x,y)
        return find(x)==find(y)
    end
end
N,M=get_i
ab=array(M)
M.times do|i|
    ab[i]=get_i.map{|x| x-=1}
end
ans=0
M.times do|i|
    uft=UnionFindTree.new(N)
    M.times do|j|
        next if i==j
        uft.union(ab[j][0],ab[j][1])
    end
    ans+=1 unless uft.same?(ab[i][0],ab[i][1])
end
puts ans

Measured memory_bytes: 3836
#include <iostream>
#include <cmath>

using namespace std;

#define ll long long int

int main() {
  ll n, k;
  cin >> n >> k;
  ll x[n];
  for (ll i = 0; i < n; i++) cin >> x[i];
  ll min_d = 2e18;
  for (ll i = 0; i <= n - k; i++) {
    if (x[i] >= 0) {
      min_d = min(min_d, x[i + k - 1]);
    }
    else if (x[i + k - 1] <= 0) {
      min_d = min(min_d, -x[i]);
    }
    else {
      min_d = min(min_d, 2 * -x[i] + x[i + k - 1]);
      min_d = min(min_d, 2 * x[i + k - 1] - x[i]);
    }
  }
  cout << min_d;
}


Measured memory_bytes: 1024
n, k = map(int, input().split())
p = list(map(int, input().split()))

expectations = [(((1 + i) * i) / 2) / i for i in p] # O(n)
i = 0
MAX = e = sum(expectations[i:i + k])
while i + k < n: # O(n)
    i += 1
    t = e - expectations[i - 1] + expectations[i + k - 1]
    MAX = max(MAX, t)
    e = t

print(MAX)

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

int main(void){
   int r,c,sum;
   cin >> r >> c;
   int spread[100][100] = {{}};
   int sum1[100] = {};
   int sum2[100] = {};
   for (int i = 0; i < r; i++){
      for (int j = 0; j < c; j++){
         cin >> spread[i][j];
         sum1[i] += spread[i][j];
         sum2[j] += spread[i][j];
      }
   }
   for (int i = 0; i < r; i++){
      for (int j = 0; j < c; j++){
         cout << spread[i][j] << " ";
      }
      cout << sum1[i] << endl;
   }
   sum = 0;
   for (int k = 0; k < c; k++){
      cout << sum2[k] << " ";
      sum += sum2[k];
   }
   cout << sum << endl;
}



Measured memory_bytes: 3128
#include "bits/stdc++.h"

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pil = pair<int, ll>;

int main() {
	const int nmonth = 12;

	string S;
	cin >> S;

	bool is_yymm = false, is_mmyy = false;
	int a = (S[0] - '0') * 10 + (S[1] - '0');
	int b = (S[2] - '0') * 10 + (S[3] - '0');
	if (0 < a and a <= nmonth)
		is_mmyy = true;
	if (0 < b and b <= nmonth)
		is_yymm = true;

	string ans;
	if (is_mmyy and is_yymm)
		ans = "AMBIGUOUS";
	else if (is_mmyy and !is_yymm)
		ans = "MMYY";
	else if (!is_mmyy and is_yymm)
		ans = "YYMM";
	else
		ans = "NA";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define _FOREVER 1
 
int main(void) {
	int  N,i,len;
	char S[10000+1];
 
    scanf("%d ",&N);
    scanf("%s",S);
    len=strlen(S);
	for(i=0;i<len;i++) {
		S[i]+=(char)N;
		printf("%c",S[i]>'Z'?S[i]-26:S[i]);
	}
 
return 0;
}

Measured memory_bytes: 128
from collections import deque
n,m=map(int,input().split())
r=[[] for i in range(n+1)]
R=[[] for i in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    r[a].append(b)
    r[b].append(a)
    R[a].append(b)
    R[b].append(a)
dep=[-1]*(n+1)
dep[0]=0
dep[1]=0
data=deque([1])
d=0
while len(data)>0:
    p=data.popleft()
    for i in r[p]:
        if dep[i]==-1:
            dep[i]=dep[p]+1
            data.append(i)
    r[p]=[]
if not all(dep[i+1]>=0 for i in range(n)):
    print("No")
else:
    print("Yes")
    for i in range(2,n+1):
        for j in R[i]:
            if dep[j]==dep[i]-1:
                print(j)
                break


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

using namespace std;

typedef long long ll;

int main(){
	int n;
	cin >> n;
	int h[20];
	int ans = 0;
	int m = 0;
	for(int i = 0; i < n; i++){
		cin >> h[i];
		if(!i)ans++;
		else if(h[i] >= m)ans++;
		m = max(h[i], m);
	}
	cout << ans << endl;
    return 0;
}

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

using namespace std;

const int maxn = 1e5 + 10;
int n;
int a[maxn][3];
int dp[maxn][3];

int main(){
	scanf("%d", &n);

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

	dp[0][0] = a[0][0];
	dp[0][1] = a[0][1];
	dp[0][2] = a[0][2];
	for(int i=1; i<n; i++){
		for(int j=0; j<3; j++){
			for(int k=0; k<3; k++){
				if(k != j){
					dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i][j]);
				}
			}
		}
	}

	int ans = max(dp[n-1][0], dp[n-1][1]);
	ans = max(dp[n-1][2], ans);

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


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

n = int(input())
h = list(map(int, input().split()))

max_h = []
for i in range(n):
    if i == 0:
        max_h.append(h[0])
    else:
        max_h.append(max(h[i],max_h[i-1]))
#print(max_h)

count = 0
for i in range(n):
    if h[i] >= max_h[i]:
        count += 1
print(count)

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

ll c[101][101];

int main() {
  int n;
  cin >> n;
  vector<vector<ll>> vec(n, vector<ll>(3));
  rep(i,n) cin >> vec[i][0] >> vec[i][1] >> vec[i][2];
  int a;
  rep(i,n) if(vec[i][2]!=0) {
    a = i;
    break;
  }
  rep(i,101)rep(j,101) c[i][j] = vec[a][2] + abs(i-vec[a][0]) + abs(j-vec[a][1]);
  rep(i,101)rep(j,101) {
    bool ok = true;
    rep(k,n) if(max(c[i][j]-abs(i-vec[k][0])-abs(j-vec[k][1]), (ll)0) != vec[k][2]) ok = false; 
    if(ok) cout << i << " " << j << " " << c[i][j] << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
#define PAI 3.14159265358979
// ver1.6
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  int n;
  cin >> n;
  int count2=0,count4=0,count1=0;
  int memo;
  rep(i,0,n){
    cin >> memo;
    if(memo%4==0) count4++;
    else if(memo%2==0) count2++;
    else count1++;
  }
  if(count4>=count1) cout << "Yes" << endl;
  else if(count2==0 && count1-count4 <= 1 ) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){

  int size, n;
  cin >> size >> n; 
  while(n--){
    int x, y;
    cin >> x >> y;
    cout << min(min(x - 1, size - x), min(y - 1, size - y))%3 + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
using namespace std;
typedef long long int ll;
const ll INF = 1000000000000000000;


int main() {

	ll N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) cin >> A[i];

	while (true) {
		sort(A.begin(), A.end());
		A.erase(remove(A.begin(), A.end(), 0), A.end());
		if (accumulate(A.begin(), A.end(), 0ll) == A.size() * A[0]) {
			cout << A[0] << endl;
			break;
		}
		for (int i = 1; i < A.size(); ++i) A[i] %= A[0];
	}
}

Measured memory_bytes: 640
def main():
    n = int(input())

    S = [0 for i in range(n)]
    for i in range(n):
        S[i] = input()


    lst =[0,0,0,0,0]
    for i in S:
        if i[0] == "M":
            lst[0]+=1
        if i[0] == "A":
            lst[1]+=1
        if i[0] == "R":
            lst[2]+=1
        if i[0] == "C":
            lst[3]+=1
        if i[0] == "H":
            lst[4]+=1

    ans =0
    ans += lst[0] * lst[1] * lst[2]
    ans += lst[0] * lst[1] * lst[3]
    ans += lst[0] * lst[1] * lst[4]
    ans += lst[0] * lst[2] * lst[3]
    ans += lst[0] * lst[2] * lst[4]
    ans += lst[0] * lst[3] * lst[4]
    ans += lst[1] * lst[2] * lst[3]
    ans += lst[1] * lst[2] * lst[4]
    ans += lst[1] * lst[3] * lst[4]
    ans += lst[2] * lst[3] * lst[4]

    print(ans)


if __name__ == "__main__":
        main()


Measured memory_bytes: 9776
def primelist( pmax )

	primes = Array.new( pmax + 1 )
	primes[ 0 ] = 0 
	primes[ 1 ] = 0 
	2.upto( pmax ){ |i|
		primes[ i ] = 1
	}

	max = Math.sqrt( pmax ).to_i

	prime = 0
	while true
		(prime+1).upto( pmax ){ |t|
			if primes[ t ] != 0
				prime = t 
				break
			end
		}
		break if prime > max 

		n = 2
		while prime * n <= pmax
			primes[ prime * n ] = 0
			n += 1
		end
	end

	plist = Array.new
	0.upto( pmax ).each{ |n|
		plist << n if primes[ n ] == 1
	}
	plist	
end

def get_answer( n )
	$plist.each_with_index{ |p,i|
		if p > n
			return i
		end
	}
	return $plist.size
end

$plist = primelist( 1000000 )
#p $plist
answer = Array.new
while line = $stdin.gets
	n = line.to_i
	answer << get_answer( n )
end
answer.each{ |a|
	puts a
}


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

int main() {
  int H, W;
  cin >> H >> W;
  
  string S0, S1;
  cin >> S0;
  if (H>1)
    cin >> S1;
    
  for (int j = 0; j < W; j++) {
    if (S0.at(j)=='#')
      cout << "#";
    else {                 ////if (S0.at(j)=='.')でもいいか？
      int count=0;
      if (j>0) {
      if (S0.at(j-1)=='#') //&&の条件必要か？
        count++;
      }
      if (j<W-1) {
      if (S0.at(j+1)=='#')
        count++;
      }
      
    if (H>1) {
      if (j>0) {
        if (S1.at(j-1)=='#')
          count++;
      }
        if (S1.at(j)=='#')
          count++;
      if (j<W-1) {
        if (S1.at(j+1)=='#')
          count++;
      }
      }
      cout << count;
    }                                   //else終了
  }   cout << endl;                     //0行目終了(Wまでループ完了)
  
  if (H>1) {
  
  string Sb, Sn, Sa;
  
  Sb=S0;
  Sn=S1;
  if (H>2)   //もしHが３以上なら
    cin >> Sa;   //2列目を入力し、以下の操作を行う
  
  for (int i = 0; i < H-1; i++) {  //0行目はやらない
    for (int j = 0; j < W; j++) {
      if (Sn.at(j)=='#')
        cout << "#";
      else {            ////if (S0.at(j)=='.')でもいいか？
        int count=0;
        if (j>0) {
        if (Sb.at(j-1)=='#')
          count++;
        }
        if (Sb.at(j)=='#')
          count++;
        if (j<W-1) {
        if (Sb.at(j+1)=='#')
          count++;
        }
        if (j>0) {
        if (Sn.at(j-1)=='#')
          count++;
        }
        if (j<W-1) {
        if (Sn.at(j+1)=='#')
          count++;
        }
        if (H>2 && i<H-2)  {
          if (j>0) {
          if (Sa.at(j-1)=='#')
            count++;
          }
          if (Sa.at(j)=='#')
            count++;
          if (j<W-1) {
          if (Sa.at(j+1)=='#')
            count++;
          }
        }
        cout << count;
        
      }//else終了
    }
    Sb=Sn;
    if (H>2)
      Sn=Sa;
    string S;
    if (i<H-2) {
      cin >> S;
      Sa=S;
    }cout << endl;
      
  }//H行まで終了
  }//もし２行以上なら、、終了
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
using namespace std;

int N;

int main()
{
    cin >> N;
    vector<int> p(N), q(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> p[i];
        --p[i];
    }

    for (int i = 0; i < N; ++i)
    {
        cin >> q[i];
        --q[i];
    }

    map<vector<int>, int> ord;
    int iter = 0;

    vector<int> v(N);
    for (int i = 0; i < N; ++i)
        v[i] = i;

    do
    {
        ord[v] = iter;
        ++iter;
    } while (next_permutation(v.begin(), v.end()));

    cout << abs(ord[p] - ord[q]) << endl;
}

Measured memory_bytes: 5248
// 2019/03/05 Tazoe

#include <iostream>
#include <map>
#include <string>
using namespace std;

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

	map<string, int> sum;

	for(int i=0; i<n; i++){
		string s;
		int m;
		cin >> s >> m;

		switch(s.size()){
		case 1:
			s = "1"+s;
			break;
		case 2:
			s = "2"+s;
			break;
		case 3:
			s = "3"+s;
			break;
		case 4:
			s = "4"+s;
			break;
		case 5:
			s = "5"+s;
			break;
		default:
			break;
		}

		if(sum.find(s) != sum.end()){
			sum[s] += m;
		}
		else{
			sum[s] = m;
		}
	}

	map<string, int>::iterator p;
	for(p = sum.begin(); p != sum.end(); p++){
		string s = p->first;
		s.erase(0, 1);
		cout << s << ' ' << p->second << endl;
	}

	return 0;
}



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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

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

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

  string s;
  cin >> s;

  vector<int> cnt(4);

  rep(i, s.length()){
    if(s[i] == 'N'){
      cnt[0]++;
    }else if(s[i] == 'S'){
      cnt[1]++;
    }else if(s[i] == 'W'){
      cnt[2]++;
    }else{
      cnt[3]++;
    }
  }

  bool ok = true;
  if(cnt[0]*cnt[1]==0 && cnt[0]+cnt[1]>0){
    ok = false;
  }

  if(cnt[2]*cnt[3]==0 && cnt[2]+cnt[3]>0){
    ok = false;
  }

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



  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int H, W, M; cin >> H >> W >> M;
    vector<int> h(H), w(W);
    set<P> bombs;
    rep(i,M){
        int a, b; cin >> a >> b;
        a--, b--;
        bombs.insert(P(a,b));
        h[a]++;
        w[b]++;
    }
    int mx_h = 0, mx_w = 0;
    vector<int> hs, ws;
    rep(i, H) if(mx_h < h[i]) mx_h = h[i];
    rep(i, W) if(mx_w < w[i]) mx_w = w[i];
    rep(i, H) if(h[i] == mx_h) hs.push_back(i);
    rep(i, W) if(w[i] == mx_w) ws.push_back(i);
    int ans = mx_h + mx_w;
    rep(i, hs.size()){
        rep(j, ws.size()){
            if(bombs.count(P(hs[i], ws[j]))) continue;
            cout << ans << endl;
            return 0;
        }
    }
    cout << ans - 1 << endl;
    return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

ll AA[111111];
ll BB[111111];

int main(){
	int n,k;
	cin >> n >> k;
	vector<ll> a;
	vector<ll> b;
	
	REP(i,n) {
		int tmp;cin >> tmp;
		if(tmp > 0)a.PB(tmp);
		else b.PB(-tmp);
	}
	
	sort(ALL(a));
	sort(ALL(b));
	
	REP(i,111110){
		AA[i+1] = LLINF;
		BB[i+1] = LLINF;
	}
	
	REP(i,a.size()){
		AA[i+1] = a[i]*2;
	}
	
	REP(i,b.size()){
		BB[i+1] = b[i]*2;
	}
	
	ll ans = LLINF;
	
	REP(i,a.size()){
		if(k-i-1 >= 0 && BB[k-i-1] != LLINF){
			ans = min(ans,a[i]+BB[k-i-1]);
		}
	}
		
	REP(i,b.size()){
		if(k-i-1 >= 0 && AA[k-i-1] != LLINF){
			ans = min(ans,b[i]+AA[k-i-1]);
		}
	}
	
	cout << ans << endl;
		
	
	return 0;
}


Measured memory_bytes: 3316
#include<stdio.h>
int main() {
	int a, b, c;
	while (1) {
		scanf("%d%d", &a, &b);
		if (a == 0 && b == 0) {
			break;
		}
		else if (a > b) {
			c = a;
			a = b;
			b = c;
			printf("%d %d\n", a, b);
		}
		else {
			printf("%d %d\n", a, b);
		}
	}
	return 0;
}

Measured memory_bytes: 1688
#include<iostream>
#include<cstdio>

using namespace std;

void trace(int a[],int n){
	for(int i=0;i<n;i++){
		if(i) printf(" ");
		printf("%d",a[i]);
	}
	printf("\n");
}

/*void insertsort(int a[],int n){

	for(int i=1;i<n;i++){
		int v=a[i];
		int j=i-1;
		while(j>=0 && v<a[j]){
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=v;
		trace(a,n);
	}
	return;
}*/

int bubblesort(int a[],int n){
	int flag=1;
	int sw=0;
	for(int i=0;flag;i++){
		flag=0;
		for(int j=n-1;j>=i+1;j--){
			if(a[j]<a[j-1]){
				swap(a[j],a[j-1]);
				flag=1;
				sw++;
			}
		}
	}
	return sw;
} 

int main(){
	int n,a[101];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int sw=bubblesort(a,n);
	trace(a,n);
	printf("%d\n",sw);
	return 0;
}


Measured memory_bytes: 3208
#include<iostream>
using namespace std;
int main()
{
    int n,k,i,j;
    cin>>n>>k;
    int *arr=new int[n];
    for(i=0;i<n;i++) cin>>arr[i];
    bool *dp=new bool[k+1]; //whether the person who starts it wins it or not
    dp[0]=false;
    for(i=0;i<=k;i++)
    {
        for(j=0;j<n;j++)
        {
            if(arr[j]<=i)   if(!dp[i-arr[j]]) break;
        }
        if(j<n) dp[i]=true;
        else dp[i]=false;
    }
    if(dp[k]) cout<<"First";
    else cout<<"Second";
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define repa(i, a, b) for (auto i = (a); i <= (b); i++)
#define repd(i, a, b) for (auto i = (a); i >= (b); i--)
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define zero(a)  memset((a), 0, sizeof (a))
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back

constexpr auto inf = numeric_limits<int>().max();
constexpr auto llinf = numeric_limits<ll>().max();

template<typename ForwardIterator>
void dump(ForwardIterator st, ForwardIterator en) {
	for (auto it = st; it != en; it++) {
		cout << *it << " ";
	}
	cout << endl;
}

template<typename ForwardIterator>
void dump_map(ForwardIterator st, ForwardIterator en) {
	for (auto it = st; it != en; it++) {
		cout << (*it).first << ":" << (*it).second << " ";
	}
	cout << endl;
}

template<typename T>
void debug(initializer_list<T> list) {
  for (auto el : list) {
    cout << el << " ";
  }
  cout << endl;
}

constexpr auto mxN = 1000010;
// bitset<mxN> primes;
// vector<ll> primeset;

// void sieve() {
// 	primes.set();
// 	primes.reset(1);
// 	repa(i, 2, mxN - 1) {
// 		if (!primes.test(i)) {
// 			continue;
// 		}
// 		for (auto j = i * 2; j < mxN; j += i) {
// 			primes.reset(j);
// 		}
// 	}
// 	repa (i, 2, mxN - 1) {
// 		if (primes.test(i)) {
// 			primeset.pb(ll(i));
// 		}
// 	}
// }

// ll maxn(ll p) {
// 	auto n = 1LL;
// 	while (n * (n + 1LL) / 2LL <= p) n++;
// 	return n - 1;
// }

// bool isprime(ll n) {
// 	auto i = 2LL;
// 	if (n == 1LL) {
// 		return false;
// 	}
// 	while (i * i <= n) {
// 		if (n % i == 0LL) {
// 			return false;
// 		}
// 		i++;
// 	}
// 	return true;
// }

// ll times(ll num, ll div) {
// 	auto t = 0;
// 	while (num % div == 0) {
// 		t++;
// 		num /= div;
// 	}
// 	return t;
// }

void solve() {
	ll n;
	cin >> n;
	// if (isprime(n)) {
	// 	cout << "1\n";
	// 	return;
	// }
	// sieve();
	// auto idx = 0;
	// auto tot = 0LL;
	// while (primeset[idx] <= lim) {
	// 	auto t = times(n, primeset[idx]);
	// 	tot += maxn(t);
	// 	++idx;
	// }
	// auto i = 2LL;
	// while (i * i <= n) {
	// 	if (n % i == 0 && isprime(i)) {
	// 		auto t = times(n, i);
	// 		tot += maxn(t);
	// 	}
	// 	i++;
	// }
	// cout << tot;
	int tot = 0;
	repa(i, 2, mxN) {
		int cur = 0;
		while (n % i == 0) {
			cur++;
			n /= i;
		}
		int j = 1;
		while (j <= cur) {
			++tot;
			cur -= j;
			++j;
		}
	}
	if (n != 1) ++tot;
	cout << tot;
	cout << "\n";
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>

using namespace std;

int main(void){
    int N,A,B,P;
    int c_gp1=0,c_gp2=0,c_gp3=0,c_min=10000000;
    int i;
    
    cin>>N;
    cin>>A>>B;

    for(i=0;i<N;i++){
        cin>>P;
        if(P>= B+1){
            c_gp3++;
        }else if(P<=B && P >= A+1){
            c_gp2++;
        }else{
            c_gp1++;
        }
    }

    if(c_min > c_gp1){
        c_min = c_gp1;
    }
    if( c_min> c_gp2){
        c_min = c_gp2;
    }
    if( c_min > c_gp3){
        c_min=c_gp3;
    }

    cout<<c_min<<endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 //------------------------------------------
inline int toInt(std::string s) {int v; std::istringstream sin(s);sin>>v;return v;}
template<class T> inline std::string toString(T x) {std::ostringstream sout;sout<<x;return sout.str();}

int main(){
  string a,b;
  cin>>a>>b;
  string foo=a+b;
  int ans=toInt(foo);

  int cnt=(int)sqrt((double)ans);

  if(cnt*cnt==ans){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
 
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            int num = Integer.parseInt(br.readLine());
            long worstLank = 0;
            long worstScore = 0;
            for (int i = 0; i < num; i++) {
                String strArr[] = br.readLine().split(" ");
                long a = Long.parseLong(strArr[0]);
                long b = Long.parseLong(strArr[1]);
                if (i == 0 || a > worstLank) {
                    worstLank = a;
                    worstScore = b;
                }
            }
            for (long i = worstScore; i > 0; i--) {
                worstLank++;
            }
            System.out.println(worstLank);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 46896
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt, pi
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N, M = getNM()
X = getList()
Y = getList()

X.sort(reverse = True)
Y.sort(reverse = True)
XP, YP = 0, 0
for i in range(N):
  XP += (N - 1 - i * 2) * X[i]
  XP %= mod
for i in range(M):
  YP += (M - 1 - i * 2) * Y[i]
  YP %= mod

print((XP * YP) % mod)

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

using namespace std;


int main(){
    string s;
    cin>>s;
    for(int i=0;s[i];i++){
        cout<<s[i];
        if(!s[i+1])
        {
           if(s[i]=='s')
            cout<<"es";
           else
            cout<<"s";
        }
    }
}
//https://codeforces.com/gym/295499/problem/E



Measured memory_bytes: 3628
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        Console.WriteLine(
            (s[1] == s[2] && (s[1] == s[0] || s[1] == s[3])) ?
            "Yes" : "No"
            );
    }
}


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

int main(){
    string s;
    cin >> s;
    bool ans=true;bool odd=true;
    for(int i=0;i<s.size();i+=2){
        if(s[i]=='L' ) odd = false; 
    }
    for(int i=1;i<s.size();i+=2){
        if(s[i]=='R' || !odd) ans = false;
    }
    if (s.size()==1 && !odd) ans = false;
    cout << ( ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  int N; cin>>N;
  vi P(N); REP(i,N) cin>>P[i];

  vi lo(N, 0); // lo[i] := [0,i] での最小値
  lo[0] = P[0];
  FOR(i,1,N) {
    lo[i] = min(lo[i-1], P[i]);
  }

  int ans=0;
  REP(i,N) {
    if (lo[i]>=P[i]) ans++;
  }

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 1792
N = int(input())

A = list(map(int, input().split(' ')))


volume = 0
for j in range(N):
    if j % 2 == 0:
        volume += A[j]
    else:
        volume -= A[j]
print(volume ,end=' ')

for i in range(1, N):
    volume = 2 * A[i - 1] - volume
    print(volume ,end=' ')

print()

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

using namespace std;

int main(){
  long long int N;
  cin >> N;
  
  map<int, string>  alp;
  alp[0]="a";
  alp[1]="b";
  alp[2]="c";
  alp[3]="d";
  alp[4]="e";
  alp[5]="f";
  alp[6]="g";
  alp[7]="h";
  alp[8]="i";
  alp[9]="j";
  alp[10]="k";
  alp[11]="l";
  alp[12]="m";
  alp[13]="n";
  alp[14]="o";
  alp[15]="p";
  alp[16]="q";
  alp[17]="r";
  alp[18]="s";
  alp[19]="t";
  alp[20]="u";
  alp[21]="v";
  alp[22]="w";
  alp[23]="x";
  alp[24]="y";
  alp[25]="z";
  
  string O;
  
  
  for(long long int i=0;N>0;i++){
    N = N-1;
    O = alp[N%26] + O;
    N = N/26;
  }
  cout << O << endl;
  return 0;
}


Measured memory_bytes: 3624
import sys
l,r = map(int,input().split())


#lとrの間に2019のばいすうがあるばあい
num = 2019
while(num<2*10**9):
    if l<=num<=r:
        print(0)
        sys.exit()
    num += 2019
 


min_num  = 2020


while(l < r):
    t = 1
    while(l+t)<=r:
        
        #print(str(l)+"*"+str(l+t)+"≡"+str((l*(l+t))%2019)+"mod(2019)")
        if (l*(l+t))%2019 < min_num:
            min_num = (l*(l+t))%2019
            if min_num == 0:
                print(0)
                sys.exit()
            
        t+=1
        
    l +=1
    
print(min_num)

Measured memory_bytes: 3064
//In the name of GOD
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const ll maxn = 2e5 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt" , "r+" , stdin) ; freopen("output.txt" , "w+" , stdout);
#define pb push_back
#define Mp make_pair
#define pll pair<ll, ll>
#define F first
#define S second

ll n, c[maxn], ans, x;

int main(){
	fast_io;
	
	for(ll i = 1; i < 100; i++){
		c[i * (i + 1) / 2]++;
	}
	for(ll i = 1; i < maxn; i++){
		c[i] += c[i - 1];
	}
	cin >> n;
	for(ll i = 2; i * i <= n; i++){
		if(n % i == 0){
			x = 0;
			while(n % i == 0) n /= i, x++;
			ans += c[x];
		}
	}
	if(n != 1) ans++;
	cout << ans;
	
	return 0;
}


Measured memory_bytes: 5164
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.endl(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  // cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  int n;
  cin >> n;
  vecint a(n);
  vector<vector<P>> xy(n);
  REP(i, n) {
    cin >> a[i];
    REP(j, a[i]) {
      int x, y;
      cin >> x >> y;
      x--;
      xy[i].push_back(make_pair(x, y));
    }
  }
  int ans = 0;
  REP(bit, 1 << n) {
    vecint honest(n, 0);
    int cnt = 0;
    REP(j, n) {
      if ((bit >> j) & 1) {
        honest[j] = 1;
        cnt++;
      }
    }
    bool ok = true;
    REP(j, n) {
      if (!honest[j]) continue;
      REPe(e, xy[j]) {
        if (honest[e.first] != e.second) {
          ok = false;
          break;
        }
      }
    }
    if (ok) ans = max(cnt, ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,  n) for (int i  =  0; i < (int)(n); ++i)
#define REPR(i,  n) for (int i  =  n - 1; i >= 0; --i)
using namespace std;
#define int long long int
//------------ATCODER TEMPLATE-------------

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

  int cnt = 0;
  int l = 0, r = N - 1;
  while (l < r) {
    while (S[l] == 'R' && l < N) ++l;
    while (S[r] == 'W' && r >=0) --r;
    if (l < r) {
      S[l] = 'R';
      S[r] = 'W';
      ++cnt;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3752
$A, $B, $C, $X, $Y = gets.chomp.split(' ').map(&:to_i)

def min(a, b)
  a < b ? a : b
end

def min_3(a, b, c)
  min(min(a, b), c)
end

res = if $X < $Y
        min_3($Y * 2 * $C, $A * $X + $B * $Y, $X * 2 * $C + ($Y - $X) * $B)
      else
        min_3($X * 2 * $C, $A * $X + $B * $Y, $Y * 2 * $C + ($X - $Y) * $A)
      end

puts res


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

int main(void){
	int A,B;
	cin>>A>>B;
	
	printf("%d\n",(A+B)%24);

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll a,b,x;
    cin >> x >> a >> b;
    cout << (x-a)%b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

static const int N=100;

using namespace std;

int main()
{
    int n,p[N+1],m[N+1][N+1];
    cin>>n;
    for (int i = 1; i <= n; i++)
    {
        cin>>p[i-1]>>p[i];
    }
    for(int i=1;i<=n;i++)m[i][i]=0;
    for(int l=2;l<=n;l++)
    {
        for (int i = 1; i <=n-l+1 ; i++)
        {
            int j=i+l-1;
            m[i][j]=(1<<21);
            for(int k=i;k<=j-1;k++)
            {
                m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
            }
        }
    }

    cout<<m[1][n]<<endl;

    return 0;
}



Measured memory_bytes: 3116
from collections import *
n,m=map(int,input().split())
l=list(map(int,input().split()))
k=len(set(l))
if(k<=m):
    print(0)
else:
    d=defaultdict(int)
    for i in l:
        d[i]+=1
    f=list(d.values())
    f.sort()
    g=k-m
    c=0
    for i in range(g):
        c+=f[i]
    print(c)


Measured memory_bytes: 152760