akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define INF 1000000000
#define MOD 1000000007

void solve() {
    int n, m, k;
    cin >> n >> m >> k;
    vll s1(n+1), s2(m+1);
    s1[0] = s2[0] = 0;
    rep(i, 0, n) {
        int tmp;
        cin >> tmp; 
        s1[i+1] = s1[i] + tmp;
    }
    rep(i, 0, m) {
        int tmp;
        cin >> tmp;
        s2[i+1] = s2[i] + tmp;
    }
    int ans = 0;
    int j = m;
    for (int i = 0; i <= n && s1[i] <= k; ++i) {
        while (s2[j] > k - s1[i]) --j;
        ans = max(ans, i + j);
    }
    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}


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

int main(){
    int a,b,c,tmp;
    cin >> a >> b >> c;
    if(a > b){
        tmp = b;
        b = a;
        a = tmp;
    }
    if(b > c){
        tmp = c;
        c = b;
        b = tmp;
    }
    if(a > b){
        tmp = a;
         a = b;
         b = tmp;
    }
    printf("%d %d %d\n" ,a,b,c);
    return 0;
}


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

int main() {
  double a, b, x;
  double ans;
  cin >> a >> b >> x;
  // 最大容積
  double maxVolume = a*a*b;
  double sideArea = a*b;
  double bottomArea = a*a;
  double height;
  // xが水筒の半分より多いか少ないかで場合分け
  if(x<=maxVolume/2) {
    // 水は側面*高さ/2になる
    height = x*2/sideArea;
    ans = atan2(b,height) * 180 / M_PI;
  } else {
    double emptyVolume = maxVolume - x;
    height = emptyVolume*2/bottomArea;
    ans = atan2(height,a) * 180 / M_PI;
  }
  cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 512
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
        int m1 = sc.nextInt();
        int d1 = sc.nextInt();
      
        int m2 = sc.nextInt();
        int d2 = sc.nextInt();
      
        if(m1 != m2 && d2 == 1){
          System.out.println(1);
        }else{
          System.out.println(0);
        }
  
	}
}

Measured memory_bytes: 35672
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>

using namespace std;

#define DEBUG if(false)

using ll = long long;
#define LINE printf("LINE : %d\n", __LINE__);
#define loop(i, n) for(i = 0; i < n; i++)
template<class T> using vec = vector<T>;

const int MOD = 1000000007;

/*
auto in(){
  string S;
  cin >> S;
  bool integer = true;
  for(int i = 0; i < S.size(); i++){
    if(not ('0' <= S[i] && S[i] <= '9')){
      integer = false;
      break;
    }
  }
  return (integer)?1:S;
}
*/


int main(){

  int N, K;
  cin >> N >> K;
  vec<int> d(K);
  vec<vec<int>> A(K);
  vec<int> sunuke(N, 0);
  int sum = 0;
  for(int i = 0; i < K; i++){
    cin >> d[i];
    int dd = d[i];
    //A[i].resize[d];
    for(int j = 0; j < dd; j++){
      int a;
      cin >> a;
      //cin >> A[i][j];
      if(sunuke[a-1] == 0){
        sum++;
        sunuke[a-1] = 1;
      }
    }
  }

  cout << N-sum << endl;

  return 0;
}


Measured memory_bytes: 3632
package main

import (
	"fmt"
)

type Item struct {
	Value  int
	Weight int
}

func main() {
	var ItemNumber int
	var MaxWeight int
	sack := []Item{}

	fmt.Scanln(&ItemNumber, &MaxWeight)

	dp := make([]int, MaxWeight+1)
	fill(dp, -1)
	dp[0] = 0

	for i := 0; i < ItemNumber; i++ {
		X := Item{}
		fmt.Scanln(&X.Weight, &X.Value)
		sack = append(sack, X)
	}
	value := Knapsack(sack, dp,ItemNumber,MaxWeight)
	fmt.Print(int64(value))
}

func Knapsack(sacks []Item,dp []int, N int, W int) int{
	for i := 0; i < N; i++ {
		w := sacks[i].Weight
		v := sacks[i].Value
		for j := W - w; j >= 0; j-- {
			if dp[j] == -1 {
				continue
			}
			dp[j+w] = max(dp[j+w], dp[j]+v)
		}
	}
	return reduce(max, dp)
}


