akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
inf = float('inf')
mod = 10**9+7


def mi(): return map(int, input().split())


def li(): return list(mi())


def li_(): return [int(x) - 1 for x in input().split()]


def lin(n: int): return [input() for _ in range(n)]


def llin(n: int): return [li() for _ in range(n)]


def llin_(n: int): return [li_() for _ in range(n)]


def lli(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def f(): return float(input())


def s(): return input().replace('\n', '')


def main():
    N = I()
    ABC = llin(N)
    dp = [[0] * 3 for _ in range(N)]
    dp[0] = ABC[0]
    for i in range(1, N):
        for j in range(3):
            dp[i][j] = max((ABC[i][j]+dp[i - 1][k]
                            for k in range(3) if k != j))
    print(max(dp[N-1]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 71260
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  
  for (int i = 0; i< N; i++) {
    cin >> d.at(i);
  }

  int x = N;
  
  for (int i = 0; i< N; i++) {
    for (int j = i + 1; j< N; j++) {
      
      if (d.at(i) == d.at(j)) {
        x--;
        break;
      }
    }    
  }
  cout << x << endl;
}


Measured memory_bytes: 256
S = sorted(input())
T = sorted(input(),reverse=True)
A = "No"
for sc,tc in zip(S,T):
    if sc == tc:
        continue
    elif sc < tc:
        A = "Yes"
        break
    else:
        break
if S == T[:len(S)] and len(S) < len(T):
    A = "Yes"
print(A)

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

using namespace std;
typedef long long ll;

int main() {
 int a,b,c,d,e,k;
 cin >> a >> b >> c >> d >> e >> k;
 if(e-a<=k){
     cout << "Yay!" << endl;
 }
 else{
     cout << ":(" << endl;
 }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll,ll>
#define pint pair<int,int>
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 100001
#define endl '\n'
#define mp make_pair
#define INF 1000000000
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ff first
#define ss second
#define ps(x,y) fixed<<setprecision(y)<<x
#define setbits(x) __builtin_popcountll(x)			//counts no of ones in binary representation
#define w(t) 	int t; cin>>t; while(t--)
#define pi 3.141592653589793238
#define sortt(v)  sort(v.begin(),v.end())
#define lb(v,x) std::lower_bound(v.begin(),v.end(),x)
#define ub(v,x) std::upper_bound(v.begin(),v.end(),x)

using namespace std;
 

int main() {
	fast;
	ll n,m,a,b,c,d;
	string s,t;
	cin>>a>>b;
	cout<<a*b;
}


 

Measured memory_bytes: 3648
S = input()
T = input()
list_a = []
if len(S) - len(T) ==0:
    cnt = 0
    for j in range(len(T)):
        if T[j] != S[j]:
            cnt += 1
    list_a.append(cnt)
else:
    for i in range(len(S) - len(T)):
        cnt = 0
        for j in range(len(T)):
            if T[j] != S[i + j]:
                cnt += 1
        list_a.append(cnt)
print(min(list_a))

Measured memory_bytes: 9024
/*A - Red or Not*/

#include <bits/stdc++.h>

using namespace std;

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	string cad;
	int num;

	cin >> num;
	cin >> cad;

	if(num >= 3200)
		cout << cad;
	else
		cout << "red";

	return 0;
}


Measured memory_bytes: 256
# A
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]#(h,w)
mine=[[0 for i in range(w)]for j in range(h)]
# 8方向
# #(-1,1)  #(0,1)  #(1,1)
# #(-1,0)    (#)   #(1,0)
# #(-1,-1) #(0,-1) #(1,-1)

dx = [0, 1, 1, 1, 0, -1, -1, -1]
dy = [-1, -1, 0, 1, 1, 1, 0, -1 ]
# print(s,mine)
for i in range(h):
    for j in range(w):
        # print(i,j)
        if s[i][j] == "#":
            mine[i][j]="#"
            for k in range(len(dx)):
                nx = i + dx[k]
                ny = j + dy[k]
                # print("m:",nx,ny)
                if 0 <= nx < h and 0 <= ny < w:
                    if s[nx][ny] != "#":
                        mine[nx][ny] += 1
for i in mine:
    print(*i,sep="")

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int n;
    cin>>n;
    vector<pair<string,pair<int,int>>> pa(n);
    for(int i=0;i<n;i++){
        string s;
        int tmp;
        cin>>s>>tmp;
        pa[i]={s,{tmp,i+1}};
    }
    sort(pa.begin(),pa.end());
    vector<int> ans;
    int pos=0;
    while(pos<n){
        vector<P> v;
        v.push_back({pa[pos].second.first,pa[pos].second.second});
        string s=pa[pos++].first;
        for(;pos<n;pos++){
            if(s==pa[pos].first){
                v.push_back({pa[pos].second.first,pa[pos].second.second});
            }else{
                break;
            }
        }
        sort(v.rbegin(),v.rend());
        for(int j=0;j<v.size();j++) ans.push_back(v[j].second);
    }
    for(int i=0;i<n;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int min = 55;
    for(int i=2;i<=N/2;i++){
      int a=i;
      int b=N-i;
      int sum = method(a)+method(b);
      if(sum<min){
        min=sum;
      }
    }
    if(N!=2){
      System.out.println(min);
    }else{
      System.out.println(2);
    }

  }

  static int method(int x){
    return x/100000+(x/10000)%10+(x/1000)%10+(x/100)%10+(x/10)%10+x%10;
  }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
#define printd(x) printf("%.12f\n", ans);
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

const int inf = 1e9 + 10;

int main(void) {
    
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    //ios::sync_with_stdio(false); cin.tie(0);

    string s;
    cin >> s;

    int n = s.size();

    s += 'x';

    int ans1 = 0, ans2 = inf;
    
    rep (i, n) {
        if (s[i] != s[i + 1]) ans1++;
    }
    
    cout << ans1 - 1 << endl;
    return 0;
}


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

int main()
{
  ll n;
  cin >> n;
  
  int tmp = n;
  int sum = 0;
  while(tmp > 0){
    sum += tmp % 10;
    tmp /= 10;
  }
  
  if(n % sum == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int H, A;
  cin >> H >> A;
  int ans = (H + A - 1) / A;
  cout << ans << '\n';
  return 0;
}

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

#define make_it_fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define ll long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define imn INT_MIN
#define imx INT_MAX

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}

template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}

