akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
typedef long long ll;

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

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

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll divc = b/c - (a+c-1)/c + 1;
    ll divd = b/d - (a+d-1)/d + 1;
    ll g = lcm(c,d);
    ll divcd = b/g - (a+g-1)/g + 1;
    cout << (b-a+1) - divc - divd + divcd << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::{Read, stdin};

fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    let mut buf = String::new();
    stdin.read_to_string(&mut buf).unwrap();
    let mut buf = buf.split_whitespace();

    let a: i32 = buf.next().unwrap().parse().unwrap();
    let b: i32 = buf.next().unwrap().parse().unwrap();

    println!("{} {}", a * b, (a + b) * 2);
}


Measured memory_bytes: 5024
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define repr(i, a, b) for (int i = (int)a; i > (int)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 4e18 + 5;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    if (s=="Sunny"){
        cout << "Cloudy" << ENDL;
    }
    else if (s=="Cloudy"){
        cout << "Rainy" << ENDL;
    }
    else{
        cout << "Sunny" << ENDL;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-3;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
const int intmax = 2147483647;
struct SegT {
private:
	int n; vector<ll> node;
public:
	SegT(int sz) {
		n = 1;
		while (n < sz)n <<= 1;
		//nodeの初期化
		node.resize(2 * n - 1, 0);
	}
	ll f(ll a, ll b) {
		return max(a, b);
	}
	void init(vector <ll> v) {
		rep(i, v.size()) {
			node[i + n - 1] = v[i];
		}
		per(i, n - 1) {
			node[i] = f(node[2 * i + 1], node[2 * i + 2]);
		}
	}
	void update(int x, ll val) {
		x += (n - 1);
		node[x] = val;
		while (x > 0) {
			x = (x - 1) >> 1;
			node[x] = f(node[2 * x + 1], node[2 * x + 2]);
		}
	}
	ll query(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0)r = n;
		if (r <= a || b <= l)return 0;
		if (a <= l && r <= b)return node[k];
		ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
		ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
		return f(vl, vr);
	}
};
int n, h[1 << 18]; vector<ll> a;
ll dp[1 << 18];
int main() {
	cin >> n;
	a.resize(n);
	rep(i, n) {
		cin >> h[i]; h[i]--;
	}
	rep(i, n)cin >> a[i];
	SegT s(n);
	rep(i, n) {
		ll val = s.query(0, h[i]);
		dp[i] = val + a[i];
		s.update(h[i], dp[i]);
		//cout << dp[i] << endl;
	}
	ll ans = 0;
	rep(i, n)ans = max(ans, dp[i]);
	cout << ans << endl;
	//stop
	return 0;
}

Measured memory_bytes: 8320
import math
n,d = map(int,input().split())
x = [list(map(int,input().split())) for _ in range(n)]
ans = 0
for i in range(n-1):
  for j in range(i+1,n):
    num = 0
    for k in range(d):
      num += (x[i][k]-x[j][k])**2
    if num == int(math.sqrt(num))**2:
      ans += 1
    else:
      continue
print(ans)

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

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

  int a[n][m],b[m];

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin >> a[i][j];
    }
  }

  for(int i=0;i<m;i++){
    cin >> b[i];
  }

  int ans[n];
  for(int i=0;i<n;i++){
    ans[i] = 0;
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      ans[i]+=a[i][j]*b[j];
    }
  }

  for(int i=0;i<n;i++){
    cout << ans[i] << endl;
  }

  return 0;
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int in(){int x; scanf("%d",&x); return x;}
static const int MAX = 100000;