func reduce(f func(x, y int) int, a []int) int {
	result := a[0]
	for i := 1; i < len(a); i++ {
		result = f(result, a[i])
	}
	return result
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func fill(a []int, x int) {
	for i := 0; i < len(a); i++ {
		a[i] = x
	}
}


Measured memory_bytes: 2704
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

template<class Monoid>
class SegmentTree{
private:
  using T = typename Monoid::T;
  const size_t n;
  vector<T> d;

  void build(){
    for(size_t b = n - 1; b > 0; b--) d[b] = Monoid::op(d[b << 1], d[b << 1 | 1]);
  }

public:
  SegmentTree(size_t n)
    : n(n), d(2 * n, Monoid::identify()) {}

  template<typename InputItr>
  SegmentTree(InputItr first, InputItr last)
    : n(distance(first, last)), d(2 * n, Monoid::identify()){
    copy(first, last, next(d.begin(), n));
    build();
  }

  /* set one value */
  void modify(size_t k, T v){
    for(d[k += n] = v; k > 1; k >>= 1) d[k >> 1] = Monoid::op(d[k], d[k ^ 1]);
  }

  /* return [l, r) value */
  T query(size_t l, size_t r){
    T res {Monoid::identify()};
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l&1) res = Monoid::op(res, d[l++]);
      if (r&1) res = Monoid::op(res, d[--r]);
    }
    return res;
  }
  
  void dump(){
    FOR(i, n, 2 * n) cout << i - n << ": " << d[i] << endl;
  }
};

/* Range Min Query */
template<typename U = ll>
struct RMQ{
  using T = U;
  static T op(const T& a, const T& b){ return min<T>(a, b); };
  static constexpr T identify(){ return numeric_limits<T>::max(); };
};

int main() {
    int n, m; cin >> n >> m;
    string s; cin >> s;
    
    reverse(s.begin(), s.end());

    SegmentTree<RMQ<>> t(n + 1);
    t.modify(0, 0);

    FOR(i, 1, n + 1) {
        if (s[i] == '1') continue;
        ll q = t.query(max(0, i - m), i);

        if (q == RMQ<>::identify()) continue;

        t.modify(i, q + 1);
    }
    
    vector<int> ans;
    ll f = t.query(n, n + 1);
    int ind = n;

    if (f == RMQ<>::identify()) {
        cout << -1 << endl;
        return 0;
    }

    for (int i = n - 1; i >= 0; i--) {
        ll v = t.query(i, i + 1);

        if (v == RMQ<>::identify()) continue;

        if (v != f) {
            ans.push_back(ind - i);
            ind = i;
            f = v;
        }
    }

    for (int a : ans) cout << a << " ";
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 2680
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, k;
  cin >> a >> b >> k;
  
  priority_queue<int, vector<int>, greater<int>> pq;
  for(int i=min(a,b); i>0; i--){
    if(a%i == 0 && b%i == 0){
      pq.push(i);
    }
    if(pq.size()==k){
      break;
    }
  }
  
  cout << pq.top() << endl;
}
  


Measured memory_bytes: 256
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)

(N, M) = reads()

A = []; B = []
for _ in range(N):
  s = input()
  A.append(s)
for _ in range(M):
  s = input()
  B.append(s)

for x in range(N-M+1):
  for y in range(N-M+1):
    if all(A[y+j][x:x+M] == B[j] for j in range(M)):
      print("Yes"); exit()

print("No")


Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int H,W,K; cin>>H>>W>>K;
  vector<string> S(H);
  rep(i,0,H) cin>>S[i];
  int ans=INF;
  rep(i,0,(1ll<<H-1)){
    bitset<10> B(i);
    int N=B.count(),sum=N;
    vi A(N+1);
    bool flag=1;
    rep(k,0,W){
      int m=0;
      vi C(N+1);
      rep(j,0,H){
        if(S[j][k]=='1') C[m]++;
        if(B.test(j)) m++;
      }
      bool F=0;
      REP(j,0,N){
        if(C[j]>K){
          flag=0;
          goto XYZ;
        }
        if(C[j]+A[j]>K) F=1;
      }
      if(F){
        REP(j,0,N) A[j]=C[j];
        sum++;
      }
      else{
        REP(j,0,N) A[j]+=C[j];
      }
    }
    XYZ:
    if(flag) ans=min(ans,sum);
  }
  cout<<ans<<endl;
  }



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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int a,b,m;cin>>a>>b>>m;
  vector<int> aa(a);
  vector<int> bb(b);
  int i;
  rep(i,a)cin>>aa[i];
  rep(i,b)cin>>bb[i];
  vector<int> x(m);
  vector<int> y(m);
  vector<int> c(m);
  rep(i,m)cin>>x[i]>>y[i]>>c[i];
  int mina=10000000;
  int minb=10000000;
  rep(i,a)if(aa[i]<mina)mina=aa[i];
  rep(i,b)if(bb[i]<minb)minb=bb[i];
  int kans=mina+minb;
  rep(i,m)
  {
    kans=min(kans,aa[x[i]-1]+bb[y[i]-1]-c[i]);
  }
  cout<<kans<<endl;
}


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

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        k: usize,
        s: u32,
    }
    let x = s;
    let y = if s == 1_000_000_000 { s - 1} else {s + 1};
    let mut out = String::new();
    for _ in 0..k {
        out.push_str(&format!("{} ", x));
    }
    for _ in 0..(n - k) {
        out.push_str(&format!("{} ", y));
    }
    out.pop();
    println!("{}", out);
}

fn main() {
    run();
}


Measured memory_bytes: 7420
#include<stdio.h>
int main(void)
{
	int a,b,c,d=0,i;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
		if((c%i)==0){
			d++;
		}
	}
	
	printf("%d\n",d);
		
	
	return 0;
}

