akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n, k;
    cin >> n >> k;
    cout << n - k + 1 << endl;

    return 0;
}


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

using namespace std;
long long x, y;
long long go(long long a, long long d) {
	long long l = 1;
	long long r = 100000000000000;
	while (l <= r) {
		long long m = (l + r) / 2;
		long long ans = a + (m - 1) * d;
		if (ans >= x) {
			r = m - 1;
		}
		else {
			l = m + 1;
		}
	}
	return l;
}
long long go1(long long a, long long d) {
	long long l = 1;
	long long r = 100000000000000;
	while (l <= r) {
		long long m = (l + r) / 2;
		long long ans = a + (m - 1)*d;
		if (ans > y) {
			r = m - 1;
		}
		else {
			l = m + 1;
		}
	}
	return r;
}
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin >> x >> y;
	if (x == y) {
		cout << x << '\n'; return 0;
	}
	long long sum = 0;
	for (long long i = 1; i <= y; i = (i << 1)) {
		// 시작부분 과 끝부분을 먼저 안다.
		long long ans = 0;
		long long s = go(i, i * 2);
		long long cnt = i + (s - 2) * (i * 2);
		if (cnt + (i - 1) >= x) {
			ans += cnt + i - x;
		}
		long long e = go1(i, i * 2);
		cnt = i + (e - 1)*(i * 2);
		if (cnt + (i - 1) > y) {
			ans += y - cnt + 1;
		}
		else {
			ans += i;
		}
		e -= 1;
		if (e >= s)
			ans += ((e - s) + 1) *i;
		if (ans & 1) {
			sum += i;
		}
	}

	cout << sum << '\n';

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    double a, b, x;
    cin >> a >> b >> x;

    double ans;
    double y = x/a;
    if(x <= a*a*b/2.0) {
        ans = ( atan( (b*b)/(2.0*y) ) / acos((double)-1) ) * 180.0;
    }
    else {
        double z = a*b - y;
        ans = ( atan( (2.0*z)/(a*a) ) / acos((double)-1) ) * 180.0;
    }

    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "stdio.h"


int main()
{
	int N, a[10000], i, j,cnt=0,A;
	scanf("%d", &N);

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

		A = a[i];
		for (j = 1; j <= A; j++) {
			if (a[i] % 2 == 0) {
				a[i] = a[i] / 2;
				cnt++;
			}
			else {
				break;
			}
		}
	}
	printf("%d\n",cnt);

    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 n = sc.nextInt();
      int m = sc.nextInt();
      int sum  = 0;
      int[] arr = new int[n];
      for(int i = 0; i < n; i++) {
        arr[i] = sc.nextInt();
        sum += arr[i];
      }
      int cnt = 0;
      for(int i = 0; i < n; i++) {
        if(arr[i] >= sum * 1.0 / (4 * m))
          cnt++;
      }
      System.out.println(cnt >= m ? "Yes" : "No");
  }
}

Measured memory_bytes: 23892
#include <stdio.h>

void gen_prime(int prime[])
{
    int i, j, c = 1;

    for (i = 0; i < 1000000 / 2; ++i) {
        prime[i * 2] = 0;
        prime[i * 2 + 1] = c;
    }
    prime[0] = prime[1] = 0;
    prime[2] = c++;

    for (i = 3; i <= 1000000; i += 2) {
        if (prime[i]) {
            prime[i] = c++;
            for (j = 2 * i; j <= 1000000; j += i) {
                prime[j] = 0;
            }
        }
    }
}

int main(void)
{
    int prime[1000000];
    int i, n;

    gen_prime(prime);

    while (scanf("%d", &n) != EOF) {
        if (n == 1) {
            printf("0\n");
        } else {
            for (i = n; prime[i] == 0; --i);
            printf("%d\n", prime[i]);
        }
    }

    return 0;
}

Measured memory_bytes: 4512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int K;
  while (cin >> K) {
    vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << v[K - 1] << endl;
  }
  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#define int long long
#define endl '\n'
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U b) { if (a > b) { a = b; return true; } return false; }

constexpr ll mod = 998244353;