int main(){
  int N = in(), h[MAX], x = 0;
  rep(i, N) h[i] = in();

  rep(i, N-1){
    if(h[i+1] - h[i] >= 1) h[i+1]--;
    else if(h[i+1] - h[i] <= -1){
      cout << "No" << endl;
      x = 1;
      break;
    }
  }
  if(x == 0) cout << "Yes" << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

  
public class Main {
	
	
  public static void main(String[] args) {
	  Scanner sc=new Scanner(System.in);
	Double r=Double.parseDouble(sc.next());
	double p=Math.PI;
	double s=r*r*p;
	double l=2*r*p;
	System.out.printf("%.6f",s);
	System.out.print(" ");
	System.out.printf("%.6f\n",l);
	
  }
}

Measured memory_bytes: 17312
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
  vector<int> A(5);
  cin >> A[0] >> A[1] >> A[2] >> A[3] >> A[4];
  vector<int> P = {0, 1, 2, 3, 4};
  int final_answer = 1e9;
  do
  {
    int ans = 0;
    for (int i = 0; i < 5; i++)
    {
      while (ans % 10 != 0)
      {
        ans += 1; // 10の倍数になるまで
      }
      ans += A[P[i]];
    }
    final_answer = min(final_answer, ans);
  } while (next_permutation(P.begin(), P.end()));

  cout << final_answer << endl;
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  const int64_t mod=1e9+7;
  vector<int> v(N,0);
  for(int i=0;i<N;i++){
    int A;
    cin >> A;
    if(N%2==0){
      if(A%2==0){
        cout << 0 << endl;
        return 0;
      }
    }else{
      if(A%2!=0){
        cout << 0 << endl;
        return 0;
      }
    }
    v.at(A)++;
    if(A==0){
      if(v.at(A)>1){
        cout << 0 << endl;
        return 0;
      }
    }else{
      if(v.at(A)>2){
        cout << 0 << endl;
        return 0;
      }
    }
  }
  int64_t ans=1;
  int n=N/2;
  for(int i=0;i<n;i++){
    ans*=2;
    ans%=mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define FOR(i,x,y) for(int i=x;i<y;i++)
using namespace std;
int main(){
  vector<char> editor;
  char c;
  while(cin >> c){
    if(c == '0')editor.push_back('0');
    else if(c == '1')editor.push_back('1');
    else if(editor.size())editor.pop_back();
  }
  for(auto x:editor)cout << x;
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

class RUQ{
public:
  int t[555555],v[555555],c;
  void init(){
    c=0;
    memset(t,0,sizeof(t));
    memset(v,0,sizeof(v));
  }
  void update(int a,int b,int x) {
    c++;
    v[c]=x;
    update2(a,b,c);
  }
  void update2(int a,int b,int x,int k=0,int l=0,int r=1<<18){
    if(b<=l||r<=a)return;
    if(a<=l&&r<=b){t[k]=max(t[k],x);return;}
    int m=(l+r)/2;
    update2(a,b,x,k*2+1,l,m);
    update2(a,b,x,k*2+2,m,r);
  }
  int query(int i){
    i+=(1<<18)-1;
    int res=t[i];
    while(i){
      i=(i-1)/2;
      res=max(res,t[i]);
    }
    return v[res];
  }
};

void Main() {
  int n,m;
  cin >> n >> m;
  RUQ r;
  r.init();
  r.v[0]=INT_MAX;
  while(m--) {
    int z,x;
    cin >> z >> x;
    if(!z) {
      int y,w;
      cin >> y >> w;
      r.update(x,y+1,w);
    } else pr(r.query(x));
  }
}

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


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

bool sosuu(int x){
  if(x==0 || x==1) return false;
  for(int i=2;i*i<=x;i++){
    if(x%i==0) return false;
  }
  return true;
}

int main(void){

  int N,x,cnt=0;
  cin >> N;

  for(int i=0;i<N;i++){
    cin >> x;
    cnt+=sosuu(x);
  } 

  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 3116
# ABC109 B - Shiritori 
n = int(input())
L = [input() for i in range(n)]
ans = "Yes"
if len(L) != len(set(L)):
    ans = "No"
for i in range(n-1):
    if L[i][-1] !=L[i+1][0]:
        ans ="No"
print(ans)

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

using namespace std;

using int64 = long long;

constexpr int DEBUG = 0;

class OnlineMedian {
 private:
  priority_queue<int64, vector<int64>, less<int64>> pq_less;
  priority_queue<int64, vector<int64>, greater<int64>> pq_greater;
 public:
  void Add(int64 x) {
    if (pq_less.empty() || x <= pq_less.top()) {
      pq_less.push(x); pq_less.push(x);
    } else {
      pq_greater.push(x); pq_greater.push(x);
    }
    if (pq_less.size() > pq_greater.size()) {
      int64 t = pq_less.top(); pq_less.pop(); pq_greater.push(t);
    } else if (pq_greater.size() > pq_less.size()) {
      int64 t = pq_greater.top(); pq_greater.pop(); pq_less.push(t);
    }
  }
  // Returns a median. When there are two, returns a less one.
  int64 LessMedian() { return pq_less.top(); }
  // Returns a median. When there are two, returns a greater one.
  int64 GreaterMedian() { return pq_greater.top(); }
  bool Empty() { return pq_less.empty(); }
};

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

  int num_queries;
  cin >> num_queries;

  OnlineMedian online_median;
  int64 absolute_sum = 0;
  int64 base = 0;
  for (int i = 0; i < num_queries; i++) {
    int command;
    cin >> command;
    if (command == 1) {
      int64 a, b;
      cin >> a >> b;

      base += b;

      if (!online_median.Empty()) {
        if (a > online_median.GreaterMedian()) {
          absolute_sum += a - online_median.GreaterMedian();
        } else if (a < online_median.LessMedian()) {
          absolute_sum += online_median.LessMedian() - a;
        }
      }

      online_median.Add(a);
    } else {
      // Output
      cout << online_median.LessMedian() << " "
          << absolute_sum + base << endl;
    }
  } 
}


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

int main()
{
    int h,w;
    cin >> h >> w;
    vector<string> v(h);

    for(size_t i=0; i<v.size();i++){
        cin >> v.at(i);
    }

    for(size_t i=0;i<v.size();i++){
        for(size_t j=0;j<v.at(i).size();j++){

            if(v.at(i).at(j)=='.'){
                int count =0;
                if(i!=0){
                    if(v.at(i-1).at(j)=='#')
                        count++;
                    if(j!=0)
                        if(v.at(i-1).at(j-1)=='#')
                            count++;
                    if(j!=v.at(i).size()-1)
                        if(v.at(i-1).at(j+1)=='#')
                            count++;
                }
                if(i!=v.size()-1){
                    if(v.at(i+1).at(j)=='#')
                        count++;
                    if(j!=0)
                        if(v.at(i+1).at(j-1)=='#')
                            count++;
                    if(j!=v.at(i).size()-1)
                        if(v.at(i+1).at(j+1)=='#')
                            count++;
                }
                if(j!=0)
                    if(v.at(i).at(j-1)=='#')
                        count++;
                if(j!=v.at(i).size()-1)
                    if(v.at(i).at(j+1)=='#')
                        count++;
                if(j==v.at(i).size()-1)
                    cout << count <<endl;
                else
                    cout << count;
            }else{
                if(j==v.at(i).size()-1)
                    cout << '#' <<endl;
                else
                    cout << '#';
            }
        }
    }
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int A[10], MAX=0, i;
    for(i=0; i<3; i++){
        scanf("%d", A+i);
        if(MAX < A[i]) MAX = A[i];
    }
    printf("%d\n", A[0]+A[1]+A[2]-MAX);
    return 0;
}


Measured memory_bytes: 128
//Keep calm and carry on..

/*  Problem :
    URL :

*/

#include<bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;


# define fast           ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
# define pb             push_back
# define pi             3.1415926535897932384626
# define mod            1000000007
# define endl          '\n'
# define DEBUG          false
# define F              first
# define S              second
# define loop1(i,a,b)   for(ll i = a; i<b; i++)
# define loop2(i,a,b)   for(ll i = b-1; i>=a; i--)
# pragma GCC optimize "trapv"


 int main(){
     fast;
     ll a,b,c,d;		cin>>a>>b>>c>>d;

     if ( ((b*d) > 0) || ((a*c) > 0) )		cout<<max(b*d,a*c);
     else {
        if (b*d < 0){
           cout<<max(a*d,c*b);
        }
        else cout<<0;

     }



     return 0;
}



Measured memory_bytes: 3668
alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
while True:
    n = int(input())
    if n == 0:
        break
    else:
        k = [int(k) for k in input().split()]
        s = list(input())
        for i in range(1,len(s)+1):
            if (i) % len(k) == 0:
                s[i-1] = alphabet[alphabet.index(s[i-1])-k[len(k)-1]]
            else:
                s[i-1] = alphabet[alphabet.index(s[i-1])-k[i % len(k)-1]]
        print("".join(s))


Measured memory_bytes: 5624
from functools import lru_cache

@lru_cache(maxsize=None)
def is_possible(n, target, total):
    if n == 0:
        return total == target
    return is_possible(n-1, target, total) or is_possible(n-1, target, total + A[n-1])


n = int(input())
A = [int(i) for i in input().split()]
_ = int(input())


for target in map(int, input().split()):
    print('yes' if is_possible(n, target, 0) else'no')



Measured memory_bytes: 135424
#include <stdio.h>


int main(void){
    int a, b, m;
    scanf("%d %d %d", &a, &b, &m);
    int la[a], lb[b];
    int i;
    int a_min, b_min;
    a_min = 100000;
    b_min = 100000;
    for(i = 0 ; i < a ; i++){
        scanf("%d", &la[i]);
        if(la[i] < a_min){
            a_min = la[i];
        }
    }
    for(i = 0 ; i < b ; i++){
        scanf("%d", &lb[i]);
        if(lb[i] < b_min){
            b_min = lb[i];
        }
    }
    int ans, x_a, x_b, c, anss;
    ans = a_min + b_min;
    for(i = 0 ; i < m ; i++){
        scanf("%d %d %d", &x_a, &x_b, &c);
        anss = la[x_a-1] + lb[x_b - 1] - c;
        if(anss < ans){
            ans = anss;
        }
    }
    printf("%d\n", ans);


    return 0;
}

Measured memory_bytes: 896
from collections import deque

if __name__ == '__main__':
	n = int(input())
	tmp = deque()
	for i in range(n):
		command = input()
		if command == "deleteFirst":
			tmp.popleft()
		elif command == "deleteLast":
			tmp.pop()
		else:
			c,d = command.split()
			if c == "insert":
				tmp.appendleft(int(d))
			elif c == "delete":
				try:
					tmp.remove(int(d))
				except:
					pass
	print(*tmp)


Measured memory_bytes: 45948
#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main(){
    string s;
    cin>>s;
    int sum=0;
    for(auto it:s){
        sum+=it-'0';
    }
    if(sum%9==0)
        cout<<"Yes";
    else
        cout<<"No";
}

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60, lmod = 1e9+7;

const int MAX_N = 100005;

int a[MAX_N],b[32];

int main(){
  int N; cin >> N;
  rep(i,N) scanf("%d",a+i);
  sort(a,a+N);
  int ans = 0,bit = 0;
  fill(b,b+32,0);
  rep(i,N){
    bit ^= a[i];
    rep(j,32){
      if((a[i]&(1<<j))!=0){
        b[j]++; break;
      }
    }
  }
  rrep(j,31){
    if((bit&(1<<j))==0) continue;
    if(b[j]!=0) ans++;
    else{
      cout << "-1" << endl;
      return 0;
    }
    bit ^= ((1<<j)-1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long a[100000];
int main()
{
	int n;
	long long ba=1,bz=1;
	cin>>n;
	for(int t=0;t<n;t++)
	{
		cin>>a[t];
		if(a[t]==0)
		{
			cout<<0;
			return 0;
		}
	}
	for(int t=0;t<n;t++)
	{
	    //cout<<"hi ";
		//if(ba/1!=1)
		if(t)
		if(ba/a[t-1]!=bz||ba>1000000000000000000)
		{
			cout<<"-1";
			return 0;
		}
		bz=ba;
		ba*=a[t];
	}
	if(ba/a[n-1]!=bz||ba>1000000000000000000)
		{
			cout<<"-1";
			return 0;
		}
	cout<<ba;
	return 0;
}

Measured memory_bytes: 4392
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
using namespace std;
char t[200000];
char d[200000];
int main()
{
	string s;
	int n,q;
	cin>>n>>q;
	cin>>s;
	for(int i=0;i<q;i++)
		cin>>t[i]>>d[i];
	int l;//左に落ちる最も右側
	int r;//右に落ちる最も左側
	//左を調べる
	int ok=-1;
	int ng=n;
	while(ng-ok>1)
	{
		int mid=(ok+ng)/2;
		int now=mid;//midのゴーレムが落ちることができるか調べる
		for(int i=0;i<q;i++)
		{
			if(now==-1 || now==n)
				break;
			if(t[i]==s[now])
			{
				if(d[i]=='L')
					now--;
				else
					now++;
			}
		}
		if(now==-1)
			ok=mid;
		else
			ng=mid;
	}
	l=ok;
	//右を調べる
	ok=n;
	ng=-1;
	while(ok-ng>1)
	{
		int mid=(ok+ng)/2;
		int now=mid;//midのゴーレムが落ちることができるか調べる
		for(int i=0;i<q;i++)
		{
			if(now==-1 || now==n)
				break;
			if(t[i]==s[now])
			{
				if(d[i]=='L')
					now--;
				else
					now++;
			}
		}
		if(now==n)
			ok=mid;
		else
			ng=mid;
	}
	r=ok;
	cerr<<l<<" "<<r<<endl;
	cout<<r-l-1<<endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    set<int> a;
    for(int i = 0; i < n; i++){
        int temp;
        cin >> temp;
        a.insert(temp);
    }
    int k = a.size();
    cout << ((n - k) % 2 ? k-1 : k) << endl;
    return 0;
}

Measured memory_bytes: 8224
from collections import Counter
N = int(input())
a = [int(i) for i in input().split()]
for i in range(N):
    if a[i] % 4 == 0:
        a[i] = 0
    elif a[i] % 4 == 2:
        a[i] = 2
    else:
        a[i] = 1
counts = dict(Counter(a))
flag = False
if 1 in counts:
    if 0 in counts:
        if 2 in counts:
            if counts[0] >= counts[1]:
                flag = True
        
        else:
            if counts[0] == counts[1]-1:
                flag = True
        
else:
    if 2 in counts:
        if counts[2] >= 2:
            flag = True
        else:
            if 0 in counts:
                flag = True
                
    else:
        if 0 in counts:
            flag = True
                

    
print('Yes' if flag==True else 'No')
    


Measured memory_bytes: 62576
n = int(input())
cnt = 0
moji = {}
for i in range(n):
    s = ''.join(sorted(list(input())))
    if not s in moji.keys():
        moji[s] = 0
    cnt += moji[s]
    moji[s] += 1
print(cnt)


#以下は、途中まで正解しているが、実行時間が長すぎる
"""
n = int(input())
s = []
ans = 0
for i in range(n):
    a = list(input())
    a.sort()
    s.append("".join(a))

x = set(s)
y = []
for i in range(len(x)):
    y.append(s.count(s[i]))

#print(y)
for j in range(len(y)):
    ans += int((y[j]*(y[j]-1))/2)

print(ans)
"""

Measured memory_bytes: 17808
N=int(input())
txy=[[0,0,0]]+[list(map(int,input().split())) for _ in range(N)]
for i in range(N):
    dist=abs(txy[i+1][1]-txy[i][1])+abs(txy[i+1][2]-txy[i][2])
    if dist>(txy[i+1][0]-txy[i][0]) or (txy[i+1][0]-txy[i][0]-dist)%2==1:
        print("No")
        break
else:
    print("Yes")

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

int main(){
    int n,m; cin >> n >> m;
    int ans = 0;
    vector<int> height(n,0);
    for(int i=0; i<n; ++i){
        int d; cin>>height[i];
    }
    vector<vector<int>> graph(n);
    for(int j=0; j<m; j++){
        int a,b; cin >> a >> b;
        a--;b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    
    for(int i=0; i<n; i++){
        int point = height[i];
        bool test = 1;
        for(int aa:graph[i]){
            if(height[aa]>=point) test = 0;
        }
        if(test) ans ++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8804
($n,$h)=glob<>;
for(1..$n){
    <>=~$";
    $m=$m>$`?$m:$`;
    $b[$_-1]=$';
}
@b=sort{$b-$a}@b;
for(@b){
    last if($_<$m);
    $h-=$_;
    $c++;
    exit!print$c if($h<=0)
}
print $c+int(--$h/$m+1)

Measured memory_bytes: 12544
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n,m; cin >> n >> m;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> sum(n+1,0);
    sort(all(a));
    rep(i,n)sum[i+1] = sum[i] + a[i];
    auto check = [&](ll x){
        bool ret = false;
        ll count = 0;
        rep(i,n){
            count += a.end() - lower_bound(all(a), x-a[i]);
        }
        if(m <=count)ret = true;
        // debug(x);debug(count);
        return ret;
    };
    ll ok = 0;
    ll ng = 1e6;
    while(abs(ok - ng) > 1){
        ll x = (ok + ng) / 2;
        if(check(x))ok = x;
        else ng = x;
    }
    // debug(ok);
    ll count = 0;
    ll ans = 0;
    rep(i,n){
        auto itr = upper_bound(all(a), ok- a[i]);
        count += a.end() - itr;
        ll index = itr - a.begin();
        ans += sum[n] - sum[index];
        ans += a[i] * (a.end() - itr);
    }
    if(count < m)ans += ok * (m - count);
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	int x=(A+D-1)/D;
	int y=(C+B-1)/B;
	cout<<(x>=y?"Yes":"No")<<'\n';
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(0); 
    cin.tie(0);   
	ll n,a[200009],res=1;
	string s;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n;i++)
	{
		if(res*a[i]>1000000000000000000 || (res*a[i]<=0) && a[0]!=0)
		{
			res=-1;
			break;
		}
		res*=a[i];
	}

	cout<<res;
	return 0;
}

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

using namespace std;
typedef long long LL;

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  int ans=0;
  if(A%2==B%2&&A%2!=C%2) A++, B++, ans++;
  else if(A%2==C%2&&A%2!=B%2) A++, C++, ans++;
  else if(B%2==C%2&&B%2!=A%2) B++, C++, ans++;
  int N=max({A,B,C});
  ans+=(3*N-A-B-C)/2;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  bool ans = 1;
  while(true){
    int size = s.size();
    if(s.substr(size-5) == "erase"){
      s.erase(size-5);
    }
    else if(s.substr(size-5) == "dream"){
      s.erase(size-5);
    }
    else if(s.substr(size-6) == "eraser"){
      s.erase(size-6);
    }
    else if(s.substr(size-7) == "dreamer"){
      s.erase(size-7);
    }
    else{
      ans = 0;
        break;
    }
    if(s.empty() == 1){
      break;
    }
  }
  if(ans){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;

int main()
{
	// #ifndef ONLINE_JUDGE
 //    freopen("inputf.in", "r", stdin);
 //    freopen("outputf.in", "w", stdout);
 //    #endif
    ll n;
    ll k;
    cin>>n>>k;
    if(n<k)
    {
    	cout<<min(n,abs(n-k));
    }
    else
    {
    	n=n%k;
    	if(n<abs(n-k))
    	{
    		cout<<n;
    	}
    	else
    	{
    		cout<<abs(n-k);
    	}

    }

}	

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ADD(X, Y) ((X) = ((X) + (Y)%MOD) % MOD)
#define LLINF LLONG_MAX / 3
#define INF 1001001001
#define PI 2*acos(0.0)
#define EPS 1e-10
// #define int long long
#define rep(i, n) for (int i = 0; i < n; ++i)
#define srep(i, s, n) for (int i = s; i < n; ++i)
#define rrep(i, n) for (int i = n-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end() 
#define rall(x) (x).rbegin(),(x).rend() 
#define debug(x) cout<<#x<<" = "<<x<<endl
typedef long long ll; 
typedef unsigned long long ull;
typedef vector<int> ivec;
typedef vector<ll> llvec;
typedef vector<string> svec;
typedef pair<int, int> pii;


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

    int K, T;
    cin >> K >> T;

    int a[T];
    rep(i, T) cin >> a[i];

    int ma;
    ma = a[0];
    rep(i, T) ma = max(ma, a[i]);

    int border;
    if (K % 2 == 0) border = K/2;
    else border = K/2 + 1;

    int sa = ma - border;

    if (sa <= 0) cout << 0 << endl;
    else if (K % 2 == 0) cout << 2*sa - 1 << endl;
    else cout << 2*sa << endl;

    

   
    return 0;
}

Measured memory_bytes: 256
//Sentou

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) int n;cin>>n;vector<int>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<int,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    int n,t;cin>>n>>t;
    vector<int>a(n);
    rep(i,0,n)cin>>a[i];
    ll ans = t;
    rep(i,1,n){
        if(a[i]-a[i-1]>t)ans+=t;
        else ans+=a[i]-a[i-1];
    }
    cout<<ans<<nnn;
    return 0;
}

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

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

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

    ll ans = n%k;
    while(1){
        if(abs(ans - k) < ans){
            ans = abs(ans - k);
        }else break;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
n,k = map(int, input().split())
al = list(map(int, input().split()))

next = [[0]*n for _ in range(60)]
for i in range(n):
    next[0][i] = al[i]-1

for p in range(1,60):
    for i in range(n):
        next[p][i] = next[p-1][next[p-1][i]]

res = 0
for p in range(59,-1,-1):
    if (k>>p)&1 == 1:
        res = next[p][res]

print(res+1)

Measured memory_bytes: 175816
#include<stdio.h>

int main() {
   int N;
   scanf("%d",&N);
   int V[N];
   int C[N];
   int sum = 0;
   for(int i = 0; i < N; i++) {
      scanf("%d",&V[i]);
   }
   for(int i = 0; i < N; i++) {
      scanf("%d",&C[i]);
   }
   for(int i = 0; i < N; i++) {
      if(V[i] - C[i] > 0) {
         sum += V[i] - C[i];
      }
   }
   printf("%d\n",sum);
}


Measured memory_bytes: 128
// Problem : D - I hate Factorization
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<string, string> pss;
#define pb push_back
#define PI acos(-1.0)
#define EPS 1e-4
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fout(S,x)            cout<<fixed<<setprecision(x)<<(S)<<endl
#define present(c,x) ((c).find(x) != (c).end())
#define T() ll t;cin>>t;while(t--)
#define mem(input,b) memset(input,b,sizeof(input))
#define ff first
#define ss second
#define fread(input) freopen("input","r",stdin)
#define fwrite(b) freopen("b","w",stdout)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define FOREACH(i,c) for (__typeof ((c).begin()) i = (c).begin() ; i != (c).end() ; i++)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
ll f3(ll a){
	return a*a*a*a*a;
}
int main(){
    fastio;
    ll x;
    cin>>x;
    map<ll,int> store;
    set<ll> st2;
    for(int i=-1000;i<=1000;++i){
    	ll xyz = f3(i);
    	store[xyz] = i;
    	st2.insert(xyz);
    }
    for(auto it:st2){
    	ll val = it;
    	//trace(val);
    	ll target = val + x;
    	if(st2.find(target) != st2.end()){
    		cout<<store[target]<<" "<<store[val]<<endl;
    		break;
    	}
    }
    return 0;
}    


Measured memory_bytes: 3876
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String s1 = scan.next();
		String s2 = scan.next();
		String s3 = scan.next();

		if(s1.charAt(s1.length()-1)==s2.charAt(0) && s2.charAt(s2.length()-1)==s3.charAt(0)) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define INF 1<<28
using namespace std;
int main(){
  long long n;
  cin>>n;long long s=1;
  long long a[n],t[n]={0};
  r(i,n)cin>>a[i];
  sort(a,a+n);
  t[0]=a[0];
  r(i,n-1){
    t[i+1]=a[i+1]+t[i];
  }
  for(int i=n-2;i>=0;i--){
    if(t[i]*2>=a[i+1])s++;
    else break;
  }
  cout<<s<<endl;
}

Measured memory_bytes: 1792
let cnt = ref 0

let insertion_sort (a : int array) n g =
  for i = g to n - 1 do
    let v = a.(i) in
    let j = ref (i - g) in
    while !j >= 0 && a.(!j) > v do
      a.(!j+g) <- a.(!j);
      j := !j - g;
      incr cnt;
    done;
    a.(!j+g) <- v;
  done

let generate_g n =
  let rec doit i g acc =
    if g > n then acc
    else doit (i + 1) (int_of_float (4.**(float_of_int i) +. 3.*.2.**(float_of_int (i - 1)) +. 1.)) (g :: acc) in
  doit 1 1 []

let shell_sort (a : int array) n =
  cnt := 0;
  let g = generate_g n in
  List.iter (fun g -> insertion_sort a n g) g;
  g

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> read_int ()) in
  let g = shell_sort a n in
  print_int (List.length g);
  print_newline ();
  match g with
  | [] -> assert false;
  | hd :: tl -> print_int hd; List.iter (fun x -> print_string " "; print_int x) tl;
  print_newline ();
  print_int !cnt;
  print_newline ();
  Array.iter (fun n -> Printf.printf "%d\n" n) a

Measured memory_bytes: 12596
#include<bits/stdc++.h>
using namespace std;
int main(){
  int r,g,b,n,a=0,t;
  cin >> r >> g >> b >> n;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      t=n-r*i-g*j;
      if(t%b==0&&0<=t/b&&t/b<=n)a++;
    }
  }
  cout << a;
}


Measured memory_bytes: 256
n = int(input())
a=list(map(int,input().split()))
box=[0]*n
b=[]
ans=0
for i in reversed(range(n)):
  if sum(box[i::i+1])%2 != a[i]:
    box[i]=1
    b.append(str(i+1))
    ans+=1
print(ans)
print(' '.join(b))

Measured memory_bytes: 17196
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  map<int,int> M;
  rep(i,0,N) M[A[i]]++;
  vi B;
  for(auto p:M) B.pb(p.second);
  sort(ALL(B));
  int O=B.size();
  B.pb(INF);
  vi C(O+2);
  REP(i,0,O) C[i+1]=C[i]+B[i];
  int sum=C[O];
  REP(i,1,N){
    int left=0,right=N/i;
    while(left+1<right){
      int mid=(left+right)/2;
      int X=disup(B,mid);
      int Y=sum-C[X]-(O-X)*mid;
      if(mid*i+Y<=N) left=mid;
      else right=mid;
    }
    int ans=left;
    int X=disup(B,right);
    int Y=sum-C[X]-(O-X)*right;
    if(right*i+Y<=N) ans=right;
    cout<<ans<<endl;
  }
  }



Measured memory_bytes: 26476
x,k,d = map(int, input().split())
count = abs(x) // d
if count >= k:
  print(abs(x)-k*d)
else:
  if (k - count) % 2 == 0:
    print(abs(x)-count*d)
  else:
    print(abs(abs(x)-(count+1)*d))

Measured memory_bytes: 9084
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// 標準入力
		Scanner sc = new Scanner(System.in);

		String line = sc.nextLine();
		List<String> lines = Arrays.asList(line.split(" "));

		/*
		List<String> lines1 = Arrays.asList(line1.split(" "));
		List<String> lines2 = Arrays.asList(line2.split(" "));
		*/

		Long x = Long.parseLong(lines.get(0));
		Long y = Long.parseLong(lines.get(1));

		Long ans = (long) 0;

		while (x <= y) {
			ans++;
			x = x * 2;

		}

		System.out.println(ans);
	}

}

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

