akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
  }
}init;

template <size_t N> int gaussian_elimination(vector<bitset<N>> &m){
  int n = m.size();
  int rank = 0;

  REV(j,N-1,0){
    int pivot = -1;

    FOR(i,rank,n){
      if(m[i][j]){
        pivot = i;
        break;
      }
    }

    if(pivot == -1) continue;

    swap(m[pivot], m[rank]);

    REP(i,n){
      if(i != rank and m[i][j]) m[i] ^= m[rank];
    }
    ++rank;
  }
  
  return rank;
}




int main(){
  int N;
  while(cin >> N){
    vector<bitset<60>> a(N);
    REP(i,N){
      LLI x; cin >> x;
      a[i] = x;
    }

    LLI ans = 0;
    
    REP(i,60){
      int c = 0;
      REP(j,N){
        if(a[j][i]) ++c;
      }

      if(c % 2 == 1){
        ans += bit(i);
        REP(j,N){
          a[j].reset(i); 
        }
      }
    }
    
    gaussian_elimination(a);

    bitset<60> t = 0;
    REP(i,N){
      t = t ^ a[i];
    }

    ans += t.to_ullong() * 2;

    cout << ans << endl;
  }


  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD=998244353;
int pw(int n,int k){
  if(k<0)return pw(n,k+MOD-1);
  int res=1;
  while(k){
    if(k&1)res*=n;res%=MOD;
    n*=n;n%=MOD;
    k>>=1;
  }
  return res;
}
std::vector<int> Factorial(1e7+2),Finverse(1e7+2);
void Cinit(){// limit is 5e6 /// write Cinit&pw /// this takes 792ms at AtCoder
  Factorial[0]=1;
  for(int i=1;i<1e7+2;i++)Factorial[i]=Factorial[i-1]*i%MOD;
  for(int i=0;i<1e7+2;i++)Finverse[i]=pw(Factorial[i],MOD-2);
}
int nCk(int n,int k){
  if(n<k)return 1;if(k<0)return 0;
  int res=Factorial[n];
  res*=Finverse[k];res%=MOD;
  res*=Finverse[n-k];res%=MOD;
  return res;
}

signed main(){
  Cinit();
  int n;cin>>n;
  int ans=pw(3,n);
  for(int i=n/2+1;i<=n;i++){
    ans-=2*nCk(n,i)*pw(2,n-i)%MOD;
    ans+=MOD;ans%=MOD;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 156544
#include<iostream>

using namespace std;


int main(){
	int w, h, n;
	int map[101][101];
	int i, j, k, l;
	int rectaW, rectaH;
	int maxtrees, count;
	int temp1, temp2;


	while (1){
		maxtrees = 0;
		for (i = 0; i <= 100; i++){
			for (j = 0; j <= 100; j++){
				map[i][j] = 0;
			}
		}


		cin >> n;
		if (n == 0){
			break;
		}
		cin >> w >> h;

		for (i = 0; i < n; i++){
			cin >> j >> k;
			map[j][k] = 1;
		}
		
		cin >> rectaW >> rectaH;
		
		
		for (i = 1; i <= w - rectaW + 1; i++){
			for (j = 1; j <= h - rectaH + 1; j++){
				count = 0;
				for (k = i; k <= i+rectaW-1; k++){
					for (l = j; l <= j+rectaH-1; l++){
						if (map[k][l] == 1){
							count++;
						}
					}
				}
				if (count > maxtrees){
					maxtrees = count;
					temp1 = i;
					temp2 = j;
				}
			}
		}

		cout << maxtrees << endl;		
			
	}
}

Measured memory_bytes: 1200
/***********************************************
 *                   _ooOoo_                   *
 *                  o8888888o                  *
 *                  88" . "88                  *
 *                  (| -_- |)                  *
 *                  O\  =  /O                  *
 *               ____/`---'\____               *
 *             .'  \\|     |//  `.             *
 *            /  \\|||  :  |||//  \            *
 *           /  _||||| -:- |||||-  \           *
 *           |   | \\\  -   * |    |           *
 *           | \_|  ''\---/''  |   |           *
 *           \  .-\__  `-`  ___/-. /           *
 *         ___`. .'  /--.--\  `. . __          *
 *      ."" '<  `.___\_<|>_/___.'  >'"".       *
 *     | | :  `- \`.;`\ _ /`;.`/ - ` : | |     *
 *     \  \ `-.   \_ __\ /__ _/   .-` /  /     *
 *======`-.____`-.___\_____/___.-`____.-'======*
 *                   `=---='                   *
 *^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

             佛祖保佑       永无BUG

   本程序已经经过开光处理，绝无可能再产生bug
 **********************************************/
#include<algorithm>
#include <iostream>
#include  <cstdlib>
#include  <cstring>
#include   <string>
#include   <vector>
#include   <cstdio>
#include    <queue>
#include    <stack>
#include    <ctime>
#include    <cmath>
#include      <map>
#include      <set>
#define ll long long
#define INF 0x3f3f3f3f
#define pii pair<int,int>
#define mkp(a,b) make_pair(a,b)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define db1(x) cout<<#x<<"="<<(x)<<endl
#define db2(x,y) cout<<#x<<"="<<(x)<<", "<<#y<<"="<<(y)<<endl
#define db3(x,y,z) cout<<#x<<"="<<(x)<<", "<<#y<<"="<<(y)<<", "<<#z<<"="<<(z)<<endl
#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<22,stdin),p1==p2)?EOF:*p1++)
using namespace std;

int peo[100010];

int main()
{
    #ifdef test
    freopen("in.txt","r",stdin);
    //freopen("in.txt","w",stdout);
    clock_t start=clock();
    #endif //test


    int N,K,Q;
    scanf("%d%d%d",&N,&K,&Q);
    for(int i=0;i<Q;i++)
    {
        int cnt;
        scanf("%d",&cnt);
        peo[cnt]++;
    }
    for(int i=1;i<=N;i++)
    {
        if(K-Q+peo[i]>0)printf("Yes\n");
        else printf("No\n");
    }

    #ifdef test
    clockid_t end=clock();
    double endtime=(double)(end-start)/CLOCKS_PER_SEC;
    printf("\n\n\n\n\n");
    cout<<"Total time:"<<endtime<<"s"<<endl;        //s为单位
    cout<<"Total time:"<<endtime*1000<<"ms"<<endl;    //ms为单位
    #endif //test
    return 0;
}


// ━━━━━━神兽出没━━━━━━
//      ┏┓       ┏┓
//     ┏┛┻━━━━━━━┛┻┓
//     ┃           ┃
//     ┃     ━     ┃
//     ????━????   ┃
//     ┃           ┃
//     ┃    ┻      ┃
//     ┃           ┃
//     ┗━┓       ┏━┛
//       ┃       ┃
//       ┃       ┃
//       ┃       ┗━━━┓
//       ┃           ┣┓
//       ┃           ┏┛
//       ┗┓┓┏━━━━━┳┓┏┛
//        ┃┫┫     ┃┫┫
//        ┗┻┛     ┗┻┛
//
// ━━━━━━感觉萌萌哒━━━━━━


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

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  
    int A, B;
    cin >> A >> B;
    int counter=0;
    for(int i=A; i<=B; i++)
    {
        string s = to_string(i);
        string t = s;
        reverse(ALL(s));
        if (s==t) counter++;
    }
    cout << counter << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n - 1);
    for(int i = 0; i < n; i++) cin >> a[i];
    int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> b[i];
        ans += b[i];
    }
    for(int i = 0; i + 1 < n; i++){
        cin >> c[i];
    }
    for(int i = 1; i < n; i++){
        if(a[i] == a[i - 1] + 1){
            ans += c[a[i] - 2];
        }
    }
    cout << ans;

    return 0;
}



