akhauriyash/Code-Regression huggingface dataset:
//***Faithless is he that says farewell when the road darkens***

#include<bits/stdc++.h>
using namespace std;

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll a[52];

ll fun(ll n){
   for(ll i=0;i<(n-1);i++)
      if(a[i]>a[i+1])
         return 0;
   return 1;
}

int main()
{
   ll n;
   cin>>n;
   for(ll i=0;i<n;i++)
      cin>>a[i];
   if(fun(n)){
      cout<<"YES\n";
      return 0;
   }
   for(ll i=0;i<n;i++){
      for(ll j=0;j<n;j++){
         swap(a[i],a[j]);
         ll c=fun(n);
         if(c==1){
            cout<<"YES\n";
            return 0;
         }
         swap(a[i],a[j]);
      }
   }
   cout<<"NO";
}

Measured memory_bytes: 256
def func
    n,k = gets.split(' ').map(&:to_i)
    a = [-1] + (gets.split(' ').map(&:to_i))
    went_flags = Array.new(n,false)

    k=k+1 #移動数でなく行った街数

    path = [1]
    cnt = 0
    while true do
        

        dest = a[path.last]
        if went_flags[dest]
            break
        end
        went_flags[dest] = true
        path << dest

        # cnt += 1
        # if cnt == k
        #     return path.last.to_s
        # end
        

    end

    loop_start_town = a[path.last]
    loop_start_index = path.index(loop_start_town)
    loop_length = path.size - loop_start_index
    loop_num = (k - loop_start_index) / loop_length
    loop_mod = (k - loop_start_index - 1) % loop_length

    # puts "d:#{path}"
    # puts "d:loop_start_index: #{loop_start_index}"
    # puts "d:loop_length: #{loop_length}"
    #  puts "d:loop_num: #{loop_num}"
    #  puts "d:loop_mod: #{loop_mod}"

    if k-1 <= loop_start_index
        # puts "d:hi"
        return path[k-1].to_s
    else
        return (path[loop_start_index + loop_mod] ).to_s
    end
end

puts func

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

using namespace std;
int main() {
	long long N;
	cin >> N;
	// x = N*y*z/(4*y*z-N*(y+z))
	for (long long i = 1; i <= 3500; i++) {
		for (long long j = 1; j <= 3500; ++j) {
			if ((4 * i*j - N * (i + j)) <= 0) {
				continue;
			}
			if (0 == (N*i*j) % (4 * i*j - N * (i + j))) {
				long long k = (N*i*j) / (4 * i*j - N * (i + j));
				cout << i <<" "<< j <<" "<< k << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 3608
function Main(input) {
  input=input.split("\n");
　const N=input[0]-0;
　const K=input[1]-0;
　const X=input[2]-0;
　const Y=input[3]-0;
  if(N<=K){
    console.log(X*N);
  }else{
    console.log(X*K+(N-K)*Y);
  }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  
  


Measured memory_bytes: 29768
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define D(x) cerr << #x << " is " << (x) << "\n";

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
template<class T> ostream& operator<<(ostream& os, const set<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const multiset<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const map<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}

vector<pair<int,int> > AB,BA;
int dp1[3][5001];
vector<vector<ll> > dp2;
int calc1(int tr,int money)
{
    if(tr==AB.size())
        return money;
    if(dp1[tr][money]!=-1)
        return dp1[tr][money];
    int m=money;
    int profit=0;
    dp1[tr][money]=calc1(tr+1,m);
    while(m>=AB[tr].s)
    {
        m-=AB[tr].s;
        profit+=AB[tr].f;
        dp1[tr][money]=max(dp1[tr][money],profit+calc1(tr+1,m));
    }
    return dp1[tr][money];
}
ll calc2(int tr,int money)
{
    if(tr==BA.size())
        return money;
    if(dp2[tr][money]!=-1)
        return dp2[tr][money];
    int m=money;
    ll profit=0;
    if(tr==BA.size()-1)
    {
        int puta=m/BA[tr].s;
        dp2[tr][money]=(ll)puta*BA[tr].f+m-BA[tr].s*puta;
        return dp2[tr][money];
    }
    dp2[tr][money]=calc2(tr+1,m);
    while(m>=BA[tr].s)
    {
        m-=BA[tr].s;
        profit+=BA[tr].f;
        dp2[tr][money]=max(dp2[tr][money],profit+calc2(tr+1,m));
    }
    return dp2[tr][money];
}
int main()
{
    memset(dp1,-1,sizeof(dp1));
	int n;
	scanf("%i",&n);
	int ga,sa,ba,gb,sb,bb;
	scanf("%i %i %i %i %i %i",&ga,&sa,&ba,&gb,&sb,&bb);
	if(ga>gb)
        BA.pb({ga,gb});
    if(ga<gb)
        AB.pb({gb,ga});
    if(sa>sb)
        BA.pb({sa,sb});
    if(sa<sb)
        AB.pb({sb,sa});
    if(ba>bb)
        BA.pb({ba,bb});
    if(ba<bb)
        AB.pb({bb,ba});
    int novo=calc1(0,n);
    dp2.resize((int)BA.size(),vector<ll>(novo+1,-1));
    printf("%lld\n",calc2(0,novo));
    return 0;
}


Measured memory_bytes: 580224
#include<iostream>
#include<algorithm>
#include<vector>
typedef long long ll;

using namespace std;
#define N 100010
ll n,m,x[N];
class UnionFind{
  public:
  ll p[N],es[N],as[N],vs[N];
  void init(){
    for(int i=0;i<N;i++){
      p[i]=i;es[i]=as[i]=0;
      vs[i]=x[i];
    }
  }
  ll Par(ll x){
    ll y=x,z;
    while(y!=p[y])y=p[y];
    while(x!=y)z=p[x],p[x]=y,x=z;
    return x;
  }
  void Unite(ll a,ll b,ll key){
    a=Par(a); b=Par(b);
    if(a==b){
      es[a]++;
      if(vs[a]>=key)as[a]=es[a];
    }
    else{
      p[b]=a;
      es[a]+=es[b]+1;
      as[a]+=as[b];
      vs[a]+=vs[b];
      if(vs[a]>=key)as[a]=es[a];
    }
  }
  ll Solve(){
    ll x=Par(0);
    return as[x];
  }
};UnionFind uf;
ll a[N],b[N];
typedef pair<ll,ll> P;
P d[N];
int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++)cin>>x[i];
    for(int i=0;i<m;i++){
      cin>>a[i]>>b[i];a[i]--,b[i]--;
      ll cost;cin>>cost;
      d[i]=make_pair(cost,i);
    }
    sort(d,d+m);
    uf.init();
    for(int i=0;i<m;i++){
      ll j=d[i].second;
      ll cost=d[i].first;
      uf.Unite(a[j],b[j],cost);
    }
    cout<<m-uf.Solve()<<endl;
    return 0;
}


Measured memory_bytes: 7296
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int i = Integer.parseInt(sc.next());
		if(i == 0) ou.println(1);
		else ou.println(0);
		ou.flush();
	}
}

Measured memory_bytes: 35688
#include <cassert>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int, int> PII;

#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); puts("");}
vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x; while (getline(ss, x, c)) v.push_back(x); return v;}
void err(vector<string>::iterator it) {}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args) {cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}

