akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>

char array1[1001],array2[1001];
int a,b,array[1001][1001];
int min(int,int,int);
void search(int,int);

int main(void){
    int i,j;
    scanf("%s",array1);
    scanf("%s",array2);
    a = strlen(array1);
    b = strlen(array2);
    for(i = a - 1;i >= 0 ;i--){
        array1[i + 1] = array1[i];
    }
    array1[0] = '0';
    for(i = b - 1;i >= 0 ;i--){
        array2[i + 1] = array2[i];
    }
    array2[0] = '0';
    array[0][0] = 0;
    for(i = 0;i < a + 1;i++){
        array[i][0] = i;
    }
    for(j = 0;j < b + 1;j++){
        array[0][j] = j;
    }
    for(i = 1;i < a + 1;i++){
        for(j = 1;j < b + 1;j++){
            search(i,j);
        }
    }
    printf("%d\n",array[a][b]);
    return 0;
}

int min(int p,int q,int r){
    if(p <= q && p <= r){
        return p;
    }else if(q <= p && q <= r){
        return q;
    }else{
        return r;
    }
}

void search(int p,int q){
    if(array1[p] == array2[q]){
        array[p][q] = array[p - 1][q - 1];
    }else{
        array[p][q] = min(array[p - 1][q],array[p][q - 1],array[p - 1][q - 1]) + 1;
    }
}

Measured memory_bytes: 4452
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(void) 
{
    ll n;
    cin >>n;
    
    vll h(n);
    ll c = 0;
    ll r = 0;
    cin >>h[0];
    rrep(i, n-1) {
        cin >>h[i];
        
        if (h[i] > h[i-1]) {
            c = 0;
        } else {
            c++;
            r = max(r, c);
        }
        
    }
    mes(r);
    
    

}


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

int main(){
    int N;
    cin >> N;
    int p[N];
    for (int i = 0; i < N; i++){
        cin >> p[i];
    }
    int ans=0;
    for(int i=1; i<=N-2; i++){
        int pmin = min({p[i-1],p[i],p[i+1]});
        int pmax = max({p[i-1],p[i],p[i+1]});
        //cout << "i pmin p[i] pmax " << i << " " << pmin << " " << p[i] << " " << pmax << endl;
        if( p[i]<pmax && p[i]>pmin ){
            ans++;
        }
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		//String S = sc.next();
		//int N = Integer.parseInt(sc.next());
		//out.println();
		// ArrayList<String> list = new ArrayList<String>();
		// list.stream().sorted().distinct();
		String a[] = {"1","3","5","7","8","10","12"};
		String b[] = {"4","6","9","11"};
		String c[] = {"2"};
		String A = sc.next();
		String B = sc.next();
		if((Arrays.asList(a).contains(A) && Arrays.asList(a).contains(B))
		|| (Arrays.asList(b).contains(A) && Arrays.asList(b).contains(B))
		|| (Arrays.asList(c).contains(A) && Arrays.asList(c).contains(B))){
			out.println("Yes");
		}else {
			out.println("No");
		}
		out.flush();	
	}
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // ここにプログラムを追記
  int reminder,a,b,ave;
  cin >> a >> b;
  ave=(a+b)/2;
  reminder=(a+b)%2;
  cout << ave+reminder << endl;
  return 0;
}

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

#define sz(x) int(x.size())
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;


int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout);
  ll a, b; cin >> a >> b;
  cout << (a * b) / __gcd(a, b);
}



Measured memory_bytes: 256
package main

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

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var cnt, ans int

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	H := make([]int, N)
	for i := 0; i < N; i++ {
		H[i], _ = strconv.Atoi(read())
	}

	for i := N - 1; 0 < i; i-- {
		if H[i-1] == H[i]+1 {
			H[i-1]--
		}
		if H[i] < H[i-1] {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i][0] == a[j][0] {
		return a[i][1] > a[j][1]
	}
	return a[i][0] < a[j][0]
}

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] > h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 3072
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    long long k,a,b;
    cin>>k>>a>>b;
    k=k+1;
    if(a+2>=b) cout<<k;
    else cout<<(k-a)/2*(b-a)+a+(k-a)%2;
}

Measured memory_bytes: 384
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(n-2):
    if (p[i] < p[i+1] and p[i+1] < p[i+2]) or (p[i+2] < p[i+1] and p[i+1] < p[i]):
        count += 1
print(count)

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

int main() {
  int X,Y,m;
  cin>>X>>Y;
  m=Y-2*X;
  if((m>=0)&&(m%2==0)&&(X-m/2>=0)){
  cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
    
}



Measured memory_bytes: 3604
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <climits>
#include <queue>

using namespace std;

const int kSize = 100001;

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

    int A[kSize];
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }

    int L[kSize];
    L[0] = A[0];
    int length = 1;

    for (int i = 1; i < n; ++i) {
        if (L[length - 1] < A[i]) {
            L[length++] = A[i];
        } else {
            *lower_bound(L, L + length, A[i]) = A[i];
        }
    }

    cout << length << endl;

    return 0;
}


