akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
)

type Point struct {
	Y int
	X int
}

var h, w int

func main() {
	fmt.Scanf("%d %d", &h, &w)

	var (
		tmp string
		level,maxlevel int
	)

	s := make([][]string, h)
	for i := 0; i < h; i++ {
		fmt.Scan(&tmp)
		for _, c := range tmp {
			s[i] = append(s[i], string(c))
		}
	}

	for i:=0; i<h; i++ {
		for j:=0; j<w; j++ {
			level = bfs(Point{i,j}, s)
			if maxlevel < level {
				maxlevel = level
			}
		}
	}

	fmt.Println(maxlevel)
}

func bfs(start Point, m [][]string) int {
	if m[start.Y][start.X] == "#" {
		return 0
	}
	var (
		p  Point
		queue []Point
		level int
	)
	maze := make([][]string, len(m))
	for i := range m {
		maze[i] = make([]string, len(m[i]))
		copy(maze[i], m[i])
	}
	queue = append(queue, start)
	maze[start.Y][start.X] = "#"

	for level = 0; len(queue) != 0; level++ {
		taskqueue := make([]Point, len(queue))
		copy(taskqueue, queue)
		queue = []Point{}
		for len(taskqueue) != 0 {
			p = taskqueue[:1][0]
			taskqueue = taskqueue[1:]

			// up
			if p.Y != 0 {
				if maze[p.Y-1][p.X] != "#" {
					queue = append(queue, Point{p.Y - 1, p.X})
					maze[p.Y-1][p.X] = "#"
				}
			}

			// right
			if p.X != w-1 {
				if maze[p.Y][p.X+1] != "#" {
					queue = append(queue, Point{p.Y, p.X + 1})
					maze[p.Y][p.X+1] = "#"
				}
			}

			//left
			if p.X != 0 {
				if maze[p.Y][p.X-1] != "#" {
					queue = append(queue, Point{p.Y, p.X - 1})
					maze[p.Y][p.X-1] = "#"
				}
			}

			//down
			if p.Y != h-1 {
				if maze[p.Y+1][p.X] != "#" {
					queue = append(queue, Point{p.Y + 1, p.X})
					maze[p.Y+1][p.X] = "#"
				}
			}
		}
	}
	return level - 1
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T;
  cin >> S >> T;
  
  vector<int>numS(S.size());
  for (int i = 0; i < S.size(); i++) {
    numS.at(i) = S.at(i) - '0';
  }
  
  vector<int>numT(T.size());
  for (int i = 0; i < T.size(); i++) {
    numT.at(i) = T.at(i) - '0';
  }
  
  vector<int>countS(26,0);
  for (int i = 0; i < S.size(); i++) {
    countS.at(numS.at(i)-49)++;
  }
  sort(countS.begin(), countS.end());
  
  vector<int>countT(26,0);
  for (int i = 0; i < T.size(); i++) {
    countT.at(numT.at(i)-49)++;
  }
  sort(countT.begin(), countT.end());
  
  for (int i = 0; i < 26; i++) {
    if (countS.at(i) != countT.at(i)){
      cout << "No" << endl;
      return 0;
    }
    else if (i == 25){
      cout << "Yes" << endl;
    }
  }
}
    
  

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

int main() {
	int h, w; cin >> h >> w;
	char a[100][101], b[102][102];

	for (int i = 0; i < h; i++) {
		scanf("%s", a[i]);
	}

	for (int i = 0; i < h + 2; i++) {
		for (int j = 0; j < w + 2; j++) {
			b[i][j] = '#';
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			b[i + 1][j + 1] = a[i][j];
		}
	}
	for (int i = 0; i < h + 2; i++) {
		for (int j = 0; j < w + 2; j++) {
			printf("%c", b[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,x;
  cin>>n>>x;
  vector<int> l(n);
  int d = 0;/*d_1の座標*/
  int count = 0;/*跳ね返った回数を数える変数*/
  for(int i=0;i<n;i++){
    cin>>l.at(i);
    d+=l.at(i);
    /*座標dがxを超えたらループを抜けて、それまでは跳ね返った回数を数える*/
    if(d>x){
      break;
    }
    else{
      count++;
    }
  }
  
  cout<<count+1<<endl;/*d_1の時点で1回跳ね返っているので+1する必要がある*/
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N;
		N = sc.nextInt();
		if(1 <= N && N <= 999) {
			System.out.println("ABC");
		} else if(1000 <= N && N <= 1998) {
			System.out.println("ABD");
		}
	}
}

Measured memory_bytes: 21716
#073C
from collections import Counter
n = int(input())
a = [0]*n
dic = dict()

for _ in range(n):
    a = int(input())
    dic.setdefault(a , 0)
    if dic[a] == 0:
        dic[a] = 1
    else:
        dic[a] -= 1
        
print(sum(dic.values()))

Measured memory_bytes: 53580
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

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

    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int dp[100010];
    for(int i=0;i<n;i++)dp[i]=INF;
    for(int i=0;i<n;i++){
        int l=0,r=n;
        for(int j=0;j<30;j++){
            int mid=(l+r)/2;
            if(dp[mid]>=a[i])r=mid;
            else l=mid;
        }
        dp[r]=a[i];
    }
    for(int i=n-1;i>=0;i--){
        if(dp[i]!=INF){
            cout<<i+1<<endl;
            break;
        }
    }

}


Measured memory_bytes: 3532
#include<cstdio>
#include <algorithm>
using namespace std;
int main()
{
    int N,i,a=0,b=0;
    int schpil[105];
    scanf("%d", &N);
    for(i=0;i<N;i++)
        scanf("%d", &schpil[i]);
    sort(schpil, schpil + N);
	reverse(schpil, schpil + N);
	for(i=0;i<N;i=i+2)
		a+=schpil[i];
	for(i=1;i<N;i=i+2)
		b+=schpil[i];
	printf("%d", a-b);
	return 0;
}

Measured memory_bytes: 128
use std::io::stdin;
use std::io::Read;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed parsing")
}
fn main() {
    let n: usize = read();

    let mut vec: Vec<Vec<(usize, usize)>> = vec![];

    for _ in 0..n {
        let a: usize = read();
        let mut v = vec![];
        for _ in 0..a {
            let x: usize = read();
            let y: usize = read();
            v.push((x, y));
        }
        vec.push(v);
    }

    let mut ans = vec![0];

    'top: for bit in 0..1 << n {
        // let bit = (0..n).map(|k| (bit >> k) & 1 == 1).collect::<Vec<bool>>();
        let mut acc = 0;
        for i in 0..n {
            if (1 << i) & bit == 0 {
                acc += 1;
                for &(x, y) in &vec[i] {
                    let m = if y == 0 { false } else { true };
                    if (1 << (x - 1) & bit == 0) != m {
                        continue 'top;
                    }
                }
            }
        }
        ans.push(acc);
    }

    println!("{}", ans.iter().max().unwrap());
}

