akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
#include<vector>

int main() {
  int n, m, res = 0;
  cin >> n >> m;
  int lb[m][n], p[m], k[m];
  for(int i = 0; i < m; i++) {
    cin >> k[i];
    for(int j = 1; j <= k[i]; j++) {
      cin >> lb[i][j];
    }
  }
  for(int i = 0; i < m; i++) {
    cin >> p[i];
  }
  bool flag;
  int sw = 0 , temp;
  for(int bit = 0; bit < (1<<n); bit++) {
    flag = true;
    vector<int> S;
    for(int i = 0; i < n; i++) {
      if(bit & (1<<i)) {
        S.push_back(i);
      }
    }
    for(int i = 0; i < m; i++) {
      sw = 0;
      for(int j = 1; j <= k[i]; j++) {
        if(bit & (1<<(lb[i][j]-1))) sw++;
      }
      if(sw%2 != p[i]) {
        flag = false;
        break;
      }
    }

    if(flag) res++;
   }
   cout << res << endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include<cmath>
using namespace std;
int main(void){
    // Your code here!
    string N;
    cin>>N;
    
    int sum=0;
    
    for(char c: N){
        
        int n= c-'0';
        sum += n%9;
        sum%=9;
    }
    if(sum==0)
    cout<<"Yes";
    else
    cout<<"No";
}


Measured memory_bytes: 3676
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a < b){
        	if(a < c && b > c){
            	System.out.println("Yes");
            }else{
            	System.out.println("No");
            }
        }else{
        	if(b < c && a > c){
            	System.out.println("Yes");
            }else{
            	System.out.println("No");
            }
        }
    }
}

Measured memory_bytes: 35592
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

char c[100005];

int main(){
  scanf("%s", c);
  int k;
  cin>>k;
  int n = strlen(c);

  rep(i,n){
    if(c[i]=='a') continue;
    if(26-(c[i] - 'a') <= k){
      k -= 26-(c[i] - 'a');
      c[i] = 'a';
    }
  }

  if(k>0){
    if(26-(c[n-1]-'a') > k){
      c[n-1] += k;
    } else {
      k -= 26-(c[n-1]-'a');
      c[n-1] = 'a' + (k%26);
    }
  }

  printf("%s\n", c);

  return 0;
}


Measured memory_bytes: 512
class UnionFind:
    def __init__(self, n):
        self.nodes = n
        self.parents = [i for i in range(n)]
        self.sizes = [1] * n
        self.rank = [0] * n

    def find(self, i): # どの集合に属しているか（根ノードの番号）
        if self.parents[i] == i:
            return i
        else:
            self.parents[i] = self.find(self.parents[i]) # 経路圧縮
            return self.parents[i]

    def unite(self, i, j): # 二つの集合を併合
        pi = self.find(i)
        pj = self.find(j)
        if pi != pj:
            if self.rank[pi] < self.rank[pj]:
                self.sizes[pj] += self.sizes[pi]
                self.parents[pi] = pj
            else:
                self.sizes[pi] += self.sizes[pj]
                self.parents[pj] = pi
                if self.rank[pi] == self.rank[pj]:
                    self.rank[pi] += 1
    def same(self, i, j): # 同じ集合に属するかを判定
        return self.find(i)==self.find(j)

    def get_parents(self): # 根ノードの一覧を取得
        for n in range(self.nodes): # findで経路圧縮する
            self.find(n)
        return self.parents

    def size(self, i):
        p = self.find(i)
        return self.sizes[p]


N, M = map(int, input().split())
AB = []
B = []
for m in range(M):
    a, b = map(int, input().split())
    AB.append((a-1,b-1))

ans = []
score = N * (N-1) // 2
uf = UnionFind(N)
for a, b in AB[::-1]:
    ans.append(score)
    if not uf.same(a,b):
        score -= uf.size(a) * uf.size(b)
        uf.unite(a,b)    

for score in ans[::-1]:
    print(score)

Measured memory_bytes: 29556
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
	int N; cin >> N;
	ll* A = new ll[N];

	bool f1 = false, f2 = false;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (i % 2 == 0 && A[i] >= 0) { f1 = true; }
		if (i % 2 == 1 && A[i] >= 0) { f2 = true; }
	}
	bool* B = new bool[N];
	for (int i = 0; i < N; i++) {
		B[i] = false;
	}
	ll s1 = 0, s2 = 0;
	if (f1 == false && f2 == false) {
		ll m = A[0];
		int k = 0;
		for (int i = 0; i < N; i++) {
			if (A[i] >= m) { m = A[i]; k = i; }
		}

		cout << m << endl;
		cout << N - 1 << endl;
		for (int i = N; i >= k + 2; i--) {
			cout << i << endl;
		}
		for (int i = 0; i < k; i++) {
			cout << 1 << endl;
		}

		return 0;
	}
	if (f1 == false) {
		s1 = -(1LL << 50);
	}
	if (f2 == false) {
		s2 = -(1LL << 50);
	}
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) {
			if (A[i] >= 0) { s1 += A[i]; }
		}
		else {
			if (A[i] >= 0) { s2 += A[i]; }
		}
	}
	
	int c = 0;
	if (s1 > s2) {
		cout << s1 << endl;
		for (int i = 0; i < N; i += 2) {
			if (A[i] >= 0) { B[i] = true; c++; }
		}
	}
	else {
		cout << s2 << endl;
		for (int i = 1; i < N; i += 2) {
			if (A[i] >= 0) { B[i] = true; c++; }
		}
	}
	vector<int> ans;
	int R = N;
	for (int i = N - 1; i >= 0; i--) {
		if (B[i] == false) {
			ans.push_back(R);
			R--;
		}
		else {
			break;
		}
	}
	int L = 0;
	while (B[L] == false) {
		L++;
		ans.push_back(1);
	}

	for (int i = R - 3; i > L + 1 ; i -= 2) {
		if ((B[i] | B[i - 1] | B[i + 1]) == false) {
			ans.push_back(i - L + 1);
		}
	}

	for (int i = 0; i < c - 1; i++) {
		ans.push_back(2);
	}

	cout << ans.size() << endl;
	for (auto itr = ans.begin(); itr != ans.end(); itr++) {
		cout << *itr << endl;
	}

	return 0;
}


