akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#define INF -1e9

typedef struct{
	int x,y;
}coordinate;

int H,W;
int d[50][50];
char s[50][51];


int bfs(){
	int i,j;
	int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
	int sx=0,sy=0,gx=H-1,gy=W-1;
	
	for(i=0;i<H;i++)for(j=0;j<W;j++)d[i][j]=INF;
	d[sx][sy]=0;
	coordinate visit[2500]={0};
	int queH=0,queT=0;
	visit[queH].x = sx;
	visit[queH].y = sy;
	queT++;
	
	while(queT>queH){
		int px=visit[queH].x,py=visit[queH++].y;
		if(px==gx && py==gy)break;
		for(i=0;i<4;i++){
			int nx = px+dx[i], ny = py+dy[i];
			if(0<=nx && nx<H && 0<=ny && ny<W && s[nx][ny]!='#' && d[nx][ny]==INF){
				visit[queT].x = nx;
				visit[queT++].y = ny;
				d[nx][ny] = d[px][py]+1;
			}
		}
	}
	return d[gx][gy];
	}
	

int main(void){
	int i,j;
	scanf("%d%d",&H,&W);
	int white = 0;
	
	for(i=0;i<H;i++){scanf("%s",&s[i]);}
	for(i=0;i<H;i++)for(j=0;j<W;j++)if(s[i][j] == '.')white++;
	
	int p = bfs();
	if(p==INF)printf("-1");
	else printf("%d",white-p-1);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int zMIN(int a,int b){return a&&b?MIN(a,b):a+b;}
int main(){
  int n,i,j,k,l,d[20][20];
  while(scanf("%d",&n),n){
    int dp[1<<17]={0};
   for(i=0;i<n;i++){
      scanf("%d",&dp[1<<i]);
      for(j=0;j<n;j++)scanf("%d",&d[i][j]);
    }
   for(j=1;j<1<<n;j++){
     for(k=0;k<n;k++){
       if((j|1<<k)==j)continue;
       dp[j+(1<<k)]=zMIN(dp[j|1<<k],dp[j]+dp[1<<k]);
       for(l=0;l<n;l++){
	 if((j|1<<l)-j)continue;
	 dp[j+(1<<k)]=zMIN(dp[j+(1<<k)],dp[j]+d[k][l]);
       }
     }
   }
   //for(j=0;j<1<<n;j++)printf("%d ",dp[j]);printf("\n");
   printf("%d\n",dp[(1<<n)-1]);
  }
  return 0;
}

Measured memory_bytes: 1120
#include <iostream>
#include <iomanip>
int main() {
    long a, b;
    std::cin >> a >> b;
    std::cout << a / b << ' ' << a % b << ' ';
    std::cout << std::fixed << std::setprecision(6)
        << static_cast<double>(a) / b << std::endl;
}



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

int main(){
  int n,m,wacount=0;
  int account = 0;
 
  cin >> n >> m;
  vector<int> wa(n,0);
   vector<bool> ac(n,false);
  vector<pair<int,string>> p(m);
  for(int i = 0; i < m; i++){
    cin >> p[i].first >> p[i].second;
  }
  
  for(int i = 0; i < m; i++){
    if(ac[p[i].first-1]==true){
      continue;
    }
    	else if(p[i].second=="WA"){
          wa[p[i].first-1]++;
        }
    	else if(p[i].second=="AC"){
      		ac[p[i].first-1] = true;
        }
    
  }
  for(int i = 0; i < n; i++){
    if(ac[i]==true)
      wacount += wa[i];
  }
  for(int i = 0; i < n; i++){
    if(ac[i]==true)
    account += 1;
  }
  cout << account <<" "<< wacount <<endl;
}


Measured memory_bytes: 6912
package main

import "fmt"

func main() {
	var N, A, B int
	fmt.Scan(&N, &A, &B)
	fmt.Println(N/(A+B)*A + Min(A, N%(A+B)))
}

func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 1772
#include "bits/stdc++.h"
using namespace std;

//

#define RESIDUE(u,v) (capacity[u][v] - flow[u][v])
#define RCOST(u,v) (cost[u][v] + h[u] - h[v])
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long

char op1,op2,op3;

int main(){
  int n;
  cin>>n;
  int m=0;
  int a = n/1000;
  n=n%1000;
  int b = n/100;
  n=n%100;
  int c = n/10;
  int d=n%10;
  REP(i,2){
    REP(j,2){
      REP(k,2){
	m=a;
	m+=(i==0)?b:(-b);
	m+=(j==0)?c:(-c);
	m+=(k==0)?d:(-d);
	if(m==7){
	  op1=(i==0)?'+':'-';
	  op2=(j==0)?'+':'-';
	  op3=(k==0)?'+':'-';
	}
      }
    }
  }
  cout<<a<<op1<<b<<op2<<c<<op3<<d<<"=7"<<endl;;
  return 0;
}


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


int main(){
    string s;
    getline(cin, s);
    stringstream ss{s};

    stack<int> num_stack;

    while(getline(ss, s, ' ')){
        if(s == "+"){
            int a, b;
            a = num_stack.top();
            num_stack.pop();
            b = num_stack.top();
            num_stack.pop();
            num_stack.push(a + b);

        }else if(s == "-"){
            int a, b;
            a = num_stack.top();
            num_stack.pop();
            b = num_stack.top();
            num_stack.pop();
            num_stack.push(b - a);

        }else if(s == "*"){
            int a, b;
            a = num_stack.top();
            num_stack.pop();
            b = num_stack.top();
            num_stack.pop();
            num_stack.push(b * a);
        }else{
            num_stack.push(stoi(s));
        }
    }


    cout << num_stack.top() << endl;


}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int MOD=998244353;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    while(cin >> a >> b >> c){
        if(a==0&&b==0&&c==0){
            return 0;
        }
        int n;cin >> n;
        vector<int> d(a+b+c,2),x(n),y(n),z(n),r(n);
        for(int i=0;i<n;i++){
            cin >> x[i] >> y[i] >> z[i] >> r[i];
            x[i]--,y[i]--,z[i]--;
        }
        for(int t=0;t<n;t++){
            for(int i=0;i<n;i++){
                if(r[i]==1){
                    d[x[i]]=1;
                    d[y[i]]=1;
                    d[z[i]]=1;
                }
                else{
                    if(d[y[i]]==1&&d[z[i]]==1){
                        d[x[i]]=0;
                    }
                    else if(d[z[i]]==1&&d[x[i]]==1){
                        d[y[i]]=0;
                    }
                    else if(d[x[i]]==1&&d[y[i]]==1){
                        d[z[i]]=0;
                    }
                }
            }
        }
        for(int i=0;i<a+b+c;i++){
            cout << d[i] << endl;
        }
    }
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int N;
    int V[25], C[25];

    cin >> N;

    for(int i = 0; i < N; ++i){
        cin >> V[i];
    }
    for(int j = 0; j < N; ++j){
        cin >> C[j];
    }

    int v_sum = 0;
    int c_sum = 0;
    int Max   = 0;
    for(int bit = 0; bit < (1<<N); ++bit){
        v_sum = c_sum = 0;
        
        for(int i = 0; i < N; ++i){
            if(bit & (1<<i)){
            v_sum += V[i];
            c_sum += C[i];
            }    
            Max = max(Max , (v_sum - c_sum));
        }
    }

    cout << Max << endl;
}

