akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll a,b,h,m;

int main(){
  
  cin >> a >> b >>h>>m;


  double ax,ay,bx,by;
  ax=cos((1.0*h/12+1.0*m/60/12)*3.141592653589793238*2.0)*(double)a;
  ay=sin((1.0*h/12+1.0*m/60/12)*3.141592653589793238*2.0)*(double)a;

  bx=cos(1.0*m/60*3.141592653589793238*2.0)*(double)b;
  by=sin(1.0*m/60*3.141592653589793238*2.0)*(double)b;

  ax-=bx;
  ay-=by;
  double ans=sqrt(ax*ax+ay*ay);

 //小数点表記
cout << setprecision(16) << ans<<endl; 
  return 0;
}

Measured memory_bytes: 4160
N,C,K = map(int,input().split())
Ts = sorted([int(input()) for _ in range(N)])

#print(Ts)

ans = 0
firstFlag = True
passenger = []	#limit lastNum
for i in range(N):
	if firstFlag:
		passenger = [Ts[i] + K,C-1]
		firstFlag = False
		ans += 1
		#print("first",str(passenger),Ts[i],ans)
	
	if i+1 < N and passenger[0] < Ts[i+1]:
		#print("time over",str(passenger),Ts[i],ans)
		firstFlag = True
	elif passenger[1] <= 0:
		#print("full",str(passenger),Ts[i],ans)
		firstFlag = True
	else:
		#print("other",str(passenger),Ts[i],ans)
		passenger[1] -= 1

print(ans)

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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

#define REPISE (s,e) for(int i=s,i<e;i++)
#define REPJSE (s,e) for(int j=s,j<e;j++)

using namespace std;

int main ()
{
  int W,a,b;

  cin >> W >> a >> b;

  if (b > W + a)
    cout << b - W - a << endl;
  else if ( b + W < a)
    cout << a - b - W << endl;
  else
    cout << 0 << endl;

  return 0;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main(){
  int x,y;
  cin>>x>>y;
  if(2*x<=y&&y<=4*x&&(y-2*x)%2==0){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
}


Measured memory_bytes: 3628
import java.util.*;
class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                int[] winp = new int[n];
                for(int i=0;i<n;i++)winp[i]=0;
                for(int i=0;i<(n*(n-1)/2);i++){
                        int t1 = sc.nextInt();
                        int t2 = sc.nextInt();
                        int p1 = sc.nextInt();
                        int p2 = sc.nextInt();
                        if(p1 > p2){
                                winp[t1-1] += 3;
                        }else if(p1 < p2){
                                winp[t2-1] += 3;
                        }else{
                                winp[t1-1] ++;
                                winp[t2-1] ++;
                        }
                }
                int[] rnk = new int[winp.length];
                for(int i=0;i<rnk.length;i++){
                        int cnt = 1;
                        for(int j=0;j<rnk.length;j++){
                                if(winp[i]<winp[j]){
                                        cnt++;
                                }
                        }
                        rnk[i] = cnt++;
                }
                for(int i=0;i<n;i++){
                        System.out.println(rnk[i]);
                }
        }
}

Measured memory_bytes: 41968
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

//#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}