Measured memory_bytes: 3624
H, W = map(int, input().split())
C = [[i for i in input().split()] for i in range(H)]
C_convert = [[0] * W] * 2 * H
for i in range(2 * H):
    C_convert[i] = C[i // 2]

for i in range(2 * H):
    print(*C_convert[i])


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<int,int> P;
const ll mod=1e9+7;

int n;
vector<int> g[10010];
vector<int> d(10010);

void dfs(int dep,vector<bool>& used,priority_queue<int>& c){
  if(used[dep]) return;
  if(c.empty()) return ;
  used[dep]=true;
  for(auto itr:g[dep]){
    if(used[itr]) continue;
    d[itr]=c.top();
    c.pop();
    dfs(itr,used,c);
  }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    rep(i,n-1){
      int a,b;
      cin>>a>>b;
      g[a].push_back(b);
      g[b].push_back(a);
    }
    priority_queue<int> c;
    ll ans=0;
    rep(i,n){
      int x;
      cin>>x;
      ans+=x;
      c.push(x);
    }
    ans-=c.top();
    vector<bool> used1(n+1,false);
    d[1]=c.top();
    c.pop();
    dfs(1,used1,c);
    cout<<ans<<endl;
    FOR(i,1,n+1){
      cout<<d[i]<<' ';
    }
    cout<<endl;
}

Measured memory_bytes: 1664
n = gets.to_i

tb = 0
xb = 0
yb = 0
ta = 0
xa = 0
ya = 0

1.upto(n) do
  ta, xa, ya = gets.split.map(&:to_i)
  dt = ta-tb
  dx = xa-xb
  dy = ya-yb
  if dx.abs + dy.abs <= dt && (dx+dy-dt)%2 == 0
    tb = ta
    xb = xa
    yb = ya
  else
    puts "No"
    exit
  end
end

puts "Yes"


Measured memory_bytes: 1788
n,x,y = [int(e) for e in input().split() ]
dst=[0]*(n+1)
for i in range(1,n+1):
  for j in range(i+1,n+1):
    l = abs(i - j)
    lxi = abs( x - i )
    lyj = abs( y - j )
    lu  = lxi + 1 + lyj
    dst[min([l,lu])] += 1

for i in range(1,n):
  print(dst[i])

    
  

Measured memory_bytes: 3444
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a,0,sizeof(a))
#define minus(a) memset(a,0xff,sizeof(a))
#define chmax(a,b) a=min((a),(b))
#define chmin(a,b) a=max((a),(b))


#define MOD 1000000007

typedef pair<int,int>P;
#define INF (1<<29)
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

int n;
string s;