Measured memory_bytes: 256
// 初回というか半分から向こう側はいじれないからこっち側半分を考えると...
// くそむずい どうやって実装するんだこれ
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	A := make([]int, N+1)
	for i := 0; i < N; i++ {
		var V int
		fmt.Scan(&V)
		A[i+1] = V
	}
	ANS := make([]int, N+1)
	for i := N; i > 0; i-- {
		s := 0
		for j := i + i; j < N+1; j += i {
			// s += A[j]	は？？？？？？？？？？？？？？？？？？？？？
			s += ANS[j]
		}
		if s%2 != A[i] {
			ANS[i] = 1
		}
		// fmt.Printf("i=%d, now ans %v\n", i, ANS[1:])
	}
	SUM := 0
	for _, a := range ANS {
		SUM += a
	}
	fmt.Println(SUM)
	arr := []int{}
	for i := 1; i < N+1; i++ {
		if ANS[i] == 1 {
			arr = append(arr, i)
		}
	}
	for i := 0; i < len(arr); i++ {
		if i == len(arr)-1 {
			fmt.Printf("%d\n", arr[i])
		} else {
			fmt.Printf("%d ", arr[i])
		}
	}
}


Measured memory_bytes: 8320
import java.util.*;

public class Main {
    public static int solve(int n, int m, int[] x, int[] y) {
        Map<Integer, List<Integer>> graph = new HashMap<>();
      	for (int i = 0; i < n; i++) {
          graph.put(i, new LinkedList<Integer>());
        }
      
        for (int i = 0; i < m; i++) {
          graph.get(x[i] - 1).add(y[i] - 1);
        }

        int[] memo = new int[n];
        Arrays.fill(memo, -1);
        
      	int result = 0;
        for (int i = 0; i < n; i++) {
          result = Math.max(result, dfs(graph, i, memo));
        }
        return result;
    }

    private static int dfs(Map<Integer, List<Integer>> graph, int from, int[] memo) {
      if (memo[from] >= 0) {
        return memo[from];
      }

      int maxPath = 0;
      for (int to : graph.get(from)) {
        maxPath = Math.max(maxPath, dfs(graph, to, memo) + 1);
      }
      memo[from] = maxPath;
      return maxPath;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();

        int[] from, to;
        from = new int[m];
        to = new int[m];
        for (int i = 0; i < m; i++) {
          from[i] = scanner.nextInt();
          to[i] = scanner.nextInt();
        }
        
        int result = solve(n, m, from, to);
        System.out.println(result);
    }
}

Measured memory_bytes: 81316
module S = Set.Make (struct type t = int let compare = compare end) ;;

Scanf.scanf "%d" (fun nn ->
    let divisors a =
        let rec loop i acc =
            if i * i > a then acc else
                let acc = if a mod i = 0 then S.add (a / i) (S.add i acc) else acc in
                loop (i + 1) acc
        in
        loop 2 (S.singleton a)
    in
    let rec loop n k =
        if n = 1 then true else
            if n < k then false else
            if n mod k = 0 then loop (n / k) k
                           else loop (n mod k) k
    in
    let rec loop2 acc = function
        | [] -> acc
        | hd :: tl ->
                let acc = if loop nn hd then acc + 1 else acc in
                loop2 acc tl
    in
    if nn = 2 then Printf.printf "%d\n" 1 else
        let set = divisors (nn - 1) in
        let set = S.union (divisors nn) set in
        loop2 0 (S.elements set) |> Printf.printf "%d\n"
)

Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int d,g;
  cin>>d>>g;
  int p[d],c[d];
  rep(i,d) cin>>p[i]>>c[i];
  int mi = MOD;
  for(int i = 0; i < (int)pow(2,d); i++) {
    int tmp = 0;
    int cnt = 0;
    rep(j, d) {
      int f = i / (int)pow(2,j) % 2;
      if(f == 1) {
        cnt += p[j];
        tmp += f * p[j] * 100 * (j + 1) + c[j];
      }
    }
    if(tmp >= g) {
      mi = min(mi, cnt);
    } else {
      repr(j, d-1) {
        int f = i / (int)pow(2,j) % 2;
        if(f == 1) continue;
        if(tmp + (p[j] - 1) * 100 * (j + 1) < g) break;
        cnt += (g - tmp - 1) / (100 * (j + 1)) + 1;
        mi = min(mi, cnt);
        break;
      }
    }
  }
  cout << mi << endl;

  return 0;

}


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

int ans[120][2][12];//二つ目の次元の0の0に数列の長さ、0の1に操作回数、1に答えの数列