Measured memory_bytes: 3772
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int N, M, X, Y;

void solve() {
}

int main() {
    cin >> N >> M >> X >> Y;
    int x[N], y[M];
    int max_x = -INF, min_y = INF;

    REP(i, N) {
        cin >> x[i];
        max_x = max(max_x, x[i]);
    }
    REP(i, M) {
        cin >> y[i];
        min_y = min(min_y, y[i]);
    }
    if (max_x > min_y) {
        cout << "War" << endl;
        return 0;
    }
    FOR(i, max_x + 1, min_y + 1) {
        if (X < i && i <= Y) {
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] cnt = new int['z' - 'a' + 1];
		Arrays.fill(cnt, Integer.MAX_VALUE);
		for (int i = 0; i < n; ++i) {
			char[] s = sc.next().toCharArray();
			int[] cur_cnt = new int['z' - 'a' + 1];
			for (char c : s) {
				cur_cnt[c - 'a']++;
			}
			for (int j = 0; j < cur_cnt.length; ++j) {
				cnt[j] = Math.min(cnt[j], cur_cnt[j]);
			}
		}
		String ans = "";
		for (int i = 0; i < cnt.length; ++i) {
			for (int j = 0; j < cnt[i]; ++j)
				ans += (char) ('a' + i);
		}
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 21844
#include<stdio.h>

int main() {
	
	int num = 0;

	scanf("%d", &num);

	switch (num % 10)
	{
	case 3:
		printf("bon\n");
		break;
	case 0:
	case 1:
	case 6:
	case 8:
		printf("pon\n");
		break;
	default:
		printf("hon\n");
		break;
	}
	
	// 終了コードは0
	return 0;
}

Measured memory_bytes: 1664
import java.math.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    List<UnionFind<Integer>> list = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      list.add(new UnionFind<>(i));
    }
    for (int i = 0; i < m; i++) {
      int a = sc.nextInt() - 1;
      int b = sc.nextInt() - 1;
      UnionFind.union(list.get(a), list.get(b), Math::min);
    }
    Set<Integer> set = list.stream().map(UnionFind::getGroupValue).collect(Collectors.toSet());
    System.out.println(set.size() - 1);
  }
}

/**
 * Union Find
 * @param <T> 値の型
 */
class UnionFind<T> {
  /** 親 (なければnull) */
  private UnionFind<T> parent;
  /** 値 */
  private final T value;
  /** 所属するグループの合算した値 (root要素以外のgroupValueは正しいとは限らない) */
  private T groupValue;

  /**
   * Union Find
   * @param value 値
   */
  public UnionFind(T value) {
    this.value = value;
    this.groupValue = value;
  }

  /**
   * 同じグループに属するかどうか
   * @param a a
   * @param b b
   * @param <S> 値の型
   * @return 同じグループに属するならtrue
   */
  public static <S> boolean sameGroup(UnionFind<S> a, UnionFind<S> b) {
    return a.getRoot().equals(b.getRoot());
  }

  /**
   * 同じ木に所属させる
   * @param a a
   * @param b b
   * @param <S> 値の型
   */
  public static <S> void union(UnionFind<S> a, UnionFind<S> b) {
    union(a, b, (_1, _2) -> _1);
  }
  /**
   * 同じ木に所属させる。また、値の計算もする
   * @param a a
   * @param b b
   * @param groupValueFunction aとbが異なるグループに属するとき、その2つのグループの値を合算する関数。
   * @param <S> 値の型
   */
  public static <S> void union(UnionFind<S> a, UnionFind<S> b, BiFunction<S, S, S> groupValueFunction) {
    UnionFind<S> aRoot = a.getRoot();
    UnionFind<S> bRoot = b.getRoot();
    if (!aRoot.equals(bRoot)) {
      bRoot.parent = aRoot;
      aRoot.groupValue = groupValueFunction.apply(aRoot.groupValue, bRoot.groupValue);
    }
  }

  @Override
  public boolean equals(Object o) {
    return this == o;
  }

  /**
   * root要素を返す。
   * @return root要素
   */
  private UnionFind<T> getRoot() {
    if (parent == null) {
      return this;
    }
    UnionFind<T> root = parent.getRoot();
    parent = root;
    return root;
  }

  /**
   * この要素の値を返す。
   * @return 値
   */
  public T getValue() {
    return value;
  }

  /**
   * この要素が属するグループの値を返す。
   * @return グループの値
   */
  public T getGroupValue() {
    return getRoot().groupValue;
  }
}



Measured memory_bytes: 57392
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int n;
	cin >> n;
	int a[n];
	forr(i,n) cin >> a[i];
	for(int i = 0; i < n; i++){
		if(a[i]%2==0){
			if(a[i]%3 and a[i]%5){
				cout << "DENIED";
				return 0;
			}
		}
	}
	cout << "APPROVED";
}

