akhauriyash/Code-Regression huggingface dataset:
N = int(input())
a = list(map(int, input().split()))

x = [0] * (N+1)

for i in range(1, N+1):
  x[i] = x[i-1] + a[i-1]

suma = x[N]
y = [suma] * (N+1)
for i in range(1, N+1):
  y[i] = y[i-1] - a[i-1]
  
ans = sum([abs(i) for i in a])
for i in range(1, N):
  ans = min(ans, abs(x[i]-y[i]))
  
print(ans)

Measured memory_bytes: 33640
#include <bits/stdc++.h>
using namespace std;
#define maxN 1000001
#define mod 1000000007
#define maxLL 1000000000000000000
#define PI 3.14159265358979323846264338327950L
typedef long long ll;

bool compared(int a,int b){
	return a < b;
}

int cmp(const void *a,const void *b){
	return(*(int*)b - *(int*)a);
}

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

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


Measured memory_bytes: 3596
#include<iostream>

using namespace std;

int max(int *p,int n){
	int i, count=0;
	for (i = 0; i < n-1; i++){
		if (p[i] < p[i + 1]){
			count++;
		}
	}
	if (count == n - 1){
		return 1;
	}
	else{
		return 0;
	}
}

int main(void){
	int N;
	int i,j,k;
	int p[50];
	int tmp,success=0;

	cin >> N;

	for (i = 0; i < N; i++){
		cin >> p[i];
	}
	k = max(p, N);
	if (k == 1){
		cout << "YES" << endl;
		return 0;
	}
	else{
		for (i = 0; i < N - 1; i++){
			for (j = i+1; j <= N - 1; j++){
				tmp = p[i];
				p[i] = p[j];
				p[j] = tmp;
				k = max(p, N);
				if (k == 1) success = 1;

				tmp = p[i];
				p[i] = p[j];
				p[j] = tmp;

			}
		}
	}
		
	if (success){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
	return 0;
}

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

using namespace std;

unordered_map<int, vector<int> >g;
unordered_map<int,bool>seen;
unordered_map<int,int>cmp;
stack<int>ts;

void dfs(int s, int c){
    seen[s] = 1;
    cmp[s] = c;
    for(auto u:g[s]){
        if(!seen[u])
            dfs(u, c);
    }
    if(c==-1) ts.push(s);
}

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

    int n,m;
    cin>>n>>m;
    int a[m], b[m];

    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        g[b[i]].push_back(a[i]);
    }

    for(int i=0;i<n;i++){
        if(!seen[i])
            dfs(i, -1);
    }

    g.clear();
    seen.clear();
    int cc = 0;

    for(int i=0;i<m;i++){
        g[a[i]].push_back(b[i]);
    }

    while(!ts.empty()){
        if(!seen[ts.top()])
            dfs(ts.top(), cc++);
        ts.pop();
    }

    seen.clear();
    g.clear();

    int q,x,y; cin>>q;
    while(q--){
        cin>>x>>y;
        cout<< (cmp[x]==cmp[y]) << '\n';
    }
}



Measured memory_bytes: 5560
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] a = new int[n + 1];
		for(int i = 1; i <= n; i++) {
			a[i] = sc.nextInt();
		}

		int[] b = new int[n + 1];
		int index = n / 2 + 1;
		boolean add;
		if(n % 2 == 0) {
			add = false;
		} else {
			add = true;
		}

		for(int i = 1; i <= n; i++) {
			b[index] = a[i];
			if(add) {
				index += i;
				add = false;
			}
			else {
				index -= i;
				add = true;
			}
		}

		for(int i = 1; i <= n; i++) {
			System.out.print(b[i] + " ");
		}
		System.out.println();
	}
}


Measured memory_bytes: 94664
#include<stdio.h>
#include<stdbool.h>
#define MAX 100

typedef struct card{
  char suit,value;
}Card;

void bubble(Card *,int);
void selection(Card *,int);
void print(Card *,int);
bool isStable(Card *,Card *,int);

void bubble(Card A[], int N)
{
  int i,j;
  Card t;
 for(i=0;i<N;i++){
   for(j=N-1;j>=i+1;j--){
     if(A[j].value<A[j-1].value){
       t= A[j];
       A[j]=A[j-1];
       A[j-1]=t;
     }
   }
  }
}

void selection(Card A[], int N)
{
  int i, j, minj;
  Card t;
  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(A[j].value<A[minj].value)
	minj=j;
    }
    t=A[i];
    A[i]=A[minj];
    A[minj]=t;
  }
}

void print(Card A[],int N)
{
  int i;
  for(i=0;i<N;i++){
    if(i>0)
      printf(" ");
    printf("%c%c",A[i].suit,A[i].value);
  }
  printf("\n");
}

bool isStable(Card C1[],Card C2[], int N){
  int i;
  for(i=0;i<N;i++){
    if(C1[i].suit != C2[i].suit)
      return false;
  }
  return true;
}



