akhauriyash/Code-Regression huggingface dataset:
<?php
//error_reporting(0);
$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
//list($a,$b,$c) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$s = trim(fgets(STDIN));
//$a = array_map('intval',explode(" ",trim(fgets(STDIN))));

$c = array();
for($i=1;$i<=$N;$i++) {
  for($j=1;$j<=$N;$j++) {
    for($k=1;$k<=$N;$k++) {
      if (!isset($c[$i][$j])) {
        $c[$i][$j]=gcd($i,$j);
      }
      if (!isset($c[$c[$i][$j]][$k])) {
        $c[$c[$i][$j]][$k]=gcd($c[$i][$j],$k);
      }
      //printf("%d %d %d  %d\n",$i,$j,$k,$s);
      $sum+=$c[$c[$i][$j]][$k];
    }
  }
}
printf("%d\n",$sum);


function gcd($a,$b) {
  if ($b == 0) return $a;
  return gcd($b,$a%$b);
}
function lcm($a,$b) {
  $l = gcd($a,$b);
  return $a / $l * $b;
}

function prime_factors(int $n) {
    $i = 2;
    $factors = [];
    while ($i * $i <= $n) {
        if ($n % $i) $i += 1;
        else {
            $n /= $i;
            $factors[] = $i;
        }
    }
    if ($n > 1) $factors[] = $n;
    return $factors;
}
function is_prime(int $n) : bool {
    $r = true;
    if ($n < 2) $r = false;
    elseif ($n == 2 || $n == 3 || $n == 5) $r = true;
    elseif ($n & 1 == 0) $r = false;
    elseif ($n % 2 == 0 || $n % 3 == 0 || $n % 5 == 0) $r = false;
    else {
        $f = true;
        $v = 7;
        $m = intval($n ** 0.5) + 1;
        while ($v < $m) {
            if ($n % $v == 0) {
                $r = false;
                break;
            }
            $v += $f ? 4 : 2;
            $f = !$f;
        }
    }
    return $r;
}


Measured memory_bytes: 17428
def insertion_sort(arr, num):
    for i in range(1, num):
        v = arr[i]
        j = i - 1
        while j >= 0 and arr[j] > v:
            arr[j+1] = arr[j]
            j -= 1
        arr[j+1] = v
        print(' '.join([str(c) for c in a]))


if __name__ == '__main__':
    n = int(input())
    a_str: str = input()
    a = a_str.split(' ')
    a = [int(c) for c in a]
    print(' '.join([str(c) for c in a]))
    insertion_sort(a, n)



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

int main(){
int N;
cin >> N;
//0 1 4 5 6 
// 1 3 1 1

//0 1 3 6
// 1 2 3
vector<int>W(N);
for(int i = 0; i < N; i++){ 
       cin >> W.at(i);
}

vector<int>sum;
sum.push_back(0);

int now = 0;
for(int i = 0; i < N; i++){ 
       now += W.at(i);
       sum.push_back(now);
}

int min_sum = 10000;
for(int i = 1; i <= N; i++){ 
       min_sum = min(min_sum, abs(sum.at(i) - (sum.at(N) - sum.at(i))));
}


cout << min_sum << endl; 
}

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

using namespace std;

int main(void) {
	int N, T;
	cin >> N >> T;
	int result = 1001;
	for(int i = 0; i < N; ++i) {
		int c, t;
		cin >> c >> t;
		if(t <= T && c < result) {
			result = c;
		}
	}
	if(result == 1001) {
		cout << "TLE\n";
	} else {
		cout << result << '\n';
	}
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        int result = 0;

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        for (int i = 0; i < N; i++) {
            int num = sc.nextInt();
            int count = half(num);
            if (result == 0) {
                result = count;
            }
            if (count == 0) {
                result = 0;
                break;
            }
            if (count < result) {
                result = count;
            }
        }
        sc.close();
        System.out.println(result);
    }


    public static int half(int num) {
        int count = 0;
        while ((num % 2) == 0) {
            num = num / 2;
            count++;
        }
        return count;
    }
}


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

using ll = long long;

using namespace std;

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    int lim = (1 << (h + w));
    vector black(h, vector<bool>(w, false));
    for (int i=0; i<h; i++) {
        string row; cin >> row;
        for (int j=0; j<w; j++) {
            black[i][j] = (row[j] == '#');
        }
    }
    int ans = 0;
    for (int b=0; b<lim; b++) {
        vector red(h, vector<bool>(w, false));
        for (int i=0; i<h+w; i++) {
            if ((b >> i) & 1) {
                if (i < h) {
                    for (int j=0; j<w; j++) red[i][j] = true;
                } else {
                    for (int j=0; j<h; j++) red[j][i-h] = true;
                }
            }
        }
        int cnt = 0;
        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                if (black[i][j] && !red[i][j]) cnt++;
            }
        }
        if (cnt == k) ans++;
    }
    cout << ans << '\n';
    return 0;
}

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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  long int h,a,s=0,n;
  cin>>h>>n;
	
  while(n-- > 0){
    cin>>a;
    s=s+a;
  }
  if(s<h)
    cout<<"No";
  else cout<<"Yes";  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long h;
  scanf("%lld", &h);
  long long s = 0;
  long long i = 1;
  while(h >= 1){
    h >>= 1;
    s += i;;
    i <<= 1;
  }
  printf("%lld", s);
}

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