int main() {
	int a,b,n, m,t=0,ans=0;
	cin >> n >> m;
	vector<vector<int>>vec(m);
	vector<int>vec2(m);
	rep(i, m) {
		cin >> a;
		rep(j, a) {
			cin >> b;
			vec[i].push_back(b-1);
		}
	}
	vecin(vec2);
	for (int i = 0; i < (1 << n); i++) {
		bitset<10>s(i);
		rep(j, m) {
			t = 0;
			rep(k, vec[j].size()) {
				t += s[vec[j][k]];
			}
			if (t % 2 != vec2[j]) {
				goto SKIP;
			}
		}
		ans++;
	SKIP:
		t = 0;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int mon[10] = {0};
	int i, j,a;
	for (i = 0; i < 10;i++)
	{
		scanf("%d",&mon[i]);
		//getchar();
	}
	for (i = 0; i<9; i++)
	{
		for (j = i+1; j<10; j++)
		{
			if (mon[i] < mon[j])
			{
				a = mon[i];
				mon[i] = mon[j];
				mon[j] = a;
			}
		}
	}
	for (i = 0; i < 3; i++)
	{
		printf("%d\n", mon[i]);
	}
	return 0;
}


Measured memory_bytes: 600
s = input()
lens = len(s)

if s[0] == ">":
	gcnt, lcnt = 0, 1
else:
	gcnt, lcnt = 1, 0
ans = 0

for i in range(lens-1):
	if s[i] == ">":
		if s[i+1] == "<":
			ans += (gcnt*(gcnt-1))//2
			ans += (lcnt*(lcnt-1))//2
			ans += max(gcnt, lcnt)
			gcnt = 1
			lcnt = 0
		else:
			lcnt += 1
	else:
		if s[i+1] == "<":
			gcnt += 1
		else:
			lcnt += 1

ans += (gcnt*(gcnt-1))//2
ans += (lcnt*(lcnt-1))//2
ans += max(gcnt, lcnt)
print(ans)

Measured memory_bytes: 9852
n = int(input())
tree = [list() for _ in range(n)]
ans = [1] * n
for _ in range(n-1):
    u, v, w = map(int, input().split())
    tree[u-1].append((v-1, w))
    tree[v-1].append((u-1, w))

stack = [0]
judge = [False] * n
while stack:
    node = stack.pop()
    judge[node] = True
    for snode, distance in tree[node]:
        if judge[snode]:
            continue
        if distance % 2 != 0:
            ans[snode] = ans[node] ^ 1
        else:
            ans[snode] = ans[node]
        stack.append(snode)
print(*ans, sep='\n')


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

using namespace std;

typedef long long ll;

const int N = 101;

vector<int> g[N];
vector<int> mt, used;

bool dfs(int v) {
    if (used[v]) {
        return false;
    }
    used[v] = 1;
    for (int u : g[v]) {
        if (mt[u] == -1 || dfs(mt[u])) {
            mt[u] = v;
            return true;
        }
    }
    return false;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n), d(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> c[i] >> d[i];
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0 ; j < n; ++j) {
            if (a[j] < c[i] && b[j] < d[i]) {
                g[i].push_back(j);
            }
        }
    }
    mt.assign(n, -1);
    for (int i = 0; i < n; ++i) {
        used.assign(n, 0);
        dfs(i);
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (mt[i] != -1) {
            ++ans;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 384
from itertools import combinations
from collections import defaultdict
N,X,Y= map(int,input().split())

ans = defaultdict(int)
for i, j in combinations(range(1,N+1),2):
    d = min(abs(i-j),abs(i-X)+1+abs(j-Y), abs(i-Y)+1+abs(j-X))
    ans[d] += 1

for i in range(1,N):
    print(ans[i])





Measured memory_bytes: 50652
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# 初項s, 交差dのn個の数列の和
def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N, H, W = map(int, input().split())

    ans = 0
    for _ in range(N):
        A, B = map(int, input().split())
        if H <= A and W <= B:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define INF (1LL<<59)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed); cerr.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed); cerr.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>arr[i];
	MOSL oxdf;
	for(int i=1;i<=n;i++)
	oxdf.ins(i - arr[i]);
	ll tc = 0;
	for(int i=1;i<=n;i++)
	{
		auto it = oxdf.find(i - arr[i]);
		oxdf.erase(it);
		ll vx = i + arr[i];
		tc += (oxdf.order_of_key(vx+1) - oxdf.order_of_key(vx));
	}	
	cout<<tc<<"\n";
	return;
}

int main(void)
{
	FLASH();
	//freopen("cowjog.in", "r", stdin);
	//freopen("cowjog.out", "w", stdout);
	int T;
	T = 1;

#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif

	//cin>>T;
	while(T--)
	solve(T);

#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cerr<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif

	return 0;
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
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);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

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

int main() {
  int N;
  cin >> N;
  vector< int > A(N);
  cin >> A;
  vector< int > cnt(1010101);
  for(auto &p : A) cnt[p]++;
  int ret = 0;
  for(int i = 0; i < A.size(); i++) {
    auto d = divisor(A[i]);
    int all = N - 1;
    cnt[A[i]]--;
    for(auto &p : d) {
      all -= cnt[p];
    }
    if(all == N - 1) ++ret;
    cnt[A[i]]++;
  }
  cout << ret << endl;
}


