akhauriyash/Code-Regression huggingface dataset:
pub 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()
}

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

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

#[derive(Debug)]
struct UnionFind {
    node: usize,
    parent: usize,
    friend: u32,
    block: u32,
    size: u32,
}

fn friend(a: usize, b: usize, uf: &mut Vec<UnionFind>) {
    uf[a].friend += 1;
    uf[b].friend += 1;
    let pa = parent(a, uf);
    let pb = parent(b, uf);
    if pa == pb {
        return;
    }
    if uf[pa].size < uf[pb].size {
        uf[pa].parent = pb;
        uf[pb].size += uf[pa].size;
    } else {
        uf[pb].parent = pa;
        uf[pa].size += uf[pb].size;
    }
}

fn block(a: usize, b: usize, uf: &mut Vec<UnionFind>) {
    let pa = parent(a, uf);
    let pb = parent(b, uf);
    if pa == pb {
        uf[a].block += 1;
        uf[b].block += 1;
    }
}

fn parent(a: usize, uf: &mut Vec<UnionFind>) -> usize {
    if uf[a].parent == 0 {
        uf[a].node
    } else {
        let p = parent(uf[a].parent, uf);
        uf[a].parent = p;
        p
    }
}

fn main() {
    let nmk: Vec<usize> = read_vec();
    let n = nmk[0];
    let m = nmk[1];
    let k = nmk[2];
    let abv: Vec<Vec<usize>> = read_vec2(m);
    let cdv: Vec<Vec<usize>> = read_vec2(k);

    let mut uf: Vec<UnionFind> = vec![];

    for i in 0..n + 1 {
        uf.push(UnionFind {
            node: i,
            parent: 0,
            friend: 0,
            block: 0,
            size: 1,
        });
    }

    for i in 0..m {
        let a = abv[i][0];
        let b = abv[i][1];
        friend(a, b, &mut uf);
    }

    for i in 0..k {
        let c = cdv[i][0];
        let d = cdv[i][1];
        block(c, d, &mut uf);
    }

    for i in 1..n + 1 {
        let p = parent(i, &mut uf);
        let c = uf[p].size - uf[i].friend - uf[i].block - 1;
        print!("{}", c);
        if i == n {
            println!("");
        } else {
            print!(" ");
        }
    }
}


Measured memory_bytes: 21748
n, y = map(int, input().split())

for i in range(n+1):
    for j in range(n+1):
        z = n - i - j
        value = z * 10000 + i * 5000 + j *1000
        if value == y and z >= 0:
            print(z, i , j)
            break
        
    else:
        continue
    
    break

else:
    print(-1, -1, -1)

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

int main() {
    int h, w;
    cin >> h >> w;
    char s[h][w];
    rep(i, h) rep(j, w) cin >> s[i][j];

    rep(i, h) rep(j, w) {
        if (s[i][j] == '.') continue;
        bool ok = false;
        for (int y = -1; y <= 1; y += 2) {
            int dy = i + y;
            if (dy >= 0 && dy < h && s[dy][j] == '#') ok = true;
        }
        for (int x = -1; x <= 1; x += 2) {
            int dx = j + x;
            if (dx >= 0 && dx < w && s[i][dx] == '#') ok = true;
        }
        if (!ok) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main()
{ 
  int n,k;
  cin>>n>>k;
  int p[n];
  for(int i=0; i<n; i++){
    cin>>p[i];
  }
 sort(p,p+n);
  int sum=0;
 for(int i=0; i<k; i++){
   sum+=p[i]; 
  }
  cout<<sum<<endl;
}
    

Measured memory_bytes: 3628
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long n = scan.nextLong();
    long sum = 0;
    for (int i=1;i<n+1;i++){
      if ((i%3!=0)&&(i%5!=0)){
        sum += i;
      }
    }
    System.out.println(sum);
  }
}


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

using namespace std;

const int N = 50;
int a[N] = { 0 };

int main() {
	int n, l, r, ans, i;
	while(cin >> n >> l >> r, n) {
		ans = 0;
		for(i = 0;i < n;++i) {
			cin >> a[i];
		}
		for(int y = l;y <= r;++y) {
			int i;
			for(i = 0;i < n;++i) {
				if(y % a[i] == 0) {
					ans += (1 - i % 2);
					break;
				}
			}
			if(i == n) {
				ans += (1 - i % 2);
			}
		}
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 3072
#include<stdio.h>

int dai(int a,int b){
  if(a > b){
    return a;
  }
  else{
    return b;
  }
}

int main(void){
  int a , b , c;
  scanf("%d %d %d",&a ,&b ,&c);

  int max = dai(a,dai(b,c));
  int sa = max - a , sb = max - b , sc = max - c;
  int flag = 1 , ans = 0;
  while(flag == 1){
    if(sa%2 + sb%2 + sc%2 == 2){
      ans += sa/2 + sb/2 + sc/2 + 1;
      flag = 0;
    }
    else if(sa%2 + sb%2 + sc%2 == 0){
      ans += sa/2 + sb/2 + sc/2;
      flag = 0;
    }
    sa ++;
    sb ++;
    sc ++;
  }

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

  return 0;
}

Measured memory_bytes: 1720
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#define SIZE 100005

using namespace std;

int A[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&A[i]);
		A[i]--;
	}
	int ret=0;
	for(int i=0;i<n;)
	{
		if(A[i]!=i) i++;
		else if(A[i]==i)
		{
			if(i+1<n&&A[i+1]==i+1)
			{
				ret++;
				i+=2;
			}
			else
			{
				ret++;
				i++;
			}
		}
	}
	printf("%d\n",ret);
	return 0;
}


