akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::BTreeSet;
#[allow(unused_imports)]
use std::collections::HashMap;
#[allow(unused_imports)]
use std::collections::HashSet;
use std::fmt::Display;
use std::fs::File;
use std::io::Read;
#[allow(unused_imports)]
use std::mem;

#[allow(dead_code)]
fn pow_speedy_with_mod(mut p: i64, mut q: i64, m: i64) -> i64 {
    p %= m;
    let mut r = p;
    let mut ret: i64 = 1;
    while q > 0 {
        ret *= if q % 2 == 1 { r } else { 1 };
        r *= r;
        r %= m;
        q /= 2;
        ret %= m;
    }
    return ret;
}

#[allow(dead_code)]
fn comb(n: usize, k: usize, m: i64, frac: &[i64], frac_inv: &[i64]) -> i64 {
    let mut ret = 1i64;
    if n < k {
        return 0;
    }
    ret *= frac[n] * frac_inv[n - k];
    ret %= m;
    ret *= frac_inv[k];
    ret %= m;
    ret
}

#[allow(dead_code)]
fn show1dvec<T: Display>(v: &Vec<T>) {
    let n = v.len();
    for i in 0..n - 1 {
        print!("{} ", v[i]);
    }
    println!("{} ", v[n - 1]);
}

#[allow(dead_code)]
fn check(i: usize, j: usize, h: usize, w: usize) -> bool {
    i < h && j < w
}

#[derive(Debug)]
struct Piece {
    mark: char,
    y: i32,
    x: i32,
}

fn main() {
    let inputstatus = 1;

    let mut buf = String::new();
    let filename = "inputrust.txt";

    if inputstatus == 0 {
        let mut f = File::open(filename).expect("file not found");
        f.read_to_string(&mut buf)
            .expect("something went wrong reading the file");
    } else {
        std::io::stdin().read_to_string(&mut buf).unwrap();
    }

    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut cond = true;
    for i in 0..n {
        let a: usize = iter.next().unwrap().parse().unwrap();
        if a % 2 == 1 {
            cond = false;
            break;
        }
    } 
    
    println!("{}", if cond {"second"} else {"first"});

    // let n = iter.next().unwrap().parse().unwrap();

    // println!("{}", n);
    // println!("{:?}", cum_num);
}



Measured memory_bytes: 3136
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

string sa;

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	bool flag=true;
	cin>>sa;
	if((int)sa.size()%2!=0)flag=false;
	for(i=0;i*2<sa.size();i++){
		if(sa[i*2]!='h' || sa[i*2+1]!='i')flag=false;
	}
	if(flag)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

int main(){
  long a,array[101],i;
  cin>>a;
  array[0]=2;
  array[1]=1;
  for(i=2;i<=a;i++){
    array[i]=array[i-1]+array[i-2];
  }
  cout<<array[a]<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
inline int read(){
	int x=0;char ch=getchar();
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x;
}
int a,b,c,k;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>a>>b>>c>>k;
	int count = 0;
	while(b<=a)
		b*=2,count++;
	while(c<=b)
		c*=2,count++;
	if(count<=k)cout<<"Yes";
	
	else cout<<"No";
	return 0;
}



Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<stdio.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<set>
#include<math.h>
#include<stack>
#include<sstream>
#include<queue>
#include<list>
#include<iomanip>
#include<bitset>
#include<limits.h>
#include <bits/stdc++.h> //
#define MOD  1000000007
#define BIG  1000000007
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define vi vector<int>;
#define pi pair<int,int>;
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll;
using namespace std ; 
	
int main(){
	IO ; 
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	ll n ; 
	cin >> n ; 
	int c =0 ; 
	for(int i =0 ; i<n ; i++){
		int a ; 
		cin >> a ;
		while( !(a&1) ){
			a/=2 ; 
			c++ ;
		}
	}

	cout << c ;
	return 0 ; 
	}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define max(x, y) ((x) > (y) ? (x) : (y))
#define min(x, y) ((x) < (y) ? (x) : (y))
#define rep(i,a,m) for((i) = (a) ; (i) < (m) ; ++(i))
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.end(),x.begin()
#define sz(x) ((int)x.size())
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pi;
int a, b, c, i, j, k;
long long ans = 0LL;
#define N 100005
int over[N], M[N], K[N];
vector<set<int>> frnd(N), blck(N);

