akhauriyash/Code-Regression huggingface dataset:
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

int isUnder(int T,int A){ // AがT以下で1,それ以外0
    if(A<=T) return 1;
    else return 0;
}

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cins(S);
    int ans = 0;
    rep(i,S.length()){
        int subAns = 0;
        for(int j=i;j<S.length();j++){
            if(S[j]=='A' || S[j]=='G' || S[j]=='C' || S[j]=='T'){
                subAns++;
            }else{
                break;
            }
        }
        ans = max(ans,subAns);
    }
    cout << ans << nn;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(n)-1,i##_len=(int)(s);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数
int n[1000][1000];
int v[1000][1000];

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}

int main() {
	int n;
	scanf("%d", &n);

	int ans = 0;
	int a = 0, b = 0, ab = 0;
	REP(i, n) {
		char s[11];
		scanf("%s", s);
		if (s[0] == 'B')b++;
		if (s[strlen(s) - 1] == 'A')a++;
		if (s[0] == 'B'&&s[strlen(s) - 1] == 'A')ab++;
		REP(j, strlen(s) - 1) {
			if (s[j] == 'A' && s[j + 1] == 'B')ans++;
		}
	}
	ans += (Min(a, b));
	if (a == b&&a == ab && a!=0)ans--;

	PRINTD(ans);
}


Measured memory_bytes: 128
N,W = map(int,input().split())
INF = 10**12
V = 1000 * N
Data = []
Data.append([0,0])
for _ in range(N):
    Data.append(list(map(int,input().split())))

DP = [[INF]*(V+1) for _ in range(N+1)]
for n in range(N+1):
    DP[n][0] = 0

for n in range(1,N+1):
    for v in range(1,V+1):
        wi,vi = Data[n]
        if v >= vi:
            DP[n][v] = min(DP[n][v],DP[n-1][v-vi]+wi)
        DP[n][v] = min(DP[n][v],DP[n-1][v])

ans = 0
for  v in range(V+1):
    if DP[N][v] <= W:
        ans = v
print(ans)

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

#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define FORR(i,a,b) for(int i=(b)-1; i>=(a); i--)

#define DEBUG(x) cerr << #x << ": " << (x) << endl

using ll = long long;
const ll MOD = 998244353;

ll n,s;