void _print() {cerr << "]\n";}

template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...) 20
#endif

ll power(ll a,ll b,ll m=1e9+7)
{
    a%=m;
    if(b==1)
    return a;
    if(b==0)
    return 1;
    ll ret=power(a,b/2);
    ret=(ret*ret)%m;
    if(b&1)
    ret=(ret*a)%m;
    return ret;
}

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

void solve()
{
    float x;
    cin>>x;
    if(x==0)
    cout<<1<<endl;
    if(x==1)
    cout<<0<<endl;
}

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


Measured memory_bytes: 3744
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<list>
#include<queue>
#include<string.h>
#include<functional>
#include<stack>
#include<deque>
#include<string>
#include<limits.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
using namespace std;

int a[300][300];
int b[300];//今の値
int c[300];//iの個数
signed main() {
	int n, m; cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
			a[i][j]--;
		}
	}
	int ans = n;
	for (int i = 0; i < n; i++) {
		c[a[i][0]]++;
	}
	int k = 0;
	set<int>S;
	while (++k<500) {
		int MAX = 0;
		for (int j = 0; j < m; j++) {
			MAX = max(MAX, c[j]);
		}
		ans = min(ans, MAX);
		for (int j = 0; j < m; j++) {
			if (c[j] == MAX) {
				S.insert(j);
			}
		}
		for (int i = 0; i < n; i++) {
			while (binary_search(S.begin(), S.end(), a[i][b[i]])) {
				if (b[i] + 1 == m)goto l;
				c[a[i][b[i]]]--;
				c[a[i][b[i] + 1]]++;
				b[i]++;
			}
		}
	}
l:;
	cout << ans << endl;
}

Measured memory_bytes: 640
n = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def co(n):
  i=1
  c=0
  while True:
    n=n-i
    #print(n)
    if n>=0:
      c+=1
    else:
      break
    i+=1
  return c

a=factorization(n) 
#print(a)

ans=0
for i,j in a:
  if i==1:
    continue
  ans += co(j)

print(ans)

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

