akhauriyash/Code-Regression huggingface dataset:
# coding=utf-8

###
### for atcorder program
###

import sys
import math
import array

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]
#R = float(input())
#A = [int(x) for x in input().split()]
#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

def main():
    A = []

    while(True):
        n, x = [int(x) for x in input().split()]
        if (n == 0) and (x == 0):
            break
        else:
            A.append([n,x])
    
    for nx in A:
        ans = 0
        for i in range(1,nx[0]+1):
            for j in range(i+1,nx[0]+1):
                for k in range(j+1,nx[0]+1):
                    if (nx[1] == i+j+k):
                        ans += 1
        print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5744
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
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;} //最小公倍数

//-------------------------------------------------
//コピペするとこ



//-------------------------------------------------


int main()
{
  int n ;
  cin >> n ;
  vector<ll> vec(n) ;
  REP(i,n){
    cin >> vec.at(i) ;
  }
  ll sum1 = 0 ;
  ll sum2 = 0 ;
  int i = 0 ;
  int j = n-1 ;
  while(i<=j){
    if(sum1<=sum2){
      sum1 += vec.at(i) ;
      i++ ;
    }
    else{
      sum2 += vec.at(j) ;
      j-- ;
    }
  }
  
  cout << abs(sum1-sum2) <<endl ;
  
  return 0 ;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int n, m, T;
char mp[10][10];
bool mark[10][10];
int ans;
int main() {
	cin >> n >> m >> T;
	for (int i = 1; i <= n; i++) {
		scanf("%s", mp[i] + 1);
	}
	for (int i = 0; i < (1 << n); i++) {
		for (int j = 0; j < (1 << m); j++) {
			memset(mark, 0, sizeof(mark));
			for (int k = 0; k < n; k++) {
				if ((i >> k) & 1) {
					for (int l = 1; l <= m; l++) {
						mark[k + 1][l] = 1;
					}
				}
			}
			for (int k = 0; k < m; k++) {
				if ((j >> k) & 1) {
					for (int l = 1; l <= n; l++) {
						mark[l][k + 1] = 1;
					}
				}
			}
			int cnt = 0;
			for (int k = 1; k <= n; k++) for(int l = 1; l <= m; l++) if (!mark[k][l] && mp[k][l] == '#') cnt++;
			if (cnt == T) ans++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3760
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
from collections import Counter

def main():
    def factorization(n):
        if n == 1:
            return []
        arr = []
        temp = n
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                arr.append([i, cnt])

        if temp!=1:
            arr.append([temp, 1])

        if arr==[]:
            arr.append([n, 1])

        return arr
    m = [0]
    for i in range(1,10**6):
        m.append(m[i-1]+i)
    ans = 0

    n = int(input())
    k = factorization(n)
    for i,l in k:
        for u in range(len(m)):
            if l < m[u]:
                ans += u-1
                break
    print(ans)



if __name__=="__main__":
    main()


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

int main()
{
    long long a,b,c,mini,ans=0;
    cin>>a>>b>>c;
    mini=min(b,c);
    ans=mini*2;
    b-=mini;
    c-=mini;
    if(a>=c) ans+=c;
    else ans+=a+1;
    ans+=b;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
l = len(s)
ans = 0
for i in range(l):
    loc = 0
    idx = i 
    while s[idx] in ["A","C","G","T"] and idx<l:
        loc += 1
        idx += 1
        if idx>=l:
            break
    ans = max(ans,loc)
print(ans)

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

using namespace std;

 int main()
 {
   long int num,i,s=0;
   cin>>num;
   i=num;

   while(i){
        s+=(i%10);
        i/=10;

   }
   if(num%s==0)
   {
       cout<<"Yes"<<endl;
    }
   else 
   {
       cout<<"No"<<endl;
       
   }

 }





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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  int n; cin >> n;
  int ans = inf;

  rep(i, n) {
    int cnt = 0;
    ll a; cin >> a;

    while (a % 2 == 0) {
      a /= 2;
      ++cnt;
    }

    chmin(ans, cnt);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        //String a = sc.next(), b = sc.next(), c = sc.next();

        int[] n = new int[3];
        for(int i=0;i<3;i++){
            n[i]=sc.nextInt();
        }
        Arrays.sort(n);
        System.out.println((n[0]==5&&n[1]==5&&n[2]==7) ? "YES" : "NO");
    }

}


Measured memory_bytes: 21844
import sys

read = sys.stdin.readline
N, Ma, Mb = map(int, read().split())
abc = [tuple(map(int, read().split())) for _ in range(N)]
d = [(Mb * a - Ma * b, c) for a, b, c in abc]
dic = dict()
for i, j in d:
    for key, value in tuple(dic.items()):
        n = key + i
        if dic.get(n):
            dic[n] = min(value + j, dic[n])
        else:
            dic[n] = value + j
    if dic.get(i):
        dic[i] = min(j, dic[i])
    else:
        dic[i] = j

if dic.get(0):
    print(dic[0])
else:
    print(-1)


Measured memory_bytes: 3444
var AList: List<Int> = mutableListOf()
var N = 0
var cache = -1
fun main(args: Array<String>) {

    N = readLine()!!.split(" ").map { Integer.parseInt(it) }[0]
    AList = readLine()!!.split(" ").map { Integer.parseInt(it) }
    for (i in 0 until N) {
        print("${calc(i)} ")
    }

}

fun calc(start: Int): Int {
    var result = 0
    var sign = 1
    if (cache == -1) {
        for (i in start until N + start) {
            result += AList[i % N] * sign
            cache = result - AList[start]
            sign *= -1
        }
    } else {
        result = -1 * cache + AList[start - 1]
        cache = result - AList[start]
    }
    return result
}


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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    int m = 1001001001;
    int ans = 0;
    rep(i,n) {
        if (v[i] < m) {
            ++ans;
            m = v[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import math
import itertools

n = int(input())
k = int(input())

f = len(str(n))

if f < k:
    print(0)
else:
    #f-1桁以内に収まる数

    en = 1
    for i in range(k):
        en *= f-1-i

    de = math.factorial(k)


    s = en // de * pow(9, k)


    #f桁目によって絞る

    kami = int(str(n)[0])

    en = 1
    for i in range(k-1):
        en *= f-1-i

    de = math.factorial(k-1)


    s += (en // de * pow(9, k-1)) * (kami-1)


    #以下上1桁は同じ数字

    keta = list(range(f-1))
    num = list(range(1,10))

    b =  kami * pow(10, f-1)
    m = 0


    if k == 1:
        m = b
        if m <= n:
            s += 1
    else:
        for d in itertools.product(num, repeat=k-1):
            for c in itertools.combinations(keta, k-1):
                m = b
                for i in range(k-1):
                    m +=  d[i] * pow(10, c[i])
                if m <= n:
                    s += 1

    print(s)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
  int col[9];
  rep(i, 9) col[i] = 0;

  int n;
  cin >> n;
  rep(i, n)
  {
    int t;
    cin >> t;
    if (t >= 3200)
      col[8]++;
    else
      col[t / 400]++;
  }
  int ans = 0, ansmax, ansmin;
  rep(i, 8) if (col[i] > 0) ans++;
  ansmax = ans;
  ansmin = ans;
  if (col[8] > 0 and ans == 0)
    ansmin++;
  ansmax = ans + col[8];
  cout << ansmin << " " << ansmax << endl;
  return 0;
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

string S;
signed main() {
    cin >> S;
    if (S == "AAA" || S == "BBB") { cout << "No" << endl; }
    else { cout << "Yes" << endl; }
}

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

#define PI 3.14159265358979
#define rad(deg) (((deg) / 360) * 2 * PI)

struct Triangle {
    double a;
    double b;
    double C;
};

double area(Triangle t) {
    return t.a * t.b * sin(rad(t.C)) / 2.0;
}

double circumference(Triangle t) {
    double c = sqrt(pow(t.a, 2) + pow(t.b, 2) - 2 * t.a * t.b * cos(rad(t.C)));
    return c + t.a + t.b;
}

double height(Triangle t) {
    return t.b * sin(rad(t.C));
}

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

    Triangle t;
    cin >> t.a >> t.b >> t.C;

    cout << fixed << setprecision(10) << area(t) << endl;
    cout << fixed << setprecision(10) << circumference(t) << endl;
    cout << fixed << setprecision(10) << height(t) << endl;
}


Measured memory_bytes: 3468
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        if(n > 8 || m > 8 ) {
            System.out.println(":(");
        } else {
            System.out.println("Yay!");
        }

    }
}


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

int bubbleSort(int A[], int N){
    int sw = 0;
    bool flag = 1;
    for (int i = 0;flag; i++){
        flag = 0;
        for (int j = N -1;j >= i +1; j--){
            if (A[j] < A[j -1]){
                swap(A[j], A[j-1]);
                sw++;
                flag = 1;
            }
        }
    }
    return sw;
}

int main(){
    int A[100], N, sw;
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];
    sw = bubbleSort(A,N);
    for (int i = 0; i < N; i++){
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;
    
    return 0;
}


Measured memory_bytes: 3128
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>

unsigned long long int attack(unsigned long long int H)
{
    if (H == 1)
    {
        return 1;
    }
    return attack(H / 2) * 2 + 1;
}

int main()
{
    unsigned long long int H;
    std::cin >> H;

    std::cout << attack(H) << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int N, i, j, t, v;
    int A[100];

    scanf("%d", &N);
    for (i = 0; i < N; i++)
        scanf("%d", &A[i]);

    for (t = 0; t < N; t++)
    {
        if (t > 0)
            printf(" ");
        printf("%d", A[t]);
    }
    printf("\n");

    for (i = 1; i < N; i++)
    {
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v)
        {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;

        for (t = 0; t < N; t++)
        {
            if (t > 0)
                printf(" ");
            printf("%d", A[t]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2148
n,d = map(int,input().split())
x = [list(map(int,input().split())) for _ in range(n)]

import itertools,math
a = [i for i in range(n)]
e = itertools.combinations(a,2)

ans = 0
for i in e:
  c = 0
  for j in range(d):
    c += (x[i[0]][j] - x[i[1]][j]) ** 2
  if math.sqrt(c).is_integer():
    ans += 1

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

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();
    int i = 0;
    do{
      i++;
      int ans = (a * i) % b;
      if(ans == c) {
        System.out.println("YES");
        return;
      }
    }while((a * i) % b != 0);
    System.out.println("NO");
  }
}


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

int main(){
  int n;
  string s;
  int maxi = 0;
  int x = 0;
  
  cin >> n >> s;

  for(int i=0;i < n;i++){

    if(s[i] == 'I')
      {
	x++;
	maxi = max(maxi,x);

      }
    if(s[i] == 'D')
      {
	x--;
	maxi = max(maxi,x);
      }
  }
  cout << maxi << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define P pair<int, int>

using namespace std;
const int INF=1e5;

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


int main(){
  int h,w,a[1009][1009];
  string s[1009];
  cin >> h >> w;
  memset(a, -1, sizeof(a));
  for(int i=0;i<h;i++)cin >> s[i];
  queue<P> q;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]=='#'){
        a[i][j]=0;
        q.push(P(i,j));
      }
    }
  }
  int mx=0;
  while(!q.empty()){
    P p=q.front();q.pop();
    int ci=p.first;
    int cj=p.second;
    for(int i=0;i<4;i++){
      int ni=ci+dy[i];
      int nj=cj+dx[i];
      if(!(0<=ni&&ni<h&&0<=nj&&nj<w))continue;
      if(a[ni][nj]==-1){
        a[ni][nj]=a[ci][cj]+1;
        mx = max(mx, a[ni][nj]);
        q.push(P(ni, nj));
      }
    }
  }
  cout << mx << endl;
}



Measured memory_bytes: 13456
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
	int n;
	cin >> n;
	int* h = new int[n];
	for(int i = 0; i < n; i++)cin >> h[i];

	int count = 0;
	int tmp = 0;
	for(int i = 0; i < n-1; i++){
		if(h[i] >= h[i+1]){
			tmp++;
		} else{
			if(count < tmp){
				count = tmp;
			}
			tmp = 0;
		}
	}

	if(count < tmp){
		count = tmp;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

int128_t cal_mod(const int128_t n, const int128_t mod) {
    // n % modを計算する。ただしmod <= 0 ならば何もしない。nが負の場合、正にして補正する。
    if (mod <= 0) {
        return n;
    } else if (0 <= n) {
        return n % mod;
    } else {
        int128_t tmp = (-n) / mod + 1;
        return (n + tmp * mod) % mod;
    }
}

int H, W, d;

int cal(int x, int y) {
    int x_mod = cal_mod(x, d * 2);
    int y_mod = cal_mod(y, d * 2);
    return x_mod / d + (y_mod / d) * 2; 
}



int main(int argc, char **argv) {
    std::cin >> H >> W >> d;

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            int c = cal(i + j, i - j);
            if (c == 0) {
                std::cout << 'R';
            } else if (c == 1) {
                std::cout << 'Y';
            } else if (c == 2) {
                std::cout << 'G';
            } else {
                std::cout << 'B';
            }
        }
        std::cout << std::endl;
    }

    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
struct ans{
    int a,b,c;
    ans(int _a,int _b,int _c):a(_a),b(_b),c(_c){};
};
vector<ans> v;
map<int,int> mp;
vector<pair<int,int>> G[25];
int way = 0;

int L;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin>>L;

    int k = log2(L);
    for(int i = 2; i <= k + 1; i++){
        v.emplace_back(ans(i - 1,i,0));
        v.emplace_back(ans(i - 1,i,pow(2,i - 2)));
    }
    int rest = L - pow(2, k);
    int wei = pow(2, k);
    for(int i = k; i >= 1; i--){
        if(rest >= pow(2, i - 1)){
            v.emplace_back(ans(i,k + 1, wei));
            rest -= pow(2, i - 1);
            wei += pow(2,i - 1);
        }
    }
    cout<<k + 1<<" "<<v.size()<<endl;
    for(int i = 0; i < (int) v.size(); i++){
        cout<<v[i].a<<" "<<v[i].b<<" "<<v[i].c<<endl;
    }



    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using Graph = vector<vector<int>>;
vector<bool>seen;
vector<int>dist;

int main (){
  int N,M;
  cin>>N>>M;
  Graph G(N);
  rep(i,M){
    int a,b;
    cin>>a>>b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }
  seen.assign(N,false);
  dist.resize(N);
  queue<int> que;
  seen[0]=true;
  que.push(0);
  while(!que.empty()){
    int v;
    v=que.front();
    que.pop();
    for(int nv: G[v]){
      if(seen[nv]==true){ continue;}
      dist[nv]=v;
      seen[nv]=true;
      que.push(nv);
    }
  }
  que.push(0);
  cout<<"Yes"<<endl;
  for(int i=1;i<N;i++){
    cout<<dist[i]+1<<endl;
  }
}


Measured memory_bytes: 10128
n,k = map(int,input().split())
s = input()
if s[k-1:k] == 'A':
    s = s[0:k-1] +'a'+s[k::]
elif s[k-1:k] == 'B':
    s = s[0:k-1] +'b'+s[k::]
else:
    s = s[0:k-1] +'c'+s[k::]
print(s)

Measured memory_bytes: 3060
function Main(input) {
    var input = input.split(' ').map(n => parseInt(n, 10));
    var a = input[0];
    var b = input[1];
    var c = input[2];
    if(a == b) {
        console.log(c);
    } else if(b == c) {
        console.log(a);
    } else {
        console.log(b);
    }
    }
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 20680
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
 ll n;
 cin>>n;
  ll ac=0,tle=0,wa=0,re=0;
  for(ll i=0;i<n;i++){
    string str;
    cin>>str;
    if(str == "AC") ac++;
    else if(str == "WA") wa++;
    else if(str == "TLE") tle++;
    else if(str == "RE") re++;
  } 
  cout<<"AC x "<<ac<<"\n";
cout<<"WA x "<<wa<<"\n";
cout<<"TLE x "<<tle<<"\n";
cout<<"RE x "<<re<<"\n";
  return 0;
}

Measured memory_bytes: 3640
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    if n == 3:
        l = [2,5,63]
    elif n == 4:
        l = [2,5,20,63]
    elif n == 5:
        l = [2,3,4,6,9]
    else:
        l = []
        while len(l) < n:
            for k in range(30000):
                for i in [2,3,4,6]:
                    l.append(6*k+i)
                    if len(l) == n:
                        break
                else:
                    continue
                break
        s = sum(l)%6
        if s == 2:
            l[4] = 30000
        elif s == 3:
            l[5] = 30000
        elif s == 4:
            l[6] = 30000
        elif s == 5:
            l[5] = 29998
    s = sum(l)%6
    print(*l)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 42480
#include <stdio.h>
int main(void)
{
    int a, b, c;

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

    if (a == b || a > b)
        puts("No");
    else if (b == c || b > c)
        puts("No");
    else
    {
        puts("Yes");
    };

    return 0;
}


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

int main() {
    int N, K; cin >> N >> K;
    vector<int> l(N, 0);
    for (int i = 0; i < N; i++) {
        cin >> l.at(i);
    }
    sort(l.begin(), l.end(), greater<int>());
    int ans = 0;
    for (int i = 0; i < K; i++) {
        ans += l.at(i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

struct dat{
    int node, par;
};

template<class T>
struct union_find{
    int N;
    vector<int> par, rank;
    vector<int> time;
    vector<T> sz;

    union_find(int N, int M) : N(N), par(N + 1), rank(N + 1, 1), time(M + 1, 0), sz(N + 1, 1){
        for(int i = 0; i <= N; ++i) par[i] = i;
    }

    void init(int n, T s){sz[n] = s;}

    int find(int v){
        return (v == par[v] ? v : find(par[v]));
    }

    void unite(int x, int y, int t){
        x = find(x);
        y = find(y);
        if(x == y) return;

        if(rank[x] > rank[y]){
            time[t] = y;
            par[y] = x;
            sz[x] += sz[y];
        }else{
            time[t] = x;
            par[x] = y;
            sz[y] += sz[x];
            if(rank[x] == rank[y]) rank[y]++;
        }
    }

    void cut(int t){
        int u = time[t];
        sz[par[u]] -= sz[u];
        par[u] = u;
    }

    T get_sz(int x){
        return sz[find(x)];
    }
};

struct arc{
    int from, to, idx;
    ll Y;
    bool operator < (const arc& e1) const {
        return Y < e1.Y;
    }
    bool operator > (const arc& e1) const {
        return Y > e1.Y;
    }
};

struct edge{
    int to, idx;
    ll Y;
};

int N, M;
ll X[100010];
bool ok[100010], used[100010];
vector<edge> G[100010];

void dfs(int v, ll Y){
    if(used[v]) return;
    used[v] = true;
    for(auto u : G[v]){
        if(u.Y > Y) continue;
        ok[u.idx] = true;
        dfs(u.to, Y);
    }
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> M;

    union_find<ll> uf(N, M);
    for(int i = 1; i <= N; ++i){
        cin >> X[i];
        uf.init(i, X[i]);
    }

    vector<arc> as;
    for(int i = 1; i <= M; ++i){
        int A, B;
        ll Y;
        cin >> A >> B >> Y;
        as.emplace_back(arc{A, B, i, Y});
        G[A].emplace_back(edge{B, i, Y});
        G[B].emplace_back(edge{A, i, Y});
    }

    sort(as.begin(), as.end());
    for(int i = 0; i < M; ++i){
        uf.unite(as[i].to, as[i].from, i);
    }

    for(int i = M - 1; i >= 0; --i){
        if(ok[as[i].idx]) continue;
        if(uf.get_sz(as[i].to) >= as[i].Y){
            dfs(as[i].to, as[i].Y);
        }
        uf.cut(i);
    }
    int ans = M;
    for(int i = 1; i <= M; ++i) ans -= ok[i]; 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16176
#include <iostream>
using namespace std;
 
int main()
{   
    int d1, d2, n;
    cin>>n;
    int count=0;
    bool flag=false;
    while(n--){
        cin>>d1>>d2;
        if(d1==d2){
            count++;
            if(count==3)
                break;
        }
        else{
            count=0;
        }
            
    }
    if(count>=3)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
        
    return 0;
}

Measured memory_bytes: 3640
n=int(input())
H=[int(i) for i in input().split()]
ans=0
cur=0
for i in range(1,n):
  if H[i]<=H[i-1]:
    cur+=1
  else:
    ans=max(ans,cur)
    cur=0
  ans=max(ans,cur)
print(ans)

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


int main() {
  ll X,Y;
  cin >> X >> Y;
  if( X == Y+1 ||
      X+1 == Y ||
      X == Y ) {
    cout << "Brown" << endl;
  } else
    cout << "Alice" << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;

const ll MOD = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()



int main() {
	ll w, h, n, x[1010], y[1010], ans = 0;
	cin >> w >> h >> n;
	for (int i = 0;i < n;i++) {
		cin >> x[i] >> y[i];
	}
	for (int i = 1;i < n;i++) {
		if (x[i] >= x[i - 1]) {
			if (y[i] >= y[i - 1]) {
				ll a = min(x[i] - x[i - 1], y[i] - y[i - 1]);
				ans += a;
				ans += ((x[i] - x[i - 1]) - a) + (y[i] - y[i - 1] - a);
			}
			else {
				ans += (x[i] - x[i - 1]) + (y[i - 1] - y[i]);
			}
		}
		else {
			if (y[i - 1] >= y[i]) {
				ll a = min(x[i - 1] - x[i], y[i - 1] - y[i]);
				ans += a;
				ans += (x[i - 1] - x[i] - a) + (y[i - 1] - y[i] - a);
			}
			else {
				ans += (x[i - 1] - x[i]) + (y[i] - y[i - 1]);
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3108
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 X = sc.nextInt();
    if(A+B<X){
      System.out.print("NO");
    }else if(A<=X){
      System.out.print("YES");
    }else{
      System.out.print("NO");
    }
    
  }
  

  
}


Measured memory_bytes: 21844
using System;
using System.IO;
using System.Text;
using static Scanner;
using static System.Math;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Solve();
        Console.Out.Flush();
    }
    static void Solve() {
        int N = ScanInt(), M = ScanInt(), X = ScanInt();
        Span<int> C = stackalloc int[N];
        var A = new int[N][];
        for (int i = 0; i < N; i++) {
            C[i] = ScanInt();
            A[i] = ScanIntArray(M);
        }
        var answer = int.MaxValue;
        for (int bit = 0; bit < 1 << N; bit++) {
            var levels = new int[M];
            var cost = 0;
            for (int i = 0; i < N; i++) {
                if (((bit >> i) & 1) == 0) continue;
                cost += C[i];
                for (int j = 0; j < M; j++) levels[j] += A[i][j];
            }
            var isAchieved = true;
            for (int j = 0; j < M; j++) {
                if (levels[j] < X) isAchieved = false;
            }
            if (isAchieved) answer = Min(answer, cost);
        }
        Console.WriteLine(answer == int.MaxValue ? -1 : answer);
    }
}

public static class Scanner
{
    static readonly Stream stdin = Console.OpenStandardInput();
    static readonly byte[] buffer = new byte[1024];
    static int length, p;
    static bool isEof;
    private static byte StdIn() {
        if (isEof) return 0;
        if (p < length) return buffer[p++];
        p = 0;
        if ((length = stdin.Read(buffer, 0, 1024)) > 0) return buffer[p++];
        isEof = true;
        return 0;
    }
    public static char GetChar() {
        var by = StdIn();
        while ((by < '!' || '~' < by) && !isEof) by = StdIn();
        return (char) by;
    }
    public static int ScanInt() {
        var temp = 0;
        for (var ch = GetChar(); '0' <= ch && ch <= '9'; ch = (char) StdIn()) {
            temp = temp * 10 + ch - '0';
        }
        return temp;
    }
    public static int[] ScanIntArray(int len, int add = 0) {
        var array = new int[len];
        for (int i = 0; i < len; i++) array[i] = ScanInt() + add;
        return array;
    }
}

Measured memory_bytes: 26080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    string s;
    int x, y;
    cin >> s >> x >> y;
    bool turn = 0, chk = 1;
    int xcnt = 0, ycnt = 0, tcnt = 0, nx = 0;
    vector<int> vecx, vecy;
    rep(i, 0, s.size()) {
        if (s[i] == 'F') {
            if (turn) {
                ycnt++;
            } else {
                xcnt++;
            }
        } else {
            if (turn) {
                turn = 0;
                vecy.push_back(ycnt);
                ycnt = 0;
            } else {
                turn = 1;
                vecx.push_back(xcnt);
                xcnt = 0;
            }
            tcnt++;
        }
    }
    if (xcnt) vecx.push_back(xcnt);
    if (ycnt) vecy.push_back(ycnt);
    x -= vecx[0];
    vecx.erase(vecx.begin());
    sort(vecx.begin(), vecx.end(), greater<int>());
    sort(vecy.begin(), vecy.end(), greater<int>());
    for (int nx : vecx) {
        if (x >= 0) {
            x -= nx;
        } else {
            x += nx;
        }
    }
    for (int ny : vecy) {
        if (y >= 0) {
            y -= ny;
        } else {
            y += ny;
        }
    }
    if (y == 0 && x == 0) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}


Measured memory_bytes: 3692
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000


int main() {
	int a[N];
	f(i, N)a[i] = 0;
	int n, k;
	long long x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%d", &n);
	f(i, n) {
		scanf("%lld %lld", &x, &y);
		ans += (y * 9);
		ans += (x*y);
	}
	ans = (ans - 10) / 9;
	printf("%lld\n", ans);


	return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.util.Collections;

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();
    sc.close();
    if (A + B + C >= 22) {
      System.out.println("bust");
    } else {
      System.out.println("win");
    }
  }
}


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

int main()
{
  int n; cin >> n;
  int a[n];
  for ( int i=0; i<n; i++) cin >> a[i];
  
  int64_t ans=1e18;
  for (int i=-100; i<101; i++)
  {
    int64_t count = 0;
    for (int j=0; j<n; j++) {
      
     count += pow(i -a[j], 2);
    }
   	ans = min(count,ans);
  }
  cout << ans << endl;
}

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 K = sc.nextInt();
    Integer[] num = new Integer[N];
    
    for(int i =0; i < N; i++){
      num[i] = 0;
    }
    for(int i = 0; i < N; i++) {
      num[sc.nextInt() - 1]++;
    }
    Arrays.sort(num);    
    int ans = 0;
    if( N-K > 0){
      for(int i = 0; i < N-K ; i++){
        ans += num[i];
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 81092
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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 main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  int ans = 0;
  rep(i, n) {
    bool flag = true;
    rep(j, n) {
      rep(k, j) {
        if (s[j][(i+k)%n] != s[k][(i+j)%n]) {
          flag = false;
          break;
        }
      }
      if (!flag)
        break;
    }
    if (flag)
      ans++;
  }
  ans *= n;
  cout << ans << endl;
  return 0;
}

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

typedef pair<int, int> P;
int d[5] = { 0, 1, 0, -1, 0 };


int main() {
    while (1) {
        int h, w, si, sj;
        cin >> h >> w >> si >> sj;
        if (!h) return 0;

        --si;
        --sj;
        vector<vector<int>> kabey(h + 1, vector<int>(w));
        vector<vector<int>> kabet(h, vector<int>(w + 1));
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j)
                cin >> kabey[i][j];
            for (int j = 0; j < w + 1; ++j)
                cin >> kabet[i][j];
        }
        for (int i = 0; i < w; ++i)
            cin >> kabey[h][i];

        if (si + 1 >= h && !kabey[si + 1][sj] || si - 1 < 0 && !kabey[si][sj] || sj + 1 >= w && !kabet[si][sj + 1] || sj - 1 < 0 && !kabet[si][sj]) {
            cout << "Yes\n";
            continue;
        }

        vector<vector<int>> canesc(h, vector<int>(w));
        queue<P> q;
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                int ok[2] = {};
                if (i + 1 >= h || canesc[i + 1][j])
                    ok[kabey[i + 1][j]] = 1;
                if (i - 1 < 0 || canesc[i - 1][j])
                    ok[kabey[i][j]] = 1;
                if (j + 1 >= w || canesc[i][j + 1])
                    ok[kabet[i][j + 1]] = 1;
                if (j - 1 < 0 || canesc[i][j - 1])
                    ok[kabet[i][j]] = 1;

                if (ok[0] && ok[1]) {
                    canesc[i][j] = 1;
                    q.push(P(i, j));
                }
            }
        }
        while (!q.empty()) {
            P p = q.front();
            q.pop();
            int pi = p.first, pj = p.second;
            for (int i = 0; i < 4; ++i) {
                int ti = pi + d[i], tj = pj + d[i + 1];
                if (ti < 0 || ti >= h || tj < 0 || tj >= w || canesc[ti][tj]) continue;

                int ok[2] = {};
                if (ti + 1 >= h || canesc[ti + 1][tj])
                    ok[kabey[ti + 1][tj]] = 1;
                if (ti - 1 < 0 || canesc[ti - 1][tj])
                    ok[kabey[ti][tj]] = 1;
                if (tj + 1 >= w || canesc[ti][tj + 1])
                    ok[kabet[ti][tj + 1]] = 1;
                if (tj - 1 < 0 || canesc[ti][tj - 1])
                    ok[kabet[ti][tj]] = 1;

                if (ok[0] && ok[1]) {
                    canesc[ti][tj] = 1;
                    q.push(P(ti, tj));
                }
            }
        }
        cout << (canesc[si][sj] ? "Yes\n" : "No\n");
    }
}

Measured memory_bytes: 5776
//Kaori Miyazono, did I reach you ?
//"I can't die because... I'm the one who will protect you." -Asuna Yuuki
 
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n;
	vector<long long int> a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] -= i + 1;
	}
	if (n == 1) {
		cout << 0;
		return 0;
	}
	sort(a.begin(), a.end());
	long long int b = a[(n >> 1) - 1];
	long long int ans = 0;
	for(int i = 0; i < n; i++) {
		ans += abs(a[i] - b);
	}
	long long int an = 0;
	b = a[n >> 1];
	for(int i = 0; i < n; i++) {
		an += abs(a[i] - b);
	}
	ans = min(ans, an);
	cout << ans << '\n';
	return 0;
}

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