fn bit_search(n: usize) -> Vec<Vec<bool>> {
    let mut vec = Vec::with_capacity(2usize.pow(n as u32));
    for b in 0..1 << n {
        vec.push((0..n).map(|k| (b >> k) & 1 == 1).collect());
    }
    vec
}


Measured memory_bytes: 4352
-- Your code here!
-- Your code here!

import Data.List.Split
import Data.List

-- Your code here!
main :: IO()
main = do
  ls <- getLines
  mapM_ putStrLn $ getMosts ls
  
getMosts :: [String] -> [String]
getMosts l = map (\(a,b) -> a) $ filter (\(a,b) -> b == maxnum) cs 
  where 
   cs = counts l
   maxnum = myMax cs

myMax :: [(String,Int)] -> Int
myMax l = maximum $ map (\(a,b) -> b) l

counts :: [String] -> [(String,Int)]
counts l = map count' es
  where
    es = nub l
    count' e = (e, count e l)

count e l = length $ filter (e==) l

getLines =  do
  s <- getContents
  return $ lines s



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

ll n, a[400005], ans, cnt;

int main()
{
    cin >> n;
    for(int i = 0; i < 3 * n; i++){
        cin >> a[i];
    }
    sort(a, a + 3 * n);
    for(ll i = 0; i < 3 * n; i++){
        ll j = 3 * n - 1 - i;
        if(i % 2){
            ans += a[j];
            cnt++;
            if(cnt == n){
                cout << ans << endl;
                return 0;
            }
        }
    }


    return 0;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int Count(const vector<int64_t> &vec, int64_t val, size_t start = 0)
{
    auto count = 0;
    for (auto i = start; i < vec.size(); i += 1) {
        count += (vec[i] == val ? 1 : 0);
    }
    return count;
}

int64_t Comb(int64_t n, int64_t k)
{
    static map<pair<int64_t, int64_t>, int64_t> memo;
    if (memo.find({n, k}) != memo.end()) {
        return memo[{n, k}];
    }

    if (k == 0 || n == k) {
        return 1;
    } else if (k == 1) {
        return n;
    }

    auto res = Comb(n - 1, k) + Comb(n - 1, k - 1);
    memo.insert({{n, k}, res});

    return res;
}

int64_t CountWays(const vector<int64_t> &nums, int a, int b)
{
    int n = nums.size();
    auto total_small = Count(nums, nums[n - a]);
    auto wanted_small = Count(nums, nums[n - a], n - a);

    if (nums[n - a] != nums.back()) {
        return Comb(total_small, wanted_small);
    }

    int64_t res = 0;
    for (auto i = a; i <= min(b, total_small); i += 1) {
        res += Comb(total_small, i);
    }
    return res;
}

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

    vector<int64_t> nums(n);
    for (auto &num : nums) {
        cin >> num;
    }
    sort(nums.begin(), nums.end());

    double sum = 0;
    for (auto i = 0; i < a; i += 1) {
        sum += nums[n - 1 - i];
    }

    auto average = sum / a;
    auto ways = CountWays(nums, a, b);

    cout << fixed << setprecision(10) << average << "\n";
    cout << ways << "\n";

    return 0;
}


Measured memory_bytes: 384
/*
设pos(x)表示编号为x的兔子的坐标
假设某一轮跳跃是兔子aj，其选择的是x，有pos'(aj) = 2 * pos(x) - pos(aj)
E(pos'(aj)) = 2 * E(pos(x)) - E(pos(aj)) = 2 * (E(pos(aj - 1)) + E(pos(aj + 1))) / 2 - E(pos(aj)) = E(pos(aj - 1)) + E(pos(aj + 1)) - E(pos(aj))
注意到E(pos'(aj)) - E(pos(aj - 1)) = E(pos(aj + 1)) - E(pos(aj)), E(pos(aj + 1)) - E(pos'(aj)) = E(pos(aj)) - E(pos(aj - 1))
故该操作等价于交换了两个差分值。直接做置换快速幂即可 
*/

#include <cstdio>
#include <algorithm>

using namespace std;

template<typename Type>
void Get_Val(Type &Ret)
{
	Ret = 0;
	char ch;
	bool Neg(false);
	while (ch = getchar(), (ch > '9' || ch < '0') && ch != '-')
		;
	if (ch == '-')
	{
		Neg = true;
		while (ch = getchar(), ch > '9' || ch < '0')
			;
	}
	do
	{
		(Ret *= 10) += ch - '0';
	}
	while (ch = getchar(), ch >= '0' && ch <= '9');
	Ret = (Neg ? -Ret : Ret);
}

const int Max_N(100050);
const int Max_M(100050);
typedef long long int LL;

int N, X[Max_N], M, A[Max_M], Now[Max_N], P[Max_N];
LL K;
int Tot, All[Max_N];
bool done[Max_N];

void dfs(const int &u)
{
	if (done[u])
		return;
	done[u] = true;
	All[Tot++] = u;
	dfs(P[u]);
}

