akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,m,n) for(int i=m; i<n; i++)
typedef long long ll;
const int MAX = 510000;
const int MOD = 1000000007;

int main() {
    int n; cin>>n;
    int k; cin>>k;
    ll ans=0;
    ll sum=0,sum2=0;
    ll j=k,l=n-k;
    rep(i,0,k){
        sum+=i;
        sum2+=(n-i);
    }
    rep(i,k,n+2){
        ans+=(sum2-sum+1);
        sum+=j;
        sum2+=l;
            j++;
            l--;
        
    }
    ans%=MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
from functools import reduce

n = int(input()) 
alist = list(map(int, input().split()))

def isMinus(x):
  if x<0:
    return 1
  else:
    return 0

#signature count
s = sum([isMinus(i) for i in alist]) % 2
#    print(alist)\\

if s == 0:
  ans = sum(map(abs, alist))
else:
  ans = sum(map(abs, alist)) - min(list(map(abs, alist)))*2

print("{}".format(ans))

Measured memory_bytes: 14908
H,W=map(int,input().split())
CH,CW=map(lambda x:int(x)-1,input().split())
DH,DW=map(lambda x:int(x)-1,input().split())
maze=[input() for i in range(H)]
di=[[-1 for _ in range(W)] for _ in range(H)]
adj=[]
for i in range(-1,2):
  for j in range(-1,2):
    if i==0 or j==0:
      adj.append((i,j))
warp=[]
for i in range(-2,3):
  for j in range(-2,3):
    if (i,j) not  in adj:
      warp.append((i,j))
adj.remove((0,0))
from collections import deque
dq=deque([(CH,CW,0)])
while dq:
  h,w,d=dq.popleft()
  if 0<=h<H and 0<=w<W and di[h][w]<0 and maze[h][w]=='.':
    di[h][w]=d
  else:
    continue
  for i in range(len(adj)):
    dq.appendleft((h+adj[i][0],w+adj[i][1],d))
  for i in range(len(warp)):
    dq.append((h+warp[i][0],w+warp[i][1],d+1))
print(di[DH][DW])

Measured memory_bytes: 263584
abhm=tuple(map(float, input().split()))
a=abhm[0]
b=abhm[1]
h=abhm[2]
m=abhm[3]

import math as mt

pi=mt.pi

c=pi*(h+m/60)/6
d=pi*m/30

print(mt.sqrt((a*mt.cos(c)-b*mt.cos(d))**2+(a*mt.sin(c)-b*mt.sin(d))**2))


Measured memory_bytes: 9448
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


int n, m;
bool graph[50][50] = {};
bool visited[50] = {};

void dfs(int v) {
	visited[v] = true;
	REP(i, n) {
		if (graph[v][i] == true && visited[i] == false) {
			dfs(i);
		}
	}
}




int main() {


	cin >> n >> m;

	int A[50] = {}, B[50] = {};


	REP(i, m) {
		cin >> A[i] >> B[i];
		A[i]--;
		B[i]--;
		graph[A[i]][B[i]] = true;
		graph[B[i]][A[i]] = true;
	}

	int ans = 0;

	REP(i, m) {
		graph[A[i]][B[i]] = false;
		graph[B[i]][A[i]] = false;

		REP(j, n) {
			visited[j] = false;
		}

		dfs(0);

		bool bridge = false;
		REP(j, n) {
			if (visited[j] == false) {
				bridge = true;
			}
		}
		if (bridge == true) {
			ans++;
		}

		graph[A[i]][B[i]] = true;
		graph[B[i]][A[i]] = true;

	}

	ANS(ans);


	return 0;
}



Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let mut s = sc.chars();
    s.sort();
    put!(if s == vec!['a', 'b', 'c'] { "Yes" } else { "No" });
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
package main

import "fmt"

func diff(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	for i := range as {
		fmt.Scan(&as[i])
	}

	sum := 0
	for _, a := range as {
		sum += a
	}

	min := diff(as[0], sum-as[0])
	su := 0
	for i := 0; i < len(as)-1; i++ {
		su += as[i]
		if v := diff(su, sum-su); v < min {
			min = v
		}
	}

	fmt.Println(min)
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  vector<ll>arr;
  vector<ll>cost;
  ll n,g,i,j,k;
  cin>>n>>k;
  for(i=0;i<n;i++)
  {
    cost.push_back(-1);
  }
  cost[0]=0;
  for(i=0;i<n;i++)
  {
    cin>>g;
    arr.push_back(g);
  }
  for(i=0;i<n-1;i++)
  {
    for(j=i+1;j<i+k+1;j++)
    {
        if(cost[j]!=-1)
        {cost[j]=min(cost[j],abs(arr[j]-arr[i])+cost[i]);}
        else if(cost[j]==-1)
        {
          cost[j]=abs(arr[j]-arr[i])+cost[i];
        }
        if(j==n-1)
        {
          break;
        }
    }
  }
  cout<<cost[n-1]<<endl;
}

Measured memory_bytes: 5564
a,b = map(int,input().split())
c = 0 
d = 0
if a == 2:
    c = 1
elif a == 4 or a == 6 or a == 9 or a == 11:
    c = 2
else:
    c = 3
if b == 2:
    d = 1
elif b == 4 or b == 6 or b == 9 or b == 11:
    d = 2
else:
    d = 3
if c == d:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, d, x, y;
  in3(n, d, x);
  vector<ll> a(n);
  rep(i, n)
    in(a[i]);
  x = x + n;
  rep(i, n){
    y = 1;
    while(y + a[i] <= d){
      y = y + a[i];
      x++;
    }
  }
  out(x);
  memi;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    REP(i, n+1) REP(j, n+1)
    {
        int num = n - i*r - j*g;
        if(num >= 0 && num % b == 0)
        {
            int bb = num / b;
            if(bb >= 0)
            {
                ans++;
            }
        }
        
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#define pi 3.14159265358979323846
using namespace std;

int main()
{
	int H,W,i,j;
	while(true)
	{
		cin>>H>>W;
		if(H!=0||W!=0){
			
			for(i=1;i<=H;i++)
			{
				if(i%2==1)
				{
					for(j=1;j<=W;j++)
						{
							if(j%2==1)
								cout<<'#';
							else
								cout<<'.';
						}
					cout<<endl;
				} 
				else
				{
					for(j=1;j<=W;j++)
					{
						if(j%2==1)
							cout<<'.';
						else
							cout<<'#';
					}
					cout<<endl;
				}
				
			}
		
		}
		else
			return 0; 
		cout<<endl;
	}
}
 


Measured memory_bytes: 3096
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
#define ll long long 
int n,m;
int love[400][400];
bool u[400];
int main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>love[i][j];
			love[i][j]--;
		}
	}
	int ans=1e9;
	for(int i=0;i<m;i++){
		int a[305];
		for(int j=0;j<m;j++){
			a[j]=0;
		}
		for(int j=0;j<n;j++){
			int x=-1;
			for(int k=0;k<m;k++){
				if(!u[love[j][k]]){
					x=love[j][k];
					break;
				}
			}
			a[x]++;
		}
		pair<int,int> l(-1,-1);
		for(int i=0;i<m;i++){
			l=max(l,make_pair(a[i],i));
		}
		ans=min(ans,l.first);
		u[l.second]=1;
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 768
import sys
import collections

n = int(input())
s=[]
for i in range(n):
  s.append(input())


c = collections.Counter(s)
#N = len(count)


ans_list = list(c.values())
ans=0
for i in range(len(ans_list)):
  if ans_list[i]>=2:
    ans+=1
  else:
    ans+=1
    
print(ans)


Measured memory_bytes: 38920
from sys import stdin

def main():
    input = stdin.buffer.readline

    N = int(input())
    L, R = [0] * N, [0] * N
    for i in range(N):
        L[i], R[i] = map(int, input().split())

    max_l = max(L)
    min_r = min(R)

    ab = [(max(0, r - max_l + 1), -max(0, min_r - l + 1)) for l, r in zip(L, R)]
    ab.sort()

    mi = float("inf")
    ma = max(r - l + 1 for l, r in zip(L, R)) + max(0, min_r - max_l + 1)
    for i in range(N - 1):
        mi = min(mi, -ab[i][1])
        ma = max(ma, mi + ab[i + 1][0])

    print(ma)

main()


Measured memory_bytes: 24960
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
using P = pair<int, int>;
using Pip = pair<int, P>;

struct edge {
  int to, d, e;
  edge(int to, int d, int e): to(to), d(d), e(e) {}
};

int N, M, L;
vector<edge> G[101];

int dij() {
  bool used[101][101];
  fill_n(*used, 101*101, false);
  priority_queue<Pip, vector<Pip>, greater<Pip> > Q;
  Q.push(Pip(0, P(0, L)));
  while ( !Q.empty() ) {
    Pip p = Q.top(); Q.pop();
    int cost = p.first, v = p.second.first, l = p.second.second;

    if ( v == N-1 ) return cost;

    if ( used[v][l] ) continue;
    used[v][l] = true;

    for ( edge e: G[v] ) {
      if ( e.d <= l ) {
	Q.push(Pip(cost, P(e.to, l-e.d)));
      }
      Q.push(Pip(cost+e.e, P(e.to, l)));
    }
  }

  assert(0);
}

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

  while ( cin >> N >> M >> L, N ) {
    for ( int i = 0; i < 101; i++ ) G[i].clear();
    for ( int i = 0; i < M; i++ ) {
      int a, b, d, e;
      cin >> a >> b >> d >> e;
      a--; b--;
      G[a].push_back(edge(b, d, e));
      G[b].push_back(edge(a, d, e));
    }
    
    cout << dij() << endl;
  }
  
  return 0;
}



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