Measured memory_bytes: 512
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Wed Dec  5 22:15:09 2018
//
package main

import "fmt"

var n, k int

func main() {
	fmt.Scan(&n, &k)

	if k%2 == 1 {
		m := n / k
		fmt.Println(m * m * m)
	} else {
		m := n / k
		m2 := n/(k/2) - m

		fmt.Println(m*m*m + m2*m2*m2)
	}
}


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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n + 1);
    rep(i,a.size()) {
        cin >> a[i];
    }

    vector<ll> upper(n + 1,0);
    vector<ll> downer(n + 1,0);
    ll ucount = 0;
    ll dcount = 0;

    for(int i = a.size() - 1; i >= 0; i--) {
        ucount += a[i];
        dcount += a[i];
        upper[i] = ucount;
        downer[i] = dcount;
        dcount /= 2;
        if(downer[i] % 2 == 1 && i != 0) {
            dcount++;
            downer[i]++;
        }
    }

    if(downer[0] != 1) {
        cout << -1 << endl;
        return 0;
    }

    ll now = 1;
    ll ans = 0;

    rep(i, a.size()) {
        ans += now;
        now -= a[i];
        if(i != a.size()) {
            now = min(now * 2, upper[i + 1]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
const int N = 1e5+1;
int mod;
int mul(int a,int b)
{
    return ((a%mod)*(b%mod))%mod;
}
int add(int a,int b)
{
    return ((a%mod)+(b%mod))%mod;
}
int power(int a,int b)
{
    int res = 1;
    while(b>0)
    {
        if(b&1)
        {
            res = mul(res,a);
        }
        b = b/2;
        a = mul(a,a);
    }
    return res;
}
int sub(int a,int b)
{
    return ((a%mod)-(b%mod)+mod)%mod;
}
int div(int a,int b)
{
    return mul(a,power(b,mod-2));
}
signed main()
{
    fast;
    int n;
    cin>>n>>mod;
    int a[n+1];
    int ans = 0;
    int sum = 0;
    map<int,int> mp;
    int pre[n+2]={};
    mp[0]++;
    pre[0] = 0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(i>=mod)
        {
            mp[pre[i-mod]]--;
        }
        sum = add(sum,a[i]);
        sum = sub(sum,1);
        ans+=mp[sum];
        mp[sum]++;
        pre[i] = sum;
        //cout<<pre[i]<<" "<<ans<<" ";
        //cout<<endl;
    }
    cout<<ans;
    
}

Measured memory_bytes: 15872
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 16;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

ll bestx[1 << MAXN][MAXN], besty[1 << MAXN][MAXN], score[MAXN], subScore[1 << MAXN], ans[MAXN];
int x[MAXN], y[MAXN], p[MAXN], n;

void calc(int pos[], int val[], ll res[1 << MAXN][MAXN]) {
    // marked points
    FOR(mask,0,(1<<n)-1) {
        FOR(i,0,n-1)
            if (mask & (1<<i)) score[i] = 0;
            else {
                int x = abs(pos[i]);
                FOR(j,0,n-1) 
                    if (mask & (1<<j)) x = min(x, abs(pos[i] - pos[j]));
                score[i] = (ll) x * val[i];
            }
        int cntMarked = __builtin_popcount(mask);
        int rest = ((1<<n)-1) ^ mask;
        for (int subOfRest = rest;; subOfRest = (subOfRest-1) & rest) {
            int s = rest ^ subOfRest;

            if (s == 0) subScore[s] = 0;
            else {
                int i = __builtin_ctz(s);
                subScore[s] = subScore[s ^ (1<<i)] + score[i];
            }
            res[s | mask][cntMarked] = min(res[s | mask][cntMarked], subScore[s]);
            if (subOfRest == 0) break;
        }
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,0,n-1) cin >> x[i] >> y[i] >> p[i];
    
    FOR(mask,0,(1<<n)-1) FOR(i,0,n) bestx[mask][i] = besty[mask][i] = 1e18;
    calc(x, p, bestx);
    calc(y, p, besty);
    FOR(i,0,n) ans[i] = 1e18;
    FOR(mask1,0,(1<<n)-1) {
        int mask2 = ((1<<n)-1) ^ mask1;
        int n1 = __builtin_popcount(mask1), n2 = n - n1;
        FOR(i,0,n1)
            FOR(j,0,n2) ans[i + j] = min(ans[i + j], bestx[mask1][i] + besty[mask2][j]);
    }
    FOR(i,0,n) cout << ans[i] << "\n";
    return 0;
}


Measured memory_bytes: 12108
use std::io::prelude::*;

fn main() {
    let stdin_ = std::io::stdin();
    let mut stdin = stdin_.lock();
    let mut buf = String::new();
    let (x, y, z, k) = {
        stdin.read_line(&mut buf).unwrap();
        let v = buf
            .split_whitespace()
            .map(|s| s.parse::<usize>().unwrap())
            .collect::<Vec<_>>();
        (v[0], v[1], v[2], v[3])
    };
    let a = {
        buf.clear();
        stdin.read_line(&mut buf).unwrap();
        let mut v = buf
            .split_whitespace()
            .map(|s| s.parse::<i64>().unwrap())
            .collect::<Vec<_>>();
        v.sort();
        v.reverse();
        v
    };
    let b = {
        buf.clear();
        stdin.read_line(&mut buf).unwrap();
        let mut v = buf
            .split_whitespace()
            .map(|s| s.parse::<i64>().unwrap())
            .collect::<Vec<_>>();
        v.sort();
        v.reverse();
        v
    };
    let c = {
        buf.clear();
        stdin.read_line(&mut buf).unwrap();
        let mut v = buf
            .split_whitespace()
            .map(|s| s.parse::<i64>().unwrap())
            .collect::<Vec<_>>();
        v.sort();
        v.reverse();
        v
    };

    let mut ans = Vec::new();
    for l in 0..x {
        for m in 0..y {
            for n in 0..z {
                if (l + 1) * (m + 1) * (n + 1) <= k {
                    ans.push(a[l] + b[m] + c[n]);
                } else {
                    break;
                }
            }
        }
    }
    ans.sort();
    ans.reverse();

    let stdout_ = std::io::stdout();
    let mut stdout = stdout_.lock();
    for an in &ans[0..k] {
        write!(stdout, "{}\n", an).unwrap();
    }
}


Measured memory_bytes: 6396
a, b = map(int, input().split())
cnt = 0
for x in range(a, b + 1):
    s = str(x)
    l = len(s)
    flg = True
    for i in range(l // 2):
        if s[i] != s[l - 1 - i]:
            flg = False
            break
    if flg:
        cnt += 1
print(cnt)


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

YES = "yes"  # type: str
NO = "no"  # type: str


def solve(S: str):
    print(YES if len(set(S)) == len(S) else NO)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N,M;
vector <int> G;





int main()
{

	cin >> N >> M;

	G.resize(N+1);

	REP(i,N+1){
		G[i]=0;
	}

	REP(i,M){
		int a,b;
		cin >> a;
		cin >> b;
		G[a]++;
		G[b]++;
	}

	int flag = 0;
	REP(i,N+1){
		if(G[i]%2!=0){
			flag = 1;
		}
	}

	if(flag)
		cout << "NO" << endl;
	else
		cout << "YES" << endl;
}



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

using namespace std;

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  cout << min(n % k, k - n % k) << '\n';
  return 0;
}

Measured memory_bytes: 384
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<ll>;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#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 rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
#define diup(a, b) (a % b == 0 ? a / b : a / b + 1)
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
//template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
//template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
//template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
//template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
//template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }
//template<class T1, class T2> bool exist_in(const T1& list, const T2& v) { return (list.end() != std::find(list.begin(), list.end(), v)); }

/*****/

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

/*****/

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

	std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	cout << (a + b + 1) / 2;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9

using namespace std;

typedef long long ll;


int add(int a, int b)
{
    int x = a+b;
    if(x >= mod)
        x -= mod;
    if(x < 0)
        x += mod;
    return x;
}
ll mul(ll a, ll b)
{
    return (a*b) % mod;
}

ll pw(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    ll sum = 0;
    for(int i = 1; i <= n; ++i)
        if(i%3 == 0 || i%5 == 0);
        else
            sum += i;
    cout << sum;
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define HEAP(T) priority_queue<T>
#define heap(T) priority_queue<T,vector<T>,greater<T> > 
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define error(...) fprintf(stderr,__VA_ARGS__)
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
using namespace std;

const int N=100005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
template<class T,class S> inline void ch(T &x,const S y){x=(x+y)%mod;}
const int BufferSize=1<<16;
char buffer[BufferSize],*Bufferhead,*Buffertail;
bool Terminal;
inline char Getchar(){
	if(Bufferhead==Buffertail){
		int l=fread(buffer,1,BufferSize,stdin);
		if(!l){Terminal=1;return 0;}
		Buffertail=(Bufferhead=buffer)+l;
	}
	return *Bufferhead++;
}
template<class T>inline bool read(T &x){
	x=0;char c=Getchar(),rev=0;
	while(c<'0'||c>'9'){c=Getchar();rev|=c=='-';if(Terminal)return 0;}
	while(c>='0'&&c<='9') x=x*10+c-'0',c=Getchar();
	x=rev?-x:x;
	return 1;
}
inline bool reads(char *x){
	char c=Getchar();
	while(c<33||c>126){c=Getchar();if(Terminal)return 0;}
	while(c>=33&&c<=126) (*x++)=c,c=Getchar();
	*x=0;return 1;
}
template<class T>inline void print(T x,const char c){
	if(!x){putchar('0');putchar(c);return;}
	if(x<0) putchar('-'),x=-x;
	int m=0,a[10];
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');
	putchar(c);
}
inline int exp(int x,int y,const int mod=::mod){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int x=1,y=0,s=1;
int n,w,h,a[105][105];

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
#endif
	scanf("%d%d",&h,&w);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int k;scanf("%d",&k);
		for(int j=1;j<=k;j++){
			y+=s;
			if(y>w){
				y=w;s=-1;x++;
			}
			else if(y==0){
				y=1;s=1;x++;
			}
			a[x][y]=i;
		}
	}
	for(int i= 1;i<=h;i++,puts(""))
		for(int j=1;j<=w;j++)
			printf("%d ",a[i][j]);
	return 0;
}

Measured memory_bytes: 384
use std::io;

fn main() {
    loop {
        let mut numbers = input_number();
        if numbers[0] == 0 && numbers[1] == 0 { break }
        numbers.sort();
        println!("{} {}", numbers[0], numbers[1]);
    }
}

#[allow(dead_code)]
fn input_number() -> Vec<i32> {
    let mut input = String::new();

    io::stdin().read_line(&mut input)
        .expect("Failed to read line");

    let vec: Vec<i32> = input
        .split_whitespace()
        .map(|x| x.parse().unwrap_or(0))
        .collect();
    vec
}



Measured memory_bytes: 5028
import sys
input = sys.stdin.readline

def readlines(n):
    for _ in range(n):
        a, b = map(int, input().split())
        yield a, b

n, m = map(int, input().split())
bridges = list(readlines(m))

tree = list(range(n+1))
rank = [1] * (n+1)

def root(v):
    while tree[v] != v:
        tree[v] = tree[tree[v]]
        v = tree[v]
    return v

def main():
    fuben = n*(n-1)//2

    for a, b in bridges[::-1]:
        x = root(a)
        y = root(b)

        if x == y:
            yield str(fuben)
            continue
        
        yield str(fuben)
        fuben -= rank[x]*rank[y]

        if rank[x] < rank[y]:
            tree[x] = y
            rank[y] += rank[x]
        else:
            tree[y] = x
            rank[x] += rank[y]

print("\n".join(list(main())[::-1]))


Measured memory_bytes: 29384
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;

long long N;

int main() {
    cin >> N;
    long long d = N;
    for (long long i = 2; i * i <= N; i++) {
        if (N % i == 0) d = N / i;
    }
    int ans = 0;
    while (d > 0) {
        d /= 10;
        ans++;
    }
    cout << ans << endl;
}

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


int main(){
    int i, j, W, H;
    while(1){
        cin >> H >> W;
        if (W==0 && H==0) break;
        for (j = 1; j < H+1; j++){
            for (i = 1; i < W+1; i++){
                if (1 < j && j < H && 1 < i && i < W){
                    cout << ".";
                }else{
                    cout << "#";
                }
            }
            cout << endl;
        }
        cout << endl;
    } 
    return 0;
}


Measured memory_bytes: 3012
a=input()
b=input()
c=input()
now="a"
while True:
    if now=="a":
        if len(a)==0:
            print("A")
            break
        now=a[0]
        a=a[1:]
    elif now=="b":
        if len(b)==0:
            print("B")
            break
        now=b[0]
        b=b[1:]
    else:
        if len(c)==0:
            print("C")
            break
        now=c[0]
        c=c[1:]

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Point[] point = new Point[n];
        int[] index = new int[n - 1];
        for (int i = 0; i < n; i++) {
            point[i] = new Point();
        }
        
        // 自分に子を割り当てる
        for (int i = 0; i < n - 1; i++) {
            int p = sc.nextInt() - 1;
            int q = sc.nextInt() - 1;
            index[i] = q;   // 出力順を記憶する
            
            point[p].child.add(q);
        }
        
        // 自分の子を若い色から塗る
        for (int i = 0; i < n; i++) {
            int nowColor = 1;
            int myColor = 0;
            if (i != 0) {
                myColor = point[i].color;
            }
            
            for (Integer children : point[i].child) {
                if (nowColor != myColor) {
                    point[children].color = nowColor;
                } else {
                    point[children].color = nowColor + 1;
                    nowColor++;
                }
                nowColor++;
            }
        }
        
        // 必要な最小色数を出力
        int max = 0;
        for (Point p : point) {
            max = Math.max(max, p.color);
        }
        System.out.println(max);
        
        // 子の色を出力順に出力
        for (int i = 0; i < n - 1; i++) {
            System.out.println(point[index[i]].color);
        }
        
    }
    
    public static class Point {
        int color;
        List<Integer> child;
        
        Point() {
            this.child = new ArrayList<Integer>();
        }
    }
}