int counter=0,flag=0;

void solve(){
	int n;
	cin >> n;
	if(n==0){flag=1;return;}
	ans[counter][0][0]=n;
	
	int S[12];//数列
	for(int i=0;i<n;i++){
		cin >> S[i];
	}
	
	bool check=false;//操作の有無のフラグ
	int time=0;//操作回数
	do{
		map<int,int> marker;
		for(int i=0;i<n;i++){
			marker[S[i]];
			marker[S[i]]++;
		}
		check=false;
		for(int i=0;i<n;i++){
			if(S[i]!=marker[S[i]]){
				check=true;
				S[i]=marker[S[i]];
			}
		}
		if(check) time++;
	}while(check);
	
	ans[counter][0][1]=time;
	for(int i=0;i<n;i++){
		ans[counter][1][i]=S[i];
	}
	counter++;
}

int main(){
	while(flag==0)solve();
	for(int i=0;i<counter;i++){
		cout << ans[i][0][1] << endl;
		for(int j=0;j<ans[i][0][0]-1;j++){
			cout << ans[i][1][j]<<" ";
		}
		cout << ans[i][1][ans[i][0][0]-1] << endl;
	}
}
			
	
	

Measured memory_bytes: 1208
K, T = map(int, raw_input().split())
A = map(int, raw_input().split())
A = sorted([[i, j] for i, j in enumerate(A)], key=lambda x:x[1])
last = -1
for i in xrange(K):
    A = sorted(A, key=lambda x:x[1])
    if len(A) == 1:
        print A[0][1] - 1 + (last == A[0][0])
        exit()
    if last == A[-1][0]:
        A[-2][1] -= 1
        last = A[-2][0]
        if A[-2][1] == 0:
            A.pop(-2)
    else:
        A[-1][1] -= 1
        last = A[-1][0]
        if A[-1][1] == 0:
            A.pop()
print 0


Measured memory_bytes: 21356
#include <iostream>
#include <string>
#include <vector>
#include <regex>
using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b >> c;

  int f, s;
  if(a == 7)s++;
  if(a == 5)f++;
  if(b == 7)s++;
  if(b == 5)f++;
  if(c == 7)s++;
  if(c == 5)f++;

  if ( f == 2 && s == 1)cout << "YES";
  else	cout << "NO";

}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int n,i;
  int k[250],pk[250],lk[250],rk[250];
  
  scanf("%d",&n);
  for(i = 1;i < n+1;i++){
    scanf("%d",&k[i]);
  }

  for(i = 1;i < n+1;i++){
    printf("node %d: key = %d, ",i,k[i]);
    if(i != 1){
      pk[i] = k[i/2];
      printf("parent key = %d, ",pk[i]);
    }
    if(i*2 < n+1){
      lk[i] = k[2*i];
      printf("left key = %d, ",lk[i]);
    }
    if(i*2+1 < n+1){
      rk[i] = k[2*i+1];
      printf("right key = %d, ",rk[i]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    ll n, m;
    cin >> n >> m;
    ll cnt = 0;
    if(m > 2*n){
        cnt += n;
        m = m - 2*n;
    }
    else{cnt += (m/2); m = 0;}
    cnt += (m/4);
    cout << cnt << endl;
}

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

using namespace std;

const int MOD = 1000000007;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i=0;i<N;++i) cin >> A[i];

    for(int i = K; i < N; ++i){
        if(A[i - K] < A[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


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

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			if (n % 1111 == 0) {
				System.out.println("NA");
				continue;
			}

			int count = 0;
			while (true) {
				if (n == 6174) {
					break;
				}
				n = slove(n);
				count++;
			}
			System.out.println(count);
		}

	}

	private int slove(int n) {
		char[] c = String.valueOf(n).toCharArray();
		Arrays.sort(c);

		int min = Integer.valueOf(String.valueOf(c));
		StringBuilder builder = new StringBuilder(String.valueOf(c)).reverse();
		while (builder.length() < 4) {
			builder.append("0");
		}
		int max = Integer.valueOf(builder.toString());
		return max - min;
	}
}

Measured memory_bytes: 45232
N,Q=gets.split.map(&:to_i)
A=[0]*(N+1)
A[c=1]=1
f=->{
	A[c-1]=1 if c-1>0 && A[c-1]==0
	A[c+1]=1 if c+1<=N && A[c+1]==0
}
Q.times{
	a,b=gets.split.map(&:to_i)
	f.()
	A[a],A[b]=A[b],A[a]
	c = c==a ? b : c==b ? a : c
}
f.()
p A.count{|e|e>0}

Measured memory_bytes: 2556
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		for(int i=0; i<3; i++){
			int h1=sc.nextInt();
			int m1=sc.nextInt();
			int s1=sc.nextInt();
			int h2=sc.nextInt();
			int m2=sc.nextInt();
			int s2=sc.nextInt();
			int h=h2-h1;
			int m=m2-m1;
			int s=s2-s1;
			if(s<0){
				s+=60;
				m--;
			}
			if(m<0){
				m+=60;
				h--;
			}
			println(h+" "+m+" "+s);
		}
	}

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

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize,
        s: Chars
    };

    let res = s
        .into_iter()
        .map(|ch| {
            let pos = (ch as u8 - 0x41 + n as u8) % 26;
            char::from(0x41 + pos)
        })
        .join("");
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2292
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   int a,b,c;
   cin >> a >> b >> c;

   if(a==b)cout << c << endl;
   else if(a==c) cout << b << endl;
   else cout << a << endl;


   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)