int diff(set<int> &a, set<int> &b){
    int cnt = 0;
    if (a.size() < b.size()) {
        for(auto x : a){
            if (b.find(x) != b.end()) cnt ++;
        }
    } else {
        for (auto x : b){
            if (a.find(x) != a.end()) cnt++;
        }
    }
    return cnt;
}

void dfs(int end, set<int> &visited){
    if (visited.find(end) != visited.end() || over[end]) return;
    visited.insert(end);
    over[end] = 1;
    for(auto x : frnd[end]) {
        dfs(x, visited);
    }
    return;
}

int main ()
{
	int n,m,k;
    int a,b;
    for(int i = 0; i <= n; ++ i) over[i] = 0, M[i] = 0;
    scanf("%d%d%d",&n,&m,&k);
    for(int i = 0; i <= n; ++ i) { 
        frnd[i] = set<int>(); 
        blck[i] = set<int>(); 
    }
    for(int i = 0; i < m; ++i){
        scanf("%d%d",&a,&b);
        frnd[a].insert(b);
        frnd[b].insert(a);
    }

    for(int i = 0; i < k; ++i){
        scanf("%d%d",&a,&b);
        if (frnd[a].find(b) == frnd[a].end()) {
            blck[a].insert(b);
            blck[b].insert(a);
        }
    }
    for(int i = 1; i <= n; ++ i){
        set<int> st;
        dfs(i,st);
        ll rem = 0LL;
        ll sum = st.size();
        //cout << sum << endl;
        ll df = 0LL;
        //cout << st.size() << endl;
        for(auto x : st){
            df = diff(st,blck[x]);
            //if (df <= 0) continue;
            //cout << x << " " << st.size() << " " << frnd[x].size() << endl;
            //for(auto f : frnd[x]){ cout << f << " | " ;} cout << endl;
            M[x] = sum - df - 1 - frnd[x].size(); 
        }
        over[i] = 1;
    }
    
    for(int i = 1; i <= n; ++ i){
        if (i != 1) cout << " ";
        cout << M[i];
    }
    cout << endl;
    
	return 0;
}

Measured memory_bytes: 34688
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a)  (a).begin(),(a).end()
//bitset<64>(x).count()
//fixed << setprecision(15) << 
int dx[4] = {-1, 0, 0, 1};
int dy[4] = {0, -1, 1, 0};
int main (){
  int r, c, sy, sx, gy, gx, ans=0;
  cin >> r >> c ;
  
  bool a[r+2][c+2] = {false};
  int dist[r+2][c+2] ;
  rep(i, r+2){
    rep(j, c+2){
      dist[i][j] = -1;
      a[i][j] = 0;
    }
  }
  char ca;
  rep(i, r){
    rep(j, c){
      cin >> ca;
      if(ca=='#'){
        a[i+1][j+1] = 0;
      } else{
        a[i+1][j+1] = 1;
        ans++;
      }
    }
  }
  sy =1;
  sx =1;
  gy =r;
  gx =c;
  queue<pair<int, int> > que;
  pair<int, int> pa;
  pa.first = sy;
  pa.second = sx;
  que.push(pa);
  dist[pa.first][pa.second] = 0;
  while(que.size()){
    pair<int, int> tmp;
    tmp = que.front();
    que.pop();
    rep(i, 4){
      pair<int, int> pre;
      pre.first = tmp.first +dx[i];
      pre.second = tmp.second +dy[i];
      if(dist[tmp.first +dx[i]][tmp.second +dy[i]]==-1&&a[tmp.first +dx[i]][tmp.second +dy[i]]==1){
        dist[tmp.first +dx[i]][tmp.second +dy[i]] = dist[tmp.first][tmp.second]+1;       
        que.push(pre);
      }
    }
  }
  if(dist[gy][gx]==-1)
    cout << -1 << endl;
  else
    cout << ans - dist[gy][gx] - 1<< endl;
}