Measured memory_bytes: 596
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int c, d;
		d = 0;
		if ((A+B) > N) {
		  d = (A + B) - N;
		}
		if(A > B){
		  c = B;
		}else{
		  c = A;
		}
		System.out.println(c + " " + d);
	}
}


Measured memory_bytes: 23124
n,k=map(int,input().split())
cnt=0
dic={}
for i in range(n):
  a,b=map(int,input().split())
  if a in dic:
    dic[a]+=b
  else:
    dic[a]=b

dic=sorted(dic.items())
for i,j in dic:
  cnt+=j
  if k<=cnt:
    print(i)
    exit()

Measured memory_bytes: 14564
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
pair<pair<string,int>,int> a[105];

for(int i = 1; i<=n; i++){
    cin>>a[i].first.first>>a[i].first.second;
    a[i].first.second *= -1;
    a[i].second = i;
}

sort(a,a+n+1);
for(int i = 1; i<=n; i++){
    cout<<a[i].second<<endl;
}
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <climits>
#include <tuple>
#include <algorithm>
#define int long long

using namespace std;

struct edge {
  int to, cost;
};

using graph_t = vector<vector<edge>>;

vector<int> shortest_path(graph_t const& graph, int start) {
  int V = graph.size();
  vector<int> dists(V, LLONG_MAX / 3);
  using P = pair<int, int>;
  priority_queue<P, vector<P>, greater<P>> que;
  dists[start] = 0;
  que.emplace(0, start);
  while (!que.empty()) {
    int d, v;
    tie(d, v) = que.top();
    que.pop();
    if (d > dists[v]) continue;
    for (auto&& e : graph[v]) {
      if (d + e.cost >= dists[e.to]) continue;
      dists[e.to] = d + e.cost;
      que.emplace(d + e.cost, e.to);
    }
  }
  return dists;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m, r;
  cin >> n >> m >> r;
  vector<int> rs(r);
  for (auto& v : rs) {
    cin >> v;
    v--;
  }
  graph_t graph(n);
  for (int i = 0; i < m; i++) {
    int a, b, t;
    cin >> a >> b >> t;
    a--; b--;
    graph[a].push_back({b, t});
    graph[b].push_back({a, t});
  }
  vector<vector<int>> dists(n);
  for (int i = 0; i < n; i++)
    dists[i] = shortest_path(graph, i);
  int result = LLONG_MAX;
  vector<vector<int>::iterator> order(r);
  for (int i = 0; i < r; i++)
    order[i] = begin(rs) + i;
  do {
    int len = 0;
    for (int i = 0; i < r - 1; i++)
      len += dists[*order[i]][*order[i+1]];
    result = min(result, len);
  } while (next_permutation(begin(order), end(order)));
  cout << result << endl;
}


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

int main(){
    int n ;
    cin >> n ;
    int curx = 0 , cury = 0 ;
    int curt = 0 ;
    for(int i=0;i<n;i++){
        int t , x , y ;
        cin >> t >> x >> y ;
        int dist = abs(curx-x) + abs(cury-y);
        if ( dist <= t-curt ){
            if ( dist % 2 != (t-curt)%2 ){
                cout << "No" << endl;
                return 0 ;
            }
            curx = x ;
            cury = y ;
            curt = t ;
        }
        else {
            cout << "No" << endl;
            return 0 ;
        }
    }
    cout << "Yes" << endl;
    return 0 ;
}


Measured memory_bytes: 256
# ABC110 D factorization
N,M=map(int,input().split())
p=10**9+7
L=10**5*3
f,inv,finv=[0]*(L+1),[0]*(L+1),[0]*(L+1)

def factorization(N):
    res=[]
    for i in range(2,int(N**(1/2))+2):
        if not N%i:
            r=0
            while not N%i:
                N//=i
                r+=1
            res.append((i,r))
    if N>1:
        res.append((N,1))
    return res

