akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

typedef long long lnt;

using namespace std;

lnt n,a,b,c,d,l,r;

inline bool range(lnt v, lnt x, lnt y) {
	return v >= x && v <= y;
}

signed main() {
	cin >> n >> a >> b >> c >> d, --n;
	
	for (int i = 0; i <= n; ++i) {
		l = -i * d + (n - i) * c;
		r = -i * c + (n - i) * d;
		
		if (range(b - a, l, r))
			return puts("YES"), 0;
	}
	
	return puts("NO"), 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL = 1LL<<40;
const double PI = atan(1)*4;
//const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    int h,w,d;cin>>h>>w>>d;
    unordered_map<int,pii> mp;
    int a;
    vector<vector<int>>A(h);
    rep(i,h){
        A[i].resize(w);
        rep(j,w){
            cin>>a;
            mp[a] = make_pair(i+1,j+1);
            A[i][j]=a;
        }
    }
    
    vector<int> cost(h*w+1,0);
    
    for(auto i = d; i<h*w+1;i++){
        
        cost[i] = cost[i-d] + (abs(mp[i].first-mp[i-d].first)+abs(mp[i].second-mp[i-d].second));
        
    }
    
    int q;cin>>q;
    
    rep(i,q){
        int l,r;cin>>l>>r;
        
        cout<<cost[r]-cost[l]<<endl;
    }
    
    
    return 0;
}