#if (( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif

#define pb push_back
#define mp make_pair
#define all(x)  (x).begin(),(x).end()
#define tr(c, it)   for(auto it=c.begin(); it!=c.end(); it++)
#define clr(a, b)   memset(a, b, sizeof(a))

const int INF = 0x3f3f3f3f;

int n;
int cnt[100010];

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
#endif

    int cas = 1;
    //scanf("%d", &T);
    while(~scanf("%d",&n))
    {
        clr(cnt, 0);
        for(int i=1; i<=n; ++i)
        {
            int v;
            scanf("%d", &v);
            cnt[v]++;
        }

        int c1 = 0, c2 = 0;
        for(int i=1; i<=100000; i++)
        {
            if(cnt[i] == 0) continue;

            //debug(i, cnt[i]);
            cnt[i] = (cnt[i] - 1) % 2 + 1;
            //debug(i, cnt[i]);

            if(cnt[i] == 1) c1++;
            else c2 ++;
        }

        int ans = c1 + c2 / 2 * 2;
        printf("%d\n", ans);

    }

    return 0;
}


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

const int N = 255000;
const int MOD_CNT = 2;
const int MOD[MOD_CNT] = {(int)1e9 + 7, (int)1e9 + 9};
const int Base = 998244353;

inline int modExp(int a, int n, int mod) {
	int ret = 1;
	while (n) {
		if (n & 1) ret = (long long)ret * a % mod;
		a = (long long)a * a % mod;
		n >>= 1;
	}
	return ret;
}