void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}


int main(){
	int N;
	cin >> N;
	double x[N], y[N];
	for(int i=0;i<N;i++){
		cin >> x[i] >> y[i];
		// printf("%.1f, %.1f\n",x[i], y[i]);
	}
	double D[N][N] ={0};
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			double X = x[i] - x[j];
			double Y = y[i] - y[j];
			double d = X * X + Y * Y; 
			D[i][j] = sqrt(d);
			// printf("%.9f, %.5f\n", D[i][j], d);
		}
	}
	double cnt = 0;
	vector<int> nums(N);
	iota(nums.begin(), nums.end(), 0);
	double ans = 0;
	do{
		for(int i=0;i<N-1;i++){
			ans += D[nums[i]][nums[i+1]];
		}
		// printVector(nums);
		// printf("%.9f\n", ans);
		cnt += 1;
	} while(next_permutation(nums.begin(), nums.end()));
	ans /= cnt;
	printf("%.9f\n", ans);
	// printf("%.9f\n", cnt);
}

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

int main(){
    int n;
    int max_d;
    int max_p;

    while(cin >> n, n != 0){
        int p;
        int d1, d2;
        max_d = 0;

        for(int i=1; i<=n; i++){
            cin >> p >> d1 >> d2;
            if(d1 + d2 > max_d){
                max_d = d1 + d2;
                max_p = p;
            }
        }
        printf("%d %d\n", max_p, max_d);
    }
    return 0;
}

Measured memory_bytes: 872
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
 
    # divisors.sort()
    return divisors
 
N,M = map(int,input().split())
arr = [i for i in make_divisors(M) if i>=N]
print(M//min(arr))

Measured memory_bytes: 38640
import sys
input=sys.stdin.readline

H, W = map(int, input().split())

a = []
for i in range(H):
    a.append(str(input()))

R = [[0] * W for i in range(H)]
L = [[0] * W for i in range(H)]
D = [[0] * W for i in range(H)]
U = [[0] * W for i in range(H)]

for i in range(H):
    cur = 0
    for j in range(W):
        if a[i][j] == "#":
            cur = 0
            U[i][j] = 0
        else:
            cur += 1
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] += U[i-1][j] + 1
        L[i][j] = cur

ans = 0
for i in reversed(range(H)):
    cur = 0
    for j in reversed(range(W)):
        if a[i][j] == "#":
            cur = 0
            D[i][j] = 0
        else:
            cur += 1
            if i == (H-1):
                D[i][j] = 1
            else:
                D[i][j] += D[i+1][j] + 1
        R[i][j] = cur
        if L[i][j] + R[i][j] + D[i][j] + U[i][j] -3 > ans:
            ans = L[i][j] + R[i][j] + D[i][j] + U[i][j] -3

print(ans)

