akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[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 v = read_vec::<usize>();
    let (n, k) = (v[0], v[1] as i64);
    let big_int = 1000_000_000 + 7;
    if n == 1 {
        println!("{}", k);
        return;
    }
    let mut edges: Vec<Vec<usize>> = vec![Vec::new(); 2 * (n - 1)];
    for _ in 0..n - 1 {
        let v = read_vec::<usize>();
        let (a, b) = (v[0] - 1, v[1] - 1);
        edges[a].push(b);
        edges[b].push(a);
    }

    let mut tree: Vec<Vec<usize>> = vec![Vec::new(); n];
    let mut parent_dict: HashMap<usize, usize> = HashMap::new();
    make_tree(0, n, &edges, &mut tree, &mut parent_dict);
    let mut topological_sorted_indexes = vec![0];
    topological_dfs(0, &tree, &mut topological_sorted_indexes);

    if tree[0].len() as i64 + 1 > k {
        println!("0");
        return;
    }
    for i in 1..n {
        if tree[i].len() as i64 + 2 > k {
            println!("0");
            return;
        }
    }

    let mut ans = k;
    for i in 0..tree[0].len() as i64 {
        ans *= k - 1 - i;
        ans %= big_int;
    }
    debug!(ans);
    for &ti in topological_sorted_indexes.iter().skip(1) {
        for i in 0..tree[ti].len() as i64 {
            ans *= k - 2 - i;
            ans %= big_int;
            // debug!(ans, ti);
        }
    }
    println!("{}", ans);
}

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()
}

fn make_tree(
    cur_idx: usize,
    parent_idx: usize,
    edges: &Vec<Vec<usize>>,
    tree: &mut Vec<Vec<usize>>,
    parent_dict: &mut HashMap<usize, usize>,
) {
    for child_idx in edges[cur_idx].iter() {
        if *child_idx == parent_idx {
            continue;
        }
        tree[cur_idx].push(*child_idx);
        parent_dict.insert(*child_idx, cur_idx);
        make_tree(*child_idx, cur_idx, edges, tree, parent_dict);
    }
}

fn topological_dfs(cur_idx: usize, tree: &Vec<Vec<usize>>, result: &mut Vec<usize>) {
    for child_idx in tree[cur_idx].iter() {
        result.push(*child_idx);
        topological_dfs(*child_idx, tree, result);
    }
}


Measured memory_bytes: 54036
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<string>
#include<string.h>
#include<vector>
#include<queue>
#include<stack> 
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double eps=1e-8;
const double inf=0x3f3f3f3f;
const int maxn=515;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;};


int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0); 
	ll a;
	cin>>a;
	ll ans=a+a*a+a*a*a;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef set<int> S;
ll n;
int w,h;
int di[]={0,1,0,-1};
int dj[]={1,0,-1,0};
string s[60],t[60];
int dist[60][60][60][60];
int gx1,gy1,gx2,gy2;
bool ok=0;
void solve(int i,int j,int k,int l){
    queue<pair<pii,pii>> que;
    que.push({pii(i,j),pii(k,l)});
    dist[i][j][k][l]=0;
    while(!que.empty()){
        int now1_i = que.front().first.first, now1_j = que.front().first.second;
        int now2_i = que.front().second.first,now2_j = que.front().second.second;
        if(s[now1_i][now1_j]=='%' && t[now2_i][now2_j]=='%') {
            ok = true;
            break;
        }
        que.pop();
        if(s[now1_i][now1_j]!='%' && t[now2_i][now2_j]!='%')
            for(int m=0;m<4;m++){
                int nex1_i = now1_i + 1*di[m];
                int nex1_j = now1_j - 1*dj[m];
                int nex2_i = now2_i + 1*di[m];
                int nex2_j = now2_j + 1*dj[m];
                if(nex1_i >= h || nex1_j >= w || nex1_i < 0 || nex1_j < 0){
                    nex1_i=now1_i;
                    nex1_j=now1_j;
                }
                if(nex2_i >= h || nex2_j >= w || nex2_i < 0 || nex2_j < 0){
                    nex2_i=now2_i;
                    nex2_j=now2_j;
                }
                if(s[nex1_i][nex1_j]=='#') nex1_i=now1_i,nex1_j=now1_j;
                if(t[nex2_i][nex2_j]=='#') nex2_i=now2_i,nex2_j=now2_j;
                if(dist[nex1_i][nex1_j][nex2_i][nex2_j] == inf){
                    que.push( {pii(nex1_i,nex1_j), pii(nex2_i,nex2_j)});
                    dist[nex1_i][nex1_j][nex2_i][nex2_j] = dist[now1_i][now1_j][now2_i][now2_j]+1;
                }
            }
    }
}
int main(){
    while(1){
        cin>>w>>h;
        if(w==0 && h==0) break;
        rep(i,60){
            rep(j,60){
                rep(k,60){
                    rep(l,60){
                        dist[i][j][k][l]=inf;
                    }
                }
            }
        }
        for(int i=0;i<h;i++) cin>>s[i]>>t[i];
        int a,b,c,d;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(s[i][j]=='L'){
                    a=i;
                    b=j;
                }
                if(t[i][j]=='R'){
                    c=i;
                    d=j;
                }
                if(s[i][j]=='%'){
                    gx1=i;
                    gy1=j;
                }
                if(t[i][j]=='%'){
                    gx2=i;
                    gy2=j;
                }
            }
        }
        ok=0;
        solve(a,b,c,d);
        if(ok) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 54580
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

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

    int N; cin >> N;
    vector<double> data(N); F0R(i, N) cin >> data[i];

    sort(all(data));
    double ans = data[0];
    FOR(i, 1, N) {
        ans += data[i]; ans /= 2;
    }

    cout << ans << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343