struct Rab {
	int val[MOD_CNT];
	Rab(long long x = 0, int inv = 0) {
		for (int i = 0; i < MOD_CNT; i++) {
			if (inv) val[i] = modExp(x, MOD[i] - 2, MOD[i]);
			else val[i] = (x % MOD[i] + MOD[i]) % MOD[i];
		}
	}
	Rab operator + (const Rab &d) const {
		Rab ret;
		for (int i = 0; i < MOD_CNT; i++) {
			(ret.val[i] = val[i] + d.val[i]) >= MOD[i] && (ret.val[i] -= MOD[i]);
		}
		return ret;
	}
	Rab operator - (const Rab &d) const {
		Rab ret;
		for (int i = 0; i < MOD_CNT; i++) {
			(ret.val[i] = val[i] - d.val[i]) < 0 && (ret.val[i] += MOD[i]);
		}
		return ret;
	}
	Rab operator * (const Rab &d) const {
		Rab ret;
		for (int i = 0; i < MOD_CNT; i++) {
			ret.val[i] = (long long)val[i] * d.val[i] % MOD[i];
		}
		return ret;
	}
	bool operator == (const Rab &d) const {
		for (int i = 0; i < MOD_CNT; i++) if (val[i] != d.val[i]) return false;
		return true;
	}
	bool operator != (const Rab &d) const {
		for (int i = 0; i < MOD_CNT; i++) if (val[i] != d.val[i]) return true;
		return false;
	}
	bool operator < (const Rab &d) const {
		for (int i = 0; i < MOD_CNT; i++) {
			if (val[i] != d.val[i]) return val[i] < d.val[i];
		}
		return false;
	}
} wrk[N + N], *pw;

char s[N];
map<Rab, int> H;

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n; cin >> n >> s + 1;
	pw = wrk + N;
	pw[0] = 1;
	for (int i = 1; i < N; i++) pw[i] = pw[i - 1] * Base;
	auto inv = Rab(Base, 1);
	for (int i = -1; i > -N; i--) pw[i] = pw[i + 1] * inv;
	
	int p = 0;
	Rab final = 0;
	for (int i = 1; i <= n; i++) {
		if (s[i] == '+') final = final + pw[p];
		if (s[i] == '-') final = final - pw[p];
		if (s[i] == '>') p++;
		if (s[i] == '<') p--;
	}
	
	function<long long(int, int)> calc = [&](int st, int en) {
		if (st == en) {
			Rab cur = 0;
			if (s[st] == '+') cur = cur + pw[0];
			if (s[st] == '-') cur = cur - pw[0];
			if (cur == final) return 1LL;
			else return 0LL;
		}
		int mid = st + en >> 1;
		auto ret = calc(st, mid) + calc(mid + 1, en);
		H.clear();
		int p = 0;
		Rab cur = 0;
		for (int i = mid + 1; i <= en; i++) {
			if (s[i] == '+') cur = cur + pw[p];
			if (s[i] == '-') cur = cur - pw[p];
			if (s[i] == '>') p++;
			if (s[i] == '<') p--;
			H[cur]++;
		}
		cur = 0, p = 0;
		for (int i = mid; i >= st; i--) {
			if (s[i] == '+') cur = cur + pw[0];
			if (s[i] == '-') cur = cur - pw[0];
			if (s[i] == '>') cur = cur * pw[1], p++;
			if (s[i] == '<') cur = cur * pw[-1], p--;
			auto now = (final - cur) * pw[-p];
			if (H.count(now)) ret += H[now];
		}
		return ret;
	};
	
	cout << calc(1, n) << "\n";
	
	return 0;
}


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

#define MAX 10000

using namespace std;

#define inf    0x3f3f3f3f
#define ll long long
#define all(a) (a).begin(),(a).end()
#define INF (int)1e15
#define MOD 1000000007
#define access(i) a[i/3][i%3]



 int main(){

 ll n , k=1, cnt=0; cin>>n;

  n--;

  while(n/k > 0){
      cnt += n/k;
    //  cout<<n/k<<" "<<cnt<<endl;
      k++;
  }

  cout<<cnt<<endl;

  return 0;
 }

Measured memory_bytes: 3568
#include<iostream>
#include<cstdio>
using namespace std;
int n;
char s[15];
long long an[10];
long long ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s);
		if(s[0]=='M')an[1]++;
		if(s[0]=='A')an[2]++;
		if(s[0]=='R')an[3]++;
		if(s[0]=='C')an[4]++;
		if(s[0]=='H')an[5]++;
	}
	for(int i=1;i<=3;i++)
		for(int j=i+1;j<=4;j++)
			for(int k=j+1;k<=5;k++)
				ans+=an[i]*an[j]*an[k];
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

struct Card{
  char suit;
  char value;
};

typedef struct Card Card;

void Bubble(Card *, int);
void Select(Card *, int);

int main(){
  struct Card C1[100], C2[100];
  int n, i,count=0;
  char ch;
  scanf("%d%c", &n,&ch);
  for ( i = 0; i < n; i++ ){
    scanf("%c%c%c", &C1[i].suit, &C1[i].value ,&ch);
  }
  for ( i = 0; i < n; i++ ){
    C2[i]=C1[i];
  }
  
  Bubble(C1,n);
  for ( i = 0; i < n; i++ ){
    printf("%c%c",C1[i].suit,C1[i].value);
    if(i<n-1)printf(" ");
  }
  printf("\nStable\n");

  Select(C2,n);
  for ( i = 0; i < n; i++ ){
    printf("%c%c",C2[i].suit,C2[i].value);
    if(i<n-1)printf(" ");
  }
  printf("\n");
  for(i=0;i<n;i++){
    if(C1[i].suit!=C2[i].suit)count=1;
  }
  if(count==0)printf("Stable\n");
  else printf("Not stable\n");
  
  return 0;
}

