akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int rec(string s, int l, int r) {
    if (s[l+1] != '[') {
        int x = stoi(s.substr(l+1,l-r-2));
        x = ceil(x/2.0);
        return x;
    }
    
    vector<int> t;
    int c = 0, tl, tr;
    for (int i = l; i < r; i++) {
        if (s[i] == '[') {
            c++;
            if (c == 2) tl = i;
        }
        else if (s[i] == ']') {
            c--;
            if (c == 1) {
                tr = i;
                t.push_back(rec(s,tl,tr+1));
            }
        }
    }
    int k = ceil(t.size()/2.0);
    sort(t.begin(), t.end());
    int sum = 0;
    for (int i = 0; i < k; i++) sum += t[i];
    
    return sum;
}

int main(void){
    int n;
    cin >> n;
    while (n--) {
        string s;
        cin >> s;
        cout << rec(s,0,s.size()) << endl;
    }
}

Measured memory_bytes: 3108
// Author : Abhisar Singhal
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <cctype>
#include <utility>   
#include <map>
#include <string>  
#include <climits> 
#include <set>
#include <string>    
#include <sstream>
#include <utility>   
#include <ctime>
#include <cassert>
#include <fstream>
#include <iomanip>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> II;
typedef vector<long long> VLL;
typedef vector<bool> VB;

#define SZ(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define MS(A) memset(A, 0, sizeof(A))
#define MSV(A,a) memset(A, a, sizeof(A))
#define MAX(a,b) ((a >= b) ? (a) : (b))
#define MIN(a,b) ((a >= b) ? (b) : (a))
#define ABS(a) (((a) > 0) ? (a) : (-a))
#define MP make_pair
#define X first
#define Y second
#define PB push_back
#define FOUND(A, x) (A.find(x) != A.end())
#define getcx getchar_unlocked
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12

#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))
#define clrbit(s, b) (s &= ~(1<<b))

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < n; i++)
#define REV(i, a, n) for(int i = a; i > n; i--)
#define FORALL(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define ALL(A) A.begin(), A.end()
#define LLA(A) A.rbegin(), A.rend()
//int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {1, 1, 1, 0, 0, -1, -1, -1}, dy[] = {1, 0, -1, 1, -1, 1, 0, -1};
inline void inp( int &n ) {
	n=0; int ch = getcx(); int sign = 1;
	while(ch < '0' || ch > '9') { if(ch == '-') sign=-1; ch = getcx(); }
	while(ch >= '0' && ch <= '9') { n = (n << 3) + (n << 1) + ch - '0', ch = getcx(); }
	n = n * sign;
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> A(n);
	REP (i, n) {
		cin >> A[i];
	}
	vector<int> ans(n);
	int l = 0, r = n - 1, p = n - 1;
	while (l <= r) {
		ans[l++] = A[p--];
		if (l <= r) {
			ans[r--] = A[p--];
		}
	}
	for (int i = 0; i < n; i++) {
		cout << ans[i] << " ";
	}
	cout << endl;
    return 0;
}


Measured memory_bytes: 3712
from sys import stdin

S = [int(x) for x in list(stdin.readline().rstrip())]

even = len(S) // 2
odd = len(S) // 2 + (len(S) % 2)

evens = 0
odds = 0

for i in S[1::2]:
    evens += i

for i in S[::2]:
    odds += i

print(min(even - evens + odds, odd - odds + evens))

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

int a, b;
bool sub(int n) {
  return n * 8 / 100 == a && n * 10 / 100 == b;
}