template<class T> class segtree {
	int n, mode;
	vector<T> data;
	T id;
public:
	segtree(int _n, int _mode) {
		n = 1;
		mode = _mode;
		while (n < _n + 2) n <<= 1;
		if (mode == 1) id = 0;
		else if (mode == 2) id = -INF;
		else if (mode == 3) id = INF;
		data = vector<T>(2 * n, id);
	}
	T operation(T a, T b) {
		if (mode == 1) return a + b;
		else if (mode == 2) return max(a, b);
		else if (mode == 3) return min(a, b);
	}
	void change(int i, T x) {
		i += n;
		data[i] = x;
		while (i > 1) {
			i >>= 1;
			data[i] = operation(data[i << 1], data[i << 1 | 1]);
		}
	}
	void add(int i, T x) { change(i, data[i + n] + x); }
	T get(int a, int b) {
		T left = id; T right = id;
		a += n; b += n;
		while (a < b) {
			if (a & 1) left = operation(left, data[a++]);
			if (b & 1) right = operation(data[--b], right);
			a >>= 1; b >>= 1;
		}
		return operation(left, right);
	}
	T get_all() { return data[1]; }
	T operator[](int i) { return data[i + n]; }
};
constexpr int RSQ = 1;
constexpr int RMQ = 2;
constexpr int RmQ = 3;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	vector<int> x(n), d(n), y(n);
	vector<P> p(n);
	rep(i, n) {
		cin >> x[i] >> d[i];
		y[i] = x[i] + d[i];
		p[i].first = x[i];
		p[i].second = y[i];
	}
	sort(all(p));
	rep(i, n) {
		x[i] = p[i].first;
		y[i] = p[i].second;
	}
	p.pb(P(INF, INF));
	vector<int> use(n);
	for (int i = 0; i < n; i++) {
		int g = lower_bound(all(x), y[i]) - x.begin();
		use[i] = g - 1;
	}
	segtree<int> seg(n, RMQ);
	rep(i, n) seg.change(i, use[i]);
	for (int i = n - 1; i >= 0; i--) {
		int maxv = seg.get(i, seg[i] + 1);
		seg.change(i, maxv);
    }
	vector<int> dp(n + 1);
	dp[n] = 1;
	for (int i = n - 1; i >= 0; i--) {
		dp[i] = dp[i + 1] + dp[seg[i] + 1];
		if (dp[i] >= mod) dp[i] -= mod;
	}
	cout << dp[0] << endl;
}