Measured memory_bytes: 256
from fractions import gcd
A, B, C, D = map(int, input().split())

diff = B - A + 1

num_c = diff // C
if A % C + diff % C > C:
    num_c += 1
num_d = diff // D
if A % D + diff % D > D:
    num_d += 1
cd = C * D // gcd(C, D)
num_cd = diff // cd
if A % cd + diff % cd > cd:
    num_cd += 1

ans = diff - (num_c + num_d - num_cd)
print(ans)

Measured memory_bytes: 5344
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <deque>
#include <vector>

using namespace std;

/*
6 7
1 3
1 4
2 3
1 5
3 5
2 4
5 6
*/

#define X first
#define Y second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair <int, int> pii;

const int INF=0x3f3f3f3f;
const int N=1e5+5;

int n, m;
vector <int> ls[N];
int bio[N], prvi=1;
vector <int> sol;
deque <int> Q;

#define deg(x) ls[x].size()

//int dfs1(int node) {
//    bio[node]=1;
//    int flag=1, res=0;
//    for (int i=0; i<deg(node); ++i) {
//        int sus=ls[node][i];
//        printf("node==%d, sus: %d, bio: %d\n", node, sus, bio[sus]);
//        system("pause");
//        if (!bio[sus]) {
//            int pom=dfs1(sus);
//            if (pom) {
//                sol.pb(node);
//                res=1;
//            }
//            flag=0;
//        }
//    }
//    if (flag && prvi) {
//        sol.pb(node);
//        prvi=0;
//        return 1;
//    }
//    return res;
//}


void load() {
    scanf("%d %d", &n, &m);
    for (int i=0; i<m;++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        ls[a].pb(b);
        ls[b].pb(a);
    }
}

void solve() {
    Q.push_back(1);
    bio[1]=1;
    while (1) {
        int node=Q.front(), fl=0;
        if (bio[node]==2) {
            node=Q.back();
            fl=1;
            if (node==1) bio[node]++;
            //printf("tuuuuuuuu node = %d\n");
        }
        if (bio[node]==2 || bio[node]>3) break;
        if (bio[node]<=1) bio[node]=2;
        for (int sus:ls[node]) {
            int z=0;
            if (!bio[sus]) {
                //printf("node == %d, sus == %d, fl == %d\n", node, sus, fl);
                if (fl) Q.push_back(sus);
                else Q.push_front(sus);
                bio[sus]=1; break;
            }
        }
    }
    printf("%d\n", Q.size());
    while (!Q.empty()) {
        printf("%d ", Q.front());
        Q.pop_front();
    }
}

int main() {
    load();
    solve();
    return 0;
}


Measured memory_bytes: 7040
n, m = (int(i) for i in input().split());

task = [[0, 0] for i in range(n)];
solved = 0;
penalty = 0;

for i in range(m):
    p, s = (j for j in input().split());
    p = int(p) - 1;
    if task[p][0] == 1:
        continue;
    if s == "AC":
        solved += 1;
        penalty += task[p][1];
        task[p][0] = 1;
    else:
        task[p][1] += 1;

print(solved, penalty);


