akhauriyash/Code-Regression huggingface dataset:
N, K = map(int, input().split())
A = list(map(int, input().split()))

flag = [False] * N
counted = [1]

nextT = A[0]
flag[0] = True
for x in range(N):
    if flag[nextT - 1] is False:
        counted.append(nextT)
        flag[nextT - 1] = True
        nextT = A[nextT - 1]
    else:
        break
before_loop_len = counted.index(nextT)
loop_len = x - before_loop_len + 1

if K <= before_loop_len:
    print(counted[K])
else:
    checkK_prep = K - before_loop_len
    checkK = checkK_prep % loop_len
    print(counted[before_loop_len + checkK])


Measured memory_bytes: 95308
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		int C = scanner.nextInt();
		int ans;
		int[] num = {A,B,C};
		scanner.close();		
	
		Arrays.sort(num);
		System.out.println(num[0]+num[1]+(num[2]*10));		
	}
}

Measured memory_bytes: 23636
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    N, M = map(int, input().split())
    box = [0] + [1 for _ in range(N)]
    red = [0, 1] + [0 for _ in range(N - 1)]
    for _ in range(M):
        x, y = map(int, input().split())
        if red[x]:
            red[y] = 1
        box[x] -= 1
        box[y] += 1
        if not box[x]:
            red[x] = 0
    answer = sum(red)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 5384
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;cin>>s>>t;
  int n=s.size(),m=t.size();
  vector<vector<int>>dp(n+1,vector<int>(m+1,0));
  for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
      if(s.at(i-1)==t.at(j-1))dp.at(i).at(j)=dp.at(i-1).at(j-1)+1;
      else dp.at(i).at(j)=max(dp.at(i).at(j-1),dp.at(i-1).at(j));
    }
  }
  int i=n,j=m;string LCS;
  while(LCS.size()<dp.at(n).at(m)){
    if(dp.at(i).at(j)==dp.at(i-1).at(j))i--;
    else if(dp.at(i).at(j)==dp.at(i).at(j-1))j--;
    else{LCS=s.at(i-1)+LCS;i--;j--;}
  }
  cout<<LCS<<endl;
}

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