void Bubble(Card *A,int n){
  int i,j;
  Card tmp;
  for(i=0;i<n;i++){
    for(j=n-1;j>=1+i;j--){
      if(A[j].value<A[j-1].value){
	tmp=A[j];
	A[j]=A[j-1];
	A[j-1]=tmp;
      }
    }
  }
}

void Select(Card *A,int n){
  int i,j,min;
  Card tmp;
  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(A[j].value<A[min].value){
	min=j;
      }
    }
    if(A[i].value!=A[min].value){
      tmp=A[i];
      A[i]=A[min];
      A[min]=tmp;
    }
  }
}

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

int main() {
  int a, b, c, x;
  int count = 0;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> x;
  
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      for (int k = 0; k <= c; k++) {
        if (500*i + 100*j + 50*k == x) {
          count++;
        }
      }
    }
  }

  cout << count << endl;
  return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#include "bits/stdc++.h"


struct RMQ {
	using t = long long;
	const static t id = std::numeric_limits<t>::min();
	static t f(const t &a, const t &b) {
		return std::max(a, b);
	}
};


template <typename M>
struct SegmentTree {
	int n;
	using T = typename M::t;
	function<T(T, T)> f = M::f;
	T id = M::id;
	std::vector<T> nodes;
	SegmentTree(int _n) {
		_n = minp(_n);
		n = _n;
		nodes.resize(2 * n - 1, id);
	}
	void update(int k, T a) {
		k += n - 1;
		nodes[k] = a;
		while (k > 0) {
			k = (k - 1) / 2;
			nodes[k] = f(nodes[2 * k + 1], nodes[2 * k + 2]);
		}
	}
	T query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
private:
	int minp(int n) {
		int ret = 1;
		while (ret < n)ret *= 2;
		return ret;
	}
	T query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l)return id;
		if (a <= l && r <= b)return nodes[k];
		else {
			T vl = query(a, b, 2 * k + 1, l, (r + l) / 2),
				vr = query(a, b, 2 * k + 2, (r + l) / 2, r);
			return f(vl, vr);
		}
	}
};


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vl h(n);
	REP(i, n)cin >> h[i];
	vl a(n);
	REP(i, n)cin >> a[i];
	SegmentTree<RMQ> st(n);
	REP(i, n) {
		ll c = max(0ll, st.query(0, h[i]));
		st.update(h[i] - 1, c + a[i]);
	}
	ll ans = 0;
	REP(i, n)ans = max(ans, st.query(i, i + 1));
	cout << ans << endl;
}

Measured memory_bytes: 7552
#include<stdio.h>
#include<string.h>

int main(void)
{
  char input[3];
  int cmpABC, cmpARC;
  
  gets(input);
  sscanf(input, "%s");
  
  cmpABC = strcmp(input, "ABC");
  cmpARC = strcmp(input, "ARC");
  
  if(cmpABC == 0)
  {
    printf("ARC\n");
  }
  else if(cmpARC == 0)
  {
    printf("ABC\n");
  }
  else
  {
  }
  
  return 0;
}

Measured memory_bytes: 1708
#!/usr/bin/env python3

def main():
    S = input()
    K = int(input())

    cnt = 0
    ans = 0
    s_temp = S[0]
    fcnt = 0
    for s in S:
        if s_temp == s:
            cnt += 1
            s_temp = s
        else:
            ans += cnt // 2
            if fcnt == 0:
                fcnt = cnt
            cnt = 1
            s_temp = s
    if fcnt == 0:
        fcnt = cnt
    ans += cnt // 2
    ans *= K
    if len(S) == fcnt:
        ans = (len(S) * K) // 2
    elif S[0] == S[-1] and cnt % 2 == 1 and fcnt % 2 == 1:
        ans += K - 1

    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

int main(){
    long long dp[100];
    dp[0] = 2;
    dp[1] = 1;
    for(int i=2;i<100;i++){
        dp[i] = dp[i-1] + dp[i-2];
    }
    int n;
    cin >> n;
    cout << dp[n] << endl;

    return 0;
}

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