Measured memory_bytes: 13172
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;


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

    string S;
    cin >> S;
    int a[4];
    rep(i,4){
        a[i]=S.at(i)-'0';
    }
    int sum;
    bool z=false;
    rep(i,2){
        rep(j,2){
            rep(k,2){
                sum=a[0]+a[1]*pow(-1,i)+a[2]*pow(-1,j)+a[3]*pow(-1,k);
                if(sum==7) {
                    z=true;
                    cout << a[0];
                    if(a[1]*pow(-1,i)>=0) cout << "+" << a[1]*pow(-1,i);
                    else cout << a[1]*pow(-1,i);
                    if(a[2]*pow(-1,j)>=0) cout << "+" << a[2]*pow(-1,j);
                    else cout << a[2]*pow(-1,j);
                    if(a[3]*pow(-1,k)>=0) cout << "+" << a[3]*pow(-1,k);
                    else cout << a[3]*pow(-1,k);
                    cout << "=7" << endl;
                    break;
                }
            }
            if(z) break;
        }
        if(z) break;
    }

}


Measured memory_bytes: 256
#include <cassert>
#include <cmath>
#include <iostream>
#include <vector>
#include <iomanip>

struct Point
{
    float x;
    float y;
};
struct Line
{
    Line(const Point& a, const Point& b)
    : p1(a), p2(b) {}
    Point p1;
    Point p2;
};
double GetSlope(const Line& line)
{
    return
    (line.p2.y - line.p1.y) /
    (line.p2.x - line.p1.x);
}
bool IsParallel(const Line& l1, const Line&l2)
{
    // std::cerr << std::fixed << std::setprecision(100) << GetSlope(l1) << std::endl;
    // std::cerr << std::fixed << std::setprecision(100) << GetSlope(l2) << std::endl;
    return GetSlope(l1) == GetSlope(l2);
    // const double gosa = 1e-10;
    // double Slope1 = GetSlope(l1);
    // double Slope2 = GetSlope(l2);
    // return std::fabs(Slope1 - Slope2) < gosa;
}
bool IsParallel(const std::vector<Point>& points)
{
    assert(points.size() == 4);
    return IsParallel(Line(points[0], points[1]), Line(points[2], points[3]));
}
std::vector<Point> Input(std::istream& is)
{
    std::vector<Point> points(4);
    for(int i = 0; i < points.size(); ++i){
        is >> points[i].x >> points[i].y;
    }
    return points;
}
int main()
{
    int n;
    std::cin >> n;
    for(int i = 0; i < n; ++i) {
        std::vector<Point> p = Input(std::cin);
        std::cout << (IsParallel(p) ? "YES" : "NO") << std::endl; 
        // if((p[1].y-p[0].y)/(p[1].x-p[0].x) == (p[3].y-p[2].y)/(p[3].x-p[2].x)){
        //     std::cout << "YES";
        // }else{
        //     std::cout << "NO";
        // }
        // std::cout << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  int N;
  cin>>N;
  long long D[100000],num[100000];
  int judge=0;
  for(int i=0;i<N;i++){
   cin>>D[i];
   num[i]=0;
  }
  if(D[0]==0){
  sort(D,D+N);
  for(int i=0;i<N;i++){
    if(judge==D[i]) judge++;
    num[D[i]]++;
  }
  if(judge!=D[N-1]+1||num[0]>1) cout<<0<<endl;
  else{
    long long answer=1;
    for(int i=1;i<judge;i++){
      for(int j=0;j<num[i];j++) answer=(answer*num[i-1])%998244353;
    }
    cout<<answer<<endl;
  }
  }
  else cout<<0<<endl;
  
  return 0;
}

Measured memory_bytes: 4640
n, y = map(int, input().split())
y //= 1000
m = y // 10
for mc in range(m, -1, -1):
  m1 = y - 10 * mc
  g = m1 // 5
  for gc in range(g, -1, -1):
    sc = m1 - 5 * gc
    if mc + gc + sc == n:
      print(mc, gc, sc)
      quit()
print(-1, -1, -1)

Measured memory_bytes: 3064
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
int sx, sy, tx, ty;
int main() {
	cin >> sx >> sy >> tx >> ty;
	int ex = tx - sx, ey = ty - sy;
	for (int i = 0; i < ex; i++) cout << 'R';
	for (int i = 0; i < ey; i++) cout << 'U';
	for (int i = 0; i < ex; i++) cout << 'L';
	for (int i = 0; i < ey; i++) cout << 'D';
	cout << 'D';
	for (int i = 0; i < ex + 1; i++) cout << 'R';
	for (int i = 0; i < ey + 1; i++) cout << 'U';
	cout << 'L';
	cout << 'U';
	for (int i = 0; i < ex + 1; i++) cout << 'L';
	for (int i = 0; i < ey + 1; i++) cout << 'D';
	cout << 'R';
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val a, b, c, x, y = sc.nextInt()
  val sum = x + y
  val p = new Array[Int](sum+1)
  for (i <- 0 to sum) {
    val ab2 = c * 2 * i
    val x1 = if (x - i > 0) (x - i) * a else 0
    val y1 = if (y - i > 0) (y - i) * b else 0
    p(i) = ab2 + x1 + y1
  }
  println(p.min)
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long int

void solve(ll caseNo)
{
    int n;
    cin >> n;
    vector<pair<int, int> > points(n);
    for(int i=0;i<n;i++)
    {
        cin >> points[i].first >> points[i].second;
    }

    int ans = 0;
    vector<int> v(n), u(n);
    for(int i=0;i<n;i++)
    {
        v[i] = points[i].first + points[i].second;
    }
    sort(v.begin(), v.end());
    ans = max(ans, v[n-1] - v[0]);
    for(int i=0;i<n;i++)
    {
        v[i] = points[i].second - points[i].first;
        u[i] = points[i].first - points[i].second;
    }
    sort(v.begin(), v.end());
    sort(u.begin(), u.end());
    ans = max(ans, u[n-1]+v[n-1]);
    cout << ans << endl;
    return;
}

int main()
{
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ll cases;
    cases = 1;
    for(ll i=1;i<=cases;i++)
    {
        solve(i);
    }
    return 0;
}

Measured memory_bytes: 6360
def main():

    n = int(input().rstrip(" "))
    weights = [int(x) for x in input().rstrip(" ").split(" ")]

    total = sum(weights)

    subtotal = 0
    diff = total

    for weight in weights:
      subtotal += weight
      new_diff = abs(total - subtotal * 2)
      if new_diff < diff:
        diff = new_diff
      else:
        break
    print(diff)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  ll S; cin >> S;
  ll x2=E9, y2=1,x3,y3;
  x3 = E9 - S%E9;
  y3 = S/E9 + 1;
  if (S==1ll*E9*E9) y3=E9, x3=0;
  cout << 0 << " " << 0 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
  //cout << abs(x2*y3-x3*y2) << endl;


  // cout << fixed << setprecision(10);
  
  return 0;
}


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

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

  int N; cin >> N;
  vector<int> P(N);
  for (int i = 0; i < N; i++) cin >> P[i];
  
  int ans = 0;
  for (int i = 1; i < N - 1; i++)
  {
    if (P[i - 1] < P[i] && P[i] < P[i + 1]) ans ++;
    if (P[i + 1] < P[i] && P[i] < P[i - 1]) ans ++;
  }
  
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
n,m,c = map(int,input().split())
li = []
for i in range(n+1):
	li.append(list(map(int,input().split())))

cnt = 0
for i in range(1,n+1):
  tmp = 0
  for j in range(m):
    tmp += li[i][j] * li[0][j]
  tmp += c
  if tmp > 0:
    cnt += 1
    
print(cnt)

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

int main(){
  int w,s;
  cin >> s >> w;
  if( w >= s ) cout << "unsafe" << endl;
  else cout << "safe" << endl;
  return 0;
}

Measured memory_bytes: 3632
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")
#define int long long

using namespace std;

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

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 20;

int n, m, l[N], r[N], a[N], ind[N], dp[N];
ll seg[N << 2], lazy[N << 2];
vi vl[N], vr[N];

void modify(int id, ll x){
	seg[id] += x;
	lazy[id] += x;
	return;
}

void shift(int id){
	modify(id << 1, lazy[id]);
	modify(id << 1 | 1, lazy[id]);
	lazy[id] = 0;
	return;
}

void add(int id, int lq, int rq, int x, int l, int r){
	if (rq <= l || r <= lq) return;
	if (lq <= l && r <= rq){
		modify(id, x);
		return;
	}
	shift(id);
	int mid = (l + r) >> 1;
	add(id << 1, lq, rq, x, l, mid);
	add(id << 1 | 1, lq, rq, x, mid, r);
	seg[id] = max(seg[id << 1], seg[id << 1 | 1]);
	return;
}

ll get(int id, int lq, int rq, int l, int r){
	if (rq <= l || r <= lq) return 0;
	if (lq <= l && r <= rq){
		return seg[id];
	}	
	shift(id);
	int mid = (l + r) >> 1;
	return max(get(id << 1, lq, rq, l, mid), get(id << 1 | 1, lq, rq, mid, r));
}

void calc(){
	for (int i = 1; i <= m + 1; i++){
		vl[l[i]].pb(i);
		vr[r[i]].pb(i);
	}
	ll sum = 0;
	for (int i = 1; i < N; i++){
		for (auto u:vl[i]){
			sum += a[u];
		}
		//if (i == 1) cout << sum << '\n';
		dp[i] = sum + get(1, 0, i, 0, N);
		//cout << i << ' ' << dp[i] << '\n';
		add(1, i, i + 1, dp[i] - sum, 0, N);
		for (auto u:vr[i]){
			add(1, l[u], r[u] + 1, a[u], 0, N);
			sum -= a[u];
		}
	}
	return;
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= m; i++){
		cin >> l[i] >> r[i] >> a[i];
		ind[i] = i;
	}
	l[m + 1] = N - 1, r[m + 1] = N - 1, a[m + 1] = 0;
	calc();
	cout << dp[N - 1];









	return 0;
}


