akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

int dx[] = {0, -1, 1, 0};
int dy[] = {-1, 0, 0, 1};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int w, h, n;
    cin >> w >> h >> n;
    int mp[105][105] = {};
    swap( w, h );
    for( int i = 0; i < n; ++i ) {
        int x, y, a;
        cin >> x >> y >> a;
        if( a == 1 ) {
            for( int j = 0; j <= x - 1; ++j ) {
                for( int k = 0; k <= w; ++k ) mp[j][k] = 1;
            }

        } else if( a == 2 ) {
            for( int j = x; j <= h; ++j ) {
                for( int k = 0; k <= w; ++k ) mp[j][k] = 1;
            }
        
        } else if( a == 3 ) {
            for( int j = 0; j <= h; ++j ) {
                for( int k = 0; k <= y - 1; ++k ) mp[j][k] = 1;

            }
        } else if( a == 4 ) {
            for( int j = 0; j <= h; ++j ) {
                for( int k = y; k <= w; ++k ) mp[j][k] = 1;
            }
        
        }
    }

    int cnt = 0;
    for( int i = 0; i < h; ++i ) {
        for( int j = 0; j < w; ++j ) if( !mp[i][j] ) ++cnt;;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int A[3][3];
int N,x=0,y=0,z=0;
int x1=0,y1=0,z1=0;
int x2=0,y2=0,z2=0;
int x3=0,y3=0,z3=0;
int x4=0,y4=0,z4=0;
int x5=0,y5=0,z5=0;
int x6=0,y6=0,z6=0;
int x7=0,y7=0,z7=0;
  for(int i=0;i<3;i++){
     for(int j=0;j<3;j++){
     	scanf("%d",&A[i][j]);
     }
  }
 
scanf("%d",&N);
int b[N];
  
  for(int k=0;k<N;k++){
  	scanf("%d",&b[k]);
  }
  
  for(int i=0;i<N;i++){
  	if(A[0][0]==b[i]) x=1;
  	if(A[1][1]==b[i]) y=1;
  	if(A[2][2]==b[i]) z=1;
 
    if(A[0][0]==b[i]) x1=1;
    if(A[0][1]==b[i]) y1=1;
    if(A[0][2]==b[i]) z1=1;
    
    if(A[1][0]==b[i]) x2=1;
    if(A[1][1]==b[i]) y2=1;
    if(A[1][2]==b[i]) z2=1;
    
    if(A[2][0]==b[i]) x3=1;
    if(A[2][1]==b[i]) y3=1;
    if(A[2][2]==b[i]) z3=1;
    
    if(A[0][0]==b[i]) x4=1;
    if(A[1][0]==b[i]) y4=1;
    if(A[2][0]==b[i]) z4=1;
    
    if(A[0][1]==b[i]) x5=1;
    if(A[1][1]==b[i]) y5=1;
    if(A[2][1]==b[i]) z5=1;
    
    if(A[0][2]==b[i]) x6=1;
    if(A[1][2]==b[i]) y6=1;
    if(A[2][2]==b[i]) z6=1;
    
    if(A[2][0]==b[i]) x7=1;
    if(A[1][1]==b[i]) y7=1;
    if(A[0][2]==b[i]) z7=1;
  }
  
  if((x==1&&y==1&&z==1)||(x1==1&&y1==1&&z1==1)||(x2==1&&y2==1&&z2==1)||(x3==1&&y3==1&&z3==1)|(x4==1&&y4==1&&z4==1)||(x==5&&y==5&&z5==1)||(x6==1&&y6==1&&z6==1)||(x7==1&&y7==1&&z7==1))
  	printf("Yes");
  else
  	printf("No");
  
return 0;
}

Measured memory_bytes: 128
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N int

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt()
	a := make([]int, N+1)
	for i := 1; i <= N; i++ {
		a[i] = nextInt()
	}
	next := 1
	ans := -1
	for i := 1; i <= N; i++ {
		if next == 2 {
			ans = i - 1
			break
		}
		next = a[next]
	}

	fmt.Println(ans)
}


Measured memory_bytes: 3164
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<deque>
using namespace std;

using ll = long long;
const int INF = 1001001001;

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

int g[2001][2001];
int result[2001];
vector< vector<int> > graph(2001);


void makeDist(int count, int index, int now)
{
    g[index][now] = min(g[index][now], count);
    if (g[index][now] != count) return;
    for (int i = 0; i < graph[now].size(); i++) {
        makeDist(count+1, index, graph[now][i]);
    }
}