int main()
{
	int n;
	cin >> n;
	auto v = vector<int>(n);
	auto c = vector<int>(n);
	for(auto& w : v) cin >> w;
	for(auto& d : c) cin >> d;
	int ans = 0;
	for(auto i = 0; i < n; ++i){
		ans += max(0, v[i] - c[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define dbug printf("I am here\n");
#define Fast ios_base::sync_with_stdio(false); cin.tie(0);
#define vs              v.size()
#define ss               s.size()
#define sot(v)        sort(v.begin(),v.end())
#define rev(v)        reverse(v.begin(),v.end())
#define ii                pair<int,int>
#define ll                long long
#define ull              unsigned long long
#define pb              push_back
#define mpp          make_pair
#define Okay         0
#define pi               3.14159

using namespace std;
const int ll cont = 10e6;
static const ll inf = 1e11;

void solve(){
    ll n, m;
    cin>>n;
   string s;
   cin>>s;
   int cnt = 0;
   for(int i=0; i<n; i++){
    if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')cnt++;
   }
   cout<<cnt<<endl;
}

int main(){
    Fast;
    solve();

    return Okay;
}


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

int main()
{
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < s.size(); i++)
  {
    if (i % 2 == 0)
    {
      if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D')
        cnt++;
    }
    else
    {
      if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D')
        cnt++;
    }
  }
  if (cnt == s.size())
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main()
{
    string s = "abcdefghijklmnopqrstuvwxyz";
    char a;
    cin >>a;
    rep(i, s.length()-1){
        if(s[i] == a){
            cout << s[i+1] << endl;
            return 0;
        }
    }
    cout << 'a' << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <stdio.h>

typedef long long ll;

using namespace std;

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll res = 0;
  if (A % 2 == B % 2) {
    res = (B - A) / 2;
  } else {
    res = min((ll)((A + B) / 2), (ll)((N - A + 1 + N - B + 1) / 2));
  }
  printf("%lld\n", res);
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int M; cin >> M;
    ll cnt=0, sum=0;
    rep(i, M){
        ll d, c; cin >> d >> c;
        cnt += c;
        sum += d * c;
    }

    cout << cnt-1 + (sum-1)/9 << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int ans(int arr[],int dp[],int n){
    if(n==1){
        return 0;
    }
  
  if(n==2)
  {if(dp[n-1]!=-1){
  return dp[n-1];
  }
  else{
      dp[1]=abs(arr[n-1]-arr[0]);
    return dp[n-1];
  }
 }
  else if(n>2){
      if(dp[n-1]!=-1){
  return dp[n-1];
  }
  else{
      dp[n-1]=min(ans(arr,dp,n-1)+abs(arr[n-2]-arr[n-1]),ans(arr,dp,n-2)+abs(arr[n-1]-arr[n-3]));
    return dp[n-1];
  }
  }
 
}
int main(){
  int n;
  int a;
  scanf("%d",&n);
  int arr[n];
  int dp[100001];
  memset(dp,-1,sizeof(dp));
  for(int i=0;i<n;i++){
    scanf("%d",&arr[i]);}
  a=ans(arr,dp,n);
  printf("%d",dp[n-1]);
return 0;
}

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

int main() {
  long count =0;
  long a,b,r,x,tmp;
  cin>>a>>b;
  x=a*b;
    if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
    r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  cout<<x/b;
}


Measured memory_bytes: 256
#include <stdio.h>

    int main(void)
    {
       int a,b,c;
       scanf("%d%d%d",&a,&b,&c);
       if(a<b){
         if(b<c){
         printf("Yes\n");
         }else{
         printf("No\n");
         }
        }else{
         printf("No\n");
        }
	return 0;
    }

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
int x,y;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	long long mn=0;
	cin>>x>>y;
	if(x==1)
		mn+=300000;
	if(x==2)
		mn+=200000;
	if(x==3)
		mn+=100000;
	if(y==1)
		mn+=300000;
	if(y==2)
		mn+=200000;
	if(y==3)
		mn+=100000;
	if(x==y&&x==1)
		mn+=400000;
	cout<<mn<<endl;
	return 0;
}


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

using namespace std;

int main() {

  int a, b, c;
  cin >> a;
  double ans, ra, rb;
  if(a <= 7 && a % 2 == 1 && a != 1){
    cout << "YES";
  }else{
    cout << "NO";
  }
  return 0;
}


Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    long long n; 
    long long ans = 1;
    cin >> n;
    for(size_t i = 1; i <= n; i++)
    {
        ans *= i;
        ans %= 1000000007;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
___mennat khoday ra azz o va jall ke taatash mojebe ghorbat ast o be shokr andarash mazide nemat.
___har nafasi ke foro miravad momedde hayatast o chon bar miayad mofarrahe zat.
___pas dar har nafasi 2 nemat mojod ast o bar har nematy shokry vajeb.

___az dast o zabane ke barayad ?
___kaz ohdeye shokrash be dar ayad !


___man be to dami gharar natvanam kard
___va ehsane to ra shomar natvanam kard
####################
___gar bar tane man zaban shavad har moyee
___yek shokre to az hezar natvanam kard

*/

#include <bits/stdc++.h>

#define pb push_back
#define SALI main
#define left(x) ((x)*2)
#define right(x) (((x)*2)+1)
#define fuck(x) cout << #x << " : " << x << endl;
#define findLowVec(v,x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define findUpVec(v,x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define findLowArr(a,n,x) (lower_bound(a, a+n, x) - a)
#define findUpArr(a,n,x) (upper_bound(a, a+n, x) - a)
#define int long long

using namespace std;

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

template<class A, class B> ostream& operator <<(ostream& out, const pair<A, B> &p)
{return out << "(" << p.first << ", " << p.second << ")";}

template<class A> ostream& operator <<(ostream& out, const vector<A> &v)
{out << "[";for(int i = 0; i < v.size(); i++) {if(i) out << ", ";out << v[i];}return out << "]";}

template<class A,class B> ostream& operator <<(ostream& out, const set<A,B> &s)
{out << "[";for(auto i = s.begin(); i != s.end(); i++) {out << ", ";out << *i;}return out << "]";}

template<class A> ostream& operator <<(ostream& out, const set<A> &s)
{out << "[";for(auto i = s.begin(); i != s.end(); i++) {out << ", ";out << *i;}return out << "]";}

const int N = 52;
const int mod = 1e9 + 7;

struct matrix
{

    int a[N][N];

    matrix(int idd = 0){
        for(int i = 0;i<N;i++){
            for(int j = 0;j<N;j++){
                a[i][j] = (idd) ? (i == j) : (0);
            }
        }
    }

    matrix operator*(const matrix& other)const{
        matrix ans;

        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                for(int k = 0; k < N; k++){
                    ans.a[i][j] += a[i][k] * other.a[k][j];
                    ans.a[i][j] %= mod;
                }
            }
        }
        return ans;
    }

};

matrix power(matrix base, int k)
{
    matrix ans(1);

    for(int i = 0;(1LL << i) <= k;i++){
        if((1LL << i) & k) ans = ans*base;
        base = base*base;
    }

    return ans;
}

int32_t SALI()
{
    int n,k;
    cin >> n >> k;
    matrix a;
    for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) cin >> a.a[i][j];
    matrix ans = power(a,k);
    int tot = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            tot += ans.a[i][j];
            tot %= mod;
        }
    }

    cout << tot;


}