// license: https://github.com/bqi343/USACO/blob/master/LICENSE

Measured memory_bytes: 256
/*input
99992
*/
#include<bits/stdc++.h>
#define ull         unsigned long long
#define ll             long long
#define M             1000000007
#define pb             push_back
#define p_q         priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()    
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp             make_pair
#define lb             lower_bound
#define ub            upper_bound
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ini(a,n,b)    for(ll int i=0;i<n;i++) a[i]=0;
#define F            first
#define S            second
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

bool DEBUG = 0;

ll MAX=100005;
vector < bool > prime(MAX);
void sieve() 
{          
    ll i,j;          
    for(i=0;i<MAX;i++) prime[i] = 1;          
    prime[0] = prime[1] = 0;
    for(i=2;i<=(int)sqrt(MAX);i++)            
        if (prime[i])              
            for(j=i;j*i<MAX;j++) prime[i*j] = 0;        
}

void initialize()
{
    sieve();
}


void solve()
{
    initialize();
    ll x;cin>>x;
    while(1)
    {
        if (prime[x])
        {
            cout<<x<<"\n";return;
        }
        x++;
    }
}


int main(void)
{
    ios
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
int len[2005];
char s[2005][10005];
bitset<10005> can[2005];
pair<int,int> dp[2][10005];
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>s[i];
		len[i]=strlen(s[i]);
	}
	for(int i=0;i<n;i++){
		can[i].reset();
	}
	can[n]=1;
	for(int i=n-1;i>=0;i--){
		can[i]=can[i+1]|(can[i+1]<<len[i]);
	}
	int cnt=0,ii=0;
	for(int i=0;i<n;i++){
		if(can[i+1][k-len[i]]) dp[0][cnt++]=make_pair(i,0);
	}
	string res;
//	cout<<"haha";
	for(int i=1;i<=k;i++){
		char mi='z';
		int cnt2=0;
		for(int j=0;j<cnt;j++){
			mi=min(s[dp[ii][j].first][dp[ii][j].second],mi);
		}
		res+=mi;
		int miid=1e9;
	//	cout<<"woc";
		for(int j=0;j<cnt;j++){
			int fi=dp[ii][j].first,se=dp[ii][j].second;
			if(s[fi][se]==mi){
				if(se+1==len[fi]) miid=min(miid,fi);
				else{
					dp[ii^1][cnt2++]=make_pair(fi,se+1);
				}
			}
		}
	//	cout<<"lala";
		for(int j=miid+1;j<n;j++){
			if(k-len[j]-i>=0&&can[j+1][k-len[j]-i]) dp[ii^1][cnt2++]=make_pair(j,0);
		}
		cnt=cnt2;
	//	cout<<cnt<<endl;
		ii^=1;
	}
	cout<<res;
}

Measured memory_bytes: 21504
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;
string s;
int main(){
	cin>>s;
	// is SUN, MON, TUE, WED, THU, FRI, or SAT
	if(s=="SUN") cout<<"7";
	else if(s=="MON") cout<<"6";
	else if(s=="TUE") cout<<"5";
	else if(s=="WED") cout<<"4";
	else if(s=="THU") cout<<"3";
	else if(s=="FRI") cout<<"2";
	else if(s=="SAT") cout<<"1";
	return 0;
}

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

int main(void){
    int num;
    double sum=0;
    double x;
    while(1){
        cin>>num;
        if(num==0)break;
        int NUMS[num];
        for(int i=0;i<num;i++){
            cin>>NUMS[i];
            sum+=NUMS[i];
        }
        x=sum/num;
        sum=0;
        for(int i=0;i<num;i++){
            sum+=pow((NUMS[i]-x),2);
        }
        cout<<fixed<<setprecision(8)<<sqrt(sum/num)<<endl;
        sum=0;
    }
    
    return 0;
}