Measured memory_bytes: 42496
// failed to generate code

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

int main(){
	int N;
	cin >> N;
	vector<int> b(N), ans(N);
	for (int i=0; i<N; i++) cin >> b[i];
	while (b.size() > 0) {
		int er = -1;
		for (int i=0; i<b.size(); i++) if (b[i] == i+1) er = i;
		// cout << er << " " << b[er] << endl;
		if (er != -1) {
			ans[b.size()-1] = b[er];
			b.erase(b.begin()+er);
			// cout << b.size() << endl;
		} else {
			break;
		}
	}

	if (b.size() > 0) {
		cout << -1 << endl;
	} else {
		for (int i=0; i<N; i++) cout << ans[i] << endl;
	}

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> p;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

string ai1333 = "ai1333";

int main(){
    int x;
    cin >> x;
    for(int i = 0;i < x / 100;i++){
        ai1333 += "3";
    }

    cout << ai1333 << endl;
} 


Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if(a==1) {
        if(b==1) cout << "Draw" << endl;
        else cout << "Alice" << endl;
        return 0;
    }
    if(b==1) {
        if(a==1) cout << "Draw" << endl;
        else cout << "Bob" << endl;
        return 0;
    }
    if(a>b) {
        cout << "Alice" << endl;
    } else if(a==b) {
        cout << "Draw" << endl;
    } else {
        cout << "Bob" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int A, B;
	cin >> A >> B;
	vector<vector<bool>> grid(100, vector<bool>(100));

	A--;
	B--;

	for (int i = 0; i < 100; i++)
	{
		for (int j = 0; j < 100; j++)
		{
			if (i < 50)
				grid[i][j] = true;
			else
				grid[i][j] = false;
		}
	}

	for (int i = 0; i < 50; i += 2)
	{
		for (int j = 0; j < 100; j += 2)
		{
			if (0 < A)
			{
				grid[i][j] = false;
				A--;
			}
		}
	}

	for (int i = 99; 50 <= i; i -= 2)
	{
		for (int j = 0; j < 100; j += 2)
		{
			if (0 < B)
			{
				grid[i][j] = true;
				B--;
			}
		}
	}

	cout << "100 100" << endl;
	for (int i = 0; i < 100; i++)
	{
		for (int j = 0; j < 100; j++)
		{
			cout << (grid[i][j] ? "#" : ".");
		}
		cout << endl;
	}
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

#include <set>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

using ll = long long;
using ii = pair<ll, ll>;

bool accept(int n, const set<int>& reject)
{
    while (n)
    {
        auto d = n % 10;
        n /= 10;

        if (reject.count(d))
            return false;
    }

    return true;
}

vector<int> filter_all(int MAX, const set<int>& reject)
{
    vector<int> valid;

    for (int n = 0; n < MAX; ++n)
        if (accept(n, reject))
            valid.push_back(n);

    return valid;
}

int main()
{
    ios::sync_with_stdio(false);

    int N, K;
    cin >> N >> K;

    set<int> reject;

    for (int k = 0; k < K; ++k)
    {
        int n;
        cin >> n;

        reject.insert(n);
    }

    auto valid = filter_all(100000, reject);

    auto it = lower_bound(valid.begin(), valid.end(), N); 

    cout << *it << endl;

    return 0;
}


Measured memory_bytes: 892
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

K = int(input())


ans = 0

tmp = {}
for i in range(201):
    tmp[i] = 0

for i in range(1, K +1):
    for j in range(1, K +1):
        tmp[math.gcd(i, j)] += 1

for k in range(1, K +1):
    for key in tmp.keys():
        ans += math.gcd(key, k) * tmp[key]
print(ans)

"""
K = 3

1 1 1  1
1 1 2  1
1 1 3  1
1 2 1  1
1 2 2  1
1 2 3  1
2 1 1  1
2 1 2  1
2 1 3  1
3 1 1  1
3 1 2  1
3 1 3  1
3 2 1  1
3 2 2  1
3 2 3  1
3 3 1  1
3 3 2  1
3 3 3  3

"""

Measured memory_bytes: 10940
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  int mx = 0;
  int sum = 0;
  rep(i, N)
  {
    int l;
    cin >> l;
    if (mx < l)
      mx = l;
    sum += l;
  }

  if (mx >= sum - mx)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}


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

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

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

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

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

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;

struct Key {
    ll match, price;
};

int main() {
    int n, m;
    cin >> n >> m;

    vector<Key> keys(m);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        ll k = 0;
        rep(j, b) {
            int c;
            cin >> c;
            c--;
            k += (1ll << c);
        }
        keys[i].match = k;
        keys[i].price = a;
    }

    vector<ll> dp(1LL << n, -1);
    dp[0] = 0;
    for (Key key : keys) {
        for (ll i = 0; i < (1LL << n); i++) {
            if (dp[i] == -1) continue;
            ll next = i | key.match;
            if (dp[next] == -1) dp[next] = dp[i] + key.price;
            else dp[next] = min(dp[next], dp[i] + key.price);
        }
    }
    cout << dp[(1LL << n) - 1] << endl;
}