int main(){
	cin >> n;
	cin >> s;
	int cnt = 0;
	string ans = s;
	for (auto a : s) {
		if (cnt == 0) {
			if (a == ')')
				ans = '(' + ans;
			else//(
				cnt++;
		}
		else {//cnt>0
			if (a == ')')
				cnt--;
			else//(
				cnt++;
		}
	}
	rep(i, cnt) {
		ans = ans + ')';
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
P = [int(n)-1 for n in input().split()]

cnt = 0
for i in range(N-1):
  if i == P[i]:
    tmp = P[i]
    P[i] = P[i+1]
    P[i+1] = tmp
    cnt += 1
if P[N-1] == N-1:
  cnt += 1
print(cnt)

Measured memory_bytes: 13880
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    int N; cin>>N;
    vec A(N);
    rep(i,N) scanf("%lld",&A[i]);
    sort(all(A));
    vec S(N+1); S[0]=0;
    rep(i,N) S[i+1]=S[i]+A[i];
    int k=N-1,ans=1;
    while(A[k]<=2*S[k]){
        k--; ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(){
    int a,b,ans;
    scanf("%d %d",&a,&b);
    ans = 0;
    if(a > b){
        ans = a + (a-1);
    }
    else if(a==b){
        ans = a*2;
    }
    else{
        ans = b + (b-1);
    }
    printf("%d",ans);
}


Measured memory_bytes: 128
import sys,collections;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
cx,cy,ct = 0,0,0
for i in range(n):
    t,x,y = Is()
    dt,dd =  t-ct, abs(x-cx)+abs(y-cy)
    if dt < dd or (dt-dd)%2 != 0:
        print("No")
        exit()
    cx,cy,ct = x,y,t
print("Yes")

Measured memory_bytes: 3436
#include<stdio.h>
#include<math.h>

int main(void){
  int a, b, c;
  double s, area;
  scanf("%d %d %d", &a, &b, &c);
  s = (a+b+c)/2;
  area = sqrt(s*(s-a)*(s-b)*(s-c));
  printf("%d", (int)area);
  return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map(String::toInt)
    val XYZ = Array(N) { readLine()!!.split(" ").map(String::toLong) }
    
    val signs =  arrayOf(
        arrayOf(+1, +1, +1),
        arrayOf(+1, +1, -1),
        arrayOf(+1, -1, +1),
        arrayOf(+1, -1, -1),
        arrayOf(-1, +1, +1),
        arrayOf(-1, +1, -1),
        arrayOf(-1, -1, +1),
        arrayOf(-1, -1, -1)
    )
    
    println(signs.map { sign ->
        XYZ.map {
            sign[0] * it[0] + sign[1] * it[1] + sign[2] * it[2]
        }.sortedDescending().slice(0 until M).sum() 
    }.max())
}


Measured memory_bytes: 40464
import bisect

N = int(input())
L = list(map(int, input().split()))

L.sort()
ans = 0

for i in range(N-2):
    for j in range(i,N-1):
        l1 = L[N-1-i]
        l2 = L[N-2-j]
        
        l = N - 2 - j - bisect.bisect_right(L, l1-l2)
        if l >= 0:
            ans += l

print(ans)

Measured memory_bytes: 3188
#include <map>
#include <algorithm>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmin(T &a, T b) { return a>b?(a=b,true):false; }
template<class T> bool chmax(T &a, T b) { return a<b?(a=b,true):false; }
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define bs2int(bs) (int)((bs).to_ulong())
#define FOR(i,x,y) for(int i=(x);i<(int)(y);i++)
#define FORP(i,x,y) for(int i=(x);i<=(int)(y);i++)
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define REPP(i,y) for(int i=1;i<=(int)(y);i++)
#define REPB(i,n) for(int i=(int)(n)-1;i>=0;i--)

int n;
vector<int> a(100010);

void msg(string s) {
  cout << s << endl;
  exit(0);
}

int main() {
  cin>>n;
  REP(i,n) cin>>a[i];
  int k=0,l=0,m=0;
  REP(i,n)
  {
    if (a[i]%4==0) k++;
    else if (a[i]%2==0) l++;
    else m++;
  }
  if (k+1<m) msg("No");
  else if (k+1==m)
  {
    if (l==0) msg("Yes");
    else msg("No");
  }
  msg("Yes");
}


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

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

	if(a == b)
		cout << "a == b" << endl;

	if(a < b)
		cout << "a < b" << endl;

	if(a >b)
		cout << "a > b" << endl;
	return 0;
}

Measured memory_bytes: 3084
//I am so vegetable
#include <bits/stdc++.h>
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _defor(i,a,b) for((i) = (a);(i)<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto p:st)
//#define _LOCAL_
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll maxn = 2e3+5;
const int MOD = 1e9 + 7;
const double exps = 1e-6;
int C[maxn][maxn];
int main() {
#ifdef _LOCAL_
	ifstream cin("E:\\acm dream\\in.txt");
	ofstream cout("E:\\acm dream\\out.txt");
#endif
	//srand((unsigned)time(nullptr));
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	C[0][0] = 1;
	_for(i, 1, maxn) {
		C[i][0] = 1;
		_for(j, 1, maxn) {
			C[i][j] = C[i - 1 ][j] + C[i - 1][j - 1];
			if (C[i][j] >= MOD)C[i][j] -= MOD;
		}
	}
	int n, k; cin >> n >> k;
	_for(i, 1, k + 1) {
		cout << (1ll*C[n - k + 1][i] * C[k - 1][i - 1]) % MOD << '\n';
	}
	return 0;
}

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

int main(){
  long long int k;
  string s;
  cin >> k >> s; 
  if(s.size() <= k){
    cout << s << endl;
  } else {
    for(int i=0; i<k; i++){
      cout << s[i];
  }
    cout << "..." << endl;
  }
}


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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

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

    int* A;
    NEW(A,N);
    for(int i=0;i<N;i++){
        scanf("%d", &A[i]);
    }

    int* B;
    NEW(B,N);
    for(int i=0;i<N;i++){
        scanf("%d\n", &B[i]);
    }

    int* C;
    NEW(C,N);
    for(int i=0;i<N-1;i++){
        scanf("%d", &C[i]);
    }

    //料理を食べた時の総満足度
    int sum=0;
    for(int i=0;i<N;i++){
        sum+=B[i];
    }

    //得られるボーナス満足度
    int bonus=0;
    for(int i=0;i<N-1;i++){
        if(A[i+1]==A[i]+1){
            bonus+=C[A[i]-1];
        }
    }

    int ans=sum+bonus;

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

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	long long n, i, j, k, ans;
	cin >> n;
	if (n % 2 == 1) ans = 0;
	else {
		ans = 0;
		n /= 2;
		while (n > 0) {
			ans += n / 5;
			n /= 5;
		}
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int n, m;
char S[3010];
int s[3010];
pp q[3010];

ll dp[3010][3010];
const ll mod = 1000000007;
ll C[3010][3010];

int main()
{
	int m_;
	read(n, m_);
	scanf("%s", S+1);
	for(int i=1; i<=n; ++i){ s[i] = s[i-1] + (S[i]=='1'); }
	
	C[0][0] = 1;
	for(int i=1; i<=3000; ++i){
		C[i][0] = C[i][i] = 1;
		for(int j=1; j<i; ++j) C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	
	for(;m_--;){
		int a, b; read(a, b);
		if(!m){ q[++m] = {a, b}; continue; }
		if(q[m].x == a){ q[m].y = max(q[m].y, b); continue; }
		if(b < q[m].y) continue;
		q[++m] = {a, b};
	}
	
	dp[0][0] = 1;
	
	for(int i=1; i<=m; ++i){
		int kbef = 0;
		if(1 < i) kbef = max(0, q[i-1].y-q[i].x+1);
		int b = s[q[i].y]-s[q[i].x+kbef-1];
		int knxt = 0;
		if(i < m) knxt = max(0, q[i].y-q[i+1].x+1);
		
		int l = q[i].y-q[i].x+1;
		for(int j=0; j<=kbef; ++j){
			int budget = j+b;
			for(int k=0; k<=knxt; ++k){
				if(k > budget || (budget-k)>(l-knxt)) continue;
				(dp[i][k] += dp[i-1][j] * C[l-knxt][budget-k] % mod) %= mod;
			}
		}
		
		/*
		printf("dp of %d : kbef %d, knxt %d\n", i, kbef, knxt);
		for(int j=0; j<=knxt; ++j){
			if(!dp[i][j]) continue;
			printf("dp[%d][%d] = %lld\n", i, j, dp[i][j]);
		}
		*/
	}
	
	printf("%lld\n", dp[m][0]);
	return 0;
}


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

int main() {
  vector<vector<int>> c(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> c.at(i).at(j);
    }
  }
  bool ok = true;
  
  if (c.at(1).at(0) - c.at(0).at(0) != c.at(1).at(1) - c.at(0).at(1) 
      || c.at(1).at(0) - c.at(0).at(0) != c.at(1).at(2) - c.at(0).at(2)) {
    ok = false;
  }
  if (c.at(2).at(0) - c.at(0).at(0) != c.at(2).at(1) - c.at(0).at(1) 
      || c.at(2).at(0) - c.at(0).at(0) != c.at(2).at(2) - c.at(0).at(2)) {
    ok = false;
  }
  if (c.at(0).at(1) - c.at(0).at(0) != c.at(1).at(1) - c.at(1).at(0) 
      || c.at(0).at(1) - c.at(0).at(0) != c.at(2).at(1) - c.at(2).at(0)) {
    ok = false;
  }
  if (c.at(0).at(2) - c.at(0).at(0) != c.at(1).at(2) - c.at(1).at(0) 
      || c.at(0).at(2) - c.at(0).at(0) != c.at(2).at(2) - c.at(2).at(0)) {
    ok = false;
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

constexpr int MOD = 1e9+7;
template<int mod>
struct ModInt {
  int x;
 
  constexpr ModInt() : x(0) {}
  constexpr ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  constexpr ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }
  constexpr ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
  constexpr ModInt operator-() const { return ModInt(-x); }
  constexpr ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  constexpr ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  constexpr ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  constexpr ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  constexpr bool operator==(const ModInt &p) const { return x == p.x; }
  constexpr bool operator!=(const ModInt &p) const { return x != p.x; }
  constexpr ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t = 0;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  constexpr ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }
  static int get_mod() { return mod; }
};

using modint = ModInt<MOD>;

modint perm(int n, int a) {
    modint ret(1);
    for (int i = 0; i < a; i++) {
        ret *= modint(n - i);
    }
    return ret;
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    auto ans = modint(2).pow(n) - modint(1) - perm(n, a) / perm(a, a) - perm(n, b) / perm(b, b);
    cout << ans << endl;
    
    return 0;
}



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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

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

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

struct RollingHash {
  const int h = 1000000007;
  const int b = 10007;
  vector<int> ha;
  vector<int> po;
  RollingHash(const vector<int> &s) {
    int n = (int) s.size();
    ha.assign(n + 1, 0);
    po.assign(n + 1, 1);
    for (int i = 0; i < n; i++) {
      ha[i + 1] = ((long long) ha[i] * b + s[i]) % h;
      po[i + 1] = ((long long) po[i] * b) % h;
    }
  }
  int get(int l, int r) {
    return (ha[r] + h - ((long long) ha[l] * po[r - l]) % h) % h;
  }
};

void solve() {
  int N;
  cin >> N;
  vi32 a(N), b(N);
  cin >> a >> b;
  vi32 adiff(N * 2), bdiff(N);
  rep(i, N) {
    adiff[i] = a[i] ^ a[(i + 1) % N];
    bdiff[i] = b[i] ^ b[(i + 1) % N];
  }
  rep(i, N) adiff[i + N] = adiff[i];
  auto arh = RollingHash(adiff);
  auto brh = RollingHash(bdiff);
  vector<pair<int, int>> ans;
  rep(k, N) {
    if (arh.get(k, k + N) == brh.get(0, N)) {
      int x = a[k] ^ b[0];
      ans.emplace_back(k, x);
    }
  }
  rep(i, ans.size()) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
}


Measured memory_bytes: 13808
#include <iostream>
#include <cmath>
#define EPS 1e-10
using namespace std;
class Point{
public:
    double x,y;
    Point(double x=0, double y=0):x(x),y(y){}
    Point operator +(const Point &p){
        return Point(x+p.x,y+p.y);
    }
    Point operator -(const Point &p){
        return Point(x-p.x,y-p.y);
    }
    Point operator *(double k){
        return Point(k*x,k*y);
    }
    Point operator /(double k){
        return Point(x/k,y/k);
    }
    
    double norm(){
        return x*x+y*y;
    }
    double abs(){
        return sqrt(norm());
    }
};
typedef Point Vector;
double dot(const Vector &v1,const Vector &v2){
    return v1.x*v2.x+v1.y*v2.y;
}
double cross(const Vector &v1,const Vector &v2){
    return v1.x*v2.y-v1.y*v2.x;
}
bool isParallel(const Vector &v1,const Vector &v2){
    if(fabs(cross(v1,v2)-0)<EPS)return true;
    return false;
}
bool isOrthogonal(const Vector &v1,const Vector &v2){
    if(fabs(dot(v1,v2)-0)<EPS)return true;
    return false;
}
int main()
{
    int q,p0x,p0y,p1x,p1y,p2x,p2y,p3x,p3y;
    cin>>q;
    while(q>0){
        cin>>p0x>>p0y>>p1x>>p1y>>p2x>>p2y>>p3x>>p3y;
        Point P0(p0x,p0y);
        Point P1(p1x,p1y);
        Point P2(p2x,p2y);
        Point P3(p3x,p3y);
        Vector v1=P1-P0;
        Vector v2=P3-P2;
        if(isOrthogonal(v1,v2))cout<<1<<endl;
        else if(isParallel(v1,v2))cout<<2<<endl;
        else cout<<0<<endl;
        q--;
    }
}


Measured memory_bytes: 3096
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

vector<int> zalgo(string t){
    vector<int> res(t.size(), 0);
    res[0] = t.size();
    int ma = 0;
    int l = 0;
    int r = 0;
    for(int i = 1; i < t.size(); i++){
        if(i > r){
            l = r = i;
            while(r < t.size() && t[r - l] == t[r]){
                r++;
            }
            res[i] = r - l;
            r--;
        } else {
            int k = i - l;
            if(res[k] < r - i + 1){
                res[i] = res[k];
            } else {
                l = i;
                while(r < t.size() && t[r - l] == t[r]){
                    r++;
                }
                res[i] = r - l;
                r--;
            }
        }
    }
    return res;
}

int main(void){
    int n;
    cin >> n;
    string s;
    cin >> s;

    int ans = 0;
    for(int i = 0; i < n; i++){
        vector<int> z = zalgo(s.substr(i));

        for(int j = 0; j < z.size(); j++){
            int l = min(z[j], j);
            //cout << z[j];
            ans = max(ans, l);
        }
        //cout << endl;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const double EPS = 1e-10;

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

    int sen = 1000;
    while (sen < N)
    {
        sen += 1000;
    }

    int ans = abs(N - sen);
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <map>
using namespace std;

#define rep(i, n) for(int i = 0; i< (int)(n); i++)
#define all(c) (c).begin(), (c).end()

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = (ll)1e12;

ll dist, n, m;
ll S[10], D[10], T[10];

bool check(int N, int *p){
  //出発順が守られているか
  vector<P> v;
  rep(i, N + 1) v.push_back(P(p[i], T[i]));
  sort(v.begin(), v.end());
  rep(i, v.size() - 1) if(v[i+1].second <= v[i].second) return false;
  
  //少し広いところを同時に3つ以上の馬車が通るか
  rep(i, m){
    map<int, int> mp;
    rep(j, N + 1) if(++mp[T[j] + D[i] * S[p[j]]] > 2) return false;
  }
  //狭いところですれ違うか
  rep(i, N + 1)rep(j, N){
    bool f = false;
    rep(k, m)   if(T[i] + S[p[i]] * D[k] == T[j] + S[p[j]] * D[k]) f = true;
    if(f) continue;
    if((T[i] - T[j]) * (T[i] - T[j] + (S[p[i]] - S[p[j]]) * dist) < 0) return false; 
  }
  
  return true;
}

ll dfs(int N, int *p){
  ll res = INF;
  if(N == n){
    res = -INF;
    rep(i, n) res = max(res, T[i] + S[p[i]] * dist);
    //cout << res << "  "<< *min_element(T, T + n) << endl;
    return res - *min_element(T, T + n);
  }

  //どの馬車ともすれ違わない場合と
  ll lb = -INF;
  ll ub = INF;
  rep(i, N){
    if(p[i] < p[N]){
      lb = max(lb, T[i] + 1);
      lb = max(lb, (T[i] + (S[p[i]] - S[p[N]]) * dist));
    }else{
      ub = min(ub, T[i] - 1);
      ub = min(ub, (T[i] + (S[p[i]] - S[p[N]]) * dist));
    }
  }
  if(lb <= ub){
    T[N] = lb == -INF ? ub : lb;
    res = min(res, dfs(N + 1, p));
  }
  
  //各少し広いところで各でどの馬車とすれ違うかで探索
  rep(i, m)rep(j, N){
    T[N] = T[j] + (S[p[j]] - S[p[N]]) * D[i];
    if(check(N, p))  res = min(res, dfs(N + 1, p));
  }
  return res;
}

int main(){
  ll res = INF;
  int p[10];
  cin >> dist >> n;
  rep(i, n) cin >> S[i];
  cin >> m;
  rep(i, m) cin >> D[i];
  rep(i, n) p[i] = i;
  do{
    T[0] = 0;
    res = min(res, dfs(1, p));
  }while(next_permutation(p, p + n));
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1196
N = int(input())
ans = N
for i in range(0, N + 1, 6):
    cnt = 0
    j = N - i
    while i > 0:
        cnt += i % 6
        i //= 6
    while j > 0:
        cnt += j % 9
        j //= 9
    ans = min(ans, cnt)
print(ans)

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

int main() {
  int N;
  cin >> N;
  int d[110];
  for(int i = 0; i < N; i++) cin >> d[i];
  int packet[110] = {0};
  for(int i = 0; i < N; i++) packet[d[i]]++;
  int counter = 0;
  for(int i = 1; i <= 100; i++) {
    if(packet[i]) counter++;
  }
  cout << counter << endl;
}


Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
#define ll long long int

using namespace std;
ll mod(ll x, ll y)
{
    if(x>y)
    {return x-y;}
    else
    return y-x;
}
int main()
{
   ll n;cin>>n;
   ll arr[200003]={0};
   for(ll i=0;i<n;i++)
   {
       
       cin>>arr[i];
   }
  ll dp[200004]={0};dp[0]=0;;
  dp[1]=mod(arr[1],arr[0]);
  for(ll i=2;i<n;i++)
  {
dp[i]=min(dp[i-2]+mod(arr[i],arr[i-2]),dp[i-1]+mod(arr[i],arr[i-1]));
  }
  cout<<(dp[n-1]);
    return 0;
}


Measured memory_bytes: 3328
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int k = sc.nextInt();
      char[] c = sc.next().toCharArray();
      int cnt = 0;
      int res = 0;
      for(int i = 0;i < n-1;i++){
      	if(c[i]==c[i+1])cnt++;
      }
      res = Math.min(n-1,cnt+2*k);
      System.out.println(res);
    }
}

Measured memory_bytes: 28536
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b; cin >> a >> b;
  bool f = true;
  for(int i = 0; i < a + b + 1; ++i){
    char c; cin >> c;
    f &= (i==a?c=='-':isdigit(c));
  }
  if(f)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


int main(){
	double x1,y1,x2,y2,x3,y3,xp,yp,z1,z2,z3;
	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){
		z1=(x3-x2)*(yp-y2)-(y3-y2)*(xp-x2);
		z2=(x1-x3)*(yp-y3)-(y1-y3)*(xp-x3);
		z3=(x2-x1)*(yp-y1)-(y2-y1)*(xp-x1);
		if(z1>0 && z2>0 && z3>0) printf("YES\n");
		else if(z1<0 && z2<0 && z3<0) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    if(n<=1000)printf("%d",1000-n);
    else if(n<=2000)printf("%d",1000-(n-1000));
    else if(n<=3000)printf("%d",2000-(n-1000));
    else if(n<=4000)printf("%d",3000-(n-1000));
    else if(n<=5000)printf("%d",4000-(n-1000));
    else if(n<=6000)printf("%d",5000-(n-1000));
    else if(n<=7000)printf("%d",6000-(n-1000));
    else if(n<=8000)printf("%d",7000-(n-1000));
    else if(n<=9000)printf("%d",8000-(n-1000));
    else if(n<=10000)printf("%d",9000-(n-1000));
    return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;

#define LL long long


int main()
{
    int L, R, d, ans = 0;
    cin >> L >> R >> d;
    for (int i = L; i <= R; i ++){
        if (i % d == 0){
            ans ++;
        }
    }
    cout << ans;
    system("pause");
    return 0;
}

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

int main() {
  ll a;
  string b;
  cin >> a >> b;
  cout << a * stoi(b.erase(b.find("."),1)) / 100 << endl;
}


Measured memory_bytes: 3624
using System;

namespace ABC099_A_ABD
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());

			if (n <= 999)
			{
				Console.WriteLine("ABC");
			}
			else
			{
				Console.WriteLine("ABD");
			}
		}
	}
}

Measured memory_bytes: 11092
#include<stdio.h>
int main(void)
{
	int a,b,c,h,i,j,temp;
	int fin[3];
	h=3;
	scanf("%d %d %d",&a,&b,&c);
	fin[0]=a;
	fin[1]=b;
	fin[2]=c;
	for(i=0;i<h-1;i++){
		for(j=h-1;j>i;j--){
			if(fin[j-1]>fin[j]){
				temp=fin[j];
				fin[j]=fin[j-1];
				fin[j-1]=temp;
			}
		}
	}
	printf("%d %d %d\n",fin[0],fin[1],fin[2]);
	return 0;
}
	

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

vector<long> s;

int BinarySearch(long t){
    int left = 0;
    int right = s.size();
    while(true){
        int mid = (right + left) / 2;
        if(s[mid] == t) return 1;
        else if(left > right) return 0;

        if(s[mid] < t) left = mid + 1;
        else if(s[mid] > t) right = mid - 1;
    }
}

int main(){
    int n, q, count = 0;
    long temp;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> temp;
        s.push_back(temp);
    }

    cin >> q;
    vector<long> t;
    for(int i = 0; i < q; i++) {
        cin >> temp;
        count += BinarySearch(temp);
    }
    printf("%d\n", count);
    return 0;
}


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