int main(){
 int N;
 cin >> N;
  vector<int> vec(N);
for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
}
int count=0;
int max_count=0;
  for (int i = 0; i < N-1; i++) {
   if (vec.at(i)>=vec.at(i+1))
     count++;
    else count=0;
    max_count=max(count, max_count);
  }
    cout << max_count << endl;
     
      
    
}

Measured memory_bytes: 640
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())

n,l = Is()
lis = []
for i in range(l,n+l):
    lis.append(i)
if 0 in range(l,n+l):
    print(sum(lis))
elif n+l-1 < 0:
    print(sum(lis) - (n+l-1))
else:
    print(sum(lis) - l)

Measured memory_bytes: 4584
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#define rep(i, a, n) for(int i = a;i < n;++i)
#define repe(i, a, n) for(int i = a;i <= n;++i)
#define repr(i, a, n) for(int i = a;i > n;--i)
#define reper(i, a, n) for(int i = a;i >= n;--i)
#define size(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define EPS (1e-20)
#define INF 999999999
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using namespace std;


int main(){
	int A, B, K;
	cin >> A >> B >> K;

	set<int> s;
	for(int i = A;i < A+K && i <= B;i++)
		s.insert(i);
	for(int i = B-K+1;A <= i && i <= B;i++)
		s.insert(i);

	for(auto v : s) cout << v << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<ll> v(n);
    rep(i,n) cin >> v[i];
    ll ans = 0;
    for(int i = 0; i <= min(n,k); ++i){
        for(int j = 0; j <= min(n-i,k-i); ++j){
            priority_queue<ll> pq;
            ll score = 0;
            rep(l,i){
                score += v[l];
                pq.push(-v[l]);
            }
            rep(l,j){
                score += v[n-1-l];
                pq.push(-v[n-1-l]);
            }
            int rest = k - i - j;
            while(!pq.empty() && pq.top() > 0 && rest > 0){
                score += pq.top();
                pq.pop();
                --rest;
            }
            chmax(ans, score);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <string>
using namespace std;
 
char in[120];
pair<pair<string,int>,int> p[110];
int main(){
int a;scanf("%d",&a);
for(int i=0;i<a;i++){
int t;scanf("%s%d",in,&t);
string tmp=in;
p[i]=make_pair(make_pair(in,-t),i);
}
std::sort(p,p+a);
for(int i=0;i<a;i++)printf("%d\n",p[i].second+1);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
	int a[100050];
	int e, i;
	int n, m;
	int t;
	int min;
	int sign;
	int flag = 1;
	while (scanf("%d %d", &n, &m) != EOF)
	{
		flag = 1;
		sign = 0;
		min = 1000000000;
		for (e = 0; e < n; e++)
		{
			scanf("%d", &a[e]);
		}
        sort(a, a + n);
		for (e = 0; e < n - m + 1; e++)
		{
			if( (a[e + m - 1] - a[e]) < min)
			{
				min = a[e + m - 1] - a[e];
				sign = 1;
			}
		}
		if (sign == 0)
		{
			min = 0;
		}
		printf("%d\n",min);



	}

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long 
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
 
#define y1 what

using namespace std;
 
const int N = (int) 5e3 + 10;
const int M = (int) 4e6 + 7;
const ll LINF = (ll) 1e18;
const int INF = (int) 1e9 + 7;
const double EPS = (double) 1e-9;
const int mod = 1e9 + 7;

const int nx[4] = {1, -1, 0, 0};
const int ny[4] = {0, 0, 1, -1};

int n, k;
vector<int> v[N];
vector<pii> q[N];
int dp[N][N];
int sz[N];

void dfs(int x, int p = -1) {
	vector<int> gt, mn;
	vector<vector<int> > tmp;
	sz[x] = 1;
	for (auto it : v[x]) {
		if (it == p)
			continue;
		dfs(it, x);
		sz[x] += sz[it];
		gt.pb(it);
	}
	tmp.resize(sz(gt) + 1);
	for (int i = 0; i <= sz(gt); i++) {
		tmp[i] = vector<int>(k + 1, INF);
	}
	tmp[0][0] = 0;
	for (int i = 1; i <= sz(gt); i++) {
		int ver = gt[i - 1];
		mn = tmp[i - 1];
		for (int max_dist = 0; max_dist <= k; max_dist++) {
			tmp[i][max_dist] = min(tmp[i][max_dist], tmp[i - 1][max_dist] + sz[ver]);
			q[max_dist].clear();
			if (max_dist) 
				mn[max_dist] = min(mn[max_dist], mn[max_dist - 1]);
		}
		for (int cur = 1; cur <= k; cur++) {
			int R = k - cur;
			tmp[i][cur] = min(tmp[i][cur], mn[min(R, cur)] + dp[ver][cur - 1]);
			if (cur + 1 <= R) {
				q[R].pb(mp(1, dp[ver][cur - 1]));
				q[cur].pb(mp(-1, dp[ver][cur - 1]));
			}
		}
		multiset<int> st;
		for (int max_dist = k; max_dist >= 0; max_dist--) {
			for (auto it : q[max_dist]) {
				if (it.f == -1) {	
					st.erase(st.find(it.s));
				} else {
					st.insert(it.s);
				}
			}
			if (!st.empty())
				tmp[i][max_dist] = min(tmp[i][max_dist], tmp[i - 1][max_dist] + *st.begin());
		}
	}
	for (int max_dist = 0; max_dist <= k; max_dist++) {
		dp[x][max_dist] = tmp[sz(gt)][max_dist];
	}
}

int main() {
    #define fn "balls"
    #ifdef witch
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
//        freopen(fn".in", "r", stdin);
//        freopen(fn".out", "w", stdout);
    #endif
    cin >> n >> k;
    for (int i = 1, x, y; i < n; i++) {
    	cin >> x >> y;
    	v[x].pb(y);
    	v[y].pb(x);
    }
    dfs(1);
    int ans = INF;
    for (int i = 1; i <= n; i++) {
    	for (int j = 0; j <= k; j++) {
    		ans = min(ans, dp[i][j] + n - sz[i]);
    	}
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 43008
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, i, j; string S; cin >> N >> S; 
vector< set<int> > al(26);
for(i=0; i<26; i++){ al[i]={N}; }
for(i=0; i<N; i++){ al[S[i]-'a'].insert(i); } 
int Q; cin >> Q;
for(i=0; i<Q; i++){
  int a; cin >> a;
  if(a==1){ 
    int k; char c; cin >> k >> c; k--;
    if(S[k]!=c){ al[S[k]-'a'].erase(k); S[k]=c; al[c-'a'].insert(k); }
  }else{
    int l, r, ans=0; cin >> l >> r; l--; r--;
    for(j=0; j<26; j++){ if(*al[j].lower_bound(l)<=r){ ans++; } }
    cout << ans << "\n";
  }
}
}

Measured memory_bytes: 24196
x1,y1,x2,y2 = map(int,input().split())

a = x2 - x1
b = y2 - y1

x4 = x1 - b
y4 = y1 + a

x3 = x4 + a
y3 = y4 + b

print(x3,y3,x4,y4)

Measured memory_bytes: 9164
#include <stdio.h>

int main(){
    int n, b, f, r, v, i, j, k;
    int cnt[4][3][10] = {0};
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d%d%d%d", &b, &f, &r, &v);
        cnt[b-1][f-1][r-1] += v;
    }
    for(i=0; i<4; i++){
        for(j=0; j<3; j++){
            for(k=0; k<10; k++){
                printf(" %d", cnt[i][j][k]);
            }
            printf("\n");
        }
        if(i != 3) printf("####################\n");
    }
    return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;

  if (A == 1 || B == 1) {
    if (A == 1 && B == 1) {
      cout << "Draw" << endl;
    } else if (A == 1) {
      cout << "Alice" << endl;
    } else {
      cout << "Bob" << endl;
    }
  } else {
    if (A == B) {
      cout << "Draw" << endl;
    } else if (A > B) {
      cout << "Alice" << endl;
    } else {
      cout << "Bob" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
 
#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)
 
ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
void oi(ll x){ cout << x; }
void od(ld x){ cout << fixed << setprecision(10) << x; }
void os(string x){ cout << x; }
void oie(ll x){ cout << x << endl; }
void ode(ld x){ cout << fixed << setprecision(10) << x << endl; }
void ose(string x){ cout << x << endl; }
void oe(){ cout << endl; }

int main(){
    vector<ll> R,G;
    set<ll> B;
    ll N=ii();
    string S=is();
    ll blen=0;
    REP(i,0,N){
        if(S[i]=='R'){
            R.push_back(i+1);
        }
        if(S[i]=='G'){
            G.push_back(i+1);
        }
        if(S[i]=='B'){
            B.insert(i+1);
            blen++;
        }
    }

    ll ret=0;
    for(ll r:R){
        for(ll g:G){
            ret+=blen;
            ll a=min(r,g);
            ll b=max(r,g);
            auto t=B.find(2*b-a);
            if(t!=B.end()&&*t>b){
                ret--;
            }
            t=B.find(2*a-b);
            if(t!=B.end()&&*t<a){
                ret--;
            }
            t=B.find((b+a)/2);
            if((b+a)%2==0&&t!=B.end()&&*t>a&&*t<b){
                ret--;
            }
        }
    }
    oie(ret);
    return 0;
}


Measured memory_bytes: 3744
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		int n = readNum();
		int f = 0;
		int v = n;
		while (v > 0) {
			f += v % 10;
			v /= 10;
		}
		if (n % f == 0)
			pln("Yes");
		else
			pln("No");
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end - start) + "ms");
		}
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSR(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main(){
	int a,b,c; cin>>a>>b>>c;
	if(a==b && b==c) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256