Measured memory_bytes: 3608
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
using namespace std;
typedef long long ll;


int main(int argc, char *args[]) {
	int N;
	cin >> N;
	ll L[100];
	L[0] = 2;
	L[1] = 1;
	for (int i = 2; i <= N; i++) {
		L[i] = L[i - 1] + L[i - 2];
	}
	cout << L[N] << endl;
}


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

const int INF=99999999;

int ma[11][11];
int dis[11][11];
int maxx,id,ans;

int slove()
{
    for(int k=0;k<=maxx;k++)
        for(int i=0;i<=maxx;i++)
            for(int j=0;j<=maxx;j++)
            dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
    ans = INF;
    for(int i=0;i<=maxx;i++)
    {
        int sum=0;
        for(int j=0;j<=maxx;j++)
            sum+=dis[i][j];
        if(ans > sum){
            ans = sum;
            id = i;
        }
    }
}

int main()
{
    int t;
    while(scanf("%d",&t)&&t)
    {
        for(int i=0;i<=11;i++)
            for(int j=0;j<=11;j++)
            if(i != j)dis[i][j] = INF;
        maxx=0;
        while(t--)
        {
            int a,b,c;
            scanf("%d %d %d",&a,&b,&c);
            dis[a][b]=c;
            dis[b][a]=c;
            maxx=max(maxx,max(a,b));
        }
        slove();
        cout<<id<<" "<<ans<<endl;
    }
}



Measured memory_bytes: 3152
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
using namespace std;

const int N = 1010;

int n;
int stay[N];
set<int> st;

void work() {
    memset(stay, 0, sizeof(stay));
    char day[100] = "";
    int now = 0;
    int T = 60 * 24;
    for (int i = 0; i < n; i++) {
        char td[100];
        scanf("%s", td);
        int hour, minu;
        scanf("%d:%d", &hour, &minu);
        int next = hour * 60 + minu;
        int ed = next;
        if (strcmp(td, day) != 0) ed = T;
        if (st.count(0)) {
            for (set<int>::iterator it = st.begin(); it != st.end(); it++)
                stay[*it] += ed - now;
        }
        if (strcmp(td, day) != 0) {
            st.clear();
            strcpy(day, td);
        }
        now = next;
        char op[2];
        int p;
        scanf("%s%d", op, &p);
        if (*op == 'I') st.insert(p);
        else st.erase(p);
    }
    int ans = 0;
    for (int i = 1; i < 1000; i++)
        ans = max(ans, stay[i]);
    printf("%d\n", ans);
}
int main() {
//freopen("data.in", "r", stdin);
    while (scanf("%d", &n), n) {
        work();
    }
    return 0;
}

Measured memory_bytes: 1084
#include<bits/stdc++.h>
#define ll long long
using namespace std;

void exp(vector<int> &v, vector<vector<int> > &adj, int i, int cnt)
{
	v[i]=cnt;
	for(int k=0; k<adj[i].size(); k++){
		if(v[adj[i][k]]==-1)
			exp(v, adj, adj[i][k], cnt);
	}
}
int no_comp(vector<vector<int> > &adj) {
  int cnt = 1, i=0, n=adj.size();
  	vector<int> v(n, -1);
  	while(n--){
  		if(v[i]==-1){
  			exp(v, adj, i, cnt);
  			cnt++;
		  }
		  i++;
	  }
  return cnt-1;
}

int main() {
  ll n, m;
  cin >> n >> m;
  vector<vector<int> > adj(n, vector<int>());
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    adj[a - 1].push_back(b - 1);
    adj[b - 1].push_back(a - 1);
  }
  cout << no_comp(adj)-1;
}

Measured memory_bytes: 10124
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if a == 0 and b == 0 and c == 0:
                continue
            if 500*i+100*j+50*k == x:
                ans += 1
print(ans)


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

bool check(int n)
{
    for (int i = 0; i * i <= n; i++)
    {
        for (int j = 0; j * j <= n; j++)
        {
            if (i * i + j * j == n)
            {
                return true;
            }
        }
    }
    return false;
}

void solve()
{
    int a, b;
    cin >> a >> b;
    int c = a * a + b * b;

    for (int i = 2; i < c; i++)
    {
        if (c % i != 0)
        {
            continue;
        }
        if (check(i) && check(c/i)){
            //cerr<<i<<" "<<c/i<<" ";
            cout<<"C"<<endl;
            return;
        }
    }
    cout<<"P"<<endl;
}

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        solve();
    }
    return 0;
}


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

