akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;i++)
#define FORD(i,a,b) for (int i=a;i>=b;i--)
using namespace std;
typedef pair<int,int> pa;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int n,m,tot,p[1010][1010],fa[1000010],s[1000010],S[1000010],cnt[1010];
char a[1010][1010];
int getf(int x){
	return fa[x]==x?x:fa[x]=getf(fa[x]);
}
int main(){
	scanf("%d%d",&n,&m);
	FOR(i,1,n){
		scanf("%s",a[i]+1);
		FOR(j,1,m) cnt[a[i][j]]++;
	}
	FOR(i,1,n)
		FOR(j,1,m)
			p[i][j]=++tot;
	FOR(i,1,tot) fa[i]=i;
	FOR(i,1,n)
		FOR(j,1,m/2){
			int X=getf(p[i][j]),Y=getf(p[i][m+1-j]);
			if (X!=Y) fa[X]=Y;
		}
	FOR(j,1,m)
		FOR(i,1,n/2){
			int X=getf(p[i][j]),Y=getf(p[n+1-i][j]);
			if (X!=Y) fa[X]=Y;
		}
	FOR(i,1,tot) s[getf(i)]++;
	FOR(i,1,tot) S[s[i]]++;
	int t=0;
	FOR(i,'a','z')
		t+=cnt[i]/4;
	if (t<S[4]) return puts("No"),0;
	t=0;
	FOR(i,'a','z')
		t+=cnt[i]/2;
	if (t<S[4]*2+S[2]) return puts("No"),0;
	puts("Yes");
	return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
const int N = 2000 + 10;
using namespace std;

char str[N];
int n;
int main()
{
  scanf("%s",str);
  n = strlen(str);
  int a=0, b=0;
  int c=0, d=0;
  for(int i=0; i<n; ++i)
  {
    if(str[i]=='N') a=1;
	else if(str[i]=='S') b=1;
	else if(str[i]=='W') c=1;
    else d=1;;
  }
  if(a==b&&c==d) puts("Yes"); else puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
int32_t main(){
    SPEED;
    string o, e;
    cin >> o >> e;
    string ans = "";
    int j = 0, k = 0;
    for(int i = 1; i <= len(o) + len(e); ++i){
        if(i & 1) ans += o[j], j++;
        else ans += e[k], k++;
    }
    cout << ans ;
}

Measured memory_bytes: 3532
object Main extends App {
  val Array(a, b, x) = scala.io.StdIn.readLine().split(' ').map(_.toLong)
  var start = 0L

  if (a % x == 0) {
    start = a
  } else {
    start = a + x - a % x
  }
  if (b >= start) {
    println((b - start) / x + 1)
  } else {
    println(0)
  }
}


Measured memory_bytes: 27060
#include <stdio.h>

int main(void)
{
	int i,x;

	for(i = 1; 1; i++)
	{
		scanf("%d",&x);

		if (x == 0)
		{
			break;
		}

		printf("Case %d: %d\n",i,x);

	}


	return 0;
}

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

int main(){
    char s[10001],*c=s;
    int n;
    cin >> n >> s;
    while (*c != '\0') {
        *c = (*c)+n;
        if(*c > 'Z') *c -= 26;
        c++;
    }
    cout << s << endl;
}

Measured memory_bytes: 3628
n,y=[int(i) for i in input().split()]
ex=False
for i in range(n+1):
  for j in range(n+1-i):
    k = n-i-j
    s = 10000*i+5000*j+1000*k
    if s == y:
      ex = True
      break
  if ex:
    break
if ex:
  print('{} {} {}'.format(i,j,k))
else:
  print('-1 -1 -1')

Measured memory_bytes: 3064
/* *
 *
 * Author: Hamkor
 *
 * */
 
#include <bits/stdc++.h>
 
using namespace std;
 
/* * * *   * * *   	* * * */
typedef long long ll;
const int oo = 1e9;
const ll mod = 100000000;
typedef complex<ll> P;
#define X real()
#define Y imag()
/* * * *   * * *   	* * * */
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, t, m = 1e9; cin>>n>>t;
	vector<pair<int, int> > a(n);
	for(int i=0; i<n; ++i) cin>>a[i].second>>a[i].first;
	sort(a.begin(), a.end());
	int k = 0;
	while (a[k].first <= t && k < n) {m = min(m, a[k].second); k++;}
	if (k) cout<<m;
	else cout<<"TLE";
	return 0;
}


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

int main(){
    int n;
    cin>>n;
    long int sum = 0;
    for(int i=1;i<=n;i++){
        if(i%3!=0){
            if(i%5!=0){
                sum = sum + i;
            }
        }
    }
    cout<<sum<<endl;
}

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

int main(void){

	char s[4];

	scanf("%s",s);

	if(strcmp(s,"SUN")==0){
		printf("7\n");
	}else if(strcmp(s,"SUN")==0){
		printf("7\n");
	}else if(strcmp(s,"MON")==0){
		printf("6\n");
	}else if(strcmp(s,"TUE")==0){
		printf("5\n");
	}else if(strcmp(s,"WED")==0){
		printf("4\n");
	}else if(strcmp(s,"THU")==0){
		printf("3\n");
	}else if(strcmp(s,"FRI")==0){
		printf("2\n");
	}else{
		printf("1\n");
	}


	return 0;
}

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

using namespace std;

int k;
queue<long long> q;
int cc;

int main(void)
{
	scanf("%d", &k);
	
	for(long long i = 1 ; i <= 9 ; i++)
		q.push(i);
	
	while(!q.empty())
	{
		long long qq = q.front();
		q.pop();
		cc++;
		
		if(cc == k)
		{
			printf("%lld", qq);
			return 0;
		}
		
		if(qq % 10 == 9)
		{
			q.push(qq * 10 + 8);
			q.push(qq * 10 + 9);
		}
		
		else if(qq % 10 == 0)
		{
			q.push(qq * 10);
			q.push(qq * 10 + 1);
		}
		
		else
		{
			q.push(qq * 10 + qq % 10 - 1);
			q.push(qq * 10 + qq % 10);
			q.push(qq * 10 + qq % 10 + 1);
		}
	}
	
	return 0;
}

Measured memory_bytes: 1792
n, m, c = gets.chomp.split.map(&:to_i)
b = gets.chomp.split.map(&:to_i)
cnt = 0
for i in 0..(n-1)
  a = gets.chomp.split.map(&:to_i)
  sum = 0
  for j in 0..(m-1)
    sum += a[j] * b[j]
  end
  sum += c
  if sum > 0
    cnt += 1
  end
end
puts cnt

Measured memory_bytes: 3836
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.Panasonic2020
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] hw = ReadInts();
            long h = hw[0];
            long w = hw[1];
            if (h == 1 || w == 1)
            {
                WriteLine(1);
                return;
            }
            if (w % 2 == 1)
            {
                if (h % 2 == 1)
                {
                    WriteLine((h * w + 1) / 2);
                }
                else
                {
                    WriteLine(h * w / 2);
                }
            }
            else
            {
                WriteLine(h * w / 2);
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
import java.io.ByteArrayInputStream;
import java.util.Scanner;

public class Main
{
    private static boolean strcmp(String s, int pos, String other) {
        if (pos >= other.length()) {
            int len = other.length();
            for (int i = 0; i < len; i++) {
                if (s.charAt(pos - i - 1) != other.charAt(len - i - 1)) {
                    return false;
                }
            }
            return true;
        }
        else {
            return false;
        }
    }

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int pos = s.length();
        while (pos > 0) {
            if (strcmp(s, pos, "dream")) {
                pos -= 5;
            }
            else if (strcmp(s, pos, "dreamer")) {
                pos -= 7;
            }
            else if (strcmp(s, pos, "erase")) {
                pos -= 5;
            }
            else if (strcmp(s, pos, "eraser")) {
                pos -= 6;
            }
            else {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
}


Measured memory_bytes: 26304
import numpy as np

k, n = map(int, input().split())
l = list(map(int, input().split()))
a = np.array(l)
b = np.delete(np.append(a,k+a[0]), 0)

sa = b-a
sa_dash = np.delete(sa, np.argmax(sa))
print(np.sum(sa_dash))

Measured memory_bytes: 34160
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

ll inf=1ll<<60;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll i,j,k,n,s1=0,s2=0,a[200000],ans;
	cin>>n;
	for (i=0;i<n;i++){
		cin>>a[i];
		s2+=a[i];
	}
	s1=a[0];
	s2-=a[0];
	ans=abs(s1-s2);
	for (i=1;i<n-1;i++){
		s1+=a[i];
		s2-=a[i];
		ans=min(ans,abs(s1-s2));
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;
#define oorret true //std::out_of_rangeが返された時
#define oor(x) [&](){try{x;} catch(const std::out_of_range& oor){return oorret;} return x;}()
double pi = 3.141592653589793238;
ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
int D;
void calculate(vector<int> c, vector<vector<int>> s, int contest,int day, vector<int> &t, ll &score){
    ll p=0;
    int a[26];
    rep(i, 26){
        a[i]=0;
    }
    rep(i, D){
        rep(j, 26){
            p-=c[j]*(i+1-a[j]);
        }
        if(i!=day){
            p+=s[i].at(t[i])+c[t[i]]*(i+1-a[t[i]]);
            a[t[i]]=i+1;
        }else{
            p+=s[day].at(contest)+c[contest]*(day+1-a[contest]);
            a[contest]=i+1;
        }
        
    }
    if(score<p){
        score=p;
        t[day]=contest;
    }
}

int main(){
cin>>D;
vector<int> c(26);
rep(i, 26){
    cin>>c[i];
}
vector<vector<int>> s(D);
int r;
rep(i, D){
    rep(j, 26){
        cin>>r;
        s[i].push_back(r);
    }
}
int M[26];
rep(i, 26){
    M[i]=0;
}
vector<vector<int>> m(D);
rep(i, D){
    rep(j, 26){
        m[i].push_back(0);
    }
}
vector<int> a(26);

rep(i, 26){
    a[i]=0;
}
rep(i, D){
}
vector<int> t(D);
ll score=0;
rep(i, D){
    rep(j, 26){
        M[j]=0;
    }
    rep(j, 26){
        score-=c[j]*(i+1-a[j]);
        rep(k, j+1){
            if(s[i].at(j)+c[j]*(i+1-a[j])>M[k]){
                rep(l, j-k){
                    M[j-l]=M[j-l-1];
                    m[i].at(j-l)=m[i].at(j-l-1);
                }
                M[k]=s[i].at(j)+c[j]*(i+1-a[j]);
                m[i].at(k)=j;
                break;
            }
        }
    }
    score+=M[0];
    a[m[i].at(0)]=i+1;
    t[i]=m[i].at(0);
}
rep(j, 20){
    rep(i, j+2){
        rep(k, D){
            calculate(c, s, m[k].at(j-i+1),k, t, score);
        }
    }
}
rep(i, D){
    cout<<t[i]+1<<endl;
}
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int sum = 100000;
  cin>>n;
  for(int i=0;i<n;i++){
    sum = (int)(sum*1.05);
    if(sum % 1000 != 0){
      sum += 1000-(sum%1000);
    }
  }
  cout<<sum<<endl;
}
	

Measured memory_bytes: 1160
R,G,B,N = map(int,input().split())
count= 0
sum = 0

for i in range(N//R +1):
    sum = 0
    sum += i * R
    for j in range((N-sum) // G +1):
        Ssum = sum
        Ssum += j * G
        if (N - Ssum) % B == 0:
            count += 1

print(count)

    

Measured memory_bytes: 40556
#include<bits/stdc++.h>
using namespace std;
long long int n,m;
int main(){
  cin >> n >> m;
  vector<pair<long long int,long long int>> v(n);
  for(int i=0;i<n;i++){
    cin >> v[i].first >> v[i].second;
  }
  sort(v.begin(),v.end());
  long long int sum=0,ans=0,i=0,l=0;
  while(sum < m){
    sum++;
    ans += v[i].first;
    l++;
    if(l == v[i].second){
      i++;
      l=0;
    }
  }
  cout << ans;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans;
int N, M;
int G[10][10], dp[1<<10][10];

int main(void) {
    scanf("%d %d", &N, &M);
    for(int i=0; i<M; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--; b--;
        G[a][b] = G[b][a] = true;
    }
    dp[1][0] = 1;
    for (int S=1; S<(1<<N)-1; S++) {
        for (int u=0; u<N; u++) for (int v=0; v<N; v++) {
            if (!((S>>v)&1) && G[u][v]) dp[S|(1<<v)][v] += dp[S][u];
        }
    }

    for (int i=0; i<N; i++) ans += dp[(1<<N)-1][i];
    
   

    printf("%d\n", ans);

	return 0;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N, M;
  cin >> N >> M;
  VVI xs(N, VI(M));
  REP(i,N) REP(j,M){
	cin >> xs[i][j];
	--xs[i][j];
  }

  int lb = 0, ub = N+1;
  while(ub-lb > 1){
	int X = (lb + ub) / 2;
	VI ind(N);
	vector<bool> ban(M);
	VI tmp(M);
	REP(i,N) tmp[xs[i][0]]++;

	bool ok = false;
	bool finish = false;
	while(!finish){
	  vector<PII> cp(M);
	  REP(i,M) cp[i] = MP(tmp[i], i);
	  sort(RALL(cp));
	  if(cp[0].FF <= X){
		ok = true;
		break;
	  }
	  int s = cp[0].SS;
	  tmp[s] = 0;
	  ban[s] = true;
	  REP(i,N){
		if(xs[i][ind[i]] == s){
		  while(ind[i] < M && ban[xs[i][ind[i]]]) ++ind[i];
		  if(ind[i] == M){
			finish = true;
			break;
		  }
		  tmp[xs[i][ind[i]]]++;
		}
	  }
	}
	if(ok) ub = X;
	else lb = X;
  }
  cout << ub << endl;

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;

int main(){
  string s, t;
  cin >> s >> t;
  vector<vector<int> > index(26);
  int n = s.length();
  s = s + s;
  rep(i, s.length()){
    index[s[i] - 'a'].push_back(i);
  }

  ll ans = 0;
  int pos = 0;
  for(int i = 0; i < t.length(); ++i){
    int c = t[i] - 'a';
    if(index[c].size() == 0){
      puts("-1");
      return 0;
    }
    pos = *lower_bound(index[c].begin(), index[c].end(), pos) + 1;
    if(pos >= n) {
      pos -= n;
      ans += n;
    }
  }
  ans += pos;
  cout << ans << endl;
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int a, b;
    cin >> a >> b;
    if(a<=9&&b<=9){
        cout << a * b << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int main(void){
    
    //変数：何処までの数「 n 」、 3つの数の和を「 x 」と置く
    int n, x;
    
    while(true){
        //変数：3つの数の和の数ができる回数「 count 」と置く
        int count = 0;
        //入力：何処までの数「 n 」、 3つの数の和を「 x 」
        cin >> n >> x;
        
        //条件：何処までの数「 n = 0 」、 3つの数の和を「 x = 0」は終了
        if(n == 0 && x == 0) break;
        
        //繰返し：組み合わせ条件を探す
        //１回目の繰り返し　➡　i = 1 , j = 2 , k = 3 となり合計6になる。(最初にkが繰り返しされている)
        // 2回目の繰り返し　➡　i = 1 , j = 2 , k = 4 となり合計7になる。(kが繰り返しされている)
        // 3回目の繰り返し　➡　i = 1 , j = 2 , k = 5 となり合計8になる。(kが繰り返しされている  ➡　kが5でkの繰り返し終了　➡　jの繰り返しに戻る)
        // 4回目の繰り返し　➡　i = 1 , j = 3 k = 4 なり合計8になる。(またkが繰り返しされている)
        for(int i = 1; i <= n; i++){
            for(int j = i + 1; j <= n; j++){
                for(int k = j + 1; k <= n; k++){
                    if(i + j + k == x) count++; 
                }
            }
        }
        cout << count << endl;
    }
    
    return 0;
}


/********************************************　　コメントなしコード　　************************************************
   
#include <iostream>
using namespace std;
int main(void){
    
    int n, x;
    
    while(true){
        int count = 0;
        
        cin >> n >> x;
        
        if(n == 0 && x == 0) break;
        
        for(int i = 1; i <= n; i++){
            for(int j = i + 1; j <= n; j++){
                for(int k = j + 1; k <= n; k++){
                    if(i + j + k == x) count++; 
                }
            }
        }
        cout << count << endl;
    }
    
    return 0;
}
   
*******************************************************************************************************************/





Measured memory_bytes: 3096
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
cnt =0
for i in range(n):
  a=list(map(int,input().split()))
  s=c+sum([b[j]*a[j] for j in range(m)])
  if s>0:
    cnt +=1
print(cnt)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!

ll _find(ll a,ll b,ll c){
    vll arr={a,b,c};
    sort(all(arr));
    a=arr[0];
    b=arr[1];
    c=arr[2];
    
    if(a%2==0 || b%2==0 || c%2==0){
        return 0;
    }
    return a*b;
}

void solve(){
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<_find(a,b,c)<<endl;
}

int main() {
    faster;
    int t=1;
    // cin>>t;
    while(t-->0){
        solve();
    }
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int main(void){
   int a, b, x, y;
   string name;
   for(int i = 0; i < 9; i++){
       cin >> name >> a >> b;
       x = a+b;
       y = a*200 + b*300; 
       cout << name << " " << x << " " << y << endl;
   }
}


Measured memory_bytes: 3128
import java.util.Scanner;
import java.util.Arrays;

public class Main{

     // Bottom-up Dynamic Programming approach.
    private static int helper(int[] nums){

        if(nums.length <=1)
            return 0;

        int[] dp = new int[nums.length];
        dp[0] = 0; // not needed, just for verobsity.
        dp[1] = Math.abs(nums[1] - nums[0]);

        for(int i = 2; i < dp.length; i++){
            dp[i] = Math.min(
                Math.abs(nums[i] - nums[i - 1]) + dp[i - 1],
                Math.abs(nums[i] - nums[i - 2]) + dp[i - 2]);
        }
        return dp[dp.length - 1];
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        if(n==0){
            System.out.println(0);
            return;
        }
        int[] nums = new int[n];
        for(int i = 0; i < n; i++) nums[i] = in.nextInt();

        System.out.println(helper(nums));
    }
}

Measured memory_bytes: 50972
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)


int main(){
  int a,b;
  int n;
  cin >> n;
  for (a = 0; a < 100;a++){
    for (b = 0; b < 100;b++){
      if (4*a + 7*b == n){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;


  return 0; 
}



Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    A, B, N = map(int,input().split())
    if B - 1 <= N:
        print(A * (B - 1) // B)
    else:
        print(A * N // B)


if __name__ == "__main__":
    main()

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

typedef long long ll;
#define nl "\n"
#define ff first
#define ss second
#define mod 1e9+7
#define lb lower_bound
#define ub upper_bound
#define eb emplace_back
#define pp pop_back
#define bs binary_search
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define sll stack<ll>
#define qll queue<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define vc vector <char>
#define vvll vector<vector<ll>>
#define mod 1e9+7
#define mxn 9e18
#define all(x) x.begin(),x.end()
#define loop(i,s,n) for(ll i=s;i<n;i++)
#define test ll t ; cin>>t; while(t--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);

void solve()
{
    ll n,k;
    cin>>n>>k;
    ll a[n],start=1,curr,prev=1,op=0,len;
    map<ll,ll> M,N;
    loop(i,0,n)
    {
        cin>>a[i];
        M[i+1]=a[i];
    }
    while(1)
    {
        curr=M[prev];
        prev=curr;
        op++;
        if(N[curr])
        {
            len=op-N[curr];
            break;
        }
        N[curr]=op;
    }
    if(k-N[curr]>-1){
    k-=N[curr];
    k%=len;
    while(k!=0)
    {
        curr=M[prev];
        prev=curr;
        k--;
    }
    }
    else
    {
        prev=1;   
        while(k!=0)
        {
        curr=M[prev];
        prev=curr;
        k--;
        }
    }
    cout<<curr;
}

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


Measured memory_bytes: 30012
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M; cin >> N >> M;
    int A[N][M];
    rep(i, N) {
        rep(j, M) {
            cin >> A[i][j];
            A[i][j]--;
        }
    }

    bool p[M];
    rep(i, M) p[i] = true;
    int ans = N+1;

    rep(k, M) {     
              
        vector<int> pnum(M);
        rep(i, N) {
            rep(j, M) {
                if (p[A[i][j]] == true) {
                    pnum[A[i][j]]++;
                    break;
                }
            }
        }
        int index = -1; 
        int maxn = -1;
        rep(j, M) {
            if(maxn < pnum[j]) {
                index = j;
                maxn = pnum[j];
            }
        }
        //dump(maxn);dump(index);
        if (maxn <= ans) {
            ans = maxn;
        }
        p[index] = false;
        //rep(i, M) cout << p[i] << " ";
        //cout << endl;
    }
    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here
        String s ;
        Scanner input =new Scanner(System.in);
        s = input.nextLine();
        if (s.equals("SUN"))
            System.out.println("7");
        else if (s.contains("MON"))
            System.out.println("6");
        else if(s.contains("TUE"))
            System.out.println("5");
        else if(s.contains("WED"))
            System.out.println("4");
        else if(s.contains("THU"))
            System.out.println("3");
        else if(s.contains("FRI"))
            System.out.println("2");
        else
            System.out.println("1");
    }
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
const int N=85;
int a[N][N],b[N][N];
int f[N][N][N*N*2];
int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=m;j++) {
			scanf("%d",&a[i][j]);
		}
	}
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=m;j++) {
			scanf("%d",&b[i][j]);
		}
	}
	f[1][1][abs(a[1][1]-b[1][1])]=1;
	int S=80*160;
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=m;j++) {
			if(i==1&&j==1) continue;
			int t=abs(a[i][j]-b[i][j]);
			for(int k=S;k>=0;k--) {
				f[i][j][abs(k-t)]|=f[i-1][j][k],f[i][j][abs(k-t)]|=f[i][j-1][k];
				if(k+t<=S) f[i][j][k+t]|=f[i-1][j][k],f[i][j][k+t]|=f[i][j-1][k];
			}
		}
	}
	for(int i=0;i<=S;i++) {
		if(f[n][m][i]) {
			printf("%d\n",i);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 385280
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end
a,b =gi
str = gsf.split('-')
puts str.size ==2 && a == str[0].length && b == str[1].length ? 'Yes' : 'No'


Measured memory_bytes: 2684
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main()
{
	ll n,b;
	vll a;
	cin >> n;
	rep(i,n){
		cin >> b;
		a.pb(b);
	}
	sort(all(a));
	Eunique(a);
	cout << (a.size()%2==0?a.size()-1:a.size()) << endl;;
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000


int main(){
	
	int A,B;
	cin>>A>>B;
	
	if(A+B>=10)cout<<"error"<<endl;
	else cout<<A+B<<endl;
	
	
	
	
    return 0;
}



Measured memory_bytes: 256
import math

a,b,C = map(int, input().split())
S = (1/2)*a*b*math.sin(math.radians(C))
L = (a**2+b**2-2*a*b*math.cos(math.radians(C)))**(1/2)+a+b
h = 2*S/a
print(S)
print(L)
print(h)



Measured memory_bytes: 5716
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        double a, b, c;
        a = sc.nextDouble();
        b = sc.nextDouble();
        c = sc.nextDouble();
        System.out.println(0.5 * a * b * Math.sin(Math.toRadians(c)));
        System.out.println(a + b + Math.sqrt(a*a+b*b - (2 * (a * b * Math.cos(Math.toRadians(c))))));
        System.out.println(b * Math.sin(Math.toRadians(c)));
    }
}


Measured memory_bytes: 28128
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
int n,len;
char s[10001];
int main()
{
//	ios::sync_with_stdio(false);
	cin>>n>>(s+1),len=strlen(s+1);
	for(res i=1;i<=len;++i) putchar('A'+(s[i]+n-'A')%26);puts("");
//	cout<<flush;
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

Measured memory_bytes: 256
//by Top1
#include <bits/stdc++.h>
     
#define f first
#define s second
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
 
const int inf = (1e9) + 1;
const int mod = 1e9 + 7;
const int maxn = 4e5 + 111;
     
using namespace std;

ll n, q, k;

struct matrix{
	ll a[55][55];
	matrix() {}
	void read(){
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				cin >> a[i][j];
	}
	void ans(){
		ll h = 0;
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++){
				h += a[i][j];
				h %= mod;
			}
		cout << h;
	}
	void write(){
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= n; j++)
				cout << a[i][j] << " ";
			cout << endl;
		}
	}
	void ff(){
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				a[i][j] = 0;
		for (int i = 1; i <= n; i++)
			a[i][i] = 1;
	}
	void operator *= (matrix y){
		ll g[55][55];
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= n; j++){
				ll h = 0;
				for (int q = 1; q <= n; q++){
					h += a[i][q] * y.a[q][j];
					h %= mod;
				}
				g[i][j] = h;
			}
		}
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				a[i][j] = g[i][j];
	}

};

matrix madpow(matrix x, ll b){
	matrix res;
	res.ff();
	while (b){
		if (b & 1)
			res *= x;
		x *= x;
		b >>= 1;
	}
	return res;
}

void solve(){                   
	cin >> n;

	cout << (n + 1) * n / 2;
}

main(){
    boost;
	                 	
	q = 1;

	while (q--){
		solve();
	}
}


Measured memory_bytes: 256
import re
import numpy as np
import math

n=input()

a = list(map(int, input().split()))

ans = 'APPROVED'
for i in a:
  if (i%2)>0:
    continue
  else:
    if ((i%3)>0) and ((i%5)>0):
      ans = 'DENIED'
      break

print(ans)


Measured memory_bytes: 21504
#include<bits/stdc++.h>
using namespace std;
int mygcd(int64_t a,int64_t b){
    if(a%b==0) return b;
    else return (mygcd(b,a%b));
}
int main(){
    int64_t A,B,C,D;
    cin>>A>>B>>C>>D;
    cout<<B-(B/C)-(B/D)+B/((C*D)/mygcd(C,D))-((A-1)-(A-1)/C-(A-1)/D+(A-1)/((C*D)/mygcd(C,D)))<<endl;
}

Measured memory_bytes: 256
#include <vector>

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

using namespace std;

typedef vector<int> vi;

// ?????£?????????????§£ (Strongly Connected Component)
// ????????°???????????°????????????????????£??¬??????????????? ???????????§
struct SCCGraph: public vector<vi> {

	vector<int> order;    // ????????????????????????(?????£?????????????£?????????????)
	vector<int> vs;   // ??°????????????
	vector<bool> used;    // ?????§???????????????

	using vector::vector;	// ?¶?????????????????????????
	SCCGraph(const vector<vi> &v): vector::vector(v) {}	// ??????????????????????????????????????¨???????????????

	// a -> b ????????????????????????push_back()??§?????????
	void add_edge(int a, int b){
		(*this)[a].push_back(b);
	}

	// scc()??§??????
	void dfs(int n, int k, vector<vi> &v, vector<vi> &rv){
		used[n] = true;
		order[n] = k;
		for(auto t: v[n]){
			if( !rv.empty() ) rv[t].push_back(n);	// ???????????°???????????????
			if( !used[t] ) dfs(t, k, v, rv);
		}
		vs.push_back(n);
	}

	// ?????£?????????????§£?????????
	int scc(){
		int N = size();
		used.assign(N, false);
		order.resize(N);
		vs.clear();
		vector<vi> rG(N), tmp;   // ????????????????????°????????¨
		for(int n=0; n < N; n++){
			if( !used[n] ) dfs(n, n, (*this), rG);
		}
		used.assign(N, false);
		int k = 0;
		for(int i = vs.size()-1; i >= 0; i--){
			if( !used[ vs[i] ] ) dfs(vs[i], k++, rG, tmp);
		}
		return k++;
	}

	// ?±????????????£????????????????????????????????????
	bool find(int x, int y){
		return order[x] == order[y];
	}

};
// ??¢??°??¨??????scc??????????????????????????????????????????????±????????????£??????????????????
vector<int> scc(const vector<vi> &v){
	SCCGraph g(v);
	g.scc();
	return g.order;
}


// 2-SAT ??????
class TwoSAT{
};


// test
// AOJ GRL_3_C (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_C&lang=jp)
int main(){
	int V, E;
	cin >> V >> E;
	//SCCGraph graph(V);
	vector<vi> edge(10005);
	rep(i,E){
		int s, t;
		cin >> s >> t;
		//graph.add_edge( s, t );
		edge[s].push_back( t );
	}

	//graph.scc();
	//rep(i,V) cout << "graph: " << i << " " << graph.order[i] << endl;

	auto g = scc(edge);

	int Q;
	cin >> Q;
	rep(i,Q){
		int u, v;
		cin >> u >> v;
		//cout << (int)graph.find(u, v) << endl;
		cout << (int)(g[u] == g[v]) << endl;
	}

	return 0;
}

Measured memory_bytes: 4900
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

ll extended_factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
        ans %= (ll)(1e9+7);
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

ll gcd(ll a, ll b){
  ll temp;
	while (a % b != 0){
		temp = b;
		b = a % b;
		a = temp;
	}
	return b;
}

ll lcm(ll a, ll b){
  return a * b / gcd(a,b);
}

char alphabet[] = {
    'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
};


int main(){
    int c[3][3];
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >> c[i][j];
        }
    }
    // 行方向
    for(int i=0; i<2; i++){
        if ( (c[i][0] - c[i][1]) != (c[i+1][0] - c[i+1][1]) ){
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i=0; i<2; i++){
        if ( (c[i][1] - c[i][2]) != (c[i+1][1] - c[i+1][2]) ){
            cout << "No" << endl;
            return 0;
        }
    }
    // 列方向
    for(int i=0; i<2; i++){
        if ( (c[0][i] - c[1][i]) != (c[0][i+1] - c[1][i+1]) ){
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i=0; i<2; i++){
        if ( (c[1][i] - c[2][i]) != (c[1][i+1] - c[2][i+1]) ){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    string s,t;
    cin >> s>>t;
    if(s.size()+1==t.size()&&t.substr(0,s.size())==s){
        cout << "Yes";
    }else {
        cout <<"No";
    }
    return 0;
}


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

int main() {

  set<int> s;
  for(int i=1; i<=30; i++)
    s.insert(i);

  int d;
  for(int i=0; i<28; i++) {
    cin>>d;
    s.erase(s.find(d));
  }

  set<int>::iterator it = s.begin();
  for(;it!=s.end();++it)
    cout<<(*it)<<endl;

}

Measured memory_bytes: 0
import numpy as np
H, W = map(int, input().split())
A = np.array([list(input()) for _ in range(H)])
del_i = []
for i in range(H):
    if all(A[i, :] == '.'):
        del_i.append(i)
del_j = []
for j in range(W):
    if all(A[:, j] == '.'):
        del_j.append(j)
A = np.delete(A, del_i, 0)
A = np.delete(A, del_j, 1)
for i in range(A.shape[0]):
    print(''.join(A[i]))

Measured memory_bytes: 12536
#include <cstdint>

using namespace std;

struct node_t {
  int64_t val;
  node_t *parent;
  node_t *left;
  node_t *right;
};

static node_t *root = nullptr;

static node_t *create_node(int64_t val, node_t *parent)
{
  node_t *node = new node_t;
  node->val = val;
  node->parent = parent;
  node->left = nullptr;
  node->right = nullptr;
  return node;
}

static void insert_node(node_t *node, int64_t val)
{
  if (val < node->val) {
    node_t *left = node->left;
    if (left != nullptr) {
      insert_node(left, val);
    } else {
      node->left = create_node(val, node);
    }
  } else {
    node_t *right = node->right;
    if (right != nullptr) {
      insert_node(right, val);
    } else {
      node->right = create_node(val, node);
    }
  }
}

void binary_search_tree_insert(int64_t val)
{
  if (root == nullptr) {
    root = create_node(val, nullptr);
  } else {
    insert_node(root, val);
  }
}

static void walk(node_t *node, void (*preorder)(int64_t), void (*inorder)(int64_t), void (*postorder)(int64_t))
{
  if (node == nullptr) return;

  if (preorder != nullptr) preorder(node->val);

  walk(node->left, preorder, inorder, postorder);
  if (inorder != nullptr) inorder(node->val);

  walk(node->right, preorder, inorder, postorder);
  if (postorder != nullptr) postorder(node->val);
}

void binary_search_tree_walk(void (*preorder)(int64_t), void (*inorder)(int64_t), void (*postorder)(int64_t))
{
  walk(root, preorder, inorder, postorder);
}

static bool find(node_t *node, int64_t val)
{
  if (node == nullptr) return false;

  if (node->val == val) {
    return true;
  } else if (val < node->val) {
    return find(node->left, val);
  } else {
    return find(node->right, val);
  }
}

bool binary_search_tree_find(int64_t val)
{
  return find(root, val);
}

#if !defined(TEST)
#include <iostream>
#include <string>
#include <vector>

static vector<int64_t> pre;
static vector<int64_t> in;

static void print_vector(vector<int64_t> &vec)
{
  for (uint32_t i = 0; i < vec.size(); i++) {
    cout << " " << vec[i];
  }
  cout << endl;
}

static void preorder(int64_t val)
{
  pre.push_back(val);
}

static void inorder(int64_t val)
{
  in.push_back(val);
}

int32_t main()
{
  uint32_t num;
  cin >> num;

  for (uint32_t i = 0; i < num; i++) {
    string command;
    cin >> command;
    if (command[0] == 'i') {
      int64_t val;
      cin >> val;
      binary_search_tree_insert(val);
    } else if (command[0] == 'f') {
      int64_t val;
      cin >> val;
      if (binary_search_tree_find(val)) {
        cout << "yes";
      } else {
        cout << "no";
      }
      cout << endl;

    } else if (command[0] == 'p') {
      pre.clear();
      in.clear();
      binary_search_tree_walk(preorder, inorder, nullptr);
      print_vector(in);
      print_vector(pre);
    }
  }

  return 0;
}
#endif

Measured memory_bytes: 28000
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <cstring>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef multiset<int> MS;
typedef queue<int> Q;

int main(){
    int n; cin>>n;
    int a[n];
    for(int i=0; i<n; i++)
        cin>>a[i];
    ll cnt1 = 0;
    int acu1[n];
    for(int i=0; i<n; i++){
        if(i<1)
            acu1[i] = a[i];
        else
            acu1[i] = a[i]+acu1[i-1];

        if(i&1 && acu1[i]>=0){
            cnt1 += acu1[i]+1;
            acu1[i] = -1;
        }
        else if(!(i&1) && acu1[i]<=0){
            cnt1 += -acu1[i]+1;
            acu1[i] = 1;
        }
    }
    ll cnt2 = 0;
    int acu2[n];
    for(int i=0; i<n; i++){
        if(i<1)
            acu2[i] = a[i];
        else
            acu2[i] = a[i]+acu2[i-1];

        if(!(i&1) && acu2[i]>=0){
            cnt2 += acu2[i]+1;
            acu2[i] = -1;
        }
        else if(i&1 && acu2[i]<=0){
            cnt2 += -acu2[i]+1;
            acu2[i] = 1;
        }
    }
    OUT(min(cnt1, cnt2));
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
    return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
int h,w,k,d[810][810],ans=INF;
char c[810][810];
queue<P>q;
signed main(){
	cin>>h>>w>>k;
	rep(i,h){
		rep(j,w){
			cin>>c[i][j];
			if(c[i][j]=='S')q.push({i,j});
			else d[i][j]=INF;
		}
	}
	while(!q.empty()){
		P p=q.front();
		q.pop();
		int x=p.fi,y=p.se;
		rep(i,4){
			int nx=x+dx[i],ny=y+dy[i];
			if(0<=nx&&nx<h&&0<=ny&&ny<w){
				if(c[nx][ny]=='#')continue;
				if(d[nx][ny]>d[x][y]+1){
					d[nx][ny]=d[x][y]+1;
					q.push({nx,ny});
				}	
			}
		}
	}
	rep(i,h){
		rep(j,w){
			if(d[i][j]<=k){
				int mi=min({i,h-i-1,j,w-j-1});
				ans=min(ans,(mi-1+k)/k);
			}
		}
	}
	cout<<ans+1<<endl;
    return 0;
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
        using namespace std;
        int main(){
			long long n,m,a[200005],b[200005],c[200005]={};
			cin>>n>>m;
			for(int i=0;i<m;i++){
				cin>>a[i]>>b[i];
				if(b[i]==n){
					c[a[i]]=1;
					
				}
			}
			for(int i=0;i<m;i++){
				if(a[i]==1){
                    if(c[b[i]]==1){
					cout<<"POSSIBLE"<<endl;
					return(0);
                  }
                }
            }
			cout<<"IMPOSSIBLE"<<endl;
    		return(0);
        }

Measured memory_bytes: 4992