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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 10000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define int long long
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

int n;
char d[1005];
bool used[10000];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i, n) cin >> d[i];
    rep(w, 4) {
        rep(i, n - w) {
            string tmp = "";
            rep(j, w + 1) {
                tmp += d[i + j];
            }
            int num = stoi(tmp);
            used[num] = true;
        }
    }
    rep(i, 10000) {
        if (!used[i]) {
            cout << i << endl;
            break;
        }
    }
}

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

int main()
{
        int n;

        scanf("%d",&n);
        int l[n];

        int i;
        for(i=0; i<n; i++)
                scanf("%d",&l[i]);

        int index=l[0];
        int j=0;
        for(i=1; i<n; i++){
                if(index < l[i]){ index=l[i]; j=i; }
        }

        int count=0;
        for(i=0; i<n; i++){
                if(i==j) continue;
                else count+=l[i];
        }

        if(count > index) printf("Yes\n");
        else printf("No\n");

        return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define mst(a,b) memset((a),(b),sizeof(a))
#define PII pair<int,int>
#define rep(i,x,y) for(auto i=(x);i<=(y);++i)
#define dep(i,x,y) for(auto i=(x);i>=(y);--i)
using namespace std;
template<class T>inline void rd(T &x) {
    x=0; int ch=getchar(),f=0;
    while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    if(f)x=-x;
}
const int inf=0x3f3f3f3f;
ll n,ans;
int main()
{
    cin>>n;
    for(ll i=2;i<=(n-1)/i;i++)
    {
        if(n%i==1) ans++;
        if(n%i==1&&(i!=(n-1)/i)) ans++;
    }
    for(ll i=2;i<=n/i;i++)
    {
        if(n%i==0)
        {
            ll temp=n;
            while(temp%i==0) temp/=i;
            if(temp%i==1) ans++;
            if(i==n/i) continue;
            temp=n;
            while(temp%(n/i)==0) temp/=(n/i);
            if(temp%(n/i)==1) ans++;
        }
        
    }
    if(n==2) cout<<1<<endl;
    else cout<<ans+2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  int S,W;
  cin>>S>>W;
  if(S<=W){
    cout<<"unsafe"<<endl;
  }
  else{
    cout<<"safe"<<endl;
  }
  return 0;
}

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

int L[10];

int main(){
  int N;
  int sum=0;
  std::cin>>N;
  for(int i=0;i<N;++i){
    std::cin>>L[i];
    sum+=L[i];
  }
  std::sort(L,L+N);
  sum-=L[N-1];
  if(sum>L[N-1]){
    std::cout<<"Yes"<<std::endl;
  }else{
    std::cout<<"No"<<std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
#define TE 2e6+5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int N; cin >> N;
	vector<ll> a(N);
	map<ll, int> mp;
	for (int i = 0; i < N; i++) {
		cin >> a[i]; mp[a[i]] = i;
	}

	sort(a.begin(), a.end());
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (mp[a[i]] % 2 != i % 2)cnt++;
	}
	cout << cnt / 2 << endl;
}



Measured memory_bytes: 10364
#include <iostream>
#include <iomanip>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

const double eps = 1e-15;

class Point
{
public:
    double x, y;
    Point() : x(0), y(0) {}
    Point(double _x, double _y) : x(_x), y(_y) {}
};

istream& operator >> (istream& in, Point& P)
{
    in >> P.x >> P.y;
    return in;
}

double Dist(const Point& P, const Point& Q)
{
    double dx = P.x - Q.x;
    double dy = P.y - Q.y;
    return sqrt(dx * dx + dy * dy);
}

class Vector
{
public:
    double x, y;
    Vector() : x(0), y(0) {}
    Vector(const Point& Start, const Point& End) : x(End.x - Start.x), y(End.y - Start.y) {}
    inline double OuterProd(const Vector& V) const
    {
        return x * V.y - y * V.x;
    }
    inline bool IsLeftOf(const Vector& V) const
    {
        return V.OuterProd(*this) > eps;
    }
    inline Vector operator + (const Vector& V) const
    {
        Vector Ret;
        Ret.x = x + V.x;
        Ret.y = y + V.y;
        return Ret;
    }
};

inline Vector operator * (double d, const Vector& V)
{
    Vector Ret;
    Ret.x = d * V.x;
    Ret.y = d * V.y;
    return Ret;
}

Point Intersect(const Point& P1, const Point& Q1, const Point& P2, const Point& Q2)
{
    Point Ret, O;
    Vector S1(O, P1), S2(O, P2);
    Vector V1(P1, Q1), V2(P2, Q2);
    double t = S2.OuterProd(V2) - S1.OuterProd(V2);
    t /= V1.OuterProd(V2);
    Vector RetVec = S1 + t * V1;
    Ret.x = RetVec.x;
    Ret.y = RetVec.y;
    return Ret;
}

double ConvexCut(const vector<Point>& vP, const Point& Start, const Point& End)
{
    double Ret = 0.f;
    int n = (int) vP.size();
    Vector RefVec(Start, End);
    Point Prev = vP[n-1], Now = vP[0];
    Vector PrevVec(Start, Prev), NowVec(Start, Now);
    bool bPrevLeft = PrevVec.IsLeftOf(RefVec), bNowLeft;

    for (int i = 0; i < n; ++i) {
        Now = vP[i];
        NowVec = Vector(Start, Now);
        bNowLeft = NowVec.IsLeftOf(RefVec);
        
        if (bPrevLeft && bNowLeft) {
            Ret += PrevVec.OuterProd(NowVec);
        } else if (!bPrevLeft && !bNowLeft) {
            ;
        } else if (bPrevLeft && !bNowLeft) {
            Point X = Intersect(Start, End, Prev, Now);
            Vector TmpVec(Start, X);
            Ret += PrevVec.OuterProd(TmpVec);
        } else {
            Point X = Intersect(Start, End, Prev, Now);
            Vector TmpVec(Start, X);
            Ret += TmpVec.OuterProd(NowVec);
        }


        Prev = Now;
        PrevVec = NowVec;
        bPrevLeft = bNowLeft;
    }

    return Ret / 2.f;
}

int main()
{
    int n;
    cin >> n;
    vector<Point> vP(n);
    for (int i = 0; i < n; ++i) {
        cin >> vP[i];
    }

    int q;
    cin >> q;
    Point Start, End;
    cout << fixed << setprecision(8);
    for (int i = 0; i < q; ++i) {
        cin >> Start >> End;
        cout << ConvexCut(vP, Start, End) << endl;
    }

    return 0;
}


Measured memory_bytes: 3288
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect_left
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def primes_for(n):
   is_prime = [True] * (n + 1)
   is_prime[0] = False
   is_prime[1] = False
   for i in range(2, n + 1):
       for j in range(i * 2, n + 1, i):
           is_prime[j] = False
   return [i for i in range(n + 1) if is_prime[i]]

N = INT()

primaries = primes_for(55555)
primaries_mod_1 = [x for x in primaries if x%5==1]
print(*primaries_mod_1[:N])


Measured memory_bytes: 4996
#include <iostream>

using namespace std;

int main(){

long n,rest;
long a[5];

  rest=0;
  cin >> n;
  for(int i=0;i<5;i++){
  cin >> a[i];
  rest=max(rest,(n-1)/a[i]);
  }
  cout << rest+5 <<endl;
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))