int main()
{
    rep(i, 2001) {
        rep(j, 2001) {
            g[i][j] = INF;
        }
    }

    int n, x, y;
    cin >> n >> x >> y;
    x--; y--;
    int m = min(x, y);
    int l = max(x, y);
    rep(i, n) {
        if (i + 1 < n) graph[i].push_back(i + 1);
        if (i - 1 >= 0) graph[i].push_back(i - 1);
        if (i == m) graph[i].push_back(l);
        if (i == l) graph[i].push_back(m);
    }

    rep(i, n) {
        makeDist(0, i, i);
    }

    rep(i, n) {
        for (int j = i; j < n; j++) {
            result[g[i][j]]++;
        }
    }

    for (int i = 1; i < n; i++) {
        cout << result[i] << endl;
    }
}


Measured memory_bytes: 16128
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <functional>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
#define repd(i,x,y) for (int i=x; i>=y; --i)
using namespace std;

typedef long long LL;
int n,m,k,tot,heap[100100];
LL sum1[100100],sum2[100100],sum,ans;
struct data
{
    int a,b;
    bool operator<(const data &t) const
    {
        return a-b>t.a-t.b;
    }
} a[100100];

int getint()
{
    char ch;
    while (!isdigit(ch=getchar()));
    int x=ch-'0';
    for (; isdigit(ch=getchar()); x=x*10+ch-'0');
    return x;
}

int main()
{
    scanf("%d%d%d",&n,&m,&k);
    repu(i,1,n+m+k)
    {
        int t;
        a[i].a=getint(),a[i].b=getint(),t=getint();
        sum+=t,a[i].a-=t,a[i].b-=t;
    }
    sort(a+1,a+n+m+k+1);
    repu(i,1,n)
        sum1[n]+=heap[++tot]=a[i].a,push_heap(heap+1,heap+tot+1,greater<int>());
    repu(i,n+1,n+k)
        if (heap[1]<a[i].a)
        {
            sum1[i]=sum1[i-1]-heap[1]+a[i].a;
            pop_heap(heap+1,heap+tot+1,greater<int>());
            heap[tot]=a[i].a,push_heap(heap+1,heap+tot+1,greater<int>());
        }
        else
            sum1[i]=sum1[i-1];
    tot=0,ans=-1LL<<60;
    repd(i,n+m+k,n+k+1)
        sum2[n+k+1]+=heap[++tot]=a[i].b,push_heap(heap+1,heap+tot+1,greater<int>());
    repd(i,n+k,n+1)
        if (heap[1]<a[i].b)
        {
            sum2[i]=sum2[i+1]-heap[1]+a[i].b;
            pop_heap(heap+1,heap+tot+1,greater<int>());
            heap[tot]=a[i].b,push_heap(heap+1,heap+tot+1,greater<int>());
        }
        else
            sum2[i]=sum2[i+1];
    repu(i,n,n+k)
        ans=max(ans,sum1[i]+sum2[i+1]);
    printf("%lld\n",ans+sum);
    return 0;
}

Measured memory_bytes: 2048
import java.util.*;
	public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            //入力
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            
            String many = "";
            String few = "";
            
            if(a < b){
            	many = "#";
            	few = ".";
            }else{
            	many = ".";
            	few = "#";
            }
            
            //出力
            System.out.println(64 + " " + 63);
            
            printrow(Math.max(a, b)-1, many, few, 31);
            
            for(int i=0; i<63; i++){
    			System.out.print(few);
    		}
    		System.out.println("");
    		
    		for(int i=0; i<63; i++){
    			System.out.print(many);
    		}
    		System.out.println("");
    		
    		printrow(Math.min(a, b)-1, few, many, 31);
            
            sc.close();
        }
        
        public static void printrow(int n, String many, String few, int count){
        	if(count==0){
        		return;
        	}else if(count%2 == 0){
        		for(int i=0; i<63; i++){
        			System.out.print(few);
        		}
        		System.out.println("");
        		printrow(n, many, few, count-1);
        	}else if(n >= 32){
        		for(int i=0; i<31; i++){
        			System.out.print(many + few);
        		}
        		System.out.println(many);
        		printrow(n-32, many, few, count-1);
        	}else if(n==0){
        		for(int i=0; i<63; i++){
        			System.out.print(few);
        		}
        		System.out.println("");
        		printrow(0, many, few, count-1);
        	}else{
        		for(int i=0; i<n; i++){
        			System.out.print(many + few);
        		}
        		for(int i=0; i<63-2*n; i++){
        			System.out.print(few);
        		}
        		System.out.println("");
        		printrow(0, many, few, count-1);
        	}	
        }
	}
	

