akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MAX_N = 1e5+1;

int par[MAX_N];
ll siz[MAX_N];

int find_p(int x) {
    // xの親を見つける
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = find_p(par[x]);
    }
}
bool same(int x, int y){
    return find_p(x) == find_p(y);
}
void union_t(int x, int y) {
    x = find_p(x);
    y = find_p(y);
    if (x == y) {
        return;
    } else {
        if (siz[x] > siz[y]) {
            // xの方が大きい
            par[y] = x;
            siz[x] += siz[y];
        } else {
            // yの方が大きい
            par[x] = y;
            siz[y] += siz[x];
        }
    }
}

int main() {
    cout << fixed << setprecision(10);
    
    int n, m; cin >> n >> m;
    vector<P> e(m);
    rep(i, m) {
        int a, b; cin >> a >> b;
        a--; b--;
        e[i] = make_pair(a, b);
    }
    // par, siz初期化
    rep(i, n) {
        par[i] = i;
        siz[i] = 1;
    }

    vector<ll> ans(m);
    ans[m-1] = ll(n) * (n-1) / 2; // nC2
    reprrev(i, 1, m) {
        int a = e[i].first, b = e[i].second;
        if (same(a, b)) {
            ans[i-1] = ans[i];
        } else {
            ans[i-1] = ans[i] - siz[find_p(a)] * siz[find_p(b)];
            union_t(a, b);
        }
    }
    rep(i, m) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4096
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = input()
if n[-1] in ["2","4","5","7","9"]:
  print("hon")
elif n[-1] == "3":
  print("bon")
else:
  print("pon")

Measured memory_bytes: 65244
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

int main()
{
	int N = 0;
	cin >> N;
	vector<pair<int, int>> vec(N, make_pair(0, 0));
	for (int i = 0; i < N; ++i)
		cin >> vec[i].first >> vec[i].second;

	double totallength = 0;
	for (int i = 0; i < N - 1; ++i)
	{
		for (int j = i + 1; j < N; ++j)
		{
			double tmp = (vec[i].first - vec[j].first)*(vec[i].first - vec[j].first) + (vec[i].second - vec[j].second)*(vec[i].second - vec[j].second);
			totallength += sqrt(tmp);
		}
	}
	cout.setf(ios::fixed);
	cout << setprecision(6) << totallength * 2 / N << endl;

	return 0;
}

Measured memory_bytes: 256
def mod10(n):
  ret = n if n%10 != 0 else 0
  return ret

n = int(input())
s = [int(input()) for _ in range(n)]
ssum = sum(s)
if ssum%10 != 0:
  print(ssum)
else:
  sdiv = list(map(mod10,s))
  if sdiv == [0]*n:
    print(0)
  else:
    sdiv = [i for i in sdiv if i!=0]
    print(ssum-min(sdiv))

Measured memory_bytes: 9196
#define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto&& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto&& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<int> a(n); std::cin>>a;
  auto b = a;
  std::sort(all(b));
  debug(a,b);

  int k = n / 2;
  int l = b.at(k-1), r = b.at(k);
  if (l==r) {
    loop(n) {
      std::cout << l << std::endl;
    }
    return 0;
  }

  for (int x : a) {
    int ans = x <= l ? r: l;
    std::cout << ans << std::endl;
  }
  return 0;
}

/*
小さいグループと大きいグループに分けます。
中央っぽいものが同じ時には全部それです。
違うときには、スキップするのが小さいグループならば大きい方、逆なら逆です。
*/

Measured memory_bytes: 3840
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <climits>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>

#define pb push_back
#define mp make_pair

using namespace std;