signed main() {
	int m, d;
	cin >> m >> d;
	int ans = 0;
	for (int i = 1; i <= d; ++i) {
		for (int j = 1; j <= m; ++j) {
			if (i % 10 == 1)continue;
			if (i / 10 == 1)continue;
			int dd = i % 10;
			dd *= i / 10;
			if (dd == j) {
				++ans;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
use proconio::input;

#[proconio::fastout]
fn main() {
    input! {
        mut a: i64,
        b: i64,
        mut c: i64,
        d: i64,
    }
    loop {
        c -= b;
        if c <= 0 {
            println!("Yes");
            return;
        }
        a -= d;
        if a <= 0 {
            println!("No");
            return;
        }
    }
}


Measured memory_bytes: 2140
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL D, G;
	in >> D >> G;
	std::vector<LL>p(D), c(D);
	rep(i, D) in >> p[i] >> c[i];

	LL ans = 114514;
	rep(bit, (1LL << D))
	{
		LL score = 0, res = 0;
		rep(i, D)
		{
			if (bit&(1LL << i))
			{
				score += 100 * (i + 1)*p[i] + c[i];
				res += p[i];
			}
		}

		LL want = G - score;
		if (want > 0)
		{
			for (int i = D - 1; i >= 0; --i)
			{
				if (!(bit&(1LL << i)))
				{
					LL point = 100 * (i + 1);
					LL cnt = want / point + (want%point == 0 ? 0 : 1);
					cnt = std::min(cnt, p[i] - 1);
					want -= point * cnt;
					res += cnt;
					if (want <= 0) break;
				}
			}
		}

		if (want <= 0) ans = std::min(ans, res);
	}

	out << ans << std::endl;
}


Measured memory_bytes: 256
//neerav code
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef long double ld; 

int main()
{
ll a,count=0,p=0;
cin>>a;
vector<pair<string ,ll> >v1(a);
for(ll i=0;i<a;i++)
{
	cin>>v1[i].first;
	cin>>v1[i].second;
}
string s;
cin>>s;
for(ll i=0;i<a;i++)
{
	if(p==1)
    count=count+v1[i].second;	
	if(v1[i].first==s)
	{
		p=1;
	}
		
}
cout<<count;

	return 0;
}

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

int main() {
    int N,D;
    cin >> N >> D;
    vector<vector<int>> X(N,vector<int>(D));
    for ( int i = 0; i < N; ++i){
        for ( int j = 0; j < D; ++j){
            cin >> X[i][j];
        }
    }
    
    int count = 0;
    for ( int i = 0; i < N-1; ++i){
        for ( int j = i+1; j < N; ++j){
            int dis = 0;
            for ( int k = 0; k < D; ++k){
                dis = dis + ( X[i][k] - X[j][k] ) *  ( X[i][k] - X[j][k] );
            }
            bool flg = false;
            for ( int x = 1; x < 1000; ++x){
                if ( dis == x * x ) flg = true;
            }
            if ( flg ) ++ count;
        }
    }
    
    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void){
    ll N;
    cin >> N;
    vector<string> j(N);
    int ac=0;
    int wa=0;
    int tle=0;
    int re=0;
    for(int i=0;i<N;i++){
        cin >> j.at(i);
        if(j.at(i)=="AC"){
            ac++;
        }else if(j.at(i)=="WA"){
            wa++;
        }else if(j.at(i)=="TLE"){
            tle++;
        }else{
            re++;
        }
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}

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

using ll = long long;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  
  vector<ll> x(n);
  for(int i = 0; i < n; i++) cin >> x.at(i);
  
  ll fatigue = 0;
  for(int i = 1; i < n; i++) fatigue += min((x.at(i) - x.at(i - 1)) * a, b);
  
  cout << fatigue << endl;
}

Measured memory_bytes: 1024
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, ans = 0;
    string s;
    cin >> n >> s;
    rep(i, n - 1) {
        if(s.substr(i, 3) == "ABC") { ans++; }
    }
    COUT(ans);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n;
    scanf("%d", &n);

    int A[9];
    int next_A[9];
    int prev_A[9];
    int i;
    for (i = 0; i < n; i++) {
        scanf("%d", &A[i]);
        next_A[i] = A[i];
        prev_A[i] = A[i];
    }

    int flag = 0;
    int j, tmp, k, mid;
    if (n == 1) {
        printf("1\n");
    }
    else {
        /* search for previous permutation */
        for (i = n - 2; i >= 0; i--) {
            if (prev_A[i] > prev_A[i + 1]) {
                flag = 1;
                break;
            }
        }
        if (flag) {
            for (j = n - 1; j > i; j--) {
                if (prev_A[j] < prev_A[i]) {
                    tmp = prev_A[j];
                    prev_A[j] = prev_A[i];
                    prev_A[i] = tmp;
                    break;
                }
            }
            mid = (n - i - 1) / 2;
            for (k = 1; k <= mid; k++) {
                tmp = prev_A[i + k];
                prev_A[i + k] = prev_A[n - k];
                prev_A[n - k] = tmp;
            }
            /* print the previous permutation */
            printf("%d", prev_A[0]);
            for (i = 1; i < n; i++) printf(" %d", prev_A[i]);
            putchar('\n');
        }
        
        /* print the given sequence */
        printf("%d", A[0]);
        for (i = 1; i < n; i++) printf(" %d", A[i]);
        putchar('\n');

        /* search for next permutation */
        flag = 0;
        for (i = n - 2; i >= 0; i--) {
            if (next_A[i] < next_A[i + 1]) {
                flag = 1;
                break;
            }
        }
        if (flag) {
            for (j = n - 1; j > i; j--) {
                if (next_A[j] > next_A[i]) {
                    tmp = next_A[j];
                    next_A[j] = next_A[i];
                    next_A[i] = tmp;
                    break;
                }
            }
            mid = (n - i - 1) / 2;
            for (k = 1; k <= mid; k++) {
                tmp = next_A[i + k];
                next_A[i + k] = next_A[n - k];
                next_A[n - k] = tmp;
            }
            /* print the next permutation */
            printf("%d", next_A[0]);
            for (i = 1; i < n; i++) printf(" %d", next_A[i]);
            putchar('\n');
        }
    }

    return 0;
}


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

int main() {
  long a,b; int k;
  cin >> a >> b >> k;
  for(int i = 0;i < k;i++){
    if(i%2 == 0){
      a /= 2;
      b += a;
    }
    else{
      b /= 2;
      a += b;
    }
  }
  cout << a << " " << b << endl;
}


Measured memory_bytes: 256
using System;
class Program
{
    static long max(long x,long y)
    {
        if (x > y) return x;
        return y;
    }
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        long i, u, v, p, q;
        string[] inputline = Console.ReadLine().Split(' ');
        u = int.Parse(inputline[0]);
        v = int.Parse(inputline[1]);
        for (i = 1; i < n; i++)
        {
            inputline = Console.ReadLine().Split(' ');
            p = (u - 1) / int.Parse(inputline[0]) + 1;
            q = (v - 1) / int.Parse(inputline[1]) + 1;
            u = max(p, q) * int.Parse(inputline[0]);
            v = max(p, q) * int.Parse(inputline[1]);
        }
        Console.WriteLine(u + v);
    }
}


Measured memory_bytes: 2904
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FUNCTION__ << endl;
#define int long long

const long long INF = __LONG_LONG_MAX__ / 2;

using namespace std;

signed main(){
    string A, B, C;
    cin >> A >> B >> C;
    cout <<
      (A.back() == B.front() && B.back() == C.front() ? "YES" : "NO");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int arr[n+1];
	for(int i=0;i<n;++i)
	cin>>arr[i+1];
	int dp[n+1];
	memset(dp,0,sizeof(dp));
	dp[n]=0;
	dp[n-1]=abs(arr[n]-arr[n-1]);
	for(int i=n-2;i>0;--i)
	{
		int mini=INT_MAX;
		for(int j=i+1,x=0;j<=n&&x<k;++j,++x)
		{
			mini=min(abs(arr[i]-arr[j])+dp[j],mini);
		}
		dp[i]=mini;
	}
	cout<<dp[1];
}
	

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

            if(H == 0 && W ==0) break;
            else{
                for(int i=0; i<H; i++){
                    for(int j=0; j<W; j++){
                        System.out.print("#");
                    }
                    System.out.printf("\n");
                }
                System.out.printf("\n");
            }
        }
    }
}