Measured memory_bytes: 176136
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vector<ll> a(n); rep(i, n) cin >> a[i];
  sort(all(a));

  vector<ll> s(n+1); rep(i, n) s[i+1] = s[i] + a[i];

  int ans = 1;
  for (int i = n-1; i >= 0; i--) {
    if(2*s[i] >= a[i]) ans++;
    else break;
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 1792
using namespace std;
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define debug(x) cout << #x <<" = " << x << endl
void solve()
{
int n;
cin>>n;
vector<pair<int,int>> v(n);
for (int i = 0; i < n; i++)
{
    int a,b;
    cin>>a>>b;
    v[i]={a,b};
}
for (int i = 0; i <=n-3; i++)
{
    if(v[i].first==v[i].second&&v[i+1].first==v[i+1].second&&v[i+2].first==v[i+2].second)
    {
        cout<<"Yes"<<endl;
        return ;
    }
}
cout<<"No"<<endl;
}
int main()
{

FASTIO
 long long int t=1;
 //cin>>t;
 while(t--)
  solve();
  return 0;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cstdlib>
#include <cctype>
#include <algorithm>
#include <functional>
#include <utility>
#include <vector>
const int maxn = 100005;
inline int lowbit(int x) {
  return x & (-x);
}
int m; int C[maxn];
inline void add(int p, int x) {
  while(p <= m) {
    C[p] += x;
    p += lowbit(p);
  }
}
inline int sum(int p) {
  int ans = 0;
  while(p > 0) {
    ans += C[p];
    p -= lowbit(p);
  }
  return ans;
}

struct Node {
  int l, r, id, typ;
  Node() {}
  Node(int L, int R) {
    l = L; r = R; typ = 0;
  }
  Node(int L, int R, int i) {
    l = L; r = R; id = i; typ = 1;
  }
  bool operator <(const Node &res) const {
    if(l == res.l) {
      return typ < res.typ;
    } else {
      return l > res.l;
    }
  }
};
int ans[maxn];
int main() {
  int n; scanf("%d%d", &n, &m);
  std::vector<Node> pool;
  for(int i = 1; i <= n; i ++) {
    int L, R; scanf("%d%d", &L, &R);
    pool.push_back(Node(L, R));
  }
  std::fill(ans + 1, ans + 1 + m, n);
  for(int i = 2; i <= m; i ++) {
    for(int j = 0; j * i < m; j ++) {
      int L = j * i, R = (j + 1) * i;
      L ++; R --;
      R = std::min(R, m);
      pool.push_back(Node(L, R, i));
    }
  }
  std::sort(pool.begin(), pool.end());
  for(auto p : pool) {
    if(p.typ) {
      ans[p.id] -= sum(p.r);
    } else {
      add(p.r, 1);
    }
  }
  for(int i = 1; i <= m; i ++) printf("%d\n", ans[i]);
  return 0;
}

Measured memory_bytes: 35428
<?php
$input_1 = trim(fgets(STDIN));
$m = explode(' ', $input_1)[1];

$input_2 = trim(fgets(STDIN));
$items = explode(' ', $input_2);

$total = array_sum($items);
$border = $total / (4 * $m);

rsort($items);

for ($i = 0; $i < $m; $i++) {
    if ($items[$i] < $border) {
        echo "No";
        exit();
    }
}

echo 'Yes';

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll x=0,f=1; char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1; ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
ll x[1000005],a[1000005],w[1000005];
int main(){
	ll n=read(),L=read(),T=read(),cur=0;
	for (ll i=0;i<n;i++){
		a[i]=read(); w[i]=read();
		if (w[i]==1){
			x[i]=(a[i]+T)%L;
			cur+=(a[i]+T)/L;
		} else{
			x[i]=(a[i]-T)%L;
			cur+=(a[i]-T)/L;
			if (x[i]<0) x[i]+=L,cur--;
		}
	}
	cur=(cur%n+n)%n;
	sort(x,x+n);
	for (ll i=cur;i<n;i++) printf("%lld\n",x[i]);
	for (ll i=0;i<cur;i++) printf("%lld\n",x[i]);
	return 0;
}

Measured memory_bytes: 10112
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    vector<vector<int>> c(3, vector<int>(3));
    rep(i, 3) rep(j, 3) cin >> c[i][j];
    rep(i, 101) {
        int a1 = i;
        int b1 = c[0][0] - i;
        int a2 = c[1][0] - b1;
        int a3 = c[2][0] - b1;
        int b2 = c[0][1] - a1;
        int b3 = c[0][2] - a1;
//        printf("%d %d %d %d %d %d\n", a1, a2, a3, b1, b2, b3);
        if ( c[1][1] != a2 + b2 ) continue;
        if ( c[1][2] != a2 + b3 ) continue;
        if ( c[2][1] != a3 + b2 ) continue;
        if ( c[2][2] != a3 + b3 ) continue;
        cout << "Yes" << endl;
        return 0;
    } 
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
"""
a(x-p) + b (p <= x <= q) の2階階差をとり、imos配列に加える
復元はaccumulateでやる
"""
def kaisa2_of_tousa(a,b,p,q,imos,n):
    if p > q: return
    imos[p] += b
    if p+1 < n: imos[p+1] += a-b
    y = a*(q-p)+b
    if q+1 < n: imos[q+1] += -y-a
    if q+2 < n: imos[q+2] += y

# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,m,*a = map(int,read().split())

imos = [0]*(2*m+1)
ans = 0
for p,q in zip(a,a[1:]):
    if p > q: q += m
    ans += q-p
    kaisa2_of_tousa(-1,0,p+1,q,imos,2*m+1)

from itertools import accumulate as acc
res = list(acc(acc(imos)))


v = 0
for i in range(1,m+1):
    w = res[i]+res[i+m]
    v = min(v,w)
    #print(w)

#print(ans)
print(ans+v)    









Measured memory_bytes: 102584
#include <iostream>
#define int long long
using namespace std;
int32_t main()
{
  int a,b; cin>>a>>b;
  if( abs(a/2019 - b/2019) > 0) cout<<0;
  else{
    int ans = 99999;
    for(int i = a; i <= b; i++)
      for(int j = i + 1; j <= b; j++)
         ans = min(ans,(i*j) % 2019);
    cout<<ans;
  }
}


Measured memory_bytes: 256
// At Corder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
using namespace std;
#include <vector>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using p = pair<int, int>;//<key,value>

int main()
{
ll x;
cin>>x;
ll m=100;
for (int i = 1;  i < 100000000; ++ i)

{
m+=m*0.01;
if(m>=x){
	cout<<i<<endl;
	return 0;
}

}
	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント:
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

typedef long long ll;

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  int a;cin >> a;
  cout << a + a*a + a*a*a << "\n";
  return 0;
}

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

int main() {
  int64_t N, K;
  cin >> N >> K;
  int64_t A = N%K;
  int64_t B = (A-K)*(-1);
  if(A > B){
    cout << B << endl;
  } else {
    cout << A << endl;
  }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
class Node{
public:
  int location;
  int p,l,r;
  Node(){}
};
class Point{
public:
  int id,x,y;
  Point(){}
  Point(int id,int x,int y): id(id),x(x),y(y){}
  bool operator < (const Point &p){return id<p.id;}
};
static const int MAX =1000000;
static const int NIL = -1;
int n;
Point P[MAX];
Node T[MAX];
int np;
bool lessX(const Point &p1,const Point &p2){return p1.x<p2.x;}
bool lessY(const Point &p1,const Point &p2){return p1.y<p2.y;}
int makeKDTree(int l,int r, int d){
  if(!(l<r))return NIL;
  int mid=(l+r)/2;
  int t=np++;
  if(d%2==0)sort(P+l,P+r,lessX);
  else sort(P+l,P+r,lessY);
  T[t].location=mid;
  T[t].l=makeKDTree(l,mid,d+1);
  T[t].r=makeKDTree(mid+1,r,d+1);
  return t;
}
void find(int v,int sx,int tx,int sy,int ty,int d,vector<Point> &ans){
  int x=P[T[v].location].x;
  int y=P[T[v].location].y;
  if(sx<=x&&x<=tx&&sy<=y&&y<=ty)ans.push_back(P[T[v].location]);
  if(d%2==0){
    if(T[v].l!=NIL)if(sx<=x)find(T[v].l,sx,tx,sy,ty,d+1,ans);
    if(T[v].r!=NIL)if(x<=tx)find(T[v].r,sx,tx,sy,ty,d+1,ans);
  }
  else{
    if(T[v].l!=NIL)if(sy<=y)find(T[v].l,sx,tx,sy,ty,d+1,ans);
    if(T[v].r!=NIL)if(y<=ty)find(T[v].r,sx,tx,sy,ty,d+1,ans);
  }
}
int main(){
  int x,y;
  cin>>n;
  rep(i,n){
    scanf("%d %d",&x,&y);
    P[i]=Point(i,x,y);
    T[i].l=T[i].r=T[i].p=NIL;
  }
  np=0;
  int root=makeKDTree(0,n,0);
  int q;
  cin>>q;
  int sx,sy,tx,ty;
  vector<Point>ans;
  rep(i,q){
    scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
    ans.clear();
    find(root,sx,tx,sy,ty,0,ans);
    sort(ans.begin(),ans.end());
    rep(j,ans.size())printf("%d\n",ans[j].id);
    cout<<endl;
  }return 0;
}

Measured memory_bytes: 16456
import math

n, d = map(int, input().split())

a = []
cnt = 0

for i in range(n):
	a.append(list(map(int, input().split())))
	
	for j in range(i):
		check = 0
		
		for k in range(d):
			check += pow(abs(a[i][k] - a[j][k]), 2)
			
		if((math.sqrt(check)).is_integer()):
			cnt += 1
			
print(cnt)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    ll a,b;
    cin>>a>>b;
    if(a*b%2==0) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
    int n,count=0,inp;
    cin >> n;
    for(int i = 0;i<n;i++){
        cin >> inp;
        if((i+1)%2==1&&inp%2==1)
            count++;
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 3592
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
		char[] x = sc.next().toCharArray();
		char[] y = sc.next().toCharArray();
		if (x[0]==y[2]){
        	if (x[2]==y[0]){
				if (x[1]==y[1]){
                	System.out.print("YES");
					return;
                }
            }
        }
		System.out.print("NO");
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main() {

    int n, m, a;
    while(cin >> n >> m >> a, n) {
        vector< vector< pair<int, int> > > line(1001);
        for(int i = 0; i < m; i++) {
            int h, p, q; cin >> h >> p >> q;
            line[h].push_back(make_pair(p, q));
            line[h].push_back(make_pair(q, p));
        }

        int now = a;
        for(int i = 1000; i > 0; i--) {
            for(int j = 0; j < line[i].size(); j++) {
                if(now == line[i][j].first) {
                    now = line[i][j].second;
                    break;
                }
            }
        }
        cout << now << endl;
    }
}

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

using namespace std;

#define lc (1 + (idx << 1))
#define rc (2 + (idx << 1))
#define md ((st + nd) >> 1)
#define fi first
#define se second
#define pb push_back
typedef long long ll;

const int N = 16;
int a[N][N];
ll dp[N+1][1<<N], b[1<<N];

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	for (int j = 1; j < (1 << n); j++) {
		for (int u = 0; u < n; u++) {
			if (j & (1 << u)) {
				for (int v = u + 1; v < n; v++) {
					if (j & (1 << v)) {
						b[j] += a[u][v];
					}
				}
			}
		}
	}
	memset(dp, -1, sizeof dp);
	dp[0][0] = 0;
	for (int i = 1; i <= n; i++) {
		dp[i][0] = 0;
		for (int j = 1; j < (1 << n); j++) {
			dp[i][j] = -1;
			int hold = j;
			do {
				if (dp[i-1][hold] != -1) {
					dp[i][j] = max(dp[i][j], dp[i-1][hold] + b[j^hold]);
				}
				--hold;
				hold &= j;
			} while (hold != j);
		}
	}
	/*
	ll res = 0;
	for (int i = 1; i <= n; i++) {
		res = max(res, dp[i][(1<<n)-1]);
	}
	printf("%lld", res);
	*/
	printf("%lld", dp[n][(1<<n)-1]);
	return 0;
}
/*
3
0 10 20
10 0 -100
20 -100 0
*/
/*
2
0 -10
-10 0
*/
/*
4
0 1000000000 1000000000 1000000000
1000000000 0 1000000000 1000000000
1000000000 1000000000 0 -1
1000000000 1000000000 -1 0
*/
/*
16
0 5 -4 -5 -8 -4 7 2 -4 0 7 0 2 -3 7 7
5 0 8 -9 3 5 2 -7 2 -7 0 -1 -4 1 -1 9
-4 8 0 -9 8 9 3 1 4 9 6 6 -6 1 8 9
-5 -9 -9 0 -7 6 4 -1 9 -3 -5 0 1 2 -4 1
-8 3 8 -7 0 -5 -9 9 1 -9 -6 -3 -8 3 4 3
-4 5 9 6 -5 0 -6 1 -2 2 0 -5 -2 3 1 2
7 2 3 4 -9 -6 0 -2 -2 -9 -3 9 -2 9 2 -5
2 -7 1 -1 9 1 -2 0 -6 0 -6 6 4 -1 -7 8
-4 2 4 9 1 -2 -2 -6 0 8 -6 -2 -4 8 7 7
0 -7 9 -3 -9 2 -9 0 8 0 0 1 -3 3 -6 -6
7 0 6 -5 -6 0 -3 -6 -6 0 0 5 7 -1 -5 3
0 -1 6 0 -3 -5 9 6 -2 1 5 0 -2 7 -8 0
2 -4 -6 1 -8 -2 -2 4 -4 -3 7 -2 0 -9 7 1
-3 1 1 2 3 3 9 -1 8 3 -1 7 -9 0 -6 -8
7 -1 8 -4 4 1 2 -7 7 -6 -5 -8 7 -6 0 -9
7 9 9 1 3 2 -5 8 7 -6 3 0 1 -8 -9 0
*/


Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
           //前から順にO(N)
		 int n;
           cin>>n;
           vin aa(n);
           rep(i,0,n)cin>>aa[i];
           int a=0,b=0,c=0;
           int cnt;
           ll ans=1;
           rep(i,0,n){
            cnt=0; 
             if(aa[i]==a)cnt++;
             if(aa[i]==b)cnt++;
             if(aa[i]==c)cnt++;
             ans*=cnt;
             ans%=inf;
             if(aa[i]==a)a++;
             else if(aa[i]==b)b++;
             else c++;
           }
           cout<<ans<<endl;
}

Measured memory_bytes: 3768
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <stack>
using namespace std;
#define ll int64_t
const long mod = 1e9 + 7;


const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


int main() {
  string s;
  long n, q;
  cin >> n >> q;
  cin >> s;





  vector<long> l(q);
  vector<long> r(q);

  vector<long> ACpos;

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

  vector<long> mp(100001);

  mp[0]=0;

  for (int i = 0; i < s.size() - 1; ++i) {
    mp[i+1] = mp[i];
    if (s[i] == 'A' && s[i + 1] == 'C') {
      ACpos.push_back(i);
      mp[i+1] += 1;
    }
  }

  //NQともに10^5

  long ans = 0;
  for (int i = 0; i < q; ++i){
    ans = mp[r[i]] - mp[l[i]];


    cout << ans << endl;


  }







  
  // cout << (an?"yes":"no");

}




















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


int main(){
  int A, B; cin >> A >> B; int ans = -1;
  rep(i, 101010){
    if((int)(i*8)/100==(int)A && (int)i/10==(int)B){
      ans = i; break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	ll k;

	vll a(3);

	rep(i, 3) cin>>a[i];

	cin>>k;

	sort(all(a));
	rep(i, k){
		a[2]=(a[2]<<1);
	}
	cout<<a[0]+a[1]+a[2]<<endl;
}

Measured memory_bytes: 256
#ifdef DEBUG
#include "redirect.h"
#endif

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

char ch[200050];
int a[200050];
int s[200050],b[3000];

int main(int argc, char *argv[]) {
#ifdef DEBUG
    init(argc, argv);
#endif
    register int n,i,t; long long ans=0;
    scanf("%s",ch);
    n=strlen(ch);
    for (t=1,i=n-1;i>=0;i--) {
        s[i]=(s[i+1]+(ch[i]-'0')*t) %2019;
        t=t*10 %2019;
    }

    for (i=n;i>=0;i--) {
        ans+=b[s[i]];
        b[s[i]]++;
    }

    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 4748
#include <iostream>
#include <cmath>
using namespace std;
string s;
int ans=999432;
int main()
{
	cin >> s;
	for(int i=0; i<s.size()-2; i++)
	{
		int N=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
		
		ans=min(ans,abs(753-N));
	}
	cout << ans;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
    
		// 出力
		System.out.println(Math.min(a, b)+ " " + ((a + b) < n ? 0 : (a + b - n)));
	}
}

Measured memory_bytes: 22868
let rec max_heapify h (a:int array) j =
  let largest = ref j
  in
  if j*2 <= h then
    begin
      if a.(j*2-1) > a.(j-1) then largest := j*2;
      if j*2+1 <= h && a.(j*2) > a.(!largest-1) then largest := j*2+1;
      if !largest != j then
        begin
          let temp = a.(!largest-1) in
          a.(!largest-1) <- a.(j-1);
          a.(j-1) <- temp;
          max_heapify h a !largest
        end
    end
;;

let build_max_heap h (a:int array) =
  let rec loop = function
      0 -> ()
    | i -> max_heapify h a i;loop (i-1)
  in loop (h/2)
;;

let () =
  let h = read_int () in
  let a = Array.init h (fun _ -> Scanf.scanf " %d" (fun x -> x))
  in
  build_max_heap h a;
  Array.iter (fun x -> print_string " ";print_int x) a;
  print_newline ();;

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

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

const int INF = 1001001001;

const double PI=acos(-1);


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

    ll ans = max(K+1, (K-(A-1))%2+((K-(A-1))/2-1)*(B-A)+B);
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define FT first
#define SD second
#define MP make_pair
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int>  P;
const int N = 3e5 + 10,MOD = 7+1e9;
char s[N];
int E[N], W[N];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    cin >> s + 1;
    for(int i = 1;i <= n;i ++)
    {
        if(s[i] == 'E') E[i] = E[i-1] + 1;
        else E[i] = E[i-1];
        if(s[i] == 'W') W[i] = W[i-1] + 1;
        else W[i] = W[i-1];
    }
    int _min = N+1;
    for(int i = 1;i <= n;i ++)
    {
        int now = W[i-1] + E[n] - E[i];
        _min = min(_min, now);
    }
    cout << _min << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N; cin >> N;
  vector<ll> d1(N), d2(N); rep(i, N) cin >> d1[i] >> d2[i];
  
  ll cnt = 0;
  bool ok = false;

  rep(i, N) {
    if(d1[i] == d2[i]) cnt ++;
    else cnt = 0;
    if(cnt >= 3) ok = true;
  }

  cout << (ok?"Yes":"No") << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3692
n,k=map(int,input().split())
d={}
for _ in range(n):
    a,b=map(int,input().split())
    if a in d:
        d[a]+=b
    else:
        d[a]=b
s=0
for i in sorted(d):
    s+=d[i]
    if s>=k:
        print(i)
        exit()


Measured memory_bytes: 16204
<?php
fscanf(STDIN, "%d", $d);
if($d==25){
  echo 'Christmas';
}
elseif($d==24){
  echo 'Christmas Eve';
}
else if($d==23){
  echo 'Christmas Eve Eve';
}
else if($d==22){
  echo 'Christmas Eve Eve Eve';
}

?>

Measured memory_bytes: 4728
#include <iostream>
#include <cstdio>
#include <algorithm>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 105
#define MOD 20190823
#define eps 1e-8
#define bl bool
#define INF 1e+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
template<class T> inline void read(T &f){
	f=0;
    T x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
ll n;
ll a[DMAX];
ll b[DMAX];
ll c[DMAX];
int main(){
	read(n);
	ll ans=0;
	for(ll i=1;i<=n;i++){
		read(a[i]);
	}
	for(ll i=1;i<=n;i++){
		read(b[i]);
		ans+=b[i];
	}
	for(ll i=1;i<=n-1;i++){
		read(c[i]);
	}
	for(ll i=1;i<=n;i++){
		if(a[i+1]-a[i]==1){
			ans+=c[a[i]];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
using namespace std;
int main() {
	int a[3];
	cin >> a[1]>> a[2] >> a[0];
	for (int j = 0; j < 3; j++) {
		for (int i = 0; i < 3; i++) {
			if (a[i] < a[i + 1]) {
				int hoge;
				hoge = a[i];
				a[i] = a[i + 1];
				a[i + 1] = hoge;
			}
		}
	}
	int sum = 0;
	sum += a[0] - a[1];
	sum += a[1] - a[2];
	cout << sum << endl;

}

Measured memory_bytes: 256
# AOJ 0081 A Symmetric Point
# Python3 2018.6.17 bal4u

def dot(a, b):
	return a.real*b.real + a.imag*b.imag
	
def norm(a):
	return a.real**2 + a.imag**2
	
def project(line, p):
	base = line[1]-line[0]
	r = dot(p-line[0], base) / norm(base)
	return line[0] + base*r
	
def symmetric_Point(line, p):
	return p + 2*(project(line, p)-p)

while True:
	try: p = list(map(float, input().split(',')))
	except: break
	
	line = []
	line.append(complex(p[0], p[1]))
	line.append(complex(p[2], p[3]))
	pp = complex(p[4], p[5])
	qq = symmetric_Point(line, pp)
	print(qq.real, qq.imag)


Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,x,t;
  cin>>n>>x>>t;
  int m=n/x;
  if(n%x==0)
    cout<<(t*(m))<<endl;
  else
    cout<<(t*(m+1))<<endl;
}

Measured memory_bytes: 3628
class BinaryIndexedTree:
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= (i & -i)
        return s

    def add(self, i, x):
        while i <= self.n:
            self.bit[i] += x
            i += (i & -i)

    def reset(self):
        self.bit = [0] * (self.n + 1)


N, Q = map(int, input().split())
BIT = BinaryIndexedTree(N)
for q in range(Q):
    com, x, y = map(int, input().split())
    if com == 0:
        BIT.add(x, y)
    if com == 1:
        print(BIT.sum(y) - BIT.sum(x - 1))



Measured memory_bytes: 7932
NM=list(map(int,input().split()))
H=list(map(int,input().split()))
A=[0 for i in range(NM[0])]
for i in range(NM[1]):
    ab=list(map(int,input().split()))
    A[ab[0]-1]=max(A[ab[0]-1],H[ab[1]-1])
    A[ab[1]-1]=max(A[ab[1]-1],H[ab[0]-1])
d=0
for i in range(NM[0]):
    if(H[i]>A[i]):
        d+=1
print(d)


Measured memory_bytes: 20076
=begin
1, 受け取った文字列 chars で 各文字配列にする
2, 各文字を ord で文字コードに変換する(https://docs.ruby-lang.org/ja/latest/method/String/i/ord.html)
3, 対象の文字列から"A".ord の文字コード分を引くことで、アルファベット順の0~25の本来の位置を出力する
4, ズラしたい数値 n を 3, の出力にたす
5, "Z"以降のずれを防ぐため %26 であまりを出す
6, 5, の出力に "A".ordの数値を足して文字コードを元に戻す
7, .chrで文字コードを文字に変換する
=end

n = gets.to_i
s = gets.chomp.chars
a = 'A'.ord

s.each{|v|
  x = ((v.ord - 65 + n) % 26 + a).chr
  printf("%s", x)
}
puts

Measured memory_bytes: 2684
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

#define LB(v, x) (lower_bound(ALL(v), x) - v.begin())
#define UB(v, x) (upper_bound(ALL(v), x) - v.begin())

int main() {
	IN(int, n);
	vector<int> a(n);
	cin >> a;
	vector<vector<int>> g(n);
	inc(i, n - 1) {
		IN(int, a, b);
		a--; b--;
		g[a].PB(b);
		g[b].PB(a);
	}
	
	vector<int> ans(n), dp(n + 1, 2e9);
	dp[0] = 0;
	function<void(int, int)> dfs = [&](int v, int p) {
		int x = LB(dp, a[v]);
		int old = dp[x];
		ans[v] = max(x, ans[p]);
		setmin(dp[x], a[v]);
		RF(e, g[v]) {
			if(e == p) { continue; }
			dfs(e, v);
		}
		dp[x] = old;
	};
	dfs(0, 0);
	RF(e, ans) { OUT(e); }
}


Measured memory_bytes: 36624
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
import numpy as np

INF = 2**30
n = int(input())
P = list(map(int, input().split()))
T = [[] for _ in range(n)]
for i, p in enumerate(P, 1):
  T[p-1].append(i)
X = list(map(int, input().split()))
D = [[-1]*n for _ in range(2)]
def dfs(color, v):
  if D[color][v] != -1:
    return D[color][v]
  l = len(T[v])
  x = X[v]
  dp = np.full(x+1, INF, dtype=np.int64)
  dp[0] = 0
  for i, nv in enumerate(T[v]):
    k = np.full(x+1, INF, dtype=np.int64)
    if x+1 >= X[nv]:
      np.minimum(k[X[nv]:], dp[:x+1-X[nv]]+dfs(color, nv), out=k[X[nv]:])
    if x+1 >= dfs(color^1, nv):
      np.minimum(k[dfs(color^1, nv):], dp[:x+1-dfs(color^1, nv)]+X[nv], out=k[dfs(color^1, nv):])
    dp = k.copy()
  res = dp.min()
  D[color][v] = res
  return res
ans = dfs(0, 0)
if ans == INF:
  print("IMPOSSIBLE")
else:
  print("POSSIBLE")

Measured memory_bytes: 34296
#include<stdio.h>

void swap( int* , int* );

int main(void)
{
	int i, j;
	int height[10];
	
	for( i = 0 ; i < 10 ; i++ )
	{
		scanf("%d", &height[i] );
	}
	for( j = 0 ; j < 9 ; j++ )
	{
		for( i = j ; i < 10 ; i++ )
		{
			if( height[j] < height[i] ) swap( &height[i], &height[j] );
		}
	}
	
	for( i = 0 ; i < 3 ; i++ )
	{
		printf("%d\n", height[i]);
	}
	
	return 0;
}

void swap( int *x , int *y )
{
	int t;
	t = *x;
	*x = *y;
	*y = t;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main() {

	int a[3][3];
	int n;

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

	scanf("%d", &n);

	int b[10];

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

	int ans[3][3] = {{0,0,0}, {0,0,0}, {0,0,0}};

	for(int k = 0; k < n; k++) {
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 3; j++) {
				if(b[k] == a[i][j]) {
					ans[i][j] = 1;
				}
			}
		}
	}

	if( (ans[0][0] == 1 && ans[1][1] == 1 && ans[2][2] == 1) || (ans[0][2] == 1 && ans[1][1] == 1 && ans[2][0] == 1) ){
		printf("Yes\n");
		return 0;
	}

	for(int i = 0; i < 3; i++) {
		if(ans[i][0] == 1 && ans[i][1] == 1 && ans[i][2] == 1){
			printf("Yes\n");
			return 0;
		}
		if(ans[0][i] == 1 && ans[1][i] == 1 && ans[2][i] == 1) {
			printf("Yes\n");
			return 0;
		}
	}

	printf("No\n");
	return 0;

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,nu,f=0;
  cin>>n;
  while(n!=0)
  {
    nu=n%10;
    n=n/10;
    if(nu==7)
    {
      f=1;
      break;
    }
  }
  if(f==1)
    cout<<"Yes";
  else
    cout<<"No";
}


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

int main() {
  int ans=0;
  int N;
  cin >> N;
  vector<map<int,int>> list(N,map<int,int>());
  for (int i=0;i<N;i++) {
    int A;
    cin >> A;
    for (int j=0;j<A;j++) {
      int person, judge;
      cin >> person >> judge;
      list.at(i)[person-1]=judge;
    }
  }
  for (int tmp = 0; tmp < (1 << N); tmp++) {
    bitset<15> s(tmp);
    //cout << s << endl;
    int flag=0;
    // ビット列を出力
    for (int i=0;i<N;i++) {
      for (auto p: list.at(i)) {
        if (s.test(i)) {
          if(s.test(p.first) != bool(p.second)) {
            flag=1;
            //cout << i << endl;
            break;
          }
        }
      }
      if(flag) {
        break;
        //cout << N << endl;
      }
    }
    if(!flag) {
      ans = max(ans,int(s.count()));
      //cout << s << endl;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(n)]


def dfs(i, a, b, c):
    if n == i:
        if a < 1 or b < 1 or c < 1:
            return 10 ** 18
        return abs(A-a) + abs(B-b) + abs(C-c)
    return min([
        dfs(i + 1, a, b, c),
        dfs(i + 1, a + l[i], b, c) + (10 if a > 0 else 0),
        dfs(i + 1, a, b + l[i], c) + (10 if b > 0 else 0),
        dfs(i + 1, a, b, c + l[i]) + (10 if c > 0 else 0)
    ])


print(dfs(0, 0, 0, 0))


Measured memory_bytes: 3064
# ARC086C - Not so Diverse (ABC081C)
from collections import Counter


def main():
    n, k = list(map(int, input().rstrip().split()))
    lst = list(map(int, input().rstrip().split()))
    cnt = sorted(Counter(lst).values(), reverse=True)
    print(sum(cnt[k:]))


if __name__ == "__main__":
    main()

Measured memory_bytes: 32572
#include<bits/stdc++.h>
using namespace std;
int n,pre[111111],suf[111111],ans;
pair<int,int> a[111111];
int calc(int l,int r)
{
	if (l>r) return 0;
	return r-l+1;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i].first,&a[i].second);
	}
	sort(a+1,a+n+1);
	pre[0]=suf[n+1]=1e9;
	for (int i=1;i<=n;i++) pre[i]=min(pre[i-1],a[i].second);
	for (int i=n;i>=1;i--) suf[i]=min(suf[i+1],a[i].second);
	for (int i=1;i<n;i++)
	{
		ans=max(ans,max(calc(a[i].first,pre[i])+calc(a[n].first,suf[i+1]),calc(a[i].first,a[i].second)+calc(a[n].first,min(pre[i-1],suf[i+1]))));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1792
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;
ll gc(ll a, ll b){
    if(b == 0) return a;
    return gc(b, a % b);
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    for(auto &x : a){
        cin >> x;
    }
    sort(ALL(a));
    int pos = lower_bound(ALL(a), x) - a.begin();
    ll ans = 0;
    if(pos < n && pos > 0)
        ans = gc(abs(x - a[pos - 1]), abs(x - a[pos]));
    else if(pos == n){
        ans = x - a.back();
    }else if(pos == 0){
        ans = a[0] - x;
    }
    debug(ans);
    for(int i = 1; i < n; i++){
        ans = gc(ans, abs(a[i] - a[i - 1]));
    }
    cout << ans;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

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


Measured memory_bytes: 2052