akhauriyash/Code-Regression huggingface dataset:
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vector<T> t(n);
    rep(i,n){
        int a,b,c;
        cin>>a>>b;
        c=a+b;
        t[i]=T(c,a,b);
    }
    sort(rall(t));
    int a=0,b=0;
    rep(i,n){
        int x,y,z;
        tie(x,y,z)=t[i];
        if(i%2==0){
            a+=y;
        }
        else{
            b+=z;
        }
    }
    cout<<a-b<<endl;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        String s = in.next();
        int total = 0;
        for (int i = 0; i < s.length()-2; i++) {
            if (s.substring(i, i+3).equals("ABC")) {
                total++;
            }
        }
        System.out.println(total);
    }
}


Measured memory_bytes: 21844
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <iostream>
#include <deque>
#include <functional>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

#define int long long

#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

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

#define debug(x) cerr << #x << ": " << x << endl;

const int MOD = 1e9 + 7;

template <typename T> T gcd(T m, T n) { return n == 0 ? m : gcd(n, m % n); }
template <typename T> T lcm(T m, T n) { return n * m / gcd(n, m); }

signed main(void)
{
  int num;
  int n; cin >> n;
  vector<int> a(n + 1);
  for (int i = 0; i < n + 1; ++i) cin >> a[i];

  vector<int> b(n);
  for (int i = 0; i < n; ++i) cin >> b[i];

  num = 0;

  for (int i = 0; i < n; ++i) {
    int m;

    for (int j = 0; j <= 1; ++j) {
      m = min(b[i], a[i + j]);
      a[i + j] -= m;
      b[i] -= m;
      num += m;
    }
  }
  
  cout << num << endl;
  
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
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;
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++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;

int alf[26];

string s;
bool valid = true;

int winner(int& i);
int person(int& i);
int winner(int &i) {
	if (s[i] == '[') {
		i++;
		int l = winner(i);
		i++;
		int r = winner(i);
		i++;
		if (alf[l] > 0 && alf[r] > 0) {
			valid = false; return 0;
		}
		else if (alf[l] == 0 && alf[r] == 0) {
			valid = false; return 0;
		}
		else if (alf[l] == 0) {
			alf[r]--; return r;
		}
		else {
			alf[l]--; return l;
		}
	}
	else {
		return person(i);
	}
}
int person(int &i) {
	return s[i++]-'a';
}

void solve() {
	cin >> s; int j = 0;
	int n = 0;
	rep(i, s.length()) {
		if ('a' <= s[i] && s[i] <= 'z')n++;
	}
	char t; int c;
	rep(i, n) {
		cin >> t >> c;
		alf[t - 'a'] = c;
	}
	int las = winner(j);
	rep(i, 26) {
		if (alf[i])valid = false;
	}
	if (valid) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(5);
	//init();
	solve();

	//cout << "finish" << endl;
	//stop
	return 0;
}



Measured memory_bytes: 3220
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
// dfmt on

void main()
{
    long N = lread();
    auto S = new string[](N);
    auto P = new long[](N);
    foreach (i; 0 .. N)
        scan(S[i], P[i]);
    auto I = iota!long(N).array;
    zip(S, P, I).sort();
    foreach (s; S.uniq())
    {
        Tuple!(long, long)[] tmp;
        foreach (t; zip(S, P, I))
            if (t[0] == s)
                tmp ~= tuple(t[1], t[2]);
        tmp.sort!"b<a"();
        foreach (t; tmp)
            writeln(t[1] + 1);
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>

#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#define all(c) c.begin(),c.end()
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define MAX_V 1001
#define MAX_E 401
#define INF INT_MAX
#define MOD 1000000007
#define EPS 1e-7

typedef long long ll;
inline int toInt(std::string s) { int v; std::istringstream sin(s); sin >> v; return v; }
template<class T> inline std::string toString(T x) { std::ostringstream sout; sout << x; return sout.str(); }
using namespace std;

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
#define X real()
#define Y imag()
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template< typename T >
struct edge {
	int src, to;
	T cost;

	edge(int to, T cost) : src(-1), to(to), cost(cost) {}

	edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

	edge &operator=(const int &x) {
		to = x;
		return *this;
	}

	operator int() const { return to; }
};
template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

int main()
{
	int a, b;
	cin >> a >> b;
	int res = max(a + b, a - b);
	res = max(res, a*b);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 764
#include<stdio.h>

#define max 100000

struct node{
  int p,left,right;
    };

struct node T[max];
int T2[max];

int recursive(int,int);
void printtree(int);

int recursive(int u,int p)
{
  T2[u] = p;
  if(T[u].right != -1)
    recursive(T[u].right,p);
  if(T[u].left != -1)
    recursive(T[u].left,p+1);
}

void printtree(int u)
{
  int i,cn;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",T2[u]);

  if(T[u].p == -1) {
    printf("root, ");
  }else if(T[u].left == -1) {
    printf("leaf, ");
  }else{
    printf("internal node, ");
  }

  printf("[");

  for(i=0,cn=T[u].left;cn!=-1;i++,cn=T[cn].right) {
    if(i){
      printf(", ");
    }
    printf("%d",cn);
  }

  printf("]\n");
}


int main()
{

  int i,j,n;
  int dep,high,cn,lef,rig; /* dep 深さ high 高さ cn 子 lef 左 rig 右*/


  scanf("%d",&n);

  for(i=0;i<n;i++) {
    T[i].p = -1;
    T[i].left = -1;
    T[i].right = -1;
  }
  

  for(i=0;i<n;i++) {
    scanf("%d%d",&high,&dep);
      for(j=0;j<dep;j++) {
         scanf("%d",&cn);
	 if(j == 0) {
	   T[high].left = cn;
	 }else{
	   T[lef].right = cn;
	 }
	 lef = cn;
	 T[cn].p = high;
      }
  }

  for(i=0;i<n;i++) {
    if(T[i].p == -1)
      rig = i;
  }
  
  recursive(rig,0);

  for(i=0;i<n;i++)
    printtree(i);

  return 0;

}

  
	






Measured memory_bytes: 6380
n, k = map(int, input().split())
a = [0]+list(map(int, input().split()))

num = 1
li = [1]
flag = [True] * n
flag[0] = False

for i in range(k):
    num = a[num]
    if flag[num-1]:
        li.append(num)
        flag[num-1] = False
    else:
        break

d = li.index(num)
ans = (k-d)%(len(li)-d)+d

print(li[ans])


Measured memory_bytes: 32384
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<utility>
#include<algorithm>

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define For(i,x,y) for(int i=((int)x);i<=((int)y);i++)
#define Dep(i,y,x) for(int i=((int)y);i>=((int)x);i--)
#define Rep(i,x) for (int y,i=head[x];i;i=E[i].nxt)
using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<int,int> pii;

int rd() {
	char c=getchar(); int t=0,f=1;
	while (!isdigit(c)) f=(c=='-')?-1:1,c=getchar();
	while (isdigit(c)) t=t*10+c-48,c=getchar(); return t*f;
}
void wt(int x) {
	if (x<0) putchar('-'),wt(-x);
	else { if (x>9) wt(x/10); putchar(x%10+48); }
}

const int N=100035;

ll n,A,B,h[N],l,r,ans;

bool chk(ll x) {
	ll key=0,res=0;
	For (i,1,n) key=max(0ll,h[i]-x*B),res+=key/A+(key%A>0);
	return res<=x;
}

int main() {
	n=rd(),A=rd(),B=rd(),A=A-B;
	For (i,1,n) h[i]=rd();
	for (l=1,r=1e9;l<=r;) {
		ll mid=l+r>>1;
		if (chk(mid)) ans=mid,r=mid-1; else l=mid+1;
	}
	printf("%d\n",ans);
	return 0;
}






Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
using namespace std;
int main() {
	int X,i = 0,ans = 0;
	cin >> X ;
	
	while (ans < X) {
		i++;
		ans += i;
	}

	cout  << i << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i,n,init) for(ll i=init;i<(n);i++)
#define repd(i,n,init) for(ll i=(n);i>=init;i--)
#define repm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define repb(bit,n,init) for(ll bit=init;bit<(1<<n);++bit)

int main()
{
    int n,m,sum = 0;
    cin >> n >> m;
    repi(i,m,0){
        int a;
        cin >> a;
        sum += a;
    }
    cout << max(n - sum,-1) << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  vec a(n);
  vec b(1e6+10);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
    b[a[i]]++;
  }
  sort(a.begin(),a.end());
  ll ans=0;
  for(ll i=0;i<n;i++) {
    if(b[a[i]]==1) {
      ans++;
    }
    if(b[a[i]]>0) {
      for(ll j=a[i];j<=1e6;j+=a[i]) {
        b[j]=-1;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 12764
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))
a=a1+a2+a3
n=int(input())
for _ in range(n):
    b=int(input())
    if b in a:
        a[a.index(b)]=0

check=0
for i in range(3):
    if (a[3*i]==a[3*i+1] and a[3*i+1]==a[3*i+2]) or (a[i]==a[i+3] and a[i+3]==a[i+6]):
        check+=1
if (a[0]==a[4] and a[4]==a[8]) or (a[2]==a[4] and a[4]==a[6]):
    check+=1
if check>0:
    print("Yes")
else:
    print("No")


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

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
  if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
  return *ci++;
}

inline int getint() {
  int A = 0;
  if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
  else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
  return A;
}

const int dm = 1 << 20;
char dn[dm], * di = dn;

inline void putint(int X) {
  if (X == 0) {
    *di++ = '0';
    *di++ = '\n';
    return;
  }
  int keta = 0;
  char C[10];
  while (X) {
    *(C + keta) = '0' + X % 10;
    X /= 10;
    keta++;
  }
  for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
  *di++ = '\n';
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n = getint(), q = getint();
  vector<int> arr(n);
  arr[1] = 0;
  for (int i = 2; i <= n; ++i) {
    arr[i] = arr[i - 1];
    if (*ci++ == 'A' && *ci =='C') ++arr[i];
  }
  ci += 2;
  for (int i = 0; i < q; ++i) {
    int left = getint(), right = getint();
    putint(arr[right] - arr[left]);
  }
  fwrite_unlocked(dn, di - dn, 1, stdout);
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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

int main(void){
    int N; cin >> N;
    VI a(N); REP(i,N) cin >> a[i];
    SORT(a);
    int n = a[N-1], r;
    int med = n/2;
    if(n%2){
        int mn = INT_INF;
        REP(i,N-1){
            if(chmin(mn, min(abs(med-a[i]), abs(med+1-a[i])))) r = a[i];
        }
    }
    else{
        int mn = INT_INF;
        REP(i,N-1){
            if(chmin(mn, abs(med-a[i]))) r = a[i];
        }
    }
    cout << n << " " << r << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#define INF (int)1e9


void bellman_ford(int m, int p, int q, std::vector<std::vector<std::pair<int, int> > > &v); 

int main(void) {
    int n;
    int m;
    int a;
    int b;
    int cost;
    int time;
    int k;
    int p;
    int q;
    int r;

    while (true) {
        std::cin >> n >> m;
        if (n == 0 && m == 0) {
            break; 
        }
        std::vector<std::vector<std::pair<int, int> > > vcost(m);
        std::vector<std::vector<std::pair<int, int> > > vtime(m);
        for (int i = 0; i < n; i++) {
            std::cin >> a >> b >> cost >> time;
            --a;
            --b;
            vcost[a].push_back(std::make_pair(cost, b));
            vcost[b].push_back(std::make_pair(cost, a));
            vtime[a].push_back(std::make_pair(time, b));
            vtime[b].push_back(std::make_pair(time, a));
        }
        std::cin >> k;
        for (int i = 0; i < k; i++) {
            std::cin >> p >> q >> r;
            --p;
            --q;
            if (r == 0) {
                bellman_ford(m, p, q, vcost);
            } else {
                bellman_ford(m, p, q, vtime);
            }
        }
    } return 0;
}

void bellman_ford(int m, int p, int q, std::vector<std::vector<std::pair<int, int> > > &v) {
    std::vector<int> rvec(m, INF);
    rvec[p] = 0;
    int value;
    int target; bool flag;

    do{
        flag = false;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < v[i].size(); j++) {
                value = v[i][j].first;
                target = v[i][j].second;
                if (rvec[target] > rvec[i] + value) {
                    rvec[target] = rvec[i] + value;
                    flag = true;
                }
            }
        }
    } while(flag);

    std::cout << rvec[q] << std::endl;
    return;
} 

Measured memory_bytes: 3180
n = gets.to_i
hs = gets.split.map(&:to_i)
ans = 1
(1..n-1).each do |i|
  ok = true
  ha = hs[i]
  (0...i).each do |j|
    hb = hs[j]
    if hb > ha
      ok = false
      break
    end
  end
  if ok
    ans += 1
  end
end
puts ans

Measured memory_bytes: 1788
#include<stdio.h>
        int main (){
          int a,b,c,max,min;
          scanf("%d %d %d",&a,&b,&c);
          max=c;
          min=a;
          if(b<min) min=b;
          if(c<min) min=c;
          if(b>max) max=b;
          if(a>max) max=a;
          printf("%d\n",max-min);
          return 0;
        }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 100000000000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);

template <typename T>
vector<T> dijkstra(int s,vector<vector<pair<T, T> > > & G){     
  using Pa = pair<T, T>;
  vector<T> D(100001,INF);//----------------
  priority_queue<Pa,vector<Pa>,greater<Pa> > q;
  D[s]=0;
  q.emplace(D[s],s);//最短距離、ゴール頂点番号

  while(!q.empty()){
    ll spath=q.top().first;
    int v=q.top().second;
    q.pop();

    if(D[v]<spath) continue;
    for(auto& e:G[v]){
      int u=e.first;//頂点番号
      T c=e.second;//最短距離
      if(D[u]>D[v]+c){
        D[u]=D[v]+c;
        q.emplace(D[u],u);
      }
    }
  }
  return D;
}


vector<vector<PL>> e(100001,vector<PL>(0));
signed main(){
   ll n;cin>>n;
   rep(i,n-1){
       ll a,b,c;cin>>a>>b>>c;
       e[a].emplace_back(b,c);
       e[b].emplace_back(a,c); 
   }

   ll q,k;cin>>q>>k;

   vector<ll> d=dijkstra(k,e);

   while(q--){
       ll x,y;cin>>x>>y;
       cout<<d[x]+d[y]<<endl;
   }
}


Measured memory_bytes: 11120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{int n,sb[105],sum;
while(cin>>n){int min=1000000007;
for(int i=1;i<=n;i++)
{cin>>sb[i];}
for(int i=1;i<=100;i++)
{sum=0;
for(int j=1;j<=n;j++)
sum=sum+pow((sb[j]-i),2);
if(min>sum)
min=sum;
}
printf("%d\n",min);
}}

Measured memory_bytes: 764
<?php
fscanf(STDIN, '%d %d %d %d', $a, $b, $c, $d);

while ($c > 0) {
  $c = $c - $b;
  if ($c <= 0) {
    echo 'Yes';
    exit;
  }
  $a = $a - $d;
  if ($a <= 0) {
    echo 'No';
    exit;
  }
}

Measured memory_bytes: 16248
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
       	 int H = sc.nextInt();
       	 int W = sc.nextInt();
            if(H ==0 && W == 0){
                break;
            }
        
       		 for(int i=0;i<H;i++){
           		 for(int j=0;j<W;j++){
              		  System.out.print("#");
           		 }
           		 System.out.println();
       		 }
            System.out.println();
        }
        sc.close();
    }
}