int N, L, A[100002], T[100002], ans = 0;
int main()
{
  cin >> N >> L;
  N += 2;
  for(int i = 1; i < N - 1; i++)
    cin >> A[i];
  queue<int> q;
  for(int i = 1; i < N - 1; i++)
    if(A[i] > A[i - 1] && A[i] > A[i + 1])
      q.push(i);
  while(!q.empty())
  {
    int n = q.front(); q.pop();
    int t = T[n] + L - A[n];
    ans = max(ans, t);
    T[n + 1] = max(T[n + 1], t);
    T[n - 1] = max(T[n - 1], t);
    A[n] = 0;
    if(n > 1 && A[n - 1] > A[n - 2])
      q.push(n - 1);
    if(n < N - 2 && A[n + 1] > A[n + 2])
      q.push(n + 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2132
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int,int> P;
typedef long long ll;
const ll mod=1000000007;


main(){
  string s;cin>>s;
  int n=s.size();
  if(s.at(n-1)=='s'){
    s+="es";
  } else{
    s+="s";
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3624
use std::collections::VecDeque;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };

    let n: usize = sc.read();
    let m: usize = sc.read();
    let mut graph = vec![vec![]; n];
    for _ in 0..m {
        let u = sc.read::<usize>() - 1;
        let v = sc.read::<usize>() - 1;
        graph[v].push(u);
        graph[u].push(v);
    }

    let q: usize = sc.read();
    let queries = (0..q)
        .map(|_| (sc.read::<usize>() - 1, sc.read::<usize>(), sc.read::<u32>()))
        .collect::<Vec<_>>();
    let mut color = vec![0; n];

    let mut dist = vec![0; n];
    for (v, d, c) in queries.into_iter().rev() {
        let mut q = VecDeque::new();
        if color[v] == 0 {
            color[v] = c;
        }
        q.push_back((v, d));
        while let Some((v, d)) = q.pop_front() {
            if d == 0 {
                continue;
            }
            for &next in graph[v].iter() {
                if color[next] == 0 {
                    color[next] = c;
                }
                if dist[next] < d - 1 {
                    dist[next] = d - 1;
                    q.push_back((next, dist[next]));
                }
            }
        }
    }

    for color in color.into_iter() {
        println!("{}", color);
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 20732
#!/usr/bin/env python3
n, a, b, c, d = map(lambda x: int(x) - 1, input().split())
s = input()

if d < c:
    f = False
    for i in range(n)[b:d + 1]:
        if '...' in s[i - 1:i + 2]:
            f = True
    if not f:
        print('No')
        exit()
    a, b = b, a
    c, d = d, c
print(['Yes', 'No']['##' in s[a:d + 1]])


Measured memory_bytes: 3572
judge="abcdefghijklmnopqrstuvwxyz"
results=[0]*26
while True:
    try:
        str=input()
    except:
        break
    for i in range(len(str)):
        for j in range(0,26):
            if str[i]==judge[j] or str[i]==judge[j].upper():
                results[j]+=1
for i in range(0,26):
    print(judge[i],":",results[i])


Measured memory_bytes: 5560
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s; cin>>s;
  int K; cin>>K;int k=K;
  int N=s.size();
  int64_t ans=0;
  for(int i=0;i<N;i++){
  int64_t a=s.at(i)-'0';
    if(a!=0){
      int64_t b=1;
    for(int64_t j=1;j<=K;j++)
      b=(b*(N-i-j)*9)/j;
      if(K!=1){
      int64_t c=1;
        for(int64_t j=1;j<=K-1;j++)
          c=(c*(N-i-j)*9)/j;b+=(a-1)*c;
      }
      if(K==1){b+=a-1;}ans+=b; K--; if(K==0)break;
      
    }
  }for(int i=0;i<N;i++)
    if(s.at(i)!='0')k--;
  if(k<=0)ans++;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<queue>
#include<set>
#include<cstring>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef long long LL;
const int MAXN=1e5+5;
int a[MAXN];
map<int,int> mp;

bool cmp(int x,int y)
{
    return x>y;
}

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        mp.clear();
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
            mp[a[i]]++;
        }
        sort(a+1,a+n+1,cmp);
        int len=unique(a+1,a+n+1)-(a+1);
        //cout<<len<<endl;
        LL ans=-1;
        LL ma1=-1,ma2=-1;
        for(int i=1;i<=len;i++)
        {
            if(mp[a[i]]>=4)
            {
                if(ma1==-1) ma1=a[i];
                else if(ma2==-1) ma2=a[i],ans=max(ans,ma1*ma2);
                ans=max((LL)a[i]*a[i],ans);
            }else if(mp[a[i]]>=2)
            {
                if(ma1==-1) ma1=a[i];
                else if(ma2==-1) ma2=a[i],ans=max(ma1*ma2,ans);
            }
        }
        if(ans!=-1)  printf("%lld\n",ans);
        else printf("0\n");
    }
    return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main(){
  string s; cin >> s;
  int sum = 0;
  for(auto c : s) {
    sum += (c-'0');
    sum %= 9;
  }
  if(sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

constexpr int MAX=10000;
constexpr int NIL=-1;

struct Node{
   int left;
   int right;
   int parent;
};

Node node[MAX];

void preorder(int u){
   if(u==NIL) return;
   cout << " " << u;
   preorder(node[u].left);
   preorder(node[u].right);
}

void inorder(int u){
   if(u==NIL) return;
   inorder(node[u].left);
   cout << " " << u;
   inorder(node[u].right);
}

void postorder(int u){
   if(u==NIL) return;
   postorder(node[u].left);
   postorder(node[u].right);
   cout << " " << u;
}

int main(){
   int left, right, root, value, n;
   cin >> n;
   for(int i=0; i<n; i++){
      node[i].parent=NIL;
   }

   for(int i=0; i<n; i++){
      cin >> value >> left >> right;
      node[value].left=left;
      node[value].right=right;
      if(left!=NIL) node[left].parent=value;
      if(right!=NIL) node[right].parent=value;
   }

   for(int i=0; i<n; i++) if(node[i].parent==NIL) root=i;

   cout << "Preorder" << endl;
   preorder(root);
   cout << endl;
   cout << "Inorder" << endl;
   inorder(root);
   cout << endl;
   cout << "Postorder" << endl;
   postorder(root);
   cout << endl;
}



Measured memory_bytes: 3136
# -*- coding: utf-8 -*-

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def nCr(n, r):
    # 10C7 = 10C3
    r = min(r, n-r)
    return factorial(n) // (factorial(r) * factorial(n-r))

N, P = MAP()
aN = LIST()

# この問題では偶奇しか関係しないのでmod 2する
for i in range(N):
    aN[i] %= 2
c = Counter(aN)

ans = 0
# 最終的に偶奇どっちにするかによって、奇数を取る数を変える
if P == 0:
    # 奇数を偶数個取る組み合わせ
    for i in range(0, c[1]+1, 2):
        ans += nCr(c[1], i)
else:
    # 同じように奇数個取る組み合わせ
    for i in range(1, c[1]+1, 2):
        ans += nCr(c[1], i)
# 偶数の数は偶奇の変化に影響を与えないので、取るor取らないの全組み合わせ(2**偶数の数)をかける
print(ans * 2**c[0])


Measured memory_bytes: 5284
#include<bits/stdc++.h>
using namespace std;
int main() {
  int h, n;
  cin >> h >> n;
  while(n--){
    int x;
    cin >> x;
    if((h -=x) <=0){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  }

Measured memory_bytes: 384
def palindrome(x):
    reverse = x[::-1]
    for i in range(len(x)):
        if (x[i] != reverse[i]):
            return False
    return True

c = input()
l = len(c)
print(["No","Yes"][palindrome(c) & palindrome(c[:(l-1)//2])& palindrome(c[(l+2)//2:])])

Measured memory_bytes: 3060
class UnionFind():
    def __init__(self, n):
        self.par = [-1 for i in range(n)]

    def root(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.root(self.par[x]) # contraction
            return self.par[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            if self.par[x] > self.par[y]: # merge technique
                x, y = y, x
            self.par[x] += self.par[y]
            self.par[y] = x

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.par[self.root(x)]


n, m = map(int, input().split())
uf = UnionFind(n)
for i in range(m):
    x, y, z = map(int, input().split())
    x -= 1
    y -= 1
    uf.unite(x, y)

par = [uf.root(i) for i in range(n)]
print(len(set(par)))


Measured memory_bytes: 13984
// #pragma GCC optimize "trapv" Uncomment when dealing with huge numbers
/*<----------PBDS---------->

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
template <typename T>
using order_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

order_set<datatype>oset;
Kth smallest : *oset.find_by_order(k-1); // 0 based index
No of elements less than k : oset.order_of_key(k);
Erase X : oset.erase(x)
<----------PBDS---------->*/
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
		int n,m; 
		cin >> n >> m;
		if(n==1 && m==0){
			cout<<"0";
			return 0;
		}
		int a[n+1];
		memset(a,0,sizeof(a));
		bool can=true;
		vector<int>vis(n,0);
		int p=m;
		while(p--)
		{
			int x,y; 
			cin >> x >> y;
			x--;
			if(vis[x] && y!=a[x])
			{
				can=false; break;
			}
			vis[x]=1;
			a[x]=y;
		}
		string l="";
		if(!vis[0])
		{
			a[0]=1;
		}
		for(int i=0;i<n;i++)
		{
			l+=(a[i]+'0');
		}
 
		if(l.length()<n ||l.length()>n|| can==false || (l[0]=='0' && n!=1))
		{
			cout<<-1;return 0;
		}
		cout<<l;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int q = sc.nextInt();
        int[] points = new int[n];
        int scNum;

        for (int i = 0; i < q; i++) {
            points[sc.nextInt() - 1]++;
        }

        for (int i = 0; i < n; i++) {
            if (k - (q - points[i]) <= 0) {
                System.out.println("No");
            } else {
                System.out.println("Yes");
            }
        }

    }
}

Measured memory_bytes: 54724
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;
use std::ops::Bound::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let s = read::<String>();
    let mut count = vec![0; 26];
    for ch in s.chars() {
        count[ch.to_digit(36).unwrap() as usize - 10] += 1;
    }
    if count.iter().all(|&x| x % 2 == 0) {
        println!("Yes");
    } else {
        println!("No");
    }
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2140
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */

#include <bits/stdc++.h>
//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class EBalancedPath {
    static const int MAXDIFF = (2 * 80 - 1) * (2 * 80 + 1);
    static const int DELTA = MAXDIFF / 2;

public:
    void solve(std::istream &in, std::ostream &out) {
        int h, w;
        in >> h >> w;
        vector<vector<int>> A(h, vector<int>(w)), B = A;
        for (auto &vec: A) {
            for (int &x: vec) {
                in >> x;
            }
        }
        for (auto &vec: B) {
            for (int &x: vec) {
                in >> x;
            }
        }
        vector<vector<bitset<MAXDIFF>>> dp(2, vector<bitset<MAXDIFF>>(w));
        for (int i = 0; i < h; ++i) {
            int now = i & 1, pre = now ^1;
            for (int j = 0; j < w; ++j) {
                dp[now][j] = 0;
                int d = abs(A[i][j] - B[i][j]);
                if (i == 0 and j == 0) {
                    dp[now][j].set(DELTA - d);
                    dp[now][j].set(DELTA + d);
                }
                if (i) {
                    dp[now][j] |= (dp[pre][j] >> d) | (dp[pre][j] << d);
                }
                if (j) {
                    dp[now][j] |= (dp[now][j - 1] >> d) | (dp[now][j - 1] << d);
                }
            }
        }
        int res = MAXDIFF;
        bitset<MAXDIFF> possible = dp[(h - 1) & 1][w - 1];
        for (int i = 0; i < MAXDIFF; ++i) {
            if (possible.test(i)) {
                res = min(res, abs(i - DELTA));
            }
        }
        out << res << "\n";
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    EBalancedPath solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


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

int main() {
	int64_t N, K;
	cin >> N >> K;
	vector<int> P(N), C(N);
	for (int& e : P) {
		cin >> e;
		--e;
	}
	for (int& e : C) cin >> e;

	vector<int> done(N);
	int64_t ans = LLONG_MIN;
	for (int i = 0; i < N; ++i) if (!done[i]) {
		done[i] = 1;
		vector<int> cyc = {i};
		int at = i;
		int64_t ccost = C[i];
		while (P[at] != i) {
			at = P[at];
			cyc.push_back(at);
			ccost += C[at];
			done[at] = 1;
		}
		for (int a = 0; a < cyc.size(); ++a) {
			int64_t cost = 0;
			for (int b = (a+1)%cyc.size(), mvs = 1; mvs <= min(K,(int64_t)cyc.size()); b=(b+1)%cyc.size(),++mvs) {
				cost += C[cyc[b]];
				int rem = K-mvs;
				if (rem >= cyc.size() && ccost > 0) {
					ans = max(ans, cost+ccost*(rem/(int64_t)cyc.size()));
				} else {
					ans = max(ans, cost);
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
int main(){
    int n;
    cin >> n;
    ll L[n];
    rep(i,n){
        cin >> L[i];
    }
    int sum=0;
    rep(i,n-2){
        for(int j=i+1; j<n-1; j++){
            for(int k=j+1; k<n; k++){
              if (L[i]==L[j] || L[i]==L[k] || L[j]==L[k]) continue;
                if(L[i]<L[j]+L[k] && L[j]<L[i]+L[k] && L[k]<L[i]+L[j]) {
                  sum++;
                }
            }
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>

using namespace std; 

string list = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main()
{
	int n, l, p;
	string s, ans;

	while(cin >> n){
		if(n==0){return 0;}
		ans = "";
		int* key = new int[n];
		for(int i=0; i<n; i++){ cin >> key[i];}
		cin >> s;
		l = s.length();
		for(int i=0; i<l; i++){ 
			p = list.find(s.substr(i,1)) - key[i%n];
			if(p<1){ p+=104; p=p%52;}
			ans += list.substr(p,1);
		}
		cout << ans << endl;
	}	
}

Measured memory_bytes: 1216
fun main(args: Array<String>) {
  val s = readLine()!!
  val n = s.length
  val f = (0 until n / 2).any { s[it] != s[n - it - 2] }
  if (s[0] != '1' || s[n - 1] != '0' || f) {
    println(-1)
    return
  }
  val list = Array<Int>(n + 1) { it }.filter { it > 0 && s[it - 1] == '1' }.sorted()
  var p = 1
  var c = 1
  for (m in list) {
    while (c < m + 1) {
      c++
      println("$p $c")
    }
    p = c
  }
}


Measured memory_bytes: 46544
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <bitset>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

const int MAX_BIT = 32;
const int MAX_N = 100010;
int N;
long long K, A[MAX_N], B[MAX_N];

long long value(std::bitset<MAX_BIT> bs) {
    long long ret = 0;
    for (int i = 1; i <= N; i++) {
        if ((bs | std::bitset<MAX_BIT>(A[i])) == bs) {
            ret += B[i];
        }
    }
    return ret;
}

int main(int argc, char **argv) {
    std::cin >> N >> K;

    for (int i = 1; i <= N; i++) {
        std::cin >> A[i] >> B[i];
    }

    std::bitset<MAX_BIT> bs(K);

    long long ret = value(bs);

    for (int i = 0; i < MAX_BIT; i++) {
        if (bs.test(i)) {
            std::bitset<MAX_BIT> tmp = bs;
            tmp.reset(i);
            for (int j = 0; j < i; j++) {
                tmp.set(j);
            }
            ret = std::max(ret, value(tmp));
        }
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//????????????????????????????????????
#define int long long
#define str string
const int inf = 999999999999999999;
struct P {
	int pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	int to, cost;
};
int gcm(int i, int j) {//?????§??¬?´???°
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
bool sfind(string s, string l) {//?????????1??????????????????2????????????
	for (int i = 0; i <= s.size() - l.size(); i++) {
		str t = "";
		for (int j = 0; j < l.size(); j++)
			t += s[i + j];
		if (t == l)
			return 1;
	}
	return 0;
}
typedef long long ll;
typedef long double ld;
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
//---------------------------------------------------
signed main() {
	int n;
	cin >> n;
	getchar();
	for (int r = 0; r < n; r++) {
		string s;
		getline(cin, s);
		for (int i = 0; i < 26; i++) {
			for (int j = 0; j < 26; j++) {
				string a = "";
				for (int z = 0; z < s.size(); z++) {
					if (s[z] == ' ')
						a += " ";
					else
						a += (char)((((s[z] - 'a')*i + j) % 26) + 'a');
				}
				if (sfind(a, "that") || sfind(a, "this")) {
					cout << a << endl;
					goto stop;
				}
			}
		}
	stop:;
	}
	getchar(); getchar();
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

signed main(){
    ll n,k;
    cin >> n >> k;
    ll sum[n+1] = {},ans = 0;

    rep(i,1,n+1) sum[i] = sum[i-1]+i;

    rep(i,k,n+2){
        if(n-i >= 0) ans += (sum[n] - sum[n-i]) - sum[i-1] + 1;
        else ans += 1;
        ans %= (ll)(1e9+7);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5100
#include<iostream>
using namespace std;
int main()
{
int x,y,z;
cin>>x>>y>>z;
if(x==y && x!=z)
{
cout<<"Yes";
}
else if(y==z && z!=x)
{
 cout<<"Yes";
}
else if(x==z && x!=y)
{
 cout<<"Yes";
}
else
{
 cout<<"No";
}
return 0;
}

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

int main() {
	double n;
	while(cin>>n&&n!=0.0){
	double s[1000],m=0.0;for(int i=0;i<n;i++)cin>>s[i],m+=s[i];
	m/=n;
	double a=0;for(int i=0;i<n;i++)a+=(s[i]-m)*(s[i]-m);
	a/=n;
	cout<<fixed<<setprecision(5)<<sqrt(a)<<endl;
	}
	return 0;
}

Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // Atcoder
    // template: cpp
    ll n, k;
    cin >> n >> k;
    vector<ll> x(n);
    rep(i, n) cin >> x[i];

    ll ans = 0;
    rep(i, n) { ans += 2 * min(abs(0 - x.at(i)), abs(x.at(i) - k)); }
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> dp(n+10,1000000);
	dp[0]=0;
	rep(i,n+1){
		dp[i+1]=min(dp[i+1],dp[i]+1);
		for(ll j=6;i+j<=n;j*=6) dp[i+j]=min(dp[i+j],dp[i]+1);
		for(ll j=9;i+j<=n;j*=9) dp[i+j]=min(dp[i+j],dp[i]+1);
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 640
num = [
    1,
    1,
    1,
    2,
    1,
    2,
    1,
    5,
    2,
    2,
    1,
    5,
    1,
    2,
    1,
    14,
    1,
    5,
    1,
    5,
    2,
    2,
    1,
    15,
    2,
    2,
    5,
    4,
    1,
    4,
    1,
    51,
]
input = int(input())
print(num[input - 1])


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    int a[n][m]={{0}};
    int b[m][1]={{0}};
    for(int i=0;i<n;i++){
        for(int r=0;r<m;r++){
            cin >> a[i][r];
        }
    }
    for(int i=0;i<m;i++){
        cin >> b[i][1];
    }
    for(int i=0;i<n;i++){
        int ans=0;
        for(int r=0;r<m;r++){
            ans+=a[i][r]*b[r][1];
        }
        cout << ans << endl;
    }
}


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

int main() {
    int N;
    long long K;
    cin >> N >> K;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
        
    long long res = 0;
    for (int d = 60; d >= -1; --d) { // d = -1 は X = K の場合
        if (d != -1 && !(K & (1LL<<d))) continue;
        
        long long tmp = 0;
        for (int e = 60; e >= 0; --e) {
            long long mask = 1LL<<e;
            int num = 0;
            for (int i = 0; i < N; ++i) if (A[i] & mask) ++num;
            
            if (e > d) {
                if (K & mask) tmp += mask * (N - num);
                else tmp += mask * num;
            }
            else if (e == d) {
                tmp += mask * num;
            }
            else {
                tmp += mask * max(num, N - num);
            }
        }
        res = max(res, tmp);
    }
    cout << res << endl;
}

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

using namespace std;

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

    int ans = 0;
    for (int i = 0; i < (int)s.size(); i++)
    {
        string t = s.substr(0, i);
        string u = s.substr(i);
        int cnt = 0;
        // cout << t << " " << u << endl;
        vector<int> num1(30), num2(30);
        for (int j = 0; j < (int)t.size(); j++)
        {
            num1[t[j] - 'a']++;
        }
        for (int j = 0; j < (int)u.size(); j++)
        {
            num2[u[j] - 'a']++;
        }
        for (int j = 0; j < 30; j++)
        {
            // cout << num1[j] << " " << num2[j] << endl;
            if (num1[j] > 0 && num2[j] > 0)
                cnt++;
        }
        // cout << endl;
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

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

#define COLS 8
#define ROWS 8

using namespace std;

void ExplodeBomb(int map[][COLS+6], int x, int y){
	int dij[] = {1,2,3,-1,-2,-3};
	
	if( map[y + 3][x + 3] == 0 ) return;
	map[y + 3][x + 3] = 0;

	for(int i = 0; i < sizeof(dij)/sizeof(*dij); i++){
		ExplodeBomb(map, x, y + dij[i]);
	}
	for(int j = 0; j < sizeof(dij)/sizeof(*dij); j++){
		ExplodeBomb(map, x + dij[j], y);
	}
}

int main(void){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		int x, y;
		int map[ROWS+6][COLS+6] = {{0,},};
		char buf[32];
		string s;
		
		cin.getline(buf,sizeof(buf)/sizeof(*buf));
		for(int j = 0; j < ROWS; j++){
			cin >> s;
			for(unsigned int k = 0; k < s.length(); k++){
				if( s[k] == '1' ) map[j+3][k+3] = 1;
			}
		}
		cin >> x >> y;
		cin.ignore();

		ExplodeBomb( map, x - 1, y - 1 );

		cout << "Data " << i + 1 << ":\n";
		for(int j = 0; j < ROWS; j++){
			for(int k = 0; k < COLS; k++){
				cout << map[j + 3][k + 3]; 
			}
			cout << '\n';
		}

	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int R, C;
char maze[50][50];
int dis[500][500];
const int inf = 0x3f3f3f3f;
void init()
{
    int dr[] = {1, 0, -1, 0};
    int dc[] = {0, 1, 0, -1};
    for (int i = 0; i < R * C; i++)
    {
        for (int j = i; j < R * C; j++)
        {
            if (i == j)
            {
                dis[i][j] = 0;
                continue;
            }
            int ri = i / C, ci = i % C, rj = j / C, cj = j % C;
            if (maze[ri][ci] == '#' || maze[rj][cj] == '#')
            {
                dis[i][j] = inf;
                dis[j][i] = inf;
                continue;
            }
            for (int k = 0; k < 4; k++)
            {
                if (ri + dr[k] == rj && ci + dc[k] == cj)
                {
                    dis[i][j] = 1;
                    dis[j][i] = 1;
                }
            }
            if (dis[i][j] != 1) 
            {
                dis[i][j] = inf;
                dis[j][i] = inf;
            }
        }
    }

    for (int k = 0; k < R * C; k++) 
    {
        for (int i = 0; i < R * C; i++)
        {
            for (int j = 0; j < R * C; j++)
            {
                if (dis[i][k] + dis[k][j] < dis[i][j])
                {
                    dis[i][j] = dis[i][k] + dis[k][j];
                }
            }
        }
    }
}
int main()
{
    cin >> R >> C;
    for (int i = 0; i < R; i++)
    {
        getchar();
        for (int j = 0; j < C; j++)
        {
            maze[i][j] = getchar();
        }
    }
    init();
    int m = -inf;
    for (int i = 0; i < R * C; i++)
    {
        for (int j = 0; j < R * C; j++)
        {
            if (dis[i][j] != inf && m < dis[i][j])
            {
                m = dis[i][j];
            }
        }
    }
    cout << m << endl;
    return 0;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

int tot[50][50];
int m[50][50];

int vx[4] = {1, 0, 0, -1};
int vy[4] = {0, 1, -1, 0};

void bfs(int x, int y)
{
	rep(i,4){
		int nx = x + vx[i];
		int ny = y + vy[i];
		if (tot[ny][nx] > tot[y][x] + 1&& m[ny][nx]==1){
			tot[ny][nx] = tot[y][x] + 1;
			bfs(nx, ny);
		}
	}
}
int main()
{
	int h, w;
	int ans = 0;
	cin >> h >> w;
	rep(i,h)rep(j,w){
		char s;cin>>s;
		int a = 1;
		if (s == '#')
			a = -1;
		m[i + 1][j + 1] = a;
		tot[i + 1][j + 1] = INF;
	}
	rep(i,h)rep(j,w){
		if(m[i+1][j+1]==-1)
			continue;
		tot[i+1][j+1] = 1;
		bfs(j+1, i+1);
		int tmp = 0;
		
		rep(l, h) rep(k, w)
		{
			tmp = max(tmp, m[l+1][k+1]==-1 ? 0 : tot[l + 1][k + 1]);
			tot[l + 1][k + 1] = INF;
		}
		ans = max(tmp, ans);
	}
	cout << ans-1 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
  int n,i;
  int f[50];

  scanf("%d",&n);

  f[0] = f[1] = 1;
  for(i = 2 ; i <= n ; i++) {
    f[i] = f[i-1] + f[i-2];
  }
  printf("%d\n",f[n]);
  return 0;
}



Measured memory_bytes: 2048
#include<iostream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

int n, x[100100];

int main() {
    int i;
    //freopen("ttt", "r", stdin);

    cin >> n;

    for(i = 1;i <= n; ++i)
        cin >> x[i];

    int r= 0;

    for(i = 1; i <= n; ++i) {
        if(x[i] == i) {
            ++r;
            swap(x[i], x[i + 1]);
        }
    }

    cout << r;

    return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	void solve() throws IOException {
		long n = nl();
		long m = nl();
		if (n % m == 0) {
			out.println("0");
			return;
		}

		out.println("1");
	}

	private int getP(long n) {
		if (n < 0)
			n = -n;
		int p = 0;
		while (n > 0) {
			n >>= 1;
			p++;
		}
		return p;
	}

	String ns() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine(), " ");
		}
		return tok.nextToken();
	}

	int ni() throws IOException {
		return Integer.parseInt(ns());
	}

	long nl() throws IOException {
		return Long.parseLong(ns());
	}

	double nd() throws IOException {
		return Double.parseDouble(ns());
	}

	String[] nsa(int n) throws IOException {
		String[] res = new String[n];
		for (int i = 0; i < n; i++) {
			res[i] = ns();
		}
		return res;
	}

	int[] nia(int n) throws IOException {
		int[] res = new int[n];
		for (int i = 0; i < n; i++) {
			res[i] = ni();
		}
		return res;
	}

	int[][] nia(int n, int m) throws IOException {
		int[][] res = new int[n][];
		for (int i = 0; i < n; i++) {
			res[i] = nia(m);
		}
		return res;
	}

	long[] nla(int n) throws IOException {
		long[] res = new long[n];
		for (int i = 0; i < n; i++) {
			res[i] = nl();
		}
		return res;
	}

	public static void main(String[] args) throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		tok = new StringTokenizer("");
		Main main = new Main();
		main.solve();
		out.close();
	}
}

Measured memory_bytes: 21332
//By Zank100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define din(t) long long t;cin>>t;
#define in(t) cin>>t;
int main() 
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	din(n);
	ll h[n],dp[n],sum=0,curr;
	for(ll i=0;i<n;i++)
	{
	    in(h[i]);
	}
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(ll i=2;i<n;i++)
	{
	    ll p=dp[i-1]+abs(h[i]-h[i-1]);
	    ll q=dp[i-2]+abs(h[i]-h[i-2]);
	    if(p<q){
	        dp[i]=p;
	    }else{
	        dp[i]=q;
	    }
	}
	sum=dp[n-1];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main()
{
    while(1)
    {
        int x,y,ans=0;
        int dp[17][17]={0};
        int course[17][17]={0};
        cin>>x>>y;if(!x)return 0;
        for(int j=0;j<y;++j){
            for(int i=0;i<x;++i){
            	cin>>course[i][j];
            	if(!course[i][0])dp[i][0]=1;
            }
        }
        for(int j=0;j<y-1;++j){
            for(int i=0;i<x;++i){
                if(!course[i][j]){
                    if(course[i][j+1]!=1)dp[i][j+1]+=dp[i][j];
                    if(i){
                        if(!course[i-1][j+1])dp[i-1][j+1]+=dp[i][j];
                    }
                    if(i<x){
                        if(!course[i+1][j+1])dp[i+1][j+1]+=dp[i][j];
                    }
                }
                if(course[i][j]==2){
                    if(course[i][j+2]!=1)dp[i][j+2]+=dp[i][j];
                }
            }
        }
        for(int j=y-1;j<y+2;++j){
            for(int i=0;i<x;++i){
                ans+=dp[i][j];
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1160