int main() {
  int H,N;
  int nok = 0;
  cin >> H >> N;

  vector<int> att(N);
  
  for (int i = 0; i < N; i++) {
    cin >> att.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    H = H - att.at(i);
  }
  
  if(H <= 0){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#ifdef on_linux
	#include <sys/resource.h>
#endif

#ifdef dobby_is_a_free_elf
	#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
	#define trace(...) 0;
#endif

using namespace std;
using namespace __gnu_pbds;


#define all(x)                  (x).begin(), (x).end()
#define between(i,x,y)          ((i) >= (x) && (i) <= (y))
#define DECIMAL(n)              cout << fixed << setprecision(n)
#define fi                      first
#define lbd                     lower_bound
#define mem0(x)                 memset(x, 0, sizeof (x))
#define mem1(x)                 memset(x, -1, sizeof (x))
#define mp                      make_pair
#define pb                      push_back
#define pf                      push_front
#define ppb                     pop_back
#define ppf                     pop_front
#define sc                      second
#define sqr(a)                  ((a) * (a))
#define sz(x)                   (int)((x).size())
#define ubd                     upper_bound

#define int                     long long

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <typename T>
using ordered_set = tree<T, null_type,
      less<T>,
      rb_tree_tag,
      tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0
// order_of_key(k) returns count of elements strictly smaller than k


const long double PI = 3.14159265358979323846264338;
const double eps = 1e-10;
#ifdef int
	const long long INF = 1e18;
#else
	const long long INF = 1e9;
#endif
const int32_t fftmod = 998244353;
const int32_t MOD = 1000000007;
const int32_t N = 1e5 + 10;
const int32_t NN = 1e6 + 10;



inline void elf_magic(int testcase)
{
	int d, t, s;
	cin >> d >> t >> s;
	if (d <= t * s) { cout << "Yes"; }
	else { cout << "No"; }

	return;
}

int32_t main()
{
	#ifdef on_linux
	rlimit cpu_time {.rlim_cur = 2, .rlim_max = RLIM_INFINITY};
	setrlimit(RLIMIT_CPU, &cpu_time);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int TESTS = 1;
	//cin >> TESTS;
	for (int i = 1; i <= TESTS; ++i) {
		// cout << "Case #" << i << ": ";
		elf_magic(i);
		if (i != TESTS)	{ cout << '\n'; }
	}
	return 0;
}

Measured memory_bytes: 3608
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

alias segT = SegmentTree!(int, min);

void main()
{
  int n; readV(n);
  int[] p; readA(n, p);

  auto inv = new int[](n+1);
  foreach (i; 0..n) inv[p[i]] = i;

  auto st = new segT[](2);
  foreach (i; 0..2) st[i] = new segT(n, n+1);
  foreach (i; 0..n) st[i%2][i] = p[i];

  struct pm
  {
    int s, t, p1;

    this(int s, int t)
    {
      this.s = s;
      this.t = t;
      p1 = st[s%2][s..t-1];
    }
  }

  auto h = Array!pm(pm(0, n)).heapify!"a.p1 > b.p1", c = 0;

  while (!h.empty) {
    auto hi = h.front; h.removeFront();
    auto s = hi.s, t = hi.t;
    auto p1 = hi.p1, i1 = inv[p1], p2 = st[(s+1)%2][i1+1..t], i2 = inv[p2];
    
    write(p1, " ", p2);
    if (c < n/2-1) write(" ");

    if (s < i1) h.insert(pm(s, i1));
    if (i1+1 < i2) h.insert(pm(i1+1, i2));
    if (i2+1 < t) h.insert(pm(i2+1, t));
  }

  writeln;
}

class SegmentTree(T, alias pred = "a + b")
{
  import core.bitop, std.functional;
  alias predFun = binaryFun!pred;

  const size_t n, an;
  T[] buf;
  T unit;

  this(size_t n, T unit = T.init)
  {
    this.n = n;
    this.unit = unit;
    an = n == 1 ? 1 : (1 << ((n-1).bsr + 1));
    buf = new T[](an*2);
    if (T.init != unit) buf[] = unit;
  }

  this(T[] init, T unit = T.init)
  {
    this(init.length, unit);
    buf[an..an+n][] = init[];
    foreach_reverse (i; 1..an)
      buf[i] = predFun(buf[i*2], buf[i*2+1]);
  }

  void opIndexAssign(T val, size_t i)
  {
    buf[i += an] = val;
    while (i /= 2)
      buf[i] = predFun(buf[i*2], buf[i*2+1]);
  }

  pure T opSlice(size_t l, size_t r)
  {
    l += an; r += an;
    T r1 = unit, r2 = unit;
    while (l != r) {
      if (l % 2) r1 = predFun(r1, buf[l++]);
      if (r % 2) r2 = predFun(buf[--r], r2);
      l /= 2; r /= 2;
    }
    return predFun(r1, r2);
  }

  pure T opIndex(size_t i) { return buf[i+an]; }
  pure size_t opDollar() { return n; }
}


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

int main(){
  enum class Winner{
    First, Second
  };

  int Nmove, Nstone;
  cin >> Nmove >> Nstone;

  vector<int> moves(Nmove);
  for(int i=0; i<Nmove; i++){
    cin >> moves.at(i);
  }

  vector<Winner> dp(Nstone+ 1, Winner::Second);
  for(int n=1; n<= Nstone; n++){
    for(auto move:moves){
      if(n < move){ break; }
      else if(dp.at(n- move)==Winner::Second){
        dp.at(n)= Winner::First;
        break;
      }
    }
  }

  string ans= (dp.at(Nstone)==Winner::First) ? "First"
                                             : "Second";
  cout << ans << endl;
}

Measured memory_bytes: 3716
A,B,C = map(int, input().split())
K = int(input())
for  i in range(K):
    if A < B:
        if B<C:
            break
        else:
            C = 2*C
    else:
        B = 2*B
if A<B<C :
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N, Q;
  cin >> N >> Q;
  vector<lint> A(N);
  REP(i, N) cin >> A[i];
  vector<lint> S(N+1);
  REP(i, N) S[i+1] = S[i] + A[i];
  vector<lint> S2(N+1);
  S2[1] = A[0];
  FOR(i, 1, N) S2[i+1] = S2[i-1] + A[i];
  REP(q, Q) {
    lint X;
    cin >> X;
    lint l = 0;
    lint r = N/2+2;
    while(r-l > 1) {
      lint m = (l+r) / 2;
      if(m == N/2+1) {
        lint a4 = A[N-m];
        if(abs(X-A[0]) <= abs(X-a4)) {
          r=m;
          break;
        } else {
          r=m-1;
          break;
        }
      }
      lint a1 = A[N-2*m];
      lint a2 = A[N-1-m];
      if(abs(X-a1) <= abs(X-a2)) {
        if(N-2*m-1 < 0) {
          r=m;
          break;
        }
        lint a3 = A[N-2*m-1];
        if(abs(X-a2) < abs(X-a3)) {
          r=m;
          break;
        }
        l=m;
      } else {
        lint a4 = A[N-m];
        r=m;
        if(abs(X-a1) <= abs(X-a4)) {
          break;
        }
      }
    }
    lint ans = S[N] - S[N-r] + (N-2*r >= 0 ? S2[N-2*r] : 0);
    cout << ans << "\n";
  }
}

Measured memory_bytes: 4096
package main

import (
	"fmt"
)

func main() {
	var A [3][3]int
	var N int
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			fmt.Scan(&A[i][j])
		}
	}
	fmt.Scan(&N)
	for N > 0 {
		N--
		var b int
		fmt.Scan(&b)
		for i := 0; i < 3; i++ {
			for j := 0; j < 3; j++ {
				if A[i][j] == b {
					A[i][j] = 0
				}
			}
		}
	}
	fmt.Println(check(A))
}