int main() {
	
	int n, m;
	cin >> n >> m;
	vector<int> a(n+1, 0), p(m);
	vector<string> s(m);
	rep(i, m){
		cin >> p[i];
		p[i]--;
		cin >> s[i];
	}
	int cnt_ac = 0, cnt_wa = 0;
	vector<int> wa(n);
	rep(i, m){
		if(a[p[i]] == 0){
			// cout << a[p[i]] << " : " << s[i] << endl;
			if(s[i] == "AC"){
				cnt_ac++;
				cnt_wa += wa[p[i]];
				a[p[i]] = 1;
			}else{
				wa[p[i]]++;
			}
		}
	}
	// rep(i, m) cout << p[i] << endl;
	cout << cnt_ac << " " << cnt_wa << endl;
	return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define MOD7 1000000007
#define MOD9 1e9 + 9
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
typedef long long ll;
typedef long double ld;
typedef string str;
typedef double d;
typedef unsigned u;
typedef unsigned long long ull;

const long long BIGINF = 2e18 + 7;
const int INF = 2e9 + 7;
const int N = 2e4 + 5;

int main () {
	/*#ifndef ONLINE_JUDGE
		freopen("inputf.txt", "r", stdin);
		freopen("outputf.txt", "w", stdout);
	#endif*/
	int h, n;
	SCD(h);
	SCD(n);
	int dp[N], capacity[N], val[N];
	int maxi = 0;
	for (int i = 0; i < n; i++) {
		SCD(capacity[i]);
		SCD(val[i]);
		//maxi = max(capacity[i], maxi);
	}
	memset(dp, INF, sizeof(dp));
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= h; j++) {
			int num = min(j + capacity[i], h);
			dp[num] = min(dp[j] + val[i], dp[num]);
		}
	}
	printf("%d", dp[h]);
	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	ll N;
  	cin>>N;
  	ll a[N];
  	rep(i,N) cin>>a[i];
  	ll count=0;
  	rep(i,N){
     	 while(a[i]%2==0){
          	a[i]/=2;
           	count++;
         }
    }
  
  	cout<<count<<endl;
  
}

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