int main()
{
	Get_Val(N);
	for (int i = 1;i <= N;++i)
		Get_Val(X[i]), Now[i] = i;
	Get_Val(M), Get_Val(K);
	for (int i = 1;i <= M;++i)
		Get_Val(A[i]), swap(Now[A[i]], Now[A[i] + 1]);
	for (int i = 1;i <= N;++i)
		P[Now[i]] = i;
	for (int i = 1;i <= N;++i)
		if (!done[i])
		{
			Tot = 0, dfs(i);
			for (int i = 0;i <= Tot - 1;++i)
				P[All[i]] = All[(i + K) % Tot];
		}
	for (int i = 1;i <= N;++i)
		Now[P[i]] = i;
	LL cha(0LL);
	for (int i = 1;i <= N;++i)
		printf("%lld\n", cha += X[Now[i]] - X[Now[i] - 1]);
	return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#include <iomanip>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000001;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
	int x,y,z;
  cin>>x>>y>>z;
  cout<<z<<" "<<x<<" "<<y<<endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,c,d;
  cin>>a>>b>>c>>d;
  long long max1,max2;

     max1=a*c;

     max2=b*d;

long long f,f2;
  if(max1>max2)
    f=max1;
  else
    f=max2;

    max1=a*d;

    max2=b*c;
    if(max1>max2)
    f2=max1;
  else
    f2=max2;
    if(f>f2)cout<<f<<endl;
    else cout<<f2<<endl;


}


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

const int MAX_V = 100000;
const int MAX_E = 100000;
int par[MAX_V + 10];
int size[MAX_V + 10];
int rankrank[MAX_V + 10];
long V, E, A[MAX_E], B[MAX_E];
long long ans[MAX_E];


void init(int n){
    for (int i = 0; i < n; i++){
        par[i] = i;
        size[i] = 1;
        rankrank[i] = 0;
    }
}

int getRoot(int x){
    if (par[x] == x){
        return x;
    }else{
        return par[x] = getRoot(par[x]);
    }
}

void unite(int x, int y){
    x = getRoot(x);
    y = getRoot(y);
    if (x == y) return;
    if (rankrank[x] == rankrank[y]) {
        par[y] = x;
        size[x] = size[x] + size[y];
        rankrank[x]++;  
    }else if (rankrank[x] < rankrank[y]) {
        par[x] = y;
        size[y] = size[x] + size[y];
    }else if (rankrank[x] > rankrank[y]) {
        par[y] = x;
        size[x] = size[x] + size[y];
    }
}

int getSize(int x){
	return size[getRoot(x)];
}

bool isSame(int x, int y){
    return getRoot(x) == getRoot(y);
}

int main(){
    cin >> V >> E;
    for (long long i = 0; i < E; ++i){
    	cin >> A[i] >> B[i];
    }
    init(V);
    for (long long i = 0; i < E ; ++i) ans[i] = 0LL;

	int da;
    for (long long i = E-1; i >= 0; --i){
		if (i == E-1) ans[i] = V*(V-1)/2;
		else ans[i] = ans[i+1] - da;
		da = isSame(A[i], B[i]) ? 0 : getSize(A[i]) * getSize(B[i]);
    	unite(A[i], B[i]);
    }

    for (long long i = 0; i < E ; ++i){
    	cout << ans[i]<< endl;
    }
    return 0;
}

