akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long int
#define pb push_back
#define mp make_pair
#define f first
#define s second 

vector < pair< pair<int,int> , int > > v;

int32_t main()
{
     
    
     
     int n;
     
      cin>>n;  
     
     for(int i=1;i<=n;i++)
     {
          int x,y,z;
          
          cin>>x>>y>>z;
          
          v.pb(mp(mp(x,y),z));
          
     }
     
     for(int i=0;i<=100;i++)
     {
          for(int j=0;j<=100;j++)
          {
               
               set <int> st;
               
               int mini=1e18,flag=0;
               
               int val;
               
               for(int k=0;k<v.size();k++)
               {
                    int a=v[k].f.f;
                    int b=v[k].f.s;
                    int c=v[k].s;
                    
                    val=abs(a-i)+abs(b-j);
                    
                    //cout<<val<<endl;
                    
                    if(c==0)
                    {
                         if(val==0)
                         flag=1;
     
                         mini=min(mini,val);
                         
                    }
                    else
                    {
                         st.insert(c+val);
                    }
                    
               }
               
               if(flag==0 && st.size()<=1)
               {
                    if(st.size()==0)
                    {
                         cout<<i<<" "<<j<<" "<<mini;
                         return 0;
                    }
                    else
                    {
                         set <int> :: iterator itr;
                         itr=st.begin();
                         
                         int pp=*itr;
                         
                         if(pp<=mini)
                         {
                              cout<<i<<" "<<j<<" "<<pp;
                              return 0;
                         }
                         
                    }
               }
               
          }
     }
     
     return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(int argc,char** argv){
  int n,k;
  string s;
  char a;
  cin >> n;
  cin >> s;
  cin >> k;
  a = s[k-1];
  for(int i = 0; i < n; i++){
    if(s[i] == a){ cout << a;}
    else{cout << '*';}
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int main(){
	int k,n;
	cin>>n>>k;
	if (k*2-1>n) cout<<"NO";
	else cout<<"YES";
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <complex>
using namespace std;

#define EPS 10e-8
#define PI 3.1415926535

typedef complex<double> Point;

int n;
Point ps[4];

int main() {
  scanf("%d", &n);
  while (n--) {
    for (int i=0; i<4; i++) {
      double x, y;
      scanf("%lf%lf", &x, &y);
      ps[i] = Point(x, y);
    }

    double t = abs(arg((ps[3]-ps[2])/(ps[1]-ps[0])));
    if ((-EPS < t && t < EPS) || (PI-EPS < t && t  < PI+EPS)) {
      puts("YES");
    } else {
      puts("NO");
    }
  }
}

Measured memory_bytes: 2876
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
const double eps = 1e-6;

/////////////////////////////////////////////

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

////////////////////////////////

#define int long long

void solve(){

	int k , q;
	cin>>k>>q;

	int d[k];
	for(int i = 0 ;i < k; ++i)
		cin>>d[i];
	while(q--){

		int n , x , m;
		cin>>n>>x>>m;

		int a[k];
		for(int i = 0 ; i < k  ; ++i)
			a[i] = d[i]%m;

		int cnt = 0;

		int p = (n-1)%k;

		for(int i = 0 ; i < p ; ++i)
			cnt+=(a[i]==0);

		int ans = cnt;
		for(int i = p ; i < k ; ++i)
			cnt += (a[i]==0);
		int div = (n-1)/k;
		ans += div*cnt;

		int sum = 0;

		for(int i = 0 ; i < k ; ++i)
			sum += a[i];

		int final = x;
		final += div*sum;
		for(int i = 0 ; i < p ; ++i)
			final +=a[i];

		//debug(final , div , sum);
		int val = final/m - x/m;

		int tot = (n-1) - val - ans;
		//debug(val , ans);
		cout<<tot<<endl;

	}
}

signed main(){

    fast;
    int t = 1;
    //cin>>t;
    for(int i = 1 ; i <= t; ++i){

    	solve();
    }
}


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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;

const int mod = 1000000007;


int main() {
    ll n;
    cin >> n;
    vector<ll> numbers(n);
    rep(i, n) cin >> numbers[i];
    sort(numbers.rbegin(), numbers.rend());

    map<ll, ll> counts;
    for (ll l : numbers) counts[l]++;
    ll ans = 0;
    rep(i, n) {
        ll l = numbers[i];
        assert(counts[l] >= 0);
        if (counts[l] == 0) continue;
        counts[l]--;

        ll max_bit = -1;
        for (int j = 0; j < 64; j++) {
            bool b = ((l >> j) & 1);
            if (b) max_bit = j;
        }
        assert(max_bit >= 0);
        ll target = 1ll << (max_bit + 1);
        target -= l;
        assert(target >= 0);
        if (counts.find(target) != counts.end() && counts[target] > 0) {
            ans++;
            counts[target]--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 14336
# -*- coding: utf-8 -*-
# モジュールのインポート
import math
import itertools


def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力を取得
    """
    N = int(input())
    x, y = [], []
    for n in range(N):
        x_n, y_n = list(map(int, input().split()))
        x.append(x_n)
        y.append(y_n)

    return N, x, y


def get_distance(x: list, y: list, i: int, j: int) -> float:
    """
    町iと町jの間の距離を取得する.

    Args:\n
        x (list): 町のx座標
        y (list): 町のy座標
        i (int): 町
        j (int): 町

    Returns:\n
        float: 町iと町jの間の距離
    """
    return math.sqrt((x[i] - x[j])**2 + (y[i] - y[j])**2)


def get_path_length(N: int, distance: dict, path: list) -> float:
    """
    経路の長さを求める.

    Args:\n
        N (int): 町の数
        distance (dict): 町間の距離
        path (list): 経路

    Returns:\n
        float: 経路の長さ
    """
    path_length = 0
    for n in range(N - 1):
        path_length += distance[(path[n], path[n + 1])]

    return path_length


def main(N: int, x: list, y: list) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 町の数
        x (list): 町のx座標
        y (list): 町のy座標
    """
    # 事前に町間の距離情報を作っておく
    distance = {}
    for i, j in itertools.product(range(N), repeat=2):
        distance[(i, j)] = get_distance(x, y, i, j)

    # 求解処理
    ans = 0
    for path in itertools.permutations(range(N)):
        ans += get_path_length(N, distance, path)
    ans /= math.factorial(N)

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N, x, y = get_input()

    # メイン処理
    main(N, x, y)


Measured memory_bytes: 9208
const line = require('fs').readFileSync('/dev/stdin', 'utf-8').split('\n');

const newNode = (id, arr) => {
    return {
        id: id,
        children: [...arr],
        parentNode: -1,
        depth: null
    };
};

const nodeToString = node => {
    const type = node.parentNode === -1 ? 'root'
               : node.children.length > 0 ? 'internal node'
               : 'leaf';
    const arr = `[${node.children.join(', ')}]`;
    return `node ${node.id}: parent = ${node.parentNode}, depth = ${node.depth}, ${type}, ${arr}`;
};

const setDepth = tree => {
    const root = tree.filter(x => x.parentNode === -1)[0];
    const helper = (node, n) => {
        node.depth = n;
        node.children.forEach(x => {
            helper(tree[x], n+1);
        });
    };
    helper(root, 0);
};

const n = parseInt(line[0]);
const data = line.slice(1, n+1)
                 .map(x => x.split(' ').map(Number));

const tree = data.map(x => {
    const id = x[0];
    const children = x.slice(2);
    return newNode(id, children);
});

tree.sort((a, b) => a.id - b.id);
tree.forEach((x, _, arr) => {
    x.children.forEach(y => {
        arr[y].parentNode = x.id;
    });
});

setDepth(tree);

console.log(tree.map(x => nodeToString(x)).join('\n'));



Measured memory_bytes: 157784
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define boost ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

const ll INF=1e18;
const int inf = 2e9;
const ll mod = 1e8;
const ld pi = acos(-1);
const int dx[4]={0,0,1,-1};
const int dy[4]={1,-1,0,0};

int cnt[26];

int main(){
  string s;
  cin>>s;
  ll ans=1;
  for(int i=0;i<sz(s);i++){
    cnt[s[i]-'a']++;
  }
  for(int i=0;i<sz(s);i++){
    for(int j=0;j<26;j++){
      if(s[i]-'a'==j)continue;
      ans+=cnt[j];
    }
    cnt[s[i]-'a']--;
  }
  cout<<ans;
}


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

using namespace std;

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

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

   int n;

   while(cin >> n && n != 0){
      int a[n],sum = 0;
      rep(i,n){
         cin >> a[i];
      }
      sort(a,a+n);
      for(int i = 1; i < n - 1; ++i){
         sum += a[i];
      }
      cout << sum / (n - 2) << endl;
   }

   return 0;
}


Measured memory_bytes: 3088
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cnt = sum(b) - sum(a)
ans1, ans2 = 0, 0
for ai, bi in zip(a, b):
    ans1 += max(0, ai - bi)
    ans2 += max(0, (bi - ai + 1) // 2)
print('Yes' if max(ans1, ans2) <= cnt else 'No')


Measured memory_bytes: 74064
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define All(obj) (obj).begin(),(obj).end()

using namespace std;


int main() {
	speed;
	vector<int> a;
	rep(i, 3) {
		int b;
		cin >> b;
		a.push_back(b);
	}
	sort(All(a));
	int ans = 10 * a.at(2) + a.at(1) + a.at(0);
	cout << ans;
	ed;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
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 VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#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()
struct fast_ios { fast_ios(){ cin.tie(nullptr); 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 ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  string s; cin >> s;
  int n = s.size();

  // map<ll, int> idx;
  Vll c(n+1);
  rep(i, n) {
    int x = s[i] - 'a';
    c[i+1] = c[i]^(1ll<<x);
  }
  // drep(i, n+1) idx[c[i]] = i;

  map<ll, int> dpmin;
  V dp(n+1, INF);
  dp[0] = 0;
  dpmin[0] = 0;
  rep2(i, 1, n+1) {
    // int j = idx[c[i]];
    // if (j < i) {
      if (dpmin.find(c[i]) != dpmin.end()) {
        chmin(dp[i], dpmin[c[i]]+1);
        chmin(dpmin[c[i]], dp[i]);
      }
    // }
    rep(x, 26) {
      int y = c[i]^(1ll<<x);
      if (dpmin.find(y) == dpmin.end()) continue;
      chmin(dp[i], dpmin[y]+1);
      if (dpmin.find(c[i]) == dpmin.end()) dpmin[c[i]] = dp[i];
      else chmin(dpmin[c[i]], dp[i]);
      // if (idx.find(y) == idx.end()) continue;
      // int j = idx[y];
      // if (j < i) chmin(dp[i], dp[j]+1);
    }
  }

  int ans = dp[n];
  cout << ans << "\n";
  return 0;
}


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

#define FAST_IO                       \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;

using namespace std;

using ll = long long;

const int MOD = 1e9 + 7;
const ll INF_LLONG = 1e18 + 9;
const int INF_INT = 1e9 + 9;

template<typename T>
unsigned int index_of_max(vector<T>& arr) {
	unsigned int idx = 0;
	for (int i = 0; i < arr.size(); ++i) {
		if (arr[i] > arr[idx])
			idx = i;
	}
	return idx;
}

template<typename T>
unsigned int index_of_min(vector<T>& arr) {
	unsigned int idx = 0;
	for (int i = 0; i < arr.size(); ++i) {
		if (arr[i] < arr[idx])
			idx = i;
	}
	return idx;
}

bool isPalindrome(string s, int l, int r) {
	for (; l <= r; ++l, --r) {
		if (s[l] != s[r])
			return false;
	}
	return true;
}

int main()
{
	//	#ifndef ONLINE_JUDGE
	//		(void)freopen("input.txt", "r", stdin);
	//		(void)freopen("output.txt", "w", stdout);
	//	#endif	
	FAST_IO;
	double L;
	cin >> L;
	printf("%.12lf", L * L * L / 27);
	return 0;
}




Measured memory_bytes: 256
#include <iostream>

#include <string>

using namespace std;




int main(){
    string s;
    string p;
    cin>>s>>p;
    
    s+=s;
    if(s.find(p)==string::npos){
        cout<<"No"<<endl;
        
    }else{
        cout<<"Yes"<<endl;
    }
        
    
    
    
}



Measured memory_bytes: 3200
#include <cstdio>
#include <cstring>

using namespace std;

int main(){
	char p[202],s[101],ch[101];

	scanf("%s %s",p,s);
	strcpy(ch, p);
        strcat(p, ch);
	if (strstr(p, s)) printf("Yes\n");
        else printf("No\n");
	return 0;
}

Measured memory_bytes: 2740
n,t=input().split()
n,t=int(n),int(t)

c=1001
for i in range(n):
    ck,tk=input().split()
    if int(tk)<=t and int(ck)<c:
        c=int(ck)
        
if c==1001:
    print("TLE")
else:
    print(c)


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

using namespace std;

int main()
{
    int n,m,x,a[102],sum1=0,sum2=0;
    cin>>n>>m>>x;
    a[0]=x;
    for(int i=1;i<=m;i++){
        cin>>a[i];
    }
    sort(a,a+m+1);
    for(int i=0;i<=m;i++){
        if(a[i]==x) break;

        sum1+=1;
    }
    sum2=m-sum1;
    cout<<min(sum1,sum2);
    return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b,c;
    cin >> a >> b >> c;
    int cnt1=0,cnt2=0;
    rep(i,b){
        int m;
        cin >> m;
        if(m<c){
            cnt1+=1;
        }
        else if(m>c){
            cnt2+=1;
        }
    }
    cout << min (cnt1,cnt2);

    return 0;
}

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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;
#define dpair pair<double,double>

template <typename Val>
Val gcd(Val a, Val b) {
//use ll or int for gcd
    if (b==0) return a;
    else return gcd(b, a%b);
}
template <typename Val>
Val vec_max(vector<Val> v){
  return *max_element(v.begin(),v.end());
}
template <typename Val>
Val vec_min(vector<Val> v){
  return *min_element(v.begin(),v.end());
}
template <typename Val>
void show_vec(vector<Val> *v){
  cout<<endl;
  rep(i,v->size()){
    cout<<v->at(i)<<" ";
  }
  cout<<endl;
}

template <typename Val,typename Number>
void count_vector(vector<Val>* A,vector<pair<Number,Val>>*R){
  sort(A->begin(),A->end());
  int count = 1;
  rep(i,A->size()){
    if(i<A->size()-1){
      if(A->at(i)==A->at(i+1))count++;
      else{
        R->emplace_back(count,A->at(i));
        count = 1;
      }
    }else{
      R->emplace_back(count,A->at(i));
    }
  }
}


struct Point{
  int x;
  int y;
};

void checker(int n, vec U, vec* m, vector<vec>* A,int X,vec* C){
  int N = A->size();
  int M = A->at(0).size();
  if(n==N){
    vec T(M,0);
    int total = 0;
    rep(i,N){
      if(U.at(i)==1){
        total+=C->at(i);
        rep(j,M){
          T.at(j)+=A->at(i).at(j);
        }
      }
    }
//    cout<<endl;
//    show_vec(&U);
//    show_vec(&T);
    rep(i,M){
      if(T.at(i)<X)return;
    }
    m->push_back(total);

    return;
  }else{
    checker(n+1,U,m,A,X,C);
    U.at(n)=1;
    checker(n+1,U,m,A,X,C);
  }
}


//---------------------------------------------------------------
int main(){
  int N,M,X;
  cin>>N>>M>>X;
  vector<vec>A(N,vec(M));
  vec C(N);
  rep(i,N){
    cin>>C.at(i);
    rep(j,M){
      cin>>A.at(i).at(j);
    }
  }
  vec U(N,0);
  vec m;
  checker(0, U, &m, &A,X,&C);
  if(m.size()>0){
  sort(m.begin(),m.end());
  cout<<m.at(0)<<endl;
}else{
  cout<<"-1"<<endl;
}

}


Measured memory_bytes: 3616
#C - HonestOrUnkind2
import itertools
import numpy as np
 
N = int(input())
info = []
for i in range(N):
    A = int(input())
    for _ in range(A):
        x,y = map(int,input().split())
        info.append((i,x-1,y))
A = np.array(list(itertools.product([0,1],repeat=N)), np.bool)
for i,x,y in info:
    bl = (~A[:,i]) | (A[:,x] == bool(y))
    A = A[bl]
    
answer = A.sum(axis = 1).max()
print(answer)

Measured memory_bytes: 18616
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (n % 2 == 1) {
			System.out.println("No");
		} else {
			String s = sc.next();
			char[] ch = s.toCharArray();
			String ans = "Yes";
			for (int i = 0; i < n / 2; i++) {
				if (ch[i] != ch[i + n / 2]) {
					ans = "No";
					break;
				}
			}

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

}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
	int n;
	cin>>n;
	vector<int> v(n);
	rep(i,n)cin>>v[i];
	int count=0;
	vector<int> vv;
	int idx=1;
	unordered_map<int,int> m;
	m[count]=idx;
	while(1){
		count++;
		idx=v[idx-1];
		if(idx==2){cout<<count<<endl;return 0;}
		if(m.find(idx)!=m.end()){cout<<-1<<endl;return 0;}
		m[idx]=idx;
	}
	return 0;
}


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

int main()
{
    int r, D, x;
    cin >> r >> D >> x;

    vector<int> xi(11);
    xi[0] = x;

    for(int i = 1; i <= 10; i++)
    {
        xi[i] = r * xi[i - 1] - D;
        cout << xi[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<ctime>
#include<sys/time.h>
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<climits>
#include<string>
#include<sstream>

#define pii pair<int,int>
#define ll long long
#define MOD 1000000007
#define in2d(i,j,H,W)(0<=i&&i<H&&0<=j&&j<W)

using namespace std;
struct UFT{
	vector<int>par;
	int getpar(int i){
		if(par[i]==i)return i;
		return par[i]=getpar(par[i]);
	}
	void unite(int i,int j){
		int t=getpar(i);
		par[t]=getpar(j);
	}
	bool uf(int i,int j){
		return getpar(i)==getpar(j);
	}
	UFT(int n){
		par=vector<int>(n);
		for(int i=0;i<n;i++)par[i]=i;
	}
	~UFT(){
		delete &par;
	}
};
struct SegT{
	vector<ll>container;
	int n;
	void update(int i,ll x){
		int ii=i+n-1;
		container[ii]=x;
		while(ii>0){
			ii=(ii-1)/2;
			//////////////////////////////////////////
			container[ii]=max(container[2*ii+1],container[2*ii+2]);
			//////////////////////////////////////////
		}
	}
	ll get(int l,int r,int l2=0,int r2=-1,int k=0){
		if(r2==-1)r2=n;
		if(r2<=l||r<=l2)return 0;
		if(l<=l2&&r2<=r)return container[k];
		ll vl=get(l,r,l2,(l2+r2)/2,2*k+1);
		ll vr=get(l,r,(l2+r2)/2,r2,2*k+2);
		///////////////////////////
		return max(vl,vr);
		///////////////////////////
	}
	////////////////new///////////////////////
	SegT(vector<int> &A){
		n=pow(2,(int)log2(A.size())+1);
		container=vector<ll>(2*n,0);
		for(int i=0;i<A.size();i++)update(i,A[i]);
	}
	~SegT(){
		delete &container;
	}

};
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main(){
	timeval t;
	gettimeofday(&t,NULL);
	timeval t2;
	//cout<<fixed<<setprecision(11);
	ll A,B;cin>>A>>B;
	if(B>A)swap(A,B);
	ll C=gcd(A,B);
	//bool prime[1000000000010];
	//for(ll i=0;i<1000000000010;i++)prime[i]=true;
	//for(ll i=0;i<1000000000010;i++)if(prime[i])for(ll j=i*2;j<1000000000010;j+=i)prime[j]=false;
	ll ans=0;
	for(ll i=2;i<1000010;i++){
		//gettimeofday(&t2,NULL);
		//cout<<t2.tv_usec-t.tv_usec<<endl;
		//if(t2.tv_usec-t.tv_usec>1700000){ans=1;break;}
		//if(!prime[i])continue;
		if(C==1)break;
		int f=0;
		while(C%i==0){C/=i;f=1;}
		//ll j=1000000000010-i;
		//if(C%j==0)f++;
		//while(C%j==0)C/=j;
		ans+=f;
		//cout<<C<<endl;;
	}
	if(C!=1)ans++;
	cout<<ans+1<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    string s;
    cin >> s;

    int64_t ans = 0;
    for (auto i : irange(0L, n - 2)) {
        if (s.substr(i, 3) == "ABC") {
            ++ans;
        }
    }

    cout << ans << endl;
}

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

int main(){
  int N;
  int s;
  
  cin>>N;
  
  s=N%10;
  
  if(s==0||s==1||s==6||s==8){
    cout<<"pon"<<endl;
  }
  else if(s==3){
    cout<<"bon"<<endl;
  }
  else{
    cout<<"hon"<<endl;
  }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    vll a(n + 1), b(n);
    REP(i, n + 1) cin >> a[i];
    REP(i, n) cin >> b[i];

    ll res = 0;
    REP(i, n){
        ll tmp = min(a[i], b[i]);
        res += tmp;
        b[i] -= tmp;
        ll ccc = min(a[i + 1], b[i]);
        res += ccc;
        a[i + 1] -= ccc;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1920
n = input()
m = len(n)
ans = 0

for k in range(m+1):
    for i in range(3 ** k):
        li = [] 
        for j in range(k):
            li.insert(0,int((i%(3**(j+1)))/(3**j)))                
        for j in range(k):
            if li[j] == 0:
                li[j] = '3'
            if li[j] == 1:
                li[j] = '5'
            if li[j] == 2:
                li[j] = '7'
        if li != []:
            if int(''.join(li)) <= int(n) and len(set(li)) == 3:
                ans += 1
print(ans)

Measured memory_bytes: 3064
def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    zero = 3
    ans = 1
    ls = [0 for _ in range(N)]
    mod = 1000000007
    for i in A:
        if i == 0:
            ans = (ans*zero)%mod
            zero -= 1
            ls[i] += 1
        else:
            ans = (ans*(ls[i-1]-ls[i]))%mod
            ls[i] +=1

    print(ans)
if __name__ == "__main__":
    main()

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

int main(){
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(u == s) --a;
    if(u == t) --b;
    cout << a << " " <<  b << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
const int MaxN = 1000;
using namespace std;
char s[MaxN + 5];
int a[MaxN + 5] , cnt[MaxN + 5];
int main()
{
	while(~scanf("%s" , s + 1)){
		memset(a , 0 , sizeof(a));
		int n = strlen(s + 1);
		int Min = 1 << 30;
		for(char i = 'a';i <= 'z';i++){
			int pre = 0 , ans = 0;
			for(int j = 1;j <= n;j++){
				if(s[j] == i){
					ans = max(j - pre - 1, ans);
					pre = j;
				}
			}
			ans = max(n - pre , ans);
			Min = min(Min , ans);
		}
		printf("%d\n" , Min);
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX_N 100005
ll mod=1e9+7;
ll add(ll a,ll b){return (a+b)%mod;}
ll mul(ll a,ll b){return (a*b)%mod;}

int N,T;
int d[MAX_N];
ll dp[MAX_N];

int main(){
  cin>>N>>T;
  for(int i=0;i<N;i++)cin>>d[i];
  sort(d,d+N);
  int x=0,y;
  dp[0]=1;
  for(int i=1;i<N;i++){
    while(d[x]<d[i]-T)x++;
    y=i-x;
    dp[i]=mul(dp[i-1],y);
    dp[i]=add(dp[i],dp[i-1]);
  }
  cout<<dp[N-1]<<endl;
  return 0;
}

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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
const double PI=3.14159265358979323846;

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







int main() {


  cout<<fixed<<setprecision(10);

  ll n; cin>>n;

  vvint dp(n+1, vint(3,0));

  rep(i,n){
    vint abc(3); rep(j,3) cin>>abc[j];

    rep(j, 3){
      chmax(dp[i+1][j], max(dp[i][(j+1)%3], dp[i][(j+2)%3]) + abc[j]);
    }
  }

  ll ans = *max_element(ALL(dp[n]));
  cout<<ans<<endl;

}

//


Measured memory_bytes: 5760
d = input().split()
cmd_list = list(input())
w = []

for cmd in cmd_list:
    if cmd == "E":
        w = d
        d[0], d[1], d[2], d[3], d[4], d[5] = w[3], w[1], w[0], w[5], w[4], w[2]
    elif cmd == "N":
        w = d
        d[0], d[1], d[2], d[3], d[4], d[5] = w[1], w[5], w[2], w[3], w[0], w[4]
    elif cmd == "S":
        w = d
        d[0], d[1], d[2], d[3], d[4], d[5] = w[4], w[0], w[2], w[3], w[5], w[1]
    elif cmd == "W":
        w = d
        d[0], d[1], d[2], d[3], d[4], d[5] = w[2], w[1], w[5], w[0], w[4], w[3]

print(d[0])



Measured memory_bytes: 5576
N = gets.chop.to_i
T, A = gets.chomp.split.map(&:to_i)
H = gets.strip.split.map(&:to_i)
ans = []
a = 0
N.times do |i|
  ans[i] = (A - (T - H[i] * 0.006)).abs
  end
puts ans.index(ans.min) + 1

Measured memory_bytes: 1788
use std::io;

fn main() {
  let mut x = String::new();
  io::stdin()
    .read_line(&mut x)
    .expect("");

  let v: Vec<&str> = x.trim()
    .split_whitespace()
    .collect();
  
  let a: i32 = v[0].parse().unwrap();
  let b: i32 = v[1].parse().unwrap();

  println!("{} {}", a * b, 2 * (a + b));
}



Measured memory_bytes: 5024
#include<stdio.h>
int main()
{
  int n,i,j,num;
  char card[5][14]={0},mark;
  //s=1,h=2,c=3,d=4
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf(" %c %d",&mark,&num);
    if(mark=='S')card[1][num]=1;
    if(mark=='H')card[2][num]=1;
    if(mark=='C')card[3][num]=1;
    if(mark=='D')card[4][num]=1;
  }
  for(i=1;i<=4;i++){
    for(j=1;j<=13;j++){
      if(card[i][j]==0){
    if(i==1)printf("S %d\n",j);
    if(i==2)printf("H %d\n",j);
    if(i==3)printf("C %d\n",j);
    if(i==4)printf("D %d\n",j);
      }
    }
  }
  return 0;
}


Measured memory_bytes: 2048
def main():
    n, m = map(int, input().split())
    a = set([int(input()) for _ in range(m)])

    ansls = [0]*(n+1)

    if 0 not in a:
        ansls[0] = 1
    if 1 not in a:
        ansls[1] = 1

    for i in range(2, n+1):
        if i not in a:
            ansls[i] = (ansls[i-2] + ansls[i-1])%(10**9 + 7)
    
    print(ansls[-1])
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 13196
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int n;
    scanf("%d",&n);
 
    if((n % 100) % 10 == 7){
        printf("Yes");
    }
    else if((n / 10) % 10 == 7){
        printf("Yes");
    }
     else if(n / 100 == 7){
        printf("Yes");
    }
    else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1708
package main

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

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	stdin.Split(bufio.ScanWords)
	var H, N int
	var A []int

	H = nextInt()
	N = nextInt()
	for i := 0; i < N; i++ {
		A = append(A, nextInt())
	}
	// fmt.Println(H, N)
	// fmt.Println(A)

	err := judge(H, N, A)
	if err != nil {
		panic(err)
	}
}

func judge(H int, N int, A []int) error {
	sum := 0
	for i := range A {
		sum += A[i]
	}
	if H > sum {
		fmt.Println("No")

	} else {
		fmt.Println("Yes")
	}
	return nil
}

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


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

string S, T, U; int loop = 1;

bool solve(string A) {
	int cnt = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == A[cnt]) cnt++;
		if (A.size() == cnt) return true;
	}
	return false;
}

int main() {
	cin >> S >> T; U = T;
	for (int i = 1; i <= 20; i++) {
		if (solve(U) == false) {
			cout << i - 1 << endl;
			break;
		}
		string B = U;
		for (int j = 0; j < T.size(); j++) {
			if (U.size() >= 300000) {
				break;
			}
			U += T[j];
			U += B;
		}
	}
	return 0;
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int P,Q,R;
int main(){
    cin >>P >>Q>>R;
    cout << min(P+Q,min(Q+R,R+P)) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a, b, c, x, count = 0;
	scanf("%d %d %d", &a, &b, &c);
	for(x = a;x <= b;x++){
		if(c%x == 0){
			count++;
		}else continue;
	} 
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
int main()
{
    using ii = long long;
    using mat = vector<vector<ii>>;
    const ii mod = 1e9 + 7;
    ii N, K;
    cin >> N >> K;
    mat a(N, vector<ii>(N));
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            cin >> a[i][j];
        }
    }
    auto mul = [&](mat a, mat b) {
        mat c(N, vector<ii>(N));;
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                for (int k = 0; k < N; ++k) {
                    c[i][j] += a[i][k] * b[k][j] % mod;
                    c[i][j] %= mod;
                }
            }
        }
        return c;
    };
    function<mat(mat, ii)> mpow = [&](mat a, ii x) {
        if (x == 1) return a;
        if (x & 1) return mul(a, mpow(a, x - 1));
        mat b = mpow(a, x / 2);
        return mul(b, b);
    };
    mat d = mpow(a, K);
    ii r = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            (r += d[i][j]) %= mod;
        }
    }
    cout << r << "\n";
}


Measured memory_bytes: 2816
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

struct MyStruct
{
	int list[13];
};


signed main() {
	int i, j, n;
	string s, s1, s2;
	bool flag = false;
	vector<int>list(26,0);

	cin >> s >> s1;


	for (i = 0; i < s.length(); i++) {

		if (s.find(s1) != string::npos) {
			cout << "Yes" << endl;
			getchar();
			getchar();
			return 0;
		}

		char ch = s[0];
		s.erase(s.begin());
		s += ch;
	}



	cout << "No" << endl;



	getchar();
	getchar();
	return 0;
}


Measured memory_bytes: 3212
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    long[long] cnt;
    foreach (a; A)
    {
        cnt[a] = cnt.get(a, 0) + 1;
    }
    long ans;
    foreach (key, value; cnt)
    {
        if (key <= value)
        {
            ans += value - key;
            continue;
        }
        ans += value;
    }
    writeln(ans);
}


Measured memory_bytes: 9044
#include<iostream>
using namespace std;

int kou[4][3][10];
int main(){

	int n, b, f, r, v;
	for (int x = 0; x < 4; x++){
		for (int y = 0; y < 3; y++){
			for (int z = 0; z < 10; z++){
				kou[x][y][z] = 0;
			}
		}
	}
	cin >> n;
	for (int a = 0; a < n; a++){
		cin >> b >> f >> r >> v;
		kou[b - 1][f - 1][r - 1] += v;


	}
	for (int x = 0; x < 4; x++){
		for (int y = 0; y < 3; y++){
			for (int z = 0; z < 10; z++){
				cout << ' ' << kou[x][y][z];
			}
			cout << endl;
		}
		if (x < 3)cout << "####################" << endl;
	}



	return 0;
}


Measured memory_bytes: 3104
from fractions import gcd

def lcm(a,b):
    return a*b//gcd(a,b)

a,b,c,d = map(int, input().split())
cd = lcm(c,d)
n = b-a+1
nc = b//c-(a-1)//c
nd = b//d-(a-1)//d
ncd = b//cd-(a-1)//cd
#print(n,nc,nd,ncd)
print(n-(nc+nd-ncd))

Measured memory_bytes: 5076
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  lint S=0;
  FOR(i,1,N+1){
    if(i%3!=0 and i%5!=0)S+=i;
  }
  cout<<S<<endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    string a, b, c;
    cin >> a >> b >> c;
    cout << "A" << b[0] << "C" << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define sd second
#define ll long long

using namespace std;

const int maxn = 200100;
const int C = 27;
const int oo = 1e9;

int n,res,a[maxn];
pair<int,int> ans[maxn];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
  //  freopen("in.txt","r",stdin);
    cin>>n;
    for (int i=1;i<=n;i++) cin>>a[i];
    int id = -1,mx=-oo,sign;
    for (int i=1;i<=n;i++)
        if (mx < abs(a[i])) {
            mx = abs(a[i]);
            id = i;
            sign = (a[i]>=0);

        }
    for (int i=1;i<=n;i++) ans[++res] = mp(id,i);
    if (sign) for (int i=1;i<n;i++) ans[++res] = mp(i,i+1);
    else {
            for (int i=n;i>1;i--) ans[++res] = mp(i,i-1);
    }
    cout<<res<<endl;
    for (int i=1;i<=res;i++) cout<<ans[i].fi<<" "<<ans[i].sd<<endl;
}


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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());


signed main()
{
    gearup;
    ll x,a,b; cin >> x >> a >> b;
    if(a >= b)out("delicious");
    else if( (b-a) <= x)out("safe");
    else out("dangerous");
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
long long f(long long x) {
	if(x%4==0) {
		return x;
	} else if(x%4==1) {
		return 1;
	} else if(x%4==2) {
		return x+1;
	} else {
		return 0;
	}
}
int main() {
	long long a,b;
	cin>>a>>b;
	cout<<(f(b)^(a==0?0:f(a-1)))<<endl;
	return 0;
}

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

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

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

int main() {
  int n;
  S(n);
  int a,b;
  S2(a,b);
  int x,y,z;
  x = y = z = 0;
  rep(i,0,n) {
    int v;
    S(v);
    if(v <= a) x++;
    else if(v <= b) y++;
    else z++;
  }
  int ans = min(x, min(y, z));
  P(ans);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>//たてH cm よこ W cm の長方形を描くプログラム

int main(void){
 
	int a,b,i,j;

	while(1){
		scanf("%d %d",&a,&b);
		if(a==0&&b==0)
			break;
		for(i=0;i<a;i++){
			for(j=0;j<b;j++)
				printf("#");
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    ans = 0
    counter = Counter(A)
    vec1 = [k for k, v in counter.items() if v >= 2]
    vec2 = [k for k, v in counter.items() if v >= 4]

    vec1.sort()
    if len(vec1) >= 2:
        ans = vec1[-2] * vec1[-1]

    vec2.sort()
    if len(vec2) >= 1:
        ans = max(ans, vec2[-1] ** 2)

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 22112
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

string s;

int main()
{
    cin>>s;
    REPALL(i,s) s[i] ='x';
    cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
	S = input().strip()
	n = len(S)
	ans = [0] * n
	for _ in range(2):
		cnt = 0
		for i in range(n):
			if S[i] == 'R':
				cnt += 1
			else:
				ans[i] += cnt // 2
				ans[i-1] += (cnt + 1) // 2
				cnt = 0
		ans = ans[::-1]
		S = S[::-1]
		S = ['R' if S[i] == 'L' else 'L' for i in range(n)]

	for i in range(n):
		print("{} ".format(ans[i]), end="")
	print("")
if __name__ == '__main__':
	main()


Measured memory_bytes: 57264
//Heaplax
#include<bits/stdc++.h>
#define N 200005
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
int n,m,a[N];
int now,cnt[N];
int fg[N];
void add(int x)
{
	if(x-cnt[x]>=1)
	{
		if(!fg[x-cnt[x]])
			++now;
		++fg[x-cnt[x]];
	}
	++cnt[x];
}
void dec(int x)
{
	--cnt[x];
	if(x-cnt[x]>=1)
	{
		--fg[x-cnt[x]];
		if(!fg[x-cnt[x]])
			--now;
	}
}
int main()
{
	re(n),re(m);
	for(int i=1;i<=n;++i)
		re(a[i]),add(a[i]);
	for(int x,y;m--;)
	{
		re(x),re(y);
		dec(a[x]);
		a[x]=y;
		add(a[x]);
		printf("%d\n",n-now);
	}
}


Measured memory_bytes: 3712