Measured memory_bytes: 34484
import sys
import numpy as np

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
mo = 10**9+7

def main():
    H,W,K=MI()
    pixels = np.array([[0 for w in range(W)] for h in range(H)])
    tob = 0
    for h in range(H):
        C = IS()
        for w,c in enumerate(C):
            if c=='#':
                pixels[h][w] = 1
                tob+=1
    N=H+W
    M=2
    ans = 0
    r = np.array([0]*N)
    for i in range(M**N):
        ii = i
        for j in range(N):
            r[j] = ii % M;
            ii //= M
        if K==np.sum(pixels[np.ix_(r[0:H]>=1, r[H:]>=1)]):
            ans+=1
    print(ans)
            
if __name__ == '__main__':
    main()

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

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

    int n, mx = 0, count = 0;
    cin >> n;
    while (n--) {
        int a, b;
        cin >> a >> b;
        if (a == b) count++;
        else count = 0;
        mx = max(mx, count);
    }
    cout << (mx >= 3 ? "Yes" : "No");
}

Measured memory_bytes: 3616
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()



int main()
{
  string s;
  cin >> s;
  if(s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
  return 0;
}


Measured memory_bytes: 3592
fun main(args: Array<String>) = yorukatsu22e()

fun yorukatsu22e() {
    operator fun List<Int>.component6() = this[5]
    val (a, b, c, d, e, f) = readLine()!!.split(' ').map { it.toInt() }

    var pair = a * 100 to 0
    var maxPercentage = 0.0

    for (aw in 0..f step a * 100) for (bw in 0..f - aw step b * 100) {
        for (cw in 0..f - aw - bw step c) for (dw in 0..f - aw - bw - cw step d) {
            val sugarWeight = cw + dw
            val waterWeight = aw + bw
            val sumWeight = sugarWeight + waterWeight

            val sugarPerWater = sugarWeight.toDouble() * 100 / waterWeight.toDouble()
            val percentage = sugarWeight.toDouble() * 100 / sumWeight.toDouble()

            if (sumWeight <= f && sugarPerWater <= e.toDouble() && percentage > maxPercentage) {
                maxPercentage = percentage
                pair = sumWeight to sugarWeight
            }
        }
    }

    val answer = "${pair.first} ${pair.second}"

    println(answer)
}


Measured memory_bytes: 38180
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	scanf("%d", &n);
	vector<int> h(n);
	for(int i=0; i<n; ++i) 
	     scanf("%d", &h[i]);
	if(n == 1) {
		printf("0");
		return 0;
	}
	if(n == 2) {
		printf("%d", abs(h[1] - h[0]));
		return 0;
	}
	vector<int> dp(n);
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for(int i=2; i<n; ++i) {
		dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
	}
	printf("%d", dp[n-1]);
	return 0;
}