ll calc(ll h, ll w) {
	ll A, B, C;
	ll ret = h*w;
	for (ll i = 1; i < h; i++) {
		A = i*w;
		B = (h - i) / 2 * w;
		C = ((h - i) - (h - i) / 2) * w;
		ll Smax = max(A, max(B, C));
		ll Smin = min(A, min(B, C));
		ret = min(ret, Smax - Smin);
	}

	for (ll i = 1; i < h; i++) {
		A = i*w;
		B = w / 2 * (h - i);
		C = (w - w / 2) * (h - i);
		ll Smax = max(A, max(B, C));
		ll Smin = min(A, min(B, C));
		ret = min(ret, Smax - Smin);
	}

	return ret;
}

int main() {
	ll H, W;
	cin >> H >> W;
	cout << min(calc(H, W), calc(W, H)) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
int main(){
	int n,k;
	double a[200005],m,mx=0;
	a[0]=0;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>m;
		m=(1+m)/2;
		a[i]=a[i-1]+m;
		if(i-k>=0){
			mx=max(mx,a[i]-a[i-k]);
		}
	}
	printf("%.12f\n",mx);
	return 0;
}



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

using namespace std;

int n;

void solve(){
    int i,j;
    string str;
    cin >> n;
    vector<pair<int,int> > v;
    for(i = 0;i < n;i++){
        cin >> j;
        v.push_back(make_pair(j,i+1));
    }
    sort(v.begin(),v.end());
    for(i = 0;i < n;i++){
        cout << v[i].second << endl;
    }
}