Measured memory_bytes: 7932
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

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

    ll n,k;cin>>k>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll sum=k;
    ll mi=0;
    rep(i,n-1){
        chmax(mi,a[i+1]-a[i]);
    }
    chmax(mi,a[0]+k-a[n-1]);
    cout<<sum-mi<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#define N 20
#define Q 200

int solve(int, int, int[N], int, int);

int main(){
  int ans, i, j, n, q, a[N], m[Q];

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

  scanf("%d", &q);
  for(j = 0; j < q; j++){
    scanf("%d", &m[j]);
  }

  for(i = 0; i < q; i++){
    ans = solve(0, m[i], a, n, 0);
    if(ans == 1) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}

int solve(int i, int m, int a[N], int n, int res){
  if(m == 0 || res == 1) return 1;
  if(i >= n) return 0;
  
  res = solve(i + 1, m, a, n, res);
  res = solve(i + 1, m - a[i], a, n, res);
  return res;
}

Measured memory_bytes: 580
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int n, k; cin >> n >> k;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int h; cin >> h;
		ans += h >= k;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct ii {
    ll a, b;
    bool operator < (ii o) const {
        return tie(a, b) < tie(o.a, o.b);
    }
};
struct iii {
    ll a, b, c;
    bool operator < (iii o) const {
        return tie(a, b, c) < tie(o.a, o.b, o.c);
    }
};

const ll MOD = 1000000007;
const ll INF = 1000000000;
const ll MAXN = 1000005;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    ll N;
    cin >> N;
    ll sum = 0;
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        ll A;
        cin >> A;
        ans = (ans + sum*A) % MOD;
        sum = (sum + A)%MOD;
    }
    cout << ans << "\n";
    
}


Measured memory_bytes: 3612
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);


      String a = sc.next();
      String b = sc.next();
      char[] a1 = new char[3];
      char[] b1 = new char[3];
      int j = 2;

      for(int i = 0;i<3;i++){
        a1[i] = a.charAt(i);
        b1[i] = b.charAt(j);
        j--;
      }

      for(int i = 0;i<3;i++){
        if(a1[i]!=b1[i]){
          System.out.println("NO");
          System.exit(0);
        }
      }

        System.out.println("YES");

  }
}


Measured memory_bytes: 23764
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  char s; cin >> s;
  if(s >= 'A'&&s <= 'Z') fin('A');
  fin('a');
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>

using namespace std;

int dp[32][32];

int main(){
    memset(dp, 0, sizeof(dp));
    string str, left, right;
    
    cin >> str;
    bool flg = false;
    for(int i=0;i<str.size();i++){
        if(str[i] == 'i' || str[i] == 'w'){
            flg = true;
        }else if(flg){
            right += str[i];
        }else{
            left += str[i];
        }
    }
    int n=left.size(), m=right.size();
    for(int i=0;i<m;i++){
        if(right[i] == '('){
            right[i] = ')';
        }else if(right[i] == ')'){
            right[i] = '(';
        }else if(right[i] == '['){
            right[i] = ']';
        }else if(right[i] == ']'){
            right[i] = '[';
        }else if(right[i] == '{'){
            right[i] = '}';
        }else if(right[i] == '}'){
            right[i] = '{';
        }
    }
    reverse(left.begin(), left.end());
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(left[i] == right[j]){
                dp[i+1][j+1] = dp[i][j]+1;
            }else{
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
            }
        }
    }
    cout << dp[n][m]*2 + 3 << endl;
}

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

int main(void){
	int r, c;
	int table[200][200];

	cin >> r >> c;

	int sum = 0;

	for(int i=0; i<r; i++){
		int sumr = 0;
		for(int j=0; j<c; j++){
			cin >> table[i][j];
			sumr += table[i][j];
		}
		table[i][c] = sumr;
	}

	for(int i=0; i<c; i++){
		int sumc = 0;
		for(int j=0; j<r; j++){
			sumc += table[j][i];
		}
		table[r][i] = sumc;
		sum += sumc;
	}
	table[r][c] = sum;

	for(int i=0; i<=r; i++){
		for(int j=0; j<=c; j++){
			if(j<c)printf("%d ", table[i][j]);
			else printf("%d\n", table[i][j]);
		}
	}

	return 0;
}

Measured memory_bytes: 1228
import numpy as np
n, m, c = map(int, input().split())
b = np.array(list(map(int, input().split())))