Measured memory_bytes: 99360
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>

using namespace std;

int main()
{
    int N, M; cin >> N >> M;
    vector<int> X(M, 0);

    for (auto &i: X)
        cin >> i;
    
    sort(X.begin(), X.end());
    
    vector<int> dif(M-1, 0);
    for (int i = 0; i < M-1; ++i)
        dif[i] = X[i+1] - X[i];
    
    sort(dif.begin(), dif.end(), greater<int>() );

    int ans = X[M-1] - X[0];
    for (int i = 0; i < N-1 && i < M-1; ++i){
        ans -= dif[i];
    }
    
    cout << ans << endl;        
}

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

int main(){
	int s;
	int ans;
	std::vector<bool> isfound(10000000, false);

	std::cin>>s;

	for(int i=0; i<10000000; i++){
		if(!isfound[s]){
			isfound[s]= true;
		}
		else{
			ans= i+1;
			break;
		}

		if(s%2==0)
			s=s/2;
		else
			s= 3*s+1;
	}

	std::cout<<ans<<std::endl;

	return 0;
	
}

Measured memory_bytes: 1408
import collections
q = int(input())
A = collections.deque()
ans = list()
for i in range(q):
    query = list(map(int, input().split()))
    if query[0] == 0:
        if query[1] == 0:
            A.appendleft(query[2])
        elif query[1] == 1:
            A.append(query[2])
    elif query[0] == 1:
        ans.append(A[query[1]])
    elif query[0] == 2:
        if query[1] == 0:
            A.popleft()
        elif query[1] == 1:
            A.pop()
