akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
    
    int n[4];
    
    scanf( "%d %d %d %d", &n[0], &n[1], &n[2], &n[3] );
    
    if( n[0] == 1 || n[0] == 9 || n[0] == 7 || n[0] == 4 ){
        if( n[1] == 1 || n[1] == 9 || n[1] == 7 || n[1] == 4 ){
            if( n[0] == n[1]){
                printf("NO");
                
            }else if( n[2] == 1 || n[2] == 9 || n[2] == 7 || n[2] == 4 ){
                if( n[0] == n[2] || n[1] == n[2] ){
                    printf("NO");
                    
                }else if( n[3] == 1 || n[3] == 9 || n[3] == 7 || n[3] == 4 ){
                    if( n[0] == n[3] || n[1] == n[3] || n[2] == n[3] ){
                        printf("NO");
                        
                    }else{
                        printf("YES");
                        
                    }
                    
                }else{
                    printf("NO");
                }
                
            }else{
                printf("NO");
            }
            
        }else{
            printf("NO");
        }
    }else{
        printf("NO");
    }
    
    return(0);
}


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

int main(){
	// おまじない
	cin.tie(0);
   	ios::sync_with_stdio(false);
    typedef pair<int,int> pair;

	int N;
	cin >> N;
    vector<vector<int>> G(N);
    vector<pair> vp;

    for(int i=1;i<N;i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
        vp.emplace_back(a,b);
    }

    int K = 0;
    map<pair,int> I;
    vector<int> cs(N,0);//0で初期化 

    vector<int> used(N,0);
    queue<int> q;
    used[0]=1;
    q.emplace(0);
    while(!q.empty()){
        int v = q.front();q.pop();
        if(K<(int)G[v].size()) K = G[v].size();
        int cur = 1;
        for(int u:G[v]){
            if(used[u]) continue;
            if(cur == cs[v]) cur++;
            cs[u]=I[make_pair(v,u)]=cur++;
            used[u]=1;
            q.emplace(u);
        }
    }

    cout << K << "\n";
    for(auto p:vp) cout << I[p] << "\n";
	return 0;
}


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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = MAP()
A = LIST()

total = sum(A)
# dp[i][j][k] := i枚目までからj枚取って、合計をkにする通り数
dp = list3d(N+1, N+1, total+1, 0)
dp[0][0][0] = 1
for i in range(N):
    a = A[i]
    for j in range(N+1):
        for k in range(total+1):
            dp[i+1][j][k] += dp[i][j][k]
            if j+1 <= N and k+a <= total:
                dp[i+1][j+1][k+a] += dp[i][j][k]
ans = 0
for j in range(1, N+1):
    if j*K <= total:
        # 1枚以上取った時の、平均がKになる所 → j枚取って合計がj*Kの所 を合計する
        ans += dp[N][j][j*K]
print(ans)


Measured memory_bytes: 92892
#coding:utf-8

n = int(input())
s = list(input())
# 最初の1種類はカウントしておく
count = 1
# 色の境目が見えたら別個体になる
for i in range(0, n-1):
    if s[i] != s[i+1]:
        count += 1

print(count)

Measured memory_bytes: 4084
# N、Lの入力受付
N, L = map(int, input().split())
# N回連続で入力文字列を受付
S = []
for i in range(N):
    S.append(input())
# S内をソート
S.sort()
# Sの要素を結合
result = ""
for i in range(N):
    result = result + S[i]
# resultを出力
print(result)


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

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

     vector<pair<ll,ll>> a(n);
     vector<pair<ll,ll>> c(m);

     rep(i,n) {
       cin >> a[i].first >>a[i].second; 
     }      
     rep(i,m){
       cin >> c[i].first >> c[i].second;
     }
     rep(i,n){
       ll ans = 1<<29; 
       int cnt;
       rep(j,m){
           if(ans>abs(a[i].first-c[j].first)+abs(a[i].second-c[j].second)){
             ans = abs(a[i].first-c[j].first)+abs(a[i].second-c[j].second);
             cnt = j;
    
       }
     }
     cout << cnt+1 << endl;
     }
 }

Measured memory_bytes: 256
#include <stdio.h>

//nの第pos桁
int set(long long n, int pos)
{
	return (n >> pos) & 1U;
}

//0~nの第pos桁の1の個数mod2
int set2(long long n, int pos)
{
	if (pos > 0 && set(n, pos))
		return (n+1) % 2;
	if (pos == 0)
		switch (n % 4) {
		 case 1:
		 case 2: return 1;
		}
	return 0;
}

int main(void)
{
	long long a, b, sum = 0;
	int pos = 39;
	
	scanf("%lld%lld", &a, &b);
	
	while (pos >= 0) {
		sum <<= 1;
		sum += (set2(b, pos)-set2(a-1, pos)+2) % 2;
		pos--;
	}
	
	printf("%lld", sum);
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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; }

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }

template<typename T> void remove(std::vector<T>& vector, unsigned int index)
{ vector.erase(vector.begin() + index); }


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

    vector<pair<ll, ll>> p;
    rep(i, N) {
        p.push_back(make_pair(A[i], i+1));
    }

    sort(p.begin(), p.end());

    rep(i, N) {
        cout << p[i].second << ' ';
    }
    cout << endl;

    return 0;
}

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