/**< WRITEN BY ALI ADELKHAH */



Measured memory_bytes: 3696
#include <stdio.h>
int main(void){
    int i, ii, iii, n, x, y, a[10000], ans = 0;
    char s[1000000], t[1000000];
    scanf("%s%s", s, t);
    for (i = 0; s[i] > 0; i++)
    {
        if (s[i] - t[i])
            ans++;
    }
    printf("%d", ans);
    
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
int n;
vvin g;

ll dp[110000][2];

void dfs(int now,int par){
  dp[now][0]=1;
  dp[now][1]=1;
  for(auto v:g[now]){
    if(v==par)continue;
    dfs(v,now);
    dp[now][0]=dp[now][0]*(dp[v][0]+dp[v][1]%inf)%inf;
    dp[now][1]=dp[now][1]*(dp[v][0])%inf;
  }
  return;
}

int main(){cout<<fixed<<setprecision(20);
		   cin>>n;
           g.resize(n);
           rep(i,0,n-1){
            int a,b;
             cin>>a>>b;
             a--;b--;
             g[a].pb(b);
             g[b].pb(a);
           }
           dfs(0,-1);
           cout<<(dp[0][0]+dp[0][1])%inf<<endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  int A, B;
  sort(a.begin(), a.end());
  while(a.size() > 0) {
    A += a.at(a.size() - 1);
    a.pop_back();
    if(a.size() > 0) {
      B += a.at(a.size() - 1);
      a.pop_back();
    }
    else break;
  }
  cout << A - B << endl;
}

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

const int MOD = 1e9+7;

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

  vector<int> dp(n+1);
  dp[0] = 1;
  vector<int> clr(3, 0);
  rep(i, n) {
    int c = 0;
    rep(ci, 3) if (clr[ci] == a[i]) ++c;
    dp[i+1] = (ll)dp[i] * c % MOD;
    rep(ci, 3) {
      if (clr[ci] == a[i]) {
        clr[ci]++;
        break;
      }
    }
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,typename=enable_if_t<iterable<T>::value>>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    cout<<setprecision(10);
    int x,y;
    cin>>x>>y;
    int a=0;
    if(x==1&&y==1)a+=4;
    if(x<4)a+=4-x;
    if(y<4)a+=4-y;
    if(a==0)cout<<0<<endl;
    else cout<<a<<"00000\n";

}


Measured memory_bytes: 256
a,b,c,d = list(map(int, input().split()))

if a < c:
    if d <= b:
        print(d - c)
    elif c <= b:
        print(b - c)
    else:
        print(0)
else:
    if b <= d:
        print(b - a)
    elif a <= d:
        print(d - a)
    else:
        print(0)


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

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

Measured memory_bytes: 256
import math
n,m = map(int, input().split())
switch = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int, input().split()))
count = 0
for j in range(2**n):#スイッチ

    flag = True
    for i in range(m):
        on = 0
        for k in switch[i][1:]:
            if (j >> k-1) & 1:
                on += 1
        if on % 2 != p[i]:
            flag = False
            #break
    if flag:
        count +=1