func check(A [3][3]int) string {
	for i := 0; i < 3; i++ {
		if A[i][0]+A[i][1]+A[i][2] == 0 {
			return "Yes"
		}
		if A[0][i]+A[1][i]+A[2][i] == 0 {
			return "Yes"
		}
	}
	if A[0][0]+A[1][1]+A[2][2] == 0 {
		return "Yes"
	}
	if A[0][2]+A[1][1]+A[2][0] == 0 {
		return "Yes"
	}
	return "No"
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
while(true){
  int w, h;
  cin >> w >> h;
  if(w == 0 && h == 0) break;
  vvi tate(h, vi(w-1));
  vvi yoko(h-1, vi(w));
  for(int i = 0; i < 2*h-1; i++){
    if(i % 2 == 0){
      for(int j = 0; j < w-1; j++){
        cin >> tate.at(i/2).at(j);
      }
    }
    else{
      for(int j = 0; j < w; j++){
        cin >> yoko.at(i/2).at(j);
      }
    }
  }

  vi dx = {1, 0, -1, 0};
  vi dy = {0, 1, 0, -1};

  queue<P> que;
  que.push(P(0, 0));
  vvi num(h, vi(w, -1));
  num.at(0).at(0) = 1;
  while(!que.empty()){
    int x = que.front().first;
    int y = que.front().second;
    que.pop();

    for(int i = 0; i < 4; i++){
      int xx = x + dx.at(i);
      int yy = y + dy.at(i);
      if(xx < 0 || xx >= w || yy < 0 || yy >= h) continue;

      if(dx.at(i) == 1 && tate.at(y).at(x) == 1) continue;
      if(dx.at(i) == -1 && tate.at(y).at(x-1) == 1) continue;
      if(dy.at(i) == 1 && yoko.at(y).at(x) == 1) continue;
      if(dy.at(i) == -1 && yoko.at(y-1).at(x) == 1) continue;

      if(num.at(yy).at(xx) == -1){
        num.at(yy).at(xx) = num.at(y).at(x) + 1;
        que.push(P(xx, yy));
      }
    }
  }
  if(num.at(h-1).at(w-1) == -1) cout << 0 << endl;
  else cout << num.at(h-1).at(w-1) << endl;
}
}