int main(){
	int a,b,c,x;
	int ans = 0;
	cin >> a >> b >> c >> x;
	for(int i = 0; i <= a; i++){
		for(int j = 0; j <= b; j++){
			for(int k = 0; k <= c; k++){
				if(500*i + 100*j + 50*k == x)
					ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://abc076.contest.atcoder.jp/tasks/abc076_a

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    R = int(input())
    G = int(input())
    x = 2*G - R
    print(x)


if __name__ == '__main__':
    main(sys.argv[1:])
    


Measured memory_bytes: 2940
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

const double PI = 3.14159265358979323846;
double A, B, H, M;

signed main(){
	cin >> A >> B >> H >> M;

	double x1 = A*sin((H*60+M)/720*2*PI);
	double y1 = A*cos((H*60+M)/720*2*PI);

	double x2 = B*sin(M/60*2*PI);
	double y2 = B*cos(M/60*2*PI);

	cout << fixed << setprecision(16);
	cout << sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)) << endl;
}

Measured memory_bytes: 4148
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        s: chars, t: chars
    }
    let mut sm = s;
    sm.sort();
    let mut tm = t;
    tm.sort();
    tm.reverse();
    let s_str = sm .iter().cloned().collect::<String>();
    let t_str = tm .iter().cloned().collect::<String>();
    println!("{}", if s_str < t_str {"Yes"} else {"No"});
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int MOD = 1e9 + 7;
int flag[10000];
int main(){
	int h,n;
	cin >> h >> n;
	vector<int> x(n);
	vector<int> y(n);
	for(int i = 0; i < n; ++i)
		cin >> x[i] >> y[i];

	vector<vector<ll> > dp(h + 3, vector<ll>(1 << 4, -MOD));
	vector<vector<int> > v(h, vector<int>(4, 1));
	for(int i = 0; i < n; ++i)
		v[y[i]][x[i]] = 0;
	
	dp[0][0] = 0;
	for(int i = 0; i < h - 1; ++i){
		for(int j = 0; j < (1<<4); ++j){
			if(dp[i][j] == -MOD)
				continue;

			dp[i+1][0] = max(dp[i+1][0], dp[i][j]);

			if(!(j&1) && !(j&(1<<1)) &&
				v[i+1][0] && v[i+1][1] && v[i][0] && v[i][1]
					)
				dp[i+1][3] = max(1 + dp[i][j], dp[i+1][3]);

			if(!(j&(1<<2)) && !(j&(1<<3)) &&
				v[i+1][2] && v[i+1][3] && v[i][2] && v[i][3]
			  )
				dp[i+1][(1<<2) + (1<<3)] = max(1 + dp[i][j], dp[i+1][(1<<2) + (1<<3)]);

			if(!(j&(1<<2)) && !(j&(1<<1)) &&
				v[i+1][2] && v[i+1][1] && v[i][2] && v[i][1]
			  )
				dp[i+1][(1<<2) + (1<<1)] = max(1 + dp[i][j], dp[i+1][(1<<2) + (1<<1)]);

			bool flag = true;
			if(j==0)
			for(int k = 0; k < 4; ++k)
				for(int l = 0; l < 2; ++l)
					if(v[i+l][k]==0)
					{
						flag=false;break;}

			if(j == 0 && flag){
				dp[i+1][(1<<4)-1] = max(2 + dp[i][j], dp[i+1][(1<<4)-1]);
			}
		}
	
	}

	int j = h-1;
			ll val =0;
		for(int i = 0; i < (1<<4); ++i)
			val = max(dp[j][i], val);
			cout << val << endl;

}



Measured memory_bytes: 5384
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val N = sc.nextInt(); val A = sc.nextInt(); val B = sc.nextInt()
  val h = new Array[Int](N)
  for(i <- 0 until N)
    h(i) = sc.nextInt()

  val enes = h.sorted

  def check(n: Long): Boolean = {
    val tmp: Long = enes.foldRight(0L){(x, y) =>
      val hoge: Long = x.toLong - B*n
      if(hoge <= 0)
        0L + y
      else {
        val piyo = if (hoge % (A-B) > 0) 1 else 0;
        (hoge / (A-B)) + piyo + y
      }
    }
    tmp <= n
  }

  // 条件を満たす最小の値を返す
  def binarySearch(min: Int, max: Int): Int = {
    val mid: Int = (max + min) / 2
    (max - min) match{
      case 0 | 1 =>
        check(min) match{
          case true  => min
          case false => max
        }
      case _ =>
        (check(mid)) match{
          case true  => binarySearch(min, mid)
          case false => binarySearch(mid, max)
        }
    }
  }

  val ans = binarySearch(1, 1e9.toInt)
  println(ans)
}


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