int main() {
  cin >> a >> b;
  for (int i = 0; i < 1000000; ++i) {
    if (sub(i)) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (){

	int n;
	scanf("%d", &n);
	
	long long int a1[n];
	long long int a2 = 1;
	long long int max = 1000000000000000000;
	long long int tot;
	
	for(int i = 0; i < n; i++){
		scanf("%lld", &a1[i]);	
	}
	for(int u = 0; u < n; u++){
		if(a1[u] == 0){
			printf("0 \n");
			return 0;
		}
	}
	for(int y = 0; y < n ; y++){
        if(a1[y]<=max/a2){    
        a2*= a1[y];    
        }	else{
        	printf("-1\n");
        	return 0;
        }
    }
	printf("%lld\n", a2);
	
	return 0;
}

Measured memory_bytes: 2460
#include <bits/stdc++.h>
#include<list>
#include<algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repj(a,b,c) for(a=b;a<c;a++)
#define repr for(i=n-1;i>=0;i--)
#define pii pair<ll,ll>
#define pll pair<ll, ll>
#define inf 100000001
const double pie  =3.141592653589793238463;
#define mod 1000000007
#define lb lower_bound
#define up upper_bound
#define rep1 for(i=1;i<=n;i++)
#define vr vector
#define POP(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define ef else if
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(),A.end());
#define REV(A) reverse(A.begin(), A.end());
#define lenth length()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n" 
const ll dx[4] = { -1, 1, 0, 0};
const ll dy[4] = {0, 0, -1, 1};
ll XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
ll YY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
#define precise(x) cout<<fixed<<setprecision(x)
#define t1(x)                cerr<<#x<<": "<<x<<endl
#define t2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define t4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define t5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define t6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
using namespace std;
void SieveOfEratosthenes(ll n) 
{ 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // for (ll p=2; p<=n; p++) 
       // if (prime[p]) 
          // cout << p << " "; 
} 

ll power(ll x, ll y) 
{ 
    ll res = 1; 
    while (y > 0) 
    { 
        if (y & 1) 
            res = res * x; 
        y = y >> 1; 
        x = x * x; 
    } 
    return res; 
}
int main()
{
    fastio
    ll t,i,j,k,l,m,n,a,x,b,y,z,c,h,d,e,p,o,nl,np,q,r;
    string s1,s2;
    cin>>s1>>s2;
    c=0;
    map<char,ll>mp;
    rep(i,0,s1.size())
    {
         if(s1[i]!=s2[i])
            c++;
    }

    cout<<c<<endl;
}

Measured memory_bytes: 3796
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_M = 12;

/* typedef */

typedef long long ll;

/* global variables */

ll n;
int k;
ll ns[MAX_M + 1], ts[MAX_M + 1];

/* subroutines */

/* main */

int main() {
  ns[0] = 0;
  ll t = 9;
  for (int m = 1; m <= MAX_M; m++, t *= 10) {
    ns[m] = ns[m - 1] + t * m;
    //printf("ns[%d] = %lld\n", m, ns[m]);
  }

  ts[0] = 0, ts[1] = 1;
  for (int m = 2; m <= MAX_M; m++) ts[m] = ts[m - 1] * 10;

  for (;;) {
    cin >> n >> k;
    if (n == 0) break;
    n--;
    
    int m;
    for (m = 1; m <= MAX_M && n >= ns[m]; m++);
    //printf("m=%d,n=%lld\n", m, n);

    stringstream ss;

    ll n0 = (n - ns[m - 1]) / m + ts[m];
    int i0 = (n - ns[m - 1]) % m;
    int len = 0;
    //printf("n0=%lld, m=%d, i0=%d\n", n0, m, i0);
    
    while (len < k + i0) {
      ss << n0;
      len += m;
      n0++;
      if (n0 >= ts[m] * 10) m++;
    }    
    cout << ss.str().substr(i0, k) << endl;
  }

  return 0;
}

Measured memory_bytes: 1232
N = int(input())
A = [list(map(int, input().split())) for _ in range(2)]

def cumsum_generator(X):
  y = X[0]
  yield y
  for x in X[1:]:
    y += x
    yield y

A = [[0] + list(cumsum_generator(A[i])) for i in range(2)]
print(max([A[0][j] + A[1][-1] - A[1][j - 1] for j in range(1, N + 1)]))


Measured memory_bytes: 3060
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	@SuppressWarnings("unchecked")
	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int k = scanner.nextInt();
		List<Pair>[] list = new List[n];
		for (int i = 0; i < n; i++)
			list[i] = new ArrayList<Pair>();
		while (m-- > 0) {
			int a = scanner.nextInt() - 1;
			int b = scanner.nextInt() - 1;
			int l = scanner.nextInt();
			list[a].add(new Pair(b, l));
			list[b].add(new Pair(a, l));
		}
		int[] dp = new int[n];
		Arrays.fill(dp, 1 << 25);
		PriorityQueue<Pair> pq = new PriorityQueue<Main.Pair>();
		for (int i = 0; i < k; i++) {
			int s = scanner.nextInt() - 1;
			dp[s] = 0;
			pq.offer(new Pair(0, s));
		}
		while (!pq.isEmpty()) {
			Pair pair = pq.poll();
			int f = pair.f;
			int s = pair.s;
			if (dp[s] < f)
				continue;
			for (Pair p : list[s]) {
				if (dp[p.f] <= f + p.s)
					continue;
				dp[p.f] = f + p.s;
				pq.offer(new Pair(f + p.s, p.f));
			}
		}
		int ans = 0;
		for (int i = 0; i < n; i++) {
			for (Pair p : list[i]) {
				int a = Math.max(dp[i], dp[p.f]);
				int b = a + (p.s - Math.abs(dp[i] - dp[p.f]) + 1) / 2;
				ans = Math.max(ans, b);
			}
		}
		System.out.println(ans);
	}

	class Pair implements Comparable<Pair> {
		int f, s;

		public Pair(int f, int s) {
			super();
			this.f = f;
			this.s = s;
		}

		@Override
		public String toString() {
			return "Pair [f=" + f + ", s=" + s + "]";
		}

		@Override
		public int compareTo(Pair o) {
			return f - o.f;
		}

	}
}

Measured memory_bytes: 109392
//#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<functional>
#include<vector>

#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

ll x, y;

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    cin >> x >> y;
    int ans = 0;
    while(x<=y)
    {
        ans++;
        x<<=1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include<iomanip>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

using namespace std;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  int n,m;
  int res=0;
  cin>>n>>m;
  typedef pair<int,int> P;
  vector<P> ba(m);
  rep(i,m)
  {
    int a,b;
    cin>>a>>b;
    ba[i]=make_pair(b,a);
  }
  sort(all(ba));
  int end=ba[0].first;
  res++;
  rep(i,m)
  {
    if(ba[i].second<end)continue;
    res++;
    end=ba[i].first;

  }
  cout<<res<<endl;


  return 0;

}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)
	// sc.Split(bufio.ScanLines)
	n := readInt()
	hpArr := make([]int, 0, n)
	for i := 0; i < n; i++ {
		hpArr = append(hpArr, readInt())
	}
	sort.Ints(hpArr)
	ans := math.MaxInt64
	for i := 0; i < n-1; i++ {
		min := solve(hpArr[i+1], hpArr[i])
		ans = minFunc(ans, min)
	}
	fmt.Println(ans)

}

func solve(a, b int) int {
	r := a % b
	for r != 0 {
		a = b
		b = r
		r = a % b
	}
	return b
}