Measured memory_bytes: 3108
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
int main() {
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e - a <= k) {
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
s = int(input())

aset = set([s])
preva = s
for m in range(10**6):
  if preva % 2 == 0:
    if preva // 2 in aset:
      break
    else:
      aset.add(preva // 2)
      preva = preva // 2
  else:
    if preva * 3 + 1 in aset:
      break
    else:
      aset.add(preva * 3 + 1)
      preva = preva * 3 + 1
print(m+2)

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include<string.h>

int main(){
	int h,m,s,time=0,nokori=0;
	
	while(1){
		scanf("%d %d %d",&h,&m,&s);
		if(h==-1 && m==-1 && s==-1)break;
		
		time=h*3600+m*60+s;
		nokori=120*60-time;

	printf("%02d:",nokori/3600);
	nokori=nokori%(3600);
	printf("%02d:",nokori/60);
	nokori=nokori%60;
	printf("%02d\n",nokori);
		
		time=h*3600+m*60+s;
		nokori=120*60-time;
		nokori*=3;

	printf("%02d:",nokori/3600);
	nokori=nokori%(3600);
	printf("%02d:",nokori/60);
	nokori=nokori%(60);
	printf("%02d\n",nokori);
		nokori=0;
	}
return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#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 REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll K = 0;
ll t;
ll ret = 0;
string s;

int main(void){
  IN(N);
  vl A(N);
  vl P(N);
  vl Q(N);
  REP(i, N) {
    A[i] = i+1;
  }
  REP(i, N) {
    IN(t);
    P[i] = t;
  }
  REP(i, N) {
    IN(t);
    Q[i] = t;
  }
  ll a = 0, b = 0;
  ll n = 1;
  do {
    bool pok = true;
    bool qok = true;
    REP(i, N) {
      if (A[i] != P[i]) pok = false;
      if (A[i] != Q[i]) qok = false;
    }
    if (pok) a = n;
    if (qok) b = n;
    n++;
  } while(next_permutation(ALL(A)));
  // DEBUG(a);
  // DEBUG(b);
  PRINT((a > b)?(a-b):(b-a));
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>

using namespace std;

int main()
{
    // 整数の入力
    string N;
    cin >> N;
    if (N[0] ==N[1] && N[1] == N[2] ||  N[1] == N[2]  && N[2] ==N[3] ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
    long long n, q;
    cin >> n >> q;
    long long query[2];
    vector<vector<vector<long long>>> min(2, vector<vector<long long>>());

    long long sum = 0;
    long long buf;
    for (int i = 0; i < q; i++) {
        buf = n - 2;
        cin >> query[0] >> query[1];
        query[0]--;
        query[1]--;

        for (int j = min[query[0]].size() - 1; j >= 0; j--) {
            if (min[query[0]][j][0] >= query[1]) {
                buf = min[query[0]][j][1] - 1;
                break;
            }
        }
        sum += buf;
        if (!min[!query[0]].size() || min[!query[0]][min[!query[0]].size() - 1][1] > query[1]) {
            min[!query[0]].push_back({buf, query[1]});
        }
    }

    cout << (n - 2) * (n - 2) - sum << endl;

    return 0;
}

Measured memory_bytes: 14280
N,M,C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(N)]

ans = 0
for i in range(N):
    tmp = 0
    for j in range(M):
        tmp += A[i][j]*B[j]
    tmp += C
    if tmp > 0:
        ans += 1
print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#include <fstream>
#include <functional>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 200001
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};
struct PPoint{Point x; Point y;};
ll gcd(ll a, ll b) { if(a < b) swap(a, b); if(b <= 0) return a; return gcd(b, a % b); }

ll dp[100001];
bool broken[100001];
int N, M;

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    cin >> N >> M;
    while(M--){int t; cin >> t; broken[t] = true;}
    
    dp[0] = 1;
    if(!broken[1])
        dp[1] = 1;
    
    for(int i = 2; i <= N; i++)
    {
        if(broken[i])
        {
            continue;
        }
        dp[i] += dp[i-1];
        dp[i] %= mod;
        dp[i] += dp[i-2];
        dp[i] %= mod;
    }
    
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pi pair<int ,int >
#define pl pair<ll ,ll >
#define pb push_back
#define vl vector <long long int >
#define vi vector <int >
#define mod 1000000007
#define eps 1e-9
#define fi first
#define se second
#define _ <<" "<<
#define forn(x,	n) for(int x = 0; x < n ;++ x) 
#define forn1(x,n) for(int x = 1; x <= n ;++ x)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
void scan(){}
template<typename F, typename... R> void scan(F &f,R&... r){cin>>f;scan(r...);}
int di_; string dnms_, co_ = ",";
void debug_(){cout<<endl;}
template<typename F, typename... R> void debug_(F &f, R&... r){while(dnms_[di_] != ',')cout<<dnms_[di_++];di_++;cout<<": "<<f<<",";debug_(r...);}
#define debug(...) dnms_=#__VA_ARGS__+co_,di_=0,debug_(__VA_ARGS__)

template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}

int main(){
	IOS

	string s;
	cin>>s;
	int n = s.size();
	string last,secondlast;
	last.pb(s[0]);
	int k=1;
	for(int i=1;i<n;i++)
	{
		secondlast = last;
		if(last.size()==1)
		{
			if(last[0]==s[i])
			{
				k++;
				last.pop_back();
				last.push_back(s[i]);
				if(i+1<n)
				last.push_back(s[i+1]);
				i++;
			}
			else
			{
				k++;
				last[0]=s[i];
			}
		}
		else
		{
			k++;
			last.pop_back();
			last.pop_back();
			last.push_back(s[i]);
		}
	}

	if(last.size()==1&&secondlast.size()==1&&last[0]==secondlast[0])
		k--;
	cout<<k;	
 
	return 0;	
}

Measured memory_bytes: 720
#include <iostream>
#include <cstdio>
#include <iomanip>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>

#include <numeric>
#include <algorithm>
#include <functional>

#include <cctype>

#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(unsigned int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                             it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))

typedef long long ll;
typedef complex<double> P;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};
const double EPS = 1e-9;
const int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

int main(){
    int n;
    cin >> n;
    rep(nind,n){
        vector<vector<int> > V(9,vector<int>(9));
        //if no -> true;
        vector<vector<bool> > flag(9,vector<bool>(9));

        rep(i,9) rep(j,9){
            cin >> V[i][j];
        }
        rep(i,9){
            vector<int> cnt(10);
            vector<int> cnt2(10);
            rep(j,9){
                cnt[V[i][j]]++;
                cnt2[V[j][i]]++;
            }
            rep(j,9){
                if(cnt[V[i][j]] >= 2)
                    flag[i][j] = true;
                if(cnt2[V[j][i]] >= 2)
                    flag[j][i] = true;
            }
        }
        rep(i,3){
            rep(j,3){
                //i,j is right up.
                vector<int> cnt(10);
                rep(k,3) rep(l,3){
                    cnt[V[3*i+k][3*j+l]]++;
                }

                rep(k,3) rep(l,3){
                    if(cnt[V[3*i+k][3*j+l]] >= 2){
                        flag[3*i+k][3*j+l] = true;
                    }
                }
            }
        }
        rep(i,9){
            rep(j,9){
                cout << (flag[i][j] ? "*" : " ") << V[i][j];
            }
            cout << endl;
        }
        if(nind != n-1) cout << endl;
    }
    return 0;
}

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

import sys
import os
from collections import deque


N = int(input())
q = deque()

for i in range(N):
    lst = input().split()
    command = lst[0]
    if command == 'insert':
        v = int(lst[1])
        q.appendleft(v)
    elif command == 'delete':
        v = int(lst[1])
        try:
            q.remove(v)
        except Exception:
            pass
    elif command == 'deleteFirst':
        q.popleft()
    elif command == 'deleteLast':
        q.pop()

print(*q)

Measured memory_bytes: 47960
#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define double long double
#define INF LLONG_MAX/3
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int n, t[110], v[110], sum;
int speed[20010];
int kukan[20010];
int memo[20010];
double dp[20010][110];
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> t[i];
		sum += t[i];
	}
	int cnt = 0;
	rep(i, n) {
		cin >> v[i];
		for (int j = cnt; j <= cnt + t[i]; j++) {
			if (!speed[j])speed[j] = INF;
			speed[j] = min(speed[j], v[i]);
			kukan[j] = i;
			if (j != cnt + t[i]) {
				memo[j] = v[i];
			}
		}
		cnt += t[i];
	}
	dp[0][0] = 1;
	REP(i, sum) {
		rep(j, speed[i] + 1) {
			if (j)if (dp[i - 1][j - 1])dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + j - 0.5);
			if (dp[i - 1][j]) {
				dp[i][j] = max(dp[i][j], dp[i - 1][j] + j);
				if (j + 0.5 < memo[i-1])dp[i][j] = max(dp[i][j], dp[i - 1][j] + j + 0.25);
			}
			if (dp[i - 1][j + 1])dp[i][j] = max(dp[i][j], dp[i - 1][j + 1] + j + 0.5);
		}
	}
	printf("%.12Lf\n", dp[sum][0] - 1);
}