using namespace std;
int box[100005];
bool boxred[100005];
int main()
{
    int n,m,xi,yi,total=1;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        box[i]=1;
    boxred[1]=true;
    while(m--)
    {
        cin>>xi>>yi;
        if(box[xi]!=0)
        {
            box[xi]-=1;
            box[yi]+=1;
            if(boxred[xi]==true)
            {
                if(boxred[yi]==false)
                 total+=1;
                boxred[yi]=true;
            }

            if(box[xi]==0&&boxred[xi]==true)
            {
                boxred[xi]=false;
                total-=1;
            }
        }
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
int main(){
int W,H,x,y,r;
scanf("%d %d %d %d %d\n",&W,&H,&x,&y,&r);
if (x+r<=W && x-r>=0 && y+r<=H && y-r>=0)printf("Yes\n");else printf("No\n");return 0;}


Measured memory_bytes: 2148
n = int(input())
s = input()
ans = 0
for i in range(1,n - 1):
    cnt = 0
    for j in range(0,26):
        a = b = False
        for k in range(0,n):
            if ord(s[k]) == j + ord('a'):
                if k < i:
                    a = True
                else:
                    b = True
        if a and b:
            cnt += 1
    ans = max(ans,cnt)
print(ans)

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

int main()
{
    int64_t N;
    cin >> N;
    //i番目の数字を記録
    vector<int64_t> list(N);
    //各整数が何個ずつあるか記録
    vector<int64_t> count(N);

    int64_t sum = 0;//N個全部使うと何通りか
    int64_t tmp;

    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        list.at(i) = tmp;
        count.at(tmp - 1)++;
    }
    for (int i = 0; i < N; i++)
    {
        sum += (count.at(i) * (count.at(i) - 1)) / 2;
    }
    for (int i = 0; i < N; i++)
    {
        if (count.at(list.at(i) - 1) != 1)
        {
            cout << sum - count.at(list.at(i) - 1) + 1;
        }
        else
        {
            cout << sum;
        }
        cout << endl;
    }
}

Measured memory_bytes: 5760
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <math.h>

typedef unsigned long long ULONG;
typedef long long LONG;
using namespace std;

#define PI 3.1415926535897932384626433
#define _DBG_

#define BIG 10000000000 //10

#define LAST 10000000 //10^7

#define MOD (LONG)(10e8 + 7)




int main(void) {
	LONG N,D;
	cin >> N>>D;
	vector<vector<LONG>> XY(N, vector<LONG>(2));

//	vector<int> X(N);
//	vector<int> Y(N);
	for (int n = 0; n < N; n++) {
		cin >> XY[n][0] >> XY[n][1];
	}

	int count = 0;
	for (int n = 0; n < N; n++) {
		double dist = sqrt(XY[n][0] * XY[n][0] + XY[n][1] * XY[n][1]);
		if( dist  <= (double)D ){
			count++;
		}
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 14344