ll modpow(ll a, ll b){
	ll r = 1;
	while(b){
		if(b&1)r=r*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return r;
}

typedef vector<ll> vl;

void debug(vl a){
	// REP(i,a.size())printf("%lld ",a[i]>MOD/2 ? a[i]-MOD : a[i]);
	REP(i,a.size())printf("%lld ",a[i]>MOD/2 ? a[i] : a[i]);
	puts("");
}

// meccha gambatte interpolation omoidasite kaiteru poyo
// by nari

vl mymul(vl a, vl b){
	int n = a.size();
	int m = b.size();
	vl c(n+m-1);
	REP(i,n)REP(j,m)c[i+j] = (c[i+j] + a[i]*b[j]%MOD) % MOD;
	// cerr << __LINE__ << endl;
	// debug(a);
	// debug(b);
	// debug(c);
	return c;
}
vl mydiv(vl a, ll b){
	// poly(a) / (x-b)
	vl orig = a;
	int n = a.size();
	vl c(n-1);
	FORR(i,0,n-1){
		c[i] = a[i+1];
		a[i] = (MOD + a[i] + c[i]*b%MOD) % MOD;
	}
	// cerr << __LINE__ << endl;
	// a = orig;
	// debug(a);
	// debug(c);
	// vl po = mymul(c,vl({MOD-b,1}));
	// if(po != a){
	// 	std::cerr << "error" << endl;
	// 	debug(a);
	// 	debug(vl({MOD-b,1}));
	// 	debug(c);
	// 	debug(po);
	// 	std::exit(1);
	// }
	return c;
}

vector<ll> interpo(vector<ll> dat){
	int n = dat.size();
	vector<ll> fact(2*n);
	fact[0] = 1;
	FOR(i,1,2*n)fact[i] = fact[i-1]*i%MOD;
	vl tot(1,1);
	REP(i,n){
		tot = mymul(tot, vl({MOD-i, 1}));
	}
	vl ret(n);
	REP(i,n){
		ll val = dat[i];
		vl pol = mydiv(tot, i);
		ll dv = fact[n-1-i] * fact[i] % MOD;
		if(i%2==1)dv = MOD-dv;
		ll m = val * modpow(dv, MOD-2) % MOD;
		REP(j,n){
			ret[j] += m * pol[j] % MOD;
			ret[j] %= MOD;
		}
	}
	return ret;
}

int main(){
	cin>>n>>s;
	ll ans = 0;
	// naive
	ll total = 0;
	ll inv2 = (MOD+1)/2;

	ans += modpow(s+1,n-1) * s % MOD * inv2 % MOD;
	// DEBUG(ans);
	// naive
	// ll sum = 0;
	// REP(i,10){
	// 	sum += modpow(s-i, n-1) * (i%2==0 ? 1 : MOD-1) % MOD;
	// 	sum %= MOD;
	// 	DEBUG(sum);
	// }

	// polynomial
	const int DEG = 2521;
	{
		vector<ll> dat(DEG);
		ll sum = 0;
		REP(i,DEG){
			sum += modpow(s-i, n-1);// * (i%2==s%2 ? 1 : MOD-1) % MOD;
			sum %= MOD;
			dat[i] = sum;
		}
		vector<ll> coeffs = interpo(dat);

		ll x = 1;
		ll add = 0;
		REP(i,DEG){
			add += coeffs[i] * x % MOD;
			add %= MOD;
			x = x * s % MOD;
		}
		// DEBUG(add);
		ans += MOD-add;
		ans %= MOD;

		// debug(coeffs);
	}
	{
		vector<ll> dat(DEG);
		ll sum = 0;
		REP(i,DEG){
			sum += modpow(s-2*i, n-1);// * (i%2==s%2 ? 1 : MOD-1) % MOD;
			sum %= MOD;
			dat[i] = sum;
		}
		vector<ll> coeffs = interpo(dat);

		ll x = 1;
		ll add = 0;
		REP(i,DEG){
			add += coeffs[i] * x % MOD;
			add %= MOD;
			x = x * (s/2) % MOD;
		}
		// DEBUG(add);
		ans += add * 2ll % MOD;
		ans %= MOD;

		// debug(coeffs);
	}

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


Measured memory_bytes: 3424
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
using namespace std;
int main()
{
  int N,K,count=0;
  vector<int> h(111111);
  cin>>N>>K;
  rep(i,N){cin>>h.at(i);if(h.at(i)>=K)count++;}
  cout<<count<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
  int i, j, c, n, m, a;
  long long int sum;
  int b[30];
  int ans = 0;

  scanf("%d %d %d", &n, &m, &c);
  
  for (i = 0; i < m; i++){
    scanf("%d ", &b[i]);
  }
  
  for (j = 0; j < n; j++){
    sum = c;
    for (i = 0; i < m; i++){
    	scanf("%d ", &a);
    	sum += a * b[i];
  	}
    if (sum > 0){
      ans++;
    }
  }
  
  
  printf("%d", ans);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, digitDP, treeDP//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vpll flag, D; vll path;
//***********//
int main() {
	cin >> N;
	string S;
	cin >> S;
	vl A(2*N);
	A[i] = 0;
	if (S[0] == 'W' || S[2*N - 1] == 'W') {
		cout << 0;
		exit(0);
	}
	for (i = 0; i < 2*N-1; i++) {
		if (S[i] == S[i + 1]) {
			A[i + 1] = (A[i] + 1) % 2;
		}
		else {
			A[i + 1] = A[i];
		}
	}
	vl R(2*N + 1), L(2*N + 1);
	R[0] = 0; L[0] = 0;
	for (i = 0; i < 2*N; i++) {
		R[i + 1] = R[i]; L[i + 1] = L[i];
		if (A[i] == 0) L[i + 1]++;
		else R[i + 1]++;
	}
	if (R[2*N] != L[2*N]) {
		cout << 0;
		exit(0);
	}
	ans = 1;
	for (i = 0; i < 2*N; i++) {
		if (A[i] == 1) {
			(ans *= (L[i] - R[i])) %= MOD;
		}
	}
	for (i = 1; i <= N; i++) {
		(ans *= i) %= MOD;
	}
	co(ans);
}

Measured memory_bytes: 8576
#include <stdio.h>
#include <string.h>
#define MAX 1001
#define END "0"

int main(void) {
    int i, s;
    char ary[MAX];
    for(; scanf("%s", ary), strcmp(ary, END); printf("%d\n", s)) {
        for(i = s = 0; ary[i]; s += ary[i++] - '0');
    }
    return 0;
}

Measured memory_bytes: 536
n = int(input())
ans = [0] * 10050
for i in range(1,105):
  for j in range(1,105):
    for k in range(1,105):
      v = i*i+j*j+k*k+i*j+j*k+k*i
      if v<10050:
        ans[v]+=1
for i in range(n):
  print(ans[i+1])

Measured memory_bytes: 9096
#include <iostream>

using namespace std;

unsigned long L[90];

int main(int argc, char *argv[]) {
	int N;
	cin >> N;

	L[0] = 2;
	L[1] = 1;
	for (int i = 2; i <= N; i++) {
		L[i] = L[i-1] + L[i-2];
	}

	cout << L[N] << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();

		if (n == 1) {
			System.out.println("Hello World");
		} else {
			int a = sc.nextInt();
			int b = sc.nextInt();

			System.out.println(a+b);
		}

		sc.close();
	}

}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int main() {
   int N;
   cin >> N;

   map<ll, ll> mp;
   rep (i, N) {
      ll a;
      cin >> a;
      mp[a]++;
   }

   vec<ll> v;
   for (auto &x : mp) {
      while (x.second > 0) {
         x.second /= 2;
         if (x.second > 0) v.push_back(x.first);
      }
   }

   sort(all(v), greater<ll>());

   if (v.size() >= 2) {
      cout << v[0] * v[1] << endl;
   } else {
      cout << 0 << endl;
   }

   return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<math.h>
using namespace std;
main(){
    int h,w,d;
    int q;
    cin>>h;
    cin>>w;
    cin>>d;
    int x[h*w];
    int y[h*w];
    for(int i=0;i<h*w;i++){
        int n;
        cin>>n;
        x[n]=i/w;
        y[n]=i%w;
    }
    int D[h*w];
    for(int i=1;i<=h*w;i++){
        if(i<=d) D[i]=0;
        else {
            D[i]=D[i-d]+abs(x[i]-x[i-d])+abs(y[i]-y[i-d]);
        }
    }
    cin>>q;
    for(int i=0;i<q;i++){
        int l,r;
        cin>>l;
        cin>>r;
        int ans=D[r]-D[l];
        cout<<ans<<endl;
    }
    return 0;
 
}

Measured memory_bytes: 2176
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

const int MR = 1e6 + 10;
const int MOD = 1e9 + 7;

int dp[MR];

int main()
{
	int n;
	scanf("%d", &n);

	dp[1] = n;
	dp[2] = n*(LL)n % MOD;

	int sum = n*(LL)(n - 1) % MOD, q = 2 * n - 2;
	queue<int> Q;
	REP(i, 2*n - 2)
		Q.push(1);

	FORQ(i, 3, n)
	{
		dp[i] = (sum + dp[i - 1]) % MOD;

		sum -= q;
		sum += MOD;
		sum %= MOD;
		
		q += dp[i - 2];
		q %= MOD;
		
		Q.push(dp[i - 2]);
		
		q -= Q.front();
		q += MOD;
		q %= MOD;

		sum += q;
		sum %= MOD;

		Q.pop();
	}

	printf("%d\n", dp[n]);

	return 0;
}

Measured memory_bytes: 12432
N = gets.to_i
if N == 1
    print 'Yes'
else
  h = gets.split(" ").map(&:to_i)
  ans = true
  (N-1).downto(1) do |i|
      if h[i-1] - h[i] > 1
        ans = false
        break
      elsif h[i-1] - h[i] == 1
        h[i-1] -= 1
      end
  end
puts 'Yes' if ans == true
puts 'No' if ans == false
end



Measured memory_bytes: 8580
sheet = []
r, c = (int(x) for x in input().split())

for row in range(r):
    bufarr = [int(x) for x in input().split()]
    bufarr.append(sum(bufarr))
    sheet.append(bufarr)

bufarr = []
for col in range(c + 1):
    bufarr.append(sum(sheet[row][col] for row in range(r)))
sheet.append(bufarr)

for row in range(r + 1):
    print(" ".join(str(sheet[row][col]) for col in range(c + 1)))

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N,count=0;	cin>>N;
	string s;	cin>>s;
	FOR(i,0,N-1)	if(s.at(i)==s.at(i+1))	count++;
	cout<<N-count<<endl;


    return 0;
}



Measured memory_bytes: 3756
(function main() {
  const n = Number(require('fs').readFileSync('/dev/stdin', 'utf8'));

  const cache = [1, 1];
  const fib = (n) => cache[n] || (cache[n] = fib(n - 1) + fib(n - 2));
  console.log(fib(n));
})();



Measured memory_bytes: 15140
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		for (int i = 0; i < N; i++) {
			int s=sc.nextInt(),d=sc.nextInt();
			int t = s%d;
			if(t==0){
				System.out.println(d);
			}else{
				System.out.println(t);
			}
			
		}
	}
}