Measured memory_bytes: 4864
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto ab = readln.split.to!(int[]);
    auto a = ab[0];
    auto b = ab[1];

    if (a > 0) {
        writeln("Positive");
    } else if (a <= 0 && b >= 0) {
        writeln("Zero");
    } else {
        writeln((b-a+1)%2 == 0 ? "Positive" : "Negative");
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
using namespace std;

int main(){
  int N, Y;
  cin >> N >> Y;
  
  vector<int> left(N+1);
  vector<int> right;
  for (int i=0; i<N+1; i++)
    left[i] = Y - 10000*i;




  for (int i=0; i<N+1; i++) {
    for (int k=0; k<N-i+1; k++) {
      for (int l=0; l<N-i-k+1; l++) {
        if (Y == 10000*i + 5000*k + 1000*l && N == i+k+l) {
          cout << i << " " << k << " " << l << endl;
          return 0;
        }
      }
    }
  }

  cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int partition(int* A,int p,int r){
  int x=A[r];
  int i=p-1;
  for(int j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      swap(A[i],A[j]);
    }
  }
  swap(A[i+1],A[r]);
  return i+1;
}
signed main(){
  int n;
  cin>>n;
  int A[n];
  for(int i=0;i<n;i++) cin>>A[i];
  int k=partition(A,0,n-1);
  for(int i=0;i<n;i++){
    if(i) cout<<" ";
    if(i==k) cout<<"[";
    cout<<A[i];
    if(i==k) cout<<"]";
  }
  cout<<endl;
  return 0;
}

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

int main(){
    ll n, m;
    cin >> n >> m;
    pair<ll, string> p;
    pair<int, ll> check[n] ;
    for(ll i = 0; i < n; i++){
        check[i].first = 0;
        check[i].second = 0;
    }

    for(ll i = 0; i < m; i++){
        cin >> p.first >> p.second;
        if(check[p.first - 1].first == 0){
            if(p.second == "AC"){
                check[p.first - 1].first = 1;
            }else{
                check[p.first - 1].second++;
            }
        }
    }

    ll ans_ac = 0;
    ll ans_wa = 0;
    for(ll i = 0; i < n; i++){
        if(check[i].first == 1){
            ans_ac++;
            ans_wa += check[i].second;
        }
    }

    cout << ans_ac << " " << ans_wa << endl;
    
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <atcoder/all>

typedef long long ll;
typedef std::pair<ll, ll> P;

constexpr ll INF = 1e15;
constexpr ll mod = 1e9+7;

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

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main() {
    ll n, d;
    cin >> n >> d;
    vector<P> ps(n);
    rep(i, n) {
        cin >> ps[i].first >> ps[i].second;
    }
    auto graph = atcoder::two_sat(n);
    rep(i, n) {
        rep(j, n) {
            if (i == j) continue;
            //条件を満たさない場合にノードをつなぐ
            if (abs(ps[i].first - ps[j].first) < d) {
                graph.add_clause(i, true, j, true);
            }
            if (abs(ps[i].first - ps[j].second) < d) {
                graph.add_clause(i, true, j, false);
            }
            if (abs(ps[i].second - ps[j].first) < d) {
                graph.add_clause(i, false, j, true);
            }
            if (abs(ps[i].second - ps[j].second) < d) {
                graph.add_clause(i, false, j, false);
            }
        }
    }
    if (graph.satisfiable()) {
        cout << "Yes" << endl;
        auto ans = graph.answer();
        rep(i, n) {
            if (!ans[i]) {
                cout << ps[i].first << endl;
            }
            else {
                cout << ps[i].second << endl;
            }
        }
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3748
/*
氏名：鈴木丈人
学籍番号：190441067
概要：入力値の3乗の計算結果を出力するプログラム
*/
#include<stdio.h>
int main(void)
{
	int input;   //入力用変数
	scanf("%d", &input);   //入力
	input = input*input*input;   //入力値の3乗
	printf("%d\n", input);   //入力値の3乗の出力
	return 0;
}


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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while (true) {
    c -= b;
    a -= d;
    if (c <= 0) {
      cout << "Yes" << endl;
      break;
    }
    if (a <= 0) {
      cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3600
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //
void solve(){
	int n = read.to!int;
	
	for(int k = 0, m = 1; m <= n; k += 1, m *= 2){ 
		if(m == n){
			"No".writeln;
			return;
		}
	}
	"Yes".writeln;
	
	int[2][] ans;
	int[int] memo; // n + i をつなげた親が memo[i]
	for(int k = 0, m = 1; m <= n; k += 1, m *= 2){ 
		if(m > 1) ans ~= [m / 2, m];
		
		ans ~= [n + m + 1, n + m];
		memo[m] = m;
		
		for(int i = m + 1; i < m * 2 && i <= n; i ++){
			ans ~= [m, i];
			if(i - m / 2 < m) ans ~= [i - m / 2, n + i], memo[i] = i - m / 2;
			else ans ~= [memo[i - m], n + i], memo[i] = memo[i - m];
		} 
	}
	
	foreach(an; ans){
		writeln(an[0], " ", an[1]);
	}
	
	
}


Measured memory_bytes: 11644
using System;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
        
        var input = Console.ReadLine().Split();
        int n=int.Parse(input[0]);
        var list = new List<string>();
        
        for(int i=0;i<n;i++)
            list.Add(Console.ReadLine());
        
        list.Sort();
        Console.WriteLine(string.Join("",list));
        
    }
}


Measured memory_bytes: 11360
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

// ll me(ll x,ll n)
// {
//   ll res=1;

//   while(n)
//   {
//     if(n&1)
//       res=(res*x)%mod;

//       x=(x*x)%mod;

//       n/=2;
//   }

//   return res;
// }


int fac[N],inv[N];

ll me(int x, int n) 
{
  ll res = 1;
  while(n) 
  {
      if(n & 1) 
         res = (1LL * res * x) % mod;
      x = (1LL * x * x) % mod;
      n >>= 1;
  }
  return res;
}

int mi(int x, int m)
{
    return me(x, m-2);
}

void fact() 
{
  fac[0] = 1;

  rep(i, 1, N) 
     fac[i] = (1LL * fac[i - 1] * i) % mod;
   

  inv[N-1] = mi(fac[N-1], mod);

  for(int i = N - 1; i > 0; i--) 
    inv[i - 1] = (1LL * inv[i] * i) % mod;
   
}

int nCr(int n, int k) 
{
  if(k > n)
      return 0;

  int ans = (1LL * fac[n] * inv[k]) % mod;
  ans = (1LL * ans * inv[n - k]) % mod;

  return ans;
}



int main() 
{ 
    int n;
    scf(n); 

    ll ans=me(10,n);
    ll x=2*me(9,n);

    ans=(ans-x+mod)%mod;

    ll y=me(8,n);

    ans=(ans+y)%mod;

    lprin((ans+mod)%mod);

  
      
  
}


Measured memory_bytes: 3824
using System;
class Program
 {
   	static void Main(string[] args)
        {
    　　string a = Console.ReadLine(); //標準入力
		string[] aa = a.Split(' ');
		
		int[] bb = new int[aa.Length];
		for(int i = 0; i< bb.Length; i++){
      			bb[i]= int.Parse(aa[i]);
      	}
      
		int count = 0;
      int test = 0;
      
		for(int i = 0; i< bb.Length; i++){
          count++;
          if(bb[i]==0){
            test = count;
          }
      	}
  
     		Console.WriteLine("{0}", test);
        }
 
  	
	static void changev(int h){
    
  	}
 }

Measured memory_bytes: 27192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Maxn 4000007
const int INF = 1e9 + 5;
const int  N = 2e5 + 314;
void foo(){
    ll n, k;
    cin>>n>>k;
    if(min(n, k)==1){
        cout<<"1\n";
        return;
    }
    cout<<((n*k)+1)/2;
}
int main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)foo();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int a[10001],ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=2;i<n;i++){
		int b=a[i-1],c=a[i+1];
		if(a[i]>b&&a[i]<c) ans++;
		else if(a[i]<b&&a[i]>c) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <tuple>
#include <map>
#include <algorithm>
using Int = long long;
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
int main()
{
    int A, B, C; cin >> A >> B >> C;
    int m = A % B;
    int x = 2*A;
    while (x % B != m) {
        if (x % B == C) {
            cout << "YES" << endl;
            return 0;
        }
        x += A;
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()

{
	int S,h,m,s;
	scanf("%d",&S);
	  h = S / 3600;
	S = S % 3600;
	  m = S / 60;
	s = S % 60;

	printf("%d:%d:%d\n",h ,m, s);
	return 0;

}



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

int main(){
    long long int n;
    cin >> n;
    
    int count=0;
    int count9=0;
    while(1){
        if(n%10==9) count9++;
        count++;
        if(n/10<1) break;
        n/=10;
    }

    if(count==count9){
        cout << 9*count << endl;
    }
    else if(count==count9+1){
        if(n==9){
            cout << 8+count9*9 << endl;
        }
        else{
            cout << n+count9*9 << endl;
        }
    }
    else{
        cout << n-1+(count-1)*9 << endl;
    }
}

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

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

  long count = 0;
  long long r=0, g=0, b=0;
  for(int i=0; i<N; i++){
    for(int j=i; j<N; j++){
      char a = S[i];
      char b = S[j];
      if(a != b){
        if(j+j-i < S.size() && j+j-i >= 0){
          char c = S[j+j-i];
          if(a != c && b != c){
            count++;
          }
        }
      }
    }
    if(S[i] == 'R') r++;
    if(S[i] == 'G') g++;
    if(S[i] == 'B') b++;
  }

  cout << r*g*b-count << endl;
}

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

ll N, sum=0;
vector<ll> A, B, C;
signed main(){
    cin >> N;
    A.resize(N);
    B.resize(N);
    C.resize(N);
    for(int i=0;i<N;i++) cin >> A[i];
    for(int i=0;i<N;i++) cin >> B[i];
    for(int i=0;i<N;i++) cin >> C[i];
    sort(A.begin(), A.end());
    sort(C.begin(), C.end());
    for(int i=0;i<N;i++) sum += distance(A.begin(), lower_bound(A.begin(), A.end(), B[i]))*distance(upper_bound(C.begin(), C.end(), B[i]), C.end());
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 2560
def gcd(a, b):
    if a < b:
        a, b = b, a

    c = a % b
    if c == 0:
        return b
    else:
        return gcd(b, c)


if __name__ == "__main__":
    a, b = map(int, input().split())
    print(gcd(a, b))


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

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int inf = 1000000000;
const int mod = 1000000007;
const double eps = 1e-9;
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1};

int W, H;
int ans;
string field[100];

void dfs(int y, int x) {
	if (x < 0 || y < 0 || x == W || y == H) return;
	if (field[y][x] == '#') return;
	ans++;
	field[y][x] = '#';
	rep(i, 4) dfs(y + dy[i], x + dx[i]);
}

int main() {
	while (cin >> W >> H, W) {
		ans = 0;
		rep(i, H) cin >> field[i];
		rep(i, H) rep(j, W) {
			if (field[i][j] == '@') dfs(i, j);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

// 入力
int n, W;
int weight[110], value[110];

// DPテーブル
int dp[110][10010];

int main() {
	cin >> n >> W;
	for (int i = 0; i < n; ++i) cin >> value[i] >> weight[i];

	// DP初期条件: dp[0][w] = 0
	for (int w = 0; w <= W; ++w) dp[0][w] = 0;

	// DPループ
	for (int i = 0; i < n; ++i) {
		for (int w = 0; w <= W; ++w) {
			if (w >= weight[i]) dp[i + 1][w] = max(dp[i][w - weight[i]] + value[i], dp[i][w]);
			else dp[i + 1][w] = dp[i][w];
		}
	}

	cout << dp[n][W] << endl;
}


Measured memory_bytes: 7036
N = int(input())
A = list(map(int,input().split()))
mount = 0

for i in range(1,N-1,2):
  mount += 2*A[i]

B1 = sum(A) - mount
B = [0]*N
B[0] = B1

for i in range(1,N):
  B[i] = 2*A[i-1]-B[i-1]
  
print(*B)

Measured memory_bytes: 14032
from heapq import *
from collections import defaultdict

N, M = map(int, input().split())
arbeits = defaultdict(list)
for _ in range(N):
    a, b = map(int, input().split())
    arbeits[a].append(b)
heap = []
ans = 0
for i in range(1, M+1):
    for b in arbeits[i]:
        heappush(heap, -b)
    if heap:
        ans += - heappop(heap)
print(ans)

Measured memory_bytes: 27800
N, M = map(int,input().split())
li = []
for _ in range(M):
  p, S = input().split()
  li.append([int(p), S])

ac = [0] * N
wa = [0] * N
c1 = 0
c2 = 0

for i in range(M):
  j = li[i][0] - 1
  if li[i][1] == "WA":
    wa[j] += 1
  if ac[j] == 0 and li[i][1] == "AC":
    ac[j] = 1
    c1 += 1
    c2 += wa[j]

print(c1, c2)


Measured memory_bytes: 28584
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
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; }

int main() {
    string s;
    cin >> s;
    int ans = s.length();
    int sc = 0, tc = 0;
    FOR(i, s.length()) {
        if (s[i] == 'S') {
            if (i && s[i - 1] == 'T') {
                ans -= min(sc, tc) * 2;
                sc = max(sc - tc, 0), tc = 0;
            }
            sc++;
        }
        else if (s[i] == 'T')tc++;
    }
    cout << ans - min(sc, tc) * 2 << endl;
}

Measured memory_bytes: 640
n,m=map(int,input().split())
d=[0 for i in range(n)]
e=[[] for i in range(n)]
for i in range(n+m-1):
  a,b=map(lambda x:int(x)-1,input().split())
  e[a].append(b)
  d[b]+=1
  
for i in range(n):
  if d[i]==0:
    root=i

s=[root]
mer=[-1 for i in range(n)]
mer[root]=0
c=[0 for i in range(n)]
while s:
  ns=[]
  for i in s:
    for j in e[i]:
      c[j]+=1
      if c[j]==d[j]:
        mer[j]=i+1
        ns.append(j)
  s=ns
print("\n".join(map(str,mer)))


Measured memory_bytes: 104120
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
   ll n,m,x,ans=10000000000;
   cin>>n>>m>>x;
   
   vvll a(n,vector<ll>(m));
   vll c(n);
   rep(i,n){
       cin>>c.at(i);
       rep(j,m)cin>>a.at(i).at(j);
   }
   
   for (int tmp = 0; tmp < (1 << 12); tmp++) {
       bool ansx=true;
    vll active(m);
    rep(i,m)active.at(i)=0;
    bitset<12> s(tmp);  // 最大20個なので20ビットのビット列として扱う
 
    // ビット列の1のビットに対応する整数を選んだとみなして総和を求める
    int sum = 0;
    for (int i = 0; i < n; i++) {
      if (s.test(i)) {
        sum += c.at(i);
        rep(j,m)active.at(j)+=a.at(i).at(j);
      }
    }
    rep(i,m){
        if(active.at(i)<x)ansx=false;
    }
    if(ansx){
        if(ans>sum)ans=sum;
  }
   }
  if(ans==10000000000)cout<<-1<<endl;
  else cout<<ans<<endl;
   
}
   



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

int main()
{
  ll N, X, Y;
  cin >> N >> X >> Y;
  ll dif = Y - X;
  vector<ll> dist(N + 1, 0);
  for (ll i = 1; i < N; ++i)
  {
    for (ll j = i + 1; j < N + 1; ++j)
    {
      // cout << i << j << endl;
      if (i <= (X) && (Y) <= j)
      {
        dist.at(j - i - dif + 1) += 1;//baku
        // cout << j - i - dif + 1 << endl;
      }
      else if (i <= X)
      {
        ll m_dist = j - i;
        m_dist = min(m_dist, Y - j + 1 + X - i);
        dist.at(m_dist) += 1;
        // cout << m_dist << endl;
      }
      else if (Y <= j)
      {
        ll m_dist = j - i;
        m_dist = min(m_dist, i - X + 1 + j - Y);
        dist.at(m_dist) += 1;
        // cout << m_dist << endl;
      }
      else
      {
        ll m_dist = j - i;
        m_dist = min(m_dist, i - X + 1 + Y - j);
        dist.at(m_dist) += 1;
        // cout << m_dist << endl;
      }
    }
  }

  for (ll i = 1; i < N; ++i)
  {
    cout << dist.at(i) << endl;
  }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
#天気の入力
s = str(input())
#連続したRの数を数える
rain_days = 0
max_rain_days = 0
for char in s:
    if char == 'R':
        rain_days += 1
        max_rain_days = rain_days
    elif char == 'S':
        rain_days = 0

print(max_rain_days)


Measured memory_bytes: 8964
let puts st = print_string st; print_string "\n";;
let puti num = print_int num; print_string "\n";;
let getSL () = Str.split (Str.regexp " ") (read_line ());;
let getLI () = List.map int_of_string (getSL ());;
let geti () = int_of_string (read_line ());;
let rep n f =
    let rec repimpl i n = if i < n then (f i; repimpl (i+1) n) else () in repimpl 0 n;;
let rep_from from until f =
    let rec repimpl i n = if i < n then (f i; repimpl (i+1) n) else () in repimpl from until;;

module MC = Map.Make(struct
    type t = char
    let compare = compare
end);;

let solve () =
    let str = read_line () in
    let len = String.length str in
    let mp = ref MC.empty in
    rep len (fun i ->
        let ch = (String.get str i) in
        if not @@ MC.mem ch !mp then
            mp := MC.add ch 0 !mp;
        let cnt = MC.find ch !mp in
        mp := MC.add ch (cnt) !mp
    );
    puts @@ if MC.cardinal !mp = 2 then "Yes" else "No";;

solve ();;


Measured memory_bytes: 384
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = list(sr())
head = int(''.join(S[:2]))
tail = int(''.join(S[2:]))
bl_head = (1 <= head <= 12)
bl_tail = (1 <= tail <= 12)
if bl_head and bl_tail:
    answer = "AMBIGUOUS"
elif bl_head:
    answer = "MMYY"
elif bl_tail:
    answer = "YYMM"
else:
    answer = "NA"

print(answer)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define LL long long

using namespace std;
const int N=5e5+10,M=1e8+10;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
int to[N<<1],nt[N<<1],dg[N],hd[N],tot=1;
void adde(int x,int y){++tot,to[tot]=y,nt[tot]=hd[x],hd[x]=tot,++dg[y];}
int n,m,a[N],an[N];
int mi[N<<2];
void psup(int o){mi[o]=min(mi[o<<1],mi[o<<1|1]);}
void modif(int o,int l,int r,int lx,int x)
{
    if(l==r){mi[o]=x;return;}
    int mid=(l+r)>>1;
    if(lx<=mid) modif(o<<1,l,mid,lx,x);
    else modif(o<<1|1,mid+1,r,lx,x);
    psup(o);
}
int quer(int o,int l,int r,int ll,int rr)
{
    if(ll>rr) return n+1;
    if(ll<=l&&r<=rr) return mi[o];
    int an=n+1,mid=(l+r)>>1;
    if(ll<=mid) an=min(an,quer(o<<1,l,mid,ll,rr));
    if(rr>mid) an=min(an,quer(o<<1|1,mid+1,r,ll,rr));
    psup(o);
    return an;
}
void bui(int o,int l,int r)
{
    if(l==r){mi[o]=n+1;return;}
    int mid=(l+r)>>1;
    bui(o<<1,l,mid),bui(o<<1|1,mid+1,r);
    psup(o);
}
struct node
{
    int x;
    bool operator < (const node &bb) const {return a[x]>a[bb.x];}
};
priority_queue<node> q;

int main()
{
////
    n=rd(),m=rd();
    for(int i=1;i<=n;++i) a[rd()]=i;
    bui(1,1,n);
    for(int i=n;i;--i)
    {
	int n1=quer(1,1,n,max(a[i]-m+1,1),a[i]-1),n2=quer(1,1,n,a[i]+1,min(a[i]+m-1,n));
	if(n1<=n) adde(i,n1);
	if(n2<=n) adde(i,n2);
	modif(1,1,n,a[i],i);
    }
    for(int i=1;i<=n;++i)
	if(!dg[i]) q.push((node){i});
    for(int h=1;h<=n;++h)
    {
	int x=q.top().x;
	q.pop();
	an[a[x]]=h;
	for(int i=hd[x];i;i=nt[i])
	{
	    int y=to[i];
	    --dg[y];
	    if(!dg[y]) q.push((node){y});
	}
    }
    for(int i=1;i<=n;++i) printf("%d\n",an[i]);
    return 0;
}


Measured memory_bytes: 27008
#include<iostream>
#define MAX_V 100000
#define MAX_E 500000
#define INF 1e9
using namespace std;
struct edge {
	int from, to, cost;
};
edge es[MAX_E];
int d[MAX_V];
int V;
int E;



bool find_negative_loop(int s)
{
	d[s] = 0;
	int count = 0;
	while (true)
	{
		bool update = false;
		count++;
		for (int i = 0; i < MAX_E; i++)
		{

			if (d[es[i].from] != INF && d[es[i].to] > d[es[i].from] + es[i].cost)
			{
				if (count == V)
				{
					return true;
				}
				d[es[i].to] = d[es[i].from] + es[i].cost;
				update = true;
			}
		}
		if (update == false)
		{
			break;
		}


	}
	return false;
}

int main()
{

	int r;
	cin >> V >> E >> r;
	for (int i = 0; i < MAX_V; i++)
	{
		d[i] = INF;
	}
	for (int i = 0; i < E; i++)
	{
		cin >> es[i].from >> es[i].to >> es[i].cost;
	}
	if (find_negative_loop(r))
	{
		cout << "NEGATIVE CYCLE" << endl;
	}
	else
	{
		for (int i = 0; i < V; i++)
		{
			if (d[i] == INF)
			{
				cout << "INF" << endl;
			}
			else
			{
				cout << d[i] << endl;
			}
		}
	}

	return 0;
}



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

using namespace std;

#define REP(i,m) for(ll i=0; i<m; i++)
#define FOR(i,n,m) for(ll i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define SORT(v) sort(ALL(v))
#define pb push_back
#define ll long long int
#define P pair<ll, ll>
 
int main(){
    string s;
    cin >> s;
    string c[3] = {"Sunny", "Cloudy", "Rainy"};
    REP(i, 3) if(c[i]==s) cout << c[(i+1)%3] << endl;
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8

# https://atcoder.jp/contests/abc096/tasks/abc096_c
# 13:17-13:33


def main():
    H, W = map(int, input().split())
    s = [None] * (H+2)
    s[0] = [-1] * (W+2)
    s[-1] = [-1] * (W+2)
    for i in range(1, H+1):
        s[i] = [None] * (W+2)
        s[i][0] = -1
        s[i][-1] = -1
        for j, bw in enumerate(input()):
            s[i][j+1] = 1 if bw == "#" else -1

    if H == 1 and W == 1 and s[1][1] == 1:
        return "Yes"

    for i in range(1, H+1):
        for j in range(1, W+1):
            if s[i][j] == 1:
                if sum(s[i][j-1:j+2]) + s[i-1][j] + s[i+1][j] == -3:
                    return "No"
    
    return "Yes"


print(main())


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#define N 3
using namespace std;

bool cmp(int a,int b)
{
    return a>b;
}

int main()
{
    int arr[N];
    int k;
    for(int i=0;i<N;i++)
        cin>>arr[i];
    cin>>k;
    while(k--)
    {
        sort(arr,arr+N,cmp);
        arr[0]*=2;
    }
    int sum=0;
    for(int i=0;i<N;i++)
        sum+=arr[i];
    cout<<sum<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
#define pb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define vi vector
#define forn(i, l, r) for(int i = l; i <= r; i++)
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define f80 long double
#define LOCAL 0
#define endl '\n'
 
typedef long long int ll;
#define int long long int
 
const int mod = 1e9 + 7;
const int N = 1005;
const int inf = 1e17;

signed main(){
    IO;
    if(LOCAL){
        freopen("inp.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    }
    int x, y;
    cin >> x >> y;
    if(x % y){
        cout << x;
    }
    else{
        cout << -1;
    }
    return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)

int main() {
	int A;
	int V;
	int B;
	int W;
	int T;
	int way;
	int speed;
	int time;
	cin >> A >> V >> B >> W >> T;
	way=abs(B - A);
	speed = V - W;
	if (speed <= 0) {
		cout << "NO";
	}
	else {
		time = way / speed;
		if (way == speed * time) {
			time = time - 1;
		}
		if (time < T) {
			cout << "YES";
		}
		else {
			cout << "NO";
		}
	}
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
//B - Grid Compression
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
const int N=1e2+5;
int f[N],g[N];
char a[N][N];
int main(void){
    ll h,w;
    std::cin >> h >> w;
    rep(i,h)cin >> a[i];
    rep(i,h)rep(j,w)if(a[i][j]=='#')f[i]=g[j]=1;
    rep(i,h){if(f[i]){
        rep(j,w){if(g[j]){
            std::cout << a[i][j];
        }}
        std::cout << std::endl;
    }}
    
}


Measured memory_bytes: 256
#include<cstdio>
 
#define rep(i,n) for(int i=0;i<(n);i++)
 
using namespace std;
 
int main(){
    int n,T,H,L; scanf("%d%d%d%d",&n,&T,&H,&L);
    int t[100],h[100];
    rep(i,n) scanf("%d%d",t+i,h+i);
 
    int yen=0;
    while(1){
        rep(i,n){
            if(t[i]>0){
                t[i]--;
                T++;
                yen+=10;
                if(T>L){ printf("%d\n",i+1); return 0; }
            if(yen==90){
                int back=yen-90;
                if(T<back/10){ printf("%d\n",i+1); return 0; }
                T-=back/10;
                //t[i]+=back/10;
                yen=0;
            }
            }
            else if(h[i]>0){
                h[i]--;
                H++;
                yen+=100;
            //if(yen>=90){
                int back=yen-90;
                if(T<back/10){ printf("%d\n",i+1); return 0; }
                T-=back/10;
                t[i]+=back/10;
                yen=0;
            //}
            }
            else{
                printf("%d\n",i+1);
                return 0;
            }
        }
    }
}

Measured memory_bytes: 1032
<?php
  fscanf(STDIN,"%d",$n);
  $p = preg_split("/ /",trim(fgets(STDIN)));
  $count = 0;
  for($i=1;$i<$n-1;$i++){
    $score = ($p[$i-1]-$p[$i])*($p[$i+1]-$p[$i]);
    if($score<0){
      $count++;
    }
  }
  echo($count);

Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <regex>
using namespace std;
int rui[110000];
int main(void){
    int n,q,tmp = 0;
    cin >> n >> q;
    string s;
    cin >> s;
    for(int i = 0;i < s.length()-1;i++){
        if(s[i] == 'A' && s[i+1] == 'C') rui[i+1] = rui[i]+1;
        else rui[i+1] = rui[i];
    }
    
    int l[n],r[n];
    for(int i = 0;i < q;i++){
        int cnt = 0;
        cin >> l[i] >> r[i];
        cnt = (rui[r[i]-1]-rui[l[i]-1]);
        cout << cnt << endl;
    }
    
    return 0;
}

Measured memory_bytes: 2176
function main(input){
    let lines = input.split("\n");
    let str = lines.shift();
    let length = parseInt(lines.shift());
    for(let i=0;i<length;i++){
        let args = lines[i].split(" ");
        let order = args[0];
        let nums = allint([args[1],args[2]]);

        if(order==="print"){
            console.log(str.slice(nums[0],nums[1]+1));
        }else if(order==="replace"){
            let rep = args[3];
            str = str.slice(0,nums[0])+rep+str.slice(nums[1]+1);
            
        }else if(order==="reverse"){
            let piece = str.slice(nums[0],nums[1]+1);
            let rev = "";
            for(let j=0;j<piece.length;j++){
                rev+= piece[piece.length-j-1];
            }
            str = str.slice(0,nums[0])+rev+str.slice(nums[1]+1);
            
        }
        
        
        
    }
    
}

function allint(arr){
    return arr.map(x=>parseInt(x));
}

main(require("fs").readFileSync("/dev/stdin","utf-8"));


Measured memory_bytes: 19216
n=int(input())
s=input()
l=[]
for i in s:
  l.append(i)

org_l=[]
count=0
for i in l:
  org_l.append(i)
  count+=1
  if count==n//2:
    break

new_l=[]
for i in l[n//2:]:
  new_l.append(i)

if n<=1:
  print('No')
elif org_l == new_l:
  print('Yes')
else:
  print('No')
  
  

Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

ll Pow(ll a, ll b, ll c){
    ll ans = 1;
    a %= c;
    while (b){
        if (b & 1) ans = (ans * a) % c;
        a = (a * a) % c;
        b >>= 1;
    }
    return (ans % c);
}

bool cmp(const int &a, const int &b){
    return a < b;
}

ll gcd(ll x, ll y){
    return x % y == 0 ? y : gcd(y, x % y);
}

ll lcm(ll x, ll y){
    return x / gcd(x, y) * y;
}

int main(){
    int n, x;
    scanf("%d%d", &n, &x);
    int l[105];
    memset(l, 0, sizeof(l));
    for (int i = 1; i <= n; i++) scanf("%d", &l[i]);
    int d[105];
    memset(d, 0, sizeof(d));
    for (int i = 2; i <= n + 1; i++)
        d[i] = d[i - 1] + l[i - 1];
    int cnt = 0;
    for (int i = 1; i <= n + 1; i++)
        if (d[i] <= x) cnt++;
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,m;cin>>n>>m;
    ll a[m],b[m],c[m];for(ll i=0;i<m;i++)cin>>a[i]>>b[i]>>c[i];
    for(ll i=0;i<m;i++)a[i]-=1,b[i]-=1,c[i]*=-1;
    vector<ll> dist(n,LLONG_MAX);
    dist[0]=0;
    for(ll t=0;t<n-1;t++){
        for(ll i=0;i<m;i++){
            if(dist[a[i]]==LLONG_MAX)continue;
            if(dist[b[i]]>dist[a[i]]+c[i])dist[b[i]]=dist[a[i]]+c[i];
        }
    }
    vector<bool> neg(n,0);
    for(ll t=0;t<n;t++){
        for(ll i=0;i<m;i++){
            if(dist[a[i]]==LLONG_MAX)continue;
            if(dist[b[i]]>dist[a[i]]+c[i])dist[b[i]]=dist[a[i]]+c[i],neg[b[i]]=1;
            if(neg[a[i]])neg[b[i]]=1;
        }
    }
    if(neg[n-1])cout<<"inf";
    else cout<<-1*dist[n-1];
}


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

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  long long res = 1;
  for (int i = 0; i < n; i++) {
    long long t; cin >> t;
    res = lcm(res, t);
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF (int)1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

template <typename T> using Vec = vector<T>; // c++11
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

int main(void) {
    while (1) {
        int n;
        int w;
        cin >> n >> w;
        if (n == 0 && w == 0) {
            break;
        }

        int sep = (100 / w) + 1;
        //std::cerr << "SEP = " << sep << endl;
        Vec<int> hist(sep, 0);

        int n_max = 0;
        int number;
        for (int i = 0; i < n; i++) {
            cin >> number;
            n_max = max(n_max, number);
            hist[number / w]++;
        }

        int h_max = 0;
        for (int i = 0; i < (int)hist.size(); i++) {
            h_max = max(h_max, hist[i]);
        }

        int w_num = n_max / w;
        //std::cerr << w_num << endl;

        int mom = 0;
        int chi = w_num * h_max;

        for (int i = 0; i < (int)hist.size(); i++) {
            mom += (w_num - i) * hist[i];
        }
        cout << fixed << setprecision(6) << (double)mom / (double)chi + 0.01 << endl;
    }
    return 0;
}

Measured memory_bytes: 3140
#include <iostream>
using namespace std;
int main(){
    int now=0,temp;
    string a,b;
    cin>>a>>b;
    while(now<a.size()){
        temp=(int)a.find(b,now);
        if(temp<0)return 0;
        now=temp+1;
        cout<<temp<<endl;
    }
}


Measured memory_bytes: 3200