Measured memory_bytes: 35072
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

#define MAX_N 10000

struct edge {
    int to, dist, cost;

    bool operator >(const edge& e) const {
        if (dist != e.dist) return dist > e.dist;
        else return cost > e.cost;
    }
};

int main()
{
    int n, m;
    while (cin >> n >> m, n|m) {
        vector<edge> G[MAX_N+1];
        rep(i, m){
            int u, v, d, c;
            cin >> u >> v >> d >> c;
            G[u].pb({v, d, c});
            G[v].pb({u, d, c});
        }
        edge cost[MAX_N+1]; // prev, dist, cost
        fill_n((edge *)cost, MAX_N+1, (edge){-1, INF, INF});
        cost[1] = {-1, 0, 0};
        priority_queue<edge, vector<edge>, greater<edge>> que;
        que.push({1, 0, 0});
        while (!que.empty()) {
            edge e = que.top(); que.pop();
            if (e > cost[e.to]) continue;
            for (edge road : G[e.to]) {
                if (e.dist + road.dist < cost[road.to].dist || e.dist + road.dist == cost[road.to].dist && road.cost < cost[road.to].cost) {
                    que.push({road.to, e.dist + road.dist, road.cost});
                    cost[road.to] = {e.to, e.dist + road.dist, road.cost};
                }
            }
        }
        int output = 0;
        REP(i, 2, n+1){
            output += cost[i].cost;
        }
        cout << output << endl;
    }
    return 0;
}