using ll = long long;
using namespace std;

constexpr int INF = 2147483647; // 2 * 1e9
constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	int sum = 0;
	for(int i = 1; i <= b- a; ++i)sum += i;
	cout <<sum - b << "\n";
	return 0;
}


Measured memory_bytes: 256
if __FILE__ == $0
  while line = gets
    a = line.to_f
    prev = a
    sum = a
    for i in (2..10)
      if i % 2 == 0
        prev = prev * 2
      else
        prev /= 3.0
      end
      sum += prev
    end
    puts sum
  end
end

Measured memory_bytes: 6104
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,n,s) for(int i=s;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

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

  int n;
  cin >> n;

  int a[(int)1e5];
  REP(i, n+1) {
    cin >> a[i];
  }

  ll ans = 0;
  int remain = 0;
  REP(i, n+1) {
    if(remain > 0) {
      if((a[i] - remain) > 0) {
        ans += remain;
        a[i] -= remain;
      } else {
        ans += a[i];
        a[i] = 0;
      }
    }

    if(i != n) {
      int b;
      cin >> b;

      if(b > a[i]) {
        ans += a[i];
        remain = b - a[i];
      } else {
        ans += b;
        remain = 0;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main()
{
	int H, N;
	scanf("%d%d", &H, &N);

	int attackSum = 0;
	for (int i = 0; i < N; ++i)
	{
		int foo;
		scanf("%d", &foo);
		attackSum += foo;
	}

	if (attackSum >= H) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0; 
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
long long a, b, c, ans;
bool check(long long x)
{
    long long sum = 0;
    while (x)
    {
        sum += (x % 10);
        x /= 10;
    }
    return sum >= b && sum <= c;
}
int main() {
    cin >> a >> b >> c;
    for (long long i = 1; i <= a; ++i)
    {
        ans += (check(i) ? i : 0);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

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

const int N = 100500;

int n, m, cnt[N];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

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

	//cout << setprecision(10) << fixed;
	
	cin >> n >> m;

	for (int i = 1; i <= m; i++) {
		int x, y;
		cin >> x >> y;
		cnt[x]++, cnt[y]++;
	}

	for (int i = 1; i <= n; i++) {
		if (cnt[i] & 1) {
			cout << "NO";
			return 0;
		}
	}

	cout << "YES";
	
	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


Measured memory_bytes: 640
S=input()

if S[0]==S[1] and S[2]==S[3]:
    if S[1]==S[2]:
        print("No")
    else:
        print("Yes")
elif S[0]==S[2] and S[1]==S[3]:
    if S[1]==S[2]:
        print("No")
    else:
        print("Yes")
elif S[0]==S[3] and S[1]==S[2]:
    if S[0]==S[2]:
        print("No")
    else:
        print("Yes")   
    
else:
    print("No")
    

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define LL long long 
#define ULL unsigned long long 

const int N = 1e5+11;
const int M = 1e6+11;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int inff = 0x3f3f3f3f3f3f3f3f;


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


int main(){
	LL a,b,c,d;
	while(cin>>a>>b>>c>>d){
			cout<<max(a*b,c*d)<<endl;
	}

return 0;
}

Measured memory_bytes: 256
S = input()
sum = 0
for j in range(2**(len(S)-1)):
    shiki = ""
    for i in range(len(S)):
        bin_str = str(format(j, 'b').rjust(10, '0'))
        shiki += S[i]
        if bin_str[-i - 1] == "1":
            shiki = shiki + "+"
    sum += eval(shiki)
print(sum)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int n,m,k,nr;
pair <int,int> v[1000006];
priority_queue <int> q;
int sol;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>m;
    for(int i=1;i<=n;++i) cin>>v[i].first>>v[i].second;
    sort(v+1,v+n+1);
    k=1;
    for(int i=1;i<=m;++i)
    {
        while(k<=n&&v[k].first<=i)
        {
            ++nr;
            q.push((int)v[k].second);
            ++k;
        }
        if(nr)
        {
            sol+=q.top();
            q.pop();
            --nr;
        }
    }
    cout<<sol;
    return 0;
}


Measured memory_bytes: 1660
#include<cstdio>
#include<algorithm>
#include<cstring>
int ans,a,b,c,x,y;
using namespace std;
int main()
{
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	ans=1000000000;
	for (int i=0;i<=max(x,y)*2;++i)
	{
		ans=min(ans,c*i+max(0,x-i/2)*a+max(0,y-i/2)*b);
	}
	printf("%d\n",ans);
} 

Measured memory_bytes: 128
n = int(input(''))
a = [int(x) for x in str(input('')).split(' ')]
b = [int(x) for x in str(input('')).split(' ')]
c = [int(x) for x in str(input('')).split(' ')]

sat = sum(b)

for i in range (0, len(a)-1):
    if a[i]+1 == a[i+1]:
        sat += c[a[i]-1]
        
print(sat)

Measured memory_bytes: 3064
using System;
class B_Bounding{
	static void Main(string[] args){
		string[] NX = Console.ReadLine().Split(' ');
		string[] Lstr = Console.ReadLine().Split(' ');
		int X = int.Parse(NX[1]);
		int[] L = new int[int.Parse(NX[0])];
		for(int Ind = 0;Ind < int.Parse(NX[0]) ; Ind ++){
			L[Ind] = int.Parse(Lstr[Ind]);
		}
		int r = 0;
		int ans = 1;
		for(int i = 0;i < int.Parse(NX[0]) ; i++){
			r += L[i];
			if(r > X)break;
			ans++;
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;

template <class T>
T mult(T n,T m){
	if(m==0) return 1;
	if(m==1){
		return n%mod;
	}else if(m%2==0){
		T t=mult(n,m/2);
		return (t*t)%mod;
	}else{
		T t=mult(n,m-1);
		return (t*n)%mod;
	}
}

vector<ll> d1(100010),d2(100010);
template <class T>
void make_table(T N){
	for(ll i=0;i<=N;i++){
		if(i==0){
			d1[i]=1;
			d2[i]=1;
		}else{
			d1[i]=(i*d1[i-1])%mod;
			d2[i]=mult(d1[i],mod-2);
		}
	}
}

template <class T>
T comb_mod_2(T n,T k){
	if(n<k) return 0;
	return (((d1[n]*d2[n-k])%mod)*d2[k])%mod;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;
  cin>>n>>k;
  vector<vector<int>> g(n);
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--,b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  ll ans=0;
  queue<int> que;
  que.push(0);
  make_table(100010);
  vector<bool> used(n,false);
  while(!que.empty()){
    int v=que.front();
    que.pop();
	used[v]=true;
    if(v==0){
      ans+=k;
      ll cnt=0;
      for(auto itr:g[v]){
        que.push(itr);
        cnt++;
      }
      ans*=comb_mod_2(k-1,cnt);
      ans%=mod;
      ans*=d1[cnt];
	  ans%=mod;
    }else{
		ll cnt=0;
      for(auto itr:g[v]){
		  if(used[itr]) continue;
        que.push(itr);
        cnt++;
      }
      ans*=comb_mod_2(k-2,cnt);
      ans%=mod;
      ans*=d1[cnt];
	  ans%=mod;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 8184
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
  char b;
  cin >> b;
  if(b=='A'){
    cout << 'T' <<endl;
  }else if(b=='T'){
    cout << 'A' <<endl;
  }else if(b=='G'){
    cout << 'C' <<endl;
  }else if(b=='C'){
    cout << 'G' <<endl;
  }

  return 0;
}

Measured memory_bytes: 256
import sys
 
def solve(N, T, A, ls_H):
    return min([(abs(A - (T - h * 0.006)), i) for (i, h) in enumerate(ls_H, start=1)])[1]
 
def readQuestion():
    ws = sys.stdin.readline().strip().split()
    N = int(ws[0])
    ws = sys.stdin.readline().strip().split()
    T = int(ws[0])
    A = int(ws[1])
    ws = sys.stdin.readline().strip().split()
    ls_H = list(map(int, ws))
    return (N, T, A, ls_H)
 
def main():
    print(solve(*readQuestion()))
 
# Uncomment before submission
main()


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set0(a) memset ((a), 0 , sizeof(a))
#define set1(a) memset((a),-1,sizeof (a))
#define pi pair<int, int>
#define ps pair<string, string>
#define pl pair<long, long>
#define pll pair<long long, long long>
#define vll vector<long long>
#define vl vector<long>
#define vi vector<int>
#define vs vector<string>
#define vps vector< ps >
#define vpi vector< pi >
#define vpl vector< pl >
#define vpll vector< pll >
#define flash  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc(t,T) for(long long t=0;t<T;t++)
#define rep(i,s,n,d) for(long long i=s;i<n;i=i+d)

bool sortbysec(const pll &a,
              const pll &b)
{
    return (a.second < b.second);
}
/*bool cxp pair<ll, pll> &a,
              const pair<ll, pll> &b)
{
    return (a.ff < b.ff);
}*/

void func(void)
{
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    else return gcd(b,a%b);
}
void printStack(stack<string> s){
    if(s.empty())return;

    string x=s.top();
    s.pop();
    printStack(s);
    cout<<x;
    s.push(x);

}

int main(){
        ll a;
        cin>>a;
        cout<<a+a*a+a*a*a<<endl;
}


// 1 2 3 1 5 3 1 0 1 0 2
// 1 2 3 4 5 6 7 8 9 10 11






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

int main(){
  long long a,b,c,d,e,f,ans;
cin>>a>>b>>c>>d>>e>>f;
ans=a/(min(b,min(c,min(d,min(e,f)))))+4;
  if(a%(min(b,min(c,min(d,min(e,f)))))==0){
  }
  else{
    ans++;
  }


cout<<ans<<endl;

}


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

int main(){
	int N;
	cin>>N;
	int y_max = N/7;
	for(int i=0;i<=y_max;i++){
		int dif = N-7*i;
		if(dif%4==0){		
			cout<<"Yes";
			break;
		}	
		if(i==y_max){
			cout<<"No";
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))

int main()
{
	string s;
	cin >> s;
	if (stoi(s.substr(5, 2)) < 5)
	{
		cout << "Heisei" << endl;
	}
	else
	{
		cout << "TBD" << endl;
	}
}



Measured memory_bytes: 256
#include <iostream>
#define create_tmp_num(a, b) a * 10 + b

using namespace std;
int main(void){
    cin.tie(0);
    iostream::sync_with_stdio(false);

    int n;
    cin >> n;
    int output =0;
    for(int i=1; i<=100; i = i*10){
            int tmp=n%10;
            n /= 10;
            if(tmp == 1) tmp=9;
            else if(tmp == 9) tmp=1;
            output += tmp * i;
    }
    cout << output << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];

    int sum = accumulate(a.begin(), a.end(), 0);
    int avg = 0;
    if (sum % N >= double(N) / 2)
    {
        avg = (sum / N) + 1;
    }
    else
    {
        avg = sum / N;
    }

    int ans = 0;
    rep(i, N)
    {
        ans += (a[i] - avg) * (a[i] - avg);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include"iostream"

using namespace std;

int main()
{
	while (1) {
	int a, b,ans;
	string o;
	
		cin >> a >> o >> b;
		if (o == "?" )break;
		if (o == "+") { ans = a + b; }
		else if (o == "-") { ans = a - b; }
		else if (o == "*") { ans = a * b; }
		else if (o == "/") { ans = a / b; }
		cout << ans << endl;
	}
    return 0;
}




Measured memory_bytes: 3140
import java.util.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int w,h;
	P s1;
	P s2;
	boolean[][] map;
	boolean[] visited;
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			w = sc.nextInt();
			h = sc.nextInt();
			if( (w|h) == 0) break;
			map = new boolean[h+2][w+2];
			visited = new boolean[6250000];
			s1 = new P(sc.nextInt(), sc.nextInt());
			s2 = new P(sc.nextInt(), sc.nextInt());
			for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) {
				map[i][j] = sc.nextInt() == 0;
			}
			Twin twin = new Twin(s1, s2, 0);
			int ans = bfs(twin);
			if(ans < 0) System.out.println("NA");
			else System.out.println(ans);
		}
	}
	int dx[] = {-1,0,1,0};
	int dy[] = {0,-1,0,1};
	int bfs(Twin twin) {
		LinkedList<Twin> que = new LinkedList<Twin>();
		que.add(twin);
		visited[twin.index()] = true;
		for(;!que.isEmpty();) {
			Twin now = que.removeFirst();
			if( now.isGoal() ) return now.c;
			if( now.c == 100) continue;
			for(int i=0;i<4;i++) {
				Twin next = now.act(dx[i], dy[i]);
				if( !visited[next.index()] ) {
					que.addLast(next);
					visited[next.index()] = true;
				}
			}
		}
		return -1;
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
	
	class Twin {
		P p1, p2;
		int c;
		Twin(P p1, P p2, int c) {
			this.p1 = p1;
			this.p2 = p2;
			this.c = c;
		}
		
		boolean isGoal() {
			return p1.x == p2.x && p1.y == p2.y;
		}
		
		int index() {
			int[] tmp = new int [4];
			tmp[0] = 1;
//			System.out.println(p1.x + " " + p1.y + " " + p2.x + " " + p2.y);
			for(int i=1;i<4;i++) tmp[i] = tmp[i-1]*50;
			return (p1.x-1) * tmp[3] + (p1.y-1) * tmp[2] + (p2.x-1) * tmp[1] + (p2.y-1) * tmp[0]; 
		}
		
		Twin act(int dx, int dy) {
			P next1;
			P next2;
			next1 = p1.act(dx, dy);
			next2 = p2.act(-dx, -dy);
			return new Twin(next1, next2, c+1);
		}
	}
	
	class P {
		int x, y;
		P(int x, int y) {
			this.x = x;
			this.y = y;
		}
		
		P act(int dx, int dy) {
			P next;
			if( map[y+dy][x+dx] ) next = new P(x+dx, y+dy);
			else next = new P(x, y);
			return next;
		}
	}
}

Measured memory_bytes: 29000
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int64_t>A(N);
  vector<int64_t>B(N);
  for(int i=0;i<N;i++){
  int64_t a,b;
    cin>>a>>b;
    A.at(i)=a;
    B.at(i)=b;
  }if(N%2==1){
  sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    int64_t ans=1+B.at((N-1)/2)-A.at((N-1)/2);
  cout<<ans<<endl;
  }else{
  sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    int64_t ans=1+B.at(N/2)+B.at((N/2)-1)-A.at(N/2)-A.at((N/2)-1);
     cout<<ans<<endl;
  }
   return 0;
}

Measured memory_bytes: 6352
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <tuple>
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

llong n;
llong l[100005];
llong r[100005];
pair<llong, llong> s[100005];

int main() {
    cin >> n;
    for (llong i = 0; i < n; i++) {
        cin >> l[i] >> r[i];
        l[i]--;
    }

    llong lm, rm;
    llong max_len;
    lm = 0, rm = 0;
    max_len = r[0] - l[0] + 1;
    
    llong p = 0;
    llong q = 0;
    
    for (llong i = 0; i < n; i++) {
        if (l[lm] < l[i]) lm = i;
        if (r[rm] > r[i]) rm = i;
    }
    for (llong i = 0; i < n; i++) {
        p = max(p, r[i] - l[i] + max(0ll, r[rm] - l[lm]));
    }
    
    for (int i = 0; i < n; i++) {
        s[i] = {max(0ll, r[i] - l[lm]), -1 * max(0ll, r[rm] - l[i])};
    }

    sort(s, s + n);
    llong mi = 1ll << 60ll;
    for (llong i = 0; i < n; i++) {
        if (i) q = max(q, s[i].first + mi);
        mi = min(mi, -s[i].second);
    }

    cout << max(p, q) << endl;

    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include <bits/stdc++.h>
#include <set>
#include <map>
using namespace std;

int main(){
  int a,b;
  cin >> a >>b ;
  if(a>9 || b>9){
    cout << -1<<endl;
  }
  else{
    cout << a*b<<endl;
  }

}


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

typedef long long ll;
ll n, m, s, c;
map<ll, ll> ma;
int main()
{
	ll t;
	cin >> n >> m;
	ma[0]++;
	while (n--) {
		scanf("%lld", &t);
		s += t;
		c += ma[s % m];
		ma[s % m]++;
	}
    cout << c << endl;
    return 0;
}

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

using Int = __int128_t;
Int abs128(Int val){return val<0?-val:val;}

ostream &operator<<(ostream &os,Int val){
  if(ostream::sentry(os)){
    __uint128_t tmp=abs128(val);
    char buf[64];
    char *d=end(buf);
    do{
      --d;
      *d=char(tmp%10+'0');
      tmp/=10;
    }while(tmp);
    if(val<0) *--d='-';
    Int len=end(buf)-d;
    if(os.rdbuf()->sputn(d,len)!=len){
      os.setstate(ios_base::badbit);
    }
  }
  return os;
}

istream &operator>>(istream &is,Int &val){
  string s;
  is>>s;
  val=0;
  for(Int i=0;i<(Int)s.size();i++)
    if(isdigit(s[i])) val=val*10+s[i]-'0';
  if(s[0]=='-') val*=-1;
  return is;
}



struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int k;
  cin>>k;
  if(k<=9){
    for(Int i=1;i<=k;i++) cout<<i<<endl;
    return 0;
  }
  vector<Int> v;
  for(Int i=1;i<1000;i++){
    Int x=i,y=0;
    v.emplace_back(x);
    for(Int j=0;j<20;j++){
      x*=10;
      y=y*10+9;
      //cout<<x+y<<endl;
      if(x+y<1e18) v.emplace_back(x+y);
    }
  }
  //cout<<v.size()<<endl;
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());
  while(v.back()>1e18) v.pop_back();
  //cout<<v.back()<<endl;
  auto calc=
    [&](Int x){
      string s=to_string((long long)x);
      Int res=0;
      for(char c:s) res+=c-'0';
      return res;
    };
  
  for(Int i=0;;i++){
    if(!k) break;
    Int flg=1;
    for(Int j=i;j<(Int)v.size();j++){
      flg&=v[i]*calc(v[j])<=v[j]*calc(v[i]);
      //if(v[i]*calc(v[j])>v[j]*calc(v[i])) cout<<v[i]<<":"<<v[j]<<endl;
      if(!flg) break;
    }
    if(flg){
      cout<<v[i]<<endl;
      k--;
    }
  }
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;

int main()
{
  string s,t;
  cin >> s >> t;
  vector <vector<ll> > dp(s.size()+1, vector<ll>(t.size()+1, 0));
  
  for( int i=0;i<s.size()+1;i++ )
    {
      for( int j=0;j<t.size()+1;j++ )
	{
	  if(i<s.size() && j<t.size())
	    {
	      if( s[i] == t[j] )
		dp[i+1][j+1] = max(dp[i][j]+1, dp[i+1][j+1]);
	      else
		dp[i+1][j+1] = max(dp[i][j], dp[i+1][j+1]);
	    }
	  if(i<s.size())
	    dp[i+1][j] = max(dp[i][j], dp[i+1][j]);
	  if(j<t.size())
	    dp[i][j+1] = max(dp[i][j], dp[i][j+1]);	  
	}
    }


  string out;
  int i = s.size(),j = t.size();
  while( i>0 && j>0 )
    {
      if(dp[i-1][j-1]+1 == dp[i][j] && s[i-1] == t[j-1])
	{
	  i--;
	  j--;
	  out = s[i]+out;
	}
      else if(dp[i-1][j-1] == dp[i][j])
	{
	  i--;
	  j--;
	}
      else if(dp[i][j-1] == dp[i][j])
	j--;
      else
	i--;
    }
    cout << out << endl;
}


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

int main() {
    int h, w;
    cin >> h >> w;
    
    char s[h][w];
    int ans[h][w];
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            cin >> s[i][j];
            ans[i][j] = 0;
        }
    }
        
    
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            if (s[i][j] == '#') {
                if (i >= 1) {
                // if (ans[i-1][j] == -1) {
                //     continue;
                // }
                ans[i-1][j]++;
                    if (j > 0) {
                // if (ans[i-1][j-1] == -1) {
                //     continue;
                // }
                        ans[i-1][j-1]++;
                    }
                    if (j < w-1) {
                // if (ans[i-1][j+1] == -1) {
                //     continue;
                // }
                        ans[i-1][j+1]++;
                    }
                }
                if (j > 0) {
                // if (ans[i][j-1] == -1) {
                //     continue;
                // }
                    ans[i][j-1]++;
                }
                if (j < w-1) {
                // if (ans[i][j+1] == -1) {
                //     continue;
                // }
                    ans[i][j+1]++;
                }
                if (i < h-1) {
                // if (ans[i+1][j] == -1) {
                //     continue;
                // }
                    ans[i+1][j]++;
                    if (j > 0) {
                // if (ans[i+1][j-1] == -1) {
                //     continue;
                // }
                        ans[i+1][j-1]++;
                    }
                    if (j < w-1) {
                // if (ans[i+1][j+1] == -1) {
                //     continue;
                // }
                        ans[i+1][j+1]++;
                    }
                }
            }
        }
    }
    
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            if (s[i][j] == '#') {
                cout << '#';
            } else {
            cout << ans[i][j];
            }
        }
        cout << endl;
    }

}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>

using namespace std;


int main()
{
	int N,K;

	cin >> N >> K;

	int cnt = 0;

	int k;
	for (int ni = 0; ni < N; ni++){
		cin >> k;
		if ( k >= K){
			cnt++;
		}
	}

	int ans = cnt;

	//printf("%.9f", ans);
	std::cout << ans;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define PI          acos(-1)
#define INF         100000000
#define sc(n)       scanf("%d",&n);
#define ssc(n)      scanf("%s",n);
#define lsc(n)      scanf("%lld",&n);
#define dsc(n)      scanf("%lf",&n);
#define csc(n)       scanf("%c",&n);
#define LL          long long int
#define UI          unsigned int
#define ULL         unsigned long long int
#define DB          double
#define pii         pair<int,int>
#define VI          vector<int>
#define MII         map<int,int>
#define PB          push_back
#define MP          make_pair
#define M(mx,a)     mx=max(mx,a)
#define IT          ::iterator
#define all(a)      a.begin(),a.end()
#define mems(a,b)   memset(a,b,sizeof(a))
#define F(i,a,b)    for(i=a;i<b;i++)
#define IN(n,aa)    for(i=0;i<n;i++)scanf("%d",&aa[i]);
#define PNT(n,aa)   for(i=0;i<n;i++)printf("%lld ",aa[i]);
#define mod         1000000007
#define NUM         109
#define NUM2        1000000000

char ch[] = {'A','C','G','T'};
int dd[109][10][10][10];
bool ck(int x,int y,int z)
{
    string ss="";
    ss.PB(ch[x]);
    ss.PB(ch[y]);
    ss.PB(ch[z]);
    if(ss=="AGC")return 0;
    return 1;
}

int solve(int n)
{
    int i,j,k,l,ii;
    for(i=0;i<4;i++)
        for(j=0;j<4;j++)
            for(k=0;k<4;k++)
                if(ck(i,j,k)&&ck(i,k,j)&&ck(j,i,k))
                {
                    dd[3][i][j][k]=1;
                }
    for(l=4;l<=n;l++)
        for(i=0;i<4;i++)
            for(j=0;j<4;j++)
                for(k=0;k<4;k++)
                    for(ii=0;ii<4;ii++)
                        if(ck(i,j,k)&&ck(ii,i,k)&&ck(ii,j,k)&&ck(i,k,j)&&ck(j,i,k))
                        {
                            dd[l][i][j][k]+=dd[l-1][ii][i][j]%mod;
                            dd[l][i][j][k]%=mod;
                        }
    int cnt=0;
    for(i=0;i<4;i++)
        for(j=0;j<4;j++)
            for(k=0;k<4;k++) cnt+=dd[n][i][j][k],cnt%=mod;
    return cnt;
}
int main()
{
    int T=1,QQ=0;
    //cin >> T ;
    while(T--)
    {
        int N;
        cin >> N ;
        cout << solve(N);
    }
}

//printf("Case %d: ",++QQ);


Measured memory_bytes: 3912
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repm(i, a, n) for (int i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void Print(bool c)
{
    if (c)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int count(int x)
{
    if (x == 0)
        return 0;
    else
        return count(x >> 1) + (x & 1);
}

int main()
{
    ll a, b;
    cin >> a >> b;
    cout << a * b / gcdll(a, b) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T> void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T> void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U> bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U> bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T> bool even(T n) { return ! (n & 1); }
template<class T> bool odd(T n) { return n & 1; }
template<class T> ll rup(T a, T b) { return a % b ? a / b + 1 : a / b; }
template<class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
ll intpow(ll a, ll n, ll _mod=numeric_limits<ll>::max()) { ll p=1; while (n) { if (n&1) p=p*a%_mod; a=a*a%_mod; n>>=1; } return p; } 
ll modc(ll a, char op, ll b, ll _mod=mod)
{
        a %= _mod; b %= _mod; ll res = 1;
        switch (op) {
        case '+': res = (a + b) % _mod; break;
        case '-': res = (a - b) % _mod; break;
        case '*': res = a * b % _mod; break;
        case '/': res = modc(a, '*', modc(b, '^', _mod-2, _mod), _mod); break;
        case '^': res = intpow(a, b, _mod); break;
        case 'P': rep(i, a-b+1, a+1) res = modc(res, '*', i, _mod); break;
        case 'C': res = modc(modc(a, 'P', b, _mod), '/', modc(b, 'P', b, _mod)); break;
        } 
        if (res < 0) { res += _mod; } return res;
}



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

        ll ans = 0;
        while (N) {
                if (N%10 == 2) ++ans;
                N /= 10;
        }

        cout << ans << endl;
}


Measured memory_bytes: 3600
#include<stdio.h>
#include<string.h>
int main(void)
{
	int i,c[26],l,x,f=0;
	char s[101];
	for(i=0;i<26;i++){
		c[i]=0;
	}
	scanf("%s",s);
	l=strlen(s);
	for(i=0;i<l;i++){
		x=s[i]-'a';
		c[x]++;
	}
	for(i=0;i<26;i++){
		if(c[i]%2!=0){
			f=1;
			break;
		}
	}
	if(f==0){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128