int n;
char s[20];
int main(){
	cin >> s;

	for(int i = 0;s[i] != '\0';i++)n++;

	for(int i = 0;i < n;i++)
		s[i] -= '0';

	long ans = 0;
	for(int i = 0;i < (1 << (n - 1));i++) {
		long a = s[0];
		for(int j = 0;j < n - 1;j++) {
			if(i & (1 << j)) {
				ans += a;
				a = s[j + 1];
			}else {
				a *= 10;
				a += s[j + 1];
			}
		}
		ans += a;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int N, X, T; cin >> N >> X >> T;
	cout << T * ((N + X - 1) / X) << endl;

}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int a[100009], b[100009], c[100009];
int dp[100009][3];
int main(){
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for(int i=1; i<n; i++){
        dp[i][0] = max(dp[i-1][1] + a[i], dp[i-1][2] + a[i]);
        dp[i][1] = max(dp[i-1][0] + b[i], dp[i-1][2] + b[i]);
        dp[i][2] = max(dp[i-1][0] + c[i], dp[i-1][1] + c[i]);
    }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
}

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

// 0-indexed
// now node k
// child node k*2+1 and k*2+2
// parent node (k-1)/2
struct data {
  int a;
};
const int maxint = 2147483647;
data resetdata = {maxint};
struct RMQ {
  // except bottom size
  int sizen;
  vector<data> dat;
  RMQ(int newn = 1, data resets = resetdata) {
    reset(newn, resets);
  }
  void reset(int newn = 1, data resets = resetdata) {
    sizen = 1;
    while(sizen < newn) sizen *= 2;
    dat.resize(2 * sizen - 1);
    for(int i = 0; i < dat.size(); ++i) dat[i] = resets;
  }
  // "go up" process
  // data[k].a = newnum
  bool update(int k, int newnum) {
    k += sizen - 1;
    dat[k].a = newnum;
    while(k > 0) {
      k = (k - 1) / 2;
      dat[k].a = min(dat[k * 2 + 1].a, dat[k * 2 + 2].a);
    }
    return 1;
  }
  // "go down" process
  // return min number in [a,b)
  // pick(a,b,0,0,sizen)
  int pick(int a, int b, int k = 0, int l = 0, int r = -1) {
    if(r == -1) r = sizen;
    // [l,r)[a,b) or [a,b)[l,r)
    if(r <= a || b <= l) return maxint;
    // [a,[l,r),b)
    if(a <= l && r <= b) return dat[k].a;
    // else
    int nowl, nowr, nextlr = k * 2 + 1, med = (l + r) / 2;
    nowl = pick(a, b, nextlr, l, med);
    nowr = pick(a, b, nextlr + 1, med, r);
    return min(nowl, nowr);
  }
};
RMQ rmq;
long long n, ans = 100000000000000000, x;
long long a[20005] = {0};

int main() {
  cin >> n >> x;
  rmq = RMQ(2 * n + 1);
  for(long long i = 0; i < n; ++i) {
    cin >> a[i];
    rmq.update(i, a[i]);
    rmq.update(i + n, a[i]);
  }
  for(long long i = 0; i < n; ++i) {
    long long nans = i * x;
    for(long long j = 0; j < n; ++j)
      nans += rmq.pick(j + n - i, j + n + 1);
    ans = min(ans, nans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import os
import sys
from collections import defaultdict

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N, W = list(map(int, sys.stdin.readline().split()))
WV = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]

# dp[w]: w 以下で選ぶときの最大の価値
dp = defaultdict(int)
dp[0] = 0
for w, v in WV:
    for k, d in list(dp.items()):
        dp[k + w] = max(dp[k + w], d + v)

ans = 0
for w, v in dp.items():
    if w <= W:
        ans = max(ans, v)
print(ans)


Measured memory_bytes: 4904
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main() {
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);

	if (a < b && b < c)
		printf("Yes\n");
	else 
		printf("No\n");

	return 0;
}

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

int main() {
  // 入力部(a,b,c)
  int a, b, c;
  cin >> a >> b >>c;

  if(b-a == c-b) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int length = S.size();
  int zero = 0;
  int one = 0;

  for(int i=0; i<length; i++) {
    if(S.at(i) == '0') zero++;
    else if(S.at(i) == '1') one++;
  }

  cout << 2 * min(zero, one) << endl;
  return 0;
}


Measured memory_bytes: 3756
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll s,w;
	cin>>s>>w;
	if(w>=s)cout<<"unsafe";else cout<<"safe";
	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#define INT_MAX 100000
int main()
{
	int n = 0, d = 0;
	int num[INT_MAX] = {};
	std::cin >> n;
	for (int i = 1; i <= n; i++) { std::cin >> num[i]; }
	for (int i = 0; i <= n; i++) {d += abs(num[i + 1] - num[i]);}

	for (int j = 1; j <= n; j++) {
		std::cout << d - abs(num[j + 1] - num[j]) - abs(num[j] - num[j - 1]) + abs(num[j + 1] - num[j - 1]) << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1664
package main

import "fmt"

func main() {
	l := make([]int, 3)
	for i := range l {
		fmt.Scan(&l[i])
	}


	for i := 0; i < len(l); i++ {
		for j := i + 1; j < len(l); j++ {
			if l[i] > l[j] {
				l[i], l[j] = l[j], l[i]
			}
		}
	}
	fmt.Println(l[0], l[1], l[2])

}



Measured memory_bytes: 1128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(System.Console.ReadLine().Trim());
        int[] line = Array.ConvertAll(System.Console.ReadLine().Trim().Split(' '),int.Parse);

        Dictionary<int, int> s = new Dictionary<int, int>();
        Dictionary<int, int> t = new Dictionary<int, int>();
        Dictionary<int, int> tmp;

        for (int i = 0; i < n ; i++)
        {
           
            tmp = (i % 2 == 0) ? s: t;

            if(tmp.ContainsKey(line[i]))
            {
                tmp[line[i]]++;
            }
            else
            {
                tmp.Add(line[i], 1);
            }
        }

        if (s.Count == 1 && t.Count == 1 && s.First().Key != t.First().Key)
        {
            //すでにVVV
            System.Console.WriteLine("{0}",0);
            return;
        }
        //else if(s.Count == 1 && t.Count == 1)
        //{
        //    //全要素が同じ
        //    System.Console.WriteLine("{0}", s.First().Value);
        //    return;
        //}

        int s1 = 0, s2 = 0, t1 = 0, t2 = 0;

        s = s.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value);
        t = t.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value);

        s1 = s[s.Keys.ToList()[0]];
        t1 = t[t.Keys.ToList()[0]];

        if(s.Keys.ToList()[0] != t.Keys.ToList()[0])
        {
            //最頻値が異なればsもtも最頻値で置換
            System.Console.WriteLine("{0}", (n - s1 - t1));

        }
        else{

            //最頻値が同じならいずれかを2番目の頻度の値で置換
            if (s.Count > 1) s2 = s[s.Keys.ToList()[1]];
            if (t.Count > 1) t2 = t[t.Keys.ToList()[1]];

            //sを最頻値で、tを二番目で書き換え
            //tを最頻値で、sを二番目で書き換え
            int sRlt = n - s1 - t2;
            int tRlt = n - s2 - t1;

            System.Console.WriteLine("{0}", Math.Min(sRlt, tRlt));

        }


    }

    


}