Measured memory_bytes: 4048
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>

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

using namespace std;
typedef long long int ll;
const int INF = 100000000;

int main()
{
    string s_dush, t;
    cin >> s_dush >> t;

    vector<int> cand;
    rep(i, s_dush.size()-t.size()+1) {
        bool is_match = true;
        rep(j, t.size()) {
            if (s_dush[i + j] != '?' &&
                s_dush[i + j] != t[j]) is_match = false;
        }
        if (is_match) cand.push_back(i);
    }
    if (cand.size() == 0) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    vector<string> s;
    rep(i, cand.size()) {
        string s_cand;
        rep(j, s_dush.size()) {
            if (s_dush[j] != '?') s_cand += s_dush[j];
            else if (cand[i] <= j &&
                j < (cand[i] + t.size())) s_cand += t[j - cand[i]];
            else s_cand += 'a';
        }
        s.push_back(s_cand);
    }
    sort(s.begin(), s.end());
    cout << s[0] << endl;
    return 0;
}

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

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

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	int n,now=-1,ns=0,out=0,a;
	cin>>n;
	rep(i,n){
		cin>>a;
		if(a==now) ns++;
		else{
			out+=ns/2;ns=1;now=a;
			//cout<<ns<<endl;
		}
	}
	out+=ns/2;
	cout<<out<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