Measured memory_bytes: 3292
import java.util.Scanner;
public class Main {
     
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String str = stdIn.next();
        int q = stdIn.nextInt();
        for(int i = 0; i < q; i++) {
            String stt = stdIn.next();
            if(stt.equals("print")) {
                int a = stdIn.nextInt();
                int b = stdIn.nextInt();
                String tmp = str.substring(a, b+1);
                System.out.println(tmp);
            }
            else if(stt.equals("reverse")) {
                int a = stdIn.nextInt();
                int b = stdIn.nextInt();
                String tmp = str.substring(a,b+1);
                String tmp2 = "";
                for(int j = tmp.length()-1; j >= 0; j--) {
                    tmp2 += String.valueOf(tmp.charAt(j));
                }
                String ck1 = str.substring(0, a);
                String ck2 = str.substring(b+1,str.length());
                str = ck1 + tmp2 + ck2;
            }
            else if(stt.equals("replace")) {
                int a = stdIn.nextInt();
                int b = stdIn.nextInt();
                String p = stdIn.next();
                String ck1 = str.substring(0, a);
                String ck2 = str.substring(b+1,str.length());
                str = ck1 + p + ck2;
                 
            }
        }
    }
}


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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
using namespace std;

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

signed main(){
	io();
	ull h; cin >> h;
	int pos = 64 - __builtin_clzll(h);
	ull ans = 1;
	for(int i = 0; i < pos - 1; ++i){
		ans <<= 1LL;
		ans |= 1LL;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
using namespace std;
int _s,a,b;
int solve(int c,int n,int s){
      if(!n) return s==_s;
      if(c>=10) return 0;
      return solve(c+1,n-1,s+c) + solve(c+1,n,s);
}
int main(){
      for(;;){
      cin >> a >> _s;
      if(!a)break;
      cout <<solve(0,a,0)<< endl;
      }
}

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

int main() {
	int N;
	cin >> N;
	vector<int> vec(N);
	for (int i = 0; i < N; i++) {
		cin >> vec.at(i);
	}
	sort(vec.begin(), vec.end());
	double answer = vec.at(0);
	for (int i = 0; i < N - 1; i++) {
		answer = (answer + vec.at(i + 1)) / 2;
	}
	cout << answer << endl;
}

Measured memory_bytes: 256
using System;
using System.Globalization;
using System.Threading;

namespace atcoder1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            while (n > 1000)
            {
                n = n - 1000;
            }

            Console.WriteLine(1000 - n);
         }
    }
}


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

int main(){
  int Max = -1,Min = 101;

  for(int i = 0; i< 3; i++){
    int x;
    cin >> x;
    Max = max(x,Max);
    Min = min(Min, x);
  }

  cout <<abs(Max - Min)<<endl;;
}


Measured memory_bytes: 256
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
import heapq as HQ

class Heap:
  def __init__(self, data, reverse=False):
    self.reverse = -1 if reverse else 1
    self.data = [self.reverse * d for d in data]
    HQ.heapify(self.data)
  def push(self, x): return HQ.heappush(self.data, self.reverse * x)
  def pop(self): return self.reverse * HQ.heappop(self.data)

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