Measured memory_bytes: 22484
X=input()
X=int(X)

def bool(X):
	for i in range(2,X):
		if X%i==0:
			flag=True
			return flag

	flag=False
	return flag

flag=True
while flag:
	flag=bool(X)
	if flag==False:
		break
	X+=1
print(X)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); ++i)
const int nil = 1e8;

int main() {
    vector<vector<int>> g(3, vector<int>(3));
    rep(i, 3) rep(j, 3) cin >> g[i][j];
    vector<int> a(3, nil), b(3, nil);
    a[0] = g[0][0];
    rep(i, 3) b[i] = g[0][i] - a[0];
    for (int i=1; i<3; ++i) {
        a[i] = g[i][0] - b[0];
    }
    vector<vector<int>> check(3, vector<int>(3));
    rep(i, 3) rep(j, 3) check[i][j] = a[i] + b[j];
    cout << (g == check ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
const int sz = 1e5, ma = 1e9;
int a[sz];
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
int abs(int a) { return max(a, -a); }
main()
{
    int n;
    scanf("%lld", &n);
    int cnt = 0, mi = ma;
    int ans = 0;
    rep(i, n)
    {
        scanf("%lld", a + i);
        if (a[i] < 0)
        {
            cnt++;
            a[i] = -a[i];
        }
        ans += a[i];
        mi = min(mi, a[i]);
    }
    if (cnt % 2)
        ans -= 2 * mi;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.IOException;

public class Main {

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int[][] floor = new int[13][11];
        int n = Integer.parseInt(br.readLine());
        while (n-- > 0) {
            String[] st = br.readLine().split(" ");
            int block = Integer.parseInt(st[0]);
            int y = Integer.parseInt(st[1]);
            int x = Integer.parseInt(st[2]);
            int value = Integer.parseInt(st[3]);
            floor[(3 * (block - 1)) + y][x] += value;
        }

        for (int i = 1; i < 13; i++) {
            for (int j = 1; j < 11; j++) {
                bw.append(" " + floor[i][j]);
            }
            bw.newLine();
            if (i % 3 == 0 && i < 12) {
                bw.append("####################\n");
            }
        }

        bw.flush();
    }

}



Measured memory_bytes: 24632
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn solve(n: usize, b: Vec<u32>) -> u32 {
  let mut a = vec![0; n];

  a[n - 1] = b[n - 2];
  a[0] = b[0];
  for i in (1..n-1).rev() {
    a[i] = std::cmp::min(b[i], b[i - 1]);
  }

  a.iter().sum()
}

fn main() {
  input! {
    n: usize,
    b: [u32; n - 1]
  };

  println!("{0}", solve(n, b));
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n; string s; cin >> n >> s;
    int ans = 0;
    int x = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'I') x++;
        else x--;
        ans = max(ans,x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int,input().split())
x = list(map(int, input().split()))

ans = 999999999

for i in range(n - k + 1):
    a = abs(x[i]) + (x[i + k - 1] - x[i])
    b = abs(x[i + k - 1]) + (x[i + k - 1] - x[i])
    ans = min(ans, a, b)
    
print(ans)

Measured memory_bytes: 14224
#!/usr/bin/env python3
import sys
import collections
input = sys.stdin.readline

a,b= map(int,input().split())
if b==0:
    print(a)
    sys.exit()
A = list(map(int,input().split()))
for i in range(100):
    if a - i not in A:
        print(a-i)
        sys.exit()
    if a + i not in A:
        print(a+i)
        sys.exit()




Measured memory_bytes: 9468
#include <stdio.h>



int main(void)
{
	//変数の宣言
	int N,i;
	int ans;
	
	//データの読み込み
	scanf("%d %d",&N,&i);
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	ans = N-i+1;
	
//	printf("計算部分終了\n");
	
	//出力
	
	printf("%d",ans);
	
//	printf("結果の出力終了\n");
	
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    long long k; cin >> k;
    int a[n]; for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a+n);
    long long lb = -1e18, ub = 1e18+1;
    // x 以上が k 個以上ある最小の x
    while (ub - lb > 1) {
        long long m = (lb + ub) / 2;
        long long cnt = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] > 0) {
                // a[j] <= floor(m / a[i])
                long long t = m >= 0 ? m / a[i] : (m + 1) / a[i] - 1;
                cnt += upper_bound(a, a+n, t) - a;
                if (a[i] <= t) cnt--;
            } else if (a[i] < 0) {
                // a[j] >= ceil(m / a[i])
                long long t = m >= 0 ? (- m) / (- a[i]) : (- m - 1) / (- a[i]) + 1;
                cnt += n - (lower_bound(a, a+n, t) - a);
                if (a[i] >= t) cnt--;
            } else if (m >= 0) cnt += n-1;
            //cout << m << ' ' << i << ' ' << cnt << endl;
        }
        //cout << ub << ' ' << lb << ' ' << k << ' ' << cnt  << endl;
        if (cnt/2 >= k) ub = m;
        else lb = m;
    }
    cout << ub << endl;
}


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