int main() {
  int64_t k,ans=0;
  cin >> k;
  for(int i=1; i<=k; i++) {
    for(int j=1; j<=k; j++) {
      for(int n=1; n<=k; n++) {
        ans += gcd(i,gcd(j,n));
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
A,B,C=map(int,input().split())
cnt=0
if A==B and B==C:
    if A%2==0:
        print(-1)
    else:
        print(0)
    exit()

while True:
    x=A
    y=B
    z=C
    if A%2!=0 or B%2!=0 or C%2!=0:
        break
    cnt+=1
    A=(y+z)//2
    B=(x+z)//2
    C=(x+y)//2
    #print(A,B,C)
print(cnt)

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	vector<vector<int>> F(N,vector<int>(10)),C(N,vector<int>(11));
	REP(i,N){
		REP(j,10){
			F[i][j]=in();
		}
	}
	REP(i,N){
		REP(j,11){
			C[i][j]=in();
		}
	}
	int maxC=-(1<<30);
	for(int i=1;i<=1023;i++){
		array<int,10> A{0,0,0,0,0,0,0,0,0,0};
		int V=i,index=0;
		while(V){
			if(V&1) A[index]=1;
			index++;
			V/=2;
		}

		int sumC=0;
		REP(j,N){
			int sum=0;
			REP(k,10){
				if(A[k]==1 && F[j][k]==1) sum++; 
			}
			sumC += C[j][sum];
		}
		maxC = max(maxC,sumC);
	}
	out(maxC);
	return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define MAX_N 100000
i64 N;
i64 H[MAX_N];

bool solve() {
  for (i64 i = N - 1; i >= 1; i--) {
    if (H[i - 1] > H[i]) {
      H[i - 1]--;
      if (H[i - 1] > H[i]) return false;
    }
  }
  return true;
}

int main() {
  cin >> N;
  REP(i, N) cin >> H[i];

  bool res = solve();

  if (res) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 1024
#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>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<long long> divisor(long long n){
	vector<long long> res;
	for(long long i = 1; i*i <= n; i++){
		if(n%i == 0){
			res.push_back(i);
			if(i != n/i) res.push_back(n/i);
		}
	}
	return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i+=2){
    	if(divisor(i).size() == 8) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        string x; cin >> x;
        sort(x.begin(), x.end());
        for (char i = 'a'; i <= 'z'; ++i) {
            if (!binary_search(x.begin(), x.end(), i))
                return cout << i, 0;
        }
        cout << "None";
        return 0;
    }





Measured memory_bytes: 3736
LOCAL = True   and False


def dprint(*args):
  if LOCAL:
    print(*args)


n = int(input())
a = []
xy = []
# x = []
# y = []
for _ in range(n):
  a.append(int(input()))
  # for _ in range(a[-1]):
  # xy = list(map(int, input().split()))
  # x[i].append(xy[0])
  # y[i].append(xy[1])
  xy.append([list(map(int, input().split())) for _ in range(a[-1])])

anses = []

for x in range(2 ** n):
  flag = True
  cnt = 0
  dprint('x', x)
  for i in range(n):
    if x & (1 << i) != 0:
      dprint('i', i)
      cnt += 1
      for j in range(a[i]):
        dprint(int(x & (1 << (xy[i][j][0] - 1)) != 0) != xy[i][j][1])
        if int(x & (1 << (xy[i][j][0] - 1)) != 0) != xy[i][j][1]:
          flag = False
  if flag:
    anses.append(cnt)

dprint(anses)
print(max(anses))


Measured memory_bytes: 47596
#include <cstdio>
#define rr register
using namespace std;
int n,A,x; long long ans,dp[51][2511];
signed main(){
	scanf("%d%d",&n,&A),dp[0][0]=1;
	for (rr int i=1;i<=n;++i){
		scanf("%d",&x);
		for (rr int j=i;j;--j)
		for (rr int m=A*n;m>=x;--m)
		    dp[j][m]+=dp[j-1][m-x];
	}
	for (rr int i=1;i<=n;++i) ans+=dp[i][i*A];
	return !printf("%lld\n",ans);
}

Measured memory_bytes: 2668
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int n = sc.nextInt();
			final int S = sc.nextInt();
			
			if(n == 0 && S == 0){
				break;
			}
			
			int[] array = new int[n];
			for(int i = 0; i < n; i++){
				array[i] = sc.nextInt();
			}
			
			Arrays.sort(array);
			
			int count = 0;
			
			for(int i = n - 1; i >= 0; i--){
				for(int j = i - 1; j >= 0; j--){
					if(array[i] + array[j] <= S){
						break;
					}else{
						count++;
					}
				}
			}
			
			System.out.println(count);
		}
	}

}

Measured memory_bytes: 14000
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = B[A[0]-1]

for n in range(1,N):
  if A[n]!=1+A[n-1]:
    ans+=B[A[n]-1]
  else:
    ans+=B[A[n]-1]+C[A[n]-2]

print(ans)

Measured memory_bytes: 9148
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;

struct SegmentTreeNode {
	int l, r;
	vector<int> v;
};

class SegmentTree {
public:
	SegmentTree(const vector<int>& a) :st(a.size() * 4) {
		BuildTree(0, 0, a.size() - 1, a);
	}

	int query(int x, int l, int r) {
		if (st[x].l > r || st[x].r < l) return 0;
		if (st[x].l >= l && st[x].r <= r)
			return distance(st[x].v.begin(), lower_bound(st[x].v.begin(), st[x].v.end(), l));
		return query((x << 1) + 1, l, r) + query((x + 1) << 1, l, r);
	}

private:
	void BuildTree(int x, int l, int r, const vector<int>& data) {
		st[x].l = l, st[x].r = r;
		if (l == r) {
			st[x].v = { data[l] };
		}
		else {
			int m = (l + r) >> 1, lc = (x << 1) + 1, rc = (x + 1) << 1;
			BuildTree(lc, l, m, data);
			BuildTree(rc, m + 1, r, data);

			int p = 0, q = 0;
			while (p < st[lc].v.size() && q < st[rc].v.size()) {
				if (st[lc].v[p] < st[rc].v[q])
					st[x].v.push_back(st[lc].v[p++]);
				else
					st[x].v.push_back(st[rc].v[q++]);
			}
			while (p < st[lc].v.size())
				st[x].v.push_back(st[lc].v[p++]);
			while (q < st[rc].v.size())
				st[x].v.push_back(st[rc].v[q++]);
		}
	}

	vector<SegmentTreeNode> st;
};

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

	unordered_map<int, int> m;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		int c;
		scanf("%d", &c);

		if (m.count(c)) {
			a[i] = m[c];
			m[c] = i;
		}
		else {
			a[i] = -1;
			m[c] = i;
		}
	}

	SegmentTree st(a);
	for (int i = 0; i < q; i++) {
		int l, r;
		scanf("%d %d", &l, &r);
		printf("%d\n", st.query(0, l - 1, r - 1));
	}

	return 0;
}

Measured memory_bytes: 153824
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