Measured memory_bytes: 28896
# coding: utf-8
S = input()
ans = 0
P = 2019
N = len(S)
S = S[::-1]
cnt = [0 for _ in range(P)]
cnt[0] = 1
v = 0
bai = 1
for i in range(N):
    v = (v + int(S[i]) * bai) % P
    bai *= 10
    bai %= P
    cnt[v] += 1
for i in range(P):
    ans += ((cnt[i] - 1) * cnt[i]) // 2
print(ans)

Measured memory_bytes: 9344
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    int result=0;
    for(int i=0;i<n;i++)
    {
        while(v[i]%2==0){
            v[i]/=2;
            result++;
        }
    }
    cout<<result;
}

Measured memory_bytes: 3664
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		long n = long.Parse(input[0]);
		long w = long.Parse(input[1]);
    long[,] dp = new long[n+1,w+1];//dp[見た種類、重さの和]=価値の和

    long[,] vertexes = new long[n,2];//ここに受け取る
    for(long i = 0; i < n; i++)
    {
      long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);//１行ごとに受け取る
      vertexes[i,0] = nums[0];
      vertexes[i,1] = nums[1];
    }

    for(long i = 1; i <= n; i++)
    {
      for(long j = 0; j <= w; j++)
      {
        if(j-vertexes[i-1,1] >= 0)
        {
          dp[i,j] = Math.Max(dp[i,j], dp[i,j-vertexes[i-1,1]] + vertexes[i-1,0]);
          dp[i,j] = Math.Max(dp[i,j], dp[i-1,j-vertexes[i-1,1]] + vertexes[i-1,0]);
        }
        dp[i,j] = Math.Max(dp[i,j], dp[i-1,j]);
      }
    }

    for(long i = 0; i <= n; i++)
    {
      for(long j = 0; j <= w; j++)
      {
        //Console.WriteLine(i+" "+j+" "+dp[i,j]);
      }
    }

		Console.WriteLine(dp[n,w]);
	}
}


Measured memory_bytes: 25256
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);

long long int n,a[200][2],i,j;
double dis=0;
cin>>n;

long long int fact=1,factn=1,factp=1;

for(i=2;i<=n;i++)
fact*=i;

for(i=2;i<=n-2;i++)
factn*=i;

for(i=2;i<=n-3;i++)
factp*=i;

for(i=0;i<n;i++)
{
  cin>>a[i][0]>>a[i][1];

}
vector<double>v;
for(i=0;i<n-1;i++)
{

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

  {
double d=sqrt( (a[i][0]-a[j][0])*(a[i][0]-a[j][0])+(a[i][1]-a[j][1])*(a[i][1]-a[j][1]) );

dis+=d;

}
}

cout<<setprecision(9)<<fixed<<(2*factn+2*(n-2)*factn)*dis/fact<<endl;