int main() {
  int n, ans = 0;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  ans = s.size();
  sort(s.begin(), s.end());
  for (int i = 1; i < n; i++) {
    if (s[i]==s[i-1]) {
      ans--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 7528
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,i,j;
  string s;
  cin>>n;
  cin>>s;
  long long x=0;
  for(i=0;i<n;i++)
  {
    if(s[i]=='R')
      x++;
  }
  long long ans=0;
  for(i=0;i<x;i++)
  {
    if(s[i]!='R')
      ans++;
  }
  cout<<ans;
}


Measured memory_bytes: 3692
#include <iostream>
#include <string>
using namespace std;
int main(){

  string s;
  int r=0,a[26]={};
  cin>>s;
  for(int i=0;i<s.size();i++) a[s[i]-'a']++;
  for(int i=0;i<26;i++) if(a[i]%2) r=1;
  if(r) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


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

int main (){
  int n;
  int a[200000];
  set <int> S;
  cin >> n;

  for(int i=0;i<n;i++) cin >>a[i];

  int ans=0;
  for(int i=0;i<n;i++){ 
    if(S.count(a[i]) ) ans++;
    else S.insert(a[i]);
    while( *--S.end()>a[i] ) S.erase(--S.end());
  }

  cout<<n-ans<<endl;


  return 0;
}

Measured memory_bytes: 11344
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Mayank
 */



#include "bits/stdc++.h"

#define ll long long
using namespace std;


class BProductMax {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        ll a1 = max(b*c, b*d);
        ll a2 = max(a*c, a*d);
        cout<<max(a2, a1);
	}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
	BProductMax solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  auto factor = [&](ll n) {
    vector<pair<ll, ll>> res;
    for (ll i = 2; i * i <= n; i++) {
      if (n % i == 0) {
        ll ex = 0;
        while (n % i == 0) {
          ex++;
          n /= i;
        }
        res.push_back({i, ex});
      }
    }
    if (n != 1) res.push_back({n, 1});
    return res;
  };
  auto f = factor(n);
  int ans = 0;
  for (auto&& [_, e] : f) {
    for (int i = 1, sum = 0;; i++) {
      sum += i;
      if (sum > e) {
        // cerr << e << ' ' << sum << ' ' << i << endl;
        ans += i - 1;
        break;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3648
n=int(input())
ans=0
if 400<=n<=599:
	ans=8
if 600<=n<=799:
	ans=7
if 800<=n<=999:
	ans=6
if 1000<=n<=1199:
	ans=5
if 1200<=n<=1399:
	ans=4
if 1400<=n<=1599:
	ans=3
if 1600<=n<=1799:
	ans=2
if 1800<=n<=1999:
	ans=1
print(ans)


Measured memory_bytes: 9184
#include <iostream>
#include <string>
using namespace std;
int main(){
	string str,si="IOI",sj="JOI";
	int ci,cj,i;
	while(cin >> str){
		ci=0;
		cj=0;
		for(i=0;i<str.size();i++){
			if(str.substr(i,3)==si){
				ci++;
			}
			if(str.substr(i,3)==sj){
				cj++;
			}
		}
		cout << cj << endl;
		cout << ci << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
n = int(input())
s = input()

right_cost = s.count("E")
left_cost = 0

ans = 10 ** 9
for i in range(n):
    if s[i] == "E":
        right_cost -= 1

    ans = min(ans, left_cost + right_cost)

    if s[i] == "W":
        left_cost += 1


print(ans)


Measured memory_bytes: 3780
n = int(input())

a = [0]*n


a = input().split()
  
b = [int(s) for s in a]

alice = 0
bob = 0
m = 0

for i in range(0,n):
  if(i%2 == 0):
    m = max(b)
    alice = alice + m
    k = b.index(m)
    del b[k]
  else:
    m = max(b)
    bob = bob + m
    k = b.index(m)
    del b[k]
print(alice-bob)

Measured memory_bytes: 38432
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod 1000000007
#pragma GCC optimize ("-O2")
#define mod2 998244353
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector <vector <int>>
#define v4096 vector <vector <lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli,lli>
#define m32 map<int,int>
#define m64it map<lli,lli>::iterator
#define m32it map<int,int>::iterator
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ist insert
#define endl "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define p_q priority_queue 
#define min_p_q priority_queue <pair<lli,int>,vt <pair<lli,int>>,greater <pair<lli,int>>>
using namespace std;
using namespace __gnu_pbds; 

//USE AT YOUR OWN RISK
lli tmod(lli x,lli m=mod){return (x%m+m)%m;}

template <typename T> 
void DEBUG_ARR(vt<T> a,char c)
{
	f(i,0,a.size())cout<<a[i]<<c;
	cout<<"\n";
}

//make sure x is below mod
lli power(lli x, lli y,lli m=mod) 
{
    lli res = 1;  
   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x)%m; 
        y = y>>1; 
        x = (x*x)%m;  
    }
    if(res<0)
       res+=m; 
    return res; 
}

// lli fact[2000009];
// lli ncr(lli n,lli r){
//     lli ans=fact[n];
//     if(r>n)return 1;
//     if(r<0)return 0;
//     if(n<0)return 0;
//     ans=(ans*power(fact[n-r],mod-2))%mod;
//     ans=(ans*power(fact[r],mod-2))%mod;
//     return ans;
// }
void normalize(lli &a,lli &b){
    if(a==0 && b==0)return;
    if(a<0){
        a=-a;
        b=-b;
    }
    else if(a==0){
        if(b<0)b=-b;
    }
    lli g=__gcd(abs(a),abs(b));
    if(g!=0){
        a/=g;
        b/=g;
    }
}
const int N=2e5+5;

//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{ 
    // fact[0]=1;
    // f(i,1,2000001)fact[i]=(i*fact[i-1])%mod;
    fastio;
    int t=1;
    // cin>>t;
    // int temp=t;
    // cout<<smvalallestprime[5]<<"\n";
	while(t--){
        // cout<<"Case #"<<temp-t<<": ";
        // clock_t t=clock();
        // ifstream in("cave.in");
        // ofstream out("cave.out");
        string s,t;cin>>s>>t;
        int ans=0;
        f(i,0,s.size())ans+=(s[i]!=t[i]);
        cout<<ans<<"\n";
        // cout<<clock()-t<<"\n";
    }   
    return 0; 	
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll a, b, c;
    cin >> a >> b >> c;

    if(a%2==0 || b%2==0 || c%2==0){
        cout << 0 << endl;
        return 0;
    }

    ll cut_edge = max(a, max(b, c));
    ll two, three;
    if(a == cut_edge){
        two = b;
        three = c;
    }
    if(b == cut_edge){
        two = c;
        three = a;
    }
    if(c == cut_edge){
        two = a;
        three = b;
    }

    cout << two*three << endl;
    
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    clock_t start = clock();
    ll D;
    cin >> D;
    vector<ll> C(26);
    rep(i, 26) cin >> C[i];
    vector<vector<ll>> S(D, vector<ll>(26));
    rep(i, D) {
        rep(j, 26) {
            cin >> S[i][j];
        }
    }
    vector<ll> T(D);

    rep(i, D) {
        ll r = rand() % 26;
        T[i] = r + 1;
    }
    vector<ll> last(26, 0);

    ll sum = 0;
    auto f = [&] {
        sum = 0;
        last.assign(26, 0);
        rep(d, D) {
            ll t = T[d];
            sum += S[d][t - 1];
            last[t - 1] = d + 1;
            rep(i, 26) {
                sum -= C[i] * ((d + 1) - last[i]);
            }
        }
        return sum;
    };
    ll ans = -INF;
    clock_t end = clock();
    double time = (end - start) / 1000;
    while (time <= 1950) {
        ll r = rand() % 26;
        r++;
        ll d = rand() % 365;
        ll old = T[d];
        T[d] = r;
        ll res = f();
        if (res > ans) {
            ans = res;
        }else {
            T[d] = old;
        }
        // cout << ans << '\n';
        end = clock();
        time = (end - start) / 1000;
    }
    // cout << time << '\n';
    rep(d, D) {
        cout << T[d] << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

int compare_int(const void *a,const void *b){
		long long A=*(long long*)a-*(long long*)b;
		if(A>0)return 1;
		if(A<0)return -1;
		return 0;
}

struct mond{
		long long a;
		int b;
};

#define N 200000

int main(){
		int n,i,m,j;
		long long d[N],t[N];
		struct mond vd[N];int c=0;
		for(i=0;i<N;i++)vd[i].b=0;
		scanf("%d",&n);
		for(i=0;i<n;i++)scanf("%lld",&d[i]);
		scanf("%d",&m);
		for(i=0;i<m;i++)scanf("%lld",&t[i]);
		qsort(d,n,sizeof(long long),compare_int);
		qsort(t,m,sizeof(long long),compare_int);
		vd[c].a=d[0],vd[c].b=1;
		for(i=1;i<n;i++){
				if(d[i-1]==d[i])vd[c].b++;
				else {
						vd[++c].a=d[i];
						vd[c].b=1;
				}
		}
		c++;
		int ansf=0;
		for(i=0;i<m;i++){
				int ub=c,lb=-1;
				while(ub-lb>1){
						int mid=(ub+lb)/2;
						if(vd[mid].a<t[i])lb=mid;
						else ub=mid;
				}
	//			printf("%lld\n",vd[ub].a);
				if(vd[ub].a==t[i]){
						if(vd[ub].b>0)vd[ub].b--;
						else{
								ansf=1;
								break;
						}
				}else {
						ansf=1;
						break;
				}
		}
		if(ansf==0)puts("YES");
		else puts("NO");
		return 0;
}


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

int main(){
    int n;
    cin >> n;
    string w[n];
    for(int i=0;i<n;i++){
        cin >> w[i];
    }

    string ans = "Yes";
    for(int i=0;i<n;i++){
        int size = w[i].size();
        if(i <n-1 && w[i][size-1] != w[i+1][0]){
            ans = "No";
            break;
        }
        for(int j=i-1;j>=0;j--){
            if(w[i] == w[j]){
                ans = "No";
                break;
            }
        }
    }
    cout << ans << endl;
}


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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b; cin>>a>>b;
    int ans = (a*3 + b) / 2;
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=300005;
 
inline int read(){
    int x=0; char ch=getchar();
    for(;!isdigit(ch);ch=getchar());
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
    return x;
}
 
void W(int x){ if(x>=10) W(x/10); putchar(x%10+'0');}
 
int n,a[N],c[N],l,ans[N];
 
inline void update(int pos,int val){
    if(val>a[pos]) c[pos]=a[pos],a[pos]=val;
    else if(val>c[pos]) c[pos]=val;
}
 
inline void solve(){
    for(int i=0,to;i<l;i++)
        for(int j=0;j<n;j++) if(!((1<<i)&j)){
            to=j|(1<<i);
             
            update(to,a[j]);
            update(to,c[j]);
        }
}
 
int main(){
    scanf("%d",&n),l=n,n=1<<n;
    for(int i=0;i<n;i++) a[i]=read(),c[i]=0;
     
    solve();
     
    for(int i=1;i<n;i++){
        ans[i]=max(ans[i-1],a[i]+c[i]);
        W(ans[i]),puts("");
    }
     
    return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

ll A[102][9] = {0};

int main()
{
    int H, W, K;
    cin >> H >> W >> K;

    vector<int> validPattern;
    validPattern.push_back(0);
    for (int i = 1; i <= pow(2, W - 1) - 1; ++i)
    {
        bool prev = false;
        bool now;
        REP(j, W)
        {
            int bit = 1 << j;
            now = (i & bit) == bit;
            if (prev && now) break;
            prev = now;
            if (j == W - 1) validPattern.push_back(i);
        }
    }

    A[1][1] = 1;
    for (int h = 1; h <= H; ++h)
    {
        for (int x = 1; x <= W; ++x)
        {
            for (auto iter = validPattern.begin(); iter != validPattern.end(); ++iter)
            {
                if (x - 1 >= 1)
                {
                    int bit = 1 << (x - 2);
                    if ((*iter & bit) == bit)
                    {
                        A[h + 1][x - 1] = (A[h + 1][x - 1] + A[h][x]) % MOD;
                        continue;
                    }
                }
                if (x + 1 <= W)
                {
                    int bit = 1 << (x - 1);
                    if ((*iter & bit) == bit)
                    {
                        A[h + 1][x + 1] = (A[h + 1][x + 1] + A[h][x]) % MOD;
                        continue;
                    }
                }
                A[h + 1][x] = (A[h + 1][x] + A[h][x]) % MOD;
            }
        }
    }

    cout << A[H + 1][K] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(){

	int hill[10];

	for(int i = 0; i < 10; i++) cin >> hill[i];

	sort(hill,hill+10,greater<int>());

	cout << hill[0] << endl << hill[1] << endl << hill[2] <<endl;

	int a;
	std::cin >> a;
return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << v.first << " " << v.second;
    return ostr;
}

int main() {
    string s, t; cin >> s >> t;
    int a, b; cin >> a >> b;
    string u; cin >> u;

    if (u == s) {
        cout << a -1 << " " << b << endl;
    } else {
        cout << a << " " << b-1 << endl;
    }
}


Measured memory_bytes: 256
import sys
sys.stdin.readline

def main():
    N, M = map(int, input().split())
    ABC = [tuple(map(int, input().split())) for _ in range(M)]
    INF = float("inf")
    cost = [-INF] * N
    cost[0] = 0
    for i in range(N-1):
        for a, b, c in ABC:
            cost[b-1] = max(cost[b-1], cost[a-1] + c)
    prev = cost[N-1]
    for a, b, c in ABC:
        cost[b-1] = max(cost[b-1], cost[a-1] + c)    
    print(cost[N-1] if cost[N-1] == prev else "inf")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#include<string.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1<<29;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int n;
int h[100001];

int calc(int n2,vector<long long>&memo){
	if(n2==0)return 0;
	if(n2==1)return abs(h[1]-h[0]);

	if(memo[n2]!=-1)return memo[n2];

	return 	memo[n2] = min(calc(n2-1,memo) + abs(h[n2]-h[n2-1]),calc(n2-2,memo) + abs(h[n2]-h[n2-2]));

}

int main() {

	vector<long long>memo(100000,-1);
	cin>>n;

	rep(i,n){
		cin>>h[i];
	}

	cout<<calc(n-1,memo)<<endl;
	return 0;
}


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

int main(){
  int n; cin >>n;
  map<string, int> mp;
  rep(i,n){
    string s; cin >>s;
    mp[s]++;
  }
  cout << "AC x " << mp["AC"] << endl;
  cout << "WA x " << mp["WA"] << endl;
  cout << "TLE x " << mp["TLE"] << endl;
  cout << "RE x " << mp["RE"] << endl;
  return 0; 
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
 int main()
 {
   long int n;
   int m,a[10000];
   cin>>n>>m;
   int s=0,i;
   for(i=0;i<m;i++) 
   {
     cin>>a[i];
   	 s+=a[i];
   }
   (n-s)>=0 ? (cout<<n-s):(cout<<-1);
   return 0;
 }

Measured memory_bytes: 3584
#include <cstdio>
typedef long long LL;
const int MAXN = 1e5+1;
LL A[MAXN], C[MAXN], S[MAXN];
int find(int L, int R, LL x)
{
	while (L < R)
	{
		int mid = (L+R)>>1;
		if(A[mid] >= x)
			R = mid;
		else
			L = mid+1;
	}
	return L;
}
int main()
{
	int N, Q, i, pos, Len = 0; LL x;
	scanf("%d%d", &N, &Q);
	A[Len++] = N;
	for(i=0; i<Q; ++i)
	{
		scanf("%lld", &x);
		while (Len && A[Len-1]>=x) --Len;
		A[Len++] = x;
	}
	C[Len-1] = 1;
	for(i=Len-1; i>=0; --i)
	{
		for(x=A[i]; x>A[0]; x %= A[pos])
		{
			pos = find(0, i+1, x)-1;
			C[pos] += C[i] * (x / A[pos]);
		}
		S[x] += C[i];
	}
	for(i=N-1; i>0; --i)
		S[i] += S[i+1];
	for(i=1; i<=N; ++i)
		printf("%lld\n", S[i]);
}

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



int main(){
	int M,T,P,R;
	while(cin >> M >> T >> P >> R && M){
		map<int,map<int,int> > wa;
		map<int,map<int,int> > ac;
		for(int i = 0 ; i < R ; i++){
			int m,t,p,j;
			cin >> m >> t >> p >> j;
			if( j != 0 ){
				wa[t][p]++;
			}else{
				ac[t][p] = m;
			}
		}
		vector< array<int,3> > v;
		for(int i = 1 ; i <= T ; i++){
			array<int,3> sub = {0,0,0};
			sub[2] = -i;
			for(int j = 1 ; j <= P ; j++){
				if( ac[i].count(j) ){
					sub[0]--;
					sub[1] += wa[i][j] * 20 + ac[i][j];
				}
			}
			v.push_back(sub);
		}
		sort(v.begin(),v.end());
		for(int i = 0 ; i < v.size() ; i++){
			if(i){
				if( v[i-1][0] == v[i][0] && v[i][1] == v[i-1][1] ){
					cout << "=";
				}else{
					cout <<",";
				}
			}
			cout << -v[i][2];
		}
		cout << endl;
		
	}
}

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

int main(){
    int n,x; cin >> n >>x;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    int cnt,dis;
    while(dis<=x){
        if(cnt==n+1) break;
        else{
        dis+=l[cnt];
        cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
class Solver():
    def __init__(self, N, costs, K):
        self.dp = [99999999999] * N
        self.dp[0] = 0
        self.K = K
        self.costs = costs

    def solve(self):
        for i in range(0, len(self.costs)):
            for k in range(1, self.K + 1):
                if i >= k:
                    self.dp[i] = min(
                        self.dp[i - k] + abs(self.costs[i] - self.costs[i-k]), self.dp[i])
        return self.dp[-1]


def main():
    N, K = [int(i) for i in input().split()]
    costs = [int(i) for i in input().split()]
    solver = Solver(N, costs, K)
    print(solver.solve())


if __name__ == "__main__":
    main()


Measured memory_bytes: 52320
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c,n) for(int i=c;i<n;i++)
 
int main(void) {
  int n,ans,cnt;
  cin>>n;
  
  ans=n/2;
  cnt=n%2;
  cout<<ans+cnt<<endl;

  return 0;
}


Measured memory_bytes: 256