Measured memory_bytes: 16968
def solve(s):
    if s[-1] == '1':
        return False
    if s[0] == '0':
        return False
    half = s[:len(s) // 2]
    if half != s[-2:(len(s) - 3) // 2:-1]:
        return False
    head = 1
    master = 1
    buf = []
    for i, c in enumerate(half):
        if c == '0':
            buf.append('{} {}'.format(master, i + 2))
        else:
            buf.append('{} {}'.format(head, i + 2))
            head = master = i + 2
    for i in range(len(half), len(s) - 1):
        buf.append('{} {}'.format(master, i + 2))
    return buf


res = solve(input())
if res == False:
    print(-1)
else:
    print('\n'.join(res))


Measured memory_bytes: 13876
while True:
  s = raw_input()
  if s == '.': break

  ns = ''
  for c in s:
    if c in ['(', ')', '[', ']']:
      ns += c

  while True:
    tmp = ns
    ns = ns.replace('[]', '')
    ns = ns.replace('()', '')
    if (tmp == ns): break

  print 'no' if ns else 'yes'

Measured memory_bytes: 4212
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <queue>
using namespace std;
int main(){
    int n,m;
    cin >>n >> m;
    priority_queue<int> q;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        q.push(x);
    }
    //cout<<q.top()<<endl;
    for(int i=0;i<m;i++){
        int y=q.top();
        q.pop();
        y /= 2;
        q.push(y);
    }
    long long count=0;
    for(int i=0;i<n;i++){
        int y=q.top();
        q.pop();
        count += y;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
#define ll long long;

int main(){

  string S; cin >> S;

  bool flag = false;
  for (int i = 0; i < S.length() - 1; i++){
    if (S[i] == S[i + 1]){
      cout << i + 1 << " " << i + 2 << endl;
      flag = true;
      break;
    }else if(i <= S.length() - 2){
      if (S[i] == S[i + 2]){
        cout << i + 1 << " " << i + 3 << endl;
        flag = true;
        break;
      }
    }
  }

  if (flag == false){
    cout << "-1 -1" << endl;
  }
  
  

  return 0;
}


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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll N,A,B;
	cin>>N>>A>>B;
    ll x;
    x = N/(A+B);
    ll ans = 0;
    ans = x*A + min(A,N-(x*(A+B)));
    cout<<ans<<"\n";

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<b;i++)
#define ren(i,a,b) for(int i=a;i>b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)

using namespace std;
typedef long long int ll;


int main()
 {
	//code
	fastio;
	char a[3];
	rep(i,0,3)    cin>>a[i];
	if(a[1]=='B')   cout<<"ARC"<<endl;
	if(a[1]=='R')   cout<<"ABC"<<endl;
	
	
	
	
	return 0;
}

Measured memory_bytes: 3616
N = int(input())
lst = [int(input()) for i  in range(N)]

def insertion_sort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while(j >= 0 and A[j] > v):
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v

def shell_sort(A, n, m, G):    
    for i in range(m):
        insertion_sort(A, n, G[i])

cnt = 0
G = [1]
for i in range(99):
    if N < 1 + 3*G[-1]:
        break
    G.append(1 + 3*G[-1])
m = len(G)
G.reverse()

shell_sort(lst, N, m, G)

print(m)
print(" ".join(list(map(str, G))))
print(cnt)
for i in lst:
    print(i)


Measured memory_bytes: 45516
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
bool is_not_out_of_range(size_t now, size_t max_num)
{
	return !(now < 0 || max_num <= now);
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int a, b, h;
	cin >> a >> b >> h;
	cout << (a + b) * h / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int maxn = 1e5+10;
int head[maxn];
int fa[maxn];//储存父节点 
int X[maxn];//储存值 
int f[maxn];//记录另外一个颜色的权值和 
int dp[maxn];
struct node{
	int to;
	int next;
}no[maxn];
int cnt;
void add(int u,int v)//V是节点号 
{
	no[cnt]={v,head[u]};
	head[u]=cnt++;
}
void dfs(int u)
{
	for(int i=head[u];i!=-1;i=no[i].next)//先遍历所有子树 
		dfs(no[i].to); 
	memset(dp,INF,sizeof(dp));
	dp[0]=0;
	for(int i=head[u];i!=-1;i=no[i].next)
	{
		int v=no[i].to;
		for(int j=X[u];j>=0;j--)
		{
			int temp=INF;
			if(j>=X[v])//如果当前点的权重大于x[v] 
				temp=min(temp,dp[j-X[v]]+f[v]);
			if(j>=f[v])
				temp=min(temp,dp[j-f[v]]+X[v]);
			dp[j]=temp; 
		}
	}
	for(int i=0;i<=X[u];i++)
		f[u]=min(f[u],dp[i]);
} 
int main()
{
	int n;
	memset(f,INF,sizeof(f));
	memset(head,-1,sizeof(head));
	scanf("%d",&n);
	for(int i=2;i<=n;i++)
	{
		scanf("%d",&fa[i]);
		add(fa[i],i);
	}
	for(int i=1;i<=n;i++)
		scanf("%d",&X[i]);
	dfs(1);//搜索根点 
	if(f[1]<INF)
        printf("POSSIBLE\n");
    else
        printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 1408
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

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

    if (a <= c && c <= b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
    //ABC134_B

    int N,D;
    cin >> N >> D;
    int count = 1;
    for(int i=1;i<N;i++){
        if(2*i*D+i >= N){
            break;
        }
        count++;
    }
  	cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,cnt=0;
void s(ll number,int x,int y,int z){
    if(number<=n){
        if(x&&y&&z)cnt++;
        s(number*10+3,1,y,z);
        s(number*10+5,x,1,z);
        s(number*10+7,x,y,1);
    }
}
int main(){
    cin>>n;
    s(0,0,0,0);
    cout<<cnt<<endl;
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int> b(n-1);
    rep(i,n-1) cin>>b[i];
    vector<int> a(n);

    a[0]=b[0];
    a[n-1]=b[n-2];
    int sum=a[0]+a[n-1];
    for(int i=1;i<n-1;i++){
        a[i]=min(b[i-1],b[i]);
        sum+=a[i];
    }
    cout<<sum<<"\n";
    return 0;
}

Measured memory_bytes: 3596
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.HashMap;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            HashMap<Long, Integer> map = new HashMap<Long, Integer>();

            int n = in.nextInt();
            int ans = 0;
            for (int i = 0; i < n; i++) {
                long l = in.nextLong();
                if (map.containsKey(l)) {
                    map.put(l, map.get(l) + 1);
                } else {
                    map.put(l, 1);
                }
            }


            for (long key : map.keySet()) {
                int cnt = map.get(key);
                if (key < cnt) {
                    ans += cnt - key;
                } else if (cnt < key) {
                    ans += cnt;
                }
            }

            out.print(ans);

        }

    }
}



Measured memory_bytes: 63320
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#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 ALL(a) (a).begin(), (a).end()
const ll MOD = 1e9 + 7;

ll fact[3000001], fact_i[3000001];

ll power(int x, int y) {
    if (y == 0) return 1;
    if (y == 1) return x;
    ll p = power(x, y >> 1);
    if (y & 1) return p * p % MOD * x % MOD;
    else return p * p % MOD;
}

ll inv(ll n) {
    return power(n, MOD - 2);
}

void init(int n) {
    fact[0] = 1;
    REP(i, n) fact[i + 1] = fact[i] * (i + 1) % MOD;
    fact_i[n] = inv(fact[n]);
    REP(i, n) fact_i[n - i - 1] = fact_i[n - i] * (n - i) % MOD;
}

ll nCr(ll n, ll r) {
    return fact[n] * fact_i[r] % MOD * fact_i[n - r] % MOD;
}

int main() {
    init(3000000);
    int K, S, N;
    cin >> K;
    string str;
    cin >> str;
    S = str.size();
    N = K + S;
    S--;
    ll ans = 0;
    FOR(i, S, N) {
        ans += nCr(i, S) * power(25, i - S) % MOD * power(26, N - 1 - i) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 52112
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int N, D;

	cin >> N >> D;
	int a = D * 2 + 1;

	cout << (N + a - 1) / a << endl;
}



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

  string str;
  getline(cin,str);
  for(int i = 0;i < str.size();i++){
    if(str[i]<='z'&&str[i]>='a') str[i] = str[i]-'a'+'A';
  }
  cout << str << endl;
  return (0);
}

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

using namespace std;

vector <string> weather = {"Sunny", "Cloudy", "Rainy"};

int main() {
	string s;
	cin >> s;
	
	int id = 0;
	
	for (int i = 0; i < 3; i++) {
		if (s == weather[i]) id = i;
	}
	
	cout << weather[(id + 1) % 3] << endl;
}


Measured memory_bytes: 256
#include<iomanip>
#include<queue>
#include<iostream>
#include<cmath>
#include<cstdio>
#define pi acos(-1)
using namespace std;

/*int arr[10000];
vector<int>adj[10000];
vector<int>v1;
bool visited[10000];
void bfs(int s)
{
    int cnt=0;
    queue<int>q;
    q.push(s);
    v1.push_back(s);
    visited[s]=1;
    cnt++;
    while(!q.empty()){
        int u=q.front();
        q.pop();
        for(int i=0;i<adj[u].size();i++){
            if(visited[adj[u][i]]==0){
                int v=adj[u][i];
                visited[v]=1;
                v1.push_back(v);
                q.push(v);
                cnt++;
            }
        }
    }
    int u=v1.size();
    for(int i=0;i<u;i++){
        arr[v1[i]-1]=cnt;
    }
    v1.clear();
}
void solve(int n)
{
    for(int i=0;i<n;i++)cout<<arr[i]<<" ";
}
int main()
{
    int m,n;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int k,j=0;
        cin>>k;
        int ara[k];
        while(j<k){
            cin>>ara[j];
            if(j){
                adj[ara[j-1]].push_back(ara[j]);
                adj[ara[j]].push_back(ara[j-1]);
            }
            j++;
        }
    }
    for(int i=0;i<n;i++){
        if(visited[i+1]==0){
          bfs(i+1);
        }
    }
    solve(n);
    //cout<<v2.size();
}
*/
int main()
{
    long long int a,b,t,k;
    cin>>t>>a;
    long long int sum=0;
    for(int i=0;i<a;i++){
        long long int p;
        cin>>p;
        sum+=p;
    }
    if(sum>t)cout<<"-1";
    else cout<<t-sum;
}




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

int main() {
  string s;
  cin >> s;
  if(s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
}
  
  

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

int main(){
  int i,j,n;
  cin>>n;
  int a;
  int ex=1;
  int ans=1;
  for(i=0;i<n;i++){
	ans*=3;
	cin>>a;
	if(a%2==0) ex*=2;
  }
  cout<<ans-ex<<endl;
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	cnt := len(s)
	cnt = calc(cnt, s, 'A')

	s = reversed(s)
	cnt = calc(cnt, s, 'Z')

	fmt.Println(cnt)
}

func reversed(s string) string {
	runes := []rune(s)
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func calc(cnt int, s string, c rune) int {
	for i := 0; rune(s[i]) != c || cnt < 0; i++ {
		cnt--
	}
	return cnt
}


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

ll mod = 1e9 + 7;
ll dp[120][4][4][4];
int main() {
    ll n;
    cin >> n;
    // 0 -> A, 1 -> T, 2 -> G, 3 -> C
    dp[0][1][1][1] = 1;
    for (int i = 0; i < (int)n; i++) {
        for (int a = 0; a < 4; a++) {
            for (int b = 0; b < 4; b++) {
                for (int c = 0; c < 4; c++) {
                    for (int d = 0; d < 4; d++) {
                        if (b == 0 && c == 2 && d == 3) continue;
                        if (b == 2 && c == 0 && d == 3) continue;
                        if (b == 0 && c == 3 && d == 2) continue;
                        if (a == 0 && c == 2 && d == 3) continue;
                        if (a == 0 && b == 2 && d == 3) continue;
                        dp[i + 1][b][c][d] += dp[i][a][b][c];
                        dp[i + 1][b][c][d] %= mod;
                    }
                }
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            for (int k = 0; k < 4; k++) {
                ans += dp[n][i][j][k];
            }
        }
    }
    cout << ans % mod << endl;
    return 0;
}

Measured memory_bytes: 256
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
int x,y;
int p[100001];
int find(int x){
	if(p[x]!=x)
		p[x]=find(p[x]);
	return p[x];
}
map<int,bool>mp; 
int main(){
	cin>>n>>m;
	for(int i=0;i<n;++i)
		p[i]=i;
	for(int i=0;i<m;++i){
		cin>>x>>y;
		p[find(x-1)]=find(y-1);
	}
	int sum=0;
	for(int i=0;i<n;++i){
		if(!mp[find(i)]){
			sum++;
			mp[find(i)]=true;
		}
	}
	cout<<sum-1<<endl;
	return 0;
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

struct union_find {
  typedef vector<int> vi;
  vi par,rank,cnt;
  int n;

  union_find(int n) : n(n) {
    par = vi(n); rank = vi(n,0); cnt = vi(n,1);
    for (int i = 0; i < n; i++) par[i] = i;
  }

  int find(int a) {
    if (par[a] == a) return a;
    return par[a] = find(par[a]);
  }

  void unite(int a, int b) {
    a = find(a); b = find(b);

    if (a == b) return;
    if (rank[a] < rank[b]) {
      par[a] = b; cnt[b] += cnt[a];
    } else {
      par[b] = a; cnt[a] += cnt[b];
      if (rank[a] == rank[b]) rank[a]++;
    }
  }

  int count(int a) { return cnt[find(a)]; }

  bool same(int a, int b) { return find(a) == find(b); }
};

const int MAX_X = 100000;
int n;

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n;
  union_find uf(2*MAX_X);
  forn(i,n) {
    int x,y; cin >> x >> y;
    x--,y--;
    uf.unite(x,MAX_X+y);
  }

  vector<int> comp_x(2*MAX_X),comp_y(2*MAX_X);
  forn(i,MAX_X)
    comp_x[uf.find(i)]++;

  for (int i = MAX_X; i < 2*MAX_X; i++)
    comp_y[uf.find(i)]++;

  ll res = 0;
  forn(i,MAX_X)
    res += 1LL * comp_x[i] * comp_y[i];

  cout << res - n << endl;

  return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end())
#define pb push_back
#define mp make_pair
#define MODP(A,B) A=(A+B)%mod
typedef pair<ll,ll> P;
typedef pair<double,double> Pd;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};


int main(){
    ll N,K; cin>>N>>K;
    ll a=N%K;
    ll b=K-a;
    cout<<min(a,b)<<endl;


}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

constexpr int N = 51;
int n, m, q;
int a[N], b[N], c[N], d[N];
int sum = 0, ans[N];

void dfs(int x, int y)
{
    if (x == n + 1)
    {
        int cnt = 0;
        rep(i, 0, q)
        {
            if (ans[b[i]] - ans[a[i]] == c[i])
            {
                cnt += d[i];
            }
        }
        chmax(sum, cnt);
        return;
    }
    else
    {
        rep(i, y, m + 1)
        {
            ans[x] = i;
            dfs(x + 1, i);
        }
    }
}

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

    cin >> n >> m >> q;
    rep(i, 0, q)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(1, 1);
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;
const int MAXN = 51;

int n;
double v[MAXN];

void solve() {
  sort(v, v + n);
  double value = (v[0] + v[1]) / 2.0;
  for (int i=2;i<n;i++) {
    value = (value + v[i]) / 2.0;
  }
  cout << setprecision(10) << value << endl;
}

int main() {
  cin >> n;
  for (int i=0;i<n;i++) {
    cin >> v[i];
  }
  solve();
}


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

int main() {
    int n;  
    cin >> n;
    vector<int> a(n);

    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }

    long sum = 0;

    for (int i = 1; i < n; i++) {
        if (a.at(i) < a.at(i - 1)) {
            sum += a.at(i - 1) - a.at(i);
            a.at(i) = a.at(i - 1);
        }
    }

    cout << sum << endl;

}


Measured memory_bytes: 4036
N, K, Q = map(int, input().split())

A = [int(input()) for _ in range(Q)]

dic = {}

for i in range(N):
    dic[i+1] = 0

for i in range(Q):
  if A[i] in dic:
    dic[A[i]] += 1
  else:
    dic[A[i]] = 1
    
    
for i in range(N):
  if K - (Q - dic[i+1]) <= 0:
    print('No')
    
  else:
    print('Yes')


Measured memory_bytes: 18980
def main():
    N, Y = list(map(int, input().split()))

    R = Y/1000 - N
    for b in range(N+1):
        tmp = (R - 4 * b)
        if (tmp < 0):
            break
        m = tmp % 9
        if (0 == m):
            c = int(tmp / 9)
            a = N - b - c
            if (a < 0):
                break
            print(c, b, a)
            return
    print(-1, -1, -1)
    return

main()


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

#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define lch (o << 1)
#define rch (o << 1 | 1)

typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pint;
typedef tuple<int, int, int> tint;

const int N = 200000 + 5;
const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;

int main() {
	ios::sync_with_stdio(0);

	int wr = 0, rw = 0;
	int n;
	cin >> n;
	string s;
	cin >> s;
	s = ' ' + s;
	for (int i = 1; i <= n; i++)
		if (s[i] == 'R') rw++;
	int ans = max(wr, rw);
	for (int i = 1; i <= n; i++) {
		if (s[i] == 'W') wr++;
		if (s[i] == 'R') rw--;
		ans = min(ans, max(rw, wr));
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3936
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑


long long n, k[200005], ans = INT_MIN, mon;
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) { cin >> k[i]; if (i == 0) { mon = k[0]; } }
	for (int i = 1; i < n; ++i) {
		ans = max(ans, k[i] - mon);
		mon = min(mon, k[i]);
	}
	cout << ans << endl;
}


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

int main()
{
    int h, w;
    cin >> h >> w;

    vector<vector<int>> c(10, vector<int>(10));
    rep(i, 10) rep(j, 10) cin >> c[i][j];

    vector<vector<int>> a(h, vector<int>(w));
    rep(i, h) rep(j, w) cin >> a[i][j];

    for (int k = 0; k < 10; k++)
        for (int i = 0; i < 10; i++)
            for (int j = 0; j < 10; j++)
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);

    int ans = 0;
    rep(i, h) rep(j, w) if (a[i][j] != -1) ans += c[a[i][j]][1];
    cout << ans << endl;
}

Measured memory_bytes: 3724
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

using System.IO;

class _Class
{
	void _(){
	}

	void _Do()
  {
    var N = _int();
		var a = _int();
		int l = 1;
		int? o=null;
		for (int i=0;i<a.Length;i++)
		{
			if (i==0)
			{

			}
			else
			{
				var o2 = Math.Sign(a[i] - a[i - 1]);
				if (
					o == 1 && o2 ==-1 || 
					o==-1&&o2==1)
				{
					o = 0;
					l++;
				}
				else if(o2!=0)
					o = o2;
			}
		}
		Console.WriteLine(l);
	}



	static void Main(string[] args)
  {
    new _Class()._Do();
  }

#region

  string _string()
  {
    return Console.ReadLine();
  }

	//
	string[] _strings()
  {
    return Console.ReadLine().Split();
  }

  int[] _int(int n)
  {
    var x = new int[n];
    for (var i = 0; i < n; i++)
    {
      x[i] = int.Parse(Console.ReadLine());
    }
    return x;
  }

	//
	int[] _int()
  {
    var ss = Console.ReadLine().Split();

    var x = new int[ss.Length];
    for (var i = 0; i < ss.Length; i++)
      x[i] = int.Parse(ss[i]);

    return x;
  }

	long[] _long()
	{
		var ss = Console.ReadLine().Split();

		var x = new long[ss.Length];
		for (var i = 0; i < ss.Length; i++)
			x[i] = long.Parse(ss[i]);

		return x;
	}
#endregion

}


Measured memory_bytes: 18528
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = str(onem())

dp = [0 for i in range(2019)]
ans = 0
dp[0] = 1
dp[int(n[-1])] = 1
ten = 1
po = int(n[-1])
for i in range(len(n)-2,-1,-1):
    ten *= 10
    ten %= 2019
    po += ten*int(n[i])
    po %= 2019
    
    ans += dp[po]

    dp[po] += 1
    



print(ans)




Measured memory_bytes: 71696
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
  int t,a,k=0;
  cin >> t >> a;
  int f[a];
  for(int i=0;i<a;i++)
  { cin>>f[i];
  }
   for(int i=0;i<a;i++)
  { k=k+f[i];
  }
  if(k>t)
    cout<<"-1"<<endl;
  else
    cout<<t-k<<endl;
  }

Measured memory_bytes: 3624
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;
 
#define REP(i,n) for(long long (i)=0;(i)<(long long)(n);(i)++)
#define RREP(i,n) for(long long (i)=(long long)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;
 
int main() {
 
    string S;
    cin >> S;
 
    cout << S.substr(0, S.size() - 8) << endl;
 
 
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] b = new int[n - 1];
        for(int i = 0; i < n - 1; i++){
            b[i] = scan.nextInt();
        }
        int out = 0;
        for(int i = 1; i < n - 1; i++){
            out += Math.min(b[i], b[i - 1]);
        }
        out += b[0];
        out += b[n - 2];
        System.out.println(out);
    }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100005