Measured memory_bytes: 256
from collections import deque

def bfs(W, H):
    G = '%'
    edges = '#' * (W + 2)
    dxy = [(0, 1), (0, -1), (1, 0), (-1, 0)]
    mapL, mapR = [edges], [edges]
    for i in range(H):
        l, r = input().split()
        mapL.append('#' + l + '#')
        mapR.append('#' + r + '#')
        if 'L' in l:
            lx, ly = i+1, l.index('L')+1
        if 'R' in r:
            rx, ry = i+1, r.index('R')+1
    mapL.append(edges)
    mapR.append(edges)
    que = deque()
    enq, deq = que.append, que.popleft
    visited = [[[[0]*(W+2)for _ in[0]*(H+2)]for _ in[0]*(W+2)]for _ in[0]*(H+2)]
    enq((lx, ly, rx, ry))
    visited[lx][ly][rx][ry] = 1
    while que:
        lx, ly, rx, ry = deq()
        for dx, dy in dxy:
            llx, lly, rrx, rry = lx + dx, ly + dy, rx + dx, ry - dy
            if mapL[llx][lly] == '#':
                llx, lly = lx, ly
            if mapR[rrx][rry] == '#':
                rrx, rry = rx, ry
            if not visited[llx][lly][rrx][rry]:
                nextL, nextR = mapL[llx][lly], mapR[rrx][rry]
                if nextL == G and nextR == G:
                    return 'Yes'
                if nextL != G and nextR != G:
                    enq((llx, lly, rrx, rry))
                    visited[llx][lly][rrx][rry] = 1
    return 'No'