Measured memory_bytes: 38664
use std::f64::consts::PI;
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let r:f64 = read();
    println!("{} {}", r*r*PI, r*2.0*PI);
}


Measured memory_bytes: 5072
using System;

namespace abc060A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            string A = str[0].Substring(str[0].Length - 1, 1);
            string B = str[1].Substring(0, 1);
            string C = str[1].Substring(str[1].Length - 1, 1);
            string D = str[2].Substring(0, 1);
            if (A == B && C == D)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>

using namespace std;

int p, q, a, n, answer;

void search( int pp, int qq, int start, int count )
{
	if(count == n) return;
	for(int i=start; i <= a; ++i) {
		int ppp = pp * i + qq;
		int qqq = qq * i;
		if(qqq > a) return;
		if(ppp / qqq > p / q) continue;
		if(!(qqq % q) && !(ppp % p) && qqq / q == ppp / p) ++answer;
		else					 search( ppp, qqq, i, count + 1);
	}
	return;
}

int gcd( int a, int b )
{
	int c;
	while(b) {
		c = a % b;
		a = b;
		b = c;
	}
	return a;
}

int main( void )
{
	while(cin >> p >> q >> a >> n,
		p | q | a | n) {
			int gg = gcd(p, q);
			p /= gg;
			q /= gg;
			answer = 0;
			search(0, 1, 1, 0);
			cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 864
#include<cstdio>

int main(){
	int dice[6];
	int a,b,x,y,q,t = 0;
	int ans[6][6] = {{0,3,5,2,4,0},{4,0,1,6,0,3},{2,6,0,0,1,5},{5,1,0,0,6,2},{3,0,6,1,0,4},{0,4,2,5,3,0}};
	
	scanf("%d %d %d %d %d %d", &dice[0], &dice[1], &dice[2], &dice[3], &dice[4], &dice[5]);
	scanf("%d", &q);
	
	for(int i = 0; i < q; i++){
		scanf("%d %d", &a, &b);
		while(a - dice[t]){
			t++;
		}
		a = t;
		t = 0;
		while(b - dice[t]){
			t++;
		}
		b = t;
		t = 0;
		
		printf("%d\n", dice[ans[a][b] - 1]);
	}

}

Measured memory_bytes: 1024
import math

n,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

mod = 10 ** 9 + 7
ans = 1

a.sort(reverse = True)
b.sort(reverse = True)

counta = 0
countb = 0
count = 0

for i in range(n*m,0,-1):
    if a and b:
        if a[0] == i and b[0] == i:
            a_tmp = a.pop(0)
            b_tmp = b.pop(0)
            if a:
                if a[0] == a_tmp:
                    print(0)
                    exit()
            if b:
                if b[0] == b_tmp:
                    print(0)
                    exit()
            counta += 1
            countb += 1
        elif a[0] == i:
            a_tmp = a.pop(0)
            if a:
                if a[0] == a_tmp:
                    print(0)
                    exit()
            counta += 1
            ans *= countb
            ans %= mod
        elif b[0] == i:
            b_tmp = b.pop(0)
            if b:
                if b[0] == b_tmp:
                    print(0)
                    exit()
            countb += 1
            ans *= counta
            ans %= mod
        else:
            ans *= (counta * countb - count)
            ans %= mod
    elif a:
        if a[0] == i:
            a_tmp = a.pop(0)
            if a:
                if a[0] == a_tmp:
                    print(0)
                    exit()
            counta += 1
            ans *= countb
            ans %= mod
        else:
            ans *= (counta * countb - count)
            ans %= mod
    elif b:
        if b[0] == i:
            b_tmp = b.pop(0)
            if b:
                if b[0] == b_tmp:
                    print(0)
                    exit()
            countb += 1
            ans *= counta
            ans %= mod
        else:
            ans *= (counta * countb - count)
            ans %= mod
    count += 1
    if not a and not b:
        idx = i
        break

for i in range(1,idx):
    ans *= i
    ans %= mod

print(ans)


Measured memory_bytes: 42092
S = input()
T = input()

memo_S = {}
memo_T = {}
answer = 'Yes'
for i in range(len(S)):
    if S[i] not in memo_S:
        memo_S[S[i]] = T[i]
    elif memo_S[S[i]] != T[i]:
        answer = 'No'
        break
    if T[i] not in memo_T:
        memo_T[T[i]] = S[i]
    elif memo_T[T[i]] != S[i]:
        answer = 'No'
        break
print(answer)

Measured memory_bytes: 3632
#include<iostream>

using namespace std;

int main(){
 int n,k;
  int a[1234567];
  cin>>n>>k;
  int sum=0;
  for(int i=0;i<n;i++){
  	cin>>a[i];
    if(a[i]>=k) sum++;
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(a) for(int k=head[a];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=1e6+5,M=5e3+5,INF=1e9,mod=998244353;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
ll ans,D,pw[55];
ll gao(int l,int r,ll dt){
	if(dt&&l>=r)return 0;
	if(l==r)return 10-(!l);
	if(l>r)return 1;
	int tp=(10-dt%10)%10;
	dt-=tp*(pw[r-l]-1);
	return (10-(!l)-tp)*gao(l+1,r-1,abs(dt)/10);
}
int main(){
	pw[0]=1;rep(i,1,18)pw[i]=pw[i-1]*10;
	read(D);ll res=0;
	rep(i,0,17)
		res+=gao(0,i,D);
	if(!D)res++;cout<<res<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main(){
    string w;
    string t;
    cin >> w;
    int i;
    for(i=0; i<w.size(); i++){
        if('A'<=w[i]&&w[i]<='Z')w[i]+='a'-'A';
    }
    int o=0;
    cin>>t;
    while(t!="END_OF_TEXT"){
        for(i=0; i<t.size(); i++){
            if('A'<=t[i]&&t[i]<='Z')t[i]+='a'-'A';
        }
        if(w==t)o++;
        cin>>t;
    }
    cout<<o<<endl;
}



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

int main() {
    int N;
    cin >> N;
    int ans=1;
    int check=0;
    for(int i=1;i<=N;i++){
        int W=i;
        int count=0;
        while(W>1){
            if(W%2==0){
                W/=2;
                count++;
            }
            else break;
        }
            if(check<count){
                check=count;
                ans=i;
            }
        }
    cout << ans <<endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	N := ReadInt()
	A := ReadInts(N)
	minusCount := 0
	for _, ai := range A {
		if ai < 0 {
			minusCount++
		}
	}
	sum := 0
	if minusCount%2 == 1 {
		sort.Slice(A, func(i, j int) bool {
			return Abs(A[i]) < Abs(A[j])
		})
		sum += -Abs(A[0])
		A = A[1:]
	}
	for _, ai := range A {
		sum += Abs(ai)
	}
	fmt.Println(sum)
}

func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 4376
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vi a,b;
vp c;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		if(x>=0) a.push_back(x);
		else b.push_back(x);
	}
	int A=a.size(),B=b.size(),t;
	if(B==n){
		sort(b.rbegin(),b.rend());
		t=b[0];
		for(int i=1;i<n;i++){
			c.push_back({t,b[i]});
			t-=b[i];
		}
	}
	else if(A==n){
		sort(a.begin(),a.end());
		t=a[0];
		for(int i=1;i<n-1;i++){
			c.push_back({t,a[i]});
			t-=a[i];
		}
		c.push_back({a[n-1],t});
		t=a[n-1]-t;
	}
	else{
		t=b[0];
		for(int i=1;i<A;i++){
			c.push_back({t,a[i]});
			t-=a[i];
		}
		c.push_back({a[0],t});
		t=a[0]-t;
		for(int i=1;i<B;i++){
			c.push_back({t,b[i]});
			t-=b[i];
		}
	}
	cout<<t<<endl;
	for(auto p:c) cout<<p.first<<' '<<p.second<<endl;
}

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

using namespace std;

int main()
{
  long long N, K;
  cin >> N >> K;

  N %= K;

  long long old = N + 1;
  while (N < old)
  {
    old = N;
    N = abs(N - K);
  }

  std::cout << old << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

bool ok(string s, string t, int pos) {
    for(int i = 0; i < t.size(); i++) {
        if(s[pos + i] != '?' && s[pos + i] != t[i]) {
            return false;
        }
    }
    return true;
}

int main() {
    ios::sync_with_stdio(false);
    cout.precision(10);
    string s, t;
    cin >> s >> t;
    string ans;
    if(t.size() > s.size()) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    for(int i = 0; i <= s.size() - t.size(); i++) {
        if(ok(s, t, i)) {
            string ss(s);
            for(int j = 0; j < t.size(); j++) {
                ss[i + j] = t[j];
            }
            if(ans.size() == 0 || ss < ans) {
                ans = ss;
            }
        }
    }
    if(ans.size() == 0) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    for(x : ans) {
        cout << (x == '?' ? 'a' : x);
    }
    cout << endl;
    return 0;
}

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

void fillDot(vector<string> &v,int x,int y,char c){
  if(x<0||y<0||v.size()<=y||v[y].size()<=x) return;
  if(v[y][x]!=c) return;
  v[y][x]='.';
  fillDot(v,x-1,y,c);
  fillDot(v,x+1,y,c);
  fillDot(v,x,y-1,c);
  fillDot(v,x,y+1,c);
}

int main(void){
  int h,w;
  while(cin>>h>>w,h||w){
    int c=0;
    vector<string> v;
    string s;
    for(int i=0;i<h;++i){
      cin>>s;
      v.push_back(s);
    }
    for(int i=0;i<h;++i){
      for(int j=0;j<w;++j){
        if(v[i][j]!='.'){
          ++c;
          fillDot(v,j,i,v[i][j]);
        }
      }
    }
    cout<<c<<endl;
  }
  return 0;
}

Measured memory_bytes: 2004
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef list<ll> listl;
typedef string str;

#define min(A, B) min(static_cast<ll>(A), static_cast<ll>(B))
#define max(A, B) max(static_cast<ll>(A), static_cast<ll>(B))

#define rep(i, max) for(ll i = 0, i_max = max; i < i_max; i++)

void in(ll& I)
{
	cin >> I;
}

void in(vl& I)
{
	for (auto& i : I)
	{
		cin >> i;
	}
}

void in(listl& I)
{
	for (auto& i : I)
	{
		cin >> i;
	}
}

void in(str& s)
{
	cin >> s;
}

void out(ll& O)
{
	cout << O;
}

void out(ll O)
{
	cout << O;
}

void out(vl& O)
{
	for (auto& o : O)
	{
		cout << o;
	}
}

ll GetGCD(ll a, ll b)
{
	if (a == 0)return b;
	if (b == 0)return a;

	int r = a % b;

	if (r == 0)
	{
		return b;
	}
	else
	{
		return GetGCD(b, r);
	}
}

int main()
{
	ll A, B, C, D;
	in(A);
	in(B);
	in(C);
	in(D);

	ll N = 0;

	ll F = A % C == 0 ? A / C : (A / C + 1);
	ll E = B % C == 0 ? B / C : (B / C);

	N += E - F + 1;

	F = A % D == 0 ? A / D : (A / D + 1);
	E = B % D == 0 ? B / D : (B / D);

	N += E - F + 1;

	ll lcm = C * D / GetGCD(C, D);

	F = A % lcm == 0 ? A / lcm : (A / lcm + 1);
	E = B % lcm == 0 ? B / lcm : (B / lcm);

	N -= E - F + 1;

	out(B - A - N + 1);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

vector<vector<ll>> g(100010); 
vector<ll> dist(100010);

int main(){
    ll n;
    string s;
    cin >> n >> s;

    char fst[] = {'S', 'W'};
    char snd[] = {'S', 'W'};

    rep(i, 2)rep(j, 2){
        string res = "";

        res += fst[i];
        res += snd[j];

        //右隣の動物を決めていく
        for(ll k = 1; k < n-1; ++k){
            if((res[k] == 'S' && s[k] == 'o') || (res[k] == 'W') && s[k] == 'x'){
                res += res[k-1];
            }
            else {
                if(res[k-1] == 'S')res += 'W';
                else res += 'S';
            }
        }
        

        //はじめの動物をもとに、矛盾していないか調べる
        if((res[0] == 'S' && s[0] == 'o') || (res[0] == 'W') && s[0] == 'x'){
            if(res[1] != res[n-1])continue;
        }
        else {
            if(res[1] == res[n-1])continue;
        }

        //最後の動物をもとに、矛盾していないか調べる
        if((res[n-1] == 'S' && s[n-1] == 'o') || (res[n-1] == 'W') && s[n-1] == 'x'){
            if(res[0] != res[n-2])continue;
        }
        else {
            if(res[0] == res[n-2])continue;
        }

        cout << res << endl;
        return 0;
    }

    cout << -1 << endl;
}

Measured memory_bytes: 3840
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	ll n, k;
	cin >> n >> k;
	n %= k;
	if(n * 2 > k) n = k - n;
	cout << n << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility> 
#include <unordered_set>
#include <vector>
#include <list> 
#include <string>
#include <iterator> 
#include <deque>
#include <array>
#include <forward_list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <bitset>
using namespace std;

#define N 100
#define EPS 1e-9

int arr[N];

//int solve(int l, int r) {
//	int diff = INT_MAX;
//	for (int k = l + 1; k < r; ++k)
//		if (abs(x - k) < diff)
//			diff = x;
//}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int x, n, best, x0, x1;
	cin >> x >> n;
	for (int i = 0; i < n; ++i)
		cin >> arr[i];

	if (n == 0) {
		cout << x << '\n';
	} else if (n == 1) {
		if (arr[0] == x) cout << x - 1 << '\n';
		else cout << x << '\n';
	} else {
		sort(arr, arr + n);

		if (binary_search(arr, arr+n, x)) {
			int lo = x - 1;
			int hi = x + 1;
			int ans = -1;
			best = INT_MAX;
			while (true) {
				x0 = abs(x - lo);
				x1 = abs(x - hi);

				if (x0 > best || x1 > best) break;

				if (!binary_search(arr, arr + n, lo)) {
					if (x0 <= best) {
						best = x0;
						ans = lo;
						if (x1 >= best)
							break;
					}
				}
				
				if (!binary_search(arr, arr + n, hi)) {
					if (x1 < best) {
						best = x1;
						ans = hi;
						if (x0 > best)
							break;
					}
				}


				--lo;
				++hi;
			}
			cout << ans << '\n';
		} else {
			cout << x << '\n';
		}
		
	}

}


Measured memory_bytes: 3192
#include<cstdio>
#include<algorithm>

using namespace std;

const long long mod = 1000000007;

long long dp[330][330][2][2];
int N, M;

long long solve(){
	dp[1][0][0][0] = 1;
	int t = 0;
	for(int i = 0; i < M; ++i){
		for(int x = 0; x < 330; ++x) for(int y = 0; y < 330; ++y){
			for(int z = 0; z < 2; ++z) dp[x][y][z][t ^ 1] = 0;
		}
		for(int x = 0; x <= N; ++x){
			for(int y = 0; y <= N; ++y){
				dp[x][y][0][1 - t] += dp[x][y][0][t] * x;
				dp[x][y][0][1 - t] %= mod;
				dp[x][y + 1][1][1 - t] += dp[x][y][0][t] * (N - x);
				dp[x][y + 1][1][1 - t] %= mod;
				
				if(x + y <= N){
					dp[x + y][0][0][1 - t] += dp[x][y][1][t] * x;
					dp[x + y][0][0][1 - t] %= mod;
				}
				dp[x][y][1][1 - t] += dp[x][y][1][t] * y;
				dp[x][y][1][1 - t] %= mod;
				dp[x][y + 1][1][1 - t] += dp[x][y][1][t] * (N - x - y);
				dp[x][y + 1][1][1 - t] %= mod;
			}
		}
		t ^= 1;
	}
	long long tmp = dp[N][0][0][t];
	tmp %= mod;
	tmp += mod;
	tmp %= mod;
	return tmp;
}

int main(){
	scanf("%d%d", &N, &M);
	long long ans = solve();
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;

int main(){
    string s;
    string t;
    cin >> s ;
    cin >> t;
    int cnt=0;

    for(int i=0;i<s.length();i++){
        if(s[i]!=t[i]){
            cnt += 1;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

//const int max_int = int(1e6 + 13);

int main() {
	//freopen("input.txt", "r", stdin);
	ios::sync_with_stdio(false);
	string a, b;
	cin >> a >> b;
	if(a.size() > b.size()) cout << "GREATER";
	if(a.size() < b.size()) cout << "LESS";
	if(a.size() == b.size()) {
		string ans = "EQUAL";
		for(int i = 0; i < a.size(); i++) {
			if(a[i] > b[i]) { ans = "GREATER"; break; }
			if(a[i] < b[i]) { ans = "LESS"; break; }
		}
		cout << ans;	
	}
}

Measured memory_bytes: 256
N , D = map(int, input().split())
P = [list(map(int,input().split())) for i in range(N)]

A = 0

for j in range(N) :
    Pi = (P[j][0]**2 + P[j][1]**2)**0.5
    if Pi <= D :
        A = A +1


print(A)

Measured memory_bytes: 45772
#include <stdio.h>

main(){
    int i,x;
	i = 1;
	while(1){
		scanf("%d",&x);
	    if ( x == 0 ){
		break;
	    } else {
		    printf("Case %d: %d\n",i,x);
		    i++;
	    }
	}
    return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int x, y;
  cin >> x >> y;
  ll ans = 0;
  if (x == 1 && y == 1) {
    ans += 400000;
  }
  if (x == 1) {
    ans += 300000;
  } else if (x == 2) {
    ans += 200000;
  } else if (x == 3) {
    ans += 100000;
  }
  if (y == 1) {
    ans += 300000;
  } else if (y == 2) {
    ans += 200000;
  } else if (y == 3) {
    ans += 100000;
  }

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


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

int main(void) {
int n, k, c = 0;
int a[100001] = {0};
std::cin >> n >> k;

for (int i = 0; i < n; i++) {
  std::cin >> a[i];
}

int j = 0;
while ( j < n - 1) {
  c++;
  j = j + k - 1;
}

std::cout << c << '\n';
return 0;
}


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

int main(){
  int n;
  cin >> n;
  while(n!=0){
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a.at(i);

    vector<int> s(n+1);
    s.at(0) = 0;
    for(int i=1;i<n+1;i++) s.at(i) = s.at(i-1)+a.at(i-1);

    int ans= -1000000000;
    for(int i=1;i<n+1;i++){
      for(int j=0;j<i;j++){
        ans = max(s.at(i)-s.at(j),ans);
      }
    }

    cout << ans << endl;

    cin >> n;
  }
}




Measured memory_bytes: 3112
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    for(int i = 0;i<n;i++){
      for(int j = 0;j<n;j++){
        if(4*i+7*j==n){
          System.out.println("Yes");
          return;
        }
      }
    }
    System.out.println("No");
  }
}


Measured memory_bytes: 35672
#include <stdio.h>
#include <string.h>

void printstr(int a, int b, char *str) {
  int length = strlen(str);
  char s[length+1];
  strncpy(s, str+a, b-a+1);
  s[b-a+1] = '\0';
  printf("%s\n", s);
}

void reversestr(int a, int b, char *str) {
  int length = strlen(str);
  char s[length+1];
  strcpy(s, str);
  int i;
  for(i = 0; i < b-a+1; i++) {
    str[a+i] = s[b-i];
  }
}

void replacestr(int a, int b, char *str, char *p) {
  int i;
  for(i = 0; i < b-a+1; i++) {
    str[a+i] = p[i];
  }
}

int main() {
  int a, b;
  char str[1001], command[8], p[1001];
  scanf("%s", str);
  int q;
  scanf("%d", &q);
  for(; q > 0; q--) {
    scanf("%s %d %d", command, &a, &b);
    if(strcmp(command,"print") == 0) {
      printstr(a, b, str);
    }
    if(strcmp(command,"reverse") == 0) {
      reversestr(a, b, str);
    }
    if(strcmp(command,"replace") == 0) {
      scanf("%s", p);
      replacestr(a, b, str, p);
    }
  }

  return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int N;cin >> N;
    vector<int> L(N);
    rep(i,N)cin >> L[i];
    sort(all(L));
    LL lon = 0;
    rep(i,N-1)lon += L[i];
    bool ok = false;
    if(L[N-1] < lon)ok = true;
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>
#include <unordered_set>

int N, A, B, C;
int l[8];

int calc(int cnt, int use, int a, int b, int c)
{
    if (cnt == N) {
        if (a == 0 || b == 0 || c == 0) {
            return 100000000;
        } else {
            const int diff = std::abs(a - A) + std::abs(b - B) + std::abs(c - C);
            const int mix = (use - 3) * 10;
            return diff + mix;
        }
    } else {
        const int v1 = calc(cnt + 1, use, a, b, c);
        const int v2 = calc(cnt + 1, use + 1, a + l[cnt], b, c);
        const int v3 = calc(cnt + 1, use + 1, a, b + l[cnt], c);
        const int v4 = calc(cnt + 1, use + 1, a, b, c + l[cnt]);
        return std::min({v1, v2, v3, v4});
    }
}

int main()
{
    std::cin >> N >> A >> B >> C;

    for (int i = 0; i < N; ++i) {
        std::cin >> l[i];
    }

    std::cout << calc(0, 0, 0, 0, 0) << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    for (int i = 0; i < 3; i++) {
        if (s % 10 == s / 10 % 10) {
            cout << "Bad" << endl;
            return 0;
        }
        s /= 10;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
 
ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}
int main(){
    ll n;
    cin>>n;
    ll ans=powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n);
    ans%=mod;
    ans=(ans+mod)%mod;
    cout<<ans<<"\n";
}

Measured memory_bytes: 3564