struct Node{

	char ch;
	vector<int> ADJ;
};

int V,E;
bool check[26];
char buf[2];
Node nodes[NUM];


int main(){

	scanf("%d %d",&V,&E);

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

		scanf("%s",buf);
		nodes[i].ch = buf[0];
	}

	int from,to;

	for(int loop = 0; loop < E; loop++){

		scanf("%d %d",&from,&to);
		nodes[from].ADJ.push_back(to);
		nodes[to].ADJ.push_back(from);
	}

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

		if(nodes[i].ch != '?'){

			printf("%c",nodes[i].ch);

		}else{

			for(int k = 0; k < 26; k++){

				check[k] = false;
			}

			for(int k = 0; k < nodes[i].ADJ.size(); k++){

				if(nodes[nodes[i].ADJ[k]].ch != '?'){

					check[nodes[nodes[i].ADJ[k]].ch-'a'] = true;
				}
			}

			for(int k = 0; k < 26; k++){

				if(!check[k]){
					nodes[i].ch = 'a'+k;
					printf("%c",nodes[i].ch);
					break;
				}
			}
		}
	}

	printf("\n");

	return 0;
}



Measured memory_bytes: 10732
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

const ll MAX_V = 1000;

struct Edge{
    ll rev,from,to;
    ll cap,icap;
    Edge(ll r,ll f,ll t,ll c) : rev(r), from(f), to(t), cap(c), icap(c) {}
};