for a in ans:
    print(a)


Measured memory_bytes: 21840
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();
        long[] a = new long[n];
        for(int i=0; i<n; i++){
            a[i] = sc.nextLong();
        }
		sc.close();
        
        long ans = a[0] / 2;
        a[0] -= ans * 2;
        for(int i=1; i<n; i++){
            if(a[i] + a[i-1] >= 2) a[i] += a[i-1];
            long tmp = a[i] / 2;
            a[i] -= tmp * 2;
            ans += tmp;
        }
        System.out.print(ans);
	}
}


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

int main(){
	int a, b, r, x, y;

	while ( cin >> a >> b ){

		if ( a >= b ){
			x = a;
			y = r = b;
		}else{
			x = b;
			y = r = a;
		}

		while ( 1 ){
			r = x % y;
			if ( !r ) break;
			x = y;
			y = r;
		}

		x =  ( a / y ) * b ;

		cout << y << " " << x << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N = 0;
	char c;
	while ((c = getchar_unlocked()) >= '0') N = N * 10 + c - '0';

	int dp[3000] = {};
	dp[0] = 1;
	const int mod = 1e9 + 7;
	rep(i, N - 1) {
		if (getchar_unlocked() == '<') {
			int k = 0;
			int tmp = dp[0];
			dp[0] = 0;
			rep(j, i + 1) {
				k += tmp;
				if (k >= mod) k -= mod;
				tmp = dp[j + 1];
				dp[j + 1] = k;
			}
		}
		else {
			int k = 0;
			for (int j = i; j >= 0; j--) {
				k += dp[j];
				if (k >= mod) k -= mod;
				dp[j] = k;
			}
		}
	}
	ll kotae = 0;
	rep(i, N) kotae += dp[i];
	printf("%lld", kotae % mod);

	Would you please return 0;
}

Measured memory_bytes: 128
def dfs(cnt, num, top):
    if cnt == 10:
        return
    v.add(int(num))
    if top == 0:
        dfs(cnt+1, "0"+num, top)
        dfs(cnt+1, "1"+num, top+1)
    elif top == 9:
        dfs(cnt+1, "8"+num, top-1)
        dfs(cnt+1, "9"+num, top)
    else:
        dfs(cnt+1, str(top-1)+num, top-1)
        dfs(cnt+1, str(top)+num, top)
        dfs(cnt+1, str(top+1)+num, top+1)


k = int(input())
v = set()
for i in range(10):
    dfs(0, str(i), i)
v = list(v)
v.sort()
v.pop(0)
print(v[k-1])


Measured memory_bytes: 26124
#include<cstdio>
#include<iostream>
using namespace std;
int x,y;
int main()
{
	scanf("%d%d",&x,&y);
	for(int i=1;i<=3;++i)
	if(i!=x && i!=y)
	{
		printf("%d\n",i);
		break;
	}
	return 0;
}

Measured memory_bytes: 256
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

ll dp[1001][1001];
ll ans[150];
int main() {
	cin >> N;
	rep(n, N){
		string X, Y;
		cin >> X;
		cin >> Y;
		rep(i, 1001){
			rep(j, 1001){
				dp[i][j] = 0;
			}
		}
		ll maxv = 0;
		rep(i, X.size()){
			rep(j, Y.size()){
				if(X[i] == Y[j]) dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1);
				dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
				dp[i][j+1] = max(dp[i][j+1], dp[i][j]); 
			}
		}
		rep(i, X.size()+1){
			rep(j, Y.size()+1){
				maxv = max(maxv, dp[i][j]);
			}
		}
		ans[n] = maxv;
	}
	rep(i, N){
		cout << ans[i] << endl;
	}
}


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