Measured memory_bytes: 5668
// inputに入力データ全体が入る
function Main(input) {
    "use strict";
    // 1行目がinput[0], 2行目がinput[1], …に入る
    const inputstr = input.split("\n")[0];
    let result = 0;

    for (let i = 0; i < Math.ceil(inputstr.length / 2); i++) {
        if (i === inputstr.length - i) break;
        if (inputstr[i] !== inputstr[inputstr.length - 1 - i]) {
            result++;
        }
    }
    console.log(result);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
    cout << fixed << setprecision(10);
    
    int N, M;
    cin >> N >> M;
    
    for (int i = 0; i < M; i++) {
        int X;
        cin >> X;
        N -= X;
    }
    
    if (N >= 0){
        cout << N;
    } else {
        cout << -1;
    }

    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<tuple>
#include<cassert>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

const int mod = pow(10, 9) + 7;

int main(){
    int a, b;
    cin >> a >> b;
    b *= 2;
    if(a - b >= 0){
        cout << a-b << endl;
    } else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(ll i=0;i<n;++i)
int MAX = 10000;
vector<int> sorted,indegree(MAX,0);
vector<vector<int>> graph(MAX);
vector<bool> used(MAX);
int n;//nodeの総数
void dfs(int now){
  used[now] = true;
  REP(i,(ll)graph[now].size()){
    if(!used[graph[now][i]]) dfs(graph[now][i]);
  }
  sorted.emplace_back(now);
}
void tsort(){
  REP(i,n){
    if(!used[i]) dfs(i);
  }
  reverse(sorted.begin(),sorted.end());
}
int main(){
    int v,e;
    cin >> v >> e;
    n = v;
    REP(i,e){
        int s,t;
        cin >> s >> t;
        graph[s].emplace_back(t);
    }
    tsort();
    REP(i,v) cout << sorted[i] << endl;
}
        


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
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; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const int mod = 1000000007;

struct edge{
    int to;
    int cost;
};

int V, E;
int from[100010], to[100010], C[100010];
vector<edge> G[100010];
int used[100010] = {0};
ll d[100010];

void reachable(int g){
    queue<int> que;
    que.push(g);
    used[g] = 1;
    while(!que.empty()){
        int v = que.front();
        que.pop();
        for(int i = 0; i < G[v].size(); i++){
            int nv = G[v][i].to;
            if(used[nv]) continue;
            used[nv] = 1;
            que.push(nv);
        }
    }
}

int bellman_ford(int s){
    for(int i = 0; i < V; i++) d[i] = LINF;
    d[s] = 0;
    for(int i = 0; i < V; i++){
        for(int j = 0; j < E; j++){
            if(d[from[j]] == LINF || d[to[j]] <= d[from[j]] + C[j]) continue;
            d[to[j]] = d[from[j]] + C[j];
            if(i == V-1 && used[to[j]]){
                return true;
            }
        }
    }
    return false;
}
 
int main(){
    int p;
    cin >> V >> E >> p;
    for(int i = 0; i < E; i++){
        cin >> from[i] >> to[i] >> C[i];
        from[i]--; to[i]--;
        C[i] = p - C[i];
        G[to[i]].pb({from[i], C[i]});
    }
    reachable(V-1);
    if(bellman_ford(0)){
        cout << -1 << endl;
        return 0;
    }
    cout << max(0LL, -d[V-1]) << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <math.h> 
#include <vector>
#include <algorithm>
#include <iomanip>      // std::setprecision
#include <map>
#include <unordered_map>
#include <string>
#include <set>

using namespace std;

int main()
{

	double N = 0;
	std::vector<int> nums;
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		int num;
		cin >> num;
		nums.push_back(num);
	}
	std::sort(nums.begin(), nums.end());
	int sol = 0;
	int i = 0, j = N-2, k = N-1;
	for (int k = N - 1; k > 1; --k)
	{
		for (int j = k - 1; j > 0; --j)
		{
			for (int i = 0; i < j; i++)
			{
				if (nums[i] + nums[j] > nums[k])
				{
					sol += j - i;
					break;
				}
			}
		}
	}
	std::cout << sol;
}


Measured memory_bytes: 256
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

int n;
int ar[N];

int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> ar[i];
    }
    int best = 1e9;
    for(int i = 1; i <= n; i++){
        int a = 0 , b = 0;
        for(int j = 1; j <= i; j++){
            a += ar[j];
        }
        for(int j = i+1; j <= n; j++){
            b += ar[j];
        }
        best = min(best , abs(a - b));
    }
    cout << best << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
template<class T> inline T GCD_L(T a,T b){
  T r;
  while(a){
    r=b;
    b=a;
    a=r%a;
  }
  return b;
}
int N;
int K;
int A[100000];
int main(){
  rd(N);
  rd(K);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  {
    int e98WHCEY;
    int cTE1_r3A;
    if(N==0){
      cTE1_r3A = 0;
    }
    else{
      cTE1_r3A = A[0];
      for(e98WHCEY=(1);e98WHCEY<(N);e98WHCEY++){
        cTE1_r3A = GCD_L(cTE1_r3A, A[e98WHCEY]);
      }
    }
    {
      int xr20shxY;
      int WYIGIcGE;
      if(N==0){
        WYIGIcGE = 0;
      }
      else{
        WYIGIcGE = A[0];
        for(xr20shxY=(1);xr20shxY<(N);xr20shxY++){
          WYIGIcGE = max_L(WYIGIcGE, A[xr20shxY]);
        }
      }
      if(K >WYIGIcGE|| K %cTE1_r3A){
        wt_L("IMPOSSIBLE");
        wt_L('\n');
      }
      else{
        wt_L("POSSIBLE");
        wt_L('\n');
      }
    }
  }
  return 0;
}
// cLay varsion 20191125-1

// --- original code ---
// int N, K, A[1d5];
// {
//   rd(N,K,A(N));
//   wt(if[K > max(A(N)) || K % gcd(A(N)), "IMPOSSIBLE", "POSSIBLE"]);
// }


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

#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(a) cout << a << endl
#define PRINT(V) for (auto v : (V)) cout << v << " "

const int MOD = 1000000007;
const double PI = acos(-1.0);

void solve() {
    ll N,M;
    cin >> N >> M;
    vector<int> a(M);
    vector<int> b(M);
    rep(i, M) cin >> a[i] >> b[i];
    ll count=0;
    while(!a.empty()){
        int min = *min_element(all(b));
        vector<int> aa;
        vector<int> bb;
        rep(i, a.size()){
            if(a[i] >= min){
                aa.push_back(a[i]);
                bb.push_back(b[i]);
            }
        }
        a = aa;
        b = bb;
        count++;
    }
    out(count);
}
int main() {
    INCANT;
    solve();
    return 0;
}




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

using namespace std;

int main() {
  string S;
  cin >> S;
  map<char, int> m;
  for (int i = 0; i < S.size(); i++) {
    if (m[S[i]]) {
      cout << "no" << endl;
      return 0;
    }
    m[S[i]]++;
  }
  cout << "yes" << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	a, b       int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func main() {
	var S, W int
	fmt.Scanf("%d %d\n", &S, &W)

	if W >= S {
		fmt.Println("unsafe")
	} else {
		fmt.Println("safe")

	}

}


Measured memory_bytes: 1820
#include <iostream>
using namespace std;
typedef long long  ll;

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
int main()
{
	ll X, Y, Z; cin >> X >> Y >> Z;
	cout << (X - Z) / (Y + Z) << endl;
	return 0;
}

Measured memory_bytes: 256
A=int(input())
B=int(input())
C=int(input())
D = int(input())
S=0
if A >= B:
  S += B
  if C >= D:
    S += D
  else:
    S += C
else:
  S += A
  if C >= D:
    S += D
  else:
    S += C
print(S)

Measured memory_bytes: 3060
import sys


class UnionFindTree:
    def __init__(self, n_node):
        self.parent = [i for i in range(n_node)]
        self.rank = [0] * n_node

    def find(self, x):
        if self.parent[x] != x:
            self.parent[x] = self.find(self.parent[x])
        return self.parent[x]

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

        if x != y:
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
            else:
                self.parent[y] = x
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

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


if __name__ == "__main__":
    n_node, n_command = map(int, input().split())
    uf_tree = UnionFindTree(n_node)

    for command, x, y in (map(int, i.split()) for i in sys.stdin):
        if command == 0:
            uf_tree.unite(x, y)
        else:
            print(int(uf_tree.have_same_root(x, y)))


Measured memory_bytes: 6780
N=int(input())
K=int(input())

def dp(N,K):
    keta = len(str(N))
    table = [[[0,0] for i in range(K+1)] for j in range(keta+1)]
    table[0][0][0]=1
    for i in range(keta):
        for j in range(K+1):
            for k in range(2):
                enable_num = int(str(N)[i]) if k==0 else 9
                for x in range(enable_num+1):
                    if x==0:
                        next_j = j
                    else:
                        next_j = j + 1
                    if next_j > K: continue
                    if k == 0 and x == enable_num:
                        next_k = 0
                    else:
                        next_k = 1
                    table[i+1][next_j][next_k]+=table[i][j][k]
    return table[keta][K][0] + table[keta][K][1]
print(dp(N,K))

Measured memory_bytes: 40560
#include <stdio.h>

int r, c, p;

int main() {
  while((c = getchar_unlocked()) > 10) {
    if (c == p) {
      p = 1;
    }
    else {
      r += 1;
      p = p == 1 ? 0 : c;
    }
  }
  printf("%d\n", r);
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

/*　入力方法
１、簡単に書く
fmt.Scan
2,たくさん読む()
bufio.Scanner
(テキストを1行ずつ読み込む。fileからscannerを生成し、scan()が末尾に達してfalseを返すまで読み込む。Text()を呼ぶことで文字列として取り出すことができる)
3,長い行を読む
bufio.ReadLine
4, スペース区切りのデータを読み込む
sc.Split(bufio.ScanWords)
#########バッファの最大読み込みの数を変更するには
sc.Buffer(buf,MaxBuf)#MAXBUFのところにサイズをしていする
*/

/* 書き込み
１、接頭辞F（前）
書き込み先を指定できる
2,接頭辞S(前)
出力ではなくフォーマットした結果を文字列で返す
3,接頭辞 f（後ろ）
フォーマット（文字列型など）を指定することができる
４、接頭辞 ln（後ろ）
オペランドの間に半角スペースが入り、文字列の最後に開業が追加

・interface{}型
どのような型がくるかわからないときに演算はできないが全ての型を受ける
new(T)
任意の型

*/
/*
フォーマット文字列
%c 1文字を出力　　　%d　　整数を10進む
%s 文字列を出力

指定子	対応する型	説明	使用例
%c	char	１文字を出力する
%s	char *	文字列を出力する
%d	int, short	整数を10進で出力する
%u	unsigned int, unsigned short	符号なし整数を10進で出力する
%o	int, short,unsigned int, unsigned short	整数を8進で出力する
%x	int, short,unsigned int, unsigned short	整数を16進で出力する
%f	float	実数を出力する
%e	float	実数を指数表示で出力する
%g	float	実数を最適な形式で出力する
%ld	long	倍精度整数を10進で出力する
%lu	unsigned long	符号なし倍精度整数を10進で出力する
%lo	long, unsigned long	倍精度整数を8進で出力する
%lx	long, unsigned long	倍精度整数を16進で出力する
%lf	double	倍精度実数を出力する
*/
/*
文字
*/
const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()

}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

/*strings.Splitで入力したものを分ける*/
func Scanner() []string {
	var s string
	if sc.Scan() {
		s = sc.Text()
	}
	slice := strings.Split(s, " ")
	return slice

}

/*"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""*/
func main() {
	var a, b, c string
	fmt.Scan(&a, &b, &c)
	fmt.Println(strings.ToUpper(string(a[0])) + strings.ToUpper(string(b[0])) + strings.ToUpper(string(c[0])))
}

Measured memory_bytes: 1844
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main()
{

    ll a,b;
    cin>>a>>b;
    if(a>0 and b>0)
    {
        cout<<"Positive"<<endl;
    }
    else if(a<0 and b>=0)
    {
        cout<<"Zero"<<endl;
    }
    else if(a==0)
    {
        cout<<"Zero"<<endl;
    }
    else
    {
        ll ans=abs(b-a)+1;
        if(ans&1)
        {
            cout<<"Negative"<<endl;
        }
        else
        {
            cout<<"Positive"<<endl;
        }
    }
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define VFOR(x,begin,num) for(int x=(begin);x<((begin)+(num));x++)
#define INF_ ((long long)1 << 60)
int main(){
    int N, M, s[10],c[10],ans=-1,low=0,up=0;
    cin >> N >> M;
    VFOR(i,1,M) {cin >> s[i] >> c[i];}
    if(N==1){
        low = 0; up = 9;
    }
    if(N==2){
        low = 10; up = 99;
    }
    if(N==3){
        low = 100; up = 999;
    }
    for(int i = low; i <= up; i++){
        int d[5];
        if(i<10){
            d[1] = i % 10;
            d[2] = -1;
            d[3] = -1;
        }
        if(i >= 10 && i < 100){
            d[3] = -1;
            d[2] = i % 10;
            d[1] = (i) / 10;
        }
        if( i >= 100 && i < 1000){
            d[1] = i / 100;
            d[2] = (i-100*d[1]) / 10;
            d[3] = i % 10;
        }
        int flg__ = 1;
        VFOR(j,1,M){
            if(d[s[j]] != c[j]){flg__ = 0; j = 10000;}
        }
        if(flg__){ ans = i; i = 1000000; }
    }
    cout << ans;
    return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<int>;
using P = pair<int,int>;

int main()
{
    int n;cin >>n;
    V c(n),s(n),f(n);
    rep(i,n-1)cin >>c[i]>>s[i]>>f[i];
    rep(i,n){
        ll now=0;
        for(int j=i;j<n-1;j++){
            if(now<s[j])now=s[j];
            else if(now%f[j]!=0)now+=(f[j]-now%f[j]);
            now+=c[j];
        }
        cout <<now << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#include <ctime> //�������ʱ��ĺ���
#include <queue> //STL��������
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

ll ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}
priority_queue<int> q;
int main()
{
	int n,m,x;
	read(n);read(m);
	for (int i=1;i<=n;i++) read(x),q.push(x);
	while (m--) q.push(q.top()/2),q.pop();
	while (!q.empty()) ans+=q.top(),q.pop();
	cout<<ans;
	return 0;
}









Measured memory_bytes: 3452
#include <iostream>

using namespace std;

int A, B, C, D, E, F;

int main() {
  int a, b, c, d;
  double density;
  int whole, sugar;
  scanf("%d %d %d %d %d %d", &A, &B, &C, &D, &E, &F);

  density = -1;
  a = 0;
  while (a * 100 * A <= F) {
    b = 0;
    while (a * 100 * A + b * 100 * B <= F && a + b != 0) {
      c = 0;
      while (a * 100 * A + b * 100 * B + c * C <= F) {
        d = 0;
        while (a * 100 * A + b * 100 * B + c * C + d * D <= F) {
          if ((a * A + b * B) * E >= c * C + d * D) {
            double dens = (double)(c * C + d * D) / (a * 100 * A + b * 100 * B);
            if (density < dens) {
              density = dens;
              whole = a * 100 * A + b * 100 * B + c * C + d * D;
              sugar = c * C + d * D;
            }
          }
          d++;
        }
        c++;
      }
      b++;
    }
    a++;
  }

  printf("%d %d\n", whole, sugar);

  return 0;
}


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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD =   1000000007;

int main()
{
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int n, t, a;
    cin >> n >> t >> a;

    vector<int> h(n);
    for (int i = 0; i < n; ++i){
        cin >> h[i];
    }

    double mindiff = INF32;
    int idx = -1;
    for (int i = 0; i < n; ++i){
        double diff = abs( (t - h[i] * 0.006) - a );
        if(mindiff > diff){
            mindiff = diff;
            idx = i + 1;
        }
    }
    cout << idx << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        if(a < b ){
            if (b < c){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26276
import sys
stdin = sys.stdin
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,M=nm()
H=nl()
Hl=[[] for i in range(N)]
A=[]
for i in range(M):
    A,B=nm()
    Hl[A-1].append(H[B-1])
    Hl[B-1].append(H[A-1])

c=0
for i in range(N):
    flag=True
    for j in range(len(Hl[i])):
        if(H[i]<=Hl[i][j]):
            flag=False
    c=(c+1 if flag==True else c)

print(c)

        

Measured memory_bytes: 23188
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)

int solve(int N, vl &A){
	ll sumY = 0;
	rp(i, 0, N){
		sumY += A[i];
	}

	ll minA = LLONG_MAX;
	ll sumX = 0;
	rp(i, 0, N-1){
		sumY -= A[i];
		sumX += A[i];
		// printf("%ld %ld\n",sumX,sumY);//
		minA = min(minA, abs(sumX - sumY));

	}
	return minA;
}

int main(){
	int N; cin>>N;
	vl A(N);
	rp(i, 0, N) cin>>A[i];
	ote(solve(N, A));
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<string>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<list>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<string.h>
#include<limits.h>
#include<functional>
#define int long long
#define mod 1000000007
using namespace std;

int c[100000];
signed main()
{
	int a, b; scanf("%lld%lld", &a, &b);
	for (int d = 0; d < a; d++) {
		scanf("%lld", &c[d]);
	}
	int l = 1, r = a - 1;
	int n = 0;
	for (int d = 1; d < a; d++) {
		n += (c[d] - c[d - 1])*l*r;
		n %= mod;
		l++; r--;
	}
	for (int d = 0; d < b; d++) {
		scanf("%lld", &c[d]);
	}
	l = 1, r = b - 1;
	int m = 0;
	for (int d = 1; d < b; d++) {
		m += (c[d] - c[d - 1])*l*r;
		m %= mod;
		l++; r--;
	}
	printf("%lld\n", n*m%mod);
}



Measured memory_bytes: 1024
import java.util.Scanner;

public class Main
{
	private static int[] x = new int[100];
	private static long[][] dp = new long[3000][60];
	private static long[][] temp = new long[3000][60];
	
	public static void main(String[] args)
	{	
		Scanner scan = new Scanner(System.in);
		int i , j , k , n , a;
		
		n = scan.nextInt();
		a = scan.nextInt();
		for (i = 0;i < n;i ++)
			x[i] = scan.nextInt();
		
		for (i = 0;i < n;i ++)
		{
			temp[x[i]][1] = 1;
			// 前面的状态
			for (j = 0;j <= 2500;j ++)
				for (k = 1;k <= i;k ++)
				{
					if (j + x[i] <= 2500)
						temp[j + x[i]][k + 1] += dp[j][k];
				}
			for (j = 0;j <= 2500;j ++)
				for (k = 0;k <= i + 1;k ++)
				{
					dp[j][k] += temp[j][k];
					temp[j][k] = 0;
				}
		}
		long ans = 0;
		for (i = 1;i <= 2500;i ++)
			for (j = 1;j <= n;j ++)
			{
				if (i % j == 0 && (i / j == a))
					ans += dp[i][j];	
			}
		System.out.println(ans);
	}
	
}



Measured memory_bytes: 13568
// template.cpp

// Defines.
//#define DEBUG
#define NUMBER_OF_DIGITS 6

// Includes.
#include <bits/stdc++.h>

#ifdef DEBUG
#include <chrono>
#endif

// Usings.
using namespace std;

// Main function.
int main()
{
#ifdef DEBUG
	chrono::system_clock::time_point start, end;
	
	start = chrono::system_clock::now();
#endif
	
	// settings.
	ios::sync_with_stdio(false);
	
	//cout << fixed;
	//cout << setprecision(NUMBER_OF_DIGITS);
	
	// logic.
	int n;
	cin >> n;
	
	int counter = 0;
	for (int i = 1; i <= n; i = (i + 2))
	{
		int sub_counter = 0;
		for (int j = 1; j <= n; j++)
		{
			if ((i % j) == 0)
			{
				sub_counter++;
			}
		}
		
		if (sub_counter == 8)
		{
			counter++;
		}
	}
	
	cout << counter << endl;

#ifdef DEBUG
	end = chrono::system_clock::now();
	
	double elapsed = chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
	cout << elapsed << "[ms]" << endl;
#endif
	
	return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

class Solver {
    public void Solve() {
        String s = sc.next();
        if (s.charAt(0) == s.charAt(1) && s.charAt(1) == s.charAt(2)) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }

    Scanner sc;

    Solver(Scanner in) {
        this.sc = in;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Solver s = new Solver(sc);
        s.Solve();
        sc.close();
    }
}


Measured memory_bytes: 23764
//#include<bits/stdc++.h>
#include<stdio.h>
#include<iostream>
#include<set>
#include<vector>
#include<cmath>
#include<list>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#include<iomanip> 
#include<cstdlib> 
#include<string>

#define ll long long

using namespace std;

ll a[100010];

int main() {
	int n;
	cin >> n;
	bool x = true;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		if (a[i] == 0) x = false;
	}
	ll tar = 1e18;
	ll ans = 1;
	bool f = true;
	for (int i = 0;x && i < n; ++i) {
		if (a[i] > tar / ans) { cout << -1 << endl; f = false; break; }
		else ans *= a[i];
	}
	if (f && x) cout << ans << endl;
	if (!x) cout << 0 << endl;
	return 0;
}

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

int main() {

  int D, N;
  cin >> D >> N;

  if (N != 100) {
    cout << (int) pow(100, D) * N << endl;
  } else {
    cout << (int) pow(100, D) * (N + 1) << endl;
  }
  
}

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

using namespace std;

int a[2000000] = { 0 }, b[2000000] = { 0 };

void CountSort(int k)
{
	int i, j;
	int c[10001] = { 0 };

	for (j = 0; j != k; ++j)
	{
		c[a[j]]++;
	}

	for (i = 1; i != 10001; ++i)
	{
		c[i] += c[i - 1];
	}

	for (j = k-1; j != -1; --j)
	{
		c[a[j]]--;
		b[c[a[j]]] = a[j];
		
	}
}




int main()
{
	int n;

	ios::sync_with_stdio(false);

	cin >> n;

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

	CountSort(n);

	for (int i = 0; i != n; ++i)
	{
		if (i)
		{
			cout << " ";
		}
		cout << b[i];
	}
	cout << endl;

	return 0;

}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;

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

  REP(i,S.size()){
    if(S[i]+N > 'Z'){
      printf("%c",S[i]+N-26);
    }else{
      printf("%c",S[i]+N);
    }
  }
  cout << endl;
}



Measured memory_bytes: 256
using System;

namespace ITP1_2_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);

            if (a < b)
                Console.WriteLine("a < b");
            else if (a > b)
                Console.WriteLine("a > b");
            else
                Console.WriteLine("a == b");
        }
    }
}

Measured memory_bytes: 8904
def comb(n, r):
	from math import factorial
	return factorial(n) // (factorial(n - r) * factorial(r))

def main():
	import sys
	input = sys.stdin.readline
	N, K = map(int, input().split())
	num = 10 ** 9 + 7
	a = N - K + 1
	print(a)
	if K > 1:
		if 2 * K <= N + 1:
			for j in range(2, K+1):
				b1 = comb(a, j) % num
				b2 = comb(K-1, j-1) % num
				ans = (b1 * b2) % num
				print(ans)
		else:
			for j in range(2, N-K+2):
				b1 = comb(a, j) % num
				b2 = comb(K-1, j-1) % num
				ans = (b1 * b2) % num
				print(ans)
			for j in range(N-K+2, K+1):
				print(0)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main(){
	int N;
	cin >> N;
	int* a = new int[2*N];
	for(int i = 0; i < 2*N; i++){
		cin >> a[i];
	}
	int sum = 0;


	for(int i = 0; i < N; i++){
		sum += a[i];
	}
	sum += a[2*N - 1];

	int summax = sum;

	for(int i = N-1; i > 0; i--){
		sum -= a[i];
		sum += a[i-1 + N];
		if(sum > summax){
			summax = sum;
		}
	}
	cout << summax;
	return 0;
}


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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int e , f;
    e = a / d;
    f = c / b;
    if(a % d != 0) ++e;
    if(c % b != 0) ++f;
    if(e >= f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

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

    int cnt[4] = {0};
    rep(i, 3){
        int a, b;
        cin >> a >> b;

        cnt[a-1]++;
        cnt[b-1]++;
    }
 
    if(cnt[0] == 1 && cnt[1] == 2 && cnt[2] == 2 && cnt[3] == 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }


    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <numeric>
#include <list>
#include <deque>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int, int>PII;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), rend()
#define PB pushback
#define SORT(c) sort((c).begin(),(c).end())

const LL INF = 1LL << 60;

//priority_queue<int> p;

int i, j, k, tmp, ans, cnt, N;
string s;

//scanf("%d",&N);

//printf("%d", ans);

//cout <<  << endl;
int main(void) {
	cin >> s;
	switch (s.at(0)) {
	case 'S' :
		printf("Cloudy");
		break;
	case 'C':
		printf("Rainy");
		break;
	case 'R':
		printf("Sunny");
		break;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
int a=0;
int b=0;
int d=0;
int r=0;
double f=0;

scanf("%d %d",&a,&b);

d=a/b;
r=a%b;
f=(double)a/b;

printf("%d %d %f\n",d,r,f);
return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
 
int main () {
    string s1, s2;
    cin >> s1;
    string x1, y1, x2, y2;
    x1 = s1.substr(0, (s1.size() - 1) / 2);
    y1 = s1.substr((s1.size() + 3) / 2 - 1);
    x2 = x1;
    y2 = y1;
    s2 = s1;
    reverse(x1.begin(), x1.end());
    reverse(y1.begin(), y1.end());
    reverse(s1.begin(), s1.end());
    if( x1 == x2 && y1 == y2 && s1 == s2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

vector<ll>memo;

ll lucas(ll x){
    if (memo[x] != -1)return memo[x];

    if (x == 0){
        memo[x] = 2;
        return 2;
    }
    else if (x==1){
        memo[x] = 1;
        return memo[x];
    }
    else {
        memo[x] = lucas(x-1) + lucas(x-2);
        return memo[x];
    } 
}


int main() {
    ll N;
    cin >> N;
    memo.resize(N+1,-1);
    cout << lucas(N) << endl;
}

Measured memory_bytes: 256
import collections

l=[]
for i in range(3):
  A1,A2=map(int,input().split())
  l.append(A1)
  l.append(A2)

c=collections.Counter(l).most_common()

if len(set(l))==4 and c[0][1]==2:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[100010];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	int now=0;
	bool def=false;
	int i;
	for(i=1;i<=n;i++){
		now=a[now];
		if(now==2){
			def=true;
			break;
		}
		now--;
	}
	if(def){
		cout << i << endl; 
	}else{
		cout << "-1" << endl;
	}
	return 0;
}

Measured memory_bytes: 640
S = input()[::-1]
word1 = "dream"[::-1]
word2 = "dreamer"[::-1]
word3 = "erase"[::-1]
word4 = "eraser"[::-1]
while True:
    if S[:5] == word1:
        S = S[5:]
    elif S[:7] == word2:
        S = S[7:]
    elif S[:5] == word3:
        S = S[5:]
    elif S[:6] == word4:
        S = S[6:]
    elif S == "":
        print("YES")
        break
    else:
        print("NO")
        break


Measured memory_bytes: 9108
#!/usr/bin/env python3
from collections import deque
n = int(input())
a = list(map(int, input().split()))
b = deque([a[0]])

for i in range(1, n):
    if i % 2 == 1:
        b.append(a[i])
    else:
        b.appendleft(a[i])

if (n - 1) % 2 == 1:
    [print(ans, end = " ") for ans in list(b)[::-1]]
else:
    [print(ans, end = " ") for ans in list(b)]

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

static const int MAX = 100009;
long long MOD = 1000000007;

int N;
int A[MAX];
int X[MAX];

int main(){
  cin >> N;
  for(int i=0;i<N;i++) cin >> A[i];
  for(int i=0;i<N;i++) X[i]=0;

  bool flag = true;
  if(N%2==0){
    for(int i=0;i<N;i++){
      if(A[i]%2 == 0) flag = false;
      X[A[i]]++;
      if(X[0] >= 2) flag = false;
      if(X[A[i]] >= 3) flag = false;
    }
  }else{
    for(int i=0;i<N;i++){
      if(A[i]%2 == 1) flag = false;
      X[A[i]]++;
      if(X[0] >= 2) flag = false;
      if(X[A[i]] >= 3) flag = false;
    }
  }
  ll ans=1;
  if(flag){
    for(int i=0;i<N/2;i++){
      ans = (ans * 2) % MOD;
    }
    cout << ans << endl;
  }
  else{
    cout << "0" << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))
Int n, m;
string str1, str2;
Int gcd(Int x, Int y){
  if(x == 0)return y;
  return gcd(y % x, x);
}
void ng(){
  cout << -1 << endl;
  exit(0);
}
int main(){
  cin >> n >> m;
  cin >> str1 >> str2;
  Int g = gcd(n, m);
  for(Int i = 0;i < g;i++){
    Int ni = n / g * i;
    Int mi = m / g * i;
    if(str1[ni] != str2[mi])ng();
  }
  cout << n * m /g << endl;
  return 0;
}

Measured memory_bytes: 512
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Apple Pie
 */

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

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  printf("%d\n", (a * 3 + p) / 2);
  return 0;
}


Measured memory_bytes: 256
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)

//typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> calc(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
string S;
bool A=false, B=false;
int main()
{
	cin >> S;
	rep(i, S.size()) {
		if (S[i] == 'A') {
			A = true;
		}
		else {
			B = true;
		}
	}
	if (A && B) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(__typeof__(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}



const int MAX = 105;

int N;
int c[MAX][MAX];

int main() {
    scanf("%d", &N);
    for (int i = 0; i < N; ++i)
        for (int j = 0; j < N; ++j)
            scanf("%d", &c[i][j]);
    
    long long res = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            res += min(c[i][j], c[j][i]);
        }
    }
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 1252
object Main extends App {

  def rec(e:Int ,cnt:Int): Int = {
    if((e & 1) == 1) cnt
    else rec(e>>1, cnt+1)
  }

  val n = io.StdIn.readLine.toInt
  val a = io.StdIn.readLine.split(" ").map(e => rec(e.toInt, 0))

  println(a.min)
}

Measured memory_bytes: 27336
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,i;
    cin>>n;
    set<int>s;
    for(i=1;i<=n;i++)
    {
        cin>>a;
        s.insert(a);
    }
    if(s.size()==n)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}


Measured memory_bytes: 9600
#include<functional>
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pf push_front
#define pb push_back
#define int long long
using namespace std;
const int INF=1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

signed main(){
  int h,w;
  cin>>h>>w;
  int mp[51][51]={};

  rep(i,h){
    rep(j,w){
      char x;
      cin>>x;
      mp[i][j]=x-48;
    }
  }

  rep(i,w-1)mp[0][i+1]+=mp[0][i];
  rep(i,h-1)mp[i+1][0]+=mp[i][0];
  loop(i,1,h){
      loop(j,1,w){
        mp[i][j]=min(mp[i-1][j],mp[i][j-1])+mp[i][j];
      }
    }
  cout<<mp[h-1][w-1]<<endl;

  

 return 0;
}

Measured memory_bytes: 3120
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std;

//for loop関係
#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 rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

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

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

//Degree <-> Radian
double toRad(double d){ double rad; rad=d*PI/180; return rad; }
double toDegree(double rad){ double d; d=rad*180/PI; return d; }
//The least common multiple : lcm
ll lcm(int a,int b){ return a*b/__gcd(a,b); }
//素数判定
bool isPrime(int n){
    int i; 
    if(n<2) return 0;
    else if(n==2) return 1;
    if(n%2==0) return 0;
    for(i=3;i*i<=n;i+=2) if(n%i==0) return 0;
    return 1;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b;
    cin >> a >> b;
    int tmpa=a,tmpb=b;
    rep(i,1,b){
        a*=10;
        a+=tmpa;
    }
    rep(i,1,tmpa){
        b*=10;
        b+=tmpb;
    }
    if(tmpa>=tmpb){
        cout << b ENDL;
    }else cout << a ENDL;
    
    return 0;
}

Measured memory_bytes: 3584
#include <stdio.h>

int main(void)
{
    int a, b, year, answer, i;
    i = 0;
    while(1) {
	scanf("%d %d", &a, &b);
	if (a == 0 && b == 0) {
	    break;
	}
	if (i != 0) {
	    printf("\n");
	}
	i++;
	answer = 0;
	for (year = a; year <= b; year++) {
	    if (year % 4 == 0) {
		if (year % 100 != 0) {
		    printf("%d\n", year);
		    answer++;
		} else if (year % 400 == 0) {
		    printf("%d\n", year);
		    answer++;
		}
	    }
	}
	if (answer == 0) {
   	    printf("NA\n");
	}
    }
    return 0;
}

Measured memory_bytes: 1044
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var t='0'+sc.S;
		int n=t.Length;
		var r=new int[n+1];
		int p=1;
		long ans=0;
		var h=new int[2020];
		h[0]++;
		for(int i = n-1;i>0;i--) {
			r[i]=((t[i]-'0')*p+r[i+1])%2019;
			h[r[i]]++;
			p=(p*10)%2019;
		}
		for(int i = 0;i<2020;i++) {ans+=h[i]*(h[i]-1)/2;}
		Console.WriteLine("{0}",ans);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 27648