def main():
    for e in iter(input, '0 0'):
        W, H = map(int, e.split())
        print(bfs(W, H))

if __name__ == '__main__':
    main()


Measured memory_bytes: 80668
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,a,b;
    scanf("%d",&t);
    vector<int>v;
    while(t--)
    {
        scanf("%d",&a);
        if(a==0)
        {
            scanf("%d",&b);
            v.push_back(b);
        }
        else if(a==1)
        {
            scanf("%d",&b);
            printf("%d\n",v[b]);
        }
        else v.pop_back();
    }

    return 0;
}



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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (int i = j; i < (n); i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1e9;

int main(){

  int n,m;cin>>n>>m;
  int a[m+10],b[m+10];
  vector<int>v[n+10];
  rep(i,0,m){
    cin>>a[i]>>b[i];
    v[a[i]].push_back(b[i]);
    v[b[i]].push_back(a[i]);
  }

  rep(i,0,v[1].size()){
    if(find(v[v[1][i]].begin(),v[v[1][i]].end(),n)!=v[v[1][i]].end()){out("POSSIBLE");return 0;}
  }

  out("IMPOSSIBLE");

  return 0;
}


Measured memory_bytes: 13552
#include <stdio.h>

int main(){
	int x;
  	scanf("%d", &x);
  	int sum = 0, p = x;
  	for(int i = 0; i < 3; i++){
    	sum += p;
      	p = p*x;
    }
    printf("%d\n", sum);
  	return 0;
  
}

Measured memory_bytes: 1708
#include<bits/stdc++.h>
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000001
#define MAXN        200000005
#define mod         1000000007
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ld n,sum=0,ans,i;
    cin>>n;
    for(i=1;i<=n;i++){
        if(int(i)%2==1){
            sum+=1;
        }
    }
    ans=sum/n;
    cout<<ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
main(){
	long long int btc_rate=380000;
	int n;
	cin >> n;
	double total=0;
	double x;
	string u;
	for(int i=0;i<n;i++){
		cin >> x >> u;
		if(u=="JPY"){
			total+=x;
		}else{
			total+=btc_rate*x;
		}
	}
	printf("%.7f\n",total);

}


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

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    int n, k, s;
    scanf("%d %d %d", &n, &k, &s);
    rep(i, 0, n){
        if(i < k){
            printf("%d ", s);
        }else{
            if(s != 1000000000){
             printf("%d ", s+1);
            }else{
                printf("999999999 ");
            }
        }
    }

    return 0;
}

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


#define vt vector
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
#define ll long long
#define ld long double
#define ar array
#define inf() ifstream cin("d.txt")
#define onf() ofstream cout("test.txt")
#define mod 1000000007
#define pb push_back
#define endl cout<<"\n";
#define prt1(a) cout<<a<<" "
#define prt2(a,b) cout<<a<<" "<<b<<" "
#define prt3(a,b,c) cout<<a<<" "<<b<<" "<<c<<" "
#define in(a) cin>>a
#define inn(a,b) cin>>a>>b
#define innn(a,b,c) cin>>a>>b>>c 
#define rep(i,st,end) for(int i=st;i<end;i++)
#define repv(i,st,end) for( i=st;i>=end;i--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define TEST ll tc;cin>>tc;while(tc--)
#define EACH(x, a) for (auto& x: a)

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {
    cin >> x;
}
void read(double& d) {
    string t;
    read(t);
    d=stod(t);
}
void read(long double& d) {
    string t;
    read(t);
    d=stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
    read(h);
    read(t...);
}
template<class A> void read(vt<A>& x) {
    EACH(a, x)
        read(a);
}
template<class A, size_t S> void read(array<A, S>& x) {
    EACH(a, x)
        read(a);
}
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a <<"\n";
    err(++it, args...);
}


void solve()
{
    ll n;
    read(n);
    if(n==1)
        cout<<0;
    else
        cout<<1;
  }

 int main()
 {
    fio;
    ll k = 1;
    ll tc = 1;
    // cin>>tc;
    while(tc--){
       // cout<<"Case #"<<k<<": ";k++;
        solve();
        endl;
    }
    
 }




Measured memory_bytes: 3532
str = gets.chomp

l = str.length
sum = 0

if l == 1
  puts str.to_i
  exit
end

["", "+"].repeated_permutation(l - 1) do |plus|
  tmp = ""
  str.each_char.with_index do |c, i|
    tmp << c
    tmp << plus[i] if i != l - 1
  end
  sum += eval(tmp)
end

puts sum

Measured memory_bytes: 1916
#include "bits/stdc++.h"
using namespace std;
int main()
{
    string s;
    cin >> s;

    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
        cout << "Bad" << endl;
    else 
        cout << "Good" << endl;
}

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

int main()
{
    vector<int> a, b, c;
    int n, inp;
    long long int ans = 0;
    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> inp;
        a.push_back(inp);
    }
    sort(a.begin(), a.end());

    for(int i = 0; i < n; i++){
        cin >> inp;
        b.push_back(inp);
    }
    sort(b.begin(), b.end());

    for(int i = 0; i < n; i++){
        cin >> inp;
        c.push_back(inp);
    }
    sort(c.begin(), c.end());

    for(int i = 0; i < n; i++){
        long long int ai = distance(a.begin(), lower_bound(a.begin(), a.end(), b[i]));
        long long int ci = distance(upper_bound(c.begin(), c.end(), b[i]), c.end());
        ans += ai * ci;
    }

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

Measured memory_bytes: 1784
#include <stdio.h>