int main() {
  int n, t;
  cin >> n >> t;
  double x, h;
  long double highest = 0;
  int i;
  for (i = 0; i < n; i++) {
    cin >> x >> h;
    highest = max(highest, (long double)(h / x));
  }
  cout << setprecision(10) << t * highest << endl;
  return 0;
}



Measured memory_bytes: 3296
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;
import javax.xml.ws.WebEndpoint;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main implements Runnable
{
    static int dx[]={-1,0,1,0};
    static int dy[]={0,-1,0,1};
    static long mod=1000000007;
    
    public static void main(String[] args) {        
        new Thread(null, new Main(), "", 200 * 1024 * 1024).start();        
    }

    public void run() {
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        int m=sc.nextInt();
        if(n<=m) {
        	for (int i = 0; i < m; i++) {
                out.print(n);
			}
        }
        else {
        	for (int i = 0; i < n; i++) {
                out.print(m);
			}
        }

        out.println();
     	out.flush();
    }
        
    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }

    static void ret(long ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x,y; double d;
//	P(int  x, int y, double d) {
//	  this.x=x;
//	  this.y=y;
//	  this.d=d;
//	}
//}


class P implements Comparable<P>{
    int x,y;
    P(int x,int y) {
    	this.x=x;
    	this.y=y;
    }

    public int compareTo(P p){
        return y-p.y;
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString()
    {
        while( st==null || !st.hasMoreTokens() )
			try {
				st = new StringTokenizer(x.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        return st.nextToken();
    }
    public int nextInt()
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) {
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) {
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() {
        return this.nextString().toCharArray();
    }    
    public long nextLong()
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 22484
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,m,d;
	scanf("%lld%lld%lld",&n,&m,&d);
	if(d==0){
		double tmp=1.0*(m-1)/n;
		printf("%.10f",tmp);
	}else{
		double tmp=2.0*(n-d)*(m-1)/(n*n);
		printf("%.10f",tmp);
	}
	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
S = input()
pos = N
ans = []
while pos > 0:
    for i in range(M, 0, -1):
        if pos - i < 0 or S[pos - i] == '1':
            continue
        ans.append(i)
        pos -= i
        break
    else:
        ans = [-1]
        break
print(*ans[::-1])

Measured memory_bytes: 6372
#include <iostream>
using namespace std;
using ull=unsigned long long; 

int main()
{
    int N;
    ull ans = 1;
    cin >> N;

    for (int i = 1; i <= N; i++) {
        ans *= i;
        ans %= 1000000007;
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> x(n), y(n);
  vector<LL> nx(n), ny(n);
  rep(i, n) {
    cin >> x[i] >> y[i];
    nx[i] = x[i], ny[i] = y[i];
  }
  sort(all(nx));
  sort(all(ny));

  LL ans = (nx.back() - nx.front()) * (ny.back() - ny.front());
  rep(lx, n) for (int rx = lx + 1; rx < n; rx ++) rep(dy, n) for (int uy = dy + 1; uy < n; uy ++) {
    LL left = nx[lx], right = nx[rx];
    LL up = ny[uy], down = ny[dy];
    int num = 0;
    rep(i, n) {
      if (left <= x[i] && x[i] <= right && down <= y[i] && y[i] <= up) num ++;
    }
    if (k <= num) {
      ans = min(ans, (right - left) * (up - down));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define loop(i,n) rep(i,0,n)
using namespace std;
using ll = long long;
template<typename weight_t> using graph = vector<vector<pair<int,weight_t>>>;
int main(){
    int n,m;
    cin >> n >> m;
    graph<int> g(n);
    loop(i,m){
        int a,b;
        cin >> a >> b;
        g[a-1].push_back({b-1,1});
        g[b-1].push_back({a-1,1});
    }
    int itr=0;
    while(g[itr].empty())++itr;
    int jtr=g[itr][0].first;
    deque<int> path;
    path.push_front(itr);
    path.push_back(jtr);
    vector<bool> used(n,false);
    used[itr]=true;
    used[jtr]=true;
    while((int)path.size()<n){
        int new_itr=0;
        while(new_itr<(int)g[itr].size()&&used[g[itr][new_itr].first])++new_itr;
        if(new_itr==(int)g[itr].size())break;
        itr=g[itr][new_itr].first;
        path.push_front(itr);
        used[itr]=true;
    }
    while((int)path.size()<n){
        int new_jtr=0;
        while(new_jtr<(int)g[jtr].size()&&used[g[jtr][new_jtr].first])++new_jtr;
        if(new_jtr==(int)g[jtr].size())break;
        jtr=g[jtr][new_jtr].first;
        path.push_back(jtr);
        used[jtr]=true;
    }
    cout << path.size() << endl;
    while(!path.empty()){
        cout << path.front()+1;
        path.pop_front();
        if(!path.empty())cout << " ";
    }
    cout << endl;
    return 0;
}

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

int H, W;
int N;
int a[10001];
int data[101][101];

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

    cin >> H >> W;
    cin >> N;

    for(int i = 1; i <= N; ++i)
        cin >> a[i];
    
    int now = 1;
    for(int i = 0; i < H; i += 2){
        for(int j = 0; j < W; ++j){
            data[i][j] = now;
            a[now] --;
            if(a[now] == 0){
                now ++;
            }
        }
        if(i + 1 >= H) break;
        for(int j = W - 1; j >= 0; --j){
            data[i + 1][j] = now;
            a[now] --;
            if(a[now] == 0){
                now ++;
            }
        }
    }
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            if(j != 0) cout << " ";
            cout << data[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
	int people[4][3][10],n,i,j,k,b,f,r,v;

	for (i = 0; i < 4; i++) {
		for (j = 0; j < 3; j++) {
			for (k = 0; k < 10; k++) {
				people[i][j][k] = 0;
			}
		}
	}

	scanf("%d", &n);

	for ( i = 0; i < n; i++){
		scanf("%d %d %d %d", &b, &f, &r, &v);
		people[b-1][f-1][r-1] += v;
	}

	for ( i = 0; i < 4; i++) {
		for ( j = 0; j < 3; j++) {
			for ( k = 0; k < 10; k++) {
				printf(" %d", people[i][j][k]);
			}
			printf("\n");
		}
		if (i != 3) {
			printf("####################\n");
		}

	}
	
}


Measured memory_bytes: 2132
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

static const int MOD = 1e9 + 7;

int main() {
    map<string, int>Day{ {"SUN", 7 },
                         {"MON", 6 },
                         {"TUE", 5 },
                         {"WED", 4 },
                         {"THU", 3 },
                         {"FRI", 2 },
                         {"SAT", 1 } };

    string S;
    cin >> S;

    cout << Day[S] << endl;;

}

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

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

    int a,b,c;
    // 引数の受け取り
    //
    cin >> a >> b >> c;

    cout << ((c>=a&&c<=b)?"Yes":"No") << endl;
    

    // 出力
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int n; cin >> n;
    vector<int> x(n); repeat(i, n) cin >> x[i];
    int a = 0, b = 0, c = 0;
    repeat(i, n) {
        if (x[i] % 4 == 0) ++a;
        else if (x[i] % 2 == 0) ++b;
        else ++c;
    }
    
    if (b == 0) {
        if (c > a + 1) cout << "No";
        else cout << "Yes";
    }
    else {
        if (c > a) cout << "No";
        else cout << "Yes";
    }
    cout << endl;
    return 0;
}

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

using namespace std;

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

int w, h;

bool init() {
	cin >> h >> w;
	return w != 0;
}

bool check(int a, int b, int c, int d) {
	int A = a * a + b * b;
	int B = c * c + d * d;
	if (A != B) return A < B;
	return a < c;
}

void solve() {
	int W = 1000, H = 1000;
	reps(i, 1, 200) {
		reps(j, i + 1, 200) {
			if (check(h, w, i, j) && check(i, j, H, W)) {
				H = i;
				W = j;
			}
		}
	}
	cout << H << " " << W << endl;
}

int main() {
	while (init()) {
		solve();
	}
}


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

int main(){
  int N,u,v,w;
  cin>>N;
  vector<pair<int,int>>G[N];
  int C[N];
  for(int i=0;i<N;i++){
    C[i]=-1;
  }
 
  for(int i=0;i<N-1;i++){
    cin>>u>>v>>w;
    u--;
    v--;
    G[u].push_back({v,w});
    G[v].push_back({u,w});
  }

  queue<int>que;
  C[0]=0;
  que.push(0);
  while(!que.empty()){
    int i=que.front();
    que.pop();
    for(int j=0;j<G[i].size();j++){
      if(C[G[i].at(j).first]==-1 && (G[i].at(j).second)%2==0){
        C[G[i].at(j).first]=C[i];
        que.push(G[i].at(j).first);
      }
      else if(G[i].at(j).second%2!=0){
        if(C[G[i].at(j).first]==-1 && C[i]==0){
          C[G[i].at(j).first]=1;
          que.push(G[i].at(j).first);
        }
        else if(C[G[i].at(j).first]==-1 && C[i]==1){
          C[G[i].at(j).first]=0;
          que.push(G[i].at(j).first);
        }
      }
    }
  }
  for(int i=0;i<N;i++){
    cout<<C[i]<<endl;
  }
  return 0;
}



Measured memory_bytes: 9972
H,K = map(int,input().split())
x=list(map(int,input().split()))
m = sum([1 for i in x if i < 0])
xm = [-x[i] for i in range(m)]
xm.reverse()

if 0 in x:
  K = K-1
  xp = x[m+1:]
else:
  xp = x[m:]
xm = [0]+xm
xp = [0]+xp

if K == 0:
  ans = 0
else:
  ans = 3 * 10**8
  for i in range(min(K+1,len(xm))):
    if K-i < len(xp):
      x = xm[i]*2+xp[K-i]
      ans = min(x,ans) 
  for i in range(min(K+1,len(xp))):
    if K-i < len(xm):
      x = xp[i]*2+xm[K-i]
      ans = min(x,ans) 
print(ans)

Measured memory_bytes: 14484
from sys import stdin
n = int(stdin.readline().rstrip())
li = list(int(stdin.readline().rstrip()) for _ in range(n))
li_to = sorted(li)
one = li_to[-1]
two = li_to[-2]
for i in range(n):
    if one == li[i]:
        print(two)
    else:
        print(one)

Measured memory_bytes: 14120
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    int l[q];
    int r[q];
    REP(i,q){
        cin >> l[i] >> r[i];
    }
    vector <int> count(100005,0);
    count[n-1]=0;
    FORR(i,n-2,0){
        if(s[i]=='A'&&s[i+1]=='C')count[i]=count[i+1]+1;
        else count[i]=count[i+1];
    }


    REP(i,q){
        cout << count[l[i]-1] -  count[r[i]-1] << endl;
        //cout << count[i] << endl;
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N - 1);
  for (int i = 0; i < N - 1; ++i) cin >> B[i];
  
  A[0] = B[0];
  A[N - 1] = B[N - 2];
  for (int i = 1; i < N - 1; ++i) {
    A[i] = B[i - 1];
    if (A[i] > B[i]) A[i] = B[i];
  }
  int ans = 0;
  for (int i = 0; i < N; ++i) ans += A[i];
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<31-1;
const int MOD = 1000000007;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

void solve(void){
    int N, S, T, W;
    cin >> N >> S >> T >> W;
    int ans = min(N, S) + min(T, W);
    cout << ans << '\n';
}

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


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

int main() {
  int a, b;
  cin >> a >> b;
  
  if ((a * b) % 2 == 0) {
  	cout << "Even" << endl;
  }
  else if ((a * b) % 2 == 1) {
  	cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
use proconio::*;

fn main() {
    input! {
        n: usize,
        mut a: [usize; n]
    }

    a.sort();
    let maxval = a[a.len() - 1];

    let mut ans = 0;
    let mut arr: [bool; 1000001] = [false; 1000001];
    for i in 0..n {
        let mut val = a[i];

        if i + 1 < n && a[i] == a[i + 1] {
            arr[val] = true;
        }
        else if arr[val] == false {
            ans += 1;
        }

        val += a[i];
        while val <= maxval {
            arr[val] = true;
            val += a[i];
        }
    }

    println!("{}", ans);
}


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



int main() {
	int n;
	ll y;
	cin >> n >> y;
	y /= 1000;
	if (y < n) {
		cout << "-1 -1 -1" << endl;
		return 0;
	}
	int a = y - n;
	for (int i = 0; i * 9 <= a; i++) {
		for (int j = 0; j * 4 <= a; j++) {
			if (9 * i + 4 * j == a && 10 * i + 5 * j <= y) {
				cout << i << " " << j << " " << y - (10 * i + 5 * j) << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <cstdio>

int main(void){
  int n, i, j, cnt, tmp;
  while(scanf("%d", &n)){
    if(n == 0){
      break;
    }
    cnt = 0;
    for(i=1; i<n/2+1; i++){
      for(j=i; j<n; j++){
        tmp = (i + j) * (j - i + 1) / 2;
        if(tmp == n){
          cnt++;
          break;
        }
        if(tmp > n){
          break;
        }
      }
    }
    printf("%d\n", cnt);
  }
  return 0;
}



Measured memory_bytes: 2596
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#define _CRT_SECURE_NO_WARNINGS
#endif
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x) {x = 0;register bool _=0;register T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void print(T n) {register bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);pc(10);}
template<typename First, typename ... Ints>
void scan(First &arg, Ints&... rest) { scan(arg);scan(rest...); }

using namespace std;
typedef long long ll;
const int MM = 3002, MOD = 1e9+7;

int N;
ll dp[MM][MM];
char str[MM];

inline ll mod(ll n){
    return (n+MOD) % MOD;
}

int main(){
    
    scan(N);
    scanf("%s", str);
    
    dp[1][1] = 1;
    
    for(int i = 2; i <= N; i++){
        for(int j = 1; j <= i; j++){
            if(str[i-2] == '<')
                dp[i][j] = mod(dp[i-1][j-1] + dp[i][j-1]);
            //sum from 1 - j-1
            else
                dp[i][j] = mod(dp[i-1][i-1] + dp[i][j-1] - dp[i-1][j-1]);
            // psa from j - i-1 (cannot exceed i-1)
            
            //printf("%lld ", dp[i][j]);
        }
        //puts("");
    }
    
    print(dp[N][N]);
    
    return 0;
}

Measured memory_bytes: 68992
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
template <class T>
inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

void ans(bool flag){
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    bool flag = true;
    if (a+b==c)
        flag = false;
    if (b+c==a)
        flag=false;
    if (a+c==b)
        flag = false;
    if (!flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int dw[3] = {-1,0,1};

int main(){
    int w,h;

    while(cin >> w >> h){
        if(!(w|h)) break;
        int field[h+2][w+2];
        int dp[h+2][w+2];
        int kind;
        long long ret=0;
        fill((int *)field, (int *)field+(h+2)*(w+2), 1);
        fill((int *)dp, (int *)dp+(h+2)*(w+2), 0);

        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                cin >> field[i][j];
            }
        }

        for(int i=1;i<=w;i++){
            if(field[1][i] == 0) dp[1][i] = 1;
        }
        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                kind = field[i][j];
                if(kind == 0){
                    for(int k=0;k<3;k++){
                        if(field[i+1][j+dw[k]] == 0 || 
                           (field[i+1][j+dw[k]] == 2 && k == 1)){
                            dp[i+1][j+dw[k]] += dp[i][j];
                        }
                    }
                }else if(kind == 2){
                    if(i != h-1){
                        if(field[i+2][j] != 1){
                            dp[i+2][j] += dp[i][j];
                        }
                    }else{
                        ret += dp[i][j];
                    }
                }
            }
        }

        for(int i=1;i<=w;i++){
            ret += dp[h][i];
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int dp[3001][3001];
int main(){
	string s,t;
	cin>>s>>t;
	for(int i=1;i<=s.length();i++){
		for(int j=1;j<=t.length();j++){
			if(s[i-1]==t[j-1]){
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	int s_len=s.length(),t_len=t.length();
	string ans="";
	while(s_len>0&&t_len>0){
		if(dp[s_len][t_len]==dp[s_len-1][t_len])s_len--;
		else if(dp[s_len][t_len]==dp[s_len][t_len-1])t_len--;
		else{
			s_len--;
			t_len--;
			ans+=s[s_len];
			//ans+=t[t_len]での可
		}
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
	
}	

Measured memory_bytes: 35456
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        long sum_a = 0, sum_b = 0;

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            sum_a += a[i];
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
            sum_b += b[i];
        }

        if (sum_a > sum_b) {
            System.out.println("No");
            return;
        }

        long opt = sum_b - sum_a;
        long ans = 0;

        for (int i = 0; i < n; i++) {
            long diff = b[i] - a[i];
            if (diff > 0) {
                ans += (diff + 1) / 2;
            }
        }

        if (ans > opt) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 43996
#include <iostream>

using namespace std;

int main(void)
{
	int n;
	while(cin >> n, n > 0){
		int s, sum = 0, maxi, mini;
		cin >> s;
		sum += s;
		maxi = s;
		mini = s;
		for(int i = 1; i < n; i++){
			cin >> s;
			sum += s;
			maxi = max(maxi, s);
			mini = min(mini, s);
		}
		cout << (sum-maxi-mini)/(n-2) << endl;
	}
	return 0;
}


Measured memory_bytes: 3008
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    int a[n];
    int cnt[3];
    fill(cnt,cnt+3,0);
    rep(i,0,n){
        cin>>a[i];
        if(a[i]%4==0)cnt[2]++;
        else if(a[i]%2==0)cnt[1]++;
        else cnt[0]++;
    }
    if(cnt[1]==0){
        cnt[2]++;
    }
    if(cnt[0]>cnt[2]){
        cout<<"No"<<endl;
        return 0;
    }
    else cout<<"Yes"<<endl;
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] W = new String[N];

		boolean isValid = true;
		String result = "Yes";

		for(int i = 0; i < N; i++) {
			W[i] = sc.next();
		}

		for(int i = 0; i < N-1; i++) {
			if(W[i].charAt(W[i].length() -1) != W[i+1].charAt(0)) {
				isValid = false;
				result = "No";
				break;
			}
			for(int j = i+1; j < N; j++) {
				if(W[i].equals(W[j])) {
					isValid = false;
					result = "No";
					break;
				}
			}
			if(!isValid) {
				break;
			}
		}

		System.out.println(result);
	}
}


Measured memory_bytes: 21844
from Queue import * # Queue, LifoQueue, PriorityQueue
from bisect import * #bisect, insort
from collections import * #deque, Counter,OrderedDict,defaultdict
#set([]) 
import math
import copy
import itertools
import string
import sys
myread = lambda : map(int,raw_input().split())
def solver():
    S = raw_input()
    while S:
        if S[-5:] == "dream":
            S = S[:-5]
        elif S[-7:] == "dreamer":
            S = S[:-7]
        elif S[-5:] == "erase":
            S = S[:-5]
        elif S[-6:] == "eraser":
            S = S[:-6]
        else:
            print "NO"
            return
    print "YES"
if __name__ == "__main__":
    solver()
    


Measured memory_bytes: 3296
n = gets.chomp.to_i
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
d = gets.chomp.to_i
e = gets.chomp.to_i

min = [a,b,c,d,e].min
puts 5 + ((n - 1) / min)


Measured memory_bytes: 1788
#include <iostream>
#include <string.h>

using namespace std;

int main(){
	char words[30];
	int min;
	int min_num;
	bool diff_flag = true;
	int length;

	scanf("%s", words);

	length = (int)strlen(words);

	for(int i = 0; i < length; i++){
		min = (int)words[i];
		min_num = i;
		for(int j = i; j < length; j++){
			if(min > (int)words[j]){
				min = (int)words[j];
				min_num = j;
			}
		}
		words[min_num] = words[i];
		words[i] = (char)min;
	}

	for(int i = 0; i < length - 1; i++){
		if(words[i] == words[i+1]){
			diff_flag = false;
		}
	}

	if(diff_flag){
		cout << "yes" << endl;
	}else{
		cout << "no" << endl;
	}
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int n,m,p,a,b;
int t[10];
vector<pii> G[31];
double dis[POW(8)][31];

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

  while (cin >> n >> m >> p >> a >> b, n) {
    REP(i,m) G[i].clear();
    a--; b--;
    REP(i,n) cin >> t[i];
    REP(i,p) {
      int x,y,z;
      cin >> x >> y >> z;
      x--; y--;
      G[x].emplace_back(y,z);
      G[y].emplace_back(x,z);
    }
    fill_n((double*)dis,POW(8)*31,INF);
    dis[0][a] = 0;
    using P = tuple<double,int,int>;
    priority_queue<P,vector<P>,greater<P>> que;
    que.emplace(0,0,a);
    while (!que.empty()) {
      int dd,S,v;
      tie(dd,S,v) = que.top(); que.pop();
      if (dis[S][v] < dd) continue;
      for (pii e : G[v]) {
        int nv = e.first;
        int cost = e.second;
        for (int i = 0; i < n; i++) if (!(S&POW(i))) {
          if (CHMIN(dis[S|POW(i)][nv],dis[S][v]+(double)cost/t[i])) {
            que.emplace(dis[S|POW(i)][nv],S|POW(i),nv);
          }
        }
      }
    }
    double ans = INF;
    REP(i,POW(n)) CHMIN(ans,dis[i][b]);
    if (ans == INF) cout << "Impossible" << endl;
    else cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 5332
#include<stdio.h>
using namespace std;
int main()
{
    int r,c,i,j;
    static int s[101][101];
    scanf("%d%d",&r,&c);
    for(i=0;i<=r;i++)
    {
        for(j=0;j<c;j++)
        {
            scanf("%d",&s[i][j]);
            printf("%d ",s[i][j]);
            s[i][c]+=s[i][j];
            s[r][j]+=s[i][j];
        }
        printf("%d\n",s[i][c]);
    }

}



Measured memory_bytes: 2728