int n;
double x[100],y[100];

double distance(double p){
  double sum=0;
  for(int i=0; i<n; i++){
	double w=abs(x[i]-y[i]);
	sum += pow(w,p);
  }
  return pow(sum,1.0/p);
}

int main(){
  cout << fixed << setprecision(12);
  cin >> n;
  for(int i=0; i<n; i++) cin >> x[i];
  for(int i=0; i<n; i++) cin >> y[i];

  cout << distance(1) << endl;
  cout << distance(2) << endl;
  cout << distance(3) << endl;
  double mx = 0;
  for(int i=0; i<n; i++) mx = max(mx,abs(x[i]-y[i]));

  cout << mx << endl;
  return 0;
}
/*#include<bits/stdc++.h>
using namespace std;
int main(){
  cout << fixed << setprecision(12);
  int n;
  double a=0,b=0,c=0,d=0;
  double sum1=0,sum2=0,sum3=0,sum4=0;
  double ans1=0,ans2=0,ans3=0,ans4=0;
  cin >> n;
  double x[1000];
  double y[1000];

  for(int i=0; i<n; i++) cin >> x[i];
  for(int i=0; i<n; i++) cin >> y[i];

  for(int i=0; i<n; i++){
	a = fabs(x[i]-y[i]);
	a = pow(a,1);
	sum1 += a;
	//ans1 = sqrt(sum1);
	ans1 = pow(sum1,(double)1.0/1);
  }
  for(int i=0; i<n; i++){
	b = fabs(x[i]-y[i]);
	b = pow(b,2);
	sum2 += b;
	ans2 = pow(sum2,(double)1.0/2);
  }
  for(int i=0; i<n; i++){
	c = fabs(x[i]-y[i]);
	c = pow(c,3);
	sum3 += c;
	ans3 = pow(sum3,(double)1.0/3);
  }
  for(int i=0; i<n; i++){
	d = fabs(x[i]-y[i]);
	d = pow(d,100000000000000);
	sum4 += d;
	ans4 = pow(sum4,(double)1.0/1000000000000000);
  }
  cout << ans1 << endl;
  cout << ans2 << endl;
  cout << ans3 << endl;
  cout << ans4 << endl;
}
*/