accepted = 0
for i in range(n):
    a = np.array(list(map(int, input().split())))
    if sum(a*b) + c > 0:
        accepted += 1
print(accepted)


Measured memory_bytes: 12424
import sys
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

import math

N, M = rl()
A = rl()

r = max(N - sum(A), -1)
print(r)



Measured memory_bytes: 68072
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const ll MOD = 1000000007;
// const int INF = 2000000000;

int H, W, N;
int sr, sc;
string S, T;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> H >> W >> N;
  cin >> sr >> sc;
  sr--;
  sc--;
  cin >> S >> T;

  int l = 0;
  int r = W - 1;
  int u = 0;
  int d = H - 1;

  for (int i = N - 1; i >= 0; i--) {
    if (r < l || d < u) {
      break;
    }

    // T
    if (T[i] == 'L' && r + 1 <= W - 1) {
      r++;
    }
    if (T[i] == 'R' && l - 1 >= 0) {
      l--;
    }
    if (T[i] == 'U' && d + 1 <= H - 1) {
      d++;
    }
    if (T[i] == 'D' && u - 1 >= 0) {
      u--;
    }

    // S
    if (S[i] == 'L') {
      l++;
    }
    if (S[i] == 'R') {
      r--;
    }
    if (S[i] == 'U') {
      u++;
    }
    if (S[i] == 'D') {
      d--;
    }
  }

  if (l <= sc && sc <= r && u <= sr && sr <= d) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 920
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e19;
const ll MOD = 1e9 + 7;

int main(){
    ll N;
    cin>>N;
    vll A;
    ll i, j;
    for(i=0;i<N;i++){
        ll a;
        cin>>a;
        A.push_back(a);
    }
    sort(A.begin(), A.end());
    ll ans1 = 0;
    ll ans2 = 0;
    ll min1 = INF;
    ll min2 = INF;
    ll fin1, fin2;
    for(i=0;i<N - 1;i++){
        if(i%2==0){
            fin1 = A[N-1-i/2];
            ans1 += A[N-1-i/2] - A[i/2];
            min1 = min(min1, A[N-1-i/2] - A[i/2]);
        }
        else{
            fin1 = A[i/2 + 1];
            ans1 += A[N-1-i/2] - A[i/2 + 1];
            min1 = min(min1, A[N-1-i/2] - A[i/2 + 1]);
        }
    }
    ans1 += fin1 - A[0];
    min1 = min(min1, fin1 - A[0]);
    ans1 -= min1;

    for(i=0;i<N - 1;i++){
        if(i%2==0){
            fin2 = A[i/2];
            ans2 += A[N-1-i/2] - A[i/2];
            min2 = min(min2, A[N-1-i/2] - A[i/2]);
        }
        else{
            fin2 = A[N-2-i/2];
            ans2 += A[N-2-i/2] - A[i/2];
            min2 = min(min2, A[N-2-i/2] - A[i/2]);
        }
    }
    ans2 += A[N-1] - fin2;
    min2 = min(min2, A[N-1] - fin2);
    ans2 -= min2;

    cout<<max(ans1, ans2)<<endl;
    return 0;
}


Measured memory_bytes: 1400
import java.util.*;

class UnionFindTree {

    int[] parent; //インデックスにとノードを対応させ、そのルートノードのインデックスを格納
    int[] rank; //parentと同様に、木の高さを格納
    int[] siz;

    public UnionFindTree(int size) {
        this.parent = new int[size];
        this.rank = new int[size];
        this.siz = new int[size];

        for (int i = 0; i < size; i++) {
            makeSet(i);
        }
    }

    public void makeSet(int i) {
        parent[i] = i;
        rank[i] = 0; //集合の高さ
        siz[i] = 1;
    }

    public void union(int x, int y) {
        int xRoot = find(x);
        int yRoot = find(y);

        //xが属する木の方が大きい場合


        if (rank[xRoot] > rank[yRoot]) {
            parent[yRoot] = xRoot; //yの親をxに更新
            siz[xRoot] += siz[yRoot];

        } else if(rank[xRoot] < rank[yRoot]) {
            parent[xRoot] = yRoot;
            siz[yRoot] += siz[xRoot];
        } else if (xRoot != yRoot){
            parent[yRoot] = xRoot;
            rank[xRoot]++; //同じ高さの木がルートの子として着くから大きさ++;
            siz[xRoot] += siz[yRoot];
        }


    }