struct Graph{
    ll V;
    vector<Edge> list[MAX_V];

    Graph(ll n = 0) : V(n) {rep(i,0,MAX_V) list[i].clear();}
    void init(ll n = 0) {V = n; rep(i,0,MAX_V) list[i].clear(); }
    void resize(ll n = 0) {V = n;}
    void reset() { rep(i,0,V) rep(j,0,list[i].size()) list[i][j].cap = list[i][j].icap; }
    inline vector<Edge>& operator[] (ll i) {return list[i]; }

    Edge &redge(Edge e){
        if(e.from != e.to) return list[e.to][e.rev];
        else return list[e.to][e.rev+1];
    }

    void addedge(ll from,ll to,ll cap){
        list[from].push_back(Edge((ll)list[to].size(),from,to,cap));
        list[to].push_back(Edge((ll)list[from].size()-1,to,from,0));
    }
};

static ll level[MAX_V];
static ll iter[MAX_V];

void dibfs(Graph &G,ll s){
    rep(i,0,MAX_V) level[i] = -1;
    level[s] = 0;  
    queue<ll> que;
    que.push(s);
    while(!que.empty()){
        ll v = que.front();
        que.pop();

        rep(i,0,G[v].size()){
            Edge &e = G[v][i];
            if(level[e.to] < 0 && e.cap > 0){
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
        }
    }
}

ll didfs(Graph &G,ll v,ll t,ll f){
    if(v == t) return f;
    for(ll &i = iter[v];i < G[v].size();i++){
        Edge &e = G[v][i], &re = G.redge(e);
        if(level[v] < level[e.to] && e.cap > 0){
            ll d = didfs(G,e.to,t,min(f,e.cap));
            if(d > 0){
                e.cap -= d;
                re.cap += d;
                return d;
            }
        }
    }
    return 0;
}

ll Dinic(Graph &G, ll s,ll t){
    ll res = 0;
    while(1){
        dibfs(G,s);
        if(level[t] < 0) return res;
        fill(iter,iter+MAX_V,0);
        ll flow;
        while((flow = didfs(G,s,t,LINF)) > 0){
            res += flow;
        }
    }
}

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

    P red[n],blue[n];
    rep(i,0,n) cin >> red[i].fs >> red[i].sc;
    rep(i,0,n) cin >> blue[i].fs >> blue[i].sc;

    Graph G(2*n+2);
    ll S_node = 2*n;
    ll T_node = 2*n+1;

    rep(i,0,n){
        rep(j,0,n){

            if(red[j].fs < blue[i].fs && red[j].sc < blue[i].sc){
                G.addedge(i,n+j,1);
            }
        }
    }

    rep(i,0,n){
        G.addedge(S_node,i,1);
        G.addedge(n+i,T_node,1);
    }

    cout << Dinic(G,S_node,T_node) << endl;
    return 0;
}