Measured memory_bytes: 3456
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.List;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n, m, k;
		LinkedList<Integer> list;

		n = 2 * Integer.parseInt(br.readLine());
		list = new LinkedList<Integer>();
		for (int i = 0; i < n; i++) {
			list.add(i + 1);
		}
		m = Integer.parseInt(br.readLine());
		for (int i = 0; i < m; i++) {
			k = Integer.parseInt(br.readLine());
			if (k > 0) {
				cut(k, list);
			} else {
				reshuffle(list);
			}
		}
		for (int i = 0; i < n; i++) {
			System.out.println(list.get(i));
		}
	}

	static List<Integer> reshuffle(List<Integer> list) {
		LinkedList<Integer> temp = (LinkedList<Integer>) list;
		int n = temp.size() / 2;
		for (int i = 0; i < n; i++) {
			temp.add(i * 2 + 1, temp.remove(n + i));

		}
		return temp;
	}

	static List<Integer> cut(int k, List<Integer> list) {
		LinkedList<Integer> temp = (LinkedList<Integer>) list;
		for (int i = 0; i < k; i++) {
			temp.addLast(temp.removeFirst());
		}
		return temp;
	}
}

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

int main()
{
    double a;
    double b;
    cin >> a >> b;
    
    double answer;
    int answer2;
    int answer3;
        
    answer = (a + b)/2;
    answer2 = (a + b)/2;
    answer3 = answer2+1;
        
    if(answer != answer2){
    if(answer > answer2 || answer < answer3)
    {answer2 += 1;}
    }
    
    
    cout << answer2 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

const int INF = 1 << 30;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, N) cin >> B[i];
    vector<vector<int>> dp(1 << N, vector<int>(55, INF));
    dp[0][0] = 0;
    rep(mask, 0, 1 << N) {
        int sorted_card_num = __builtin_popcount(mask);
        vector<P> rest_cards;
        int now_pos = sorted_card_num;
        rep(i, 0, N) {
            if (!((mask >> i) & 1)) {
                rest_cards.emplace_back(i, now_pos++);
            }
        }
        rep(last_val, 0, 55) {
            if (dp[mask][last_val] == INF) {
                continue;
            }
            for (auto now_card : rest_cards) {
                int next_val = -1;
                if (abs(now_card.first - sorted_card_num) % 2 == 0) {
                    next_val = A[now_card.first];
                }
                else {
                    next_val = B[now_card.first];
                }
                if (next_val >= last_val) {
                    chmin(dp[mask | (1 << now_card.first)][next_val], dp[mask][last_val] + abs(now_card.second - sorted_card_num));
                }
            }
        }
    }
    int ans = INF;
    rep(s, 0, 55) {
        chmin(ans, dp[(1 << N) - 1][s]);
    }
    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 67840
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;

typedef long long ll;