Measured memory_bytes: 3464
#include <iostream>
#include <limits.h>
#include <algorithm>
using namespace std;

int n, h[100010], k;
int dp[100010];

int solve(int l) {
    if (dp[l] >= 0) return dp[l];
    
    int x[105], min = 1e9;
    for (int i = 0; i < k && l - 1 - i > 0; i++) {
        x[i] = solve(l - 1 - i) + abs(h[l] - h[l - 1 - i]);
        if (x[i] < min) min = x[i];
    }
    dp[l] = min;
    return dp[l];
}


int main(void){
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
        dp[i] = -1;
    }
    dp[1] = 0;  h[0] = h[1];
    
    
    cout << solve(n) << endl;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
#define mod 1000000007
#define MAX 10001
#define f(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rf(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);i--)
#define pb push_back
#define pf push_front
#define nl cout << "\n";
 
//void ini(){
//	#ifndef ONLINE_JUDGE
//		freopen("input.txt","r",stdin);
//		freopen("output.txt","w",stdout);
//	#endif
//}

ll v[101],w[101],dp[101][100001];

ll knapsack(ll n,ll wt){
	if(n==0 || wt==0){
		return 0;
	}

	if(dp[n][wt]!=-1){
		return dp[n][wt];
	}

	if(w[n]>wt){
		return dp[n][wt]=knapsack(n-1,wt);
	}else{
		return dp[n][wt]=max(v[n]+knapsack(n-1,wt-w[n]),knapsack(n-1,wt));
	}
}

int main(){
	//ini();
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
    ll n,wt;
    cin >> n >> wt;
    f(i,1,n+1){
    	cin >> w[i]>> v[i];
    }

    memset(dp,-1,sizeof(dp));

    cout << knapsack(n,wt);

}

Measured memory_bytes: 79232
n=int(input())
a=list(map(int,input().split()))
b=[0]*(10**5)
for i in range(n):
    if a[i]==0:
        b[0]+=1
        b[1]+=1
    elif a[i]==(10**5)-1:
        b[(10**5)-1]+=1
        b[(10**5)-2]+=1
    else:
        b[a[i]]+=1
        b[a[i]-1]+=1
        b[a[i]+1]+=1
print(max(b))

Measured memory_bytes: 13964
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;

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


Measured memory_bytes: 256
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
xy=[lnii() for i in range(n)]
xy.sort(key=lambda x:x[0])

ans=n

pq=[]
for i in range(n-1):
  for j in range(i+1,n):
    t_p=xy[j][0]-xy[i][0]
    t_q=xy[j][1]-xy[i][1]
    pq.append([t_p,t_q])

for p,q in pq:
  cnt=0
#  for x,y in xy:
#    if [x+p,y+q] in xy:
#      cnt+=1
  for i in range(n):
    for j in range(n):
      if i==j:
        continue
      x1,y1=xy[i]
      x2,y2=xy[j]
      if (x2-x1)==p and (y2-y1)==q:
        cnt+=1
  ans=min(ans,n-cnt)
print(ans)

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