int main(){
    solve();
}


Measured memory_bytes: 1780
#!/usr/bin/env python3
import sys

def delete(larger, move):
    for i in move:
        larger.remove(i)
    return larger

def solve(N: int, d: "List[int]"):
    ABC = []
    ARC = sorted(d)

    count = 0

    for K in range(10**6):
        move = []
        for i in ARC:
            if i < K:
                move.append(i)
            else:
                break
        ABC += move
        delete(ARC, move)

        if len(ABC) == len(ARC):
            count += 1
        elif len(ABC) > len(ARC):
            break
        
    print(count)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, d)

if __name__ == '__main__':
    main()


Measured memory_bytes: 16864
# cording:utf-8

# 回数を入力
N = int(input())

D1 = [0] * N
D2 = [0] * N

# N回入力
for i in range(N):
    D1[i], D2[i] = map(int, input().split())

A = 0
# 一つ目の文字列を探索
for i in range(N-2):
    if (D1[i] == D2[i]) & (D1[i+1] == D2[i+1]) & (D1[i+2] == D2[i+2]):
        print("Yes")
        A = 1
        break

if A == 0:
    print("No")


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

void CountingSort(int *A, int *B, int n)
{
	int C[10005] = {};

	for ( int i = 0; i < n; i++ ) {
		C[A[i]]++;
	}

	for ( int i = 1; i <= 10000; i++ ) {
		C[i] += C[i - 1];
	}

	for ( int i = 0; i < n; i++ ) {
		B[C[A[i]] - 1] = A[i];
		C[A[i]]--;
	}
}	