def nCr_init(L,p):
    for i in range(L+1):
        if i<=1:
            f[i],finv[i],inv[i]=1,1,1
        else:
            f[i]=(f[i-1]*i)%p
            inv[i]=(p-inv[p%i]*(p//i))%p
            finv[i]=(finv[i-1]*inv[i])%p

def nCr(n,r,p):
    if 0<=r<=n and 0<=n:
        return (f[n]*finv[n-r]*finv[r])%p
    else:
        return 0

nCr_init(L,p)
p_list=factorization(M)
res=1
for a,r in p_list:
    res=(res*nCr(r+N-1,r,p))%p
print(res)

Measured memory_bytes: 72304
import string
n,k=map(int,input().split())
numbers="0123456789"
alphabets=string.ascii_letters
characters=numbers+alphabets

def base_cvt(value, n=2):
    tmp=int(value)
    result = ''
    while tmp >= n:
        idx = tmp%n
        result = characters[idx] + result
        tmp = int(tmp / n)
    idx = tmp%n
    result = characters[idx] + result
    return result
print(len(base_cvt(str(n),k)))

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    i64 n, m;
    std::cin >> n >> m;
    std::vector<std::pair<i64, i64>> v;
    for (int i = 0; i < n; i++) {
        i64 a, b;
        std::cin >> a >> b;
        v.emplace_back(a, b);
    }
    std::sort(v.begin(), v.end());
    i64 ret = 0;
    auto it = v.begin();
    while (m) {
        auto a = it->first;
        auto b = it->second;
        it++;
        ret += std::min(m, b) * a;
        m -= std::min(m, b);
    }
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long, long> > vllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n, sum = 0;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  int arr[n];
  fi(0, n) {
    cin >> arr[i];
    if(i == 0) {
      sum += abs(arr[i]);
    }
    else {
      sum += abs(arr[i] - arr[i - 1]);
    }
  } 
  sum += abs(arr[n - 1]);
  fi(0, n) {
    if(i == 0) {
      ans = sum - abs(arr[i]) - abs(arr[i + 1] - arr[i]) + abs(arr[i + 1]);
    }
    else if(i == n - 1) {
      ans = sum - abs(arr[i]) - abs(arr[i] - arr[i - 1]) + abs(arr[i - 1]);
    }
    else {
      ans = sum - abs(arr[i] - arr[i - 1]) - abs(arr[i] - arr[i + 1]) + abs(arr[i - 1] - arr[i + 1]);
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  string S;
  cin>>S;
  if(S=="zyxwvutsrqponmlkjihgfedcba"){cout<<-1<<endl;}
  else if(S.size()==26){
    ll maxcharacter=S.at(25);
    ll rock;
    for(ll i=0;i<25;i++){
      if(S.at(24-i)<maxcharacter){
        for(ll j=0;j<24-i;j++){cout<<S.at(j);}
        rock=24-i;
        unordered_map<ll,ll> mp;
        for(ll i=0;i<rock;i++){
          mp[S.at(i)]++;
        }
        char start=S.at(rock)+1;
        while(mp[start]>0){start++;}
        cout<<start<<endl;
        return 0;
      }
      else{maxcharacter=S.at(24-i);}
    }
  }
  else{
    unordered_map<ll,ll> mp;
    for(ll i=0;i<(ll)S.size();i++){
      mp[S.at(i)]++;
    }
    cout<<S;
    if(mp['a']==0){cout<<"a"<<endl;return 0;}
    if(mp['b']==0){cout<<"b"<<endl;return 0;}
    if(mp['c']==0){cout<<"c"<<endl;return 0;}
    if(mp['d']==0){cout<<"d"<<endl;return 0;}
    if(mp['e']==0){cout<<"e"<<endl;return 0;}
    if(mp['f']==0){cout<<"f"<<endl;return 0;}
    if(mp['g']==0){cout<<"g"<<endl;return 0;}
    if(mp['h']==0){cout<<"h"<<endl;return 0;}
    if(mp['i']==0){cout<<"i"<<endl;return 0;}
    if(mp['j']==0){cout<<"j"<<endl;return 0;}
    if(mp['k']==0){cout<<"k"<<endl;return 0;}
    if(mp['l']==0){cout<<"l"<<endl;return 0;}
    if(mp['m']==0){cout<<"m"<<endl;return 0;}
    if(mp['n']==0){cout<<"n"<<endl;return 0;}
    if(mp['o']==0){cout<<"o"<<endl;return 0;}
    if(mp['p']==0){cout<<"p"<<endl;return 0;}
    if(mp['q']==0){cout<<"q"<<endl;return 0;}
    if(mp['r']==0){cout<<"r"<<endl;return 0;}
    if(mp['s']==0){cout<<"s"<<endl;return 0;}
    if(mp['t']==0){cout<<"u"<<endl;return 0;}
    if(mp['u']==0){cout<<"u"<<endl;return 0;}
    if(mp['v']==0){cout<<"v"<<endl;return 0;}
    if(mp['w']==0){cout<<"w"<<endl;return 0;}
    if(mp['x']==0){cout<<"x"<<endl;return 0;}
    if(mp['y']==0){cout<<"y"<<endl;return 0;}
    if(mp['z']==0){cout<<"z"<<endl;return 0;}
  }
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define MOD 1e+7
#define inf 1e9
#define fi first
#define se second
using namespace std;

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

  int64_t n, m;
  cin >> n >> m;
  vector<pair<int64_t, int64_t>> data(0);
  rep(i,n) {
    int64_t a, b;
    cin >> a >> b;
    data.push_back(make_pair(a, b));
  }
  sort(data.begin(), data.end());

  int64_t res = 0;
  int64_t idx = 0;
  while(m > 0) {
    int64_t a = data[idx].fi;
    int64_t b = data[idx].se;
    res += a * min(m, b);
    m -= min(m, b);
    idx++;
  }
  cout << res << endl;
}

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

int main(){
    int n,ans;
    cin>>n;
    for(int i=1;i<=n;i++){
        ans=0;
        for(int x=1;x<100 && x*x<i;x++){
            for(int y=1;y<=x && x*x+y*y+x*y<i;y++){
                for(int z=1;z<=y;z++){
                    if(x*x+y*y+z*z+x*y+y*z+z*x==i){
                        if(x==y && y==z)ans++;
                        else if(x==y || y==z || x==z)ans+=3;
                        else ans+=6;
                    }
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <fstream>
#include <math.h>
#include <string>

using namespace std;

int main(){
  int x;
  cin >> x;
  int tmp;
  while(tmp==0){
    for(int i=2; i<x; i++){
      if(x%i==0){
        tmp = 1;
        break;
      }
    }
    if(tmp == 0){
      cout << x;
      break;
    }
    tmp = 0;
    x++;
  }
}


Measured memory_bytes: 256
package main

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

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	nums := map[int]int{}
	for i := 0; i < n; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		nums[a-1]++
		nums[a]++
		nums[a+1]++
	}
	var max int
	for _, v := range nums {
		if max < v {
			max = v
		}
	}
	fmt.Printf("%d\n", max)
}


Measured memory_bytes: 6784
a[6],x;main(i,j){for(;~j;++i)i<6?x|=1<<(gets(a+i),j=a[i]-=49):i>10?x=i=0:printf("%d\n",x-(x&-x)&&x-7?j=a[i-5],x&2?x&1?j+1:j:j?1:2:3);}

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

int main()
{
	char n[4];
	int i;
	cin>>n;
	  if(n[0] == '7' || n[1] =='7' || n[2] == '7'){
	    cout<<"Yes"<<endl;
	  }
	  else cout<<"No" << endl;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using P = pair<int, int>;

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};


const int MOD = 1000000007;
using mint = Fp<MOD>;

int main(){
    int n,m;
    cin >> n >> m;
    if(abs(n-m) > 1){
        cout << 0 << endl;
    }else{
        mint factn = 1, factm = 1;
        rep(i,n) factn *= (mint)(i+1);
        rep(i,m) factm *= (mint)(i+1);
        if(n == m){
            cout << ((mint)2*factn*factm) << endl;
        }else{
            cout << (factn*factm) << endl;
        }
    }

    return 0;
}

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

p_all = set(range(-200, 200)) - set(p)
# print(p_all)

mi = float('inf')
ans = 0
for i in p_all:
    if abs(x - i) < mi:
        mi = abs(x - i)
        ans = i

print(ans)

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int x,n;
  cin >> x >> n;
  
  int ans = 1e8;
  vector<int>p(n);
  set<int>st;
  rep(i,n) cin >> p[i];
  rep(i,n) st.insert(p[i]);
  for(int i=101;i>=0;i--){
    if(st.count(i))continue;
    if(abs(ans-x)>=abs(i-x))ans=i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n,k;
    cin >> n >> k;
    int a[n];
    rep(i,n)cin >> a[i];
    rep(i,n-k){
        if(a[i]<a[k+i])cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 4400
#include <iostream>
#include <vector>
#include <stdio.h>
using namespace std;

int main()
{
    int n, query;
    scanf("%d %d", &n, &query);
    vector<vector<int> > vec(n);

    int flag, index, num;
    for (int loop = 0; loop < query; loop++)
    {
        scanf("%d", &flag);
        switch (flag)
        {
        case 0:
            scanf("%d %d", &index, &num);
            vec[index].push_back(num);
            break;
        case 1:
            scanf("%d", &index);
            if (!vec[index].empty())
            {
                printf("%d", vec[index][0]);
                for (unsigned int i = 1; i < vec[index].size(); i++)
                {
                    printf(" %d", vec[index][i]);
                }
            }
            printf("\n");
            break;
        case 2:
            scanf("%d", &index);
            vec[index].clear();
            break;
        default:
            break;
        }
    }

    return 0;
}



Measured memory_bytes: 5924
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
#include <functional>

//#include "All.h"

using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

int gcd(int a, int b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll beki(ll a, ll b) {
    ll tmp = 1;
    REP(i, b) tmp *= a;
    return tmp;
}

ll N, K;
ll ans = 0;
ll mod = 1e9 + 7;

int main() {
    cin >> N >> K;
    //for (ll k = K - 1; k <= N; k++) {
    //    ans += -k * k + (N - 1) * k + N + 1;
    //    ans %= ll(1e9) + 7;
    //}
    ll n = N - (K - 1);
    ans += -n * (n + 1) * (2 * n + 1) / 6
        + (N - 2 * K + 1) * n * (n + 1) / 2
        + (n + 1) * (-(K - 1) * (K - 1) + (N - 1) * (K - 1) + N + 1);
    //ans %= mod;
    //ans += ;
    //ans %= mod;
    //ans += ;
    ans %= mod;
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <stdio.h>

int main(int argc, char const *argv[])
{
    int N, D;
    int a, b, gurd;
    scanf("%d%d", &N, &D);
    a = N - D;
    b = N + D;
    if( N % (b - a + 1) > 0) {
        gurd = N / (b - a + 1) + 1;
    }
    else {
        gurd = N / (b - a + 1);
    }
    printf("%d", gurd);
    return 0;
}

Measured memory_bytes: 128
def checkmin(i):
    six_k = 1
    nine_k = 1
    list_before_compare = []
    list_before_compare.append(dp_table[i])
    
    #1円引き出したとき
    list_before_compare.append(dp_table[i-1] + 1)
    
    #6のべき乗の引き出し
    while 6**six_k <= i:
        list_before_compare.append(dp_table[i-6**six_k] + 1)
        six_k += 1
    
    #9のべき乗の引き出し
    while 9**nine_k <= i:
        list_before_compare.append(dp_table[i-9**nine_k] + 1)
        nine_k += 1

    return min(list_before_compare)    

n = int(input())

dp_table = [float("inf")] * (n+1)

#1円になるための取り出し方は1通りのみ→最小値は1
dp_table[0] = 0

for i in range(1,n+1):
    dp_table[i] = checkmin(i)

print(dp_table[-1])



Measured memory_bytes: 45520
n = int(input())
a = list(map(int,input().split()))
c = 0
for i in range(n):
    if a[i] < 0:
        c += 1
        a[i] = abs(a[i])
if c % 2 == 0:
    print(sum(a))
else:
    print(sum(a)-(min(a)*2))

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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


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

    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int ans = 0;
    for(int i = 0; i <= A; i++){
        for(int j = 0; j <= B; j++){
            if(((X - i * 500 - j * 100 ) % 50 == 0) && (((X - i * 500 - j * 100 ) / 50 <= C && ((X - i * 500 - j * 100 ) / 50 >= 0)))){
                ans++;
            }
        }
    }

    cout << ans << endl;

    
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(void){
  int num,i=0;
  int* a;
  int* b;
  int* c;
 
  scanf("%d",&num);

  a=(int*)calloc(num,sizeof(int));
  b=(int*)calloc(num,sizeof(int));
  c=(int*)calloc(num,sizeof(int));


  while(num>i){
    scanf("%d %d %d",(a+i),(b+i),(c+i));
    i++;
    
  }

  for(i=0;num>i;i++){
   *a=*a**a;
   *b=*b**b;
   *c=*c**c;
   if(*a==*c+*b || *b==*a+*c || *c==*b+*a){
      printf("YES\n");
    }
    else{
      printf("NO\n");
    }
    a++;
    b++;
    c++;
  }
  return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


// ∑{i = 0 to N−1} floor((A×i+B)/M)
// これいつ使うんだマジで
long long floor_sum(long long n, long long m, long long a, long long b) {
    long long ans = 0;
    if (a >= m) {
        ans += (n - 1) * n * (a / m) / 2;
        a %= m;
    }
    if (b >= m) {
        ans += n * (b / m);
        b %= m;
    }

    long long y_max = (a * n + b) / m, x_max = (y_max * m - b);
    if (y_max == 0) return ans;
    ans += (n - (x_max + a - 1) / a) * y_max;
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a);
    return ans;
}


int main(){

    int t;
    cin >> t;
    rep(i,t) {
        int n, m, a, b;
        cin >> n >> m >> a >> b;
        ll ans = floor_sum(n,m,a,b);
        cout << ans << endl;
    }
}

Measured memory_bytes: 3640
from functools import lru_cache

T = int(input())

caseList = []

for i in range(T):
    caseList.append(list(map(int, input().split())))


@lru_cache(maxsize=None)
def solve(n, A, B, C, D):
    if n == 0:
        return 0
    if n == 1:
        return D
    if n == 2:
        return min(D + D, A + D)

    ans = n * D

    for num, cost in zip([2, 3, 5], [A, B, C]):
        ans = min(
            solve((n + (num - n % num)) // num, A, B, C, D) + cost + D * (num - n % num),
            solve((n - n % num) // num, A, B, C, D) + cost + D * (n % num),
            ans,
        )

    return ans


for N, A, B, C, D in caseList:
    print(solve(N, A, B, C, D))

Measured memory_bytes: 35976
/*ILTH      ILTH            ILTHILTHILTH    ILTH        ILTH
  ILTH      ILTH                ILTH        ILTH        ILTH
  ILTH      ILTH                ILTH        ILTHILTHILTHILTH
  ILTH      ILTH                ILTH        ILTH        ILTH
  ILTH      ILTHILTHILTH        ILTH        ILTH        ILTH

  */
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;

const int maxN=18;
const int base=1000000;
const ll oo=1e18;

pii f[1<<maxN+5];
int n;

pii mer(pii x, pii y){
    pii t;
    ll a[5];
    a[1]=x.fi;a[2]=x.se;
    a[3]=y.fi;a[4]=y.se;
    for (int i=1; i<=3; ++i){
        if (a[i]==-oo) continue;
        for (int j=i+1; j<=4; ++j){
            if (a[j]==-oo) continue;
            if (a[i]%base==a[j]%base) a[j]=-oo;
        }
    }
    sort(a+1, a+5);reverse(a+1,a+5);
    t={a[1],a[2]};
    return t;
}
int main()
{
    //ifstream cin("a.inp");
    cin >> n;
    for (int i=0; i<(1<<n); ++i){
        ll x;
        cin >> x;
        f[i]={x*base+i,-oo};
    }
    for (int i=1; i<(1<<n); ++i){
        f[i]=mer(f[i],f[0]);
        ll maxs=-oo;
        for (int j=n; j>=0; --j){
            if (i&(1<<j)){
                int h=(i^(1<<j))|((1<<j)-1);
                maxs=max(maxs,f[h].fi/base+f[h].se/base);
                f[i]=mer(f[i],f[(i^(1<<j))]);
            }
        }
        cout << max(maxs,f[i].fi/base+f[i].se/base) << endl;
    }
    return 0;
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    vector<int> a{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << max(a + b, max(a - b, a * b)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{	
	int a,b;
	while(cin>>a>>b)
	{
		if(a==0&&b==0)break;
		for(int i=0;i<a;i++)
		{
			for(int j=0;j<b;j++)
			{
				if((i%2==0&&j%2==0)||(i%2&&j%2))cout<<"#";
				else cout<<".";
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;	
}


Measured memory_bytes: 3080
import itertools
from collections import deque

H, W = [int(_) for _ in input().split()]
A = [list(input()) for _ in range(H)]
Q = deque([])
for i, j in itertools.product(range(H), range(W)):
    if A[i][j] == '#':
        Q += [[i, j, 0]]
while Q:
    i, j, d = Q.popleft()
    for ni, nj in [[i - 1, j], [i + 1, j], [i, j - 1], [i, j + 1]]:
        if 0 <= ni < H and 0 <= nj < W and A[ni][nj] == '.':
            A[ni][nj] = '#'
            Q += [[ni, nj, d + 1]]
print(d)


Measured memory_bytes: 157316
#include <bits/stdc++.h>
using namespace std;
int main() {
  char S[110000];
  cin >> S;
  bool app[26];
  for (int i=0; i<26; i++) {
    app[i] = false;
  }
  for (int i=0; S[i] != '\0'; i++) {
    app[S[i]-'a'] = true;
  }
  for (int i=0; i<26; i++) {
    if (!app[i]) {
      cout << (char)(i+'a') << endl;
      return 0;
    }
    
  }
  cout << "None" << endl;
}

Measured memory_bytes: 384
li = list(map(int, input().split()))
N, K = li[0], li[1]
d = []
A = []
for i in range(K):
    d.append(input())
    A.append(list(map(int, input().split())))
sunuke = list(range(1, N+1))
treated = []
for Ai in A:
    for x in Ai:
        if x not in treated:
            treated.append(x)
tricked = list(set(sunuke) - set(treated))
print(len(tricked))

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

int main(){
  int n,cnt=0;
  cin >> n;
  int a[n],b[9]={};
  for(int i=0;i<n;i++)
    cin >> a[i];
  for(int i=0;i<n;i++){
    for(int j=0;j<8;j++){
      if(400*(j)<=a[i]&&a[i]<400*(j+1))
        b[j]++;
    }
    if(3200<=a[i])
      b[8]++;
  }
  for(int i=0;i<9;i++){
    if(b[i]!=0)
      cnt++;
  }
  if(b[8]>0&&cnt==1) cout << 1 << ' ' << cnt-1+b[8] << endl;
  else if(b[8]>0) cout << cnt-1 << ' '<< cnt-1+b[8] << endl;
  else cout << cnt << ' ' << cnt << endl;
}


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

int main() {
    int N, K, L;
    int a = 1;
    cin>>N>>K;
    L = K;
    for (int b = 1; b < N;b++){
        if(N/K>0){
            a ++ ;
          K *=L;
        }else{
            break;
        }
    }
    cout << a << endl;
}



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

int main()
{
    int N;
    cin >> N;
    vector<int> s(N);
    int sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> s[i];
        sum += s[i];
    }
    sort(s.begin(), s.end());

    if (sum % 10 != 0)
    {
        cout << sum << endl;
        return 0;
    }
    for (int i = 0; i < s.size(); i++)
    {
        if ((sum - s[i]) % 10 != 0)
        {
            cout << sum - s[i] << endl;
            return 0;
        }
    }
    cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
a,l=[list(input())for i in range(h)],[0]*26
for i in a:
 for j in i:l[ord(j)-97]+=1
o,t,f=(h//2)*(w//2),(h//2)*(w%2)+(w//2)*(h%2),(h%2)*(w%2)
for i in l:
 while o and i>3:o-=1;i-=4
 while t and i>1:t-=1;i-=2
 f-=i
print("Yes"if o==t==f==0else"No")

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

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int size = scanner.nextInt();
		int[][] G = new int [size][size];
		for (int i = 0; i < size; i++) {
			for (int j = 0; j < size; j++) {
				G[i][j] = scanner.nextInt();
			}
		}
		boolean[] isVisites = new boolean[size];
		int[] costs = new int[size];
		Arrays.fill(costs, Integer.MAX_VALUE);
		costs[0] = 0;
		int cost = 0;
		for (int i = 0; i < size; i++) {
			int minCost = Integer.MAX_VALUE;
			int minEm = -1;
			for (int j = 0; j < size; j++) {
				if (!isVisites[j] && costs[j] < minCost) {
					minCost = costs[j];
					minEm = j;
				}
			}
			isVisites[minEm] = true;
			cost += costs[minEm];
			for (int k = 0; k < size; k++) {
				costs[k] = Math.min(costs[k], G[minEm][k] < 0 ? Integer.MAX_VALUE : G[minEm][k]);
			}
		}
		System.out.println(cost);
	}
}

Measured memory_bytes: 41400
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> v(n);
  for(int i=0; i<n; i++){
    cin>>v.at(i);
  }
  sort(v.begin(), v.end() );
  int ans =0;
  for(int i=0; i<k; i++){
    ans += v.at(i);
  }
  cout<< ans << endl;
//    cout << fixed << setprecision(10);
}


Measured memory_bytes: 3628
ID_num, gate_num = tuple([int(i) for i in input().split(" ")])
min_list = []
max_list = []
for i in range(gate_num):
    min_ID, max_ID = tuple([int(i) for i in input().split(" ")])
    min_list.append(min_ID)
    max_list.append(max_ID)
M = min(max_list)
m = max(min_list)
if M >= m:
    print(min(max_list) - max(min_list) + 1)
else:
    print(0)

Measured memory_bytes: 11020
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner scan = new Scanner (System.in);
		final String END = "-";
		String word;
		String str;
		int m;
		int h;
		
		do {
			word = scan.next();
			if (word.equals(END)) break;
			m = scan.nextInt();
			
			for (int i = 0; i < m; i++) {
				h = scan.nextInt();
				str = word + word;
				int hh = h + word.length();
				word = str.substring(h, hh);
			}
			
			System.out.println(word);
			
		} while(true);
		
	}
}



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

#define MAXN 2000001
int inv[MAXN];
int finv[MAXN];
int fact[MAXN];
int mod = 1e9 + 7;

void init(int n) {
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i <= n; i++) {
    fact[i] = (i * fact[i-1]) % mod;
    inv[i] = mod - ((inv[mod%i] * (mod/i)) % mod);
    finv[i] = (finv[i-1] * inv[i]) % mod;
  }
}

int32_t main() {
  int x, y;
  cin >> x >> y;

  /*
  2n + m = x
  2m + n = y
  3n = 2x - y
  3m = 2y - x
  */
  int n3 = 2*x - y;
  int m3 = 2*y - x;
  if (n3 < 0 || m3 < 0 || n3%3 != 0 || m3%3 != 0) {
    cout << 0;
    return 0;
  }

  int n = n3/3;
  int m = m3/3;
  init(n+m);
  int res = (fact[n+m]*((finv[n]*finv[m])%mod))%mod;
  cout << res;
}

Measured memory_bytes: 20736
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int k,x,i;
    int left,right;
    cin >> k >> x;
    left = x-(k-1);
    right = x+(k-1);
    for(i=left;i<=right;i++) cout << i << ' ';
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f,MAXN=1e6+10;
const LL MOD=1e9+7;
int X,Y;
LL fac[MAXN],inv[MAXN];
inline LL fpm(LL x,LL y){
    LL ret=1;
    while(y){
        if(y&1){
            ret=ret*x%MOD;
        }
        x=x*x%MOD;
        y>>=1;
    }
    return ret;
}
int main(){
    scanf("%d%d",&X,&Y);
    if((4*X-2*Y)%3||(2*Y-X)%3){
        putchar('0');
        return 0;
    }
    int A=(2*X-Y)/3,B=(2*Y-X)/3,N=A+B;
    if(A<0||B<0){
        putchar('0');
        return 0;
    }
    fac[0]=1;
    for(int i=1;i<=N;i++){
        fac[i]=fac[i-1]*i%MOD;
    }
    inv[N]=fpm(fac[N],MOD-2);
    for(int i=N-1;i>=0;i--){
        inv[i]=inv[i+1]*(i+1)%MOD;
    }
    printf("%lld",fac[N]*inv[A]%MOD*inv[B]%MOD);
    return 0;
}


Measured memory_bytes: 14592
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    string a, b;
    cin >> a >> b;
    if(a.length() > b.length() || (a.length() == b.length() && a > b)) {
        cout << "GREATER" << endl;
    } else if(a.length() < b.length() || (a.length() == b.length() && a < b)) {
        cout << "LESS" << endl;
    } else {
        cout << "EQUAL" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<cctype>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N;
    cin >> N;
    ll h,n,w;
    for(h=1;h<3500;h++){
        for(n=1;n<3500;n++){
            if((4*h*n-n*N-N*h)!=0)w=N*h*n/(4*h*n-n*N-N*h);
            if(w>0&&4*h*n*w==N*(h*n+n*w+w*h)){
                cout << h <<" " <<n << " "<<w <<endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256