akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;

vector< vector<char> > ans(vector< vector<char> > a){
	vector< vector<char> > w;
	FOR(i,0,a.size()){
		bool add = false;
		char x = a[i][0];
		if(x=='#')add = true;
		FOR(j,0,a[i].size()){
			if(x!=a[i][j])add = true;
		}
		if(add)w.push_back(a[i]);
	}
	return w;
}

vector< vector<char> > rot90(vector< vector<char> > a){
	vector< vector<char> > w;
	ll h = a.size();
	ll ww = a[0].size();
	w.resize(ww);
	FOR(i,0,ww)w[i].resize(h);
	FOR(i,0,h){
		FOR(j,0,ww){
			w[j][i] = a[i][j];
		}
	}
	return w;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector< vector<char> > a;
	ll h,w;
	cin>>h>>w;
	FOR(i,0,h){
		vector<char> wv;
		a.push_back(wv);
		FOR(j,0,w){
			char x;
			cin>>x;
			a[i].push_back(x);
		}
	}
	a = ans(a);
	a = rot90(a);
	a = ans(a);
	a = rot90(a);
	FOR(i,0,a.size()){
		FOR(j,0,a[i].size()){
			cout<<a[i][j];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

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

ll N, K;
map<ll, ll> mp;

int main() {
  cin >> N >> K;
  repe(i, 1, N) {
    ll a, b;
    cin >> a >> b;
    mp[a] += b;
  }

  for (auto e : mp) {
    if (K <= e.second) {
      cout << e.first;
      return 0;
    } else {
      K -= e.second;
    }
  }
}


Measured memory_bytes: 7460
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  ll N,M;
  cin >> N >> M;
  if(N > 1&& M > 1){
    cout << (N-2) * (M-2) << endl;
  }else if(N == 1 && M == 1){
    cout << 1 << endl;
  }else{
    cout << max(N,M) - 2 << endl;
  }
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,i,j,k,n,m,x,y,ans = 0;
	string	s;

	cin >> n;
	vector<int> l(n);
	for(i=0;i<n;i++) {
		cin >> l[i];
	}
	sort(l.begin(), l.end());
	//for(i=0;i<n;i++) cout << l[i] << endl;
	for(i=n-1;i>1;i--) {
		for(j=i-1;j>0;j--) {
			int low = l[i] - l[j];
			int up = l[j];
			//cout << 'i' << i << 'j' << j << "  " << low << ' ' << up << endl;
			// low < ok <= up
			if (low >= up) continue;
			int il = upper_bound(l.begin() , l.begin() + j , low) - l.begin();
			int iu = upper_bound(l.begin() , l.begin() + j , up ) - l.begin();

			if (il <= iu) ans += iu - il;
			//cout << "il iu : " << il << ' ' << iu << endl;
			//cout << ans << endl;
		}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
k = gets.to_i
p = k / 50
q = k % 50

puts 50
base = 49 + p
if q==0
  puts 50.times.map{base}.join(" ")
else
  incr = 50 - q + 1
  decr = q
  puts (q.times.map{base + incr} + (50-q).times.map{base - decr}).join(" ")
end

Measured memory_bytes: 1788
///supercalifragilisticexpialidocious.
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cstdlib>
#include <cctype>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <utility>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <list>
#include <bitset>
#include <complex>
using namespace std;
#define f first
#define s second
#define endl '\n'
#define PB pop_back
#define pb push_back
#define mp make_pair
#define int long long
#define sz(s) (int)s.size()
#define seper(n) setprecision(n)
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a,b,sizeof a)
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef map<int , int> mii;
typedef pair<int , int> pii;
typedef map<string , int> msi;
const int MAXN = 1e5 + 10;
int n , u , v , a , b , mx , distv[MAXN] , distu[MAXN];
vector<int> adj[MAXN];
void dfs(int u , int p , int dis[MAXN])
{
	for(auto v : adj[u])
		if(v != p)
			dis[v] = dis[u] + 1 , dfs(v , u , dis);
	return;
}	
int32_t main()
{
	cin >> n >> v >> u;
	for(int i = 0 ; i < n - 1 ; i ++)
		cin >> a >> b , adj[a].pb(b) , adj[b].pb(a);
	dfs(v , 0 , distv) , dfs(u , 0 , distu);
	for(int i = 1 ; i <= n ; i ++)
		if(distv[i] <= distu[i])
			mx = max(mx , distu[i] - 1);
	return cout << mx << endl , 0;
}


Measured memory_bytes: 12544
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define dbg(x) cout << #x << ": " << x << endl;
using namespace std;

const int N = 2e5 + 10, M = 1e6 + 10;
unordered_map<int, int> cnt;
unordered_map<int, int> vis;
int a[N];

void seive() {
    for (int i = 2; i <= 100; i++) {
        for (int j = i * i; j <= 100; j += i){
            if (!vis[j]) {
                vis[j] = 1;
            }
        }
    }
    rep(i, 2, 100) {
        if (!vis[i]) dbg(i);
    }
}
int main() {
    //seive();return 0;
    int n; cin >> n;
    int mx = 0;
    rep(i, 1, n) {
        cin >> a[i];
        vis[a[i]] = 1;
        //mx = max(mx, a[i]);
    }

    rep(i, 1, n) {
        int v = a[i];
        for (int j = 1; j * j <= v; j++) {
            if (v % j == 0) {
                cnt[v] += vis[j];
                if (j * j != a[i]) cnt[v] += vis[v / j];
            }
        }
    }
    int ans = 0;
    rep(i, 1, n) {
        if (cnt[a[i]] == 1) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 39828
n = int(input())
ans_taro = 0
ans_hanako = 0

for i in range(n):
  c_taro, c_hanako = input().split()
  if c_taro > c_hanako:
    ans_taro += 3
  elif c_taro == c_hanako:
    ans_taro += 1
    ans_hanako += 1
  else:
    ans_hanako += 3

print('%d %d' %(ans_taro, ans_hanako))


Measured memory_bytes: 5596
#include <bits/stdc++.h>
//#define int long long
#define rep(i, l, r) for(int i = l; i <= r; ++ i)
using namespace std;
const int MAXN = 1e5 + 10, mod = 1e9 + 7, INF = 1e9;

signed main()
{
	int x;
	scanf("%d", &x);
	if(x == 0) puts("1");
	else if(x == 1) puts("0"); 
	return 0;
}

Measured memory_bytes: 3684
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, K, A[1010];
i64 C[1010][1010];

i64 dp[2][1010];

int main()
{
	C[0][0] = 1;
	for (int i = 1; i <= 1000; ++i) {
		C[i][0] = 1;
		for (int j = 1; j <= 1000; ++j) C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
	}
	scanf("%d%d", &N, &K);
	for (int i = 0; i < K; ++i) scanf("%d", A + i);

	int t = 0;
	for (int i = 0; i <= N; ++i) dp[t][i] = 0;
	dp[t][0] = 1;

	for (int i = 0; i < K; ++i) {
		for (int i = 0; i <= N; ++i) dp[1 - t][i] = 0;
		for (int j = 0; j <= N; ++j) {
			if (dp[t][j] == 0) continue;
			int mx = min(N - j, A[i]);
			int rem = N - j;
			for (int k = 0; k <= mx; ++k) {
				ADD(dp[1 - t][j + k], dp[t][j] * C[rem][k] % MOD * C[N - k][A[i] - k]);
			}
		}
		t = 1 - t;
	}
	printf("%lld\n", dp[t][N]);
	return 0;
}


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main (void) {
    int N,M;
    cin>>N>>M;
    vector<int> p(N);
    REP(i,N) {
        int t;
        cin>>t;
        p[i] = t-1;
    }
    UnionFind uf(N);
    REP(i,M) {
        int a,b;
        cin>>a>>b;
        a--;b--;
        uf.unite(a,b);
    }
    int ans = 0;
    REP(i,N) {
        int n = p[i];
        if (uf.find(i) == uf.find(n)) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
S = input()
if S == "SUN":
    print(7)
elif S == "MON":
    print(6)
elif S == "TUE":
    print(5)
elif S == "WED":
    print(4)
elif S == "THU":
    print(3)
elif S == "FRI":
    print(2)
elif S == "SAT":
    print(1)


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

using namespace std;

string s;
int n;

int main(){
  cin >> s;
  n = s.size();
  s = " " + s;
  int r = 0;
  for(int i = 1; i <= n/2 + n%2; ++i){
    if(s[i] != s[n - i + 1]) ++r;
  }
  cout << r;
  return 0;
}


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




int main(void){
   int n,m;
   cin>>n>>m;
   vector<int> a(n),b(n);
   for(int i=0;i<m;i++){
      int p;
      string s;
      cin>>p>>s;
      --p;
      if(a[p])continue;
      if(s=="AC"){
         a[p]=1;
      }
      else{
         b[p]++;
      }
   }
   int x=0,y=0;
   for(int i=0;i<n;i++){
      x+=a[i];
      if(a[i])y+=b[i];

   }
cout<<x<<" "<<y<<endl;


return 0;
}




Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
#define MAXN 400010
const ll MOD = 998244353;
const ll INF = 1e15;

ll N;
vi V[MAXN];
ll a,b;
ll dst[MAXN];
vi O;
vi E;
ll out[MAXN];

void dfs(int x, int p){
	for (auto v:V[x])if(v!=p){
		dst[v] = dst[x]+1;
		dfs(v,x);
	}
}

ll done[MAXN];

int main(){
	cin>>N;
	for (int i=0;i<=N;++i){
		cin>>a>>b;
		V[a].pb(b);
		V[b].pb(a);
	}
	dfs(1,-1);

	for (int i=1;i<=N;++i){
		if (dst[i]%2==1)O.pb(i);
		else E.pb(i);
	}
	if (SZ(O) > SZ(E))swap(O,E);

	ll h = N/3;

	if (SZ(O) > h){
		ll t=1;
		while (SZ(O) && t <= N){
			out[O.back()] = t;
			done[t] = 1;
			O.pop_back();
			t += 3;
		}
	}
	if (SZ(O) > h){
		ll t=2;
		while (SZ(O) && t <= N){
			out[O.back()] = t;
			done[t] = 1;
			O.pop_back();
			t += 3;
		}
	}
	ll t=3;
	while (SZ(O) && t <= N){
		out[O.back()] = t;
		done[t] = 1;
		O.pop_back();
		t += 3;
	}
	vi rem;
	for (int i=1;i<=N;++i)if (!done[i])rem.pb(i);
	for (int i=1;i<=N;++i){
		if (out[i] == 0){out[i] = rem.back();rem.pop_back();}
	}
	for (int i=1;i<=N;++i)cout<<out[i]<<' ';
}

Measured memory_bytes: 33004
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    string x;
    cin >> x;

    int count = x.size();
    stack <int> st;

    for (int i = 0; i < x.size(); i++) {
        if (x[i] == 'S') {
            st.push(0);
        } else if (x[i] == 'T') {
            if (st.size() > 0) {
                st.pop();
                count -= 2;
            }
        }
    }

    cout << count << "\n";
    return 0;
}

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

int main() {
  int n,k,d,a,ans;
  cin >> n >> k;
  ans = n;
  vector<bool> sunuke(n);
  for(int i = 0; i < k; i++){
    cin >> d;
    for(int j = 0; j < d; j++){
      cin >> a;
      if(!sunuke.at(a - 1)){
        ans--;
        sunuke.at(a - 1) = true;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
N = int(input())
R = {i:0 for i in range(1,N+1)}
A = list(map(int,input().split()))
for i in range(1,N+1):
    R[i] = A[i-1]
count = 0
for i in range(1,N+1):
    if i == R[R[i]]:
        count += 1
print(count//2)

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

typedef long long ll;
using namespace std;

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

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

struct Test {
    ll b, l, u;
    Test(ll b, ll l, ll u) : b(b), l(l), u(u) {}
    inline ll D(const ll &a) { return (a < b ? l : u) * (a - b); }
};

ll n, x, d0;
V<Test> tests;

bool isok(ll mid) {
    ll q = mid / x, r = mid % x;
    ll sum = d0;
    rep(i, q) {
        sum -= tests[i].D(0);
        sum += tests[i].D(x);
    }
    rep(i, n) {
        ll s = sum;
        if(i < q) {
            s -= tests[i].D(x);
            s += tests[i].D(r);
            s -= tests[q].D(0);
            s += tests[q].D(x);
        } else {
            s -= tests[i].D(0);
            s += tests[i].D(r);
        }
        if(s >= 0) return true;
    }
    return false;
}

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

    cin >> n >> x;
    rep(i, n) {
        ll b, l, u;
        cin >> b >> l >> u;
        tests.push_back(Test(b, l, u));
    }
    sort(ALL(tests),
         [&](Test a, Test b) { return a.D(x) - a.D(0) > b.D(x) - b.D(0); });
    for(Test t : tests)
        d0 += t.D(0);
    if(d0 >= 0) {
        cout << 0 << endl;
        return 0;
    }
    ll ng = 0, ok = n * x;
    while(ng + 1 < ok)
        (isok(ng + ok >> 1) ? ok : ng) = ng + ok >> 1;
    cout << ok << endl;

    return 0;
}

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

typedef long long ll;
#define MAX 12345
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)

int main()
{
    string str;

    while(cin>>str){
        ll l=str.size();
        while(l--){
            cout << str[l];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1172
#include <stdio.h>
int main(){
int num, score[100], i, max, min, sum, ave;
while(1){
	scanf("%d",&num);
		if(num==0) break;
for( i=0 ; i<num ; i++ ){
	scanf("%d",&score[i]);
}
max = min = score[0];
    for(i=1;i<num;i++){
      if(max < score[i])
    max = score[i];
      if(min > score[i])
    min = score[i];
}
sum=0;
for( i=0 ; i<num ; i++){
sum+=score[i];
}
sum = sum - max - min;
ave = sum / (num-2);
printf("%d\n",ave);
}
return 0;
}

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

#define M 1000000007
#define MM 998244353 
#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define PI 3.1415926536
#define INF 2e18
#define endl "\n"
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
ll dp[10004],a[1004],b[1004],n;
int main()
{
	ios_base::sync_with_stdio(0);	
	cin.tie(0);
	cout.tie(0);
	ll h,i,j;
	cin>>h>>n;
	for(i=1;i<=n;++i)
		cin>>a[i]>>b[i];
	ll ans=2e18;
	dp[0]=0;
	for(i=1;i<=h;++i)
	{
		dp[i]=2e18;
		for(j=1;j<=n;++j)
		{
			if(a[j]>=i)
			{
				dp[i]=min(dp[i],b[j]);
			}
			else
				dp[i]=min(dp[i-a[j]]+b[j],dp[i]);
		}
	}
	cout<<dp[h];
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <functional>
#include <list>
#include <utility>
#include <map>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))
const ll mod = 1000000007;
const double eps = 1e-10;
const int MAX = 200000;

int main() {
	int n, k;
  vector<int> v;
	cin >> n;
  rep(i,n) {
    cin >> k;
    v.push_back(k);
  }
  sort(v.begin(), v.end());

  double ans = ((double) v.at(0) + (double) v.at(1)) / 2.0;
  for(int i = 2; i < n; i++) {
    ans = (ans + (double) v.at(i)) / 2.0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int N;
  std::cin >> N;
  long long ans = 0;
  for (int i: range(1, N + 1)) {
    if (i % 3 != 0 && i % 5 != 0) {
      ans += i;
    }
  }
  std::cout << ans << '\n';
  return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 1000000007ULL
#define cINF ((1ll<<62)-1)
#define cINFINT ((1<<30)-1)


int main()
{
	cin.tie( 0 ); ios::sync_with_stdio( false );
	ll n;cin>>n;
	vector<ll> v( n, 0 );
	REP(i,n) cin>>v[i];

	sort(ALL(v));
	cout<< v[n/2] - v[n/2-1] << endl;

	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
import java.lang.*;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (a!=b){
            if (c>(a-b))
                System.out.println(c-(a-b));
            else
                System.out.println(0);
        }
        else
            System.out.println(c);
    }
}


Measured memory_bytes: 35832
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define int long long

using namespace std;

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

const int N = 300000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

int n, a[N], b[N], fen[N];
void add(int id, int x){
	if (id == 0) cout << "Fuck" << endl;
	for (; id < N; id += id & (-id)) fen[id] += x;
}

int get(int id){
	int res = 0;
	for (; id > 0; id -= id & (-id)) res += fen[id];
	return res;
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++){
		if (i % 2 == 1) cin >> a[i / 2 + 1];
		else cin >> b[i / 2];
		if (i % 2 == 1) if (a[i / 2 + 1] % 2 == 0) return cout << "No", 0;
		if (i % 2 == 0) if (b[i / 2] % 2 == 1) return cout << "No", 0;
	}
	int ans = 0;
	for (int i = 1; i <= (n / 2) + (n % 2); i++){
		ans += i - 1 - get(a[i] - 1);
		add(a[i], 1);
	}
	memset(fen, 0, sizeof fen);
	for (int i = 1; i <= (n / 2); i++){
		ans += i - 1 - get(b[i] - 1);
		add(b[i], 1);
	}
//	cout << ans << '\n';
	memset(fen, 0, sizeof fen);
	int res = 0;
	for (int i = 1; i <= n; i++){
		if (i % 2 == 1) res += i - 1 - get(a[i / 2 + 1] - 1);
		else res += i - 1 - get(b[i / 2] - 1);
		if (i % 2 == 1) add(a[i / 2 + 1], 1);
		else add(b[i / 2], 1);
//		cout << res << '\n';
	}
//	cout << res << '\n';
	if (res % 3 != 0) return cout << "No", 0;
	cout << (res / 3 == ans?"Yes":"No");
//	cout << (ans % 3 == 0?"Yes":"No");










	return 0;
}


Measured memory_bytes: 6400
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>


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

int a;

int main(){
    cin >> a;
    cout << a + a*a + a*a*a << endl;


return 0;
}

Measured memory_bytes: 3632
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(int N, long[] x, long[] y) {
    auto engines = zip(x, y)
        .map!(t => tuple(atan2(t[1].to!real, t[0].to!real), [t[0], t[1]]))
        .array
        .sort()
        .map!(t => t[1]);

    auto cum = new long[][](N * 2, 2);
    cum[0] = engines.front;
    foreach (i, v; chain(engines, engines).enumerate.drop(1))
        cum[i][] = v[] + cum[i - 1][];

    real ans = 0;
    for (int i = 1; i < 2 * N; i++) {
        for (int j = i; j < min(2 * N, i + N); j++) {
            long[] temp = [0, 0];
            temp[] = cum[j][] - cum[i - 1][];
            ans = ans.max(
                temp.map!"a * a"
                .sum
                .to!real
                .sqrt);
        }
    }

    return format("%.11f", ans);
}

void main() {
    auto input = stdin.byLine.map!split.joiner;

    int N;
    N = input.front.to!int;
    input.popFront;

    long[] x = new long[](cast(size_t) (N));
    long[] y = new long[](cast(size_t) (N));
    foreach (i; 0 .. cast(size_t) (N)) {
        x[i] = input.front.to!long;
        input.popFront;
        y[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, x, y);
    else
        solve(N, x, y).writeln;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int n;
  cin >> n;
  vi32 a(n);
  cin >> a;
  rep(i, n) a[i]--;
  set<int, less<int>> rs = {n};
  set<int, greater<int>> ls = {-1};
  vi32 indices(n);
  rep(i, n) indices[a[i]] = i;
  i64 ans = 0;
  rep(i, n) {
    int idx = indices[i];
    int r = *rs.lower_bound(idx);
    int l = *ls.lower_bound(idx);
    ans += (i64) (r - idx) * (idx - l) * (i + 1);
    rs.insert(idx);
    ls.insert(idx);
  }
  cout << ans << '\n';
}


Measured memory_bytes: 20608
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include<iomanip>
#include<sstream>
#include <fstream>
#define ll long long
#define pb push_back
#define clr(a, b) memset((a), (b), sizeof(a))
#define debugs(x) cout << "Line" << __LINE__ << "	" << #x << "=" << x << endl
#define break break
#define continue continue
#define itn int
#define endl '\n'
#define Endl endl
#define vint vector<int>
#define pii pair<int, int> 
using namespace std;

int n, k, m;
void solve(int T)
{
	cin >> n;
	string s;
	map<string, int>mp;
	//cout << n%1000 << endl;
	while (n--)
	{
		cin >> s;
		mp[s]++;
	}
	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	int numoftest = 1;

	//cin >> numoftest;


	for (int siven = 1; siven <= numoftest; ++siven)
		solve(siven);
	return 0;
}

/*


*/

Measured memory_bytes: 3232
#include<stdio.h>

int main(void){

  int n = 0;
  int sum = 0;
  int buffer = 0;

  scanf("%d", &n);

  buffer = n;
  while(n>0){

    sum = sum + n%10;
    n /= 10;

  }

  if(buffer % sum == 0){

    printf("Yes\n");

  }else{

    printf("No\n");

  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <algorithm>
#include <set>

using namespace std;

using ll = long long;

inline ll min(ll a, ll b) {
	return a < b ? a : b;
}

const int Max = 1e5 + 12;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, A[Max], B[Max];
	ll monsters = 0;
	cin >> N;
	for (int i = 1; i <= N + 1; ++i) {
		cin >> A[i];
	}
	for (int i = 1; i <= N; ++i) {
		cin >> B[i];
	}
	int i = N;
	while (i >= 1) {
		if (A[i + 1] >= B[i]) {
			monsters += B[i];
			A[i + 1] -= B[i];
			B[i] = 0;
		}
		else {
			monsters += A[i + 1];
			B[i] -= A[i + 1];
			A[i + 1] = 0;
			if (A[i] >= B[i]) {
				A[i] -= B[i];
				monsters += B[i];
				B[i] = 0;
			}
			else {
				B[i] -= A[i];
				monsters += A[i];
				A[i] = 0;
			}
		}
		--i;
	}
	cout << monsters;
	//system("pause");
	return 0;
}


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

int main(){
  string S;
  cin >>S;
  int sum = 700;
  
  if(S[0]=='o') sum+=100;
  if(S[1]=='o') sum+=100;
  if(S[2]=='o') sum+=100;
  
  int ans = sum;
  cout <<ans<< endl;
}


Measured memory_bytes: 256
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final List<Integer> list = IntStream.range(0, scanner.nextInt())
                .mapToObj(i -> scanner.nextInt())
                .collect(Collectors.toList());

        final Map<Integer, Integer> index = new HashMap<>();
        for (int i = 0; i < list.size(); i++) {
            index.put(list.get(i), i);
        }

        Collections.sort(list);
        int count = 0;
        for (int i = 0; i < list.size(); i++) {
            final int tmp = list.get(i);
            if (i % 2 != index.get(tmp) % 2) {
                count++;
            }
        }

        System.out.println(count / 2);
    }
}


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


int main() {
  int N;
  cin>>N;
  
  vector<int> B(N-1);
  for(int i=0;i<N-1;i++){
    cin>>B.at(i);
  }
  
  vector<int> A(N);
  A.at(0)=B.at(0);
  for(int i=0;i<N-1;i++){
    A.at(i+1)=B.at(i);
    if(A.at(i)>=B.at(i)) A.at(i)=B.at(i);
  }
  int sum=0;
  for(int i=0;i<N;i++){
    sum+=A.at(i);
  }
  cout<<sum<<endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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(){
    vector<ll> a(7);
    rep(i,7) cin >> a[i];
    ll ans=a[1],cnt=0;
    vector<ll> use={a[0],a[3],a[4]};
    if (use[0]==0||use[1]==0||use[2]==0){
        rep(i,3) ans+=use[i]/2*2;
        cout << ans << endl;
        return 0;
    }
    rep(i,3) if (use[i]%2==1) ++cnt;
    rep(i,3) ans+=(use[i]-1)/2*2;
    if (cnt==0) ans+=6;
    if (cnt==1) ans+=4;
    if (cnt>=2) ans+=3;
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String S = scan.nextLine();
    String T = scan.nextLine();
    int length = 0;
    int ans = 0;

    length = S.length();

    for (var i = 0; i < length; i++) {
      if (S.charAt(i) != T.charAt(i)){
        ans++;
      }
    }


    System.out.println(ans);
    scan.close();
  }
}

Measured memory_bytes: 42904
#include <stdio.h>
typedef long long LL;
int main()
{
	LL n,a[5],mx = 0;
	scanf("%lld",&n);
	for(int i = 0;i < 5;i++){
		scanf("%lld",&a[i]);
		if((n - 1) / a[i] > mx)
			mx = (n-1) / a[i];	
	}
	printf("%lld\n",mx + 5);
	return 0;	
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,x,cnt=0;
  cin>>n;
  int arr[n]={0};
  for(int i=0;i<n;i++)cin>>arr[i];
int ans=0;
  for(int i=0;i<n-1;i++)
  {
      if(arr[i]>=arr[i+1])cnt++;
      else cnt=0;
      if(cnt>ans)ans=cnt;
  }
  cout<<ans;
}


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

int main() {
	string s;
	cin >> s;
	int n = s.size();
	int v[26]={};
	for (int i = 0;i < n;i++)v[s[i] - 'a']++;
	string ans = "Yes";
	for (int i = 0;i < 26;i++) {
		if (v[i] % 2 != 0) {
			ans = "No";
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
int n,a,b,i,x[200005],y[200005],sd[200005],zz[200005],book[200005],ans,flag;
int top,nex[400005],to[400005],fir[200005],top2,nex2[400005],to2[400005],fir2[200005];
void lj(int u,int v){
	top++;
	nex[top]=fir[u];
	fir[u]=top;
	to[top]=v;
}
void lj2(int u,int v){
	top2++;
	nex2[top2]=fir2[u];
	fir2[u]=top2;
	to2[top2]=v;
}
void ss(int u,int v,int w){
	sd[v]=w;
	zz[v]=u;
	for(int top1=fir[v];top1;top1=nex[top1])
		if(to[top1]!=u)
			ss(v,to[top1],w+1);
}
void ss2(int u,int v,int w){
	if(sd[v]<=w)
		return;
	if(book[v]==1)
		flag=1;
	ans=max(ans,sd[v]);
	for(int top1=fir2[v];top1;top1=nex2[top1])
		if(to2[top1]!=u)
			ss2(v,to2[top1],w+1);
}
int main(){
	n=read();a=read();b=read();
	for(i=1;i<n;i++){
		x[i]=read();y[i]=read();
		lj2(x[i],y[i]);
		lj2(y[i],x[i]);
	}
	for(i=1;i<n;i++){
		x[0]=read();y[0]=read();
		lj(x[0],y[0]);
		lj(y[0],x[0]);
	}
	ss(b,b,0);
	for(i=1;i<n;i++){
		if(sd[x[i]]<sd[y[i]])
			swap(x[i],y[i]);
		if(zz[x[i]]!=y[i]&&zz[zz[x[i]]]!=y[i]&&zz[x[i]]!=zz[y[i]]){
			book[x[i]]=1;
			book[y[i]]=1;
		}
	}
	ss2(a,a,0);
	if(flag==1)
		pus(-1,2);
	else
		pus(ans*2,2);
   	return 0;
}

Measured memory_bytes: 20352
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int n  = sc.nextInt();
        int cnt = 0,root_value = -1;
        ArrayList<Node> T = new ArrayList<>();
        Map<Integer,Integer> L = new HashMap<>();
        for(int i=0;i<n;i++){
            String s = sc.next();
            if(s.charAt(0)=='i') {
               int value=sc.nextInt();
               if(cnt==0) {
                   root_value=value;
                   Node v = new Node();
                   v.element(value,-1,-1,-1);
                   T.add(v);
                   L.put(value,0);
               }
               else insert(T,L,value,root_value);
               cnt++;
            }
            else{
                StringBuilder I = new StringBuilder();
                StringBuilder P = new StringBuilder();
                Order(T,L,root_value,I,P);
                System.out.println(I);
                System.out.println(P);
            }
        }
    }
    public static void Order(ArrayList<Node> T,Map<Integer,Integer> L,int now,StringBuilder I,StringBuilder P){
        int num = L.get(now);
        P.append(" "+now);
        if(T.get(num).left!=-1) Order(T,L,T.get(num).left,I,P);
        I.append(" "+now);
        if(T.get(num).right!=-1) Order(T,L,T.get(num).right,I,P);
    }
    public static void insert(ArrayList<Node> T,Map<Integer,Integer> L,int value,int root_value){
        int index = L.get(root_value);
        if(root_value>=value){
            if(T.get(index).left!=-1) insert(T,L,value,T.get(index).left);
            else{
                T.get(index).left = value;
                Node v = new Node();
                v.element(value,root_value,-1,-1);
                T.add(v);
                L.put(value,T.size()-1);
            }
        }
        else{
            if(T.get(index).right!=-1)insert(T,L,value,T.get(index).right);
            else{
                T.get(index).right = value;
                Node v = new Node();
                v.element(value,root_value,-1,-1);
                T.add(v);
                L.put(value,T.size()-1);
            }
        }
    }
    public static class Node{
        int value,parent,left,right;
        public void element(int value,int parent,int left,int right){
            this.value = value;
            this.parent = parent;
            this.left = left;
            this.right = right;
        }
    }
}


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

signed main() {
  int N, X, base = 0;
  cin >> N >> X;
  vector<int> b(N), l(N), u(N);
  vector<pair<int, int>> v;
  for (int i = 0; i < N; i++) {
    cin >> b[i] >> l[i] >> u[i];
    base += l[i] * b[i];
    v.push_back({(X - b[i]) * u[i] + l[i] * b[i], i});
  }

  sort(v.begin(), v.end(), greater<pair<int, int>>());

  auto check = [&](int mid) {
    int full = mid / X, rem = mid - full * X;
    int sum = 0;
    for (int i = 0; i < full; i++) {
      sum += v[i].first;
    }

    int mx = 0;
    for (int i = 0; i < N; i++) {
      int add;
      int j = v[i].second;

      if (rem >= b[j]) {
        add = l[j] * b[j] + (rem - b[j]) * u[j];
      } else {
        add = l[j] * rem;
      }

      if (i < full) {
        mx = max(mx, sum - v[i].first + add + (full == N ? 0 : v[full].first));
      } else {
        mx = max(mx, sum + add);
      }
    }

    return mx >= base;
  };

  int ok = N * X, ng = -1;
  while (abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    if (check(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  cout << ok << endl;
  return 0;
}


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

int main() {
  int K,A,B;
  cin >> K >> A >> B;
  bool ans = false;
  for (int i=A; i<=B; i++){
    if(i%K ==0){
      ans = true;
      break;
    }
  }
  if(ans) cout<<"OK"<<endl;
  else cout <<"NG"<<endl;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
int i,j;
#define rep(i,l,r) for(i=(l);i<(r);i++)
#define per(i,r,l) for(i=(r);i>(l);i--)
int main(){
	int kurt,koyun;
	scanf("%d%d",&koyun,&kurt);
	if(kurt>=koyun)printf("unsafe");
	else printf("safe");
	return 0;
}

Measured memory_bytes: 1700
<?php
fscanf(STDIN,"%d %d",$l,$r);
$result=99999;
for($i=$l; $i<=$r; $i++)
{
	for ($j=$i+1; $j<=$r; $j++)
	{
		$result=min($result,($i*$j)%2019);
		if($result==0)
			break 2;
	}
}
echo($result);

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
#define mod 1000000007
long long exp(long long taban, long long us) {
    long long carpan = taban;
    long long temp = us;
    long long res = 1;
    for(int i = 0;;i++){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
        if(temp == 0) break;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (((a*b)%mod)*(exp(ebob(a,b), (ll)mod-2))) % mod;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, m; cin>>n>>m;
	vector<vector<char>> vec(n, vector<char>(m));
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin>>vec[i][j];
		}
	}
	int dp[n][m] = {};
	dp[0][0] = 1;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(!i && !j) continue;
			if(!i && vec[i][j] != '#') dp[i][j] = dp[i][j-1];
			if(!j && vec[i][j] != '#') dp[i][j] = dp[i-1][j];
			if(i && j && vec[i][j] != '#'){
				dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod;
			}
		}
	}
	cout<<dp[n-1][m-1];
	return 0;
}


Measured memory_bytes: 5120
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
typedef long long int ll;
typedef long double ld;
const ll INF = (1 << 31);
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
const int MAX = 510000;
const ll MOD = 1000000007;
ll ans = 0, n,a;
ll dp[60][60][2501];
int main() {
	cin >> n >> a;
	vector<int> x(n);
	rep(i, n) {
		cin >> x[i];
		dp[i + 1][1][x[i]] = 1;
	}
	rep(i, n) {
		rep(j, n) {
			rep(k, 2501 - x[i]) {
				dp[i + 1][j][k] += dp[i][j][k];
				dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
			}
		}
	}
	rep(i, n+1) {
		ans += dp[n][i][i * a];
	}cout << ans << endl;
}

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

int main() {
    int N; long long K; cin >> N >> K;
    vector<int> A(N);
    for(int i=0; i<N; ++i) {
        cin >> A[i];
        --A[i];
    }

    vector<vector<int>> next(N, vector<int>(60));
    for(int i=0; i<N; ++i) {
        next[i][0] = A[i];
    }

    for(int k=1; k<60; ++k) {
        for(int i=0; i<N; ++i) {
            next[i][k] = next[next[i][k - 1]][k - 1];
        }
    }

    int res = 0;
    for(int k=0; k<60; ++k) {
        if(K & (1LL << k)) res = next[res][k];
    }
    cout << res + 1 << '\n';
}

Measured memory_bytes: 58692
#include <bits/stdc++.h>
 
int main()
{
	int N, M, X, Y;
	scanf("%d%d%d%d", &N, &M, &X, &Y);
	int max_x{X}, min_y{Y};
	for (int i{}; i < N; i++)
	{
		int tmp;
		scanf("%d", &tmp);
		max_x = std::max(max_x, tmp);
	}
	for (int i{}; i < M; i++)
	{
		int tmp;
		scanf("%d", &tmp);
		min_y = std::min(min_y, tmp);
	}
	if (max_x < min_y) puts("No War");
	else puts("War");
 
	return 0;
}

Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

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

        List<String> ansList = new ArrayList<>();

        // 2^30 = 1073741824
        // 2^31 = 2147483648
        long target = n;
        for (int i = 1; i <= 32; i++) {
//            System.out.println(target);
            if (Math.abs(target) % pow(2, i) != 0) {
                ansList.add("1");
                target -= pow(-2, i - 1);
            } else {
                ansList.add("0");
            }
        }

//        System.out.println(ansList);

        String ans = "";
        boolean flag = false;
        for (int i = ansList.size() - 1; i >= 0; i--) {
            if (ansList.get(i).equals("1")) {
                flag = true;
            }
            if (flag) {
                ans += ansList.get(i);
            }
        }

        if (ans.equals("")) {
            ans = "0";
        }
        System.out.println(ans);
    }

    // baseのn乗を計算を返す
    static long pow(int base, int n) {
        long ret = 1;
        for (int i = 0; i < n; i++) {
            ret *= base;
        }
        return ret;
    }
}


Measured memory_bytes: 22736
import bisect
A, B, Q = map(int, input().split())
INF = 10**18

s = [-INF] + [int(input()) for _ in range(A)] + [INF]
t = [-INF] + [int(input()) for _ in range(B)] + [INF]

# print("s", s)
# print("t", t)
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    # print(f"b{b}, d{d}")

    res = INF

    for S in [s[b-1], s[b]]:
        for T in [t[d-1], t[d]]:
            # print(f"S{S}, T{T}")
            d1, d2 = abs(S-x)+abs(T-S), abs(T-x)+abs(T-S)
            res = min(res, d1, d2)
    print(res)



Measured memory_bytes: 17648
import math
N=int(input())
c=[[0]*10 for _ in range(10)]

for n in range(1,N+1):
  size = int (math.log10(n) + 1)
  sen= n//(10**(size-1))
  matu =n %10
  c[sen][matu] +=1

count=0

for i in range(10):
  for j in range(10):
    count +=c[i][j]*c[j][i]
      
print(count)    
  

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int H, W, d;
int board[510][510];
bool pattern[1000][1000];

bool inBoard(int x, int y) {
	return x >= 0 && x < W && y >= 0 && y < H;
}

signed main() {
	cin >> H >> W >> d;

	if (d % 2) {
		rep(y, H) {
			rep(x, W) cout << ((x + y) % 2 ? 'R' : 'Y');
			cout << endl;
		}
		return 0;
	}

	int pH = d - 1;
	int pW = d;
	rep(y, pH) rep(x, pW) pattern[y][x] = true;
	rep(y, pH) {
		int num = abs(pH / 2 - y);
		rep(i, num) {
			pattern[y][i] = false;
			pattern[y][pW - i - 1] = false;
		}
	}

	int cnt = 0;
	for (int ty = - H - 2 * d; ty < H + 2 * d; ty += d / 2) {
		int tx = -d;
		if (cnt % 2) tx -= d / 2;

		int color = cnt % 2 ? 0 : 2;
		color += (cnt / 2) % 2 ? 0 : 1;
		while (tx < W) {
			rep(py, pH) rep(px, pW) {
				if (!inBoard(tx + px, ty + py)) continue;
				if (!pattern[py][px]) continue;
				board[ty + py][tx + px] = color;
			}

			color += color % 2 ? -1 : 1;
			tx += pW;
		}

		cnt++;
	}

	char ch[4] = { 'R', 'Y', 'G', 'B' };
	rep(y, H) {
		rep(x, W) cout << ch[board[y][x]];
		cout << endl;
	}

    return 0;
}


Measured memory_bytes: 3456
#include <stdio.h>
#include <stdlib.h>
#define STACK_SIZE 100
#define OP 1000000
int top=0;
int Stack[STACK_SIZE];
void push(int a){
  Stack[++top]=a;
}
int pop(){
  return Stack[top--];
}
int main(){
  char s[OP];
  int n,a,b;
  while(scanf("%s",s)!=EOF){
    if(atoi(s)!=0){
      n=atoi(s);
      push(n);
    }
    else{
      a=pop();
      b=pop();
      switch(s[0]){
      case '+':
	push(b+a);
	break;   
      case '-':
	push(b-a);
	break;
      case '*':
	push(b*a);
	break;
      }
    }
  }
  printf("%d\n",Stack[top]);
  return 0;
}

Measured memory_bytes: 556
package main

import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func main() {
    sc.Split(bufio.ScanWords)
	var bseq [20]int

	N := nextInt()
	M := nextInt()
	C := nextInt()

    for i := 0; i < M; i++ {
        bseq[i] = nextInt()      
	}
	
	var count int
	for index := 0; index < N; index++ {
		var ask = 0
		for index := 0; index < M; index++ {	
          ask += nextInt()*bseq[index]
		}
		if ask+C > 0 {
			count++
		}      
	}
  	fmt.Print(count)
}

Measured memory_bytes: 640