int main()
{
	int n;
	int A[2000005], B[2000005];
	
	cin >> n;
	for ( int i = 0; i < n; i++ ) {
		cin >> A[i];
	}
	
	CountingSort(A, B, n);
	cout << B[0];
	for ( int i = 1; i < n; i++ ) {
		cout << " " << B[i];
	}
	cout << endl;
	return ( 0 );
}	


Measured memory_bytes: 18736
if __name__ == "__main__":
    from collections import deque
    H, W = map(int,input().split())
    s = []
    black = 0
    for _ in range(H):
        t = list(input())
        for c in t:
            if c == "#":
                black += 1
        s.append(t)
    q = deque([(0,0,1)])
    s[0][0] = "#"
    while q:
        x,y,d = q.popleft()
        if x == H-1 and y == W-1:
            print(H*W-d-black)
            exit(0)
        for nx,ny in [(x+1,y), (x,y+1), (x-1,y), (x,y-1)]:
            if 0 <= nx < H and 0<= ny < W and s[nx][ny] == ".":
                s[nx][ny] = "#"
                q.append((nx,ny,d+1))
    print(-1)

Measured memory_bytes: 9512
from collections import deque
class csr:
    def __init__(self,N,edges):
        self.start = [0]*(N+1)
        self.elist = [0]*len(edges)
        for e in edges:
            self.start[e[0]+1] += 1
        for i in range(1,N+1):
            self.start[i] += self.start[i-1] 
        counter = self.start[:]
        for e in edges:
            self.elist[counter[e[0]]] = e[1]
            counter[e[0]] += 1