int main()
{
	int L,m;
	double v,a,b,c;
	cin>>L;
	a=L*1.0/3;
	b=(L-a)/2;
	c=L-a-b;
	v=a*b*c;
	cout<<fixed<<setprecision(12)<<v;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
#define end getchar();getchar();return 0
int inf = 1000000000;
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt=1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
int prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
void prime_factor(int n){
	int cnt = 1;
	map<int, int>res;
	int m = n;
	for (int i = 2; i<= n; i++) {
		if(prime(i)){
			while (m%i == 0) {
				++res[i];
				m /= i;
			}
		}
	}
	cout << n <<":"<< endl;
	for (int i = 2; i<= n; i++) {
		if (res[i]) {
			cout << i << " " << res[i] << endl;
		}
	}
	cout << endl;
}
/*Library End!*/
int n, t[100005], ans;
map<int, int>mp;
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> t[i];
	sort(t, t + n);
	for (int i = 0; i < n; i++) {
		int s = upper_bound(t, t + n, t[i]) - lower_bound(t, t + n, t[i]);
		if (s < t[i])ans += s;
		else ans += s - t[i];
		i += s - 1;
	}
	cout << ans << endl;
	end;
}

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

int main(){
    string a,b;
    cin >> a >> b;
    if(a.length()>b.length()){cout << "GREATER" << endl;}
    else if(a.length()<b.length()){cout << "LESS" << endl;}
    else if(a==b){cout << "EQUAL" << endl;}
    else cout << (a > b ? "GREATER":"LESS") << endl;
    return 0;
}

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

vector<int> G[100010];
int L[2][100010];


void dfs(int T, int V, int cost) {
	L[T][V] = cost;
	rep(i, G[V].size()) {
		if (L[T][G[V][i]] != INF) continue;
		dfs(T, G[V][i], cost + 1);
	}
}

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

	int N;
	cin >> N;
	rep(i, N-1) {
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	rep(i, 2) rep(j, 100010) L[i][j] = INF;
	dfs(0, 1, 0);
	dfs(1, N, 0);
	int Fennec = 0;
	int Snuke = 0;
	REP(i, 1, N) {
		if (L[0][i] <= L[1][i]) Fennec++;
		else Snuke++;
	}
	if (Fennec > Snuke) cout << "Fennec" << endl;
	else cout << "Snuke" << endl;

    return 0;
}


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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if((A!=B&&B!=C&&C!=A)||(A==B&&B==C&&C==A)){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD 998244353
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int H, W;
int A[302][302];

int main()
{
	scanf("%d%d", &H, &W);
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) scanf("%d", &(A[i][j]));
	}
	int piv = 0;
	for (int i = 0; i < W; ++i) {
		int r = -1;
		for (int j = piv; j < H; ++j) {
			if (A[j][i] == 1) {
				r = j;
				break;
			}
		}
		if (r == -1) continue;
		if (r != piv) for (int j = 0; j < W; ++j) swap(A[r][j], A[piv][j]);
		for (int j = 0; j < H; ++j) if (j != piv && A[j][i] == 1) {
			for (int k = i; k < W; ++k) A[j][k] ^= A[piv][k];
		}
		++piv;
	}
	i64 ret = 1;
	for (int i = 0; i < H; ++i) ret = ret * 2 % MOD;
	i64 sub = 1;
	for (int i = 0; i < (H - piv); ++i) sub = sub * 2 % MOD;
	ret += MOD - sub;
	ret %= MOD;
	for (int i = 0; i < W - 1; ++i) ret = ret * 2 % MOD;
	printf("%lld\n", ret);
	return 0;
}


Measured memory_bytes: 640
import sys
a=int(input())
l=[int(input()) for _ in range(a)]
c=1
n=l[0]
for i in range(a+1):
  if n==2:
    print(c)
    sys.exit()
  m=l[n-1]
  l[n-1]=0
  n=m
  c+=1
  if n==0:break
print(-1)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;


int main(){
    map<char,P> ma;
    ma['N'] = P(1,0);
    ma['E'] = P(0,1);
    ma['S'] = P(-1,0);
    ma['W'] = P(0,-1);
    while(cin >> n && n){
        vector<vector<bool>> f(30,vector<bool>(30,false));
        rep(i,n){
            ll x,y;
            cin >> x >> y;
            f[y][x] = 1;
        }
        ll m;
        cin >> m;
        P pos = P(10,10);
        f[10][10] = 0;
        rep(i,m){
            char c;
            int x;
            cin >> c >> x;
            rep(j,x){
                pos.first += ma[c].first;
                pos.second += ma[c].second;
                f[pos.first][pos.second] = 0;
            }
            // cout << pos.first << " " << pos.second << endl;
        }
        bool F = 1;
        rep(i,30){
            rep(j,30)if(f[i][j])F = 0;
        }
        if(F)cout << "Yes" << endl;
        else cout << "No" << endl;
    }

}


Measured memory_bytes: 3008
#include <iostream>