n, x, t = I()
print(C(n / x) * t)

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    vi a(5);
    rep(i, 5) cin >> a[i];
    int ans = INF;
    rep(i, 5) {
        int cnt = 0;
        rep(j, 5) {
            if (j == i) cnt += a[j];
            else cnt += (a[j] + 9) / 10 * 10;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)
 
int main()
{
    string s;
    cin>>s;
    int N = 0, W = 0, S = 0, E = 0; 
    for(int i = 0; i < (int)s.size() ;i++){
        if(s[i] == 'N') N++;
        else if(s[i] == 'W') W++;
        else if(s[i] == 'S') S++;
        else E++;
    }
    if(N) N /= N; 
    if(W) W /= W; 
    if(S) S /= S; 
    if(E) E /= E;
    cout << (N ^ S || W ^ E ? "No" : "Yes") << endl;
    return 0;
}


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

using std::cout;
using std::cin;
using std::endl;

int main(){
    int K,A,B,k;
    bool ans = true;
    cin >> K;
    k = K;
    cin >> A >> B;
    while(K <= B && ans){
        if(A <= K && K <= B){
            ans = false;
            cout << "OK";
        }
        K += k;
    }
    if(ans) cout << "NG";
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MAX=1e9;
ll mod=1e9+7;
#define pb push_back
#define se second
#define fi first
#define maxe max_element
#define mine min_element
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define boost  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
vector<int> graph[205];
int color[205];
int nCk[100][100];
bool bipartite_jugding(int v, int c){
    color[v] = c;
    for(int i = 0; i < graph[v].size(); ++i){
        if(color[graph[v][i]] == c) return false;
        if(color[graph[v][i]] == 0 && !bipartite_jugding(graph[v][i], -c)){
            return false;
        }
    }
    return true;
}

 void combi() {
	for (int i = 0; i <= 99; ++i) nCk[i][0] = 1;
	for (int i = 1; i <= 99; ++i) for (int j = 1; j <= i; ++j) {
		nCk[i][j] = (nCk[i-1][j] + nCk[i-1][j-1]) % mod;
	}
}

long long expo(ll x,ll n,ll M)
{

    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*expo((x*x)%M,(n-1)/2,M))%M;

}
 ll n,k,s;
void solve()
{
   /* cin>>n
  vector<pair<ll,pair<ll,ll> > > wo;
  ll x,l;
  for(int i=0;i<n;i++)
  {
      cin>>x>>l;
      wo.pb({x+l,{0,i}});
      wo.pb({x-l,{1,i}});
  }
   sort(wo.begin(),wo.end());
   ll start=0;
   for(int i=0;i<2*n;i++)
   {
       if(wo[i].se.fi==0)
        start++;
       else
        start--;
        if(wo[i].fi!=wo[i+1].fi)
            ans=min(ans,start)

   }*/
   ll  H,W,N;
   cin>>H>>W>>N;
   ll m=max(H,W);int i;
   for(i=1;i<=min(H,W);i++)
    if(i*m>=N)
    break;
   cout<<i<<endl;


}

int main(){
    boost;
  solve();
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;



int main(void) {
  int n,m;
  cin >> n >> m;
  vivi a(n);
  rep(i,m){
    int p,q;
    cin >> p >> q;
    p--;
    q--;
    a[p].push_back(q);
    a[q].push_back(p);
  }
  bool ok = false;
  rep(i,a[0].size()){
    int g = a[0][i];
    rep(j,a[g].size()){
      if(a[g][j]==n-1) ok = true;
    }
  }
  if(ok) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
      
}




Measured memory_bytes: 18160
//Mahdibuet3*
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define s(n) scanf("%lld",&n)
main()
{
    ll n,i,j=0,k,m,q=-1,c=0,a,b;
    s(n);
    s(m);
    vector<ll>x[n+1];
    for(i=0;i<m;i++)
    {
        s(a);s(b);
        x[b-1].push_back(a);
    }
    for(i=1;i<=n;i++)
    {
        for(int k=0;k<x[i].size();k++)
        {
            if(q<x[i][k])
            {
                q=i;
                c++;
            }
        }
    }
    printf("%lld",c);
}



Measured memory_bytes: 5116
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }

bool func(ll a) {
	ll i = 0;
	for (i = 0; i * i < a; ++i);
	return a == i*i;
}

int main() {
	int n, d;
	cin >> n >> d;
	vector<vector<ll>> x(n, vector<ll>(d));
	REP(i, n) {
		REP(j, d) {
			cin >> x[i][j];
		}
	}
	int res = 0;
	REP(i, n) {
		REP(j, n) {
			int temp = 0;
			if (i != j) {
				REP(k, d) {
					temp += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
				}
				if (func(temp))res++;
			}
			
		}
	}
	put(res/2);
	return 0;
}

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

int main() {
	int k;
	string s;
	cin >> k >> s;
	int n = s.size();
	if(n <= k) cout << s << endl;
	else {
		cout << s.substr(0, k) << "..." << endl;
	}
	return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
int main(void){
  int n,a,x[50],k,i,j;
  long dp[50][5001]={};
  scanf("%d%d",&n,&a);
  for (i=0;i<n;i++){
    scanf("%d",&k);
    x[i]=k-a;
  }
  dp[0][2501]++;
  dp[0][x[0]+2501]++;
  for (i=1;i<n;i++){
    for (j=0;j<5001;j++){
      dp[i][j]=dp[i-1][j]+dp[i-1][j-x[i]];
    }
  }
  printf("%ld\n",dp[n-1][2501]-1);
  return 0;
}

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

using namespace std;

#define intt long long

int main() {

	int k;
	cin >> k;
	queue <intt> q;
	for (int i = 1; i <= 9; i ++) {
		q.push(1LL * i);
	}
	while (-- k) {
		long long x = q.front();
		q.pop();
		if (x % 10 != 0) {
			q.push(x * 10 + x % 10 - 1);
		}
		q.push(10 * x + x % 10);
		if (x % 10 != 9) {
			q.push(x * 10 + x % 10 + 1);
		}
	}
	cout << q.front() << '\n';
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>

using namespace std;

struct Info{
	int first,second,third,score;
};

int main(){

	int N,work1[101],work2[101],work3[101];
	Info table[200];

	for(int i = 0; i < 200; i++)table[i].score = 0;

	for(int i = 0; i < 101; i++){
		work1[i] = work2[i] = work3[i] = 0;
	}

	scanf("%d",&N);

	for(int i = 0; i < N; i++){
		scanf("%d %d %d",&table[i].first,&table[i].second,&table[i].third);
		work1[table[i].first]++;
		work2[table[i].second]++;
		work3[table[i].third]++;
	}

	for(int i = 0; i < N; i++){
		if(work1[table[i].first] == 1)table[i].score += table[i].first;
		if(work2[table[i].second] == 1)table[i].score += table[i].second;
		if(work3[table[i].third] == 1)table[i].score += table[i].third;
		printf("%d\n",table[i].score);
	}

	return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc  = new Scanner(System.in);
		int N = sc.nextInt();
		String[] array = new String[N];
		String str = sc.nextLine();
		str = sc.nextLine();
		array = str.split(" ");
		int max = 0;
		int count = 0;
		for (int j=0; j<N-1; j++) {
			if (Integer.parseInt(array[j]) >= Integer.parseInt(array[j+1])) {
				count++;
			}
			else {
				count = 0;
			}
		
			if (count >= max) {
				max = count;
			}
		}
		
		System.out.println(max);
		
	}

}


Measured memory_bytes: 48848
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

void precalc() {
}

const int maxn = (int) 2e4 + 10;
int a[maxn], b[maxn];
int perm[maxn];
int n;

int read() {
  if (scanf("%d", &n) < 1) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    a[i] = maxn * (i + 1);
    b[i] = maxn * (n - i);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", perm + i);
    --perm[i];
    a[perm[i]] += i;
  }
  return 1;
}

void solve() {
  for (int i = 0; i < n; ++i) {
    printf("%d%c", a[i], " \n"[i == n - 1]);
  }
  for (int i = 0; i < n; ++i) {
    printf("%d%c", b[i], " \n"[i == n - 1]);
  }
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 1024
loop do
    n = gets.to_i
    break if n == 0
    k = n
    hash = {}
    n.times do
        dice = [0] + gets.chomp.split
        class << dice
            def roll!
                self[1], self[3], self[6], self[4] = self[3], self[6], self[4], self[1]
            end
            def spin!
                self[2], self[3], self[5], self[4] = self[3], self[5], self[4], self[2]
            end
        end
        if dice[6] == 'Red'
            2.times { dice.roll! }
        elsif dice[1] != 'Red'
            dice.spin! until dice[3] == 'Red'
            dice.roll! 
        end
        c = dice[2..5].min
        dice.spin! until dice[2] == c
        k -= 1 if hash[dice] 
        hash[dice] = 1
    end
    p n - k
end

Measured memory_bytes: 10128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,k; cin >> n >> k;
  cout << (n>=2*(k-1)+1 ? "YES\n" : "NO\n");

  return 0;
}


Measured memory_bytes: 3596
using System;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = InputHelper.NextInt();
            var a = InputHelper.NextInt();
            var b = InputHelper.NextInt();
            x -= a;
            x %= b;
            Console.WriteLine(x);
        }
    }
    
    internal static class InputHelper
    {
        private static int _current;
        private static string[] _buffer;

        public static string next()
        {
            while (_buffer == null || _current == _buffer.Length)
            {
                _current = 0;
                _buffer = Console.ReadLine()?.Split();
            }

            return _buffer[_current++];
        }

        public static int NextInt()
        {
            return int.Parse(next());
        }
    }    
}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  Solver(LL n) : n(n){};

  void solve() {
    cout << pow((double)n / 3.0, 3) << endl;
  }
};
class Solver2 {
 public:
  int n, m;
  Solver2(LL n, LL m) : n(n), m(m){};