Measured memory_bytes: 640
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++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 all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}



int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N,D;
  cin>>N>>D;
  vector<vector<int>> data(N, vector<int>(D));
 
  // 入力 (2重ループを用いる)
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> data.at(i).at(j);
    }
  }
  int cnt=0;
  rep(i,N){
    FOR(j,i+1,N){
      int ans=0;
      rep(k,D){
        ans+=(data[i][k]-data[j][k])*(data[i][k]-data[j][k]);
      }
      int ans2=sqrt(ans);
      if(ans2*ans2==ans)
        cnt++;
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=LONG_LONG_MAX;
const ll ms=(2e5)+5;

unordered_map<int,int> mm;
int main()
{
    idfc;

    int n;
    cin>>n;
    int i;
    int e;
    int d;
    ll a=0;
    for(i=1;i<=n;i++)
    {
        cin>>e;
        d=i-e;
        a+=mm[d];
        mm[i+e]+=1;
    }
    cout<<a;

    return 0;
}

Measured memory_bytes: 18456
#include <iostream>
#include <string>
 
int main(int argc, char* argv[]) {
  std::string line;
  std::cin >> line;
  if(line[2] == line[3] && line[4] == line[5]) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] L = new long[n];
		List<Long> memo = new ArrayList<Long>();
		int count = 0; 
		for(int i = 0; i < n; i++) {
			long a = sc.nextLong();
			L[i]=a;
		}
		Arrays.sort(L);
		for(int i = 0; i < n-2; i++) {
			long r = L[i];
			for(int j = i+1; j < n-1; j++) {
				long l = L[j];
				for(int k = j+1; k < n; k++) {
					long now = L[k];
					if(r!=now&&l!=now&&r!=l&&r+l>now&&r+now>l&&l+now>r) count++;
				}
			}
		}
		System.out.println(count);
    }
}