using namespace std;
int a[5];
int main()
{
    int s,res=0;
    cin>>s;
    for(int i=0; i<4; i++)
    {
        a[i]=s%10;
        s=s/10;
    }
    for(int i=0; i<4; i++)
    {
        if(a[i]==a[i+1])
        {
            res++;
        }
        if(i==2)
        {
            break;
        }
    }
    if(res!=0)
    {
        cout<<"Bad";
    }
    else
    {
        cout<<"Good";
    }
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using Double = long double;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        string S;
        cin >> S;
        auto is_tapi_chang = [](string s) {
            string t = s;
            reverse(all(t));
            return t == s;
        };

        Int N = S.size();
        string tree, neri;
        for (int i = 1; i <= S.size(); ++i) {
            if (i >= 1 && i <= (N - 1) / 2) {
                tree += S[i - 1];
            }
            if (i >= (N + 3) / 2 && i <= N) {
                neri += S[i - 1];
            }
        }
        if (is_tapi_chang(S) && is_tapi_chang(tree) && is_tapi_chang(neri)) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
def main():
    n = int(input())
    p = list(map(int, input().split()))

    cnt = 0
    for i in range(n):
        if p[i] != i+1:
            cnt += 1
        if cnt > 2:
            break
    if cnt == 0 or cnt == 2:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  string s; cin >> s;
  stack<bool> st;
  int cnt = 0;
  for(int i=0;i<(int)(s.size());++i) {
    int now = s[i] - '0';
    if(st.empty() || st.top() == now) {
      st.push(now);
    } else {
      cnt++;
      st.pop();
    }
  }
  cout << cnt * 2 << endl;
}


Measured memory_bytes: 512
import numpy as np
def cumsum(x):
    return list(np.cumsum(x))

def cumsum_number(N,K,x):
    ans=[0]*(N-K+1)
    number_cumsum = cumsum(x)
    number_cumsum.insert(0,0)
    for i in range(N-K+1):
        ans[i]=number_cumsum[i+K]-number_cumsum[i]
    return ans
"""
int #整数
float #小数

#for
for name in fruits: #fruitの頭から操作
    print(name)

#リスト
list0 = [] #リスト生成
list0 = [1,2,3,4] #初期化
list0 = [0]*10 #[0,0,0,0,0,0,0,0,0,0]
list1= [i for i in range(10)] #>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
list1 = list(map(int, input().split()))　# 複数の入力をリストに入れる
number=[int(input()) for i in range(int(input()))] #複数行の入力をリストに
list1 = list1 + [6, 7, 8] #リストの追加
list2.append(34) #リストの追加　最後に（）内が足される
list.insert(3,10) #リストの追加　任意の位置（追加したい位置,追加したい値）
len(list4) #リストの要素数
max(sa) #list saの最小値
list5.count(2) #リスト(文字列も可）内の2の数
list1.sort() #並び替え小さい順
list1.sort(reverse=True)  #並び替え大きい順
set(list1) #list1内の重複している要素を削除し、小さい順に並べる
sum([2,3,   ,3]) #リストの合計

abs(a) #aの絶対値
max(a,b) min(a,b) #最大値　最小値
text1 = text1.replace("34","test") #text1内の"34"を"test"に書き換える(文字列内の文字を入れ替える)

exit(0) #強制終了

cumsum(リスト) #累積和をリストで返す
cumsum_number(N,K,x) #N個の数が含まれるリストx内のK個からなる部分和をリストで返す
"""
N,K=map(int,input().split())
number=[1]*N
for i in range(K):
    A=int(input())
    number1=map(int,input().split())
    for j in number1:
        number[j-1]=0
print(number.count(1))



Measured memory_bytes: 27012
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    double d,t,s;
    cin>>d>>t>>s;
    if(d/s <= t)cout<<"Yes";
    else cout<<"No";
    return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int n;
  string s;
  cin >> n >> s;

  const ll mod = 1e9+7;
  vvl dp(n+1, vl(n+1));
  dp[1][1] = 1LL;
  rep(i,2,n+1) {
    rep(j,1,i+1) {
      if (s[i-2] == '>') dp[i][j] += dp[i-1][j-1];
      else dp[i][j] += (dp[i-1][i-1]-dp[i-1][j-1]+mod)%mod;
      dp[i][j] %= mod;
    }
    rep(j,1,i+1) {
      dp[i][j] += dp[i][j-1];
      dp[i][j] %= mod;
    }
  }

  cout << dp[n][n] << '\n';
}

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

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

  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  sort(A.begin(), A.end());

  if(N % 2){
    long long ans1 = - A[N / 2] - A[N / 2 + 1];
    for(int i = 0; i < N / 2; i++){
      ans1 -= 2 * A[i];
    }
    for(int i = N / 2; i < N; i++){
      ans1 += 2 * A[i];
    }

    long long ans2 = A[N / 2 - 1] + A[N / 2];
    for(int i = 0; i < N / 2 + 1; i++){
      ans2 -= 2 * A[i];
    }
    for(int i = N / 2 + 1; i < N; i++){
      ans2 += 2 * A[i];
    }
    cout << max(ans1, ans2) << endl;
  }else{
    long long ans = A[N / 2 - 1] - A[N / 2];
    for(int i = 0; i < N / 2; i++){
      ans -= 2 * A[i];
    }
    for(int i = N / 2; i < N; i++){
      ans += 2 * A[i];
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 640