return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;
vector<ll> fre(1000007, 0);
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n, i, j, k, l, m;
    cin >> n;
    vector<ll> data(n + 1);
    for (i = 1; i <= n;i++){
        cin >> data[i];
        fre[data[i]]++;
    }
    ll ans = 0;
    for (i = 1; i <= n;i++){
        ll cnt = 0;
        for (j = 1; j * j <= data[i];j++){
            if(data[i]%j==0){
                cnt += fre[j];
                if(j==data[i])
                    cnt--;
                if(j!=data[i]/j){
                    cnt += fre[data[i]/j];
                    if(data[i]/j==data[i])
                        cnt--;
                }    
            }
        }
        if(cnt==0){
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 12692
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
int main() {
	int n;
	scanf("%d", &n);
	int b = 1;
	int x = 0, y = 0, t = 0;
	for (int i = 1; i <= n; ++i) {
		int tx, ty, tt;
		scanf("%d%d%d", &tt, &tx, &ty);
		if ((tx - x) + (ty - y) > tt - t || ((tx - x) + (ty - y) - tt + t + 300000)% 2) {
			printf("No\n");
			return 0;
		}
		
		x = tx, y = ty, t = tt;
	}
	if (b) {
		printf("Yes\n");
	}
	return 0;
}



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

int main()
{
    int N; 
    long double C = 0.0;
    cin >> N;
    vector<int> A(N);
    vector<long double> B(N); 
    for(int i = 0; i < N; i++)
    {
        cin >> A.at(i);
        B.at(i) = 1.0 / (double)A.at(i);
        C += B.at(i); 
    } 
    cout << 1.0 / C << endl;
    return 0;
}

Measured memory_bytes: 256
//Finite Disappointment and Infinite Hope
#include <bits/stdc++.h>
using namespace std;
#define help ios_base:: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.first<<","<<v.second<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    for(auto &x:c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
const ll N=2e5+5,MOD=1e9+7;
int main(){
help
    ll h,n;cin>>h>>n;
    ll a[n],b[n];for(ll i=0;i<n;i++)cin>>a[i]>>b[i];
    ll dp[h+1];
    dp[0]=0;
    for(ll i=1;i<=h;i++)dp[i]=1e12;
    for(ll i=0;i<=h;i++){
        for(ll j=0;j<n;j++){
            dp[ min(i+a[j] , h) ] =min ( dp[ min(i+a[j] , h) ] , dp[i] + b[j]);
        }
    }
    cout<<dp[h];
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
const int MaxN = 1e3 + 5;
int n,m,i,j,k,ans;
char a[MaxN];
int main(){
	while(~scanf("%s",&a)){
		ans = strlen(a);
		printf("%c",a[0]);
		printf("%d",ans-2);
		printf("%c\n",a[ans-1]);
		}
	}


Measured memory_bytes: 128
#include <cstdio>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1, 0, 1, 1, -1, -1}, dx = {1,-1,0,0, 0, 1, -1, 1, -1};
//vector<int> dy = {0, 0, 1, -1}, dx = {1, -1, 0, 0};

int N,Q;
const int segSize = (1 << 18) - 1;
ll Seg[segSize], lazySeg[segSize];

void eval(int k, int l, int r){
    if(lazySeg[k] != 0){
        Seg[k] += lazySeg[k];
        
        if(r - l > 1){
            lazySeg[2*k+1] += lazySeg[k] / 2;
            lazySeg[2*k+2] += lazySeg[k] / 2;
        }
        lazySeg[k] = 0;
    }
}

void add(int a, int b, ll x, int k, int l, int r){
    eval(k, l, r);
    if(a <= l && r <= b){
        lazySeg[k] += x * (r - l);
        eval(k, l, r);
    }else if(b <= l || r <= a) ;
    else{
        add(a, b, x, 2*k+1, l, (l+r)/2);
        add(a, b, x, 2*k+2, (l+r)/2, r);
        Seg[k] = Seg[2*k+1] + Seg[2*k+2];
    }
}

ll getSum(int a, int b, int k, int l, int r){
    eval(k, l, r);
    if(b <= l || r <= a) return 0;
    if(a <= l && r <= b){
        return Seg[k];
    }else{
        return getSum(a, b, 2*k+1, l, (l+r)/2) + getSum(a, b, 2*k+2, (l+r)/2, r);
    }
}

int main(void){
    cin >> N >> Q;
    int N_ = 1;
    while(N_ < N){
        N_ *= 2;
    }
    for(int i = 0; i < Q; i++){
        int com;
        cin >> com;
        if(com == 0){
            int x, y, d;
            cin >> x >> y >> d;
            add(x-1, y, d, 0, 0, N_);
        }else{
            int x, y;
            cin >> x >> y;
            cout << getSum(x-1, y, 0, 0, N_) << endl;
        }
    }
}


Measured memory_bytes: 6272
#include <iostream>
#include <bits/stdtr1c++.h>
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;
const int N = 100005;
const int MOD = 1000000007;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;cin >> n;
    int a[n+1];
    for(int i=1;i<=n;i++) cin >> a[i];
    int count=0;
    for(int i=1;i<=n;i+=2){
        if(a[i]%2!=0) count++;
    }
    cout << count;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  
  int snum = s.size();
  int tnum = t.size();
  string answer = "Yes";
  
  if (s.at(0) == s.at(s.size()-1) && t.at(0) == t.at(t.size()-1)) {
    if (snum >= tnum) {
      answer = "No";
    }
  }
  
  else {
    if (s.at(0) >= t.at(tnum-1) ) {
    answer = "No";
    }
  }
  
  
  
  cout << answer << endl;
  
}



Measured memory_bytes: 256
n = int(input())

lst = []
res = []

while n > 0:
    lst.append(n%10)
    n //= 10
    
lst.reverse()


for i in lst:
    if i == 1:
        res.append(9)
    elif i == 9:
        res.append(1)
    else:
        res.append(i)


S = ""

for j in res:
    S += str(j)

print(S)


Measured memory_bytes: 3060
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
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...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =998244353;
const int maxn = 200005;
#define endl '\n'
#define ld long double
#define int ll
#define all(x) (x).begin(),(x).end()


int32_t main()
{ 
  IOS

  int x, k, d;
  cin >> x>> k >> d;
  x = abs(x);
  int p = min(k,x/d);
  x -= p*d;
  int rem = k - p;
  int ans;
  if(rem%2 == 0){
    ans = x;
  }
  else{
    ans = abs(x-d);
  }
  cout << ans << endl;


  

  










  
    
} 



Measured memory_bytes: 3648
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-11
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007
const int N = 200031;

int n,cnt[N];
int ans;

int main(){
	//freopen("tree.in","r",stdin);
	//freopen("tree.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	cin>>n;
	for (int i=1;i<=n;i++)
	{
		int val;
		cin>>val;
		cnt[val]++;
	}

	for (int i=0;i<=100000;i++)
	{
		ans=max(ans,cnt[i]+cnt[i+1]+cnt[i+2]);
	}
	cout<<ans<<endl;

	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
//#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

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

const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    int N;
    cin>>N;
    vector<int> d(N);
    for(int i=0;i<N;i++){
        cin>>d[i];
    }
    int ans=0;
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            ans+=d[i]*d[j];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int answer[7][7] = {
{0,0,0,0,0,0,0},
{0,0,3,5,2,4,0},
{0,4,0,1,6,0,3},
{0,2,6,0,0,1,5},
{0,5,1,0,0,6,2},
{0,3,0,6,1,0,4},
{0,0,4,2,5,3,0}
};

void printDice(int inputDice[]){
	for(int i = 1 ; i < 7 ; i++){
		printf("%d  ", inputDice[i]);
	}
}

int main(){
	int inputDice[7];
	int i ;
	for(i = 1 ; i <= 6 ; i++){
		scanf("%d", &inputDice[i]);
	}


	int question;
	scanf("%d", &question);
	
	while(question--){
		int front, top;
		int fIndex, tIndex;
		scanf("%d%d",&top,&front);
		
		for(i = 1 ; i <= 6; i++){
			int dice = inputDice[i];
			if(front == dice){
				fIndex = i;
			}
			if(top == dice){
				tIndex = i;
			}
		}
		
		printf("%d\n", inputDice[answer[tIndex][fIndex]]);
		
	}
	return 0 ;
} 


Measured memory_bytes: 2096
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int N, K, R, S, P;
    string T;

    cin >> N >> K >> R >> S >> P >> T;

    char now;
    char prev;
    map<char, int> m;
    m['r'] = P;
    m['s'] = R;
    m['p'] = S;
    u32 flag = false;
    s64 ans = 0;
    rep (i, K)
    {
        int j = i;
        flag = false;
        prev = '\0';
        while (j < N)
        {
            now = T[j];
            if (now == prev)
            {
                if (flag)
                {
                    ans += m[now];
                    flag = false;
                }
                else
                {
                    flag = true;
                }
            }
            else
            {
                ans += m[now];
                flag = false;
            }
            j += K;
            prev = now;
        }
    }

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



Measured memory_bytes: 512
#include <stdio.h> 
 #include <string.h> 
 #define MAX 100 
 
 
 int main(){ 
     int n; 
     int t_point=0, h_point=0; 
     char tarou[MAX], hanako[MAX]; 
 
 
     scanf("%d", &n); 
     for(;n>0;n--){ 
         scanf(" %s %s", tarou, hanako); 
         if(strcmp(tarou, hanako)>0){ 
             t_point+=3; 
         }else if(strcmp(tarou, hanako)==0){ 
             t_point+=1; 
             h_point+=1; 
         }else if(strcmp(tarou, hanako)<0){ 
             h_point+=3; 
         } 
     } 
     printf("%d %d\n", t_point, h_point); 
 
 
     return 0; 
 } 



Measured memory_bytes: 2088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll N,K;
    cin>>N>>K;
    vector<ll> a(N);
    vector<ll> b(N);
    rep(0,i,N)cin>>a[i];
    rep(0,i,N)cin>>b[i];
    sort(a.begin(),a.end());
    sort(b.rbegin(),b.rend());
    ll l=-1,r=1e12;
    while(l+1<r){
        ll x=(l+r)/2;
        ll sum=0;
        rep(0,i,N){
            sum+=max(0ll,a[i]-x/b[i]);
        }
        if(sum<=K)r=x;
        else l=x;
    }
    cout<<r<<endl;
}


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

#define pb push_back
#define vi vector < int >
#define ii pair < int, int >
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ )
#define DFOR( i, hi, lo ) for( int i = (hi);i >= (lo);i-- )
#define pqueue priority_queue

using namespace std;

const int MAXN = 2e5 + 10;

int n;
int A[ MAXN ];
int B[ MAXN ];
int freq[ MAXN ];
int fact[ MAXN ];

int main()
{
	cin >> n;
	FOR( i, 1, n + 1 )
	{
		cin >> A[ i ];
		B[ i ] = 1;freq[ i ] = n / i;
	}
	
	int m = 0;
	DFOR( i, n, 1 )
	{
		int x = freq[ i ];
		bool ok = false;
		if ( x % 2 != A[ i ] )
		{
			B[ i ] = 0;
			freq[ i ]--;
			ok = true;
		}
		FOR( j, 1, sqrt( i ) + 1 )
		{
			if ( i % j == 0 && ok )
			{
				if ( j != i && !fact[ j ] )
				{
					//cout << j << ' ';
					freq[ j ]--;
					fact[ j ] = 1;
				}
				if ( i / j < i && i / j != j && !fact[ i / j] ) 
				{	
					//cout << i / j << ' ';
					freq[ i / j ]--;
					fact[ i / j ] = 1;
				}
			}
			if ( B[ i ] == 1 )
				m++;
		}
		FOR( j, 1, sqrt( i ) + 1 )	
		{
			if ( i % j == 0 )
			{
				fact[ j ] = 0;fact[ i / j ] = 0;
			}
		}
	}
	
	m = 0;
	FOR( i, 1, n + 1 )
	{
		if ( B[ i ] )
			m++;
	}
	cout << m << "\n";
	FOR( i, 1, n + 1 )
		if ( B[ i ] )
			cout << i << "\n";
	return 0;
}


Measured memory_bytes: 3968
#include <stdio.h>
#include <algorithm>

using namespace std;


int main(){
	int n,minimum,tmp;
	scanf("%d",&n);
	int table[n][n];
	int data[n][2];

	for(int i=0;i<n;i++){
		for(int k=0;k<n;k++)table[i][k] = 0;
		scanf("%d %d",&data[i][0],&data[i][1]);
	}

	for(int i=n-2;i>=0;i--){
		for(int k=0;k<=i;k++){
			if(i==n-2){
				table[n-i-1][k] = data[k][0]*data[k][1]*data[k+1][1];
		}else{
				minimum = 2147483647;
				for(int p=0;p<=n-i-2;p++){
					tmp=(table[p][k]+table[n-i-p-2][k+p+1])+(data[k][0]*data[k+p][1]*data[k+n-i-1][1]);
					minimum = min(minimum,tmp);
				}
				table[n-i-1][k] = minimum;
			}
		}
	}

	printf("%d\n",table[n-1][0]);

    return 0;
}

Measured memory_bytes: 2776
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int V[300000], W[300000];

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


	int X, Y;
	cin >> X >> Y;

	rep(i, 200) {
		int y = i * 2 + (X - i) * 4;

		if (X - i >= 0 && y == Y) {
			co("Yes");
			return 0;
		}



	}

	co("No");



	Would you please return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int h,w,p[2005][2005],m[2005][2005],l[2005],r[2005],ans;
stack<int>q;
int rec(int a[]){
	a[0]=-1,a[w]=-1;
	q.push(0);
	for(int i=1;i<w;i++){
		while(a[q.top()]>=a[i])q.pop();
		l[i]=q.top();
		q.push(i);
	}
	q.push(w);
	for(int i=w-1;i>=1;i--){
		while(a[q.top()]>=a[i])q.pop();
		r[i]=q.top();
		q.push(i);
	}
	int res=0;
	for(int i=1;i<w;i++)res=max(res,((r[i]-l[i]-1)+1)*(a[i]+1));
	return res;
}
int main(void){
    scanf("%d%d",&h,&w);
    ans=max(h,w);
    for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			char c;
			scanf(" %c",&c);
			if(c=='#')m[i][j]=1;
		}
	}
	for(int i=1;i<h;i++){
		for(int j=1;j<w;j++){
			if((m[i][j]^m[i-1][j]^m[i][j-1]^m[i-1][j-1])==0)p[i][j]=1;
		}
	}
	for(int i=1;i<h;i++){
		for(int j=0;j<w;j++){
			if(p[i][j]>0)p[i][j]+=p[i-1][j];
		}
	}
	for(int i=1;i<h;i++)ans=max(ans,rec(p[i]));
	printf("%d\n",ans);
}