Measured memory_bytes: 26444
import sys
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

n = int(input())
import sys
vals = [None]*n
def quest(q):
    print(q)
    sys.stdout.flush()
    res = input()
    if res=="Vacant":
        exit()
        res = -1
    elif res=="Male":
        res = 1
    else:
        res = 0
    vals[q] = res
    return res

k = n//2
res1 = quest(0)
res2 = quest(k)

if (res2-res1)%2 != k%2:
    l = 0
    r = k
else:
    l = k
    r = n
    
while l<r+1:
    m = (l+r)//2
    res = quest(m)
    if (res-vals[l])%2 != (l-m)%2:
        r = m
    else:
        l = m
quest(l)
quest(r)

Measured memory_bytes: 62952
def examA():
    X = I(); A = I(); B = I()
    ans = (X-A)%B
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()


Measured memory_bytes: 38384
#include <iostream>
#include <cmath>

using namespace std;

int main() {

  long long n, lim, x, y, ans = 0;
  cin >> n >> lim;
  for(int i = 1;i <= n;i++){
    cin >> x >> y;
    x= abs(x);
    y =abs(y);
    if(sqrt(x*x + y*y) <= lim){
      ans++;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3676
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n, m, v, p;
    cin >> n >> m >> v >> p;
    vl a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    vl cum(n, 0);
    cum[0] = a[0];
    for (int i = 1; i < n; ++i) {
        cum[i] += cum[i - 1] + a[i];
    }
    ll ret = p;
    v -= 1 + (p - 1); // used for ith problem and largetst p-1
    for (int i = 0; i < n - p; ++i) {
        ll curr  = a[i] + m;
        if (curr < a[n - p])
            continue;
        ll tempv = v;
        tempv -= i;
        if (tempv <= 0) {
            ret++;
            continue;
        }
        ll idx     = lower_bound(a.begin(), a.end(), curr) - a.begin();
        idx        = min(idx, n - p);
        ll cumsum  = cum[idx] - cum[i];
        ll canused = curr * (idx - i) - cumsum;
        if (canused >= m * tempv) {
            ret++;
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,i,j;
    cin>>a>>j;
    string s;
    b=0;
    cin>>s;
    c=0;
    for(i=0;i<a-1;i++){
        if(s[i]==s[i+1])
        b++;
        else
        c++;
    }
    if(j*2<c)
    b=b+j*2;
    else
    b=b+c;
    cout<<b<<endl;
}


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

using Graph = vector<vector<int>>;

int main()
{
    int n,m;
    cin >> n >> m;

    Graph g(n);

    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }
    
    for (int i = 0; i < n; i++)
    {
        cout << g[i].size() << endl;
    }
    
}

Measured memory_bytes: 256
# include <iostream>
# include <vector>
# include <string>
# include <set>

using namespace std;

int main() {
  int n; cin >> n;
  set<string> S;
  string s;
  
  for(int i = 1;i <= n;i++) { cin >> s; S.insert(s); }
  
  cout << S.size() << endl;
  //for(auto i : S) { cout << i << endl; }
  
  return 0;
}

Measured memory_bytes: 19208
#include<stdio.h>
#include<iostream>
using namespace std;

int A,B;
int main (){
    cin >> A >> B;
    if( A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) cout <<"Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int N;
	int x, y, b, p;
	int value;
	int answer;
	scanf("%d", &N);
	do {
		scanf("%d%d%d%d", &x, &y, &b, &p);
		value = 0;
		answer = b*x + p*y;
		
		if( b >= 5 && p >= 2) {
			answer *= 0.8;
		} else {
			if( b < 5)
				value += 5*x;
			else
				value += b*x;
			if( p < 2)
				value += 2*y;
			else
				value += p*y;
			
			value *= 0.8;
			if( answer > value)
				answer = value;
		}
		
		printf("%d\n", answer);
		
		N--;
	} while ( N > 0);
	return 0;
}

Measured memory_bytes: 600
import sys
from sys import stdin
def I():
    return stdin.readline().rstrip()
def MI():
    return map(int,stdin.readline().rstrip().split())
def LI():
    return list(map(int,stdin.readline().rstrip().split()))
#main part

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
        return -self.parents[self.find(x)]
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def group_count(self):
        return len(self.roots())
 
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
 
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
 
 
N, K = MI()
uf = UnionFind(N)
        
for i in range(K):
    A, B = MI()
    uf.union(A-1, B-1)
 
print(uf.group_count()-1)

Measured memory_bytes: 13192
import std.stdio, std.string, std.array, std.conv;

void main() {
    string[] board = ["#", "."];
    while (true) {
        int[] tmp = readln.chomp.split.to!(int[]);
        int h = tmp[0], w = tmp[1];
        if (h == 0 && w == 0) break;
        foreach (i; 0 .. h) {
            foreach (j; 0 .. w) {
                write(board[(i+j)%2]);
            }
            writeln;
        }
        writeln;
    }
}


Measured memory_bytes: 2484
import sys
input=sys.stdin.readline
import math

def main():
    H,W = map(int, input().split())
    if H%3 == 0 or W%3 == 0:
        print(0)
    else:
        mi = H*W
        # 縦3分割パターン
        s = W*math.ceil(H/3) - W*math.floor(H/3)
        mi = min(mi, s)
        # 横3分割パターン
        s = H*math.ceil(W/3) - H*math.floor(W/3)
        mi = min(mi, s)
        # 下2分割パターン
        for h in range(1,H):
            a = h*W
            b = (H-h)*math.ceil(W/2)
            c = (H-h)*math.floor(W/2)
            mi = min(mi, max(a,b,c) - min(a,b,c))
        # 右2分割パターン
        for w in range(1,W):
            a = H*w
            b = math.ceil(H/2)*(W-w)
            c = math.floor(H/2)*(W-w)
            mi = min(mi, max(a,b,c) - min(a,b,c))
        print(mi)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
N, K = map(int, input().split())
S = input()

if N == 1:
    print(0)
else:
    H = 0
    N_LR = 0
    N_RL = 0

    if S[0] == 'R' and S[1] == 'R':
        H += 1
    if S[0] == 'R' and S[1] == 'L':
        N_RL += 1
    if S[0] == 'L' and S[1] == 'R':
        N_LR += 1

    if S[N-1] == 'L' and S[N-2] == 'L':
        H += 1

    for i in range(1, N-1):
        if S[i] == 'L' and S[i-1] == 'L' or S[i] == 'R' and S[i+1] == 'R':
            H += 1
        if S[i] == 'R' and S[i+1] == 'L':
            N_RL += 1
        if S[i] == 'L' and S[i+1] == 'R':
            N_LR += 1

    M = min(N_RL, N_LR, K)
    H += 2 * M
    K -= M
    N_RL -= M
    N_LR -= M

    s0 = S[0]
    while K > 0 and (s0 == 'R' and N_RL > 0 or s0 == 'L' and N_LR > 0):
        if s0 == 'R' and N_RL > 0:
            H += 1
            s0 = 'L'
            N_RL -= 1
            K -=1
        elif s0 == 'L' and N_LR > 0:
            H += 1
            s0 = 'R'
            N_LR -= 1
            K -=1

    sN = S[N-1]
    while K > 0 and (sN == 'R' and N_LR > 0 or sN == 'L' and N_RL > 0):
        if sN == 'R' and N_LR > 0:
            H += 1
            sN = 'L'
            N_LR -= 1
            K -=1
        elif sN == 'L' and N_RL > 0:
            H += 1
            sN = 'R'
            N_RL -= 1
            K -=1

    print(H)


Measured memory_bytes: 40688
AList=[]
for _ in range(5):
    AList.append(int(input()))

min1 = 10
minval = 0 
for i in range(5):
    n = AList[i] % 10
    if n != 0 and min1 > n:
        min1 = n
        minval = AList[i]

sum1 = 0
if minval != 0:
    AList.remove(minval)
    sum1 = minval

for i in range(len(AList)):
    n = AList[ i ] + 9
    sum1 += (n // 10) * 10
print(sum1)


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

template <class Abel> struct BIT {
	vector<Abel> dat[2];
	Abel UNITY_SUM = 0;                     // to be set

	/* [1, n] */
	BIT(int n) { init(n); }
	void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }

	/* a, b are 1-indexed, [a, b) */
	inline void sub_add(int p, int a, Abel x) {
		for (int i = a; i < (int)dat[p].size(); i += i & -i)
			dat[p][i] = dat[p][i] + x;
	}
	inline void add(int a, int b, Abel x) {
		sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
	}

	/* a is 1-indexed, [a, b) */
	inline Abel sub_sum(int p, int a) {
		Abel res = UNITY_SUM;
		for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
		return res;
	}
	inline Abel sum(int a, int b) {
		return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
	}

	/* debug */
	void print() {
		for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
		cout << endl;
	}
};

int main() {
	int N; cin >> N;
	int Q; cin >> Q;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) cin >> a[i];

	vector<int> lefts(Q), rights(Q), ids(Q);
	for (int i = 0; i < Q; ++i) {
		cin >> lefts[i] >> rights[i];
		--lefts[i];
		ids[i] = i;
	}
	sort(ids.begin(), ids.end(), [&](int i, int j) {
		return rights[i] < rights[j]; });

	BIT<int> bit(N + 5);
	vector<int> prev(1100000, -1);
	vector<int> res(Q, 0);
	int r = 0;
	for (auto i : ids) {
		for (; r < rights[i]; ++r) {
			bit.add(prev[a[r]] + 2, r + 2, 1);
			prev[a[r]] = r;
		}
		int tmp = bit.sum(lefts[i] + 1, lefts[i] + 2);
		res[i] = max(res[i], tmp);
	}
	for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}

Measured memory_bytes: 21728
n,s = int(input()), list(input())
def z_algo(s):
    n = len(s)
    a = [0]*n
    i,j,l = 1,0,n
    a[0] = n
    while i < l:
        while i+j < l and s[j] == s[i+j]:
            j += 1
        if not j:
            i += 1
            continue
        a[i] = j
        k = 1
        while l-i > k < j-a[k]:
            a[i+k] = a[k]
            k += 1
        i += k
        j -= k
    return a

ans = 0
for i in range(n-1):
    a = z_algo(s[i:])
    len_a = len(a)
    for j in range(len_a):
        ans = max(ans, min(j,a[j]))
print(ans)

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

//create arrays outside of main()
int a[10] = {};

stack<char> s;


int main() {

    int n;
    cin >> n;

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

    sort(a, a+n, greater<int>());

    int sum =0;

    for (int i=1; i<n+1; i++){
        sum += a[i];
    }

    if(a[0]<sum){
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
import sys
import heapq
N,K=map(int,input().split())
H=list(map(lambda x: -int(x),input().split()))

if N <= K:
    print(0)
    sys.exit()

heapq.heapify(H)

for i in range(K):
    heapq.heappop(H)

print(sum(H)*(-1))

Measured memory_bytes: 25896
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt(),L[][]=new int[n+1][n+1];
		
		for(int i=0;i<n;i++) {
			int u=Integer.parseInt(in.next()), k=Integer.parseInt(in.next());
			for(int j=0;j<k;j++) {
				int v=Integer.parseInt(in.next());
				L[u][v]=1;
			}
		}
		
		PrintWriter out=new PrintWriter(System.out);
		for(int i=1;i<=n;i++) {
			for(int j=1;j<n;j++) out.print(L[i][j]+" ");
			out.println(L[i][n]);
		}
		out.flush();
	}

}




Measured memory_bytes: 30628
x,n = map(int,input().split())
if n > 0:
  a = list(map(int,input().split()))
else:
  a = []
a = set(a)
ans = x
for i in range(100):
  if not x-i in a:
    print(x-i)
    break
  if not x+i in a:
    print(x+i)
    break 

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
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);
        DMakeThemEven solver = new DMakeThemEven();
        solver.solve(1, in, out);
        out.close();
    }

    static class DMakeThemEven {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int h = in.nextInt();
            int w = in.nextInt();
            boolean[][] f = new boolean[h][w];
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    f[i][j] = in.nextInt() % 2 == 0;
                }
            }

            StringBuilder sb = new StringBuilder();
            int cnt = 0;
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w - 1; j++) {
                    if (!f[i][j]) {
                        cnt++;
                        sb.append(i + 1).append(" ")
                                .append(j + 1).append(" ")
                                .append(i + 1).append(" ")
                                .append(j + 2).append("\n");
                        f[i][j] = !f[i][j];
                        f[i][j + 1] = !f[i][j + 1];
                    }
                }
            }

            for (int i = 0; i < h - 1; i++) {
                if (!f[i][w - 1]) {
                    cnt++;
                    sb.append(i + 1).append(" ")
                            .append(w).append(" ")
                            .append(i + 2).append(" ")
                            .append(w).append("\n");
                    f[i][w - 1] = !f[i][w - 1];
                    f[i + 1][w - 1] = !f[i + 1][w - 1];
                }
            }

            out.println(cnt);
            out.print(sb);

        }

    }
}