int main(){
    int n,x;
    cin>>n;
    int no4 = 0, no2 = 0, no1 = 0;
    for(int i = 0; i < n; i++){
        cin>>x;
        if(x%4 == 0)no4++;
        else if(x%4 == 2)no2++;
        else no1++;
    }
    if(no2 == 0){
        if(no1 <= no4+1){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }else{
        if(no1 <= no4)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}


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

int main()
{
    ll k, x;
    cin >> k >> x;
    for (ll i = x - k + 1; i <= x + k - 1; i++)
        cout << i << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
    ll n, x;
    cin >> n >> x;
    vector<ll> m(n);
    for(int i = 0; i < n; ++i){
        cin >> m.at(i);
    }
    ll ans = n;
    x -= accumulate(m.begin(), m.end(), 0);
    ans += x / (*min_element(m.begin(), m.end()));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
using namespace std;
#define N 1000000

int main(){
    int n;
    cin>>n;
    int b[n-1];
    long sum=0;
    for (int i=0; i<n-1; i++){
        cin>>b[i];
    }
    for (int i=0; i<n; i++){
        if (i==0){
            sum+=b[0];
        }
        else if (i==n-1){
            sum+=b[n-2];
        }
        else{
            sum+=min(b[i-1], b[i]);
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
a = [[j for j in input()] for i in range(H)]

row, col = [False] * H, [False] * W
for i in range(H):
    for j in range(W):
        if a[i][j] == "#":
            row[i] = col[j] = True

for i in range(H):
    if row[i]:
        for j in range(W):
            if col[j]:
                print(a[i][j], end="")
        print()


Measured memory_bytes: 4468
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define ll int64_t
using namespace std;

bool compare_by_b(pair<string,int> a,pair<string,int> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

int main(){
    int c=0;
    string s,w;
    cin>>s;
    rep(i,s.size()) if(s.at(i)!='A') w.push_back(s.at(i));
    rep(i,s.size()-1) if(s.at(i)==s.at(i+1)){
        cout<<"NO"<<endl;
        return 0;
    }
    if(w=="KIHBR" && c<=4) {
        rep(i,s.size()-4) if(s.at(i)=='K' && s.at(i+1)=='I' && s.at(i+2)=='H'){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		BigDecimal a = new BigDecimal(sc.next());
		BigDecimal b = new BigDecimal(sc.next());

		BigDecimal result = a.multiply(b);
		System.out.println(result.setScale(0, RoundingMode.DOWN));
		sc.close();
	}
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define contains(c, i) ((c).find(i) != (c).end())
#define present(i, c) (find(all(c), i) != (c).end())

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i <= n; i++)
#define repa(i, a, b) for(int i = (a); i < (b); i++)
#define repd(i, n) for(int i = (n)-1; i >= 0; i--)

#define TRACE(x...) x
#define dbg(x) TRACE(cerr << #x" = " << x << endl)
#define dbgall(x) TRACE(cerr << #x" = "; for(auto __i : x) cerr << __i << " "; cerr << endl)
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<class T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<class T, class S>  ostream& operator<<(ostream& os, const pair<T, S>& p) { os << "(" << p.first << ", " << p.second << ")"; return os; }

//=========================

void print_binary(int n) {
    int len = 10;
    string r;
    while(n > 0) r = char('0' + n % 2) + r, n /= 2;
    r = string(len - r.size(), '0') + r;
    cerr << r << endl;
}

void run_test() {
    int n; cin >> n;
    vi a(n);
    int xort = 0;
    rep(i, n) cin >> a[i], xort ^= a[i];
    rep(i, n) {
        int xor1;
        xor1 = a[i];
        int ans = 0;
        rep(b, 31) {
            if((xor1 & (1 << b)) != (xort & (1 << b))) 
                ans |= (1 << b);
        }
        cout << ans << " ";
    }
    cout << endl;
}

//=========================

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	//int _t = 1, __t; cin >> __t; while(_t <= __t) { cout << "Case #" << _t++ << ": "; run_test(); }
	// int _t; cin >> _t; while(_t--) run_test();
	run_test();
	return 0;	
}



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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;

int main() {
    
    int n,m,miss=0,ac=0;
    cin>>n>>m;
    Vec vec(n,0),wa(n,0);
    
    for(int i=0;i<m;i++){
        int a;
        string b;
        cin>>a>>b;

        if(b=="AC"){
            if(vec[a-1]==0){
                ac++;
                 vec[a-1]=1;
            }
        }

        else{
            if(vec[a-1]==0){
                wa[a-1]++;
            }
        }

    
        }
    
    for(int i=0;i<n;i++){
            if(vec[i]==1){
                miss+=wa[i];
            }
    }
    cout<<ac<<" "<<miss<<endl;
}
 

Measured memory_bytes: 3968
<?php
fscanf(STDIN, "%s", $s);
$array = [
  'SUN' => 7,
  'MON' => 6,
  'TUE' => 5,
  'WED' => 4,
  'THU' => 3,
  'FRI' => 2,
  'SAT' => 1,
];
echo $array[$s];

Measured memory_bytes: 4604
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define IOS {ios :: sync_with_stdio(false); cin.tie(0);cout.tie(0); }
#define F first
#define S second
#define pb push_back
typedef long double ld;
#define deci(n) cout << fixed << setprecision(n);
typedef long long ll;

#define mem0(x)  memset(x,0,sizeof(x));
#define mem1(x)  memset(x,1,sizeof(x));
#define memm1(x) memset(x,-1,sizeof(x));
#define all(a) a.begin(), a.end()
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define fori2(n) for(ll i=1;i<=n;i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define forj2(n) for(ll j=1;j<=n;j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define fork2(n) for(ll k=1;k<=n;k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
const ll md = 1e9 + 7;

#define BSET(a, p) ((a) | (1ll << (p)))
#define BCHK(a, p) ((a) & (1ll << (p)))
#define BXOR(a, p) ((a) ^ (1ll << (p)));
#define BREM(a, p) (BCHK(a, p)?(BXOR(a, p)):(a))
#define BSHO(a, N) (bitset<N>(a))
// const ll N = 100005;
// ll fac[N] = {1};
// #define calfac for(ll i=1  ;i<N;i++) fac[i] = (fac[i-1]*i)%md;
// ll C[N+1][M+1]; 
// void  ncr(){
//     ll n = N,k = M; 
//     for (ll i = 0; i <= n; i++) { 
//         for (ll j = 0; j <= min(i, k); j++) { 
//             if (j == 0 || j == i)  C[i][j] = 1; 
//             else C[i][j] = C[i - 1][j - 1] +  C[i - 1][j]; 
//         } 
//     } 
// } 


#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 
// Ordered set docs:
// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}
ll modInv(ll a)
{
    return pow(a,md-2);
}
 
// ll nCr(ll n,ll r)
// {
//     return (fac[n]*modInv((fac[r]*fac[n-r])%md))%md;
// }

 
ll po(ll x,ll n){
    if(n==0) return 1;
    if(n%2==1) return (x*po(x,n-1));
    else {
        ll k=po(x,n/2);
        return (k*k);
    }
}
 
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
}
const ll N = 200005;
ll a[N],h[N],bit[N],n;
void update(ll x,ll val){
    for(; x <= n ; x += (x&(-x))){
        bit[x] = max(bit[x],val);
    }
}
ll query(ll x){
    ll mx = 0;
    for(; x > 0 ; x -= (x&(-x))){
        mx = max(bit[x],mx);
    }
    return mx;
}


int32_t main(){
    IOS;
    ll i,j,k,m,p,q;
    cin >> n;
    fori2(n) cin >> h[i];
    fori2(n) cin >> a[i];
    fori2(n){
        k = query(h[i]-1);
        update(h[i],k + a[i]);
    }
    cout << query(n) << "\n";
} 

Measured memory_bytes: 4992
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] d = new int[N];
		for (int i = 0; i < N; i++) {
			d[i] = sc.nextInt();
		}
		int count = 0;
		for (int i = 0; i < d.length - 1; i++) {
			for (int j = i + 1; j < d.length; j++) {
				count += d[i] * d[j];
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21716
def match(N, Y):
    for x in range(N+1):
        if 10000*x > Y:
            break
        for y in range(N-x+1):
            if 10000*x + 5000*y > Y:
                break
            z = N-x-y
            total = 10000*x + 5000*y + 1000*z
            if total == Y:
                return x,y,z
    return -1,-1,-1
  
N, Y = map(int, input().split())
x,y,z = match(N,Y)
print('{} {} {}'.format(x,y,z))

Measured memory_bytes: 38768
#include <iostream>

using namespace std;

int main(){

  int A,B;
  int ans = 0;

  cin >> A >> B;

  for(int i = A; i <= B; i++){
    int one = i % 10;
    int ten = (i / 10) % 10;
    int tho = (i / 1000) % 10;
    int tth = i / 10000;

    if((one == tth) && (ten == tho)){
      ans++;
    }

  }

  cout << ans << "\n";

  return 0;
}


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

#define ll unsigned long long

using namespace std;

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	if ((b - a) % 2 == 0)
		cout << (b - a) / 2;
	else {
		ll variant1 = a + (b - a) / 2;
		ll variant2 = (n - b + 1) + (n - (a + (n - b + 1))) / 2;
		cout << min(variant1, variant2);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
#define mp make_pair
ll check (ll n,ll m,ll i,ll j)
{
	if(i>=0 && i<n && j<m && j>=0)
	   return 1;
	else
	 return 0;   
}
int main()
{
	ll t;
	t = 1;
	while(t--)
	{
		ll i,n;
		map<string,ll>map1;
		cin>>n;
		for(i=0;i<n;i++)
		{
			string f;
			cin>>f;
			map1[f]++;	
		} 
		cout<<"AC x "<<map1["AC"]<<endl;
		cout<<"WA x "<<map1["WA"]<<endl;
		cout<<"TLE x "<<map1["TLE"]<<endl;
		cout<<"RE x "<<map1["RE"]<<endl;
	}
	return 0;
} 

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

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

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

    for(int i = k; i < n; i++){
        if(a[i] > a[i - k]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

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

int main() {
	ll n,count=0;
	string s;
	cin>>n;
	map<string,ll> m;
	while(n--){
		cin>>s;
		sort(s.begin(),s.end());
		m[s]++;
	}
	for(auto x:m){
		if(x.second>=2){
			count+=(x.second*(x.second-1))/2;
		}
	}
	cout<<count<<endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 5e5; int n;
char s[maxN + 1];

int segtree[26][4*maxN];
void build(int k, int i = 1, int lo = 0, int hi = n - 1)
{
  if (lo == hi)
  {
    segtree[k][i] = (s[lo] - 'a') == k;
    return;
  }
  int mid = (lo + hi) >> 1;
  build(k, 2*i, lo, mid), build(k, 2*i + 1, mid + 1, hi);
  segtree[k][i] = segtree[k][2*i] + segtree[k][2*i + 1];
}
int query(int k, int qlo, int qhi, int i = 1, int lo = 0, int hi = n - 1)
{
  if (hi < qlo || lo > qhi) return 0;
  if (lo >= qlo && hi <= qhi) return segtree[k][i];
  int mid = (lo + hi) >> 1;
  return query(k, qlo, qhi, 2*i, lo, mid) + query(k, qlo, qhi, 2*i + 1, mid + 1, hi);
}
void update(int k, int pos, int diff, int i = 1, int lo = 0, int hi = n - 1)
{
  if (lo == hi)
  {
    segtree[k][i] += diff;
    return;
  }
  int mid = (lo + hi) >> 1;
  if (pos <= mid) update(k, pos, diff, 2*i, lo, mid);
  else update(k, pos, diff, 2*i + 1, mid + 1, hi);
  segtree[k][i] = segtree[k][2*i] + segtree[k][2*i + 1];
}

int main()
{
  while (scanf("%d", &n) != EOF)
  {
    scanf(" %s", s);
    for (int i = 0; i < 26; i ++)
      build(i);

    int q; scanf("%d", &q);
    while (q --)
    {
      int op; scanf("%d", &op);
      if (op == 1)
      {
        int i; char c; scanf("%d %c", &i, &c); i --;
        if (s[i] != c)
        {
          update(s[i] - 'a', i, -1);
          update(c - 'a', i, 1);
          s[i] = c;
        }
      }
      else
      {
        int l, r; scanf("%d %d", &l, &r); l --, r --;
        int ans = 0;
        for (int i = 0; i < 26; i ++)
          ans += query(i, l, r) > 0;
        printf("%d\n", ans);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 160512
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
typedef long long ll;
const int N=1e6;
int n,k,x;
string s;
vector<int>v;
int dp[N];

int main(){


	scanf("%d",&n);
	for(int i =0;i<n;i++){
		scanf("%d",&x);
		v.push_back(x);
	}
	for(int i =0;i<n;i++)
		dp[i]=1000000000;
	dp[n-1]=0;
	if(n-2>=0)
		dp[n-2]=abs(v[n-2]-v[n-1]);
	if(n-3>=0)
		dp[n-3]=abs(v[n-3]-v[n-1]);
	for(int i=n-2;i>0;i--){
		if(i-1>=0){
			dp[i-1]=min(dp[i-1],dp[i]+abs(v[i-1]-v[i]));

		}
		if(i-2>=0){
			dp[i-2]=min(dp[i-2],dp[i]+abs(v[i-2]-v[i]));
		}

	}
	cout << dp[0]<<endl;
	return 0;
}

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

int main() {
    int n; cin >> n;
    int offices[4][3][10] = {};
    
    for (int i = 0; i < n; ++i) {
        int office, floor, room, resident; cin >> office >> floor >> room >> resident;
        --office, --floor, --room; // convert to index
        
        offices[office][floor][room] += resident;
    }
    
    for (int office = 0; office < 4; ++office) {
        for (int floor = 0; floor < 3; ++floor) {
            for (int room = 0; room < 10; ++room) {
                cout << " " << offices[office][floor][room];
            }
            cout << endl;
        }
        if (office != 3) cout << "####################" << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;

int modpow(int x, int n, int mod) {
    int res = 1;
    while (n > 0) {
        if (n & 1) {  // nが奇数のとき
            res *= x;
            res %= mod;
        }
        x *= x;
        x %= mod;
        n >>= 1;
    }
    return res;
}
 
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
 
	int N;
	cin >> N;
    map<P, int> mp;
	rep(i,N){
		int a, b;
        cin >> a >> b;
        if(a == 0 && b == 0){
            mp[{0,0}]++;
        }
        else if(a == 0){
            mp[{0,1}]++;
        }
        else if(b == 0){
            mp[{1,0}]++;
        }
        else{
            int gc = __gcd(a, b);
            a /= gc;
            b /= gc;
            if(a > 0 && b > 0){
                mp[{a,b}]++;
            }
            else if(a < 0 && b < 0){
                mp[{-a, -b}]++;
            }
            else if(a < 0){
                mp[{a,b}]++;
            }
            else if(b < 0){
                mp[{-a, -b}]++;
            }
        }
	}
    int ans = 1;
    /*
    for(auto e : mp){
        cout << e.first.first << ' ' << e.first.second << ' ' << e.second << endl;
    }
    */
    for(auto e : mp){
        int x = e.first.first;
        int y = e.first.second;
        if(x == 0 && y == 0){
            continue;
        }
        else if(x == 0 || y == 0){
            int z1 = mp[{0,1}];
            int z2 = mp[{1,0}];
            ans *= modpow(2,z1,MOD) + modpow(2,z2,MOD) -1;
            mp[{0,1}] = 0;
            mp[{1,0}] = 0;
        }
        else if(x > 0 && y > 0){
            int z1 = mp[{x,y}];
            int z2 = mp[{-y,x}];
            ans *= modpow(2,z1,MOD) + modpow(2,z2,MOD) -1;
            mp[{x,y}] = 0;
            mp[{-y,x}] = 0;
        }
        else{
            int z1 = mp[{x,y}];
            int z2 = mp[{y,-x}];
            ans *= modpow(2,z1,MOD) + modpow(2,z2,MOD) -1;
            mp[{x,y}] = 0;
            mp[{y,-x}] = 0;
        }
        ans %= MOD;
    }
    ans = (ans-1+mp[{0,0}]);
    if(ans < 0) ans += MOD;
    ans %= MOD;
    cout << ans << endl;
}

Measured memory_bytes: 28540
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<int> h(N);
  vector<bool> ok(N);
  for (int i=0;i<N;i++){
    cin>>h[i];
    ok[i]=true;
  }
  for (int i=0; i<M; i++){
    int a,b;
    cin>>a>>b;
    if(h[a-1]<=h[b-1]){
      ok[a-1]=false;
    }
    if(h[b-1]<=h[a-1]){
      ok[b-1]=false;
    }
  }
  int ans=0;
  for(int i=0; i<N; i++){
    if (ok[i]==true) ans++;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <iomanip>
using namespace std;
const int N = 3005;
double dp[N][N];
int vis[N][N];
double p[N];
int n;
double solve(int i, int chead, int ctail) {
	if ( i == n) {
		if ( chead > ctail) return 1;
		return 0;
	}
	if (vis[i][chead]) return dp[i][chead];
	double head = solve(i + 1, chead + 1, ctail) * p[i];
	double tail = solve(i + 1, chead, ctail + 1) * ( 1 - p[i]);
	vis[i][chead] = 1;
	return dp[i][chead] = head + tail;

}
int  main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	cout <<setprecision(10) << solve(0, 0, 0);
	return 0;
}


Measured memory_bytes: 104832
#include<cstdio>
#include<cstring>

const int MAXN = 100 + 10;
char s[MAXN];

void solve();
int main()
{
    solve();
    return 0;
}

void solve()
{
    int n;
    scanf("%d", &n);
    getchar();
    fgets(s, n + 1, stdin);
    if(n%2==1)
        printf("No");
    else 
    {
        if(strncmp(s,s+n/2,n/2)==0)
            printf("Yes");
        else
            printf("No");
    }
}

Measured memory_bytes: 1728
S = input()
flg = 0

target_S = "keyence"

if S.startswith(target_S) or S.endswith(target_S):
    flg = 1
else:
    for i in range(len(target_S)):
        target_left = target_S[:i]
        target_right = target_S[i:]
        
        if S.startswith(target_left) and S.endswith(target_right):
            flg = 1

if flg == 1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
while True:
    try:
        H,W = map(int,input().split())
        if H==W and H==0:
            break
    except:
        break
    
    x,y = 0,0
    room = []
    move_his = []
    flg = False
    for i in range(H):
        room.append([t for t in input()])
    
    while room[y][x] != ".":
        if room[y][x]==">":
            x+=1
        elif room[y][x]=="<":
            x-=1
        elif room[y][x]=="^":
            y-=1
        elif room[y][x]=="v":
            y+=1
        
        if [x,y] in move_his:
            flg = True
            break
        move_his.append([x,y])

    if flg:
        print("LOOP")
    else:
        print(x,y)



Measured memory_bytes: 5680
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    string a,b;cin>>a>>b;
    if(a.length()<b.length()){
        a=1;b=2;
    }
    else if(a.length()>b.length())
    {
        a=2;b=1;
    }
    if(a<b)
        cout<<"LESS"<<endl;
    else if(a==b)cout<<"EQUAL"<<endl;
    else cout<<"GREATER"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int num,n1,n2,i;
    scanf("%d",&num);

    n1 = num%100;
    n2 = num/100;

    if(1<=n2&&n2<=12){
        if(1<=n1&&n1<=12)printf("AMBIGUOUS\n");
        else printf("MMYY\n");
    }
    else{
        if(1<=n1&&n1<=12)printf("YYMM\n");
        else printf("NA\n");
    }

    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> b(n-1);

    rep(i,n-1) cin >> b[i];

    vector<int> a(n);
    rep(i,n-1) {
        if (i == 0 || a[i] > b[i]) {
            a[i] = b[i];
        }
        a[i+1] = b[i];
    }

    int ans = 0;
    rep(i,n) {
        ans += a[i];
    }

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

Measured memory_bytes: 3524
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n,m,a;
long long ans;
priority_queue<int> qu;
int main(){
	scanf("%d%d", &n, &m);
	rep(i,n){
		scanf("%d", &a);
		qu.push(a);
	}
	rep(i,m){
		a = qu.top(); qu.pop();
		qu.push(a/2);
	}
	while(!qu.empty()){
		ans += qu.top(); qu.pop();
	}
	printf("%lld\n", ans);
}


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

int block[100][100];
int xs, ys, xg, yg, n, w, h;

bool dfs(int x, int y, int c)
{
  if(block[x][y] != c || block[x][y] == 0)
    return false;
  if(x == xg && y == yg)
    return true;
  bool b = false;
  block[x][y] = 0;
  if(x < w - 1)
    b |= dfs(x + 1, y, c);
  if(x > 0 && !b)
    b |= dfs(x - 1, y, c);
  if(y < h - 1 && !b)
    b |= dfs(x, y + 1, c);
  if(y > 0 && !b)
    b |= dfs(x, y - 1, c);
  return b;
}

int main()
{
  while(true)
  {
    cin >> w >> h;
    if(!w && !h)
      break;
    cin >> xs >> ys
      >> xg >> yg >> n;
    xs--; ys--;
    xg--; yg--;
    
    for(int i = 0; i < n; i++)
    {
      int c, d, x, y;
      cin >> c >> d >> x >> y;
      x--; y--;
      block[x][y] = c;
      block[x + 1][y] = c;
      block[x][y + 1] = c;
      block[x + 1][y + 1] = c;
      if(d == 0)
        x += 2;
      else
        y += 2;
      block[x][y] = c;
      block[x + 1][y] = c;
      block[x][y + 1] = c;
      block[x + 1][y + 1] = c;
    }
    if(dfs(xs, ys, block[xs][ys]))
      cout << "OK\n";
    else
      cout << "NG\n";
  }
}

Measured memory_bytes: 1144
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest122-A
#  https://atcoder.jp/contests/abc122/tasks/abc122_a

def solveProblem(inputString):
	answer = ""
	if inputString == "A":
		answer = "T"
	elif inputString == "T":
		answer = "A"
	elif inputString == "C":
		answer = "G"
	elif inputString == "G":
		answer = "C"
	else :
		answer = ""
	return answer


if __name__ == '__main__':
	b = str(input().strip())
	solution = solveProblem(b)
	print("{}".format(solution))


Measured memory_bytes: 2940
#N = gets.chomp.to_i
N, M = gets.chomp.split.map(&:to_i)

def solve
  num = "x" * N
  M.times do 
    ss, cc = gets.chomp.split.map(&:to_i)
    #s << (ss-1)
    #c << cc
    ss -= 1
    cc = cc.to_s
    if num[ss] == 'x'
      num[ss] = cc
      next
    end
    if num[ss] != cc  # Check invalidness
      p(-1)
      return
    end
  end
  
  # Check 0
  if num.size == 1 && num[0] == 'x'
    p 0
    return
  end
  if num.size == 1
    p num.to_i
    return
  end

  # Here, num.size > 1
  if num[0] == '0'
    p(-1)
    return
  end

  # Here, num is valid
  if num[0] == 'x' # set 1 to first digit
    num[0] = '1'
  end
  0.upto(num.size-1).each do |i|
    if num[i] == 'x'
      num[i] = '0'
    end
  end
  p num.to_i
end  
# Here, s[i] means the number of digit.

solve

Measured memory_bytes: 1788
from itertools import combinations


def read_input():
    s = input().strip()
    return s

def split_and_sum(s, indice):
    indice_e = [0] + indice + [10]

    result = []
    for start,end in zip(indice_e, indice_e[1:]):
        result.append(int(s[start:end]))

    return sum(result)

def submit():
    s = read_input()
    max_index = len(s)

    acc = 0
    for i in range(max_index):
        for c in combinations(range(1, max_index), i):
            acc += split_and_sum(s, list(c))

    print(acc)

if __name__ == '__main__':
    submit()

Measured memory_bytes: 39664
S = input()
flg=True

if ('N' in S) and ('S' not in S):
    flg=False
if ('S' in S) and ('N' not in S):
    flg=False
if ('W' in S) and ('E' not in S):
    flg=False
if ('E' in S) and ('W' not in S):
    flg=False

ans = 'Yes' if flg else 'No'
print(ans)

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

int main()
{
	int x, y, W, H, r;
	
	cin >> W >> H >> x >> y >> r;
	
	if ( W >= x +r && H >= y + r && x - r >= 0 && y - r >= 0) cout << "Yes" << endl;
	
	else cout << "No" << endl;
	
	return 0;	
}


Measured memory_bytes: 3136
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>

using namespace std;

int main() {
	int a, b;

	cin >> a >> b;

	if (a <= b)cout << a << endl;
	else cout << a - 1 << endl;

	return 0;
}

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

using namespace std;
using ll = long long;

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

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

const ll MOD = 1000000007;

int main() {
	int a, b;

    cin >> a >> b;
	int ans = 0;

	if(b==1) {
		ans = 0;
	} else if(a>=b) {
		ans = 1;
	} else {
		ans = (b-1) / (a-1);
		if ((b-1) % (a-1) != 0) {
			ans += 1;
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 256
s=input()
ans=1

i=0
if i<len(s) and s[i]=="A":
  i+=1
if i<len(s) and s[i]=="K":
  i+=1
else:
  ans=0
if i<len(s) and s[i]=="I":
  i+=1
else:
  ans=0
if i<len(s) and s[i]=="H":
  i+=1
else:
  ans=0
if i<len(s) and s[i]=="A":
  i+=1
if i<len(s) and s[i]=="B":
  i+=1
else:
  ans=0
if i<len(s) and s[i]=="A":
  i+=1
if i<len(s) and s[i]=="R":
  i+=1
else:
  ans=0
if i<len(s) and s[i]=="A":
  i+=1
if i!=len(s):
  ans=0

if ans:
  print("YES")
else:
  print("NO")

  

Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;

int main(){
  int array[100];
  int n;
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> array[i];
  }
  for(int j = 0;j < n;j++){
    cout << array[n-j-1];
    if(j != n-1){
      printf(" ");
    }else{
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>

double round( double, int );

int main( void ) {
	double a, b, c, d, e, f;

	while ( scanf( "%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f ) == 6 )
		printf( "%.3f %.3f\n", round( ( c * e - b * f ) / ( a * e - b * d ), 4 ), round( ( - c * d + a * f ) / ( a * e - b * d ), 4 ) );

	return 0;
}

// 小数第digit位を四捨五入する（小数第digit-1位までの概数で表す）
double round( double x, int digit ) {
	int i;

	for ( i = 0; i < digit - 1; i++ )
		x *= 10.0;

	if ( x > 0 )
		x = (double)(int)( x + 0.5 );
	else
		x = (double)(int)( x - 0.5 );

	for ( i = 0; i < digit - 1; i++ )
		x /= 10.0;

	return x;
}

Measured memory_bytes: 648
#include <stdio.h>

int selectionSort();
int i,j;
int x[100];
int n;

int main(){
  int tem;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&x[i]);
  }
  
  tem = selectionSort();

    for(i=0;i<n;i++){
      printf("%d",x[i]);
      if(i<n-1){
	printf(" ");
      }
    }
    printf("\n%d\n",tem);
    
    return 0;
  }
  int selectionSort(){
    int cnt = 0;
    int minj;
    int tem;
    for(i=0;i<n-1;i++){
      minj = i;

      for(j=i;j<n;j++){
	if(x[j] < x[minj]){
	  minj = j;
	}
      }
      if(x[i] != x[minj]){
      tem = x[i];
      x[i] = x[minj];
      x[minj] = tem;
      cnt++;
      }
    }
    return cnt;
  }
  






























Measured memory_bytes: 2140
using System;
using System.Collections.Generic;
using System.Linq;

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine().Split(' ');
            var N = int.Parse(S[0]);
            var M = int.Parse(S[1]);
            var C = int.Parse(S[2]);

            var B = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            var A = new List<int[]>();
            for(var i=0; i<N; ++i)
            {
                A.Add(Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse));
            }


            var count = 0;
            foreach (var a in A)
            {
                var sum = 0;
                for(var i=0; i<M; ++i)
                {
                    sum += a[i] * B[i];
                }

                if (sum + C > 0)
                    count++;
            }
            Console.WriteLine(count);
        }
        
    }
}


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

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

    int N;
    cin >> N;
    vector<vector<int>> imos(1001, vector<int>(1001));
    for (int i = 0; i < N; i++) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        imos[x1][y1]++;
        imos[x1][y2]--;
        imos[x2][y1]--;
        imos[x2][y2]++;
    }
    int ans = 0;
    for (int i = 0; i <= 1000; i++) {
        for (int j = 0; j <= 1000; j++) {
            if (i > 0) imos[i][j] += imos[i-1][j];
            if (j > 0) imos[i][j] += imos[i][j-1];
            if (i > 0 && j > 0) imos[i][j] -= imos[i-1][j-1];
            ans = max(ans, imos[i][j]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6856
/*
   Author: Shivam Shukla
*/
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pair<ll,ll> > vpll;
 
const int MOD=1e9+7;
const int MAX=1e5+5;
const double PI= acos(-1.0);
const long double EPS=1e-10;
const int64_t INF=1e18+10;
 
#define fastio() ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0)
#define trace(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vi vector<int>
#define vl vector<ll>
#define vs vector<str>
#define vc(x) vector<x>
#define mapll map<ll,ll>
#define mapib map<int,bool>
#define mapiv map<int,vector>
#define mapsi map<string,int>
#define rep(i,j,k) for(ll i=j;i<k;i++)
#define down(i,j,k) for(ll i=j;i>=k;i--)
#define repa(i,n) for(ll i=0;i<n;i++)
#define dowa(i,n) for(ll i=n;i>=0;i--)
#define reps(i,j,k,s) for(ll i=j;i<k;i+=s)
#define downs(i,j,k,s) for(ll i=j;i>=k;i-=s)
#define trv(i,x) for(auto i:x)
#define pb push_back
#define eb emplace_back
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define str string 
#define dub double
#define pqmax priority_queue<ll>
#define pqmin priority_queue<ll,vl,greater<ll> >
 
template<typename t> t lcm(t a, t b) {return (a*b)/__gcd(a,b);}
template<typename t> t gcd(t a, t b) {return __gcd(a,b);}
template<typename t> t mul_mod(t a, t b, t m){t res=((a%m)*(b%m)%m); return res;}
template<typename t> t add_mod(t a, t b, t m){t res=((a%m)+(b%m))%m; return res;}
template<typename t> t pow_mod(t a,t b,t m) {t res=1;while(b){if(b&1) res=mul_mod(res,a,m);a=mul_mod(a,a,m), b>>=1;} return res%m;}
template<typename t> vc(t) num_vec(t num) {t res; while (num) res.pb(num%10), num/=10; return res;}
template<typename t> t vec_num(t vec) {t res=0; ll mul=1; repa(i,sz(vec)) res=vec[i]*mul, mul*=10; return res;}
template<typename t> t div_mod(t a, t b, t m) {return mul_mod<t>(a, pow_mod(b, m - 2, m), m);} 
template<typename t> t sub_mod(t a, t b, t m) {return ((a % m) - (b % m) + m ) % m;}

ll c(ll n, ll r) {
    ll res = 1;
    repa(i, r){
       res = mul_mod<ll>(res, (n - i), (ll) MOD);
       res = div_mod<ll>(res, i + 1, (ll) MOD);
    }
    return res;
}

int32_t main(int argc,char** argv){
	fastio();
	auto tstart= clock();

    ll n, a, b; cin >> n >> a >> b; 
    ll res = pow_mod<ll>(2ll, n, (ll)MOD) - 1;

    res = sub_mod<ll>(res, c(n, a), (ll) MOD);
    res = sub_mod<ll>(res, c(n, b), (ll) MOD);

    cout << res << endl;  

    cerr<<setprecision(2)<<fixed<<"Time elapsed: "<<(double)(clock() - tstart)/CLOCKS_PER_SEC<<endl; 
    return 0; 
}

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

int main()

{



int n,m;
cin>>n>>m;
if(n==m){cout<<1; return 0;}
int sum=1,counter=0;
while(sum<m){
sum--;
        sum+=n;

      counter++;



}

cout<<counter;

}





Measured memory_bytes: 256
// AOJに通すと16/18でWA.マキシマムのケースでつまづいている.

#include <iostream>
using namespace std;
int main(){
    int n,m,l;
    int A[100][100],B[100][100];
    long C[100][100];
    cin>>n>>m>>l;

    //行列A
    for (int i = 0; i < n ; ++i) {
        for (int j = 0; j < m ; ++j) {
            cin>>A[i][j];
        }
    }

    //行列B
    for (int i = 0; i < m ; ++i) {
        for (int j = 0; j < l ; ++j) {
            cin >> B[i][j];
        }
    }

    //行列C
    for (int i = 0; i < n ; ++i) {
        for (int j = 0; j < l ; ++j) {
            for (int k = 0; k < m ; ++k) {
                C[i][j] += A[i][k]*B[k][j];
            }
        }
    }
    //出力
    for (int i = 0; i < n ; ++i) {
        for (int j = 0; j < l-1  ; ++j) {
            cout<<C[i][j]<<" ";
        }
        cout << C[i][l-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define Graph vector<vector<int>>
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<
#define AA(i) cout<<i<<endl;
const int U=2e5+5;
const ll MOD=1000000007;
const int INF = 1001001001;

int main(){
    ll N,D; cin >> N >> D;
    D = D*D;
    vector<ll> X(N),Y(N);
    int i;
    int ans=0;
    rep(i,N){
        cin >> X[i] >> Y[i];
        if(X[i]*X[i]+Y[i]*Y[i]<=D) ans++;
    }

    AA(ans);
    return 0;
}

Measured memory_bytes: 6356
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)
typedef long long ll;

int main(){
  int n;cin>>n;ll p=0,m=0;
  vector<int> a(n,0);
  REP(i,n) cin>>a.at(i);
  //プラスで始める場合
  int sm=0;
  REP(i,n){
    sm+=a.at(i); 
    if(!(i%2)){
      while(sm<=0){
        p++;
        sm++;
      }
    }else{
      while(sm>=0){
        p++;
        sm--;
      }    
    }
  }
  
  //マイナスで始める場合
  sm=0;
  REP(i,n){
    sm+=a.at(i); 
    if(!(i%2)){
      while(sm>=0){
        m++;
        sm--;
      }
    }else{
      while(sm<=0){
        m++;
        sm++;
      }    
    }
  }

  cout<<min(m,p)<<endl;
}

Measured memory_bytes: 640
# coding=utf-8

###
### for atcorder program
###

import sys
import math

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

#abc list
#abc = [chr(ord('a') + i) for i in range(26)]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

def get_input():
    N = []
    while True:
        try:
            #N.append(input())
            N.append(int(input()))
        except EOFError:
            break
    return N

A = get_input()

N = []
maxnum = -1

for i in A:
    count = 0
    for j in A:
        if i == j:
            count += 1
    if maxnum < count:
        maxnum = count
        N = [i]
    elif maxnum == count:
        N.append(i)

N = set(N)
N = sorted(N)

for i in N:
    print(i)




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

int main() {
  int N, K, sum = 0;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if (x < (K - x)) {
      sum += 2 * x;
    } else {
      sum += 2 * (K - x);
    }
  }
  
  cout << sum << endl;
}


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

long long int valor[110],peso[110],dp[110][100010];

long long int ks(int n,int c){
  if(n==0||c==0) return dp[n][c]=0;
  if(dp[n][c]!=-1) return dp[n][c];
  if(peso[n]>c) return dp[n][c]=ks(n-1,c);
  long long int no=ks(n-1,c),yes=valor[n]+ks(n-1,c-peso[n]);
  return dp[n][c]=max(no,yes);
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  memset(dp,-1,sizeof(dp));
  long long int n,w;
  cin>>n>>w;
  for(long long int i=1;i<=n;i++) cin>>peso[i]>>valor[i];
  cout<<ks(n,w)<<"\n";
  return 0;
}

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

int main()
{
  int n;
  int i, ans;
  cin >> n;
  vector<string> s(n);
  for(i=0; i<n; i++)
  {
    cin >> s[i];
  }
  sort(s.begin(),s.end());
  ans = 1;
  for(i=0; i<n-1; i++)
  {
    if(s[i]==s[i+1])continue;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9600
n = int(input())

table = [[[0]*10 for i in range (0,3)] for k in range (0,4)]

for i in range(n):
    b,f,r,v = input().split()
    b = int(b)
    f = int(f)
    r = int(r)
    v = int(v)
    table[b-1][f-1][r-1] += v

for b in range(4):
    for f in range(3):
        print(' '+ ' '.join(map(str,table[b][f])))
    if b < 3:
        print('#'*20)



Measured memory_bytes: 5604