print(count)

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

typedef long long ll;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define yes "Yes"
#define yse "Yes"
#define no "No"

#define pb push_back
#define rep(i, l, n) for (int i = (l); i < n; i++)
#define rep_cs(i, l, n) for (int i = (l); i <= n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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 MOD = 1000000007;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(v.begin(), v.end());
// int sum = accumulate(v, v + v.size(), 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

using Graph = vector<vector<int>>;
Graph G;
vector<bool> seen;
void dfs(const Graph &G, int v)
{
    seen[v] = true;

    for (auto next_v : G[v])
    {
        if (seen[next_v])
            continue;
        dfs(G, next_v);
    }
}

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

    cout << 3 * x * x << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main()

{

    int h, w;
    cin >> h >> w;
    char a[h][w];
    int row[w];
    int col[h];
    /*初期化*/
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            a[i][j] = '-';
        }
    }
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < h; i++)
    {
        col[i] = 0;
    }
    for (int i = 0; i < w; i++)
    {
        row[i] = 0;
    }
    //初期化おわり

    for (int i = 0; i < h; i++)
    {
        int count = 0;
        for (int j = 0; j < w; j++)
        {
            if (a[i][j] == '#')
            {
                count = 1;
            }
        }
        if (count == 0)
        {
            col[i] = 1;
        }
    }

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

        int count = 0;
        for (int j = 0; j < h; j++)
        {
            if (a[j][i] == '#')
            {
                count = 1;
            }
        }
        if (count == 0)
        {
            row[i] = 1;
        }
    }

    //  cout << "-------------^\n";
    for (int i = 0; i < h; i++)
    {

        int count = 0;
        for (int j = 0; j < w; j++)
        {
            if (col[i] == 0 && row[j] == 0)
            {
                cout << a[i][j];
                count = 1;
            }
        }
        if (count == 1)
        {
            cout << "\n";
        }
    }
    /*
    cout << "col-------------\n";
    for (int i = 0; i < h; i++)
    {
        cout << col[i];
    }
    cout << "row--------------\n";
    for (int i = 0; i < w; i++)
    {
        cout << row[i];
    }*/
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a1: [i32; 3],
        a2: [i32; 3],
        a3: [i32; 3],
        n: usize,
        b: [i32; n],
    }

    let mut card = vec![vec![false; 3]; 3];

    for x in &b {
        if let Some(i) = a1.iter().position(|y| y == x) {
            card[0][i] = true;
            continue;
        }

        if let Some(i) = a2.iter().position(|y| y == x) {
            card[1][i] = true;
            continue;
        }

        if let Some(i) = a3.iter().position(|y| y == x) {
            card[2][i] = true;
            continue;
        }
    }

    if card[0].iter().all(|&e| e == true)
        || card[1].iter().all(|&e| e == true)
        || card[2].iter().all(|&e| e == true)
        || (card[0][0] == true && card[1][0] == true && card[2][0] == true)
        || (card[0][1] == true && card[1][1] == true && card[2][1] == true)
        || (card[0][2] == true && card[1][2] == true && card[2][2] == true)
        || (card[0][0] == true && card[1][1] == true && card[2][2] == true)
        || (card[0][2] == true && card[1][1] == true && card[0][2] == true)
    {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n , x) for (int i = (int)(x); i < (int)(n); ++i)