    //引数の属する木のルートのidを返す
    public int find(int i) {
        if (i != parent[i]) {
            parent[i] = find(parent[i]);
        }
        return parent[i];
    }

    //同じ木に属しているか
    public boolean same(int x, int y) {
        return find(x) == find(y);
    }
    public int getSize(int i) {
        return siz[find(i)];
    }
}

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int K = sc.nextInt();
        int[] ans = new int[N];
        int[] friendNum = new int[N];
        int[] blockNum = new int[N];
        UnionFindTree uft = new UnionFindTree(N);

        for(int i=0;i<M;i++){
            int a = sc.nextInt()-1;
            int b = sc.nextInt()-1;
            uft.union(a,b);
            friendNum[a]++;
            friendNum[b]++;

        }

        for(int i=0;i<K;i++){
            int a = sc.nextInt()-1;
            int b = sc.nextInt()-1;
            if(uft.same(a,b)){
                blockNum[a]++;
                blockNum[b]++;
            }

        }


        for(int i=0;i<N;i++){
//            System.out.print("size:"+uft.getSize(i));
//            System.out.print("friend"+friendNum[i]);
//            System.out.print("block"+blockNum[i]);
//            System.out.print("root"+uft.find(i));
            System.out.print(uft.getSize(i) - friendNum[i] - blockNum[i]-1 +" ");
        }

    }

}









Measured memory_bytes: 117996
#include <bits/stdc++.h>
using namespace std;
typedef int64_t Int;
#define dump(x) cout << (x) << '\n'
Int mod = 1e9+7;
//Int mod = 998244353; 