int main()
{
	int n,p;
	int a;
	ll odd = 0;
	ll even = 0;
	ll er[55];
	er[0] = 1;
	for(int i = 1; i <= 50; i++)
	{
		er[i] = er[i-1]<<1;
	}
	cin>>n>>p;
	for(int i = 0 ; i < n; i++)
	{
		cin>>a;
		if( a & 1 )
			odd++;
		else
			even++;
	}
	ll ans = er[even];
	if( 0 == p)
	{
		{
			if( odd & 1) 
			{
				ans *= er[odd - 1];
			}
			else
			{
				if( odd > 0)
					ans *= er[odd - 1];
			}	
		}
	}
	else
	{
		if( 0 == odd)
			ans = 0;
		else
		{
			if( odd & 1)
			{
				ans *= er[odd - 1];
			}
			else
			{
				ans *= er[odd - 1];
			}
		}
	}
	cout<<ans<<endl;
	//printf("%I64d\n", ans);
	//system("pause");
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define N 55
using namespace std;
int main()
{
	char maps[N][N];
	int r,c;
	cin>>r>>c;
	bool cando=true;
	for(int i=0;i<r;i++)
	cin>>maps[i];
    for(int i=0;i<r;i++)
    {  if(cando==false)
         break;
    	for(int j=0;j<c;j++)
    	{
    	if(maps[i][j]=='#')
    	   {
    	   	if(i!=r)
    	   {
    	   	if(maps[i+1][j]=='#')
    	   	continue;
			   }
			   if(i!=0)
			   {
			   	if(maps[i-1][j]=='#')
			   	continue;
			   }
			   if(j!=c)
			   {
			   	if(maps[i][j+1]=='#')
			   	continue;
			   }
			   if(j!=0)
			   {
			   	if(maps[i][j-1]=='#')
			   	continue;
			   }
			   cando=false;
			   break;
		   }
        }
	}
	if(cando)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'

int main(int argc, char const *argv[]) {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    string s;
    cin>>s;
    for(int i=0;i<3;i++) {
        if(s[i]=='7') {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;

}


Measured memory_bytes: 3612
n = int(input())
a = list(map(int, input().split()))

abs_min = 10**10
minus_cnt = 0
for i in range(n):
    abs_min = min(abs(a[i]), abs_min)
    if a[i] < 0:
        minus_cnt += 1
        a[i] *= -1

if minus_cnt %2 == 0:
    print(sum(a))
else:
    print(sum(a) - abs_min*2)



Measured memory_bytes: 14332
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
LL a[3030];
LL dp[3030][3030];

LL calc(int l, int r){
    if(dp[l][r] > 0)return dp[l][r];
    LL ret;
    if((n - (r - l))%2 == 0){
        //先手
        if(r - l == 1)return a[l];
        ret = -HINF<LL>();
        ret = max(calc(l + 1, r) + a[l], calc(l, r - 1) + a[r - 1]);
    }else{
        //後手
        if(r - l == 1)return 0;
        ret = HINF<LL>();
        ret = min(calc(l + 1, r), calc(l, r - 1));
    }
    return dp[l][r] = ret;
}

LL sum = 0;
int main(){
    INIT;
    cin >> n;
    REP(i, n){
        cin >> a[i];
        sum += a[i];
    }
    LL x = calc(0, n);
    LL y = sum - x;
    cout << x - y << endl;
}

Measured memory_bytes: 72064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,W,h,w;
  cin >> H >> W;
  string s;
  int i=0;
  while (i < H*W){
    cin >> s;
    if (s=="snuke") break;
    i++;
  }
  h = i/W+1;
  w = i-(h-1)*W+1;
  char p = 'A';
  p = p - 1 + w;
  cout << p << h;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 10000005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define inf 1e9
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define mod 1000000007
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define ios ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
int a[1004];
int main()
{
    ios;
    ll n;
    cin>>n;
    ll ans=1;
    for(ll i=2;i<=n;i++)
    {
        if(a[i]==0)
        {
            for(int j=i;j<=n;j=j+i)
            {
                a[j]=1;
            }

            ll p=0;
            ll k=i;
            while(k<=n){p=p+n/k;k=k*i;}
            p++;
            ans=ans*p;
            ans=ans%mod;
        }
    }
    cout<<ans<<endl;



}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int S,h,m,s;
    scanf("%d",&S);
    h=S/3600;
    m=(S-3600*h)/60;
    s=S-3600*h-60*m;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }


int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
  
	map<string, vector<int>> m;
	int q;
	cin >> q;
	while(q--){
		int op;
		cin >> op;
		if(op == 0){
			string key;int x;
			cin >> key >> x;
			m[key].push_back(x);
		}else if(op == 1){
			string key;
			cin >> key;
			for(auto i:m[key])cout << i << '\n';
		}else if(op == 2){
			string key;cin >> key;
			m.erase(key);
		}else{
			string lef, rig;
			cin >> lef >> rig;
			auto pos1 = m.lower_bound(lef);
			auto pos2 = m.upper_bound(rig);
			while(pos1 != pos2){
				if(pos1->second.size()){
					for(auto i:pos1->second){
						cout << pos1->first << ' ' << i << '\n';
					}
				}
				pos1++;
			}
		}
			
	}
    return 0;
}



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

struct cell{
  long long id;
  long long kirei;
  long long oisii;
  long long ninki;
  long long sum[8];
};


bool comparecell0(const cell& left,const cell& right){
  return left.sum[0] > right.sum[0];
}
bool comparecell1(const cell& left,const cell& right){
  return left.sum[1] > right.sum[1];
}
bool comparecell2(const cell& left,const cell& right){
  return left.sum[2] > right.sum[2];
}
bool comparecell3(const cell& left,const cell& right){
  return left.sum[3] > right.sum[3];
}
bool comparecell4(const cell& left,const cell& right){
  return left.sum[4] > right.sum[4];
}
bool comparecell5(const cell& left,const cell& right){
  return left.sum[5] > right.sum[5];
}
bool comparecell6(const cell& left,const cell& right){
  return left.sum[6] > right.sum[6];
}
bool comparecell7(const cell& left,const cell& right){
  return left.sum[7] > right.sum[7];
}

int main(int argc, char *argv[])
{
  
  int N;
  int M;
  vector<cell> vec;
  long long result = 0;
  typedef bool (*FUNC_TABLE)(const cell &,const cell &);
  FUNC_TABLE func_table[] = {comparecell0,comparecell1,comparecell2,comparecell3,comparecell4,comparecell5,comparecell6,comparecell7};
  
  cin >> N;
  cin >> M;

  for (int i = 0; i < N; i++) {
    cell c;
    
    cin >> c.kirei;
    cin >> c.oisii;
    cin >> c.ninki;
    c.id = i;
    c.sum[0] = c.kirei+c.oisii+c.ninki;
    c.sum[1] = c.kirei+c.oisii-c.ninki;
    c.sum[2] = c.kirei-c.oisii+c.ninki;
    c.sum[3] = c.kirei-c.oisii-c.ninki;
    c.sum[4] = -c.kirei+c.oisii+c.ninki;
    c.sum[5] = -c.kirei+c.oisii-c.ninki;
    c.sum[6] = -c.kirei-c.oisii+c.ninki;
    c.sum[7] = -c.kirei-c.oisii-c.ninki;

      
    vec.push_back(c);
  }
  //  std::sort(vec.begin(),vec.end(),comparecell0);

  for (int i = 0; i <8 ; i++) {
    std::sort(vec.begin(),vec.end(),*func_table[i]);
    long long sum = 0;
    for(auto j = 0; j < M;j++){
      sum += vec[j].sum[i];
    }

    if (sum > result) {
      result = sum;
    }
  }
  cout << result << "\n";
  
}


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

count = 0
a = []

for i in range(n):
    a = list(map(int, input().split()))
    if a[0] == a[1]:
        count += 1
        if count == 3:
            print("Yes")
            break
        a = []
    else:
        count = 0
        a = []

if count != 3:
    print("No")


Measured memory_bytes: 9176
import sys
input = sys.stdin.readline
def main():
    N,M = map(int,input().split())
    H = tuple(map(int,input().split()))
    good = [1]*N
    for _ in range(M):
        a,b = map(int,input().split())
        a-=1;b-=1
        if H[a]<H[b]:
            good[a] = 0
        elif H[a] ==H[b]:
            good[a] = 0
            good[b] = 0
        else:
            good[b] = 0
    print(good.count(1))
if __name__ == "__main__":
    main()

Measured memory_bytes: 20256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = Math.min(n * a, b);
        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF pow(10,10)
#define M 1000000007


int main(void){
    ll h,w; cin >> h >> w;
    vector<string> maze;
    string s(w+2,'#');
    maze.push_back(s);
    for(int i=0;i<h;i++){
        string t; cin >> t; t = "#"+t+"#";
        maze.push_back(t);
    }
    maze.push_back(s);

    // for(int i=0;i<maze.size();i++){
    //     for(int j=0;j<maze[i].size();j++){
    //         cout << maze[i][j] << ' ';
    //     }cout << endl;
    // }cout << endl;

    vector<vector<ll>>cnt(h+2,vector<ll>(w+2,0));
    for(int i=1;i<=h;i++)if(maze[1][i]=='.')cnt[1][i]=1; else break;
    for(int i=1;i<=w;i++)if(maze[i][1]=='.')cnt[i][1]=1; else break;

    for(int i=2;i<=h;i++){
        for(int j=2;j<=w;j++){
            if(maze[i][j]=='.'){
                cnt[i][j] = (cnt[i-1][j] + cnt[i][j-1])%M;
            }
        }
    }

    // for(int i=0;i<maze.size();i++){
    //     for(int j=0;j<maze[i].size();j++){
    //         cout << cnt[i][j] << ' ';
    //     }cout << endl;
    // }cout << endl;

    cout << cnt[h][w] << endl;
    return 0;
}

Measured memory_bytes: 10112
#include<bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < (int)(n); i++)
#define sum(a) accumulate(a.begin(),a.end(),0LL)
#define put(i) cout<<fixed<<i<<endl
using namespace std;
using ll = long long;

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

    ll ans = 0;
    sort(a.begin(),a.end(),greater<ll>());
    priority_queue<ll> q;
    q.push(a[0]);
    for(long long i = 1; i < n; i++){
        ans += q.top(); q.pop();
        q.push(a[i]);
        q.push(a[i]);
    }
    put(ans);
}

Measured memory_bytes: 6940
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  string a;
  cin  >> a;
  if (a[0] == '7' or a[1] == '7' or a[2] == '7') {
    cout << "Yes";
  } else {
    cout << "No";
  }
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
//配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


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

int main() {
  int n;
  cin >> n;
  string S[101];
  rep(i, 0, n) cin >> S[i];

  bool frag = true;
  rep(i, 0, n) {
    rep(j, i+1, n) {
      if (S[i] == S[j]) frag = false;
    }
  }
  rep(i, 0, n-1) {
    if (S[i][S[i].size()-1] != S[i+1][0]) frag = false;
  }
  if (frag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main() {
	string s[4];
	s[0] = "Sunny";
	s[1] = "Cloudy";
	s[2] = "Rainy";
	s[3] = "Sunny";
	string ss;
	cin>>ss;
	rep(i,0,4){
		if(ss==s[i]){
			cout << s[i+1] << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
/**
 *     author: qodjf
 *     created: 04.18.2020 02:04:55
 */
#include <vector>
#include <cmath>
#include <iostream>
using namespace std;

using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  vector<ll> dp(N + 10, 0);

  ll sum = 0;
  for (int i = N - 1; i >= 1; i -= 2) {
    sum += a[i];
    dp[i - 1] = max(a[i - 1] + dp[i + 1], sum);
  }
  for (int i = N - 3; i >= 0; i -= 2) {
    dp[i] = max(dp[i + 2] + a[i], dp[i + 1]);
  }
  cout << dp[0] << endl;
}


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

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())

int main()
{
	int n,i,j;
	cin>>n;
    int*H=new int[n+1];

    for(i=1;i<=n;++i)
        cin>>H[i];
    	
    int *dp=new int[n+1];
    dp[1]=0;dp[2]=dp[1]+abs(H[2]-H[1]);
    for(i=3;i<=n;++i)
    {
    	dp[i]=min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]));
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n;
    cin>>n;
    
    cout << "ABC" << n <<endl;
    
    return 0;
}



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BNotFound solver = new BNotFound();
        solver.solve(1, in, out);
        out.close();
    }

    static class BNotFound {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            String s = in.string();
            boolean[] a = new boolean[26];
            s.chars().forEach(c -> a[c - 'a'] = true);
            for (char c = 'a'; c <= 'z'; c++) {
                if (!a[c - 'a']) {
                    out.println(c);
                    return;
                }
            }
            out.println("None");
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 26836
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>

using namespace std;

bool is_keyence(const string& s)
{
  string keyence = "keyence";
  if (keyence == s) return true;
  auto pos = s.find(keyence);
  if (pos == 0 or pos == s.size() - keyence.size()) return true;
  size_t begin = 0;
  for (; s[begin] == keyence[begin]; ++begin);
  size_t end = s.size() - 1;
  for (size_t i = keyence.size() - 1; s[end] == keyence[i]; --end, --i);
  return begin + (s.size() - 1 - end) >= keyence.size();
}

int main()
{
  string s;
  cin >> s;
  cout << (is_keyence(s) ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d %d", $H, $W, $K);
$map = [];
for ($i = 0; $i < $H; $i++) {
    fscanf(STDIN, "%s", $c);
    $map[$i] = str_split($c);
}
$HW = pow(2, $H+ $W);
$ans = 0;
for ($i = 1; $i < $HW; $i++) {
    $cnt = 0;
    $selH = intdiv($i, pow(2, $W));
    $selW = $i - pow(2, $W) * $selH;
    if ($selH === 0 || $selW === 0) continue;
    $cnt = 0;
    $chk = 0;
    for ($y = 0; $y < $H; $y++) {
        for ($x = 0; $x < $W; $x++) {
            $str_y = str_pad(decbin($selH), $H, "0", STR_PAD_LEFT);
            $str_x = str_pad(decbin($selW), $W, "0", STR_PAD_LEFT);
            if ($str_y[$y] === '1') {
                if ($str_x[$x] === '1') {
                    $chk++;
                    if ($map[$y][$x] === '#') $cnt++;
                }
            }
        }
    }
    if ($cnt === $K) $ans++;
}
printf("%d", $ans);


Measured memory_bytes: 16220
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod2 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9

int h,w,k;
string dtob(int num,int rlen)
{
    string r="";
    while(num>0)
    {
        r=to_string(num%2)+r;
        num/=2;
    }
    int rem=rlen-r.length();
    string t(rem,'0');
    return t+r;
}
int main()
{
    cin >> h >> w >> k;
    vector<string>v(h);
    for(int i=0;i<h;i++)
        cin >> v[i];
    int ans=0;
    for(int i=0;i<pow(2,h);i++)
    {
        string s1=dtob(i,h),s2;
        for(int j=0;j<pow(2,w);j++)
        {
            s2=dtob(j,w);
            int t=0;
            for(int l=0;l<h;l++)
            {
                if(s1[l]=='1')
                    continue;
                for(int m=0;m<w;m++)
                    if(s2[m]=='0' and v[l][m]=='#')
                        t+=1;
            }
            if(t==k)
                ans+=1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4164
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
def euc(p):
    return sum([abs(i-j)**p for i,j in zip(a,b)])**(1/p)
for i in range(1,4):
    print("{:.8f}".format(euc(i)))
print("{:.8f}".format(max([abs(i-j) for i,j in zip(a,b)])))


Measured memory_bytes: 5656
# -*- coding: utf-8 -*-
import math
A, B, H, M = map(int, input().split())

H_deg = 30 * H + 0.5 * M
M_deg = 6 * M

HM_rad = math.radians(min(abs(H_deg - M_deg), 360 - abs(H_deg - M_deg)))
print(math.sqrt((A ** 2) + (B ** 2) - 2 * A * B * math.cos(HM_rad)))

Measured memory_bytes: 9572
#include "bits/stdc++.h"
using namespace std;

int main() {
	int n, a[200000];
	cin >> n;
	long long snuke_sum = 0;
	long long araiguma_sum = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		snuke_sum += a[i];
	}
	long long ans = LONG_MAX;
	for (int i = 0; i < n - 1; ++i) {
		snuke_sum -= a[i];
		araiguma_sum += a[i];
		ans = min(ans, abs(snuke_sum - araiguma_sum));
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
// general helpers
const debug = (message?: any, ...optionalParams: any[]) => {
  if (process.env.LOCAL_DEBUG === '1') console.log(message, ...optionalParams)
}

// helpers
const parseLines = (
  lines: string[]
): any => {
  const N = +lines[0]
  const distances = lines.slice(1, 1 + N).map(line => line.split(' ').map(l => +l))
  const obj = { N, distances }
  debug(obj)
  return obj
}

// solver
export const solve = (lines: string[]): string => {
  let { distances } = parseLines(lines)
  let isReach = true
  for (let d of distances) {
    const [t, x, y] = d
    if (t % 2 === 0 && (x + y) % 2 !== 0) {
      isReach = false
      break
    } else if (t % 2 === 1 && (x + y) % 2 !== 1) {
      isReach = false
      break
    } else if ((x + y) > t) {
      isReach = false
      break
    }
  }
  return isReach ? "Yes" : "No"
}

// main
const main = (lines: string[]) => {
  console.log(solve(lines))
}

// exec main function for submit
if (process.env.LOCAL_DEBUG !== '1') {
  const { stdin: input, stdout: output } = process
  input.resume()
  input.setEncoding('utf8')
  const lines: string[] = []
  require('readline')
    .createInterface({ input, output })
    .on('line', (line: string) => lines.push(line))
    .on('close', () => main(lines))
}


Measured memory_bytes: 55104
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        
        if(a > 9 || b > 9){
            System.out.println("-1");
        }else{
            System.out.println(a*b);
        }
    }
}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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

    cout << (N-2)/(K-1) + 1 << endl;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
  int n,x,t; cin>> n >> x >> t;
  if(n%x==0){
    int l =n/x;
    cout<<t*l<<endl;
  }
  else{
  int l= n/x+1;
    cout<<t*l<<endl;
  }
}
  

Measured memory_bytes: 3584
#include <iostream>
#include <map>
#include <string>

int main()
{
    int count = 0;
    std::cin >> count;

    std::map<std::string, int> map;
    for (auto lp = 0; lp < count; ++lp)
    {
        std::string val;
        std::cin >> val;

        map[val] = 0;
    }

    std::cout << map.size();
}

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

int main() {
    int n; cin >> n;
    long long sum = 0;
    map <int, int> m;

    for(int i = 0; i < n; i++) {
        int x; cin >> x;
        m[x]++;
        sum += x;
    }

    int q; cin >> q;
    for(int i = 0; i < q; i++) {
        long long b1, b2; cin >> b1 >> b2;
        sum -= m[b1] * b1;
        sum += m[b1] * b2;
        m[b2] += m[b1];
        m[b1] = 0;
        cout << sum << "\n";
    }

    return 0;
}


Measured memory_bytes: 8056
#include <iostream>
#include<vector>
#include <math.h>
#include<stdio.h>
#include <climits>
#include<algorithm>
#include<string>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define LL  long long 
#define Pi 3.14159265358979;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int x,y;
	int i = 0, j = 0,k = 0;//ループ用配列
	int n;
	int count = 0;
	int ans = 0;

	cin >> x >> y;

	if (2 * x <= y and y <= 4 * x and y % 2 == 0) cout << "Yes" << "\n";
	else cout << "No" << "\n";
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  ll s = a + b;
  ll ans = n/s * a;
  ll m = n % s;
  ans += min(m, a);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		StringTokenizer tokenizer;
		String line;
		String result;
		while ((line = reader.readLine()) != null) {

			int[] lines = new int[line.length()];
			for (int i = 0; i < line.length(); i++) {
				lines[i] = line.codePointAt(i);
			}
			int t = 0;
			while (true) {

				char[] cs = new char[lines.length];
				for (int i = 0; i < lines.length; i++) {
					cs[i] = (char) lines[i];
				}

				result = String.valueOf(cs);
				if (result.contains("the") || result.contains("this")
						|| result.contains("that")) {
					break;
				}
				for (int i = 0; i < lines.length; i++) {
					if (lines[i] >= 'a') {
						lines[i] = lines[i] + 1;
						if (lines[i] > 'z')
							lines[i] -= 26;
					}
				}
				
			}
			System.out.println(result);

		}
	}
}

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

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

  int ans=0;
  for(int i=0; i<=k; i++){
    for(int j=0; j<=k; j++){
      if(0<=s-i-j && s-i-j<=k)
      ans++;
    }
  }
  cout<<ans<<endl;
}

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

int main() {
  int pay,yen,n;cin >> pay >> yen;
  n = pay%500;
  if(n<=yen){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  

}


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

#define int long long

using namespace std;



int32_t main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);

        string s;
        cin>>s;

        stack < char > me;

        for(int i=0;i<s.length();i++)
        {
                if(s[i]=='0')
                        me.push(s[i]);
                else if(s[i]=='1')
                        me.push(s[i]);
                else if(me.size())
                        me.pop();
        }

        vector < char > ans;

        while(!me.empty())
        {
                ans.push_back(me.top());
                me.pop();
        }
        reverse(ans.begin(),ans.end());
        for(int i=0;i<ans.size();i++)
        {
                cout<<ans[i];
        }
        cout<<endl;

        return 0;

}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD


ll N,D[101];
ll i, j, k,ans;



int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        scanf("%lld",&D[i]);
    }
    fornum(i,0,N){
        fornum(j,i+1,N){
            ans+=D[i]*D[j];
        }
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int, M: int, x: "List[int]", y: "List[int]", z: "List[int]"):
    ret = -float('inf')
    for b in range(8):
        c = [1] * 3
        for k in range(3):
            if (1 << k) & b:
                c[k] = -1
        s = []
        for i in range(N):
            s.append(x[i] * c[0] + y[i] * c[1] + z[i] * c[2])
        s.sort(reverse=True)
        ret = max(ret, sum(s[:M]))
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    z = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        z[i] = int(next(tokens))
    solve(N, M, x, y, z)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
import numpy as np
#入力
N = int(input())
A = list(map(int, input().split()))
#カウンターテーブルの用意
count=[0]*(1000001)
for a in A:count[a]+= 1

#全体のgcdが1でないならnot coprime
if np.gcd.reduce(A)!=1:
    print("not coprime")
#A[x] % i == 0 && A[y] % i == 0 となるx, y が存在しないならpairwise coprime
elif np.all([sum(count[i::i])<=1 for i in range(2,10**6+1)]):
    print("pairwise coprime")
else:
    print("setwise coprime")


Measured memory_bytes: 150544