Measured memory_bytes: 31744
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  vector<pair<ll, ll>> val;

  for (ll i = -500; i <= 500; i++) {
    val.emplace_back(i, i * i * i * i * i);
  }

  ll x;
  cin >> x;
  for (ll i = 0; i < val.size(); i++) {

    ll a = val[i].first;
    for (ll j = 0; j < val.size(); j++) {
      ll b = val[j].first;

      if ((val[i].second - val[j].second) == x) {
        cout << a << " " << b << en;
        return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
typedef pair<int,int> P;
typedef long long ll;
ll n,m,k,ans;
string s;


int main(){
   cin >> n;
   string t; cin >> s >> t;
   rep(i,n){
     bool frag = true;
     rep(j,n-i){
       if(s[i+j] != t[j]) frag = false;
     }
     if(frag){
       cout << 2*n-(n-i) << "\n"; return 0;
     }
   }
   cout << 2*n << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[6],b;
	for(int i=1;i<=5;i++)
	cin>>a[i];
	for(int i=1;i<=5;i++)
	if(a[i]==0)
	{
		b=i;
		break;
	}
	cout<<b<<endl;
	return 0;
}


Measured memory_bytes: 3572
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
  long long int x;

  cin >> x;
  long long q = x / 11;
  long long p = x % 11;
  if(p == 0) {
    cout << q * 2  << endl;
  }else if(p <= 6) {
    cout << q * 2 + 1 << endl;
  }else {
    cout << q * 2 + 2 << 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;

int main(){
	int a,b,c; scanf("%d%d%d",&a,&b,&c);
	puts(a==b&&a==c?"Yes":"No");
	return 0;
}


Measured memory_bytes: 3684
#include <iostream>
#include <sstream>
#include <istream>
#include <string>
#include <vector>

using namespace std;

bool judge(int year, int month, int date) {
  if (year > 2019) {
    return false;
  }

  if (month > 4) {
    return false;
  }

  return true;
}

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

  stringstream ss;
  ss << S;

  vector<string> str;
  string buf;
  while(getline(ss, buf, '/')) {
    str.push_back(buf);
  }

  int year = stoi(str[0]);
  int month = stoi(str[1]);
  int date = stoi(str[2]);

  if (judge(year, month, date)) {
    cout << "Heisei" << endl;
  }
  else {
    cout << "TBD" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int N=110;
using namespace std;
int main()
{
  int n;
  cin>>n;
  int arr[N];
  for(int i = 0 ;i <n;i++)
  cin>>arr[i];
  sort(arr,arr+n);
  cout<<abs(arr[n-1]-arr[0]);
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>
using namespace std;

typedef pair<int,int> pii;
const int INF = 1 << 30;

bool check(const vector<pii> &v, int xl, int xr, int yl, int yr){
	int th = yr - yl;
	int ymin = INF, ymax = -INF, xmin = INF, xmax = -INF;
	for(size_t i = 0; i < v.size(); ++i){
		if(v[i].first < xl || v[i].first > xr || v[i].second < yl || v[i].second > yr){
			xmin = min(xmin, v[i].first);
			xmax = max(xmax, v[i].first);
			ymin = min(ymin, v[i].second);
			ymax = max(ymax, v[i].second);
		}
	}

	return xmax <= xmin + th && ymax <= ymin + th;
}

int main(){
	int n;
	scanf("%d", &n);
	vector<pii> v(n);
	int ymin = INF, xmin = INF, xmax = -INF;
	for(int i = 0; i < n; ++i){
		int x, y;
		scanf("%d%d", &x, &y);
		v[i] = pii(x + y, x - y);
		ymin = min(ymin, v[i].second);
		xmin = min(xmin, v[i].first);
		xmax = max(xmax, v[i].first);
	}
	
	int left = 1, right = 300000;
	while(left < right){
		int mid = (left + right) >> 1;
		if(check(v, xmin, xmin + mid, ymin, ymin + mid) ||
		   check(v, xmax - mid, xmax, ymin, ymin + mid)
		){
			right = mid;
		}
		else{
			left = mid + 1;
		}
	}
	printf("%d\n", left);
}

Measured memory_bytes: 1796
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    int n;
    scanf("%d",&n);
    for (int i=1;i<=n;i++){
        if (i%3==0 || i%10==3 || i%100==3 || i%1000==3 || i%10000==3 || (i/10)%10==3 || (i/100)%10==3 || (i/1000)%10==3 || (i/10000)%10==3){
            printf(" %d",i);
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 3232
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main() {
	ll a, cnt = 1;
	while (cin >> a) {
		if (!a)break;
		cout << "Case " << cnt<<": " << a << endl;
		cnt++;
	}
	return 0;
}


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

int main(){
  int H, W, K; cin >> H >> W >> K;
  vector<vector<bool>> vec(H, vector<bool>(W, false));
  rep(h, H) rep(w, W) {
    char c; cin >> c;
    if (c == '#') vec[h][w] = true;
  }
  int ans = 0;
  for (int bit = 0; bit < (1 << (H + W)); bit++) {
    bitset<12> bs(bit);
    int cnt = 0;
    rep(h, H) rep(w, W) {
      if (bs[h] and bs[H + w] and vec[h][w]) cnt++;
    }
    if (cnt == K) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

int main(void)
{

    int n;
    cin >>n;

    bool solved = false;
    for(int i = 1; i <= 9 && !solved; i++){
        for(int j = 1; j <= 9 && !solved; j++){
            if(n == i * j){
                solved = true;
            }
        }
    }

    if(solved){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

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

int main() {
  ll A, B;
  cin >> A >> B;
  if ((A%2 == 0 && B%2 == 0) || (A%2 == 1 && B%2 == 1)) {
    cout << (A+B)/2 << endl;
  }
  else {
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll dp[52],a[52],b[52];
int main() {
	ll n,p;
	cin>>n>>p;
	if(p==0){
		dp[0]=1;
	}
	b[0]=1;
	for(ll i=1;i<=n;i++){
		cin>>a[i];
		b[i]=2*b[i-1];
	}
	for(ll i=1;i<=n;i++){
		if(a[i]%2!=0&&p==1){
			dp[i]=dp[i-1]+(b[i-1]-dp[i-1]);
		}
		if(a[i]%2==0&&p==0){
			dp[i]=dp[i-1]*2;
		}
		if(a[i]%2!=0&&p==0){
			dp[i]=dp[i-1]+(b[i-1]-dp[i-1]);
		}
		if(a[i]%2==0&&p==1){
			dp[i]=dp[i-1]*2;
		}
	}
	cout << dp[n];
}

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

int main () {
  int n;
  cin >> n;
  string w[n];
  for (int i=0; i<n; i++)
    cin >> w[i];  // 入力を代入
  
  int flag = 0;
  
  for (int i=0; i<n; i++)
    for (int j=0; j<i; j++)
      if (w[i] == w[j]) {
        if (flag != 1) {
          cout << "No" << endl;  // ダブり判定
          flag = 1;
        } else break;
      }
  
  if (flag != 1)
    for (int i=1; i<n; i++)
      if (w[i-1][w[i-1].length() - 1] != w[i][0]) {
        if (flag != 1) {
          cout << "No" << endl;  // 一致判定
          flag = 1;
        } else break;
      }
  
  if (flag != 1)
    cout << "Yes" << endl;
  
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  long long int a,i,n,max=-10000000,min=10000000,sum=0;
  scanf("%lld",&n);
  for (i=0;i<n;i++){
    scanf("%lld",&a);
    sum=sum+a;
    if(min>a){
      min=a;
    }
    if(max<a){
      max=a;
    }
  }
  printf("%lld %lld %lld\n",min,max,sum);
  return 0;
  }

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
 
// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
 
using namespace std;
using namespace __gnu_pbds;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define endl "\n"
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
 
const int INF = 1e16;
const double PI = acos(-1);
const int N = 1e6 + 7;
int mod = 1e9 + 7;

const int maxn = 302;
double dp[maxn][maxn][maxn];
int n;

double solve(int a, int b, int c)
{
    if(a + b + c == 0)
        return 0;
    double &res = dp[a][b][c];
    if(res >= 0)
        return res;
    double s = a + b + c;
    double t = (double) (n - s) / s;
    res = t;
    if(a)
        res += (solve(a - 1, b, c) + 1) * a / s;
    if(b)
        res += (solve(a + 1, b - 1, c) + 1) * b / s;
    if(c)
        res += (solve(a, b + 1, c - 1) + 1) * c / s;
    return res;
}

int32_t main()
{
    IOS;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int a;
    cin >> n;
    int cnt[4] = {0};
    for(int i = 0; i < n; i++)
        cin >> a, cnt[a]++;
    for(int i = 0; i <= n; i++)
        for(int j = 0; j <= n; j++)
            for(int k = 0; k <= n; k++)
                dp[i][j][k] = -1;
    cout << setprecision(12) << fixed;
    cout << solve(cnt[1], cnt[2], cnt[3]) << endl;
    return 0;
}

Measured memory_bytes: 215296
#include <cmath>
#include <iostream>
#include <cstdio>
#include <ctype.h>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <iomanip>
#include <set>
#include <stack>
#include <queue>
#include <vector>
#include <sstream>

using namespace std;

int main()
{
	char c;
	while(1)
	{
		if((c=getchar())==EOF)break;
		if(c>='a'&&c<='z')printf("%c",c+('A'-'a'));
		else printf("%c",c);
    }
	
    return 0;
}

Measured memory_bytes: 1072
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int n;
  cin>>n;
  int x,ans=0;
  rep(i,0,n){
    cin>>x;
    while(x%2==0){
      x=x/2;
      ans++;
    }
  }
  cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
////////////////////////////////////////

int main() {
	int N, C; cin >> N >> C;
	int dp[31][100100];
	int table[31][100100];
	memset(dp, 0, sizeof(dp));
	memset(table, 0, sizeof(table));
	for (int i = 0; i < N; ++i) {
		int s, t, c;
		cin >> s >> t >> c;
		dp[c][s]++;
		dp[c][t + 1]--;
	}
	for (int i = 1; i <= C; ++i) {
		for (int j = 1; j < 100100; ++j) {
			dp[i][j] += dp[i][j - 1];
		}
	}
	for (int i = 1; i <= C; ++i) {
		for (int j = 0; j < 100100; ++j) {
			if (dp[i][j] > 1) {
				dp[i][j] = 1;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < 100100; ++i) {
		int count = 0;
		for (int j = 1; j <= C; ++j) {
			count += dp[j][i];
		}
		ans = max(ans, count);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 24448