//便利関数群
var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	i, _ := strconv.Atoi(read())
	return i
}

func max(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func minFunc(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

func abs(x, y int) int {
	if x-y > 0 {
		return x - y
	}
	return -(x - y)
}

type XY struct {
	x, y int
}

type Points []XY

func (p Points) Len() int {
	return len(p)
}
func (p Points) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}
func (p Points) Less(i, j int) bool {
	return p[i].x < p[j].x
}
func (p Points) remove(i int) Points {
	if i >= len(p) {
		return p
	}
	return append(p[:i], p[i+1:]...)
}


Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int a[100000], n, q, k, sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> k;
		if (*lower_bound(a, a + n, k) == k) sum++;
	}
	cout << sum << endl;
	return 0;

}

Measured memory_bytes: 3440
#include<bits/stdc++.h>
#define ll long long int 
using namespace std;
 
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll x; cin >> x;
  
  if(x<500) cout << (x/5)*5;
  else {
    ll y = (x/500)*1000;
    x=x-y/2;
    cout << y+(x/5)*5 ;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  string s;
  cin >> s;
  int cnt = 0;
  if(s[0] == 'R'){
    if(s[1] == 'R'){
      if(s[2] == 'R'){
        cnt = 3;
      }else{
        cnt = 2;
      }
    }else{
      cnt = 1;
    }
  }else{
    if(s[1] == 'R'){
      if(s[2] == 'R'){
        cnt = 2;
      }else{
        cnt = 1;
      }
    }else{
      if(s[2] == 'R'){
        cnt = 1;
      }else{
        cnt = 0;
      }
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
#define min(a,b) ((a)<(b)? (a):(b))
int main(void) {
	int w,h,c;
	int i,n,div,cost=0;
	
	scanf("%d%d%d",&w,&h,&c);
	n=min(w,h);
	for(i=1;i<=n;i++){
		if(w%i==0 && h%i==0) div=i;
	}
	cost=(w/div)*(h/div)*c;
	printf("%d\n",cost);

	return 0;
}

Measured memory_bytes: 596
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 105
#define int long long
using namespace std;
int n,head[N],tot;
struct edge{int next,to;}e[N<<1];
void add(int u,int v)
{
	e[++tot]=(edge){head[u],v};
	head[u]=tot;
}
int dis[N];
int mount[N];
int ans=1000,res=0;
void dfs(int x,int fa)
{
	for(int i=head[x];i;i=e[i].next)
		if(e[i].to!=fa)
		{
			dis[e[i].to]=dis[x]+1;
			mount[x]++;
			dfs(e[i].to,x);
		}
}
int X[N],Y[N];
main()
{
	scanf("%lld",&n);
	for(int i=1;i<n;i++)
	{
		scanf("%lld%lld",&X[i],&Y[i]);
		add(X[i],Y[i]);add(Y[i],X[i]);
	}
	for(int i=1;i<=n;i++)
	{
		memset(dis,0,sizeof(dis));
		memset(mount,0,sizeof(mount));
		dis[i]=1;
		dfs(i,0);
		int now=0;
		for(int i=1;i<=n;i++)
			now=max(now,dis[i]);
		int tmp[N]={0};
		for(int i=1;i<=n;i++)
		{
			tmp[dis[i]]=max(tmp[dis[i]],mount[i]);
		}
		int haha=1;
		for(int i=1;i<now;i++)
			haha*=tmp[i];
		if(now<ans)ans=now,res=haha;
		else if(now==ans)res=min(res,haha);
	}
	for(int i=1;i<n;i++)
	{
		memset(dis,0,sizeof(dis));
		memset(mount,0,sizeof(mount));
		dis[X[i]]=dis[Y[i]]=1;
		dfs(X[i],Y[i]);dfs(Y[i],X[i]);
		int now=0;
		for(int i=1;i<=n;i++)
			now=max(now,dis[i]);
		int tmp[N]={0};
		for(int i=1;i<=n;i++)
		{
			tmp[dis[i]]=max(tmp[dis[i]],mount[i]);
		}
		int haha=2;
		for(int i=1;i<now;i++)
			haha*=tmp[i];
		if(now<ans)ans=now,res=haha;
		else if(now==ans)res=min(res,haha);
	}
	printf("%lld %lld\n",ans,res);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define NIL -(long long)(1e9)
#define ll long long
long long n,w;

int weigths[102];
long long values[102];

 long long dp2[100005];
 long long dp1[100005];


#define INF 0x3f
 // ll dp2[100005];


void min_self(int& a,int b){
	a= min(a,b);
	return;

}



int main () {
memset(dp2,INF,sizeof(dp2));
cin>>n>>w;
ll val_sum=0;

//dp[i]'deki bu ağırlıkta ulaşabileceğim max value i dir 
for (long long j = 0; j <= n; ++j)
{
	cin>>weigths[j]>>values[j];
	val_sum+=values[j];
}
dp2[0]=0;
for (int i = 0; i < n; ++i)// item
{	for (int j = val_sum-values[i]; j >= 0 ; --j){ //j value
		dp2[j+values[i]]=min(dp2[j+values[i]], dp2[j]+weigths[i]);
		
	}
	// dp2=dp1;
	}
	ll ans=72;
// 	for (int i = 0; i <= val_sum; ++i)
// {
	
// 		cout<<dp2[i]<<" ";
	
// }



for (int i = 0; i <= 100000; ++i)
{
	if (dp2[i]<=w &&dp2[i]!=INF )
	{
		ans=i;
	}
}
cout<<ans;
	return 0;
}

/*



ll ans=0;


for (int i = 0; i <= n; ++i)
{
	for (int j = 0; j < 150; ++j)
	{
		cout<<dp[i][j]<<" ";
	}
	cout<<"\n";
}


}

*/

Measured memory_bytes: 1024
//#define NDEBUG

#include <bits/stdc++.h>
#include <bits/extc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define iceil(a, b) ((a + b - 1) / b)
#define tomax(a, b) (a = max(a, b))
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}

//#define TEST

using namespace std;
using namespace __gnu_pbds;

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

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using tiii = tuple<int, int, int>;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
    return o << '(' << p.F << ',' << p.S << ')';
}

int main(){
    StarBurstStream

    int n;
    cin >> n;
    vector<ll> a(n + 1);
    for(int i = 1; i <= n; i++) cin >> a[i];

    vector<ll> dp(n + 1, 1000);
    for(int i = 1; i < n; i++){
        ll cnt = dp[i] / a[i];
        ll tmp = dp[i] - cnt * a[i];
        for(int j = i + 1; j <= n; j++){
            dp[j] = max(dp[j], tmp + cnt * max(a[i], a[j]));
        }
    }

    cout << dp[n] << "\n";

    return 0;
}

Measured memory_bytes: 3580
#include<stdio.h>
int main(){

  float x1, y1, x2, y2, x3, y3, x4, y4, AB, CD;
  int i, n;
  scanf("%d", &n);
  for(i=0;i<n;i++){
  scanf("%f %f %f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);

  AB=(y1-y2)/(x1-x2);

  CD=(y3-y4)/(x3-x4);

  if(AB==CD)

  printf("YES\n");

  else

  printf("NO\n");

  }

  return 0;

  }


Measured memory_bytes: 2048
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

vector<vector<ll> > dp;

ll sum(int l, int r, ll *s) {
    if (l == 0)
        return s[r];

    return s[r]-s[l-1];
}

ll func(int l, int r, ll *s) {
    if (l == r)
        return dp[l][r] = 0;
    if (dp[l][r] != -1)
        return dp[l][r];

    ll ans = 1e18;
    for (int i = l; i < r; i++) {
        ans = min(ans, sum(l, i, s)+sum(i+1, r, s)+func(l, i, s)+func(i+1, r, s));
    }

    return dp[l][r] = ans;
}

int main() {
    int n;  cin >> n;
    ll *a = new ll[n], *s = new ll[n];
    for (int i = 0; i < n; i++) 
        cin >> a[i];
    dp.resize(n, vector<ll>(n, -1));

    s[0] = a[0];
    for (int i = 1; i < n; i++)
        s[i] = s[i-1] + a[i];

    cout << func(0, n-1, s) << endl;

    return 0;
}

Measured memory_bytes: 4948
#include <bits/stdc++.h>
#define REP(i, a) for(int i=0; i<int(a); i++)
#define ALL(x) begin(x), end(x)
#define VI vector<int>
using namespace std;
typedef long long LL;

const int MAX_N=100005;

struct WeightedUnionFind {
    int n;
    int INF = 1e9;
    vector<int> par, sz, weight;

    WeightedUnionFind() {}
    WeightedUnionFind(int n_) : n(n_), par(n_, 0), sz(n_, 1), weight(n_, 0) { iota(begin(par), end(par), 0); }

    int find(int x) { 
        if(x==par[x]) return x;
        int y = find(par[x]);
        weight[x]+=weight[par[x]];
        return par[x]=y;
    }

    void unite(int x, int y, int w) {
        int px = find(x);
        int py = find(y);
        if(px == py) return;
        if(sz[px] < sz[py]) {
            swap(px, py);
            swap(x, y);
            w = -w;
        }
        sz[px] += sz[py];
        par[py] = px;
        weight[py] = weight[x] - w - weight[y];            
    }

    int same(int x, int y) { return find(x) == find(y); }

    int diff(int x, int y) { // x -> y
        if(same(x, y)) return weight[x]-weight[y];
        return INF;
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    WeightedUnionFind wuf(n);

    while(q--) {
        int op;
        cin >> op;
        if(op == 0) {
            int x, y, w;
            cin >> x >> y >> w;
            wuf.unite(x, y, w);
        } else {
            int x, y;
            cin >> x >> y;
            int ans = wuf.diff(x,y);
            if(ans < wuf.INF) cout << ans << endl;
            else cout << '?' << endl;
        }
    }

    return 0; 
}


Measured memory_bytes: 3828
N, K = list(map(int, input().split()))
X = list(map(int, input().split()))

X.sort()

ma = max(X)
mi = min(X)

if ma <= 0:
    X.sort(key=lambda x: -x)
    a = 0
    for i in range(K):
        a = X[i]
    print(abs(a))
elif 0 <= mi:
    a = 0
    for i in range(K):
        a = X[i]
    print(abs(a))
else:
    ans = 1000000000000000000
    for i in range(N):
        l = i
        r = i + K - 1
        if r < N and X[l] <= 0 <= X[r]:
            if abs(X[l]) > abs(X[r]):
                ans = min(abs(X[r]) * 2 + abs(X[l]), ans)
            else:
                ans = min(abs(X[l]) * 2 + abs(X[r]), ans)
    print(ans)

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

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

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

  vector<ll> pre(n, 0);
  pre[0] = v[0];
  for(int i=1; i<n; i++)
    pre[i] += pre[i-1]+v[i];

  vector<vector<pair<ll,ll>>> dp(n, vector<pair<ll,ll>>(n, make_pair(0,0)));
  for(int i=0; i<n; i++)
    dp[i][i].first = v[i], dp[i][i].second = 0;

  for(int i=1; i<n; i++)
  {
    for(int j=0; j+i<n; j++)
    {
      dp[j][j+i].first = max(v[j+i]+dp[j][j+i-1].second, v[j]+dp[j+1][j+i].second);
      if(j == 0)
        dp[j][j+i].second = pre[j+i] - dp[j][j+i].first;
      else
        dp[j][j+i].second = (pre[j+i]-pre[j-1]) - dp[j][j+i].first; 
    }
  }
 
  cout<<dp[0][n-1].first - dp[0][n-1].second;
  return 0;
}


Measured memory_bytes: 141056
void main()
{
    int n = readln.chomp.to!int;
    int[] a = readln.split.to!(int[]);

    int[] odd = a.stride(2).array;
    int[] even = a[1..$].stride(2).array;

    if (n % 2)
    {
        reverse(odd);
        writeln(odd.to!(string[]).join(" "), " ", even.to!(string[]).join(" "));
    }
    else
    {
        reverse(even);
        writeln(even.to!(string[]).join(" "), " ", odd.to!(string[]).join(" "));
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 17904
n=gets.to_i
h={}
n.times do 
 a=gets
 h[a.chomp] = 1
end

for m in ["S","H","C","D"] do
 for i in 1..13 do
   puts "#{m} #{i}" if !h.has_key?(m+" "+i.to_s) 
 end
end


Measured memory_bytes: 6856
#include<stdio.h>
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    int p[n];
    for(int i=0;i<n;i++)
    scanf("%d",&p[i]);
    int min=p[0];
    for(int i=0;i<n;i++){
        for(int j=i;j<n;j++){
            if(p[i]<=p[j]){
                min=p[j];
                p[j]=p[i];
                p[i]=min;
            }

        }
    }
    int sum=0;
    for(int i=(n-1);i>=(n-k);i--){
        sum=sum+p[i];
   //     printf("%d ",sum);
    }
    printf("%d",sum);
//    for(int i=0;i<n;i++)
  //  printf("%d ",p[i]);
    return 0;
}

Measured memory_bytes: 1712
#include<iostream>
using namespace std;
#define MAX 2000000

int H, A[MAX + 1];

void maxHeapify(int i) {
  int l, r, largest;
  l = 2 * i;
  r = 2 * i + 1;

  if(l <= H && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest]) largest = r;

  if(largest != i) {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

int main() {
  cin >>  H;

  for(int i = 1; i <= H; i++) cin >> A[i];

  for(int i = H / 2; i >= 1; i--) maxHeapify(i);

  for(int i = 1; i <= H; i++) {
    cout<<" "<<A[i];
  }

  cout << endl;
  return 0;
}



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

using namespace std;

int main() {
    const int mod = 1e9 + 7;
    int n, m;
    cin >> n >> m;
    vector<vector<char>> grid(n, vector<char>(m));
    vector<vector<int>> dp(n, vector<int>(m));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> grid[i][j];
        }
    }
    int j = 0;
    while (j < m && grid[0][j] != '#') {
        dp[0][j] = 1;
        ++j;
    }
    while (j < m) {
        dp[0][j] = 0;
        ++j;
    }
    int i = 1;
    while (i < n && grid[i][0] != '#') {
        dp[i][0] = 1;
        ++i;
    }
    while (i < n) {
        dp[i][0] = 0;
        ++i;
    }
    for (i = 1; i < n; ++i) {
        for (j = 1; j < m; ++j) {
            if (grid[i][j] == '#')dp[i][j] = 0;
            else
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
        }
    }

    printf("%d", (dp[n - 1][m - 1] % mod));
}

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

int main(){
    ll  n ;
    cin >> n ;
    vector<ll> ans(4,0) ;
    rep(i,n){
      string s ;
      cin >> s ;
      if(s == "AC")ans[0]++ ;
      if(s == "WA")ans[1]++ ; 
      if(s == "TLE")ans[2]++ ; 
      if(s == "RE")ans[3]++ ; 
    }
    cout << "AC x " << ans[0] <<endl ;
    cout << "WA x " << ans[1] <<endl ;
    cout << "TLE x " << ans[2] <<endl ;
    cout << "RE x " << ans[3] <<endl ;

}

Measured memory_bytes: 3488
#include<stdio.h>

int A[100001];

int key;

int partition(int *A,int p, int r){
  
  int x,i,j,temp;
  
  x = A[r];
  i = p-1;
  
  for(j=p;j<r;j++){
    if(A[j] <= x ){
      i++;
      if(j == r) key = i;
      temp = A[i];
      A[i] = A[j];
      A[j] = temp;
    }
  }
  
  temp = A[i+1];
  A[i+1] = A[r];
  A[r] = temp;
  
  return i+1;
}
int main(char args[]) {
  
  int i,n,x;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  key = partition(A,0,n-1);
  
  for(i=0;i<n-1;i++){
    if(i>0) printf(" ");
    if(key == i) printf("[%d]",A[i]);
    else printf("%d",A[i]);    
  }
  if(key == i) printf(" [%d]",A[n-1]);
  printf(" %d\n",A[n-1]);
  return 0;
}

Measured memory_bytes: 992
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
int n,m,i,j,mod=998244353,fac[3000005],inv[3000005],fi[3000005],ans;
int c(int x,int y)
{
	return 1ll*fac[x]*fi[y]%mod*fi[x-y]%mod;
}
int f(int x,int y)
{
	return c(x+y-1,x-1);
}
int main()
{
	fac[0]=fac[1]=fi[0]=fi[1]=inv[1]=1;
	fz(i,2,3000000){
		fac[i]=1ll*fac[i-1]*i%mod;
		inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
		fi[i]=1ll*fi[i-1]*inv[i]%mod;
	}
	scanf("%d%d",&n,&m);
	fz0g(i,min(n,m)){
		if((m+m+m-i)%2==0){
			ans=(ans+1ll*c(n,i)*f(n,(m+m+m-i)/2))%mod;
		}
	}
	fz0g(i,min(n,m)){
		if((m-i)%2==0){
			ans=(ans-1ll*c(n,i)*f(n,(m-i)/2)%mod*n)%mod;
		}
	}
	inc(ans,mod)
	fz0g(i,min(n-1,m)){
		if((m-i)%2==0){
			ans=(ans+1ll*c(n-1,i)*f(n-1,(m-i)/2)%mod*n)%mod;
		}
	}
	printf("%d\n",ans); 
	return 0;
}

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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

vector<int> l;

void dfs(vector<vector<int>>& edges, vector<bool>& used, int i) {
    for (int j : edges[i]) if (!used[j]) {
        used[j] = true;
        dfs(edges,used,j);
    }
    l.push_back(i);
}

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> dp(n,0);
    vector<vector<int>> edges(n);
    vector<bool> used(n,false),vst(n,false);
    for (int i = 0;i < m;++i) {
        int x,y;
        cin >> x >> y;
        x--;y--;
        edges[x].push_back(y);
    }
    for (int i = 0;i < n;++i) if (!used[i]) {
        used[i] = true;
        dfs(edges,used,i);
    }
    reverse(l.begin(),l.end());
    for (int i : l) if (!vst[i]) for (int j : edges[i]) dp[j] = max(dp[j],dp[i]+1);
    cout << *max_element(dp.begin(),dp.end()) << endl;
    return 0;
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

const int N = 2e5;

void solve() {
  int n; cin >> n;
  vector<int> vt(n);
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> vt[i];
  }
  for (int i = 0; i < n; i++) {
    if (vt[i] % 2 == 1 && i + 1 < n && vt[i + 1]) {
      vt[i]--, vt[i + 1]--; ans++;
    }
    ans += vt[i] / 2;
  }
  cout << ans;
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES (n == 1)

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(20);
  //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
  solve();
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define freinput "input.txt","r",stdin
#define freoutput "output.txt","w",stdout
#define mp make_pair
#define fi first
#define sc second
#define pb push_back
#define ellapse printf("Time : %0.3lf\n",clock()*1.0/CLOCKS_PER_SEC);
typedef long long ll;
typedef unsigned long int uld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
struct comp {
       bool operator() (int a,int b) {
            return a>b;
       }
};

int main(){
//    #ifdef chris
//    freopen(freinput);
//    freopen(freoutput);
//    #endif // chris
//    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll res=0;
    ll s = 5;
    if (n%2==1){
        cout<<0<<endl;
    }else{
        while(n/s!=0){
            res += n/s/2;
            s *=5;
        }
        cout<<res<<endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

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

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

const int INF = 1001001001;

struct Dice
{
	int data[6];
	void roll(int a, int b, int c, int d)
	{
		int tmp = data[d];
		data[d] = data[c];
		data[c] = data[b];
		data[b] = data[a];
		data[a] = tmp;
	}
	void rotateX(){
		roll(0, 4, 5, 1);
	}
	void rotateY(){
		roll(0, 2, 5, 3);
	}
	void rotateZ(){
		roll(1, 2, 4, 3);
	}
	int hash()
	{
		int ret = INF;
		rep(i, 6){
			rep(j, 4){
				int h = 0;
				rep(k, 6)
					h = h*6 + data[k];
				ret = min(ret, h);
				rotateX();
			}
			i%2 ? rotateY() : rotateZ();
		}
		return ret;
	}
};

int main()
{
	const char* colors[] = {"Cyan", "Yellow", "Red", "Magenta", "Green", "Blue"};
	map<string, int> dict;
	rep(i, 6)
		dict[colors[i]] = i;
	
	int n;
	while(scanf("%d", &n), n){
		int hash[30];
		rep(i, n){
			Dice dice;
			rep(j, 6){
				char str[128];
				scanf("%s", str);
				dice.data[j] = dict[str];
			}
			hash[i] = dice.hash();
		}
		sort(hash, hash+n);
		printf("%d\n", n - (unique(hash, hash+n)-hash));
	}
	return 0;
}

Measured memory_bytes: 1100
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 23 09:53:22 2019

@author: Yamazaki Kenichi
"""

S = input()

flg = True
tmp = S[0]
for i in range(1,len(S)):
    if S[i] == tmp:
        flg = False
    tmp = S[i]
if flg:
    ans = 'Good'
else:
    ans = 'Bad'
print(ans)

Measured memory_bytes: 3060
#!/usr/bin/env python3

N = int(input())
# S = input()
# N, K = map(int, input().split())
A = list(map(int, input().split()))
from collections import Counter

def main():
    nums = []
    for a in A:
        nums.append(a)
        nums.append(a + 1)
        nums.append(a - 1)
    print(Counter(nums).most_common()[0][1])

if __name__ == "__main__":
    main()


Measured memory_bytes: 30200
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            int iH = int.Parse(sS[0]);
            int iW = int.Parse(sS[1]);
            List<List<string>> lstSS = new List<List<string>>();
            for (int i = 0; i < iH; i++)
            {
                string s2 = Console.ReadLine().Trim();
                List<string> oneUsr = new List<string>();
                for (int j = 0; j < s2.Length; j++)
                {
                    oneUsr.Add(s2.Substring(j, 1));
                }
                lstSS.Add(oneUsr);
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            for (int i = 0; i < lstSS.Count; i++)
            {
                for (int j = 0; j < lstSS[i].Count; j++)
                {
                    if (lstSS[i][j] == ".") { lstSS[i][j] = GetBmbCnt(lstSS, i , j, iH, iW); }
                }
            }

            // 出力
            for (int i = 0; i < lstSS.Count; i++)
            {
                string sOut = "";
                for (int j = 0; j < lstSS[i].Count; j++)
                {
                    sOut = string.Join("", lstSS[i]);
                }
                Console.WriteLine("{0}", sOut.ToString().Trim());
            }

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
        // #数取得
        private static string GetBmbCnt(List<List<string>> lstSS, int i, int j, int iH, int iW)
        {
            int iBmbCnt = 0;
            if (i - 0 >= 0 && j - 1 >= 0 && lstSS[i - 0][j - 1] == "#") { iBmbCnt += 1; }       // ←
            if (i - 1 >= 0 && j - 1 >= 0 && lstSS[i - 1][j - 1] == "#") { iBmbCnt += 1; }       // ↖
            if (i - 1 >= 0 && j - 0 >= 0 && lstSS[i - 1][j - 0] == "#") { iBmbCnt += 1; }       // ↑
            if (i - 1 >= 0 && j + 1 < iW && lstSS[i - 1][j + 1] == "#") { iBmbCnt += 1; }       // ↗
            if (i + 0 < iH && j + 1 < iW && lstSS[i + 0][j + 1] == "#") { iBmbCnt += 1; }       // →
            if (i + 1 < iH && j + 1 < iW && lstSS[i + 1][j + 1] == "#") { iBmbCnt += 1; }       // ↘
            if (i + 1 < iH && j + 0 < iW && lstSS[i + 1][j + 0] == "#") { iBmbCnt += 1; }       // ↓
            if (i + 1 < iH && j - 1 >= 0 && lstSS[i + 1][j - 1] == "#") { iBmbCnt += 1; }       // ↙
            return iBmbCnt.ToString();
        }

}


Measured memory_bytes: 13524
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll a,b,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    vector<ll> v(4);
    char c;
    rep(i,4){
        cin>>c;
        v[i]=atoll(&c);
    }
    if(v[0]+v[1]+v[2]+v[3]==7) {cout<<v[0]<<'+'<<v[1]<<'+'<<v[2]<<'+'<<v[3]<<"=7"<<endl;
    }else if(v[0]+v[1]+v[2]-v[3]==7) {cout<<v[0]<<'+'<<v[1]<<'+'<<v[2]<<'-'<<v[3]<<"=7"<<endl;
    }else if(v[0]+v[1]-v[2]+v[3]==7) {cout<<v[0]<<'+'<<v[1]<<'-'<<v[2]<<'+'<<v[3]<<"=7"<<endl;
    }else if(v[0]+v[1]-v[2]-v[3]==7) {cout<<v[0]<<'+'<<v[1]<<'-'<<v[2]<<'-'<<v[3]<<"=7"<<endl;
    }else if(v[0]-v[1]+v[2]+v[3]==7) {cout<<v[0]<<'-'<<v[1]<<'+'<<v[2]<<'+'<<v[3]<<"=7"<<endl;
    }else if(v[0]-v[1]+v[2]-v[3]==7) {cout<<v[0]<<'-'<<v[1]<<'+'<<v[2]<<'-'<<v[3]<<"=7"<<endl;
    }else if(v[0]-v[1]-v[2]+v[3]==7) {cout<<v[0]<<'-'<<v[1]<<'-'<<v[2]<<'+'<<v[3]<<"=7"<<endl;
    }else if(v[0]-v[1]-v[2]-v[3]==7) {cout<<v[0]<<'-'<<v[1]<<'-'<<v[2]<<'-'<<v[3]<<"=7"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main(){
	int n,m,a,b;
	string s,ts;
	while(cin >> n,n){
		map<string,int> ma;
		for(int i = 0;i < n;++i){
			cin >> s >> a;
			ma[s] = a;
		}
		cin >> m;
		for(int i = 0;i < m;++i){
			b = 0;
			cin >> s >> a;
			for(int j = 0;j < a;++j){
				cin >> ts;
				b += ma[ts];
			}
			if(b < ma[s]) ma[s] = b;
		}
		cin >> s;
		cout << ma[s] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
using namespace std;

#define ll long long
#define MP make_pair

ll powint(ll powintnum,ll powintjou){
if(powintjou==1){
return powintnum;
}else if(powintjou==0){
return 1;
}else if(powintjou%2==0){
int powinttmp=powint(powintnum,powintjou/2);
return powinttmp*powinttmp;
}else{
int powinttmp=powint(powintnum,powintjou-1);
return powinttmp*powintnum;
}
}

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

	ll ans=(a-b)*powint((-1),((k)%2));

	cout<<ans<<"\n";




	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a,b;
  cin >> a >> b;
  reverse(b.begin(),b.end());
  if(a==b) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().strip().split())

max_left = 0
min_right = n
for _ in range(m):
    l_tmp, r_tmp = map(int, input().strip().split())
    if max_left < l_tmp:
        max_left = l_tmp
    if r_tmp < min_right:
        min_right = r_tmp

if min_right < max_left:
    print(0)
else:
    print(min_right - max_left + 1)


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

string s[105];
int memo[105][105];

int main2() {
  int H = nextInt();
  int W = nextInt();
  REP(i, H) cin >> s[i];


  REP(i, 105) REP(j, 105) memo[i][j] = 1001001001;

  queue<int> q;
  q.push(0);
  q.push(0);
  memo[0][0] = (s[0][0] == '.') ? 0 : 1;

  while (!q.empty()) {
    int h = q.front(); q.pop();
    int w = q.front(); q.pop();

    if (h + 1 < H) {
      int nh = h + 1;
      int nw = w;
      int ncost = memo[h][w] + ((s[h][w] == '.' && s[nh][nw] == '#') ? 1 : 0);
      if (memo[nh][nw] > ncost) {
        memo[nh][nw] = ncost;
        q.push(nh);
        q.push(nw);
      }
    }
    if (w + 1 < W) {
      int nh = h;
      int nw = w + 1;
      int ncost = memo[h][w] + ((s[h][w] == '.' && s[nh][nw] == '#') ? 1 : 0);
      if (memo[nh][nw] > ncost) {
        memo[nh][nw] = ncost;
        q.push(nh);
        q.push(nw);
      }
    }
  }
  // REP(i, H) {
  //   REP(j, W) cout << memo[i][j];
  //   cout << endl;
  // }
  ll ans = memo[H-1][W-1];
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	if (K == 1) cout << 0;
	else cout << N - K;
}

Measured memory_bytes: 256
import itertools
import collections
N,M=map(int,raw_input().split())
#print N,M
a=[map(int,raw_input().split()) for i in range(M)]
#print a
b=list(itertools.permutations(range(1,N+1)))
#print b

ans=0
for i in b:
	if i[0]!=1:
		continue
	c=[]
	for j in i:
		#print i,j
		if len(c)<2:
			c.append(j)

		if len(c)==2:
			if c in a or c[::-1] in a:
				cnt=1
			else:
				cnt=0
				break
			c.pop(0)
	ans+=cnt
print ans

Measured memory_bytes: 8148
<?php
fscanf(STDIN, "%d %d %d", $a, $b, $c);
// $a = 4;
// $b = 4;
// $c = 1;
$array = [$a, $b, $c];
sort($array);
if($array[0] === $array[1]){
  echo $array[2];
}else{
  echo $array[0];
}
?>


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

#define N 3

int main() {
	static int aa[N];
	int n, m, s, c, i;

	scanf("%d%d", &n, &m);
	if (n == 1 && m == 0) {
		printf("0\n");
		return 0;
	}
	memset(aa, -1, n * sizeof *aa);
	while (m--) {
		scanf("%d%d", &s, &c), s--;
		if ((n > 1 && s == 0 && c == 0) || (aa[s] != -1 && aa[s] != c)) {
			printf("-1\n");
			return 0;
		}
		aa[s] = c;
	}
	for (i = 0; i < n; i++)
		printf("%d", aa[i] != -1 ? aa[i] : i == 0 ? 1 : 0);
	printf("\n");
	return 0;
}


Measured memory_bytes: 128
sa=input()
sb=input()
sc=input()
x="a"
while True:
    if x=="a":
        if len(sa)==0:
            print("A")
            break
        x=sa[0]
        sa=sa[1:]
    elif x=="b":
        if len(sb)==0:
            print("B")
            break
        x=sb[0]
        sb=sb[1:]
    elif x=="c":
        if len(sc)==0:
            print("C")
            break
        x=sc[0]
        sc=sc[1:] 

Measured memory_bytes: 9048
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 20;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

pii operator-(pii l, pii r){ return pii(l.first - r.first, l.second - r.second); }
ll operator/(pii l, pii r){ return (ll)l.first * r.second - (ll)l.second * r.first; }
ll operator*(pii l, pii r){ return (ll)l.first * r.first + (ll)l.second * r.second; }

const int MX = 1000005;
const int MM = 998244353;

ll C[MX], C2[MX], I[MX];
int N, K;

int main()
{
	scanf("%d%d", &N, &K);
	if(K < N) return !printf("0\n");
	I[1] = 1;
	for(int i = 2; i < MX; i++) I[i] = (MM-MM/i) * I[MM%i] % MM;
	C[0] = C2[0] = 1;
	for(int i = 1; i <= K; i++) C[i] = C[i-1] * (K-i+1) % MM * I[i] % MM;
	for(int i = 1; i <= K-1; i++) C2[i] = C2[i-1] * (K-i) % MM * I[i] % MM;

	ll ans = 0;
	if( K%2 == 0 && K/2 >= N){
		int v = K/2-N;
		int ad = K/2+v+1;
		ll sub = ad >= 0 ? C2[ad] : 0;
		ans = (ans + C2[K/2-1] - sub + MM) % MM;
	}
	for(int i = K/2+1; i <= K; i++){
		if(i < N) continue;
		int v = i-N;
		int ad = i+v+1;
		ll sub = ad >= 0 ? C[ad] : 0;
		ans = (ans + C[i] - sub + MM) % MM;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 18688
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;


    void calc()
    {
        cin = new Scanner();
        int[] ab = cin.ArrayInt(2,0);
        if((ab[0]+ab[1])%2==0)Console.WriteLine((ab[0]+ab[1])/2);
        else Console.WriteLine((ab[0]+ab[1]+1)/2);
    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}






Measured memory_bytes: 13140