int main(){
 Card C1[MAX],C2[MAX];
  int i, N;
  char A[2],ch;
  
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%c%c%c",&ch,&C1[i].suit,&C1[i].value);
    /*scanf("%s",A);
    C1[i].suit=A[0];
    C2[i].value=A[1];
    */
  }

  /*
  printf("C1.suit: ");
  for(i=0;i<N;i++)
    printf("%c ", C1[i].suit);
  printf("\n");
  printf("C1.value: ");
  for(i=0;i<N;i++)
    printf("%c ", C1[i].value);
  printf("\n");
  */
  
  for (i=0;i<N;i++)
    C2[i]=C1[i];
  
  bubble(C1,N);
  selection(C2,N);
  
  print(C1,N);
  printf("Stable\n");
  print(C2,N);
  if(isStable(C1,C2,N))
    printf("Stable\n");
  else printf("Not stable\n");
  
  return 0;

}
    



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define N 100005
#define MXN 200005
short dp[105][105][105][105];
int sum[105][105];
pii p;
int h,w;
int get(int a,int b,int c,int d){
   // printf("%d %d %d %d\n",a,b,c,d);
    if(a>c||b>d)return 0;
    return sum[c][d]+sum[a-1][b-1]-sum[a-1][d]-sum[c][b-1];
}
int DP(int a,int b,int c,int d){
    if(dp[a][b][c][d]!=-1)return dp[a][b][c][d];
    if(p.x<a||p.x>c||p.y<b||p.y>d)return 0;
  //  printf("%d %d %d %d\n",a,b,c,d);
    dp[a][b][c][d]=max((int)dp[a][b][c][d],DP(a+1,b,c,d)+get(max(a,c-p.x+1),max(b,d-p.y+1),min(a,h-(p.x-a-1)),min(d,w-(p.y-b))));
    dp[a][b][c][d]=max((int)dp[a][b][c][d],DP(a,b,c-1,d)+get(max(c,c-1-p.x+1),max(b,d-p.y+1),min(c,h-(p.x-a)),min(d,w-(p.y-b))));
    dp[a][b][c][d]=max((int)dp[a][b][c][d],DP(a,b+1,c,d)+get(max(a,c-p.x+1),max(b,d-p.y+1),min(c,h-(p.x-a)),min(b,w-(p.y-b-1))));
    dp[a][b][c][d]=max((int)dp[a][b][c][d],DP(a,b,c,d-1)+get(max(a,c-p.x+1),max(d,d-1-p.y+1),min(c,h-(p.x-a)),min(d,w-(p.y-b))));
    return dp[a][b][c][d];
}
int main(){
 //   int h,w;
    scanf("%d %d",&h,&w);
    char c[105][105];
    MEMS(dp);
    for(int i=1;i<=h;i++){
        scanf("%s",c[i]+1);
        for(int j=1;j<=w;j++){
            if(c[i][j]=='o')sum[i][j]++;
            if(c[i][j]=='E')dp[i][j][i][j]=0,p=mp(i,j);
            sum[i][j]+=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
        }
    }
    printf("%d\n",DP(1,1,h,w));
}