Measured memory_bytes: 2640
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  d,n=pM(split(readline()))
  println(100^d*(n+Int(n==100)))
end
main()
if isdefined(Base, :mystdin);close(mystdin);end

Measured memory_bytes: 166912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
const ll MAX = 510000;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
void Main(){
    ll n;cin>>n;
    vector<ll> x(n);
    For(i,0,n) cin>>x[i];
    COMinit();
    vector<ll> acc(n+1,0);
    For(i,0,n) acc[i+1]=acc[i]+inv[i+1];
    For(i,0,n-1){
        ans+=(x[i+1]-x[i])*acc[i+1]%MOD;
        ans%=MOD;
    }
    ans*=fac[n-1];
    cout<<ans%MOD<<endl;
}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 13824
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long i64;

#define iter(i, n) for (int i = 1; i <= n; ++i)
#define NR 201000

const int inf = 1e9;

vector<int> g[NR];
char s[NR];
int m1[NR], m2[NR], n, son[NR];
i64 ans;

void dfs(int x, int fa) {
	m2[x] = -inf; m1[x] = -1;
	for (int v : g[x]) if (v != fa) {
		dfs(v, x);
		if (m1[x] == m1[v]) son[x] = 0;

		if (m1[v] > m1[x]) m2[x] = m1[x], m1[x] = m1[v], son[x] = v;
		else if (m1[v] > m2[x]) m2[x] = m1[v];
	}
	++m1[x], ++m2[x];
//	printf("!!%d %d\n", m1[x], m2[x]);
}

bool calc(int x, int fa, int upper) {
//	printf("!%d %d\n", m1[x] - 1, upper);
	//upper = max(upper, m1[x] - 1);
	int lower = (s[x] == '1' ? 0 : +inf);
	
	int mx = 0;
	for (int v : g[x]) if (v != fa) {
	//	printf("%d->%d %d\n", v, x, mx);
		if (calc(v, x, max(upper, v != son[x] ? m1[x] : m2[x]) + 1)) {
			lower = min(lower, m1[v] + 1);
		}
		mx = m1[v] + 1;
	}

	
	if (fa == 0) upper = m1[x] + 1;
	upper = min(upper - 1, m1[x] + 1);
	//printf("%d %d %d\n", x, lower, upper);
	if (lower <= upper) ans += upper - lower + 1;
	return lower != inf;
}

bool cmp(int i, int j) { return m1[i] < m1[j]; }

int main() {
	scanf("%d", &n);
	iter(i, n - 1) {
		int x, y;
		scanf("%d%d", &x, &y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	scanf("%s", s + 1);
	int root;
	iter(i, n) if (s[i] == '1') root = i;
	dfs(root, 0);
	iter(i, n) sort(g[i].begin(), g[i].end(), cmp);
	
	calc(root, 0, 0);
	printf("%lld\n", ans);
	return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ok = 0, ng = n;
    vector<int> state(n, -1);
    cout << 0 << endl;
    string s;
    cin >> s;
    if (s == "Vacant") return 0;
    state[0] = (s == "Female"); 
    while (true) {
        int mid = (ok + ng) / 2;
        cout << mid << endl;
        cin >> s;
        if (s == "Vacant") break;
        state[mid] = (s == "Female");
        if (state[mid] == state[ok]) {
            if ((mid - ok) % 2 == 0) ok = mid;
            else ng = mid;
        } else {
            if ((mid - ok) % 2 == 0) ng = mid;
            else ok = mid;
        }
    }
    return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない


int main() {

	int ans = 0;
	int num[100000];
	int n, k,o;
	cin >> n >> k;

	rep(i, 0, n) {
		cin >> num[i];
	}

	if (n == k) {
		cout << 1 << endl;
	}
	else if ((n - k) % (k - 1) != 0) {
		cout << 1 + (n - k) / (k - 1) + 1 << endl;
	}
	else {
		cout << 1 + (n - k) / (k - 1) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 640