#define MAX 100

typedef unsigned long long ull;

ull gcd(ull x, ull y);
ull lcm(ull x, ull y);

int main(void)
{
	ull timer[MAX];
	ull min_time;
	int n, i;
	
	scanf("%d", &n);
	for(i=0; i<n; i++)
		scanf("%llu", &timer[i]);
	
	min_time = lcm(timer[0], timer[1]);
	for(i=2; i<n; i++)
		min_time = lcm(min_time, timer[i]);
	
	if(n == 1)
		min_time = timer[0];
	
	printf("%llu", min_time);
	
	return 0;
}

// 最大公約数を求める関数
ull gcd(ull x, ull y)
{
	ull r;
	
	// ユーグリッドの互除法
	while((r = x % y) != 0){ // yで割り切れるまでループ
		x = y;
		y = r;
    }
	
	return y;
}

// 最大公約数を求める関数
ull lcm(ull x, ull y)
{
	ull num, ans;
	
	num = gcd(x, y);
	
	if(x%num == 0)
		ans = (x/num) * y;
	else if(y%num == 0)
		ans = x * (y/num);
	
	return ans;
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      String s1 = sc.next();
      String s2 = sc.next();
      
      StringBuffer str = new StringBuffer(s1);
      
      if (str.reverse().toString().equals(s2)){
        System.out.println("YES");
      } else {
        System.out.println("NO");
      }
    }
}

Measured memory_bytes: 35776
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    a, b = map(int, input().split())
    P = list(map(int, input().split()))
    x = y = z = 0
    for p in P:
        if p <= a:
            x += 1
        elif a < p <= b:
            y += 1
        else:
            z += 1
    print(min(x, y, z))


if __name__ == '__main__':
    main()


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


void solve(long long A, long long B, long long C, long long K){
    long long res = 0;
    if (K > A) {
        res += A;
        K -= A;
    } else {
        res += K;
        K = 0;
    }
    if (K > B) {
        K -= B;
    } else {
        K = 0;
    }

    if (K > C) {
        res -= C;
    } else {
        res -= K;
    }
    printf("%d\n", res);

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long K;
    scanf("%lld",&K);
    solve(A, B, C, K);
    return 0;
}


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

int main() {
	char c[2][3];
	cin>>c[0][0]>>c[0][1]>>c[0][2]>>c[1][0]>>c[1][1]>>c[1][2];
	if(c[0][0]==c[1][2]){
		if(c[0][1]==c[1][1]){
			if(c[0][2]==c[1][0]){
				cout<<"YES"<<endl;
				return 0;
			}
		}
	}
	cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
const int MOD = 1e9+7;
template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a/b; a -= t*b; swap(a,b); u -= t*v; swap(u,v); }
        return ModInt(u);
    }
    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if(e % 2 == 0) { p = (p*p) % mod; e /= 2; }
            else { a = (a*p) % mod; e--; }
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};
using modint = ModInt<MOD>;
const int MAX_N = 25;
const int MAX_BIT = (1<<21)+10;

signed main() {
    int N;
    cin >> N;
    vector<vector<int>> A(N, vector<int>(N));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> A[i][j];
        }
    }
    
    modint dp[MAX_N][MAX_BIT];
    dp[0][0] = 1;
    
    for (int i = 0; i < N; i++) {
        for (int s = 0; s < (1<<N); s++) {
            if (dp[i][s] != 0) {
                for (int j = 0; j < N; j++) {
                    if (A[i][j] == 1 && !(s&(1<<j))) {
                        dp[i+1][(s|(1<<j))] += dp[i][s];
                    }
                }
            }
        }
    }
    
    cout << dp[N][(1<<N)-1] << endl;
    return 0;
}