Measured memory_bytes: 95000
s = input()
like = 753
ans = 10**10
for i in range(len(s)-3+1):
    s2 = ""
    for j in range(3):
        s2 += s[i+j]
    d = int(s2)
    diff = abs(like-d)
    ans = min(ans,diff)
print(ans)

Measured memory_bytes: 3060
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong bignum = 1_000_000_007;
alias SugarWater = Tuple!(long, "swater", long, "sugar");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long a,b,c;
    scan(a,b,c);
    max(0, (c - a + b)).writeln();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<vector<int >>adj;
vector<set<int> >con(100000);
vector<int>vis;
vector<int>pos;
void dfs(int n,int i)
{
  if(vis[n])return;
  vis[n]=1;
  con[i].insert(n);
  pos[n]=i;
  for(auto x:adj[n])
  {
      dfs(x,i);
  }
  return ;
}
  
int main()
{
	int n,m,k;
    cin>>n>>m>>k;
    adj.resize(n);
  	vis.resize(n);
  	vector<int>ans(n);
  	pos.resize(n);
    for(int i=0;i<m;i++)
    {
    	int a,b;
		cin>>a>>b;
        adj[a-1].push_back(b-1);
        adj[b-1].push_back(a-1);
     }
  	int p=0;
  	for(int i=0;i<n;i++)
    {
      if(vis[i])continue;
      else 
      {
        dfs(i,p);
        p++;
      }
    }
  	for(int i=0;i<n;i++)
    {
      int t=adj[i].size();
      ans[i]=con[pos[i]].size()-t-1;
    }
      
      
  	
    for(int i=0;i<k;i++)
    {
    	int a,b;
		cin>>a>>b;
       	a--;
      	b--;
      	if(pos[a]==pos[b])
        {
          ans[a]-=1;
          ans[b]-=1;
        }
     }
     for(auto x:ans)cout<<x<<' ';
  
  
  
  return 0;
}
  