int main() {
    Int n, k;
    string s;
    cin >> n >> s >> k;
    char a = s[k - 1];
    for (Int i = 0; i < n; i++) {
        if (a == s[i]) {
            cout << s[i];
        }
        else {
            cout << '*';
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring> 
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
 
using namespace std;

#define mod 1000000007

int main()
{
    int n, k;
    int pnum[26] = {};
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        string p;
        cin >> p;
        pnum[p[0] - 'A']++;
    }
    int ans = 0;
    while(1){
        int probnum = 0;
        sort(pnum, pnum + 26);
        for(int i = 25; i >= 0; i--){
            if(pnum[i] > 0){
                probnum++;
                pnum[i]--;
            }
            if(probnum == k) break;
        }
        // cout << probnum << endl;
        if(probnum == k) ans++;
        else break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

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

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

string s;

void solve() {
    int n = s.length();
    string rev;
    int i_s = inf, i_e = -1;
    rep(i, n) {
        if (s[i] != 'x') {
            i_s = min(i_s, i), i_e = max(i_e, i);
            rev += s[i];
        }
    }
    if (i_s == inf) i_s = -1;
    rep(i, rev.length() / 2) {
        if (rev[i] != rev[rev.length() - 1 - i]) {
            cout << "-1" << endl;
            return;
        }
    }
    if (i_s == -1) {
        cout << 0 << endl;
        return;
    }
    int ans = 0;
    for (int i = 0; i < i_s; ++i) if (s[i] == 'x') ans++;
    for (int i = i_e; i < n; ++i) if (s[i] == 'x') ans--;
    ans = abs(ans);


    while (i_s < i_e) {
        if (s[i_s] == s[i_e]) i_s++, i_e--;
        else if (s[i_s] == 'x') {
            i_s++;
            ans++;
        } else if (s[i_e] == 'x') {
            i_e--;
            ans++;
        }
    }
    cout << ans << endl;
}

int main() {
    cin >> s;
    solve();
    return 0;
}

Measured memory_bytes: 640
# coding: utf-8
A, B = map(int, input().split())
S = input()
ans = 'Yes'
for i in range(A + B + 1):
    if i != A:
        if S[i] == '-':
            ans = 'No'
            break
    else:
        if S[i] != '-':
            ans = 'No'
            break
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<bool> a(n);
  vector<int> v(n);
  for (int i=0; i<m;i++){
   string s;
   int t;
    cin >> t >> s;
    if (s=="AC") a[t-1]=true;
    if (s=="WA" && a[t-1]==false) v[t-1]++;
  }
  int ac=0;
  int pena=0;
  for (int j=0;j < n;j++){
    if (a[j]){
      ac++;
      pena+=v[j];
    }
  }
  cout << ac << " " << pena << endl;
    return 0;
}


Measured memory_bytes: 640
fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map { it.toInt() }
    val S = readLine()!!
    println(String(S.mapIndexed { i, c -> if (i == K - 1) map[c]!! else c }.toCharArray()))
}

val map = mapOf('A' to 'a', 'B' to 'b', 'C' to 'c')

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

int main() {
  
  string s, t;
  cin >> s >> t;
  int total = 0;
  
  int size = s.size();
  
  for (int i = 0; i < size; i++){
    if(s.at(i) != t.at(i)){
      total = total + 1;
    }
  }
  
  cout << total << endl;
}



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

int main(){
  
  int n;
  cin>>n;
  int a[n],b[n];
  for(int i=0;i<n;i++) cin>>a[i]>>b[i];
  pair<int,int> P[n];
  for(int i=0;i<n;i++){
    P[i].first=b[i];
    P[i].second=a[i];
  }
  sort(P,P+n);
  int sum=0;
  bool ans=1;
  for(int i=0;i<n;i++){
  	sum+=P[i].second;
    if(sum>P[i].first){
      ans=0;
      break;
    }
  }
  
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;


int main() {

    lli L, R;
    cin >> L >> R;

    if (R - L >= 2019) {
        cout << 0 << endl;
        return 0;
    }

    if (L == 0) {
        cout << 0 << endl;
        return 0;
    }

    vector<lli> nums;
    for (lli i = L; i <= R ; ++i) {
        for (lli j = i + 1; j <= R ; ++j) {
            nums.push_back(i * j % 2019);
        }
    }

    lli min = *min_element(nums.begin(), nums.end());

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 17128
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    string s; cin >> s;
    string t = s;
    reverse(begin(t), end(t));
    int cnt = 0;
    for (int i = 0; i < (int)s.size(); i++) if (s[i] != t[i]) cnt++;
    cout << cnt / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define R cin>>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int N; R N;
    int a[N];
    rep(i, N) R a[i];
    int max = 0, cnt = 0;
    rep(i, N) {
        if (max <= a[i]) {
            max = a[i];
            cnt++;
        }
    }
    cout << cnt << '\n';
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	static class Pair implements Comparable<Pair> {
		long a, b;

		Pair(long a, long b) {
			this.a = a;
			this.b = b;
		}

		public int compareTo(Pair p) {
			if (a > p.a)
				return 1;
			else if (a < p.a)
				return -1;
			else
				return 0;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		long[] a = new long[n];
		Pair[] pair = new Pair[n];

		for (int i = 0; i < n; i++) {
			a[i] = Long.parseLong(sc.next());
			pair[i] = new Pair(a[i], i);
		}

		Arrays.sort(pair, Collections.reverseOrder());

		long[][] dp = new long[n + 1][n + 1];

		dp[0][0] = 0;

		for (int i = 0; i < n + 1; i++) {
			for (int j = 0; j <= n - i; j++) {
				if (i == 0 && j == 0)
					continue;

				Pair p = pair[i + j - 1];
				long left = 0;
				long right = 0;

				if (i > 0) {
					left = dp[i - 1][j] + p.a * (Math.abs(p.b - i + 1));
				}
				if (j > 0) {
					right = dp[i][j - 1] + p.a * (Math.abs(n - j - p.b));
				}
				dp[i][j] = Math.max(left, right);
			}
		}
		long max = 0;
		for (int i = 0; i <= n; i++) {
			max = Math.max(max, dp[i][n - i]);
		}
		System.out.println(max);

	}

}


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

bool check_perfect_square(int ans){

	int i=1 ,r=1 ;
	while(r<ans){
		i++ ;
		r=i*i ;
	}

	if(r==ans)
		return true ;
	else
		return false ;


}

void solve(){
	
	int a,b ;
	cin>>a>>b ;

	int temp=b ;

	int count=0 ;
	while(temp){
		temp=temp/10 ;
		count++ ;
	}

	int ans=a*pow(10,count)+b ;

	bool x=check_perfect_square(ans) ;

	if(x==true)
		cout<<"Yes" ;
	else
		cout<<"No" ;

}	

int main(){


	
	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

Measured memory_bytes: 3828
#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>

using namespace std;

/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;*/ //int order_of_key, it find_by_order

typedef long long ll;
typedef unsigned int ui;
typedef long double ld;
typedef pair<int, int> pii;

#define pb push_back
#define ft first
#define sd second
#define mpr make_pair
#define max3(a, b, c) max((a), max((b), (c)))
#define max4(a, b, c, d) max(max((a), (b)), max((c), (d)))
#define all(x) begin((x)), end((x))
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define isz(x) (int)(x).size()

/* <----------------------------------------------------------> */

const int MAX = 1e5 + 7;
vector<pii> g[MAX];
char us[MAX];
int x[MAX], mn = (int)1e9, mx = -(int)1e9;

bool dfs(int v)
{
    us[v] = true;
    mn = min(mn, x[v]);
    mx = max(mx, x[v]);
    for (pii e : g[v])
    {
        if (us[e.ft] && x[e.ft] != x[v] + e.sd) return true;
        else if (!us[e.ft])
        {
            x[e.ft] = x[v] + e.sd;
            if (dfs(e.ft)) return true;
        }
    }
    return false;
}

void solve()
{
    int n, m;
    scanf("%d%d", &n, &m);
    forn (i, m)
    {
        int l, r, d;
        scanf("%d%d%d", &l, &r, &d);
        --l; --r;
        g[l].pb({r, d});
        g[r].pb({l, -d});
    }
    forn (i, n) if (!us[i])
    {
        x[i] = 0;
        if (dfs(i))
        {
            puts("No");
            return;
        }
    }
    if (mx - mn <= (int)1e9) puts("Yes");
    else puts("No");
}

/* <----------------------------------------------------------> */

// #define LOCAL
// #define FILE_NAME ""

int main()
{
    #if defined LOCAL
        freopen("input.txt", "r", stdin);
    #elif defined FILE_NAME
        freopen(FILE_NAME".in", "r", stdin);
        freopen(FILE_NAME".out", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    solve();

    return 0;
}


Measured memory_bytes: 11136
#include "bits/stdc++.h"

// Begin {{{
using namespace std;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, b, e) for (i64 i = (b); i <= (e); ++i)
#define repr(i, b, e) for (i64 i = (b); i >= (e); --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<>>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
inline i64 sigma(i64 n) { return n * (1 + n) >> 1; }
inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; }
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
#ifndef DEBUG
#define dump(...)
#endif

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

inline void outs() { cout << "\n"; }
template <class Head, class... Tail>
inline void outs(Head&& head, Tail&&... tail) {
  cout << head << (sizeof...(tail) ? " " : "");
  outs(forward<Tail>(tail)...);
}

template <class T>
inline void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e == &vec.back()]; }

template <class T>
inline void outs(vector<vector<T>> &df) { for (auto &vec : df) outs(vec); }

inline void outl() { cout << "\n"; }
template <class Head, class... Tail>
inline void outl(Head&& head, Tail&&... tail) {
  cout << head << (sizeof...(tail) ? "\n" : "");
  outl(forward<Tail>(tail)...);
}

template <class T>
inline void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

inline void outn() {}
template <class Head, class... Tail>
inline void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
inline void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
  return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
  return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  var(int, a, b);

  int i = 0;
  while (true) {
    if (sigma(i) - a == sigma(i + 1) - b) {
      outl(sigma(i) - a);
      return 0;
    }
    ++i;
  }

  return 0;
}



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

typedef long long ll;

int main () {

    ll x,y;
    cin >> x >> y;

    ll ans;


    
    if( (x >= 0 and y >= 0) ) {
	if( x <= y )       // 0 <= x <= y
	    ans = y-x;
	else               // 0 <= y < x
	    ans = min(2 + abs(x-y), 1 + abs(y-(-x)));
    }else if( x >= 0 and y < 0 ) {
	if( -x <= y )      // -x <=  y < 0 <= x
	    ans = 1 + abs(y-(-x));
	else               //  y < -x < 0 <= x
	    ans = 1 + abs((-x)-y);
    }else if( x < 0 and y >= 0 ) {
	if( -x <= y )      // x <= 0 <= -x <= y
	    ans = 1 + abs(y-(-x));
	else               // x <= 0 <= y <= -x
	    ans = min(1 + abs(y-(-x)), y-x);
    }else if( x < 0 and y < 0 ){
	if( x <= y )       // x <= y <= 0
	    ans = abs(y-x);
	else               // y <= x < 0 < -x <= -y
	    ans = 2 + abs(x-y);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
// #include <algorithm>
// #include <queue>
// #include <cmath>
// #include <string>
// #include <numeric>
// #include <set>
// #include <map>
// #include <iomanip>

// #define MOD 1000000007
// #define INF 1000000001

using namespace std;
// typedef unsigned long long ull;
// typedef long long ll;

void p_() {
    cout << "\n";
}
template<class Head, class... Body>
void p_(Head head, Body... body) {
    cout << head << ",";
    p_(body...);
}


int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    vector<int> count(N, 0);
    for (int i = 0; i < N-1; ++i) {
        int A;
        cin >> A;
        count[A-1] += 1;
    }
    for (int i = 0; i < N; ++i) {
        cout << count[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 4052
loop do
  n = gets.to_i
  break if n.zero?

  totals = Hash.new(0)

  n.times do
    e, p, q = gets.split.map(&:to_i)

    totals[e] += p * q
  end

  employees = totals.select { |_, total| total >= 1_000_000 }.keys

  if employees.empty?
    puts 'NA'
  else
    puts employees.join("\n")
  end
end

Measured memory_bytes: 8752
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int, int>;
     
const int MOD = 1e9 + 7;

int main(){
   ll n, m;
   cin >> n >> m;
   if(n == 1 && m == 1){
      cout << 1 << endl;
   }
   else if(n == 1 || m == 1){
      ll r = max(n, m);
      r -= 2;
      if(r < 0)r = 0;
      cout << r << endl;
   }
   else {
      ll r = (n - 2) * (m - 2);
      if(r < 0)r = 0;
      cout << r << endl;
   }
}


Measured memory_bytes: 3460
import java.util.Scanner

import scala.annotation.tailrec

object Main extends App {

  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val hs = Vector.fill(n)(sc.nextInt)

  // 左から(昇順)見ると、-1する要素の左右を見ないといけないため、
  // exe: Seq(2, 2, 2, 1 )
  // 右から(降順)見る。 => Vector


  @tailrec
  def loop(vec: Vector[Int], right: Int): Boolean = {
    if(vec.isEmpty) true
    else {
      val left = vec.last
      right - left match {
        case  d if d <= -2 => false
        case -1            => loop(vec.init, left - 1)
        case _             => loop(vec.init, left)
      }
    }
  }

  val res = if(loop(hs.init, hs.last)) "Yes" else "No"

  println(res)

}


Measured memory_bytes: 69416
#include "bits/stdc++.h"

using namespace std;

const int INF = numeric_limits<int>::max() / 2;

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

    double d,e;
    while(cin>>d>>e,d||e){
        double res=INF;
        for(double x=0;x<=100;x++){
            for(double y=0;y<=100;y++){
                if(x+y!=d) continue;
                res=min(res,abs(sqrt(x*x+y*y)-e));
            }
        }
        cout<<fixed<<setprecision(10)<<res<<endl;
    }
}

Measured memory_bytes: 3224
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iomanip>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    double r;
    cin >> r;
    cout << fixed << setprecision(2) <<2*M_PI*r;
}









Measured memory_bytes: 3792
n,m = map(int, input().split())

ab = [list(map(int, input().split())) for _ in range(m)]


def dfs(source):
    dist = [-1]*(n+1)
    dist[source] = 0
    q = [source]
    while q:
        a = q.pop()
        for b in V[a]:
            if dist[b]!=-1:
                continue
            dist[b] = dist[a] + 1
            q.append(b)
    return dist

from collections import defaultdict
import collections

res = 0
for i in range(m):
    abc = ab.copy()
    del abc[i]
    V = defaultdict(list)

    for _ in range(m-1):
        a, b = abc[_][0],abc[_][1]
        V[a].append(b)
        V[b].append(a)
    d1 =dfs(1)
    c = collections.Counter(d1)
    if c[-1] >1:
        res +=1
print(res)

Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<iomanip>
#include<map>
#include<stack>
const int maxn = 1e5+10;
#define INF 1e9+10
using namespace std;
int main()
{
    int n,k;
    cin >> n >> k;
    int ans = k;
    for(int i = 2; i <= n; i ++)
    {
        ans *= (k-1);
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 256