Measured memory_bytes: 205184
#include<bits/stdc++.h>
const int mo=1000000007;
using namespace std;
int n,m,cnt;
struct Mat{
	int a[3][3];
	Mat(){
		memset(a,0,sizeof(a));
	}
	void set(int x,int v0,int v1,int v2){
		a[x][0]=v0; a[x][1]=v1; a[x][2]=v2;
	}
	void set2(){
		set(0,1,0,0);
		set(1,0,1,0);
		set(2,0,0,1);
	}
}t,r,R;
Mat operator *(Mat a,Mat b){
	Mat c;
	for (int i=0;i<3;i++)
		for (int j=0;j<3;j++)
			for (int k=0;k<3;k++)
				c.a[i][j]=(c.a[i][j]+1ll*a.a[i][k]*b.a[k][j])%mo;
	return c;
}
Mat power(Mat a,int v){
	Mat b; b.set2();
	for (;v;v/=2,a=a*a)
		if (v&1) b=b*a;
	return b;
}
int main(){
	scanf("%d%d",&n,&m);
	int cnt=1;
	t.set(0,1,2,4);
	r.set(0,1,1,1);
	r.set(1,0,1,2);
	r.set(2,1,1,2);
	R.set(0,1,0,0);
	R.set(1,0,1,2);
	R.set(2,1,0,1);
	for (int i=1;i<=m;i++){
		int x;
		scanf("%d",&x);
		if (x==1) t.set(0,1,1,3);
		else t=t*power(r,x-cnt-1)*R;
		cnt=x;
	}
	t=t*power(r,n-cnt);
	printf("%d",t.a[0][0]);
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

num = int(input())
line =  lambda x: [int(i) for i in input().split(' ')]
a = line(1)
b = line(1)

masume = {}
for i in range(num):
    masume[(i, 0)] = a[i]
    masume[(i, 1)] = b[i]
    



def change(index, masume):
    return masume[(index+1, 0)] - masume[(index, 1)]

first = sum([masume[(0, 0)]] + [masume[(i, 1)] for i in range(num)])

maximum = first
current = first
for i in range(num-1):
    current +=  + change(i, masume)
    maximum = max(maximum, current)
print(maximum)

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

#define NT 26
#define ND 365

#define MAX(X,Y) (((X)>(Y))?(X):(Y))
#define MIN(X,Y) (((X)<(Y))?(X):(Y))

typedef long long ll;

int D, c[NT], s[ND][NT], last[ND][NT];

vector <int> greedy (void) {
	vector <int> retarr;
	ll satisfication = 0;
	for (int d=0; d<D; d++) {
		ll diff = 0, dtsum = 0;
		for (int typ=0; typ<NT; typ++) 
			dtsum += c[typ] * (d+1 - last[d][typ]);
		int ti = -1;
		for (int typ=0; typ<NT; typ++) {
			ll diff_t = s[d][typ] + c[typ] * (d+1 + last[d][typ]);
			diff_t -= dtsum;
			if (ti==-1) {
				diff = diff_t;
				ti = typ;
			} else {
				if (diff < diff_t) {
					diff = diff_t;
					ti = typ;
				}
			}
		}
		for (int afterd=d; afterd<D; afterd++) {
			last[afterd][ti] = d+1;
		}
		satisfication += diff;
		retarr.push_back (ti+1);
	}
	return retarr;
}

void disp (int x) {
	cout << x << endl;
}


int main () {
	cin >> D;
	for (int typ=0; typ<NT; typ++)
		cin >> c[typ];
	for (int d=0; d<D; d++) {
		for (int typ=0; typ<NT; typ++) {
			cin >> s[d][typ];
			last[d][typ] = 0;
		}
	}
	vector <int> v = greedy ();
	for_each (v.begin(), v.end(), disp);
	return 0;
}

Measured memory_bytes: 3692
import sys
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def search(arr):
    ret = [0] * 3000
    ret[0] = 1
    for num in arr:
        tmp = copy.copy(ret)
        for i in range(2700):
            tmp[i + num] += ret[i]
        ret = tmp
    return ret

def solve():
    n, k = getList()
    nums = getList()
    pos = []
    neg = []
    zero = 0
    for num in nums:
        if num == k:
            zero += 1
        if num < k:
            neg.append(k - num)
        if num > k:
            pos.append(num - k)

    posarr = search(pos)
    negarr = search(neg)

    ans = 0
    for i in range(2800):
        ans += posarr[i] * negarr[i]
    # print(posarr)
    # print(negarr)
    print(ans * pow(2, zero) - 1)

def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()







Measured memory_bytes: 71664
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#define MOD 1000000007
using namespace std;

int main()
{
	int i;
	int ans1, ans2;
	string s;
	cin >> s;
	ans1 = -2;
	ans2 = -2;
	for (i = 0; i < (int)s.length() - 2; i++){
		if (s[i] == s[i + 1] || s[i] == s[i + 2]){
			ans1 = i;
			break;
		}
	}
	if (s[s.length() - 2] == s[s.length() - 1]){
		ans1 = s.length() - 2;
		ans2 = s.length() - 1;
	}
	if (ans1 != -2&&ans2==-2){
		if (s[ans1] == s[ans1 + 1]){
			ans2 = ans1 + 1;
		}
		else if (s[ans1] == s[ans1 + 2]){
			ans2 = ans1 + 2;
		}
	}
	cout << ans1+1 << " " << ans2+1 << endl;


	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int time = scan.nextInt();
		for(int i = 0; i < time; i++){
			boolean judge = true;
			int max1 = 0;
			int max2 = 0;
			int array[] = new int[10];
			for(int j = 0; j < 10; j++){
				array[j] = scan.nextInt();
			}
			for(int j = 0; j < 10; j++){
				if(max1 < array[j])
					max1 = array[j];
				else if(max2 < array[j])
					max2 = array[j];
				else judge = false;
			}
			if(judge)
				System.out.println("YES");
			else
				System.out.println("NO");
		}
	}
}

Measured memory_bytes: 25924
//
// Created by watemus on 02.05.2020.
//

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

using namespace std;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ff first
#define ss second

using ll = long long;
using ld = long double;
#define int ll

constexpr ll INFL = 1'000'000'000'000'000'228;
constexpr int INFI = 1'000'000'228;

#ifdef LOCAL
#else
#endif

void run() {
    int n, m, q;
    cin >> n >> m >> q;
    vector<int> d(q), a(q), b(q), c(q);
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    vector<int> cur = {1};
    int ans = 0;
    auto gen = [&](const auto &gen) {
        if (cur.size() - 1 == n) {
            int cans = 0;
            for (int i = 0; i < q; i++) {
                if (cur[b[i]] - cur[a[i]] == c[i]) cans += d[i];
            }
            ans = max(cans, ans);
            return;
        }
        for (int i = cur.back(); i <= m; i++) {
            cur.push_back(i);
            gen(gen);
            cur.pop_back();
        }
    };
    gen(gen);
    cout << ans << '\n';
}

signed main() {
#ifdef LOCAL
    std::freopen("input.txt", "r", stdin);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
    int t = 1;
//    cin >> t;
    while (t--) {
        run();
    }
    return 0;
}

Measured memory_bytes: 3612