#define repB(i, n) for (int i = n; i >= 1; --i)
#define repBX(i, n , x) for (int i = (int)(n); i >= int(X); --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int H,N;
    ll A = 0;
    cin >> H >> N;
    rep(i,N){
        int a;
        cin >> a;
        A += a;
    }
    if(H<=A){
        cout << "Yes" << endl;
    }else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int n;
  cin >> n;
  int first = n/100;
  int second = n%100;
  bool mon_first = false, mon_second = false;
  if(first>=1&&first<=12) mon_first = true;
  if(second>=1&&second<=12) mon_second = true;
  if(mon_first){
    if(mon_second){
      cout << "AMBIGUOUS" << endl;
    }else{
      cout << "MMYY" << endl;
    }
  }else{
    if(mon_second){
      cout << "YYMM" << endl;
    }else{
      cout << "NA" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 384
use std::env;
use std::io::*;
use std::str::*;
use std::mem;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn read_char() -> char {
    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>();
    c[0]
}
fn read_String_Vec() -> Vec<char> {
    let S = read::<String>();
    S.chars().collect::<Vec<char>>()
}

fn vecchar_to_String(Vs: &Vec<char>) -> String {
    let mut S = String::new();
    for i in 0..Vs.len() {
        S.push(Vs[i]);
    }
    S
}

/*
A : 65
Z : 90
a : 97
z : 122
*/

/*
let N = read::<i32>();
let S = read::<String>();
let S = read_String_Vec();
let C = read_char();
*/

/*
 .to_string() : * -> String
 &*S          : String -> &str
*/

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let N = read::<usize>();
    let mut Four = false;
    for n in 0..N {
        let C = read_char();
        if C == 'Y' {
            Four = true;
        }
    }

    if Four {
        println!("Four");
    } else {
        println!("Three");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define INF (1<<21)
const int maxn=100+10;
const int maxw=10000+10;
int n,W;
int w[maxn];
int v[maxn];
int d[maxw];
void solve()
{
    memset(d,0,sizeof(d));
    for(int i=0;i<n;i++)
    {
        for(int j=W;j>=w[i];j--)
        {
            d[j]=max(d[j],d[j-w[i]]+v[i]);
        }
    }
    printf("%d\n",d[W]);
}
int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d%d",&n,&W);
    for(int i=0;i<n;i++) scanf("%d%d",&v[i],&w[i]);

    solve();

    return 0;
}

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

// Shortening code
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;

// Macros
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = a; i >= b; i--)

const ll INF = 1e18;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // Your code
    string s, t;
    cin >> s;
    cin >> t;
    vector<vi> dp(s.length() + 1, vi(t.length() + 1));

    REP(i, 1, s.length() + 1)
    {
        REP(j, 1, t.length() + 1)
        {
            if (s[i - 1] == t[j - 1])
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }

    int i = s.length(), j = t.length(), cur = dp[i][j];
    string ans;
    while (dp[i][j] > 0)
    {
        while (dp[i][j - 1] == cur)
            j--;
        while (dp[i - 1][j] == cur)
            i--;
        ans += t[j - 1];
        i--;
        j--;
        cur--;
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
    return 0;
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    int K = 0,cnt = 1;
    for(;K < N;cnt++)K += cnt;
    if(K != N){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    cout << cnt << endl;
    vector<int> V[cnt];
    int re = cnt-1,idx1 = 0,idx2 = 1;
    rep(i,1,N+1){
        V[idx1].push_back(i);
        V[idx2].push_back(i);
        if(idx2 == cnt-1){
            idx1++;
            idx2 = idx1 + 1;
        }else idx2++;
    }
    rep(i,0,cnt){
        cout << cnt - 1 << " ";
        rep(j,0,cnt-1)cout << V[i][j] << " \n"[j==cnt-2];
    }
}

Measured memory_bytes: 2304
N = int(input())

S = []

ans = 0

for i in range(N):

    s = list(input())
    S.append(s)


for A in range(N):

    flag = True

    for i in range(N):

        for j in range(i):

            if S[(i+A) % N][j % N] != S[(j+A) % N][i % N]:
                flag = False
                break

        if not flag:
            break

    if flag:
        ans += N

print (ans)


Measured memory_bytes: 45276
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApps
{
    class Program
    {
        static void Main(string[] args)
        {
            while(true){
                //Console.WriteLine("初めの数字を入力してください");
		int i = 0;
                if(int.TryParse(Console.ReadLine(), out i)){
                    if(i == 0) return;
                    int a, b;a = b = 0;
                    for(int u = 0; u < i; u++){
                        string s = Console.ReadLine();
                        int[] iis = s.Split().Select(x => int.Parse(x)).ToArray();
                        //Console.WriteLine(iis[0] + iis[1]);
                        a += iis[0] > iis[1] ? iis[0] + iis[1] : iis[0] == iis[1] ? iis[0] : 0; 
                        b += iis[0] < iis[1] ? iis[0] + iis[1] : iis[0] == iis[1] ? iis[1] : 0; 
                    }
                    Console.WriteLine("{0} {1}",a, b);


                }

            }

        }
    }
}



Measured memory_bytes: 9836
#include <iostream>
using namespace std;
int main(){
    int a,b,c,f,s,t;
    cin >> a >> b >> c;
    if ((a<=b) && (a<=c)) {
        f=a;
        if (b<=c) s=b,t=c;
        else s=c,t=b;
    } else if ((b<=a) && (b<=c)){
        f=b;
        if (a<=c) s=a,t=c;
        else s=c,t=a;
    } else {
        f=c;
        if (a<=b) s=a,t=b;
        else s=b,t=a;
    }
    
    cout << f << " " << s << " " << t << "\n";
    return 0;
}


Measured memory_bytes: 3064