Measured memory_bytes: 19924
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int maxn = 50 + 5;
const int mod = 1e9 + 7;

int f[maxn][maxn][maxn * maxn * 2];
int n , k;
void add(int &x ,int y){
    x += y;if(x >= mod)x-=mod;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> n >> k;
    f[0][0][maxn * maxn] = 1;
    for(int i = 0 ; i < n ; ++i){
        for(int j = 0 ; j <= n ; ++j){
            for(int k = 0 ; k < maxn * maxn * 2  ; ++k){
                if(f[i][j][k] == 0)continue;
                add(f[i + 1][j][k] , (ll)f[i][j][k] * (2 * j + 1) % mod);
                add(f[i + 1][j + 1][k - 2 * (i + 1)] , f[i][j][k]);
                if(j >= 0){
                    add(f[i + 1][j - 1][k + 2 * (i + 1)] , (ll)f[i][j][k] * j * j % mod);
                }
            }
        }
    }
    cout << f[n][0][maxn * maxn + k];
}


Measured memory_bytes: 65792
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
long long r1,r2,c1,c2,p;
long long fact[2000005],ans,inv[2000005];
long long power(long long a,long long b){
    long long res=1;
    while (b>0){
        if (b%2==1) res=(res*a)%p;
        b/=2;
        a=(a*a)%p;
    }
    return res;
}
long long ncr(int n,int r){
    long long ans=fact[n];
    ans*=inv[r];
    ans%=p;
    ans*=inv[n-r];
    return ans%p;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>r1>>c1>>r2>>c2;
    p=1e9+7;
    fact[0]=1;
    inv[0]=power(fact[0],p-2);
    for (int i=1;i<2000005;i++){
        fact[i]=fact[i-1]*i;
        fact[i]%=p;
        inv[i]=power(fact[i],p-2);
    }
    for (int i=r1;i<=r2;i++){
        ans+=ncr(i+c2+1,i+1);
        ans%=p;
        ans-=ncr(i+c1,i+1);
        ans%=p;
        /*
        for (int j=c1;j<=c2;j++){
            ans+=ncr(i+j,i);
            ans%=p;
        }
        */
    }
    cout<<(ans+p)%p;
}

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

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;

	int ans = max(0, c - (a - b));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rep1n(i, n) for(int i=1;i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
int main() {
	int n;
	cin >> n;
	vector<string>s(n);
	rep(i, n)cin >> s[i];
	vector<map<char, int>>m(n);
	rep(i, n)rep(j, s[i].size())m[i][s[i][j]]++;
	int ans = 0;
	map<char, int>minmap;
	for (char i = 'a'; i <= 'z'; i++) {
		auto mi = [&]()->int {
			int minn = 5000;
			rep(j, n) {
				minn = min(m[j][i], minn);
			}
			return minn;
		};

		minmap[i] = mi();
		ans += minmap[i];
		rep(j, minmap[i])cout << i;
	}




	cout << endl;

	return 0;
}





Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int m,n,a,b,t=999999;
int main(){
	scanf("%d%d",&m,&n);
	for(int i=1;i<=m;i++){
		scanf("%d %d",&a,&b);
		if(b>n)continue;
		else t=min(t,a);
	}
	if(t!=999999)cout<<t<<endl;
	else cout<<"TLE"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
using namespace std;
 
int main(){
    
    int ans=0;
    string S;

    cin >> S;

    for(int i=0;i<=3;i++){
        if(S[i]=='+'){
            ans +=1;
        }else{
            ans -=1;
        }
    }
    
    cout << ans <<endl;

    return 0;
}

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

static const int N = 8000;

static bool dp(const std::vector<int>& xx, int begin, int end)
{
    std::vector<std::vector<bool>> dpt(xx.size()+1, std::vector<bool>(N*2+1, false));
    dpt[0][begin+N] = true;

    for (size_t i = 0; i < xx.size(); i++) {
        for (int j = 0; j < N*2+1; j++) {
            bool b1 = (j+xx[i] < 2*N+1)?dpt[i][j+xx[i]]:false;
            bool b2 = (0 <= j-xx[i])?dpt[i][j-xx[i]]:false;
            dpt[i+1][j] = b1 || b2;
        }
    }

    return dpt[xx.size()][end+N];
}

int main() {
    std::vector<int> XX, YY;
    std::string s;
    int x, y;
    int x0 = -1;

    std::cin >> s >> x >> y;

    int d = 0;
    int cnt = 0;
    for (const auto c: s) {
        if (c == 'T') {
            if (x0 < 0) {
                x0 = cnt;
            } else {
                if (cnt > 0) {
                    if (d == 0) {
                        XX.push_back(cnt);
                    } else {
                        YY.push_back(cnt);
                    }
                }
            }
            cnt = 0;
            d = 1 - d;
        } else {
            cnt++;
        }
    }
    if (x0 < 0) {
        x0 = cnt;
    } else {
        if (cnt > 0) {
            if (d == 0) {
                XX.push_back(cnt);
            } else {
                YY.push_back(cnt);
            }
        }
    }

    std::cout << ((dp(XX, x0, x) && dp(YY, 0, y))?"Yes":"No") << std::endl;

    return 0;
}

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

int main()
{
    string s;
    cin >> s;
    if(s=="SUN") cout << 7 << endl;
    else if(s=="MON") cout << 6 << endl;
    else if(s=="TUE") cout << 5 << endl;
    else if(s=="WED") cout << 4 << endl;
    else if(s=="THU") cout << 3 << endl;
    else if(s=="FRI") cout << 2 << endl;
    else if(s=="SAT") cout << 1 << endl;

    return 0;

}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  cout << (((a+b)==c || (a+c)==b || (b+c)==a) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

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


int main(){
	int k;
	string S;

	cin >> S;

	int sum = 0;

	k = (int)S.size();

	for(int i = 0; i < (int)S.size(); i++){
		if(S[i] == 'o'){
			sum++;
		}
	}

	if((sum + (15 - k))  < 8 ){
		cout << "NO" << endl;
	}
	else{
		cout << "YES" << endl;
	}




}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

using namespace std;

int main() {

	int n, k;

	cin >> n >> k;

	if (n%k == 0) {
		cout << "0" << endl;
	}
	else {
		cout << "1" << endl;
	}

	return 0;

}

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

template<typename T>
T get_value(std::istream& is);

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

  vector<int> cities(get_value<size_t>(cin));
  for (auto i {get_value<size_t>(cin)}; i != 0; --i) {
    const auto a {get_value<int>(cin)}, b {get_value<int>(cin)};
    ++cities[a-1];
    ++cities[b-1];
  }

  for (auto e : cities)
    cout << e << '\n';
  
  return 0;
}

template<typename T>
inline T get_value(std::istream& is)
{
  T v;
  is >> v;
  return v;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include<functional>
using namespace std;
typedef long long LL;
inline long long read()
{
	long long kk=0,f=1;
	char cc=getchar();
	while(cc<'0'||cc>'9'){if(cc=='-')f=-1;cc=getchar();}
	while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}
	return kk*f;
}
set<string>S;
string ss;
int main()
{
	int a,b;
	a=read();b=read();
	if(a>b)printf("safe\n");
	else printf("unsafe\n");
}

Measured memory_bytes: 3628
S=input()
Q=int(input())
A= [input().split() for i in range(Q)]

tmp=0
s=S
t=''

for li in A:
    if li[0]=='1':
        tmp=(tmp+1)%2
    else:
        if (tmp+int(li[1]))%2 == 1:
            t += li[2]
        else:
            s += li[2]

if tmp == 0:
    print(t[::-1]+s)
else:
    print(s[::-1]+t)

Measured memory_bytes: 40668
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#define ll long long
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pi(n) prllf("%d",n)
#define pl(n) prllf("%d",n)
using namespace std;

int main(){
  int n;
  cin>>n;
  if(n<1000) cout<<"ABC"<<endl;
  else cout<<"ABD"<<endl;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <fstream>
#include <functional>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>


using namespace std;


int main() {
	int P, Q, R;

	cin >> P >> Q >> R;
	cout << P + Q + R - max({ P,Q,R }) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int a[10005],ans[105][105];
int main()
{
    int i,i0,n,m,H,W,p;
    while(scanf("%d %d",&H,&W)!=EOF)
    {
        p=0;
        scanf("%d",&n);
        for(i=0;i<n;i++)scanf("%d",&a[i]);
        for(i=0;i<H;i++)
        {
            if(i&1)
            {
                for(i0=W-1;i0>=0;i0--)
                {
                    ans[i][i0]=p+1;
                    a[p]--;
                    if(!a[p])p++;
                }
            }
            else
            {
                for(i0=0;i0<W;i0++)
                {
                    ans[i][i0]=p+1;
                    a[p]--;
                    if(!a[p])p++;
                }
            }
        }
        for(i=0;i<H;i++)
        {
            for(i0=0;i0<W;i0++)
            {
                printf("%d",ans[i][i0]);
                if(i0==W-1)printf("\n");
                else printf(" ");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

#define NUM 300000
bool P[NUM+1];
typedef vector <int> VI;

int main( void )
{
    VI PS;
    memset( P, false, sizeof( P ) );
    bool f = true;
    int t = 1;
    int count = 0;
    while ( t <= NUM )
    {
        P[t] = true;
        t += f ? 5 : 2;
        f = !f;
        count++;
    }
    P[1] = false;

    for ( int i = 2; i <= NUM; i++ )
    {
        if ( !P[i] ) continue;
        for ( int j = i+i; j <= NUM; j += i )
        {
            P[j] = false;
        }
    }

    int n;
    while ( cin >> n && n != 1 )
    {
        VI L;
        for ( int i = 2; i <= n; i++ )
        {
            if ( P[i] && n % i == 0 ) L.push_back( i );
        }

        cout << n << ": ";
        for ( VI ::iterator it = L.begin(); it != L.end(); it++ )
        {
            cout << *it;
            if ( it + 1 == L.end() ) cout << endl;
            else cout << " ";
        }
    }

    return 0;
}

Measured memory_bytes: 1196
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
typedef long long int ll;
using namespace std;

int main(){
	for(int i=1;i<10;i++){
		for(int j=1;j<10;j++){
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}
}


Measured memory_bytes: 3048