Measured memory_bytes: 36680
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int N;
  cin >>N;
  int Y=N*N*N;
  cout << Y << endl;
}
  

Measured memory_bytes: 256
a = list(map(int,input()))

b = int(input())

k = 0

if len(a) == 1:
    print(a[0])

else:
    for i in range(len(a)):
        if a[i] == 1:
            k += 1
        else:
            k = a[i]
            break
        if k == b:
            k = 1
            break
    print(k)


Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  std::vector<std::pair<int, int>> lt, gt;
  std::string S; std::cin >> S;
  std::vector<int> v(S.size()+1, 0);

  int start = 0;
  for (int i = 1; i < S.size(); ++i) {
    if (S[i-1] != S[i]) {
      if (S[i-1] == '<') lt.push_back({start, i});
      else               gt.push_back({start, i});
      start = i;
    }
  }

  if (S[S.size()-1] == '<') lt.push_back({start, S.size()});
  else                      gt.push_back({start, S.size()});


  for (auto& p : lt) {
    int start = p.first;
    int end = p.second;
    int count = end - start;

    for (int i = 0; i < count; ++i) v[i + start] = i;
    v[end] = std::max(v[end], count);
  }

  for (auto& p : gt) {
    int start = p.first;
    int end = p.second;
    int count = end - start;

    for (int i = 0; i < count; ++i) v[end - i] = i;
    v[start] = std::max(v[start], count);
  }

  LL sum = 0;
  for (LL x : v) sum += x;
  std::cout << sum << std::endl;
}


Measured memory_bytes: 4984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
//cout << fixed << setprecision(15);

int main() {
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int t = 0;
  while (b <= a) {
    b *= 2;
    t++;
  }
  while (c <= b) {
    c *= 2;
    t++;
  }
  cout << (t <= k ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3632
N, M = [int(i) for i in input().split()]
pS = {}
 
for _ in range(M):
    a, s = [i for i in input().split()]
    if a not in pS:
        pS[a] = {}
        if s == 'AC':
            pS[a]['AC'] = True
        else:
            pS[a]['count'] = 1
    else:
        if s == 'AC':
            pS[a]['AC'] = True
        elif 'AC' not in pS[a]:
            pS[a]['count'] += 1
 
s = 0
a = 0
for v in pS.values():
    if 'AC' in v and 'count' in v:
        s += v['count']
    if 'AC' in v:
        a += 1
    
print(a, s)

Measured memory_bytes: 44452