int main() {
    cin>>K>>N;
    ll ans = 0;
    rep(i, K + 1){
        ll sum = N - i;
        ans += max(0LL, min(sum + 1, K * 2 - sum + 1));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<int, lli> il;

#define INT_INF (lli)(1e9 + 7)
lli modadd(lli a, lli b) {
    return (a + b) % INT_INF;
}
lli modsub(lli a, lli b) {
    return (a + INT_INF - b) % INT_INF;
}
lli modmul(lli a, lli b) {
    return (a * b) % INT_INF;
}

lli modpower(lli x, lli y) {
    if (y == 0) return 1;
    else if (y == 1) return x;
    else if (y & 1) {
        lli t = modpower(x, y >> 1);
        return modmul(modmul(t, t), x);
    }
    else {
        lli t = modpower(x, y >> 1);
        return modmul(t, t);
    }
}

lli moddiv(lli a, lli b) {
    return modmul(a ,modpower(b, INT_INF-2));
}

lli fac[100500] = {};
lli cmb(int n,int r) {
    return moddiv(fac[n], modmul(fac[r], fac[n-r]));
}
int main() {
    int N, M;
    cin >> N >> M;
    map<int, int> prime;
    int m = M;
    for (int i = 2; i * i <= M; i++) {
        while (m % i == 0) {
            prime[i]++;
            m /= i;
        }
    }
    if (m != 1) prime[m]++;
    fac[0] = 1;
    for (int i = 1; i < 100500; i++) {
        fac[i] = modmul(fac[i-1], i);
    }
    lli ans = 1;
    for (map<int, int>::iterator it = prime.begin(); it != prime.end(); ++it) {
        int p = it->first, n = it->second;
        ans = modmul(cmb(n + N - 1, N - 1), ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
a = []
n = int(input())
b = [int(i) for i in input().split()]

flag = True
for i in range(n):
    if i+1 < b[i]:
        flag = False

for i in range(n):
    a.insert(b[i]-1,b[i])

if flag == False:
    print("-1")

else:
    for i in a:
        print(i)

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


int gethash(const string& s, const vector<int>& v) {
    stack<int> st;
    for (char c : s) {
        if ('a' <= c && c <= 'd')
            st.push(v[c - 'a']);
        else if (c == '+') {
            int a = st.top();
            st.pop();
            int b = st.top();
            st.pop();
            st.push(a | b);
        }
        else if (c == '*') {
            int a = st.top();
            st.pop();
            int b = st.top();
            st.pop();
            st.push(a & b);
        }
        else if (c == '^') {
            int a = st.top();
            st.pop();
            int b = st.top();
            st.pop();
            st.push(a ^ b);
        }
    }
    return st.top();
}

int main() {
    while (true) {
        string s;
        cin >> s;
        if (s == ".") return 0;

        int p;
        cin >> p;
        reverse(s.begin(), s.end());
        int h = gethash(s, { p / 1000, p / 100 % 10, p / 10 % 10, p % 10 });
        int c = 0;
        for (int i = 0; i < 10; ++i)
            for (int j = 0; j < 10; ++j)
                for (int k = 0; k < 10; ++k)
                    for (int l = 0; l < 10; ++l)
                        c += gethash(s, { i, j, k, l }) == h;

        cout << h << " " << c << "\n";
    }
}



Measured memory_bytes: 3084
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N;
  cin >> N;
  int sum = 0, mx = 0;
  for (int i = 0; i < N; i++) {
    int l;
    cin >> l;
    sum += l;
    chmax(mx, l);
  }

  if (sum - mx > mx) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

#define ran 202202

int n;
int a[ran];

int main() {
	int s = 0;
	
	scanf("%d", &n);
	for(int i=0;i<n;i++){
		scanf("%d", &a[i]);
		s ^= a[i];
	}
	for(int i=0;i<n;i++)
		printf("%d%c", s^a[i], i<n-1?' ':'\n');
	
	return 0;
}

Measured memory_bytes: 4560
#include<iostream>
using namespace std;
int main(){
  int n, m;
  cin >> n >> m;  

  int p[n] = {};
  for (int i=0;i<n;i++)p[i] = 0;
  
  int pi;
  string s;
  int ac = 0; // accuracy count
  int tpc = 0; // true penalty count  
  int pc[n] = {}; // penalty count per question
  for (int i=0;i<n;i++)pc[n] = 0;

  for (int i=0;i<m;i++){
    cin >> pi >> s;
    pi = pi-1;
    if (s == "AC"){
      if (p[pi])
        continue;
      p[pi] = 1;
      ac++;
      tpc += pc[pi];
    }else if(s == "WA"){
      if (p[pi])
        continue;
      pc[pi]++;
    }
  }
  cout << ac << ' ' << tpc;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

const int M = 1e9+7;

using namespace std;

ll fexp (ll x, ll y)
{
    ll r=1;
    while (y)
    {
        if (y&1)
            r=(r*x)%M;
        x=(x*x)%M;
        y>>=1;
    }
    return r;
}

main()
{
    fast;
    int n,i;
    cin>>n;
    int a[n];
    for (i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int f=0;
    if (n&1)
    {
        if (a[0]!=0)
            f=1;
        else
        {
            for (i=1;i<n;i+=2)
            {
                if (a[i]==i+1 && a[i+1]==i+1)
                    continue;
                else
                {
                    f=1;
                    break;
                }
            }
        }
        if (!f)
            cout<<fexp(2,n/2)%M<<endl;
        else
            cout<<"0\n";
    }
    else
    {
        for (i=0;i<n;i+=2)
        {
            if (a[i]==i+1 && a[i+1]==i+1)
                continue;
            else
            {
                f=1;
                break;
            }
        }
        if (!f)
            cout<<fexp(2,n/2)%M<<endl;
        else
            cout<<"0\n";
    }
}

Measured memory_bytes: 640
N = gets.to_i
D = gets.split.map(&:to_i)
MOD = 998244353

if D[0] != 0
  puts 0
  exit
end

E = D.sort!.slice_when{|a,b|a!=b}.to_a.map{|v|[v[0],v.size]}

count = 1
pre = 1
E.each_with_index do |(a,b), i|
  if a != i
    puts 0
    exit
  end

  if a == 0
    if b != 1
      puts 0
      exit
    else
      next
    end
  end

  b.times do
    count *= pre
    count %= MOD
  end

  pre = b
end

puts count



Measured memory_bytes: 18040
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i, input;
        i = 0;
        while (true) {
            i++;
            input = sc.nextInt();
            if (input==0) break;
            System.out.println("Case "+i+": "+input);
        }
    }
}


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

int main() {
  string C1;
  string C2;
  cin >> C1;
  cin >> C2;
  if (C1.at(0) == C2.at(2) && C1.at(1) == C2.at(1) && C1.at(2) == C2.at(0)){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3596
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int pop();
void push();

int main() {
  int x,y,top=0;
  char p[100];

  while(scanf("%s",p) != EOF) {
    if(p[0] == '+') {
      x = pop();
      y = pop();
      push(x + y);
    }
    else if(p[0] == '-') {
      y = pop();
      x = pop();
      push(x - y);
    }
    else if(p[0] == '*') {
      x = pop();
      y = pop();
      push(x * y);
    }
    else {
      push(atoi(p));
    }
  }
  printf("%d\n",pop());
  return 0;
}

int top,p[1000];

int pop() {

  top--;
  return p[top+1];
}

void push(int x) {

  p[++top] = x;
}
  
	      



Measured memory_bytes: 2088
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define FOR(i,l,r) for(int i=l;i<int(r);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define all(a) a.begin(),a.end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define debug(x) cout<<#x<<": "<<x<<endl
typedef long long ll;

#define M 500

ll a[250020],b[M];
bool same[M];

int N;

void update(int j){
    same[j] = true;
    ll first = a[j*M] + b[j];
    rep(i,M) same[j] &= (a[i+j*M]+b[j] == first);
}

// [l,r) 
void add(int l,int r,int x){
    if(l>=r) return;
    if(l/M == r/M){
        FOR(i,l,r){
            a[i] += x;
        }
        update(l/M);
        return;
    }

    FOR(j,l/M+1,r/M){
        b[j] += x;
    }
    
    FOR(i,l,(l/M+1)*M){
        a[i] += x;
    }
    update(l/M);

    FOR(i,r-r%M,r){
        a[i] += x;
    }
    update(r/M);
}

int main(void){
    cin>>N;
    vector<int> s(N);
    rep(i,N) cin>>s[i];
    rep(i,N/2) a[i] = s[i]-s[N-1-i];
    rep(j,M) update(j);

    int Q;
    cin>>Q;
    while(Q--){
        int l,r,x;
        cin>>l>>r>>x;
        l--,r--;
        if(l<N/2 && N/2<=r){
            if(l<N-1-r) {
                add(l,N-1-r,x);
            }
            else {
                add(N-1-r,l,-x);
            }
        }
        if(r<N/2){
            add(l,r+1,x);
        }
        if(N/2<=l){
            add(N-1-r,N-l,-x);
        }

        bool allZero = true;
        rep(j,M){
            allZero &= (same[j] && a[j*M]+b[j]==0);
        }

        cout<<allZero<<endl;
    }
    return 0;
}

Measured memory_bytes: 6800
# 要復習
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    s = input()
    if len(set(s))  == len(s):
        print("yes")
    else:
        print("no")


if __name__ == "__main__":
    main()




Measured memory_bytes: 5192
#include<iostream>
    #include<vector>
    #include<iterator>
    #include <algorithm>

    using namespace std;

    int main(){
        int a, b, c; cin >> a >> b >> c;
        for (int i = 0; i < c; i++) {
            b -= a;
            if (b < 0){
                cout << i << endl;
                break;
            }
            if (i == c-1){
                cout << i+1 << endl;
            }
        }
        return 0;
    }

Measured memory_bytes: 256
n=int(input())
if n==2:
  print(-1)
  exit()
if n==3:
  print("abb")
  print("a.c")
  print("ddc")
  exit()
if n==5:
  print("aabbc","hi..c","hi..d","g.jjd","gffee")
  exit()
if n==7:
  print("..abc..")
  print("..abc..")
  print("aax..aa")
  print("bbx..bb")
  print("cc.yycc")
  print("..abc..")
  print("..abc..")
  exit()
a=[n*["."]for _ in range(n)]
if n%2:
  a[-5][-5],a[-5][-4],a[-5][-3],a[-5][-2],a[-5][-1]=list("aabbc")
  a[-4][-5],a[-4][-4],a[-4][-3],a[-4][-2],a[-4][-1]=list("hi..c")
  a[-3][-5],a[-3][-4],a[-3][-3],a[-3][-2],a[-3][-1]=list("hi..d")
  a[-2][-5],a[-2][-4],a[-2][-3],a[-2][-2],a[-2][-1]=list("g.jjd")
  a[-1][-5],a[-1][-4],a[-1][-3],a[-1][-2],a[-1][-1]=list("gffee")
  n-=5
for i in range(0,n,2):
  a[i][i],a[i][i+1]="a","a"
  a[i+1][i],a[i+1][i+1]="b","b"
if n%4==0:
  for i in range(0,n,2):
    a[n-i-2][i],a[n-i-2][i+1]="c","d"
    a[n-i-1][i],a[n-i-1][i+1]="c","d"
else:
  for i in range(0,n-2,2):
    a[i][i+2],a[i][i+3]="c","d"
    a[i+1][i+2],a[i+1][i+3]="c","d"
  a[n-2][0],a[n-2][1]="c","d"
  a[n-1][0],a[n-1][1]="c","d"
for i in a:print("".join(i))


Measured memory_bytes: 12020
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "cmath"
#include "random"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	vector<int>v(4);
	for (int i = 0; i < 4; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	N += v[1] + v[2] + v[3];
	cin >> v[0];
	cin >> v[1];
	N += max(v[0], v[1]);
	cout << N << endl;
	return 0;
}


Measured memory_bytes: 3212
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int A,B,C;
	cin>>A>>B>>C;
	if (C>A && C<B || C>B && C<A){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 1000001
#define M 1000000007
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define Y cout<<"YES\n";
#define N cout<<"NO\n";
#define print(x)                 cout<<#x<<": "<<x<<endl;
#define print2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl;
#define print3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define print4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define print5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define print6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;

int main()
{
    fast
    lli n;
    cin>>n;
    lli x=0;
    vector<lli> v(n);
    for(lli i=0;i<n;i++)
    {
        cin>>v[i];
        x=x^v[i];
    }
    for(lli i=0;i<n;i++)
    {
        cout<<(x^v[i])<<" ";
    }
}
//a+b=a?b+2?(a&b)
//a+b==(a&b)+(a|b)
//__builtin_popcount(number)
//cout<<fixed<<setprecision(8)<<output<<"\n";



Measured memory_bytes: 4740
#include<bits/stdc++.h>
#define MOD 1000000007
#define N 405
using namespace std;

int n,c,a[N],b[N],dp[N][N],pre[N][N],us[N][N];

int dfs(int now,int rem) {

  int yol=0;
  if(now>n) return !rem;
  if(~dp[now][rem]) return dp[now][rem];
  for(int i=(now<n?0:rem);i<=rem;i++) {
    int alt=dfs(now+1,rem-i);
    int no=(pre[i][b[now]]+MOD-pre[i][a[now]-1])%MOD;
    yol=(yol+(1ll*alt*no)%MOD)%MOD;
  }
  return dp[now][rem]=yol;

}

void init() {

  for(int i=0;i<=N-5;i++) {
    for(int j=1;j<=N-5;j++) {
      if(i) {
        us[i][j]=(1ll*us[i-1][j]*j)%MOD;
      }
      else {
        us[i][j]=1;
      }
      pre[i][j]=(pre[i][j-1]+us[i][j])%MOD;;
    }
  }

}

int main() {

  memset(dp,-1,sizeof(dp));
  init();
  scanf("%d %d",&n,&c);
  for(int i=1;i<=n;i++) {
    scanf("%d",a+i);
  }
  for(int i=1;i<=n;i++) {
    scanf("%d",b+i);
  }
  printf("%d",dfs(1,c));
}


Measured memory_bytes: 2176
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(ll i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
//typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
class DIJ{
	public:
	struct edge{
		int to,cost;
	};
	vector<vector<edge> >G;
	int n;
	vi d;//distance
	DIJ(int size){
		n=size;
		G=vector<vector<edge> >(n);
	}
	void add_edge(int a,int b,int c){
		edge e={b,c},ee={a,c};
		G[a].pb(e);
//		G[b].pb(ee);
	}
	void dij(int s){
		d=vi(n,inf);
		d[s]=0;
		priority_queue<pii>q;
		q.push(pii(0,s));
		while(!q.empty()){
			pii p=q.top();
			q.pop();
			int pos=p.second,cost=-p.first;
			if(cost>d[pos])continue;
			rep(i,G[pos].size()){
				edge e=G[pos][i];
				int to=e.to;
				int nowcost=cost+e.cost;
				if(nowcost<d[to]){
					d[to]=nowcost;
					q.push(pii(-d[to],to));
				}
			}
		}
	}
};
int main(){
	int n;
	cin>>n;
	DIJ dij(n);
	rep(i,n){
		dij.add_edge(i,(i+1)%n,1);
		dij.add_edge(i,(i*10)%n,0);
	}
	
	dij.dij(1);
	cout<<1+dij.d[0]<<endl;
}






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

using namespace std ;

map < char , int > mp1 ;

int main ()
{
    string s ;
    cin >> s ;
    for ( int i = 0 ; i < s . size ( ) ; ++ i ){
        mp1 [ s [ i ] ] ++ ;
    }
    for ( char u = 'a' ; u <= 'z' ; ++ u ){
        if ( mp1 [ u ] % 2 == 1 ){
            cout << "No" ;
            return 0 ;
        }
    }
    cout << "Yes" ;
    return 0 ;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int r,g,b,n;
    Scd3(r,g,b);
    Scd(n);

    ll ans = 0;
    for (int i = 0; i < n+1; i+= r){
        for( int j = 0; i+j < n+1; j+= g ){
            if( (n-i-j) % b == 0 ) ans++;
        }
    }

    printf ("%llu\n", ans);

    return 0;
}



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

using namespace std;

int n;
int a;
vector<int> x;

map<tuple<int, int, int>, long long> dp;

long long dfs(int now, int select, int sum) {
	if (now == n) {
		return select && (select * a == sum);
	}
	if (sum > select * a) {
		return 0;
	}
	auto status = make_tuple(now, select, sum);
	if (dp.count(status)) return dp[status];
	return dp[status] = dfs(now + 1, select + 1, sum + x[now]) + dfs(now + 1, select, sum);
}

void hawawa()
{
	cin >> n >> a;
	x.resize(n);
	for (auto&& i : x) {
		cin >> i;
	}
	sort(begin(x), end(x));
	cout << dfs(0, 0, 0) << "\n";
}

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


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

		String S = sc.next();
		if( S.equals("SUN") ){
			System.out.println("7");
		}
		if( S.equals("MON") ){
			System.out.println("6");
		}
		if( S.equals("TUE") ){
			System.out.println("5");
		}
		if( S.equals("WED") ){
			System.out.println("4");
		}
		if( S.equals("THU") ){
			System.out.println("3");
		}
		if( S.equals("FRI") ){
			System.out.println("2");
		}
		if( S.equals("SAT") ){
			System.out.println("1");
		}
	}
}


Measured memory_bytes: 23636
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = s.length();
        for (int i = 0; i < n; i++) {
            System.out.print("x");
        }
        System.out.println();
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


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

  VV a(2, V(3));
  cin >> a[0] >> a[1];

  Vll dp(n+1);
  rep(i, n+1) {
    dp[i] = i;
    rep(j, 3) if (i >= a[0][j]) chmax(dp[i], dp[i-a[0][j]] + a[1][j]);
  }

  ll m = dp[n];
  dp = Vll(m+1);
  rep(i, m+1) {
    dp[i] = i;
    rep(j, 3) if (i >= a[1][j]) chmax(dp[i], dp[i-a[1][j]] + a[0][j]);
  }
  
  cout << dp[m] << endl;
  return 0;
}


Measured memory_bytes: 195584
dy = [1, 0, -1, 0, 1, -1, 1, -1]
dx = [0, 1, 0, -1, 1, 1, -1, -1]

H, W = map(int, input().split())
field = []

for i in range(H):
    field.append(list(input()))

for y in range(H):
    for x in range(W):

        if field[y][x] == '#':
            continue

        cnt = 0

        for k in range(8):
            ny = y + dy[k]
            nx = x + dx[k]

            if ny<0 or H<=ny or nx<0 or W<=nx:
                continue

            if field[ny][nx] == '#':
                cnt += 1

        field[y][x] = str(cnt)

for y in range(H):
    print("".join(field[y]))

Measured memory_bytes: 3188
def subtraction(a,b):
    return a-b


# env num
FAVNUM = 753

# get input
S = str(input())

# get length
l = len(S)

for i in range(0,l-2):
    if i == 0:
        min_num = abs(subtraction(int(S[i:i+3]),FAVNUM))
    else:
        tmp = abs(subtraction(int(S[i:i+3]),FAVNUM))
        min_num = min(min_num,tmp)

print(min_num)


Measured memory_bytes: 3060
x, y , a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)

a = sorted(p[:x] + q[:y] + r, reverse=True)[:x+y]

print(sum(a))

Measured memory_bytes: 23200
N, M = gets.split.map(&:to_i)
edges = Array.new(N){Hash.new}
M.times do
    a, b = gets.split.map(&:to_i)
    edges[a-1][b-1] = true
    edges[b-1][a-1] = true
end
Q = gets.to_i
vs, ds, cs = [], [], []
Q.times do |i|
    vs[i], ds[i], cs[i] = gets.split.map(&:to_i)
    vs[i] -= 1
end

ans = Array.new(N, 0)
width = Array.new(N, -1)
(Q-1).downto(0) do |q|
    v, d, c = vs[q], ds[q], cs[q]
    next if width[v] >= d
    ans[v] = c if ans[v] == 0
    width[v] = d
    updated = [v]
    (d-1).downto(0) do |i|
        nup = []
        updated.each do |src|
            edges[src].each do |dst, _|
                next if width[dst] >= i
                ans[dst] = c if ans[dst] == 0
                width[dst] = i
                nup.push(dst)
            end
        end
        break if nup.length == 0
        updated = nup
    end
end

puts ans

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  set<int> s;
  rep(i, 3) {
    int a; std::cin >> a;
    s.insert(a);
  }
  if (s.size() == 2)
    std::cout << "Yes" << "\n";
  else
    std::cout << "No" << "\n";
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(2e3 + 5);

ll n;
int l[MAX_N];

ll count_exclude(int i, int j) {
  int summation = l[i] + l[j];

  int index = lower_bound(l, l + n, summation) - l;

  ll part = (ll)(n - index);

  ll subtraction;

  if (i >= index && j >= index) {
    subtraction = -2;
  } else if (i >= index || j >= index) {
    subtraction = -1;
  } else {
    subtraction = 0;
  }

  return part - subtraction;
}

int main(void) {
  // Here your code !
  scanf("%lld", &n);

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

  sort(l, l + n);

  ll whole = n * (n - 1) * (n - 2) / 6;

  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      whole -= count_exclude(i, j);
    }
  }

  ll ans = whole;

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int func(int x, int y, int op)
{
  if (op == 0) {
    return x + y;
  }
  else {
    return x - y;
  }
}

char pm(int op)
{
  if (op == 0) {
    return '+';
  }
  else {
    return '-';
  }
}

int main()
{
  int N;
  cin >> N;
  int A, B, C, D;
  A = N / 1000;
  N -= A * 1000;
  B = N / 100;
  N -= B * 100;
  C = N / 10;
  D = N % 10;
  bool found = false;
  for (int i = 0; i <= 1 ; i++) {
    for (int j = 0; j <= 1 ; j++) {
      for (int k = 0; k <= 1 ; k++) {
        int result = func(func(func(A, B, i), C, j), D, k);
        if (result == 7) { 
          cout << A << pm(i) << B << pm(j) << C <<pm(k) << D
            << "=" << result << endl;
          found = true;
          break;
        }
      }
      if (found) break;
    }
    if (found) break;
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main(){
    stack<long> s;
    vector<pair<long, long> > v;
    string ch;
    long j, sub, sum = 0;
    cin>>ch;
    for (long i = 0; ch[i]; i++){
        if (ch[i] == '\\') s.push(i);
        else if (ch[i] == '/' && !s.empty()){
            j = s.top();
            s.pop();
            sub = i - j;
            sum += sub;
            while (!v.empty() && v.back().first > j){
                sub += v.back().second;
                v.pop_back();
            }
            v.push_back(make_pair(j, sub));
        }
    }
    cout << sum << endl << v.size();
    for (int i = 0; i < v.size(); i++) cout << " " << v[i].second;
    cout << endl;
    return 0;
}


Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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(){
    ll n,m;
    cin>>n>>m;
    ll ac=0,wa=0;
    vector<bool> solved(n+1,false);
    vector<ll> submit(n+1,0);
    rep(i,m){
        ll p; string s;
        cin>>p>>s;
        if(s=="AC" && !solved[p]){
            ac++;
            wa+=submit[p];
            solved[p]=true;
        }else{
            submit[p]++;
        }
    }
    cout<<ac<<' '<<wa<<endl;
}

Measured memory_bytes: 1024
N, M, X = map(int,input().split())
A = list(map(int,input().split()))

ans1 = 0
for i in range(X,N + 1):
  if i in A:
    ans1 += 1

ans2 = 0
for i in reversed(range(X)):
  if i in A:
    ans2 += 1

print(min(ans1,ans2))

Measured memory_bytes: 3064
// In The Name Of Godd
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<string> vs;
typedef pair<ll, ll> ii;
typedef pair<int, ii> iii;
typedef pair<double, double> dd;
typedef pair<dd, double> ddd;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<dd> vdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vii> vvii;

#define forn(i, n) for (ll i = 0; i < n; i++)
#define forr(i, n) for (ll i = n; i >= 0; i--)
#define fore(i, x, n) for (ll i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define inf 100000000000
#define eps 1e-9

const int maxk = 1e5 + 10;
const int maxn = 110;

ll dp[maxk][maxn];
int n, k;
ll mod = 1e9 + 7;

void add(ll &a, ll b) {
    a += b;
    if (a >= mod) a -= mod;
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> k;
    vi nms(n + 1);
    forn(i, n) cin >> nms[i + 1];
    dp[0][0] = 1;
    vi ps(k + 1);
    forn(i, n + 1) {
        forn(j, k + 1) {
            ll cur = ps[j];
            if(j - nms[i] - 1 >= 0) cur -= ps[j - nms[i] - 1];
            add(dp[j][i], cur);
        }
        ps[0] = dp[0][i];
        forn(j, k + 1) if(j) ps[j] = 0, add(ps[j], (ps[j - 1] + dp[j][i]) % mod);
    }
    assert(dp[k][n] + mod >= 0);
    cout << ((dp[k][n] + mod) % mod) << endl;
}


Measured memory_bytes: 87040
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val k = sc.nextInt()
    val q = sc.nextInt()
    val count = Array(n) {0}
    repeat(q) {
        val a = sc.nextInt()
        count[a - 1]++
    }
    repeat(n) {
        val score = k - (q - count[it])
        println(if (score > 0) "Yes" else "No")
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1000000000 + 7;
const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;


int h, w;
char g[2005][2005];
int dy[4] = {0, 1, 0, 1};
int dx[4] = {0, 0, 1, 1};
vector<vector<int>> grid(2005, vector<int>(2005));

struct Rectangle {int height, pos;};

int largest_hist(int size, vector<int> &hist) {
    stack<Rectangle> s;
    int maxv = 0;
    hist[size] = 0;

    for (int i = 0; i <= size ; i++) {
        Rectangle rect;
        rect.height = hist[i];
        rect.pos = i;

        if (s.empty()) {
            s.push(rect);
        }
        else {
            if (s.top().height < rect.height) s.push(rect);
            else if (s.top().height > rect.height) {
                int target = i;
                while (!s.empty() && s.top().height >= rect.height) {
                    Rectangle pre = s.top(); s.pop();
                    int area = (pre.height + 1) * (i - pre.pos + 1);
                    maxv = max(maxv, area);
                    target = pre.pos;
                }
                rect.pos = target;
                s.push(rect);
            }
        }
    }
    return maxv;
}

int largest_rect(int h, int w, vector<vector<int>> &grid) {
    vector<vector<int>> hist(h, vector<int>(w + 1));
    for (int j = 0; j < w; j++) {
        for (int i = 0; i < h; i++) {
            if (grid[i][j] == 1) {
                hist[i][j] = 0;
            }
            else {
                hist[i][j] = (i > 0) ? hist[i - 1][j] + 1 : 1;
            }
        }
    }

    int ret = 0;
    for (int i = 0; i < h; i++) {
        ret = max(ret, largest_hist(w, hist[i]));
    }
    return ret;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    rep(i, h)rep(j, w) cin >> g[i][j];
    rep(i, h - 1)rep(j, w - 1) {
        int tmp = 0;
        rep(k, 4) {
            tmp += g[i + dy[k]][j + dx[k]] == '.' ? 1 : 0;
        }
        if (tmp % 2 == 1) grid[i][j] = 1;
    }
    cout << max({h, w, largest_rect(h - 1, w - 1, grid)}) << endl;
}


Measured memory_bytes: 66944
#include <cstdio>
#include <set>
#define M(x,y)std::make_pair(x,y)
typedef std::set<std::pair<int,int> >S;
int n,m,x,y,x1,y1,x2,y2,dx,dy;main(){for(;scanf("%d",&n),n;printf("%d\n",n)){
S s;S::iterator it1,it2;
for(;n;n--)scanf("%d%d",&x,&y),s.insert(M(x,y));
for(it1=s.begin();it1!=s.end();it1++)
	for(x1=it1->first,y1=it1->second,it2=it1,it2++;it2!=s.end();it2++)
		if(x2=it2->first,y2=it2->second,dx=x2-x1,dy=y2-y1,m=dx*dx+dy*dy,m>n&&s.find(M(x1-dy,y1+dx))!=s.end()&&s.find(M(x2-dy,y2+dx))!=s.end())n=m;
}}

Measured memory_bytes: 1164