  void solve() {
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


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

int main() {

    string S, T;
    cin >> S;
    cin >> T;

    int count = 0;
    for (int i = 0; i < 3; i++) {
        if (S[i] == T[i]) count++;
    }
    cout << count << endl;

    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> X;
    int l;
    for(int i = 0; i < N; i++){
        cin >> l;
        X.push_back(l);
    }

    int min_val = *min_element(X.begin(),X.end());
    int max_val = *max_element(X.begin(),X.end());

    int ans = INT32_MAX;
    for(int i = min_val; i <= max_val; i++){
        int sum = 0;
        for(int j = 0; j < (int)X.size(); j++){
            sum += (X[j] - i) * (X[j] - i); 
        }
        ans = min(ans,sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define REP(i,a,n) for(int i=a;i<(n);i++)
using namespace std;
bool isTriangle(int x,int y,int z)
{
	if(x==y||x==z||y==z)return 0;
	if(x+y<=z||x+z<=y||y+z<=x)return 0;
	return 1;
}
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	int ans=0,n,a[101];
	cin>>n;
	REP(i,0,n)cin>>a[i];
	REP(i,0,n)REP(j,i+1,n)REP(k,j+1,n)
	if(isTriangle(a[i],a[j],a[k]))ans++;
	cout<<ans<<endl;
    return 0;
}



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

using namespace std;

typedef long long ll;

#define p(x) cout << x << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define range(i, begin, end) for (int i = begin; i < (int)(end + 1); i++)
#define all(x) (x).begin(), (x).end()

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

  vector<int> as(n);
  rep(i, n) { cin >> as[i]; };

  vector<int> order(n);

  rep(i, n) { order[as[i] - 1] = i; }

  rep(i, n) { cout << order[i] + 1 << " "; };

  return 0;
}


Measured memory_bytes: 1536
# coding: utf-8

# https://atcoder.jp/contests/abc098/tasks/arc098_b
# give up
# 15:29-16:15


def bin20(x):
    bin_x = bin(x)[2:]
    x_len = len(bin_x)

    return list(map(int, "0" * (20-x_len) + bin_x))


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A = [bin20(a) for a in A]

    ans = 0
    left = 0
    right = 0
    sum20 = [0] * 20
    pre_right = -1
    while True:
        if right > pre_right:
            for k in range(20):
                sum20[k] += A[right][k]

        pre_right = right

        if 2 in sum20:
            for k in range(20):
                sum20[k] -= A[left][k]
            ans += right - left
            left += 1
        else:
            right += 1

        if right == N:
            ans += (N-left) * (N-left+1) // 2

            return ans


print(main())


Measured memory_bytes: 59528
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int a[100'000];

int main()
{
    int n, k, q;
    cin >> n >> k >> q;
    fill(a, a + n, k - q);
    rep(i, q)
    {
        int j;
        cin >> j;
        j--;
        a[j]++;
    }

    rep(i, n)
    {
        cout << (a[i] > 0 ? "Yes" : "No") << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 A, B, C, D;
  cin >> A >> B >> C >> D;
  for(i64 i=0;;i++)
    if(i%2==0)
    {
      C-=B;
      if(C<=0)
      {
        cout<<"Yes"<<endl;
        return 0;
      }
    }
    else
    {
      A-=D;
      if(A<=0)
      {
        cout<<"No"<<endl;
        return 0;
      }
    }
  return 0;
}


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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

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

	int x, y;
	cin >> x >> y;

	ll ans = 0;
	vector<ll> g = { 0, 300000, 200000, 100000 };
	if (x <= 3) ans += g[x];
	if (y <= 3) ans += g[y];
	if (x == y && x == 1) ans += 400000;
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    R, C, K, *RCV = map(int, read().split())

    item = [[0] * C for _ in range(R)]
    for r, c, v in zip(*[iter(RCV)] * 3):
        item[r - 1][c - 1] = v

    dp = [0] * (C + 1)
    for i in range(R):
        value = [0] * 4
        for j in range(C):
            if value[0] < dp[j + 1]:
                value[0] = dp[j + 1]
            if item[i][j] > 0:
                for k in range(2, -1, -1):
                    if value[k + 1] < value[k] + item[i][j]:
                        value[k + 1] = value[k] + item[i][j]
            dp[j + 1] = max(value)

    print(dp[C])

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 200656
a = input()


def bubun(inp):
    result = []

    def saiki(bb, index, buf):
        if len(bb) == index:
            if len(bb) == 0:
                result.append(buf)
        else:
            saiki(bb, index + 1, buf)
            buf += int(bb[:index+1])
            bb = bb[index+1:]
            saiki(bb, 0, buf)
    saiki(inp, 0, 0)
    return sum(result)


print(bubun(a))


Measured memory_bytes: 3060
function Main(input) {
    var C = input[0];

    var list = ['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'];

    var index = list.findIndex(a => a === C);

    console.log(index !== 25 ? list[index + 1] : list[0]);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    int n, x;
    while(cin>>n>>x){
        ll ans=0;
        for(int i=0; i<n; ++i){
            scanf("%d",a+i);
        }
        int tmp=0;
        ans=1;
        for(int i=0; i<n; ++i){
            tmp+=a[i];
            if(tmp>x)
                break;
            ++ans;
        }
        cout<<ans<<endl;
    }
  return 0;
}




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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	int a, b;
  	cin >> a >> b;
	if(a+b>=10) puts("error");
  	else cout << a+b << endl;
  	return;
}

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

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

int main() {
    int k, s, i, count;
    cin >> k >> s;

    for (int a=0; a<=k; ++a) {
        for (int b=0; b<=k; ++b) {
            i = s - a - b;
            if (i <= k && i >= 0) {
                ++count;
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int H, W, sx, sy, dx, dy;
char grid[1011][1011];
int d1[4] = {-1,0,0,1}, d2[4] = {0,1,-1,0};

bool isSafe(int i, int j)
{
	return i >= 1 and i <= H and j >= 1 and j <= W and grid[i][j] != '#';
}

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	cin >> H >> W;
	cin >> sx >> sy;
	cin >> dx >> dy;
	int dist[H+1][W+1];
	for(int i = 1;i <= H;i++)
		for(int j = 1;j <= W;j++)
			cin >> grid[i][j], dist[i][j] = INT_MAX;
	if(grid[sx][sy] == '#')
		cout << -1;
	else 
	{
		deque<pair<int,int>> dq;
		dq.push_back({sx,sy});
		dist[sx][sy] = 0;
		while(!dq.empty())
		{
			auto x = dq.front();dq.pop_front();
			int i = x.first, j = x.second;
			for(int it = 0;it < 4;it++)
			{
				if(isSafe(i + d1[it],j + d2[it]) and dist[i+d1[it]][j+d2[it]] > dist[i][j])
				{	
					dq.push_front({i + d1[it],j + d2[it]});
					dist[i + d1[it]][j + d2[it]] = dist[i][j];
				}
			}
			for(int it = -2;it <= 2;it++)
			{
				for(int jt = -2;jt <= 2;jt++)
				{
					if(isSafe(i+it,j+jt) and dist[i + it][j + jt] > dist[i][j] + 1)
					{
						dist[i+it][j+jt] = dist[i][j] + 1;
						dq.push_back({i + it, j + jt});
					}
				} 
			}
		}
		cout << ((dist[dx][dy] == INT_MAX) ? -1 : dist[dx][dy]) << '\n';
	}
}


Measured memory_bytes: 8556
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		final int N = scan.nextInt();
		long[] h = new long[N];
		for(int i = 0; i < N; i++) {
			h[i] = scan.nextLong();
		}
		scan.close();
		boolean flg = true;
		// 末尾から見ていく
		for(int i = N - 2; i >= 0; i--) {
			if(h[i] - h[i + 1] == 1) {
				h[i]--;
			}else if(h[i] - h[i + 1] >= 2 ) {
				flg = false;
				break;
			}
		}
		if(flg) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


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

int main() {
  int k,x;
  cin >> k>>x;
  int a=x-k+1;
  int b=x+k-1;
  for(int i=a;i<b;i++){
    cout << i << " ";
  }
  cout << b << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 500 + 10;
int H, W;
char S[MAXN][MAXN];

int main() {
	register int i, j, k;
	scanf("%d%d", &H, &W);
	for(i = 0; i < H; ++i)
		scanf("%s", S[i]);
	for(i = 0; i < 2; ++i, puts(""))
		for(j = 0; j < H; ++j, puts(""))
			for(k = 0; k < W; ++k)
				putchar(".#"[S[j][k] == '#' || (k == W - 1 || (k && j & 1)) == i]);
	return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
 int zetta(int x){
	 if(x<0)
		 return -x;
	 else
		 return x;
 }
 
	 int main(){
		 int a,b;
		 int c,k;
		 scanf("%d%d",&a,&b);
		 c=a+b;
		 k=zetta(c)/2;
		 if(c%2==1)
			 printf("IMPOSSIBLE");
		 else
			 printf("%d",k);
		 return 0;
	 }
	 
			 
			 

Measured memory_bytes: 128
def main():
    N = input() 
    a = [input() for y in range(N)] 
    a_max = -10**9
    a_min = a[0]
    for j in xrange(1,len(a)):
        if a[j] - a_min > a_max:
            a_max = a[j] - a_min
        if a[j] < a_min:
            a_min = a[j]
    print a_max
main()

Measured memory_bytes: 19004
#include<bits/stdc++.h>
#define push push_back
#define sz size()
#define s second
#define f first
#define N 800
using namespace std;
typedef pair<int,int> P;
int n,p[N],d,a,b,c,m;
vector<P> e[N];
bool u[N];

void dfs(int x,int s){
  u[x]=true;
  for(int i=0;i<e[x].sz;i++){
    int nx=e[x][i].f;
    if(u[nx])continue;
    if(e[nx].sz==1){
      m=max(m,s);
      continue;
    }
    dfs(nx,s+e[x][i].s);
  }
}

int main(){
  while(1){
    cin>>n;
    if(!n)break;
    for(int i=1;i<n;i++)cin>>p[i];
    a=b=c=0;
    for(int i=1;i<n;i++){
      cin>>d;
      a+=d;
      e[i].push(P(p[i]-1,d));
      e[p[i]-1].push(P(i,d));
    }
    for(int i=0;i<n;i++)
      if(e[i].sz==1)
	b+=e[i][0].s;
    for(int i=0;i<n;i++)
      if(e[i].sz!=1){
	memset(u,0,sizeof(u));
	m=0;
	dfs(i,0);
	c=max(c,m);
      }
    cout<<3*a-2*b-c<<endl;
    for(int i=0;i<n;i++)e[i].clear();
  }
  return 0;
}

Measured memory_bytes: 1324
// ABC137C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include<map> //mapを使う
#include <iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main()
{
	int len = 10;//各文字列の長さ
	int N;
	cin >> N;
	vector<string> s(N);
	vector<vector<int>>alphabet(N, vector<int>(26));
	vector<string>s2(N);//アスキーコードに変換したあと、文字列にした

	map<string, int> m;
	for (int i = 0; i < N; i++)
	{
		cin >> s.at(i);
		for (int j = 0; j < 10; j++)
		{
			//文字をASCIIコードに変換するには(int)キャストする
			alphabet.at(i).at((int)s.at(i).at(j) - 97)++;
		}
		for (int k = 0; k < 26; k++)
		{
			s2.at(i) += to_string(alphabet.at(i).at(k));//文字列にする
		}
		//cout << s2.at(i) << endl;
		auto itr = m.find(s2.at(i));
		if (itr!=m.end())
		{
			m.at(s2.at(i))++;
		}
		else
		{
			m.insert(pair<string, int>(s2.at(i), 1));
		}
	}

	map <string, int>::iterator p;
	for (p = m.begin(); p != m.end(); p++)
	{
		//cout << p->first << " "<< p->second << endl;
	}
	long ans = 0;
	long count = 0;
	for (p = m.begin(); p != m.end(); p++)
	{
		for (int i = p->second-1; i > 0; i--) //繰り返しの数を計算する
		{
			count += i;
		}
		//cout << count << endl;
		ans += count; //繰り返しの数の合計
		count = 0;
	}
	cout << ans << endl;
}

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

const double EPS = 1e-8;
const double INF = 1e12;

//point
typedef complex<double> P;
namespace std {
	bool operator < (const P& a, const P& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}
double cross(const P& a, const P& b) {
	return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
	return real(conj(a)*b);
}
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;								  // a--c--b on line
}

// line
struct L : public vector<P> {
	L(const P& a, const P& b) {
		push_back(a); push_back(b);
	}
};

// polygon
typedef vector<P> G;

P extreme(const vector<P> &po, const L &l) {
  int k = 0;
  for (int i = 1; i < po.size(); ++i)
    if (dot(po[i], l[1]-l[0]) > dot(po[k], l[1]-l[0])) k = i;
  return po[k];
}

enum { OUT, ON, IN };
int contains(const G& po, const P& p) {
  bool in = false;
  for (int i = 0; i < po.size(); ++i) {
  	P a = po[i] - p, b = po[(i+1)%po.size()] - p;
    if (imag(a) > imag(b)) swap(a, b);
    if (imag(a) <= 0 && 0 < imag(b))
      if (cross(a, b) < 0) in = !in;
    if (cross(a, b) == 0 && dot(a, b) <= 0) return ON;
  }
  return in ? IN : OUT;
}

double area2(const G& po) {
	double A = 0;
  	for (int i = 0; i < po.size(); ++i) 
    	A += cross(po[i], po[(i+1)%po.size()]);
	//????????????????????????????????¨????????????
  	return A/2;
}

bool isconvex(const G &p) {
	int n = p.size();
	if(cross(p[0]-p[n-1],p[n-2]-p[n-1]) < 0) return false;
	for(int i = 1; i < n-1; ++i) {
		if(cross(p[i+1]-p[i],p[i-1]-p[i]) < 0) return false;
	}
	return true;

}
	
int main() {
	int n;
	cin >> n;
	G po;
	for(int i=0; i<n; ++i) {
		double x, y;
		cin >> x >> y;
		P p(x, y);
		po.push_back(p);
	}
	if(isconvex(po)) cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 3228
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanLines)

	for sc.Scan() {
		s := strings.Split(sc.Text(), " ")
		H, _ := strconv.Atoi(s[0])
		W, _ := strconv.Atoi(s[1])

		if H == 0 && W == 0 {
			return
		}

		for h := 0; h < H; h++ {
			for w := 0; w < W; w++ {
				if (h+w)%2 == 0 {
					fmt.Print("#")
				} else {
					fmt.Print(".")
				}
			}
			fmt.Println()
		}
		fmt.Println()
	}
}



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

int main(){
    int N;
    cin >> N;
    int A[100009];
    A[0] = 0, A[N + 1] = 0;
    for (int i = 1; i <= N; i++){
        cin >> A[i];
    }

    int distance = 0;
    for (int i = 1; i <= N + 1; i++){
        distance += abs(A[i] - A[i - 1]);
    }
    for (int i = 1; i <= N; i++){
        if((A[i + 1] - A[i]) * (A[i] - A[i - 1]) < 0){
            cout << distance - abs(A[i + 1] - A[i]) - abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i - 1]) << endl;
        }
        else cout << distance << endl;
    }
    //cout << distance << endl;
    return 0;

}

Measured memory_bytes: 1664
#include <math.h>
#include <ctype.h>
#include <limits.h>
#include <string.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>

#define nl                std::cout << "\n"
#define in(x)             std::cin  >> (x)
#define out(x)            std::cout << (x) << " "
#define err(x)            std::cerr << "DBG: " << #x << " " << (x) << "\n"

#define inn(x)            int x; in(x);
#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)
#define rrep(i, n)        for (int i = (n) - 1; i > -1; --i)

#define no                puts("NO")
#define yes               puts("YES")

using ll  = long long int;
using vi  = std::vector<int>;
using ii  = std::pair<int, int>;
using iii = std::pair<ii, int>;
using vii = std::vector<ii>;

const int N = 1010101;
const int MD = 1e9 + 7;

void solve() {
    inn(w); inn(h);
    inn(x); inn(y);
    out((double) w * h / 2.0);
    bool ans = (w%2 == 0 && h%2 == 0) ? (x == w/2 && y == h/2) : 0;
    out(ans);
}

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

    //int t; in(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}


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

int main()
{
	string s,t,temp;
	cin>>s>>t;
	int m,n,i,j;
	m=s.size();n=t.size();
	int dp[m+1][n+1];
	for(i=0;i<=m;i++)
	{
		for(j=0;j<=n;j++)
		{
			if(i==0||j==0)dp[i][j]=0;
			else if(s[i-1]==t[j-1])
			{
				dp[i][j]=1+dp[i-1][j-1];
			}
			else
			{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	int lcs=dp[m][n];
	char lc[lcs+1];
	i=m;j=n;
	while(i>0&&j>0)
	{
		if(s[i-1]==t[j-1])
		{
			lc[lcs-1]=s[i-1];
			i--;j--;lcs--;
		}
		else
		{
			if(dp[i-1][j]>dp[i][j-1])
			{
				i--;
			}
			else
			{
				j--;
			}
		}
	}
	lc[dp[m][n]]='\0';
	if(dp[m][n]==0)cout<<"";
	else cout<<lc;
}

Measured memory_bytes: 35456