class scc_graph:
    def __init__(self,N):
        self.N = N
        self.edges = []
    
    def add_edge(self,v,w):
        self.edges.append((v,w))

    def scc_ids(self):
        g = csr(self.N,self.edges)
        now_ord = group_num = 0
        visited = deque()
        low = [0]*self.N
        order = [-1]*self.N
        ids = [0]*self.N
        parent = [-1]*self.N
        for i in range(self.N):
            if order[i] == -1:
                stack = deque()
                stack.append(i)
                stack.append(i)
                while stack:
                    v = stack.pop()
                    if order[v] == -1:
                        low[v] = order[v] = now_ord
                        now_ord += 1
                        visited.append(v)
                        for i in range(g.start[v],g.start[v+1]):
                            to = g.elist[i]
                            if order[to] == -1:
                                stack.append(to)
                                stack.append(to)
                                parent[to] = v
                            else:
                                low[v] = min(low[v],order[to])
                    else:
                        if low[v] == order[v]:
                            while True:
                                u = visited.pop()
                                order[u] = self.N
                                ids[u] = group_num
                                if u == v:
                                    break
                            group_num += 1
                        if parent[v] != -1:
                            low[parent[v]] = min(low[parent[v]],low[v])
        for i,x in enumerate(ids):
            ids[i] = group_num-1-x

        return group_num,ids
    
    def scc(self):
        group_num,ids = self.scc_ids()
        groups = [[] for _ in range(group_num)]
        for i,x in enumerate(ids):
            groups[x].append(i)
        return groups
    
import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
N,M = map(int,readline().split())
ab = list(map(int,read().split()))
sg = scc_graph(N)

it = iter(ab)
for a,b in zip(it,it):
    sg.add_edge(a,b)

scc = sg.scc()
print(len(scc))
for group in scc:
    print(str(len(group))+' '+' '.join(map(str,group)))

Measured memory_bytes: 214184