#define MOD 1000000007
#define INF 1000000000

int N, M, K;

int main()
{
    cin >> N >> M >> K;
    REP(i, N+1) {
        REP(j, M+1) {
            if(K == (N - i) * j + (M - j) * i) {
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main () {

    int H, W, i, j;

    for (; ; ) {
        scanf("%d", &H); scanf("%d", &W);
        if (H == 0 && W == 0)
            break;
        for (i = 0; i < H; i++) {
            for (j = 0; j < W; j++) {
                if ((i + j) % 2 == 0) {
                    putchar('#');
                } else {
                    putchar('.');
                }
            }
            puts("");
        }
    puts("");
    }

    return 0;

}



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

using namespace std;
using ll = long long;

int main() {
  int x,n;
  cin >> x >> n;
  vector<int> p(101);

  rep (i,n) {
    int k;
    cin >> k;
    p[k]++;
  }

  if (p[x] == 0) {
    cout << x << endl;
    return 0;
  }

  int count = 0;

  while (true) {
    count++;
    int ans;
    for (int i = -1; i <= 1; i++) {
      ans = x + count*i;
      if (p[ans] == 0) {
        cout << ans << endl;
        return 0;
      }
    }
  }
  

  
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
int main (){
  int n;
  cin >> n;
  int a[n];
  int t=0;
  for(int i=0; i<n; i++){
    cin >> a[i];

    if(a[i]%2!=0){
      t++;
    }else if(a[i]%5==0){
      t++;
    }else if(a[i]%3==0){
      t++;
    }
    
  }
  if(n==t){
    cout <<"APPROVED" << endl;
  }
  if(n!=t){
    cout <<"DENIED" << endl;
  }

  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    int n, m;
    cin >> n >> m;
    vector<int> cnt(n + 1, 0);
    cnt[0] = 1;
    rep(i, m)
    {
        int x;
        cin >> x;
        cnt[x] = -1;
    }
    rep(i, n)
    {
        if (cnt[i + 1] == -1)
        {
            cnt[i + 1] = 0;
            continue;
        }
        if (i >= 1)
            cnt[i + 1] = (cnt[i] + cnt[i - 1]) % mod;
        else
            cnt[i + 1] = cnt[i];
    }
    cout << cnt[n] << endl;
}


Measured memory_bytes: 1024
#pragma GCC optimize ("-O3")
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
ll NUM = 1e9+7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define zer ll(0)
 

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

    v64 v(n,0);
    ll sum=0;


    forn(i,n)
    {
        cin>>v[i];
    }


    forn(i,n)
    {
        forsn(j,i+1,n)
        {
            sum += v[i]*v[j];
        }
    }

    cout<<sum;

    return 0;
}

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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int n;
	cin >> n;
	map<int, int> mp;
	REP(i, n)
	{
		int a;
		cin >> a;
		mp[a] = i + 1;
	}
	REPIT(mp)
	{
		print((*it).second);
	}
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 5504
object Main extends App {
  val in = readLine.split(' ').map(_.toDouble)
  val a = in(0)
  val b = in(1)
  val C = in(2).toRadians

  val c = math.sqrt(a*a + b*b - 2*a*b*math.cos(C))

  val L = a + b + c;

  val h = b * math.sin(C)

  val S = a * h / 2;

  println(S)
  println(L)
  println(h)
}



Measured memory_bytes: 43916
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 1e18;
const ll fact_table = 5000000;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[550010];
vector<ll> R[550010];
vector<pair<ll, double> > tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<"\n";
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 998244353;
//ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,f,g,h,w,i,j,q,r,l;
ll k,ans;
ll x[500005],y[500005],z[500005];
ll dp[5005][5005];
char s[500005];
char t[500005];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> a >> b >> k;
    ll ans1 = max(0ll , a - k);
    ll ans2;
    if(a >= k){
        ans2 = b;
    }else{
        ans2 = max(0ll , b - (k - a));
    }
    pe(ans1);p(ans2);
    return 0;
}















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

int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll s,t,u,v;
    s=a*c;t=a*d;
    u=b*c;v=b*d;
    ll ans=s;
    chmax(ans,t);
    chmax(ans,u);
    chmax(ans,v);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3644
a,b,c,d=map(int,input().split())
count=0
for i in range(100):
  turn1=c-b
  c=turn1
  count+=1
  if c<=0:
    break

newcount=0
for i in range(100):
  turn2=a-d
  a=turn2
  newcount+=1
  if a<=0:
    break

if count<=newcount:
  print('Yes')
else:
  print('No')

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

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

  rep(i,n-1) {
    ans += min(T[i+1] - T[i], t);
  }
  cout << ans+t << endl;
  return 0;
}

Measured memory_bytes: 3880
#include <cstdio>
char str[400005];
int main()
{
	// freopen("AGC011-D.in", "r", stdin);
	int n, k;
	scanf("%d%d%s", &n, &k, str);
	int he = 0, ta = n, flg = 0;
	while (k-- && he < n)
	{
		if ((str[he] ^ flg) == 'A')
			str[he] ^= 3;
		else
		{
			flg ^= 3;
			str[ta++] = 'A' ^ flg;
			he++;
		}
	}
	if ((n & 1) && !(k & 1))
		str[he] ^= 3;
	for (int i = he; i < ta; i++)
		putchar(str[i] ^ flg);
	puts("");
	return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>

int main(){
   std::string O, E;
   std::cin >> O >> E;
   std::string S, Sout;
   S = O + E;
   int N = S.size();
   for (int i=0; i<N; i++){
      if (i % 2 == 0){
         Sout = Sout + O.at(i/2);
      } else{
         Sout = Sout + E.at(i/2);
      }
   }
   std::cout << Sout << std::endl;

}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(){
	int x,n[101], i=0;
	char s[100];
	
	while(scanf("%s", s)!=EOF){
		if(s[0]=='+'){
			n[i-1]+=n[i];
			i--;
		}else if(s[0]=='-'){
			n[i-1]-=n[i];
			i--;
		}else if(s[0]=='*'){
			n[i-1]*=n[i];
			i--;
		}else{
			x=atoi(s);
			i++;
			n[i]=x;
			
		}
	}
	printf("%d\n", n[i]);
	
	return 0;
}



Measured memory_bytes: 2148
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(s) (s).begin(),(s).end()
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define rrep(i,n,l) for(int i=n-1;i>=l;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a);
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
//typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

vi v;
int n, l;

int main() {
	while (cin >> n >> l) {
		if (n == 0 && l == 0)break;
		int d[100] = {};
		bool f = 0;
		d[0] = n;
		rep(i,1,21) {
			string s;
			stringstream ss, ss2, ss3;
			ss << n;
			ss >> s;
			while (s.size()<l){
				s += "0";
			}
			string t1 = s;
			sort(ALL(t1));
			string t2 = t1;
			reverse(ALL(t2));
			int mi, ma;
			ss2 << t1;
			ss2 >> mi;
			ss3 << t2;
			ss3 >> ma;
			n = ma - mi;
			d[i] = n;
			//o(n);
			REP(j, i) {
				if (d[i] == d[j]) {
					cout << j << " " << d[i] << " " << i - j << endl;
					f = 1;
					break;
				}
			}
			if (f)break;
		}
	}
}

Measured memory_bytes: 1248
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main() {
  string A, B;
  cin >> A >> B;
  string ans="EQUAL";
  if(A.size() > B.size())
    ans = "GREATER";
  else if(A.size() < B.size())
    ans = "LESS";
  else {
    rep(i,A.size()) {
      if(A[i] > B[i]) {
        ans = "GREATER";
        break;
      }
      else if(A[i] < B[i]) {
        ans = "LESS";
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N,Q = map(int, input().split())

es = [[] for _ in range(N)]
for i in range(N-1):
    a,b = map(int, input().split())
    es[a-1].append(b-1)
    es[b-1].append(a-1)


ans = [0] * N
px = [0] * N
for i in range(Q):
    p, x = map(int, input().split())

    px[p-1] += x

visited = [False] * N

stack = [0]
while stack:
    i = stack.pop()
    ans[i] += px[i]
    visited[i] = True
    for j in es[i]:
        #print(i,j,es)
        if visited[j] == False:
            ans[j] += ans[i]
            stack.append(j)
    

print(*ans)

Measured memory_bytes: 62572
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ls x<<1
#define rs x<<1|1
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-6;
const ull hashp=1e7+19;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=2e5+100;
int vis[maxn];
int a[maxn];
int dp[maxn];
int num[maxn];
void solve()
{
	int n;scd(n);
	rep1(i,n){
		scd(a[i]);
		vis[a[i]]++;
	}
	dp[0]=1;
	int cnt=3;
	rep1(i,n){
		if(!a[i])num[0]++,dp[i]=1ll*dp[i-1]*cnt%mod,cnt--;
		else dp[i]=1ll*dp[i-1]*num[a[i]-1]%mod,num[a[i]-1]--,num[a[i]]++;
		//dbg(i);
		//dbg(dp[i]);
	}
	int ans=dp[n];
	ac;
}
int main(){
    //IOS;
    solve();
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 2002

enum Type{
	VISUAL,
	DANCE,
	VOCAL,
};

struct Info{
	int point[3];
};

int vonus_point[3] = {5,3,2};
Info info[NUM];
double dp_allocate[NUM][NUM],dp_appeal_num[NUM];
double dp_exp[3][NUM];

int main(){

	int N,M;
	scanf("%d %d",&N,&M);

	for(int i = 0; i < N; i++){
		scanf("%d %d %d",&info[i].point[VISUAL],&info[i].point[DANCE],&info[i].point[VOCAL]);
	}

	for(int i = 0; i <= M; i++){
		for(int k = 0; k <= M; k++)dp_allocate[i][k] = 0;
	}

	int self = 0;

	dp_allocate[0][0] = 1;

	for(int count = 1; count <= M; count++){
		for(int vi = 0; vi <= count-1; vi++){
			dp_allocate[count][vi+1] += dp_allocate[count-1][vi]/3.0;
			dp_allocate[count][vi] += dp_allocate[count-1][vi]*2.0/3.0;
		}
	}

	double tmp = 0;
	for(int num = M; num >= 0; num--){
		tmp += dp_allocate[M][num];
		dp_appeal_num[num] = tmp;
	}

	for(int junle = 0; junle <= 2; junle++){
		for(int count = 0; count <= M; count++)dp_exp[junle][count] = 0;
	}

	double rank_1,rank_2,rank_3,rank_lowest,upper_probability;
	int self_point,enemy_point,need_count;

	for(int junle = 0; junle <= 2; junle++){
		for(int count = 0; count <= M; count++){

			rank_1 = 1.0,rank_2 = 0.0,rank_3 = 0.0,rank_lowest = 1.0;

			self_point = info[self].point[junle]*count;

			for(int i = 1; i < N; i++){

				enemy_point = info[i].point[junle];

				if(self_point%enemy_point == 0){
					need_count = self_point/enemy_point;
				}else{
					need_count = self_point/enemy_point+1;
				}

				if(need_count > M){
					upper_probability = 0;
				}else{
					upper_probability = dp_appeal_num[need_count];
				}

				rank_3 = rank_2*upper_probability+rank_3*(1-upper_probability);
				rank_2 = rank_1*upper_probability+rank_2*(1-upper_probability);
				rank_1 *= (1-upper_probability);
				rank_lowest *= upper_probability;
			}

			dp_exp[junle][count] = (rank_1+rank_2+rank_3)*vonus_point[junle]-rank_lowest;
		}
	}

	double ans = -DBL_MAX;

	int vo;
	for(int vi = 0; vi <= M; vi++){
		for(int da = 0; vi+da <= M; da++){
			vo = M-(vi+da);

			ans = max(ans,dp_exp[VISUAL][vi]+dp_exp[DANCE][da]+dp_exp[VOCAL][vo]);
		}
	}

	printf("%.12lf\n",ans);

    return 0;
}



Measured memory_bytes: 34576
n, m = map(int, input().split())
an = [input() for _ in range(n)]
bn = [input() for _ in range(m)]
diff = n-m+1
flag = False
for i in range(diff):
    for j in range(diff):
        if [a[j:m+j] for a in an[i:m+i]] == bn:
            flag = True
print('Yes' if flag else 'No')


Measured memory_bytes: 3060
N=int(input())
A=list(map(int,input().split()))

Ans=0
S=[0]*(len(A)+1)

for i in range(0,N):
  S[i+1]=S[i]+A[i]
  #print(S[i+1])
  
#print(S[N])  
  
for i in range(0,N):
#  print(A[i]*(S[N]-S[i+1]))
  Ans+=A[i]*(S[N]-S[i+1])
  
print(Ans%(10**9+7))

  

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

const int mod = 998244353;
int n, k, l[10], r[10], a[200001], b[200002] = { 0, 1, -1 };

int main() {
	cin >> n >> k;
	for (int i = 0; i < k; ++i) {
		cin >> l[i] >> r[i];
	}

	for (int i = 1; i < n; ++i) {
		a[i] = (a[i - 1] + b[i]) % mod;
		for (int j = 0; j < k; ++j) {
			int x, y;
			x = min(n + 1, i + l[j]);
			y = min(n + 1, i + r[j] + 1);
			b[x] += a[i];
			b[x] %= mod;
			b[y] -= a[i];
			b[y] %= mod;
		}
	}
	a[n] = (a[n - 1] + b[n]) % mod;

	if (a[n] < 0)
		a[n] += mod;
	cout << a[n] << endl;
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 1005;
int N, K;
int A[MAX_N];
int sumA[MAX_N];

bool used[MAX_N*MAX_N];

signed main()
{
  cin >> N >> K;
  REP(i,N) {
    cin >> A[i];
    sumA[i+1] = sumA[i] + A[i];
  }

  vector<int> vec;
  REP(l,N) {
    FOR(r,l+1,N+1) {
      vec.push_back(sumA[r] - sumA[l]);
    }
  }

  sort(begin(vec), end(vec));
  // REP(i,vec.size()) {
  //   cerr << vec[i] << endl;
  // }
  // cerr << endl;

  for(int Bit = 55; 0 <= Bit; Bit--) {
    int k = 0;
    REP(i,vec.size()) {
      if(used[i]) {
        continue;
      }
      if((vec[i] >> Bit) & 1) {
        k++;
      }
    }

    if(k >= K) {
      // cerr << Bit << endl;
      REP(i,vec.size()) {
        if(used[i]) {
          continue;
        }
        if(!((vec[i] >> Bit) & 1)) {
          used[i] = true;
        }
      }
    }
  }

  int ans = ((LL)1 << 60)-1;
  REP(i,vec.size()) {
    if(used[i]) {
      continue;
    }
    ans &= vec[i];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 6512
#include <iostream>
using namespace std;
int main() 
{
	int i, j, H, W;
    while (1) {
    	cin >> H >> W;
        if(H == 0 && W == 0) {
        	break;
        }
        for (i = 1; i <= H; i++) {
            for (j = 1; j <= W; j++) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
	return 0;
}


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

int main(int argc, const char * argv[]) {
    int L;
    cin >> L;
    
    double ll = static_cast<double>(L);
    
    double ans = ll * ll * ll / 27.0;
    
    cout << setprecision(12) << ans;
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
#define INF 1 << 30
#define MOD 1000000007;
#define pi 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

int main() { 
  int a, b;
  cin >> a >> b;
  for (int i = 0; i < a; i++) {
    string s;
    cin >> s;
    D(s);
    D(s);
  }
  return 0;
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split( )))
#print(a)
x = 0
front = 0
step = 0
for height in a :
    #print('ooo', height)
    if front > height :
        x = front - height
        #print('ppp',x)
        step += x
    if front < height:
        front = height
print(step)


Measured memory_bytes: 32372
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
int main() {
    long long N, ans = 1;
    cin >> N;
    rep(i, N) ans = (ans * (i + 1)) % MOD;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

long long a, b, c, k;

int main(){
	cin >> a >> b >> c >> k;

	if(k < a || k == a){
		cout << k << endl;
	}
	else if(k < (a + b) || k == (a + b)){
		cout << a << endl;
	}
	else{
		cout << a - (k - (a + b)) << endl;
	}


	return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>		// standard input output
#include <iostream>		// input output stream, cin cout( console in console out)
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>		// input output manipulation

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

int main() {
  int H1, M1, H2, M2, K; // 変数の宣言
  cin >> H1 >> M1 >> H2 >> M2 >> K; // 標準入力
  
  int ans, av_time;
  av_time = (H2 - H1) * 60 + M2 - M1;
  ans = av_time - K;
  cout << ans << endl; // 標準出力
}

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

typedef long long LL;
const int N = 1000005, mod = 998244353;

int n, m, factor[N], ifactor[N], ans;
void reduce(int &x) { x += x >> 31 & mod; }
int pow(int x, int y, int ans = 1) {
	for (; y; y >>= 1, x = (LL) x * x % mod)
		if (y & 1) ans = (LL) ans * x % mod;
	return ans;
}
void init(int n) {
	factor[0] = 1;
	for (int i = 1; i <= n; ++i)
		factor[i] = (LL) factor[i - 1] * i % mod;
	ifactor[n] = pow(factor[n], mod - 2);
	for (int i = n; i; --i)
		ifactor[i - 1] = (LL) ifactor[i] * i % mod;
}
int c(int x, int y) { return (LL) factor[x + y] * ifactor[x] % mod * ifactor[y] % mod; }

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> m, init(n + m);
	if (n < m) std::swap(n, m);
	for (int i = 1; i <= m; ++i)
		ans = (ans + (LL) c(i, i) * c(n - i, m - i)) % mod;
	std::cout << (n + pow(c(n, m) * 2, mod - 2, ans)) % mod << '\n';
	return 0;
}

Measured memory_bytes: 8064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Aoj.DPL.Chapter1B
{
    public class Item
    {
        public int Value { get; set; }
        public int Weight { get; set; }

        public Item (int v, int w)
        {
            Value = v;
            Weight = w;
        }
    }
    class Program
    {
        public static void Solve()
        {
            int[] n_w = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int n = n_w[0];
            int w = n_w[1];

            var items = new Item[n+1];
            items[0] = new Item(0, 0);
            for (int i = 1; i <= n; i++)
            {
                int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                items[i] = new Item(input[0], input[1]);
            }

            var values = new int[n + 1][];
            values[0] = Enumerable.Repeat(0, w + 1).ToArray();
            for (int i = 1; i <= n; i++)
            {
                values[i] = Enumerable.Repeat(0, w + 1).ToArray();
                
                var item = items[i];
                for (int j = 0; j < item.Weight; j++)
                {
                    values[i][j] = values[i - 1][j];
                }

                for (int j = 0; j <= w; j++)
                {
                    if (j < item.Weight) {
                        values[i][j] = values[i - 1][j];
                    } else {
                        values[i][j] = Math.Max(
                            values[i - 1][j],
                            values[i - 1][j - item.Weight] + item.Value
                        );
                    }
                }
            }

            Console.WriteLine(values[n][w]);
        }

        public static void Main()
        {
            // Console.SetIn(new System.IO.StreamReader("DiscreteOptimizationProblems/Input/01_Combinational_B_03.txt"));
            // var sw = new Stopwatch();
            // sw.Start();

            Solve();

            // Console.WriteLine("{0}ms", sw.ElapsedMilliseconds);
        }
    }
}

Measured memory_bytes: 15472
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n; cin >> n;
    rep(_,n){
        int a;cin >>a;
        if(a % 2) return puts("first")*0;
    }
    cout << "second" << endl;
}




Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,i,j,min;
	float v[50],tmp;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%f",&v[i]);
	}
	for(i=0;i<n-1;i++){
		min=i;
		for(j=i+1;j<n;j++){
			if(v[min]>v[j]){
				min=j;
			}
		}
		tmp=v[i];
		v[i]=v[min];
		v[min]=tmp;
	}
	for(i=0;i<n-1;i++){
		v[i+1]=(v[i]+v[i+1])/2;
	}
	printf("%f\n",v[n-1]);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
bool isPrime(int x){
  for (int i = 2; i*i <= x ; ++i)
  {
    if(x%i == 0){
      return false;
    }
  }
  return true;
}
int main(){	
      //   #ifndef ONLINE_JUDGE
      //  // for getting input from input.txt
      //  freopen("input.txt", "r", stdin);
      //  // for writing output to output.txt
      //  freopen("output.txt", "w", stdout);
      // #endif

       int n;
       cin>>n;
        for (int i = n; i <= 10000000; ++i)
        {
          if(isPrime(i) == true){
            cout<<i<<endl;
            return 0;
          }
        }
       return 0;
 }


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Int32;
using static System.Math;
 
class Program
{
    static bool[] n2b(int n)
    {
        var result = new bool[10];
        int i = 0;
        while (0 < n)
        {
            result[i++] = (n % 2) == 1;
            n = n >> 1;
        }
        return result;
    }

    static int GetAndCount(bool[] lhs, bool[] rhs)
    {
        int result = 0;
        for(int i = 0; i < lhs.Length; ++i)
        {
            if (lhs[i] && rhs[i]) ++result;
        }
        return result;
    }

    static void Main(string[] args)
    {
        label:
        int n = Parse(ReadLine());
        var f = new bool[n][];
        var p = new int[n][];
        for(int i = 0; i < n; ++i)
        {
            f[i] = new bool[10];
            var sp = ReadLine().Split();
            for(int j = 0; j < sp.Length; ++j)
            {
                if (sp[j] == "1") f[i][j] = true;
            }
        }
        for (int i = 0; i < n; ++i)
        {
            p[i] = ReadLine().Split().Select(Parse).ToArray();
        }
        int result = MinValue;
        for (int i = 1; i < 1024; ++i)
        {
            var array = n2b(i);
            int tmp = 0;
            for (int j = 0; j < f.Length; ++j)
            {
                tmp += p[j][GetAndCount(f[j], array)];
            }
            result = Max(result, tmp);
        }
        WriteLine(result);
    }
}


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

int N, L;
int idx = 0;
string s;

class Mat {
public:
    vector<vector<int>> m;
    Mat(){}
    Mat(vector<vector<int>> m_):m(m_){}

    void output() {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++){
                if (j) cout << " ";
                cout << m[i][j] + 1;
            }
            cout << endl;
        }
    }
};

Mat init_state;
Mat move(const Mat &s, const Mat &t) {
    vector<vector<int>> ret(N, vector<int>(N));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            int ny = t.m[i][j] / N, nx = t.m[i][j] % N;
            ret[i][j] = s.m[ny][nx];
        }
    }
    return Mat(ret);
}

Mat pow(const Mat &m, int x) {
    Mat ret = init_state, tmp = m;
    while (x) {
        if (x & 1) ret = move(ret, tmp);
        tmp = move(tmp, tmp);
        x = x >> 1;
    }
    return ret;
}

Mat seq();
Mat rep();

int number() {
    int ret = 0;
    while (isdigit(s[idx])) {
        ret = 10 * ret + (s[idx] - '0');
        idx++;
    }
    return ret;
}

Mat ope() {
    char shift = s[idx++];
    int num = number();
    num--;

    auto op_mat = init_state.m;
    if (shift == 'L') {
        for (int i = 0; i < N; i++)
            op_mat[num][i] = init_state.m[num][i < N-1 ? i + 1 : 0];
    } else if (shift == 'R') {
        for (int i = 0; i < N; i++)
            op_mat[num][i] = init_state.m[num][i ? i - 1 : N - 1];
    } else if (shift == 'U') {
        for (int i = 0; i < N; i++)
            op_mat[i][num] = init_state.m[i < N - 1 ? i + 1 : 0][num];
    } else { // shift == 'D'
        for (int i = 0; i < N; i++)
            op_mat[i][num] = init_state.m[i ? i - 1 : N - 1][num];
    }

    return Mat(op_mat);
}

Mat rep() {
    idx++; // skip '('
    Mat ret = seq();
    idx++;
    int num = number();
    ret = pow(ret, num);
    return ret;
}

Mat seq() {
    Mat ret = init_state;
    while (s[idx] == '(' || "LRUD"s.find(s[idx]) != string::npos) {
        Mat right;
        if (s[idx] == '(')
            right = rep();
        else
            right = ope();
        ret = move(ret, right);
    }
    return ret;
}

int main() {
    idx = 0;
    cin >> N >> L >> s;

    vector<vector<int>> init(N, vector<int>(N));
    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            init[i][j] = i * N + j;
    init_state = Mat(init);

    seq().output();
}



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

int main()
{
ll n , p ;
p=2019;
string s ;
cin >> s ;
n=s.size();
auto mod = [&](ll modx) {modx%=p;modx+=p;modx%=p;return modx; };
vector<ll> v;
rep(i,n){
  v.push_back(s[i]-'0');
}
if(p==2||p==5){
  rep(i,n){
    if(v[i]%p==0)ans+=i+1;
  }
}
else{
vector<ll> a(p);
vector<ll> b(n);
ll k=1,kk=0;
rep(i,n){
  kk=mod(k*v[n-1-i]+kk);
  a[kk]++;
  b[n-i-1]=kk;
  k=mod(k*10);
}
a[0]++;
rep(i,n){
  ans+=a[b[i]]-1;
  a[b[i]]--;
}

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


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

int main(){
  int i,N,value[51] ;
  float sum,c ;

  cin >> N ;

  for(i=0;i<N;i++){
    cin >> value[i] ;
  }

  sort(value,value+N) ;

  c = value[0] ;

  for(i=1;i<N;i++){
    sum = (c+value[i])/2 ;
    c = sum ;
  }

  cout << sum ;
}


Measured memory_bytes: 888
#include <stdio.h>
#define MAX (2*100000)

int main()
{
  int N;
  int bucket[MAX];
  
  int temp;
  int index;
  for(index = 0; index < MAX; ++index)
    bucket[index] = 0;
  
  scanf("%d", &N);
  for(index = 0; index < N - 1; ++index){
    scanf("%d", &temp);
    ++bucket[temp - 1];
  }
  for(index = 0; index < N; ++index)
    printf("%d\n", bucket[index]);
  
  return 0;
}

Measured memory_bytes: 2508
n = int(input())
s = input()
w = [0]
e = [0]
for i in range(len(s)):
    if s[i]=="W":
        w.append(w[i]+1)
        e.append(e[i])
    else:
        w.append(w[i])
        e.append(e[i]+1)
ans = 10**9
for i in range(0,len(s)):
    ans = min(ans,w[i]+e[-1]-e[i+1])
print(ans)


Measured memory_bytes: 17644
n, m = map(int, input().split())
abc = [list(map(int, input().split())) for _ in range(m)]


def bellman_ford(s, g):
	dist = [float("inf")] * n
	dist[s] = 0
	negative = [False] * n
	for i in range(2 * n):
		for a, b, c in abc:
			a -= 1
			b -= 1
			c = -c

			if dist[b] > dist[a] + c:
				dist[b] = dist[a] + c
				if i >= n:
					negative[b] = True

	if negative[g]:
		ret = "inf"

	else:
		ret = -dist[g]

	return ret


ans = bellman_ford(0, n - 1)
print(ans)


Measured memory_bytes: 3572
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    ll h,w,d,q;
    cin>>h>>w>>d;
    vector<pint> num(100009);
    rep(i,h)rep(j,w){
        int a;
        cin>>a;
        num[a]={i+1,j+1};
    }

    vll dp(100009);
    dp[0]=0;
    for(ll i=d;i<=h*w;i++){
        dp[i]=dp[i-d]+abs(num[i-d].fi-num[i].fi)+abs(num[i-d].se-num[i].se);
    }

    cin>>q;
    rep(i,q){
        ll l,r;
        cin>>l>>r;
        ll ans=dp[r]-dp[l];
        cout<<ans<<endl;
    }

}

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

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    pair<pair<string, int> , int> book[n];
    for (size_t i = 0; i < n; i++) {
        string s;
        int p;
        cin >> s >> p;
        book[i] = make_pair(make_pair(s, -p), i+1);
    }

    sort(book, book+n);
    for (size_t i = 0; i < n; i++) cout << book[i].second << endl;
    return 0;
}


Measured memory_bytes: 3652
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = Integer.parseInt(sc.next());
        int N = Integer.parseInt(sc.next());
        int[] A = new int[N];
        Integer[] dist = new Integer[N];
        int time = 0;

        for (int i = 0; i < N; i++) {
            A[i] = Integer.parseInt(sc.next());
        }

        for (int i = 0; i < N - 1; i++) {
            dist[i] = Math.abs(A[i + 1] - A[i]);
        }

        dist[N - 1] = Math.abs(A[0] + K - A[N - 1]);

        Arrays.sort(dist, Collections.reverseOrder());
        for (int i = 1; i < N; i++) {
            time += dist[i];
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(time);
        out.flush();
        sc.close();
    }
}

Measured memory_bytes: 61068