akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define MEGA_MIND ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define M_PI 3.14159265358979323846
#define mod 1000000007
#define endl "\n"
#define point complex<ld>
using namespace std;
using ll = long long;
using lli = long long int;
using ld = long double;


const int N = 3e5 + 5, inf = 2e9;


ll fact[1000006], inv[1000006];

ll fp(ll base, ll exp)
{
	if (exp == 0)
		return 1;
	ll ans = fp(base, exp / 2);
	ans = (ans * ans) % mod;
	if (exp % 2 != 0)
		ans = (ans * (base % mod)) % mod;
	return ans;
}

void calcFacAndInv(ll n)
{
	fact[0] = inv[0] = 1;
	for (ll i = 1; i <= n; i++)
	{
		fact[i] = (i * fact[i - 1]) % mod;
		inv[i] = fp(fact[i], mod - 2);
	}
}

ll ncr(ll n, ll r)
{
	return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll npr(ll n, ll r)
{
	return (fact[n] * inv[n - r]) % mod;
}

int main()
{
	MEGA_MIND
		calcFacAndInv(1000000);
	ll n, k; cin >> n >> k;
	ll r = n - k, b = k;
	for (int i = 1; i <= k; i++)
	{
		if (r+1<i)
		{
			cout << 0 << endl;
		}
		else
		cout << ncr(r + 1, i) * ncr(b - 1, i - 1) % mod << endl;
	}return 0;
}

Measured memory_bytes: 15872
#include <stdio.h>

void print_array(int A[], int N) {
    for (int i=0;i<N;i++) {
        printf("%d%c",A[i],i==N-1?'\n':' ');
    }
}

void insert_sort(int A[], int N) {
        print_array(A, N);
    for (int i=1;i<N;i++) {
        int j=i-1;
        int key=A[i];
        while (j>=0 && A[j]>key) {
           A[j+1]=A[j];
          j--;
        }
       A[j+1]=key;
    print_array(A, N);
    }
} 

int main() {
    int N, A[100+1];
    scanf("%d", &N);
    for(int i=0;i<N;i++) {
        scanf("%d", &A[i]);
    }
    insert_sort(A,N);
    return 0;
}



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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  string s;cin>>s;
  int n=s.size();
  ll res=0;
  int a_cnt=0;
  for(int i=0;i<n;i++){
    if(s[i]=='A'){
      a_cnt++;
    }else{
      if(i+1==n)break;
      if(a_cnt==0)continue;
      if(s[i]=='B'&&s[i+1]=='C'){
        res += a_cnt;
        i++;
      }else{
        a_cnt=0;
      }
    }
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 720
n=int(input())
G=[[] for i in range(n+1)]
G_order=[]
for i in range(n-1):
  a,b=map(int,input().split())
  G[a].append(b)
  G_order.append(b)

from collections import deque
q=deque([1])
color=[0]*(n+1)
while q:
  cur=q.popleft()
  c=1
  for nx in G[cur]:
    if c==color[cur]:
      c+=1
    color[nx]=c
    c+=1
    q.append(nx)

print(max(color))
for i in G_order:
  print(color[i])


Measured memory_bytes: 23152
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
#define rep(i,n) for(int i=1;i<=(int) (n);i++)
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
using namespace std;
int main(){
  int m,d,d1,d2,cnt=0;
  cin>>m>>d;

  for(int j=1;j<=m;j++){
    for(int i=1;i<=d;i++){
  d1=i/10;
  d2=i%10;
  if(d1>1&&d2>1){
  if(d1*d2==j)cnt++;
}
}
}
cout<<cnt;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>

using namespace std;

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

    while( int l = S.length()  ){
        if( l < 5 ){
            cout << "NO" << endl;
            return 0;
        } else if( S.substr(l-5,l+1) == "dream"){
            S = S.substr(0,l-5);
        } else if( S.substr(l-5,l+1) == "erase"){
            S = S.substr(0,l-5);
        } else if( S.substr(l-6,l+1) == "eraser"){
            S = S.substr(0,l-6);
        } else if( S.substr(l-7,l+1) == "dreamer"){
            S = S.substr(0,l-7);
        } else {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

int main(){
	int n,k; cin >> n >> k;
	int nk = k*2 + 1;
	string s; cin >> s;
	vector<int> kukan;
	bool h = (s[0] == '1');
	if(!h){
		kukan.push_back(0);
	}
	int c = 1;
	for(int i=1; i<n; i++){
		if((s[i] == '1') == h) c++;
		else{
			kukan.push_back(c);
			h = !h;
			c = 1;
		}
	}
	kukan.push_back(c);
	if(s[n-1] == '0') kukan.push_back(0);
	int ss = 0;
	int ans = 0;
	rep(i,nk){
		if(i >= (int)(kukan.size())){
			cout << ss << endl;
			return 0;
		}
		ss += kukan[i];
	}
	ans = ss;
	for(int i=0; i<kukan.size()-nk; i+=2){
		ss = ss - kukan[i] + kukan[i+nk] - kukan[i+1] + kukan[i+nk+1];
		ans = max(ss,ans);
	}
	cout << ans << endl;
	//print(kukan);
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
 
    int n;
    cin >> n;
    vector<int> P(n), Q(n);
    for(int i = 0; i < n; i++){
        cin >> P[i];
    }
    for(int i = 0; i < n; i++){
        cin >> Q[i];
    }
 
    
    vector<int> A(n);
    for(int i = 0; i < n; i++){
        A[i] = i + 1;
    }
 
    int ai = -1, bi = -1, cnt = 0;
    do{
        if(ai == -1){
            bool f = true;
            for(int i = 0; i < n; i++){
                if(A[i] == P[i]);
                else{
                    f = false;
                    break;
                }
            }
            if(f) ai = cnt;
        }
        if(bi == -1){
            bool f = true;
            for(int i = 0; i < n; i++){
                if(A[i] == Q[i]);
                else{
                    f = false;
                    break;
                }
            }
            if(f) bi = cnt;
        }
        if(ai != -1 and bi != -1){
            break;
        }
        cnt++;
    }while(next_permutation(A.begin(), A.end()));
 
    cout << abs(ai - bi) << endl;
 
    return 0;
}

Measured memory_bytes: 256
x, y, a, b, c = map(int, input().split())
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]
r = [int(i) for i in input().split()]

p = list(reversed(sorted(p)))
q = list(reversed(sorted(q)))
r = list(reversed(sorted(r)))
apple = p[:x] + q[:y] + r
apple = list(reversed(sorted(apple)))
print(sum(apple[:x+y]))

Measured memory_bytes: 25264
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
int n, m;
int l;
int food[30]={};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>m;
    for(int i=0;i<n;i++) 
    { 
          cin>>l;
        for(int j=0;j<l;j++){
            int a;
            cin>>a;
            food[a-1]++;
        }
    }
    int ans=0;
    for(int i=0;i<m;i++){
        if(food[i]==n) ans++;
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define MINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e, v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int N;
int A[100010];

void _main() {
    cin >> N;
    map<int, int> cnt;
    REP(i, N) cin >> A[i], cnt[A[i]]++;
    int a = 0, b = 0;
    for (auto&& p : cnt) {
        if (p.second % 2 == 0) {
            ++a;
        } else {
            ++b;
        }
    }
    if (a % 2 == 0) cout << a + b << endl;
    else cout << a + b - 1 << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	string ans;
	if (a == b) {
		if (a != c)
			ans = "Yes";
		else
			ans = "No";
	} else if (b == c) {
		if (b != a)
			ans = "Yes";
		else
			ans = "No";
	} else if (a == c) {
		if (a != b)
			ans = "Yes";
		else
			ans = "No";
	} else
		ans = "No";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <map>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr ll INF = 1LL << 60;

string s;
ll q, a, f;
char c;

int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> s >> q;
  // 反転回数: ぐう気をみる
  ll cnt = 0;
  string t = "";
  REP(i, q) {
    cin >> a;
    if (a == 1) {
      ++cnt;
    } else {
      cin >> f >> c;
      if (f == 1) {
        if (cnt & 1) {
          s.push_back(c);
        } else {
          t = c + t;
        }
      } else {
        if (cnt & 1) {
          t = c + t;
        } else {
          s.push_back(c);
        }
      }
    }
  }
  if (cnt & 1) {
    reverse(s.begin(), s.end());
    reverse(t.begin(), t.end());
    cout << s << t << endl;
  } else {
    cout << t << s << endl;
  }
  return 0;
}



Measured memory_bytes: 1072
import Control.Applicative
import Control.Monad
import Data.Maybe (fromJust)
import qualified Data.ByteString.Char8 as BC
import Data.ByteString.Char8 (ByteString)
import Data.List

main = do
    n <- readLn
    unless (n==0) $ do
        cards <- map parseLine <$> replicateM n BC.getLine
        report $ score cards
        main

parseLine :: ByteString -> (Int, Int)
parseLine l = case map (fst . fromJust . BC.readInt) . BC.words $ l of
                 [a,b] -> (a,b)

report :: (Int, Int) -> IO ()
report (a,b) = putStrLn . unwords . map show $ [a,b]

score :: [(Int, Int)] -> (Int, Int)
score = foldl' f (0, 0)
    where
        f (scoreA, scoreB) (a,b) =
            case a `compare` b of
                 GT -> (a+b+scoreA, scoreB)
                 LT -> (scoreA, a+b+scoreB)
                 EQ -> (a+scoreA, b+scoreB)

Measured memory_bytes: 6576
#include<stdio.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>

int main()
{
	long long n;
	int s{};
	scanf("%lld", &n);

	for (long long tmp = n; tmp != 0; tmp /= 10)
	{
		s += tmp % 10;
	}

	if (n % s) printf("No\n");
	else printf("Yes\n");

	return 0;
}

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

int main(void) {
	int n;
	cin >> n;
	vector<int> o(n);
	for (int i = 0; i < n; i++) {
		cin >> o[i];
	}
	int ans = 1;
	int h = o[0];
	for (int i = 1; i < n; i++) {
		if(h <= o[i]) {
			ans++;
			h = o[i];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args ){
	    Scanner sc = new Scanner(System.in);
	    
	    int a = sc.nextInt();
	    int b = sc.nextInt();
	    
	    if( (a*b) % 2 == 0 )System.out.println("Even");
	    else System.out.println("Odd");
    }
}

Measured memory_bytes: 21204
N = int(input())
inp = list(map(lambda x: int(x), input().split(" ")))

counts = {}
for i in range(N):
    counts[inp[i]] = 0
for i in range(N):
    counts[inp[i]] += 1

ret = {}

allsum = 0
for k in counts.keys():
    allsum += counts[k]*(counts[k]-1)//2

for i in range(N):
    print(allsum - counts[inp[i]]+1)


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

int main() {
  string n;
  cin >> n;
  if(n[0] == n[1] || n[1] == n[2] || n[2]==n[3]){
    cout << "Bad" << "\n";
  }
  else{
    cout << "Good" << "\n";
  }
}


Measured memory_bytes: 256
import glob


# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = 'ABC\\159\\D'

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    alph = []

    def rec(self, result, now, max, N):

        if now == N:
            res = ""
            for i in result:
                res += self.alph[i]
            print(res)
            return

        if now == 0:
            result[0] = 0
            self.rec(result, now+1, 0, N)
            return

        for i in range(0, max+2):
            if i == N:
                return
            result[now] = i
            if i > max:
                self.rec(result, now+1, i, N)
            else:
                self.rec(result, now+1, max, N)

    def resolve(self):

        N = int(self.input_data())

        self.alph = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z".split(",")
        self.result = [0 for i in range(N)]
        self.rec(self.result, 0, 0, N)


solver = Solver(REL_PATH)
solver.exec_resolve()


Measured memory_bytes: 5220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int A, B;
string S;

bool ok() {
  for(int i = 0; i < A; i++){
    if(S[i] < '0' || S[i] > '9') return false;
  }
  if(S[A] != '-') return false;
  for(int i = A+1; i < A+B+1; i++) {
    if(S[i] < '0' || S[i] > '9') return false;
  }
  return true;
}

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

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


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

N,W = map(int,input().split())
info = []
for i in range(N):
    w,v = map(int,input().split())
    if i == 0:
        w1 = w
    w = w - (w1-1)
    info.append((w,v))
# dp[i][j][k]
# dp[i][j][k] = max(dp[i-1][j][k],dp[i-1][j-w][k-1])
# dp[0][j][0] = 0
# ans = max(dp[N][j][k] w1*k + j <= W)
dp = [[[0]*(N+1) for _ in range(400)] for _ in range(N+1)]
for i in range(1,N+1):
    w = info[i-1][0]; v = info[i-1][1]
    for j in range(400):
        for k in range(1,N+1):
            dp[i][j][k] = dp[i-1][j][k]
            if j - w >= 0:
                if dp[i][j][k] < dp[i-1][j-w][k-1] + v:
                    dp[i][j][k] = dp[i-1][j-w][k-1] + v
ans = -1
for j in range(400):
    for k in range(N+1):
        if not((w1-1)*k + j <= W):
            continue
        if dp[N][j][k] > ans:
            ans = dp[N][j][k]
print(ans)

Measured memory_bytes: 77020
#include <iostream>
#include <vector>

typedef long long ll;

using namespace std;

int main()
{
  ll h;
  cin >> h;
  ll ans = 0;
  ll fact = 1;
  while(h > 1)
  {
    h /= 2;
    ans += fact;
    fact *= 2;
  }
  ans += fact;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void) {
    double v, t, h, N;
    
    while (scanf("%lf", &v) != EOF) {
        t = v / 9.8;
        h = 4.9 * t * t;
        N = (h + 5) / 5;
        printf("%d\n", (int)ceil(N));
    }
    return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL -1
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	int64_t N, T;
	cin >> N >> T;

	vector<int64_t> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v.at(i);
	}

	int64_t sum = T;
	for (int i = 1; i < N; i++) {
		sum += min(v.at(i) - v.at(i - 1), T);
	}

	cout << sum << endl;
}

Measured memory_bytes: 4676
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define x first
#define y second
#define pii pair<int , int>
#define sz(a) (int)(a.size())
const int INF = 1000 * 1000 * 1000;
const int mod = 998244353;
const int MAX = 1000 * 1000 + 47;
using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	int h ,  w , n;
	cin >> h >> w >> n;
	h = max(h , w);
	cout << (n + h - 1) / h;
}


Measured memory_bytes: 256
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

count=0
n=int(input())
for i in range(1, n+1, 2):
  ans=1
  c=collections.Counter(prime_factorize(i))
  clist = c.values()
  for j in clist:
    ans *= (j+1)
  if ans == 8:
    count += 1
    
print(count)

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

#define int long long 
#define MOD 1000000007



using namespace std;


signed main(){

	int N,P;
	cin>> N>>P;
	
	unordered_map<int,int> sosu;

	int q = (int)sqrt(P)+1;
	
	if(N==1){
		cout << P <<endl;
		return 0;
	}
	int ans = 1;
	

	for(int i=2;i<=q;i++){
		int k=0;		
		while(1){
			if(P%i==0){
				P=P/i;
				k++;	
			}
			else{
				break;
			}	
		}
		
		if(k>=N){
			int y = (int)k/N;
			for(int j=0;j<y;j++){
				ans = ans*i;
			}
		}
		
		if(i>P){
			break;
		}
		
	}
	
	cout << ans << endl;
 	
 	return 0;
	

}

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

int main(){

  int n, z, w;
  cin >> n >> z >> w;
  int a[2000];
  for (int i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }

  int case1 = abs(w - a[n-1]);

  int k = 0;
  int l = 1;
  int ma;
  while(k < n-1){
    ma = -1e9;
    int mi;
    for (int i = k; i < n-1; i++){
      if (ma < abs(a[n-1] - a[i]) * l){
        mi = i;
        ma = abs(a[n-1] - a[i]) * l;
      }
    }
    k = mi + 1;
    l *= -1;
  }

  int case2 = abs(ma);
  if (n == 1) case2 = 0;
  cout << max(case1, case2) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long 
#define float long double 
#define el '\n'
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
        enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
        ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
        *this << "[";
        for (auto it = d.b; it != d.e; ++it)
                *this << ", " + 2 * (it == d.b) << *it;
        ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


signed main(){
        IOS;
        int n , W ;
        cin >> n >> W ;
        vector<int>dp(W+1,0);
        for(int i=0;i<n;i++){
                int w , v ;
                cin >> w >> v ;
                for(int j = W-w ; j>=0 ; j-- ){
                        dp[j+w] = max(dp[j+w],dp[j]+v);
                }
        }
        cout << dp.back() << endl ;
        return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
char s[303030];
int cntw[303030],cnte[303030];
int main()
{
	int l,ans=303030;
	cntw[0]=0;
	scanf("%d",&l);
	scanf("%s",s+1);
	cnte[l+1]=0;
	for(int i=1;i<=l;i++)
		cntw[i]=cntw[i-1]+(s[i]=='W');
	for(int i=l;i>=1;i--)
		cnte[i]=cnte[i+1]+(s[i]=='E');
	for(int i=1;i<=l;i++)
		ans=min(ans,cntw[i-1]+cnte[i+1]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//約数列挙(√N)
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
//素因数分解(√N)
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
//素数テーブル(NloglogN)
vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}
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;
}

//二項係数(K)
ll binomial(int64_t N, int64_t K) {
  if(K < 0 || N < K) return 0;
  ll ret = 1;
  for(ll i = 1; i <= K; ++i) {
    ret *= N;
    N--;
    ret%=1000000007;
    ll p=modinv(i,1000000007);
    ret*=p;
    ret%=1000000007;
    if(ret<0)ret+=1000000007;
  }
  return ret;
}
//二項係数テーブル(N^2)
template< typename T >
vector< vector< T > > binomial_table(int N) {
  vector< vector< T > > mat(N + 1, vector< T >(N + 1));
  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= i; j++) {
      if(j == 0 || j == i) mat[i][j] = 1;
      else mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j];
    }
  }
  return mat;
}
int main(){
  int x,y;
  cin >>  x >> y;
  if((x+y)%3!=0){
    cout << 0 << endl;
    return 0;
  }
  ll n=(x+y)/3;
  ll k=x-n;
  cout << binomial(n,k)<<endl;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main()
{
    int h,w;
    while(cin>>h>>w)
    {
        if(h==0 && w==0)
            break;
        else
        for(int i=0;i<h;i++)
        {
            for(int j=0;j<w;j++)
            {
            cout<<"#";
            }
            cout<<endl;
        }
         cout<<endl;

    }
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 2e5+5;
const int mod = 1e9+7;
using namespace std;


void solve() {
	ll t;
	rep(i,1,6) {
		cin >> t;
		if (t==0) {cout << i; return;}
	}
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:\\Users\\Fish_Brother\\Desktop\\in", "r", stdin);
	//freopen("C:\\Users\\Fish_Brother\\Desktop\\out", "w", stdout);
#endif
	//int t; cin >> t; while(t--)
	solve();

	return 0;
}

Measured memory_bytes: 3636
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

const int MAXN = 211;
int dp[MAXN][MAXN];

template<class Iter> int levenshtein(Iter s_first, Iter s_last, Iter t_first, Iter t_last, int cost=1) {
    int n = distance(s_first, s_last);
    int m = distance(t_first, t_last);
    REP (i, n+1) dp[i][0] = i;
    REP (j, m+1) dp[0][j] = j;
    REP (i, n) REP (j, m) {
	int c = cost;
	if (*(s_first+i) == *(t_first+j)) c = 0;
	dp[i+1][j+1] = min(dp[i][j] + c, min(dp[i][j+1], dp[i+1][j]) + 1);
    }
    return dp[n][m];
}

int levenshtein(const string &s, const string &t) {
    return levenshtein(s.begin(), s.end(), t.begin(), t.end());
}

const int L = 128;
const int Q = 850;
const int D = 62;

char C(int i) {
    if (i < 26) return i + 'a';
    i -= 26;
    if (i < 26) return i + 'A';
    i -= 26;
    return i + '0';
}

int A[D];

string PW = "ABIUJBIEHIiujaibuhr9821";
int cnt;
int query(const string &s) {
    cnt++;
    printf("? %s\n", s.c_str());
    fflush(stdout);

#ifdef MYTEST
    return levenshtein(s, PW);
#endif

    int ret;
    scanf("%d", &ret);
    return ret;
}

void answer(const string &s) {
    printf("! %s\n", s.c_str());
    fflush(stdout);
    assert(s == PW);
    assert(cnt <= Q);
}

void MAIN() {
#ifdef MYTEST
    while (PW.size() < L) PW.push_back(C(rand() % D));
#endif

    int len = L;
    REP (i, D) {
	int q = query(string(1, C(i)));

	A[i] = q;
	amin(len, q+1);
    }


    vector<string> V;
    REP (i, D) if (A[i]+1 == len) {
	int q = query(string(len, C(i)));
	V.push_back(string(len - q, C(i)));
    }

    while (V.size() >= 2u) {
	sort(V.begin(), V.end(), [](const string &a, const string &b) {
		return a.size() > b.size();
		});
	string a = V.back();
	V.pop_back();
	string b = V.back();
	V.pop_back();

	int i = 0;
	REP (j, b.size()) {
	    while (1) {
		string tmp = a.substr(0, i);
		tmp.push_back(b[j]);
		tmp += a.substr(i);

		int q = query(tmp);
		if (q == len - (int)tmp.size()) {
		    i++;
		    a = tmp;
		    break;
		} else {
		    i++;
		}
	    }
	}
	V.push_back(a);
    }

    answer(V.back());
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 3808
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long A=sc.nextLong();
		long B=sc.nextLong();
		long C=sc.nextLong();
		long K=sc.nextLong();
		if(K<A){
			System.out.println(K);
		}else if(K<A+B){
			System.out.println(A);
		}else{
			System.out.println(A-(K-A-B));
		}
	}
}


Measured memory_bytes: 27024
import java.math.BigInteger;
import java.util.*;
public class Main {
	

	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		
		int k = sc.nextInt();
		int x = sc.nextInt();
		
		System.out.println(k * 500 >= x ? "Yes" : "No");
			
		
		

		


		
		
	}
	


}

 

Measured memory_bytes: 22732
#include <bits/stdc++.h>
#define ll long long int
#define N 1000
#define M 1000000007
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define mp make_pair
#define bs binary_search
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.14159265
#define cot cout.tie(0)
using namespace std;
/**
  * @author :: Rishabh
  *
  */
int main()
{
	ibs;
	cti;
	char c;
	cin>>c;
	if(c>='a' && c<='z')
	cout<<'a'<<"\n";
	else
	cout<<'A'<<"\n";
	return 0;
}

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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 9000000000000000
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

struct Edge {
    long long to; // 繋がる所
    long long cost; // 区間距離（コスト）
};
using Graph = vector<vector<Edge>>;
using P = pair<long, int>;

/* dijkstra(G,s,dis)
    入力：グラフ G, 開始点 s, 距離を格納する（結果） dis
    計算量：O(|E|log|V|)
    副作用：dis が書き換えられる
*/
void dijkstra(const Graph &G, int s, vector<long long> &dis) {
    int N = G.size();
    dis.resize(N, INF);
    priority_queue<P, vector<P>, greater<P>> pq;  // 「仮の最短距離, 頂点」が小さい順に並ぶ
    dis[s] = 0;
    pq.emplace(dis[s], s);
    while (!pq.empty()) {
        P p = pq.top();
        pq.pop();
        int v = p.second;
        if (dis[v] < p.first) {  // 最短距離で無ければ無視
            continue;
        }
        for (auto &e : G[v]) {
            if (dis[e.to] > dis[v] + e.cost) {  // 最短距離候補なら priority_queue に追加
                dis[e.to] = dis[v] + e.cost;
                pq.emplace(dis[e.to], e.to);
            }
        }
    }
}

 

int main(){
    int n,m,s,t;
    cin>>n>>m>>s>>t;
    s--;t--;
    Graph ge(n),gs(n);
    int u, v, a ,b;
    rep(i,m){ 
        cin>>u>>v>>a>>b;
        u--;v--;
        Edge e;
        e.cost=a;
        e.to=v;
        ge[u].push_back(e);
        e.to=u;
        ge[v].push_back(e);
        e.cost=b;
        e.to=v;
        gs[u].push_back(e);
        e.to=u;
        gs[v].push_back(e);
        }
    vector<ll> daiE,daiS;
    dijkstra(ge,s,daiE);
    dijkstra(gs,t,daiS);
    vector<ll> ans(n);
    ll val=INF;
     for(int i=n-1;i>=0;i--){
         val=min(daiE[i]+daiS[i], val);
         ans[i]=1000000000000000-val;
    }
    rep(i,n) cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 21028
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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


int main() {
  ll N;

  cin>>N;
  ll a[N];
  ll ans =0;
  FOR(i,0,N-1){
    cin>>a[i];
    ans=ans-1+a[i];}





  cout<<ans<<endl;
  return 0;


 
}
 


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main() {

int a, b;
cin >> a >> b;

int aCopy = std::max(a, b);
int bCopy = std::min(a, b);

int r = 0;
while (bCopy != 0) {
r = aCopy % bCopy;
aCopy = bCopy;
bCopy = r;

}

cout << aCopy << endl;

return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	if (n > 81) {
		cout << "No";
	}
	else {
		for (int a = 1; a < 10; a++) {
			for (int b = 1; b < 10; b++) {
				if (a * b == n) {
					cout << "Yes";
					return 0;
				}
			}
		}
		cout << "No";
	}
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
using namespace std;
int main(){
    string n;
    cin>>n;
    if((n[0]=='9')||(n[1]=='9')){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}



Measured memory_bytes: 256
#[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! {
        ab: u64, bc: u64, _ca: u64
    }

    println!("{}", ab*bc/2);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#define SIZE 100005

using namespace std;
typedef pair <int,int> P;

P pos[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int a;
		scanf("%d",&a);
		pos[i]=P(a,i);
	}
	sort(pos,pos+n);
	int ret=0;
	for(int i=0;i<n;i++)
	{
		if(pos[i].second%2!=i%2)
		{
			ret++;
		}
	}
	printf("%d\n",ret/2);
	return 0;
}


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

Measured memory_bytes: 1012
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#include<limits>
#include<bitset>
#include<ctype.h>
#include<set>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000000;
const int MAX=100001;
const double EPS=1e-10;
using namespace std;
vector<int> G[300];
int match[300];
bool used[300];
int V;
void add_edge(int u,int v){
    G[u].push_back(v);
    G[v].push_back(u);
}
bool dfs(int v){
    used[v]=true;
    for(int i=0;i<(int)G[v].size();i++){
        int u=G[v][i],w=match[u];
        if(w<0||!used[w]&&dfs(w)){
            match[v]=u;
            match[u]=v;
            return true;
        }
    }
    return false;
}
int func(){
    int res=0;
    for(int i=0;i<300;i++){
        match[i]=-1;
    }
    for(int v=0;v<V;v++){
        if(match[v]<0){
            for(int i=0;i<300;i++){
                used[i]=0;
            }
            if(dfs(v)){
                res++;
            }
        }
    }
    return res;
}
int main() {
    int n;
    cin>>n;
    V=n;
    vector<P> r,b;
    for(int i=0;i<n;i++){
        int aa,bb;
        cin>>aa>>bb;
        r.push_back(P(aa,bb));
    }
    for(int i=0;i<n;i++){
        int c,d;
        cin>>c>>d;
        b.push_back(P(c,d));
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if((r[i].first<b[j].first)&&(r[i].second<b[j].second)){
                add_edge(i,n+j);
            }
        }
    }
    cout<<func()<<endl;
}








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

using namespace std;

int main(){
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    
    if(A >= K){
        cout << K << endl;
        
    }else{
        //
        if(B >= K - A){
            cout << A << endl;
        }else{
            cout << A - (K - A - B) << endl;
        }
        
    }
}


Measured memory_bytes: 3644
fun main(args: Array<String>) {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val e = (1..m).map{ readLine()!!.split(" ").map { it.toInt()-1 } }
    val a = Array(n){ mutableSetOf<Int>() }
    e.forEach{
        a[it[0]].add(it[1])
        a[it[1]].add(it[0])
    }

    if ((1..n-2).any {
        a[it].contains(0)&&a[it].contains(n-1) })
        println("POSSIBLE")
    else
        println("IMPOSSIBLE")

}

Measured memory_bytes: 119592
#include <iostream>
using namespace std;
using ll = int64_t;
int main()
{
	ll n,D;
	cin >> n >> D;
	ll ans = 0;
	for (ll i = 0; i<n; i++)
	{
		ll x, y;
		cin >> x >> y;
		ll d2 = x * x + y * y;
		if (d2 <= D * D) {
			ans++;
		}
	}
	cout << ans << endl;


}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll modpow(ll a, ll n){
  if(n==0)return 1;
  if(n%2==0){
    ll t=modpow(a,n/2);
    return t*t%MOD;
  }
  return a*modpow(a,n-1)%MOD;
}
ll modinv(ll a){
  return modpow(a,MOD-2);
}
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク

    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};
int h,w;
vector<string>vec;
int u[3000][3000];
int d[3000][3000];
int l[3000][3000];
int r[3000][3000];

    
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  COMinit();
  
  cin >> h >> w;
  vec.resize(h);
  rep(i,h) cin >> vec[i];
  rep(i,h){
    int cur=0;
    rep(j,w){
      if(vec[i][j]=='#')cur=0;
      else cur++;
      l[i][j]=cur;
    }
  }
  rep(i,h){
    int cur=0;
    for(int j=w-1;j>=0;j--){
      if(vec[i][j]=='#')cur=0;
      else cur++;
      r[i][j]=cur;
    }
  }
  rep(j,w){
    int cur=0;
    rep(i,h){
      if(vec[i][j]=='#')cur=0;
      else cur++;
      u[i][j]=cur;
    }
  }
  rep(j,w){
    int cur=0;
    for(int i=h-1;i>=0;i--){
      if(vec[i][j]=='#')cur=0;
      else cur++;
      d[i][j]=cur;
    }
  }
  int m=0;
  rep(i,h){
    rep(j,w){
      if(vec[i][j]=='.')chmax(m,l[i][j]+r[i][j]+u[i][j]+d[i][j]-3);
    }
  }
  cout << m << endl;
  
}


Measured memory_bytes: 116096
# include <bits/stdc++.h>
  using namespace std;
# define res(a,b,c) for (int64 a=b ; a<c ; a++)
# define ress(a,b)  for (auto a = b.begin() ; a!=b.end() ; a++) 
# define all(con) con.begin() , con.end()
# define INF (int)1e9  
# define MOD 1000000007
# define pb push_back   
# define mp make_pair
# define f first
# define s second   
# define MAX numeric_limits<int>::max() 
# define MIN numeric_limits<int64>::min()
# define mymin -1000000000000000001
# define mymax 1000000000000000001
# define watch(x) cout<<(#x)<<" is "<<(x)<<endl
# define in(x) cin>>(x)
# define inn(x,y) cin>>(x)>>(y)  
# define out(x) cout<<(x)<<"\n"  
# define outt(x,y) cout<<(x)<<" "<<(y)<<"\n"  
typedef long long int int64;
typedef unsigned long long int uint64;
typedef vector<int64> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef pair<int64,int64> pi; 
bool doubleSame(double a, double b)
{ const double eps = 1e-15; return ( abs(a-b)<= eps*abs(a) ); }

int main()
{
	int64 n; 
	cin>>n;

	vi list(n);
	int64 ttime = 0;
	res(i,0,n)
	{
		cin>>list[i];
		ttime+=list[i];
	}

	int64 m;
	cin>>m;
	vector<pi> d(m);
	res(i,0,m)
	{
		cin>>d[i].f>>d[i].s;
	}

	res(i,0,m)
	{
		cout<<(ttime-list[d[i].f-1]+d[i].s)<<"\n";
	}
}

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

string b(ll n) {
  ll sum = 0;
  ll nn = n;
  while(nn !=0) {
    sum += (nn % 10);
    nn /= 10;
  }
  return (n % sum == 0) ? "Yes" : "No";
}

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

  cout << b(n);
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
namespace io{
    const int l=1<<20;
    char buf[l],*s,*t,c;
    inline void gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            c=s==t?EOF:*s++;
        }else c=*s++;
    }
    template<class IT>inline void gi(IT &x){
        x=0;gc();while(c<'0'||c>'9')gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
    }
    char buf0[20];int a;
    template<class IT>inline void pi(IT x){
        if(x<0){putchar('-');x=-x;}
        do buf0[++a]=x%10+48;while(x/=10);
        while(a)putchar(buf0[a--]);
        putchar('\n');
    }
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=1000005,inf=1000000000;
char c[N];
int main(){
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    scanf("%s",c+1);
    int n=strlen(c+1),i,k,a,b,d0=0,d1=inf,D0,D1;
    per(i,n,1){
		D0=D1=inf;
		a=c[i]^'0';
		REP(b, 0  ,10-a)cmin(D0,d0+a+(b<<1)   );
		REP(b,10-a,10  )cmin(D1,d0+a+(b<<1)-10);
		REP(b, 0  ,9 -a)cmin(D0,d1+a+(b<<1)+1 );
		REP(b,9 -a,10  )cmin(D1,d1+a+(b<<1)-9 );
		d0=D0;
		d1=D1;
	}
	printf("%d",min(d0,d1+1));
    return 0;
}

Measured memory_bytes: 1280
n, k = map(int, input().split())
ans = 0

def Base_10_to_n(X, n):
    if (int(X / n)):
        return Base_10_to_n(int(X / n), n) + str(X % n)
    return str(X % n)

print(len(str(Base_10_to_n(n, k))))

Measured memory_bytes: 3060
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N-1):
    if A[i] > A[i+1]:
        ans = ans + A[i] - A[i+1]
        A[i+1] = A[i+1] + (A[i] - A[i+1])
print(ans)

Measured memory_bytes: 32068