Measured memory_bytes: 237824
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		sc.nextLine();
		String s = sc.next();

		int count = 0;
		for(int i=0;i<s.length()-2;i++) {
			if(s.charAt(i) == 'A' && s.charAt(i+1) == 'B' && s.charAt(i+2) == 'C') {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 23764
import java.util.*;

public class Main {

    static class UnionFind {
        int[] size;
        int[] id;

        public UnionFind(int n) {
            size = new int[n];
            id = new int[n];

            for (int i = 0; i < n; ++i) {
                size[i] = 1;
                id[i] = i;
            }
        }

        void unify(int p, int q) {
            int root1 = find(p);
            int root2 = find(q);

            if (size[root1] > size[root2]) {
                size[root1] += size[root2];
                id[root2] = root1;
            } else {
                size[root2] += size[root1];
                id[root1] = root2;
            }
        }

        int find(int p) {
            int root = p;
            while (root != id[root]) root = id[root];
            while (p != root) {
                int next = id[p];
                id[p] = root;
                p = next;
            }
            return root;
        }

        boolean connected(int p, int q) {
            return find(p) == find(q);
        }
    }

    static class Edge {
        int from, to;

        public Edge(int from, int to) {
            this.from = from;
            this.to = to;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        List<Edge> edges = new ArrayList<>();
        for (int i = 0; i < M; ++i) {
            int x = Integer.parseInt(sc.next()) - 1;
            int y = Integer.parseInt(sc.next()) - 1;
            edges.add(new Edge(x, y));
        }

        int res = 0;
        for (int i = 0; i < M; ++i) {
            UnionFind uf = new UnionFind(N);
            for (int j = 0; j < M; ++j) {
                if (i == j) continue;
                Edge edge = edges.get(j);
                uf.unify(edge.from, edge.to);
            }
            Edge edge = edges.get(i);
            if (!uf.connected(edge.from, edge.to)) ++res;
        }

        System.out.println(res);
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define ll long long
#define db double
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define A first
#define B second
#define lowbit(p) (p&(-p))
using namespace std;
void read(int &x){
	x=0; char c=getchar(); int p=1;
	for (;c<48;c=getchar())if (c=='-')p=-1;
	for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=p;
}
void read(ll &x){
	x=0; char c=getchar(); int p=1;
	for (;c<48;c=getchar())if (c=='-')p=-1;
	for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=p;
}
void Min(int &x,int y){
	if (x>y)x=y;
}
void Min(ll &x,ll y){
	if (x>y)x=y;
}
void Max(int &x,int y){
	if (x<y)x=y;
}
void Max(ll &x,ll y){
	if (x<y)x=y;
}
#define M 200005
set<int>q[M];
int main(){
//	freopen("1.in","r",stdin);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int h,w,n,x,y,res;
	read(h); read(w); read(n);
	for (int i=1;i<=n;i++){
		read(x); read(y);
		q[x].insert(y);
	}
	int tmp=1;
	for (int i=1;i<h;i++){
		if (q[i+1].size()&&*q[i+1].begin()<=tmp){
			printf("%d\n",i);
			return 0;
		}
		else{
			if (!q[i+1].count(tmp+1))tmp++;
		}
	}
	printf("%d\n",h);
	return 0;
}

Measured memory_bytes: 18944
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;

const int MAX_V=10001;
const int INF=0x3f3f3f3f;
int mincost[MAX_V];
int dist[MAX_V];
struct edge{
    int to, dist, cost;
    edge(){to=dist=cost=0;}
    edge(int tt, int dd, int cc){
        to=tt; dist=dd; cost=cc;
    }
    bool operator < (const edge& b) const {
        return dist>b.dist;
    }
};

int main(){
    int N,M;
    while((cin>>N>>M) && N){
        vector<edge> G[N+1];
        int u, v, d, c;
        for(int i=0; i<M; i++){
            scanf("%d%d%d%d", &u, &v, &d, &c);
            G[u].push_back(edge(v, d, c));
            G[v].push_back(edge(u, d, c));
        }//cin
        memset(mincost, 0x3f, sizeof(mincost));
        memset(dist, 0x3f, sizeof(dist));
        dist[1]=mincost[1]=0;
        priority_queue<edge> que;
        que.push(edge(1,0,0));
        while(!que.empty()){
            edge cur=que.top(); que.pop();
            u=cur.to; d=cur.dist;
			if(d>dist[u]) continue; 
            for(int i=0; i<G[u].size(); i++){
                v=G[u][i].to;
                int d2=d+G[u][i].dist;
                c=G[u][i].cost;
                if(d2<dist[v] || (d2==dist[v]&&c<mincost[v])){
                	dist[v]=d2;
                	mincost[v]=c;
                    que.push(edge(v, d2, c));
                }
            }
        }
        int res=0;
        for(int i=1; i<=N; i++) res+=mincost[i];
        cout<<res<<endl;
    }//while
}


Measured memory_bytes: 4376
N, A, B = map(int, input().split())
s = input()
a = 0
b = 0
ans = []

for i in range(N):
    if s[i] == 'a':
        if a < A:
            ans.append('Yes')
            a += 1
        elif b < B:
            ans.append('Yes')
            b += 1
        else:
            ans.append('No')
    elif s[i] == 'b':
        if b < B:
            ans.append('Yes')
            b += 1
        else:
            ans.append('No')
    else:
        ans.append('No')

print(*ans, sep='\n')

Measured memory_bytes: 6344
import sys
import collections as col
import numpy as np
MOD = 1000000007
def input():
    return sys.stdin.readline().rstrip()
def main():
    n, k = [int(e) for e in input().split()]
    adj = [[] for _ in range(n+1)]
    for _ in range(n-1):
        u, v = [int(e) for e in input().split()]
        adj[u].append(v)
        adj[v].append(u)
    ans = 1
    queue = col.deque([(1, 0, k)])
    while len(queue) > 0:
        u, p, k_ = queue.popleft()
        ans = (ans * k_) % MOD
        if p == 0:
            k_next = k - 1
        else:
            k_next = k - 2
        for v in adj[u]:
            if v == p:
                continue
            queue.append((v, u, k_next))
            k_next -= 1
    print(ans)
main()

Measured memory_bytes: 41976
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000000
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  int N;
  cin >> N;
  vector<int> P(N), Q(N);
  rep(i, N){
    cin >> P.at(i);
  }
  rep(i, N){
    cin >> Q.at(i);
  }
  vector<int> R(N);
  rep(i, N){
    R.at(i) = i+1;
  }
  int a = 0;
  int b = 0;
  int c = 0;
  bool mtP = true;
  bool mtQ = true;
  sort(all(R));
  do {
    rep(i, N){
      if(mtP){
        if(P.at(i) != R.at(i)){
          mtP = false;
        }
      }
      if(mtQ){
        if(Q.at(i) != R.at(i)){
          mtQ = false;
        }
      }
    }
    if(mtP){
      a = c;
    }
    if(mtQ){
      b = c;
    }
    mtP = true;
    mtQ = true;
    c++;
  } while (next_permutation(all(R)));
  cout << abs(a-b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};



int main(void){
    ll K;
    cin >> K;
    ll x,y;
    x = (K+49) / 50;
    y = K % 50;
    
    vector<ll> ans(50);
    for(int i = 0; i < 50; i++){
        ans[i] = i;
    }
    for(int i = 0; i < 50; i++){
        ans[i] += x;
    }
    if(y != 0){
        ans[50-y-1]--;
    }
    
    cout << 50 << endl;
    for(int i = 0; i < 50; i++){
        cout << ans[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    int n,m;
    cin >> n >> m;
    vector <vector <int>> s(m);
    rep (i,0,m) {
        int k;
        cin >> k;
        rep(j,0,k) {
            int a;
            cin >> a;
            a--;
            s[i].push_back(a);
        }

    }
    vector <int> p(m);
    rep (i,0,m) {
        cin >> p[i];
    }
    ll ans = 0;
    for (int bit = 0; bit < (1<< n); bit++) {
        bool flag = true;
        for(int i = 0; i <m; i++) {
            int count = 0;
            for (auto v : s[i]) {
                if (bit & (1 << v)) count++;
            }
            if (count % 2 != p[i]) flag = false;
        }
        if (flag) ans++;

    }
    cout << ans << endl;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i<n;i++)
using ll = long long;
using P = pair<ll,ll>;
 
int main() {
  ll n;cin>>n;
  vector<ll> v(n);
  rep(i,n) cin>>v.at(i);
  ll sumb = 0;
  rep(i,n){
    sumb+=v.at(i);
  }
  sumb -= v.at(0);
  ll suma=v.at(0),ans = 1e10;
  if (n==2){
    cout << abs(v.at(0) - v.at(1)) << endl;
    return 0;
  }
  for (int i = 1;i<n-1;i++){
    suma+=v.at(i);
    sumb-=v.at(i);
    ans = min(ans,abs(suma-sumb));
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int H=stdIn.nextInt();
		int W=stdIn.nextInt();
		char S[][]=new char[H][W];
		int key[][]=new int[H][W];
		String a="";
		int z=0,y=0,x=0,max=0;
		while(z<H){
			a=stdIn.next();
			while(y<W){
				S[z][y]=a.charAt(y);
				if(S[z][y]=='#')
					x=-1;
				x++;
				key[z][y]=x;
				y++;
			}y=0;x=0;
			z++;
		}z=0;y=W-1;
		while(z<H){
			while(y>=0){
				if(S[z][y]=='#')
					x=-1;
				x++;
				key[z][y]+=x-1;
				y--;
			}y=W-1;x=0;
			z++;
		}z=0;y=0;
		while(z<W){
			while(y<H){
				if(S[y][z]=='#')
					x=-1;
				x++;
				key[y][z]+=x;
				y++;
			}y=0;x=0;
			z++;
		}z=0;y=H-1;
		while(z<W){
			while(y>=0){
				if(S[y][z]=='#')
					x=-1;
				x++;
				key[y][z]+=x-1;
				if(max<key[y][z])
					max=key[y][z];
				y--;
			}y=H-1;x=0;
			z++;
		}z=0;
		System.out.println(max-1);
	}
}

Measured memory_bytes: 67768
use std::io;
use std::str::FromStr;
use std::collections::VecDeque;

type Point = (usize, usize);

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_int_tuple() -> (usize, usize) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<usize> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn push_queue(x: usize, y: usize, queue: &mut VecDeque<Point>, count: &mut Vec<Vec<usize>>, field: &mut Vec<Vec<char>>, h: &usize, w: &usize) {
    if x > 0 && field[y][x-1] == '.' {        
        queue.push_back((x - 1, y));
        count[y][x-1] = count[y][x] + 1;
        field[y][x-1] = '#';
    }
    if x < w - 1 && field[y][x+1] == '.' {
        queue.push_back((x + 1, y));
        count[y][x+1] = count[y][x] + 1;
        field[y][x+1] = '#';
    }
    if y > 0 && field[y-1][x] == '.' {
        queue.push_back((x, y - 1));
        count[y-1][x] = count[y][x] + 1;
        field[y-1][x] = '#';
    }
    if y < h - 1 && field[y+1][x] == '.' {
        queue.push_back((x, y + 1));
        count[y+1][x] = count[y][x] + 1;
        field[y+1][x] = '#';
    }
}

fn main() {
    let (h, w) = input_int_tuple();
    let mut field: Vec<Vec<char>> = Vec::new();

    for _ in 0..h {
        let line: String = input();
        let line: Vec<char> = line.chars().collect();
        field.push(line);
    }

    let mut black = 0usize;
    for line in &field {
        for c in line {
            if *c == '#' {
                black += 1;
            }
        }
    }

    let mut count: Vec<Vec<usize>> = Vec::new();
    for _ in 0..h {
        count.push(vec![0; w]);
    }
    let mut queue: VecDeque<Point> = VecDeque::new();
    field[0][0] = '#';
    push_queue(0, 0, &mut queue, &mut count, &mut field, &h, &w);
    let mut way: i32 = -1;
    while queue.len() > 0 {
        // println!("{:?}", queue);
        let current_point: Point = queue.pop_front().unwrap();
        if current_point == (w-1, h-1) {
            way = count[current_point.1][current_point.0] as i32;
            break;
        }
        field[current_point.1][current_point.0] = '#';
        push_queue(current_point.0, current_point.1, &mut queue, &mut count, &mut field, &h, &w);
    }
    if way == -1 {
        println!("-1");
        return;
    }
    
    println!("{}", h * w - black - way as usize - 1);
}


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

using namespace std;
int main(void) {
	int n, k, h, sum = 0; cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		cin >> h;
		if (h >= k)sum++;
	}
	cout << sum;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
  int A,B;
  char op[5];
  scanf("%d %s %d",&A,op,&B);
  if(strcmp(op,"+")==0){
    printf("%d",A+B);
  }else if(strcmp(op,"-")==0){
    printf("%d",A-B);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main(){
    Hello
    int n, m, c;
    cin >> n >> m >> c;
    int b[m], a[n][m];
    for(int i = 0; i < m; i++) cin >> b[i];
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            cin >> a[i][j];
    int ans = 0;
    for(int i = 0; i < n; i++){
        int cur = c;
        for(int j = 0; j < m; j++)
            cur += a[i][j] * b[j];
        if(cur > 0) ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3704
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=3.1415926535897932384626433832795;
const ll INF = 1LL<<62;
const ll MINF = -1LL<<62;

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


int main() {
	IO;
	ll n;
	cin>>n;
	ll res=0;
	for(int i=1;i<=n;++i) {
		if(i%3!=0 && i%5!=0) res+=i;
	}
	cout<<res<<"\n";
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define SP << " " <<
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

#define int long long
int MOD = 1e9 + 7;

int addmod(int a, int b) {
  if(a + b >= MOD) {
    return a - MOD + b;
  } else {
    return a + b;
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  reverse(all(S));
  int sz = S.size();
  vector<vector<int>> dp(sz, vector<int>(13, 0));
  vector<int> keta(sz);
  keta[1] = 10;
  FOR(i, 2, sz) {
    keta[i] = (keta[i - 1] * 10) % 13;
  }

  if(S[0] == '?') {
    REP(i, 10) { dp[0][i] = 1; }
  } else {
    dp[0][S[0] - '0'] = 1;
  }

  FOR(i, 1, sz) {
    if(S[i] == '?') {
      REP(n, 10) {
        REP(k, 13) {
          dp[i][(keta[i] * n + k) % 13] =
              addmod(dp[i][(keta[i] * n + k) % 13], dp[i - 1][k]);
        }
      }
    } else {
      int n = S[i] - '0';
      REP(k, 13) {
        dp[i][(keta[i] * n + k) % 13] =
            addmod(dp[i][(keta[i] * n + k) % 13], dp[i - 1][k]);
      }
    }
  }
  // REP(i, sz) {
  //   REP(j, 13) { cout << dp[i][j] SP endl; }
  //   cout << endl;
  // }
  cout << dp[sz - 1][5] << endl;
  return 0;
}

Measured memory_bytes: 14416
#include <iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define pb push_back
#define fi first
#define se second
#define sz(x)  x.size()
#define cl(x)  x.clear()
#define all(x)  x.begin() , x.end()
#define rep(i , x , n)  for(ll i = x ; i <= n ; i ++)
#define per(i , n , x)  for(int i = n ; i >= x ; i --)
#define mem(x)  memset(x , 0 , sizeof(x))
#define mem_1(x)  memset(x , -1 , sizeof(x))
#define mem_inf(x)  memset(x , 0x3f3f3f3f , sizeof(x))
#define debug(x)  cout << '*' << x << '\n'
#define ddebug(x , y)  cout << '*' << x << ' ' << y << '\n'
using namespace std ;
typedef long long ll ;
typedef pair<int , int> pii ;
typedef pair<ll , ll> pll ;
const ll mod =  1e9+7;
const ll maxn = 1e5 + 10 ;
const int inf = 0x3f3f3f3f ;
const double eps = 1e-8 ;

ll ans[5000004];
int main(){
    rep(i,1,105)
    rep(j,1,105)
    rep(k,1,105)
    ans[i*i+j*j+k*k+i*j+i*k+j*k]++;
    int n;
    cin>>n;
    rep(i,1,n)
    cout<<ans[i]<<endl;

}


Measured memory_bytes: 3672
n = int(input())
b = list(map(int, input().split()))

a = [[] for i in range(n)]

for i in range(len(b)):
  a[i].append(b[i])
  a[i+1].append(b[i])

ans = 0
for i in a:
  ans += min(i)

print(ans)

Measured memory_bytes: 3064
import static java.lang.System.out;
public class Main {
     public static void main(String[] args){
          String str = new java.util.Scanner(System.in).nextLine();
          String[] tmp = str.split(" ");
          int a = Integer.parseInt(tmp[0]);
          int b = Integer.parseInt(tmp[1]);
          
          int area = a * b;
          int circu = (a + b) * 2;
          out.print(area + " ");                                                                                                           
          out.println(circu);
     }
}

Measured memory_bytes: 26296
from operator import mul
from functools import reduce
import sys
x,y = map(float,input().split())
m = (2*x - y)/3
n = (y - m)/2
if not (m.is_integer() and n.is_integer()):
  print(0)
  sys.exit()
if n < 0 or m < 0:
  print(0)
  sys.exit()
m = int(m)
n = int(n)
mod = 10**9 + 7
def cmb(h, r):
    if h - r < r: r = h - r
    if r == 0: return 1
    if r == 1: return h
    r = int(r)

    humerator = [h - r + k + 1 for k in range(r)]
    dehominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = dehominator[p - 1]
        if pivot > 1:
            offset = (h - r) % p
            for k in range(p-1,r,p):
                k = int(k)
                offset = int(offset)
                humerator[k - offset] /= pivot
                dehominator[k] /= pivot

    result = 1
    for k in range(r):
        if humerator[k] > 1:
            result *= int(humerator[k])

    return result
if (x + y) % 3 != 0:
  print(0)
else:
  print(cmb(n + m,n)%mod)

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int sign(int x) { return (x > 0) - (x < 0); }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const deque<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const set<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

signed main() {
    string S;
    cin >> S;
    if (S == "RSR") { fin(1); }
    cout << count(all(S), 'R') << endl;
}


Measured memory_bytes: 3596
import Foundation
var r = Int(readLine()!)!
var ac = 0
var wa = 0
var tle = 0
var re = 0
for _ in 0 ..< r {
   let arr=readLine()!
    if arr == "AC" {
        ac += 1
    }
    if arr == "WA" {
           wa += 1
    }
    if arr == "TLE" {
           tle += 1
       }
    if arr == "RE" {
           re += 1
       }
}
print("AC x "+String(ac))
print("WA x "+String(wa))
print("TLE x "+String(tle))
print("RE x "+String(re))

Measured memory_bytes: 13116
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x)
{
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=getchar();}
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=310,M=N*N,mod=998244353;
void Add(int &x,int y) { x=(x+y)%mod; }
int Pow(int x,int y) {
	int res=1;
	while(y) {
		if(y&1) res=res*(ll)x%mod;
		x=x*(ll)x%mod,y>>=1;
	}
	return res;
}
int dp[N][M],n,m;
int f[N][M];
int a[N];
int main() {
	rd(n);
	for(int i=1;i<=n;++i) rd(a[i]),m+=a[i];
	dp[0][0]=1;
	for(int i=1;i<=n;++i)
		for(int j=0;j<=m;++j) {
			dp[i][j]=dp[i-1][j];
			if(j>=a[i]) Add(dp[i][j],dp[i-1][j-a[i]]*2ll%mod);
		}
//	for(int i=0;i<=m;++i) cout<<dp[n][i]<<' '; cout<<endl;
	int ans=Pow(3,n);
	for(int j=0;j<=m;++j) {
		if(j<=m-j) ans=(ans-dp[n][j]*3ll)%mod;
	}
	if(m%2==0) {
		f[0][0]=1;
		for(int i=1;i<=n;++i)
			for(int j=0;j<=m;++j) {
				f[i][j]=f[i-1][j];
				if(j>=a[i]) Add(f[i][j],f[i-1][j-a[i]]);
			}
		ans=(ans+3ll*f[n][m/2])%mod;
	}
	printf("%d\n",(ans+mod)%mod);
	return 0;
}

Measured memory_bytes: 229120
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int b[30];
int main()
{
  int n, m, c, a, ans = 0;
  scanf("%d%d%d", &n, &m, &c);
  for (int i = 0; i < m; i++)
  {
    scanf("%d", &b[i]);
  }
  while (n)
  {
    int tmp = 0;
    for (int i = 0; i < m; i++)
    {
      scanf("%d", &a);
      tmp += a * b[i];
    }
    if (tmp + c > 0)
      ans++;
    n--;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------

int main(void) {
  int n, k;
  cin >> n >> k;

  priority_queue<int, vector<int> ,greater<int>> q;

  vecb ketaok(10, true);
  rep(i,k){
    int tmp;
    cin >> tmp;
    ketaok[tmp]=false;
  }
  rep(i,10){
    if(ketaok[i]) q.push(i);
  }

  bool ok=true;
  while(ok){
    int tmp=q.top();
    q.pop();
    if(tmp>=n){
      prt(tmp);
      return 0;
    }
    rep(i,10){
      if(ketaok[i] && tmp>0) q.push(tmp*10+i);
    }
    //prt(tmp);
  }
}


Measured memory_bytes: 640
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var arr = arrLong();
        var a = arr[0];
        var b = arr[1];
        var k = arr[2];
        if (k <= a) a -= k;
        else
        {
            b = Math.Max(b - (k - a), 0);
            a = 0;
        }
        Console.WriteLine(a + " " + b);
    }

    static int[] arrInt()
    {
        return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
    }

    static long[] arrLong()
    {
        return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray();
    }

    static string[] arrStr()
    {
        return Console.ReadLine().Split(' ').ToArray();
    }

}

Measured memory_bytes: 28176
// Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
int main()
{
   // freopen("a.txt","r",stdin);
    int n,a,b,c=1;
    cin>>n>>a>>b;
    for(int i=a;i<=b;i++)
    {
        if(i%n==0)
        {
            c=0;break;
        }
    }
    if(c==0)cout<<"OK\n";
    else cout<<"NG\n";

}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

void add(ll& a, ll b){a = (a+b) % MOD;}

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

const int prime[25] = {
    2, 3, 5, 7, 11,
    13, 17, 19, 23, 29,
    31, 37, 41, 43, 47,
    53, 59, 61, 67, 71,
    73, 79, 83, 89, 97};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;cin>>N;
    int cnt[25];
    fill(cnt,cnt+25,0);
    for(int n=1;n<=N;n++){
        int m=n;
        for(int i=0;i<25;i++){
            while(m%prime[i]==0){
                ++cnt[i];
                m/=prime[i];
            }
        }
    }

    int ans=0;
    for(int p=0;p<25;p++){
        if(cnt[p]>=74) ++ans;
    }

    for(int p=0;p<25;p++){
        for(int q=0;q<25;q++){
            if(p==q)continue;
            if(cnt[p]>=4&&cnt[q]>=14)++ans;
            if(cnt[p]>=2&&cnt[q]>=24)++ans;
        }
    }

    for(int p=0;p<25;p++){
        for(int q=0;q<25;q++){
            for(int r=q+1;r<25;++r){
                if(p==q||p==r)continue;
                if(cnt[p]>=2&&cnt[q]>=4&&cnt[r]>=4)++ans;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

int main(){
  int M,N;
  while(~scanf("%d %d",&M,&N)){

    int max_score = 0;
    for(int ppl_idx=0;ppl_idx<M;ppl_idx++){
      int sum = 0;
      for(int problem_idx =0;problem_idx<N;problem_idx++){
	int flag;
	scanf("%d",&flag);
	if(flag == 1) sum++;
      }
      max_score = max(sum,max_score);
    }

    printf("%d\n",max_score);
  }
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	ll n, k;
	cin >> n >> k;
	ll a = n/k;
	ll b = 0;
	if( k % 2 == 0 && k/2 <= n ) b = ( n - k/2 ) / k + 1;
	cout << a*a*a + b*b*b << endl; 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define F first
#define S second
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()
signed main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a)cout<<k<<endl;
    else if(k<=a+b)cout<<a<<endl;
    else if(a+b+c<=k)cout<<a-c<<endl;
    else cout<<a-(k-a-b)<<endl;
    return 0;
}


Measured memory_bytes: 3640
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <cassert>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <sstream>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, b, a) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

struct dpdata
{
    int a, b, c;

    int size()
    {
        return a;
    }
};

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

    string s, t;
    cin >> s >> t;

    vector dp(s.size() + 1, vector<dpdata>(t.size() + 1, {0, -1, -1}));
    // dp[i][0], dp[0][j] = "";
    FOR(i, 1, s.size())
    {
        FOR(j, 1, t.size())
        {
            dp[i][j] = dp[i - 1][j];
            if (dp[i][j].size() < dp[i][j - 1].size())
            {
                dp[i][j] = dp[i][j - 1];
            }
            if (s[i - 1] == t[j - 1] and dp[i][j].size() < dp[i - 1][j - 1].size() + 1)
            {
                dp[i][j] = {dp[i - 1][j - 1].size() + 1, i - 1, j - 1};
            }
        }
    }

    string ans;
    {
        auto [a, i, j] = dp[s.size()][t.size()];
        while (i != -1 and j != -1)
        {
            ans += s[i];
            auto [aa, ii, jj] = dp[i][j];
            a = aa;
            i = ii;
            j = jj;
        }
        reverse(ans.begin(), ans.end());
    }

    cout << ans << '\n';

    return 0;
}


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

int main() {
    long long int n;
    cin>>n;
    long long int ar[n],pre[n],suff[n],min=INT_MAX;
    for(int i=0;i<n;i++)
    cin>>ar[i];
    pre[0]=ar[0];
    suff[n-1]=ar[n-1];
    for(int i=1;i<n;i++)
    pre[i]=pre[i-1]+ar[i];
    for(int i=n-2;i>=0;i--)
    suff[i]=suff[i+1]+ar[i];
    for(int i=1;i<n;i++)
    {
        if(abs(pre[i-1]-suff[i])<min)
        min=abs(pre[i-1]-suff[i]);
    }
    cout<<min<<endl;
    
	return 0;
}

Measured memory_bytes: 4992
N = int(input())
ac,wa,tle,re = [0 for i in range(4)]
for i in range(N):
    val = input()
    if val == "AC":
        ac += 1
    elif val == "WA":
        wa += 1
    elif val == "TLE":
        tle += 1
    elif val == "RE":
        re += 1
    else:
        pass
print(f"AC x {ac}")
print(f"WA x {wa}")
print(f"TLE x {tle}")
print(f"RE x {re}")


Measured memory_bytes: 9196
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 
#include <math.h>
#include <bits/stdc++.h>
using namespace std;

using namespace std;
int main(){
    int n;std::cin >> n;
    std::cout << ((n==3||n==5||n==7)?"YES":"NO") << std::endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
mod = 10**9+7  # 出力の制限
R = N - K


def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

# a = cmb(n, r, mod)

for i in range(1, K + 1):
    print(cmb(R+1,i,mod)*cmb(K-1,i-1,mod)%mod)


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


int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    ll sum = 0;
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=n;++j)
        {
            for(int k=1;k<=n;++k)
            {
                sum+= __gcd(i,__gcd(j,k));
            }
        }
    }
    cout<<sum;
}


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

int main() 
{
    string S1, S2, S3;
    cin >> S1 >> S2 >> S3;
    if(S1[S1.size()-1] == S2[0] && S2[S2.size()-1] == S3[0]) 
        cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
const int INF = 1145141919;
 
int n, z, w;
int a[2005];
int dp[2][2005];
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> z >> w;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = n - 1; i >= 0; i--) {
        dp[0][i] = abs((i == 0 ? w : a[i]) - a[n]);
        dp[1][i] = abs((i == 0 ? z : a[i]) - a[n]);
        for (int j = i + 1; j < n; j++) {
            dp[0][i] = max(dp[0][i], dp[1][j]);
            dp[1][i] = min(dp[1][i], dp[0][j]);
        }
    }
    cout << dp[0][0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int A,B;
	cin >> A >> B;

	if (A == 1) {
		A = 14;
	}
	if (B == 1) {
		B = 14;
	}

	if (A<B) {
		cout << "Bob" << endl;
	}
	else if(A == B) {
		cout << "Draw" << endl;
	}
	else {
		cout << "Alice" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const long long mod = 1e9 + 7;
const int INF = 1 << 20;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main()
{
    int x,a;
    cin >> x >> a;
    if(x < a) cout << 0;
    else cout << 10;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int ab(int x){
    return max(x,-x);
}

int main(){
    fastIO;
    int n, s;
    cin >> n >> s;
    int x[n];
    ll p[n];
    deque<int> ff;
    for(int i = 0 ; i < n ; i ++ ){
        cin >> x[i] >> p[i];
        ff.push_back(i);
    }
    vector<int> order;
    int f1, f2;
    while(ff.size() > 1){
        f1 = ff.front();
        f2 = ff.back();
        if(p[f1] < p[f2]){
            order.push_back(f1);
            p[f2] += p[f1];
            ff.pop_front();
        }
        else{
            order.push_back(f2);
            p[f1] += p[f2];
            ff.pop_back();
        }
    }
    order.push_back(ff.back());
    reverse(order.begin(), order.end());
    int lf = s;
    int rf = s;
    ll res = 0;
    for(auto p : order){
        if(x[p] >= lf && x[p] <= rf){
            continue;
        }
        res += ab(s-x[p]);
        s = x[p];
        lf = min(lf, s);
        rf = max(rf, s);
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 2560
n = int(input())
w = list(map(int,input().split()))
s1 = w[0]
s2 = sum(w[1:])
mini = abs(s2-s1)
for i in range(1,n-1):
  s1 += w[i]
  s2 -= w[i]
  a = abs(s2-s1)
  if a < mini:
    mini = a
print(mini)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>

using namespace std;

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	
	if(a+b+c-max({a,b,c})==max({a,b,c})){
		cout<<"Yes"<<endl;
		}
	else{
		cout<<"No"<<endl;
		}
	
	}

Measured memory_bytes: 256
N = int(input())
ans = 0
p = [list(map(int, input().split())) for i in range(N)]


def dist(x, y):
    return ((p[x][0] - p[y][0]) ** 2 + (p[x][1] - p[y][1]) ** 2) ** 0.5


for i in range(N - 1):
    for j in range(i + 1, N):
        ans += dist(i, j) * 2 / N

print(ans)


Measured memory_bytes: 3060
"use strict";

const main = (input) => {
    const spi = input.split('\n');
    let [a,b,c] = spi[0].split(' ').map(e => Number(e));

    [b, a] = [a, b];
    [c, a] = [a, c];

    console.log(`${a} ${b} ${c}`);
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29508