akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 59;

struct edge
{
  int to, cost;
};

int H, W, N;
vector< edge > g[200000];
int64 v[200000];

int main()
{
  cin >> H >> W;
  cin >> N;
  for(int i = 0; i < N; i++) {
    int h, w, c;
    cin >> h >> w >> c;
    --h, --w;
    g[h].emplace_back((edge) {w + H, c});
    g[w + H].emplace_back((edge) {h, c});
  }
  fill_n(v, H + W, INF);

  for(int i = 0; i < H + W; i++) {
    if(v[i] != INF) continue;
    queue< int > que;
    v[i] = 0;
    que.emplace(i);
    int64 latte = INF, malta = INF;
    while(!que.empty()) {
      int p = que.front();
      que.pop();
      if(p < H) latte = min(latte, v[p]);
      else malta = min(malta, v[p]);
      for(auto &e : g[p]) {
        auto vv = e.cost - v[p];
        if(v[e.to] == INF) {
          v[e.to] = vv;
          que.emplace(e.to);
        } else if(v[e.to] != vv) {
          cout << "No" << endl;
          return (0);
        }
      }
    }
    if(latte + malta < 0) {
      cout << "No" << endl;
      return (0);
    }
  }

  cout << "Yes" << endl;
}

Measured memory_bytes: 12800
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    while(1)
    {
        int n;
        int sta[35]={0};
        sta[0]=1;
        cin>>n;
        if(n==0)break;
        for(int i=0;i<n;i++)
        {
            sta[i+1]+=sta[i];
            sta[i+2]+=sta[i];
            sta[i+3]+=sta[i];
        }
        cout<<(((sta[n]+9)/10)+364)/365<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import sys

N = int(input())
S = input()

temp = 1
ansarray = []
counter = 0
if N == 1:
    print(1)
    sys.exit()


for i in range(1, N):
    counter += 1
    if S[i] == S[i - 1]:
        temp += 1
    else:
        ansarray.append(temp)
        temp = 1
    if counter == N-1:
        ansarray.append(temp)
        print(len(ansarray))

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


public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			int[] s = new int[n], t = new int[n];
			for(int i=0;i<n;i++){
				String[] r = sc.next().split(":"), v = sc.next().split(":");
				s[i] = Integer.parseInt(r[0])*3600+Integer.parseInt(r[1])*60+Integer.parseInt(r[2]);
				t[i] = Integer.parseInt(v[0])*3600+Integer.parseInt(v[1])*60+Integer.parseInt(v[2]);
			}
			Arrays.sort(s); Arrays.sort(t);
			int res = n;
			for(int i=0;i<n;i++)for(int j=0;j<i;j++){
				if(t[j]<=s[i]){
					res--; t[j] = 1<<29; break;
				}
			}
			System.out.println(res);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K; cin >> N >> K;
    ll ans = LLINF;
    ll X[N], Y[N]; rep(i, N) cin >> X[i] >> Y[i];
    rep(left, N){
        rep(right, N){
            rep(down, N){
                rep(up, N){
                    int acc = 0;
                    ll xl = X[left], xr = X[right], yd = Y[down], yu = Y[up];
                    rep(i, N){
                        if(xl <= X[i] && X[i] <= xr && yd <= Y[i] && Y[i] <= Y[up]) acc++;
                    }
                    if(acc >= K) ans = min(ans, (xr-xl)*(yu-yd));
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());

    int a, b, c;
    cin >> a >> b >> c;

    if (a == b && b == c) {
        cout << 1 << endl;
    } else if (a == b || b == c || c == a) {
        cout << 2 << endl;
    } else {
        cout << 3 << endl;
    }
    
}


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

int main() {
    int R, C;
    cin >> R >> C;
    int table[R + 1][C + 1];
    for (int i = 0; i < R; i++) {
        for (int j = 0; j < C; j++) cin >> table[i][j];
    }

    for (int i = 0; i < R; i++) {
        int rlast = 0;
        for (int j = 0; j < C; j++) rlast += table[i][j];
        table[i][C] = rlast;
    }
    for (int j = 0; j <= C; j++) {
        int clast = 0;
        for (int i = 0; i < R; i++) clast += table[i][j];
        table[R][j] = clast;
    }
    for (int i = 0; i <= R; i++) {
        for (int j = 0; j <= C; j++) {
            if (j) cout << " ";
            cout << table[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3132
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<P, int> PP;
const double PI = 3.14159265358979323846;
const double esp = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+17 + 10;

const int maxN = 100001;

//0:indexed
class RMQ{
private:
	int n;
	P dat[maxN * 4];

	//[a,b),[l,r) //(Max,Min)
	P rec(int a, int b, int k, int l, int r){
		if (b <= l || r <= a)return P(-infi, infi);
		if (a <= l && r <= b)return P(dat[k].first, dat[k].second);
		else {
			P vl = rec(a, b, 2 * k + 1, l, (l + r) / 2), vr = rec(a, b, 2 * k + 2, (l + r) / 2, r);
			return P(std::max(vl.first, vr.first), std::min(vl.second, vr.second));
		}
	}

public:
	void init(int x){
		n = 1;
		while (n < x)n *= 2;
		rep(i, 2 * n - 1)dat[i] = P(-infi, infi);
	}

	void update(int k, int a){
		k += n - 1;
		dat[k] = P(a, a);
		while (k > 0){
			k = (k - 1) / 2;
			dat[k].first = std::max(dat[2 * k + 1].first, dat[2 * k + 2].first);
			dat[k].second = std::min(dat[2 * k + 1].second, dat[2 * k + 2].second);
		}
	}

	//[a,b] //(Max,Min)
	P query(int a, int b){
		return rec(a, b + 1, 0, 0, n);
	}
};

int n, q;
RMQ r;

int main(){
	std::cin >> n >> q;
	r.init(n);
	rep(i, q){
		int a, b, c;
		std::cin >> a >> b >> c;
		if (a == 0)r.update(b, c);
		else {
			int ans = r.query(b, c).second;
			std::cout << (ans == infi ? 2147483647 : ans) << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4292
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <climits>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
typedef long long int ll;
using namespace std;

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

    set<int> w, r;

    rep(i, n) {
        char c;
        cin >> c;
        if (c == 'W') w.insert(i);
        else r.insert(i);
    }

    if (w.size() == 0 || r.size() == 0) {
        cout << 0 << endl;
        return 0;
    }

    int cnt = 0;

    while (1) {
        auto itrW = w.begin();
        auto itrR = r.end();
        itrR--;

        if (*itrW > *itrR) break;


        r.insert(*itrW);
        w.insert(*itrR);
        w.erase(itrW);
        r.erase(itrR);

        cnt++;
        
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 12916
#include<stdio.h>

int main(void){
    int n;
    int a[200000];
    
    scanf("%d",&n);
    
    scanf("%d",a);
    for(int i=1;i<n;i++){
        scanf("%d",a+i);
        a[i-1]=a[i]-a[i-1];
    }
    int y=a[0],z=a[0];
    for(int i=0;i<n-2;i++){
        if(z+a[i+1]>a[i+1]){
            z+=a[i+1];
        }else{
            z=a[i+1];
        }
        
        if(z>y){
            y=z;
        }
    }
    
    printf("%d\n",y);
    
    return 0;
    
}



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

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

  int can = true;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    // 偶数について、3 or 5 のどちらでも割り切れないものがあるかどうか
    if (a % 2 == 0 && (a % 3 != 0 && a % 5 != 0)) {
      can = false;
    }
  }

  cout << (can ? "APPROVED" : "DENIED") << endl;
  return 0;
}



Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using vl = vector<long long>;
using vs = vector<string>;
using ii = vector<vector<long long>>;
int main() {
	ll a;
	cin >> a;
	ll count = 0;
	vl x(a);
	for (int i = 0; i < a; i++) {
		cin >> x[i];
	}
	for (ll i = 0; i < a; i++) {
		for (ll j = 0; j < 100; j++) {
			if (x[i] % 2 == 1) {
				break;
			}
			else {
				count++;
				x[i] = x[i] / 2;
			}
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 3644
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define msg(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define pri(a) cout << a << endl;

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

  ll n,ans=0;
  cin >> n;
  //ll n,k,ans=0;
  //cin >> n >> k;
  // string s;
  // cin >> s;

  // vint v(n);
	// rep(i,n){
	// 	cin >> v[i];
	// }

  //昇順
  //std::sort(v.begin(),v.end());

  // for(int i=1;i<n;i++){
  //   for(int j=1;j<n;j++){
  //     if(i!=j && i+j==n){
  //       ans++;
  //     }
  //   }
  // }
  if(n%2==0){
      cout << n/2-1 << endl;
  }
  else{
    cout << n/2 << endl;
  }


}

Measured memory_bytes: 256
#include <stdio.h>
int max(int, int);
int min(int, int);
int main(){
    int sizu, minv, maxv;
    int i, j;
    scanf("%d",&sizu);
    int A[sizu];

    for(i = 0; i < sizu; i++){
        scanf("%d",&A[i]);
    }

    minv = A[0];
    maxv = -2000000000;

    for(j = 1; j < sizu; j++){
        maxv = max(maxv,A[j]-minv);
        minv = min(minv, A[j]);
    }

    printf("%d\n",maxv);

    return 0;
}

int max(int a, int b){
    if(a > b){
        return a;
    }else{
        return b;
    }
}

int min(int a, int b){
    if(a < b){
        return a;
    }else{
        return b;
    }
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

	int n;
	string x;
	
	cin>>n>>x;
	
	string a="";
	string b="";
	
	for(int i=0;i<n/2;i++) a+=x[i];
	for(int i=n/2;i<n;i++) b+=x[i];
	
	if(a==b) cout<<"Yes";
	else cout<<"No";
					                                				
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	
	return 0;
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) (a).begin(),(a).end()

template<typename T1, typename T2> inline void chkmin(T1 & x, const T2 & y) {if (y < x) x = y;}
template<typename T1, typename T2> inline void chkmax(T1 & x, const T2 & y) {if (x < y) x = y;}

#define int ll
int k;

void read() {
	cin >> k;
}

void run() {
	int now = 0;
	for (int i = 1; i <= k + 100; i++) {
		now *= 10;
		now += 7;
		now %= k;
		if (now == 0) {
			cout << i << endl;
			exit(0);
		}
	}
	cout << -1 << endl;
}

void write() {

}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(20), cout.setf(ios::fixed);
	read();
	run();
	write();
	return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
template <typename T>
T gcd(T m, T n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main(){
  ll H,N;
  cin>>H>>N;
  vector<ll> A(N);
  FOR(i,N){
    cin>>A[i];
    H-=A[i];
  }
  putYN(H<=0);
    
  
  return 0;
}

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

int main(){
  int H,W;
  int x,y;
  cin >> H >> W;
  vector<string> canvas(50);
  for(int i=0; i<H; i++){
    cin >> canvas.at(i);
  }

  vector<int> dx = {1,0,-1,0};
  vector<int> dy = {0,1,0,-1};

  bool can = true;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(canvas.at(i).at(j) == '#'){
        bool can2 = false;
        for(int k=0; k<4; k++){
          x = i + dx.at(k);
          y = j + dy.at(k);
          if(x >= 0 && x < H && y >= 0 && y < W &&
             canvas.at(x).at(y) == '#'){
               can2 = true;
             }
        }
        if(!can2){
          can = false;
          break;
        }
      }
    }
    if(!can){
      break;
    }
  }

  if(can){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
N=int(input())
divisor=[0]*(N+1)
count=[0]*(N+1)
for i in range(2,N+1):
    if divisor[i]:
        continue
    j=1
    while i*j<=N:
        divisor[i*j]=1
        now=i*j
        while now%i==0:
            count[i]+=1
            now//=i
        j+=1
ans=1
M=10**9+7
for i in range(N+1):
        ans*=(count[i]+1)
        ans%=M
print(ans)

Measured memory_bytes: 9192
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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


void solve(string S){
    int c0=0, c1=0;
    REP(i, S.size()){
        if(S[i]=='0')c0++;
        else if(S[i]=='1')c1++;
    }
    cout<<2*min(c0,c1)<<endl;
}

int main(){
    string S;
    cin>>S;
    solve(S);
    return 0;
}


Measured memory_bytes: 512
n,a,b = map(int, input().split())

def F(n,a,b):
    #ab間にある要素の数が偶数
    if (b-a)%2==0:
        return (b-a)//2
    #左端で止まる
    tmp = []
    #左側からみて
    x = (a-1)+(b-1)+1
    tmp.append(x//2)
    #右側からみて
    x = (n-a)+(n-b)+1
    tmp.append(x//2)
    return min(tmp)

print(F(n,a,b))

Measured memory_bytes: 3064
//                             ¯\_(ツ)_/¯   
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mma,ava,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(),(a).end()
#define ll long long
 
 
void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
 
const int N=2e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;
int n;
int a[100];

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();

	scanf("%d",&n);

	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	ll curr = 1000;
	
	for(int i=1;i<n;i++){
		if(a[i]>a[i-1]){
			curr = (curr/a[i-1])*a[i] + curr % a[i-1];
		}
	}

	printf("%lld\n",curr );
	
}

//CBA

Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <fstream>
#include <algorithm>
#include <cmath>
using namespace std;

// Tenki
int main()
{
    int a, b;
    cin >> a >> b;
    int count = ceil(((double)b - 1) / (a - 1));

    cout << count << endl;
    return 0;    
}

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

public class Main {
  
   public static void main(String[]abc){
      Main ans = new Main();
      int sol = ans.solve();
      System.out.println(sol);
   }
  
   private int solve() {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int K = sc.nextInt();
      int [] array = new int[N+1];
      for(int i=1;i<=N;i++) {
         array[i] = sc.nextInt();        
      }
      int [] dp = new int[N+1];
      Arrays.fill(dp, Integer.MAX_VALUE);
      dp[1]=0;
      dp[0]=0;
      for(int i=2;i<=N;i++){
         for(int j=i-1;j>=1 && i-j<=K;j--){
            dp[i] = Math.min(dp[j]+ Math.abs(array[j]-array[i]), dp[i]);
         }
      }
	//System.out.println(Arrays.toString(dp));
     return dp[N];
      
      
   }
}

Measured memory_bytes: 59448
import sys
input = sys.stdin.readline
def print_ans(N, Q, S, arr):
    """Test Case
    >>> print_ans(8, 3, "ACACTACG", [[3, 7], [2, 3], [1, 8]])
    2
    0
    3
    """
    t = [0] * (N+1)
    for i in range(N):
        t[i+1] = t[i] + (1 if S[i:i+2] == "AC" else 0)
    for ar in arr:
        print(t[ar[1] - 1] - t[ar[0] - 1] )

if __name__ == '__main__':
    N, Q = map(int, input().rstrip().split())
    S = input().rstrip()
    arr = [list(map(int, input().rstrip().split())) for _ in range(Q)]
    print_ans(N, Q, S, arr)


Measured memory_bytes: 32208
import numpy

N, K = [int(i) for i in input().split()]
S = input()

strList = [0, 0]
oneNum = 0
zeroNum = 0
if S[0] == "1":
    strList.append(0)

for i in range(N):
    if S[i] == "1":
        oneNum += 1
        if zeroNum != 0:
            strList.append(zeroNum)
        zeroNum = 0
    if S[i] == "0":
        zeroNum += 1
        if oneNum != 0:
            strList.append(oneNum)
        oneNum = 0

if oneNum != 0:
    strList.append(oneNum)
if zeroNum != 0:
    strList.append(zeroNum)

strList.append(0)
strList.append(0)

strCumsum = numpy.cumsum(strList).tolist()

ans = 0
for i, s in enumerate(strCumsum):
    if i % 2 == 1:
        ans = max(ans, strCumsum[i] - strCumsum[max(0, i - K * 2 - 1)])

print(ans)



Measured memory_bytes: 17756
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
sat = b[a[0]-1]
for i in range(n-1):
    sat += b[a[i+1]-1]
    if a[i+1] == a[i] + 1:
        sat += c[a[i+1]-2]
print(sat)

Measured memory_bytes: 3064
count = gets.to_i

hash = {'AC' => 0, 'WA' => 0, 'TLE' => 0, 'RE' => 0}

count.times do
  result = gets.chomp
  hash[result] = hash[result] + 1
end

puts "AC x #{hash['AC']}"
puts "WA x #{hash['WA']}"
puts "TLE x #{hash['TLE']}"
puts "RE x #{hash['RE']}"

Measured memory_bytes: 14296
#include<iostream>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main(){
    string s,p;
    cin >> s >> p;
    s+=s;
    int n=s.find(p);
    if(n>=0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3228
# -*- coding: utf-8 -*-

N,K=map(int,input().split())

ans=0
M=1000000007

S=[0]*(N+2)

for i in range(1,N+1):
    S[i+1]=S[i]+i

for i in range(K,N+2):
    U=S[N+1]-S[N-i+1]
    B=S[i]
    ans+=U-B+1
    ans%=M

print(ans)







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


int main(){

	ll n;
	cin>>n;
	ll a[n+1],b[n+1],c[n+1];
	ll dp[n+1][3];
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i]>>c[i];

	}
       dp[1][0]=a[1];
       dp[1][1]=b[1];
       dp[1][2]=c[1];

     for(int i=2;i<=n;i++){
         dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
         dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
         dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
     }



     cout<<max(dp[n][2],max(dp[n][0],dp[n][1]))<<endl;

}

Measured memory_bytes: 4864
# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def main():
    n = int(input())
    arr = []
    for i in range(n):
        arr.append(input())
    print(len(set(arr)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 53504
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;
using T = tuple<int, int, int>;

int main() {
        int n;
        while (scanf("%d", &n) && n) {
                getchar();
                map<string, int> mp;
                int nodes = 0;
                vector<T> es;
                for (int i = 0; i < n; i ++) {
                        char ss[1024], tt[1024];
                        int val;
                        scanf("1 %s = 10^%d %s", ss, &val, tt);
                        getchar();
                        string s = ss;
                        string t = tt;
                        if (!mp.count(s)) mp[s] = nodes ++;
                        if (!mp.count(t)) mp[t] = nodes ++;
                        es.push_back(make_tuple(mp[s], mp[t], val));
                }
                vector<vector<pair<int, int>>> g(nodes);
                for (int i = 0; i < n; i ++) {
                        int a, b, d;
                        tie(a, b, d) = es[i];
                        g[a].emplace_back(b, d);
                        g[b].emplace_back(a, -d);
                }
                vector<bool> used(nodes, false);
                vector<int> dist(nodes);
                bool ans = true;
                function<void (int, int)> dfs = [&](int u, int d) {
                        used[u] = true;
                        dist[u] = d;
                        for (auto e : g[u]) {
                                if (!used[e.first]) {
                                        dfs(e.first, d + e.second);
                                } else if (dist[e.first] != d + e.second) {
                                        ans = false;
                                }
                        }
                };
                for (int i = 0; i < nodes; i ++) if (!used[i]) {
                        dfs(i, 0);
                }
                puts(ans ? "Yes" : "No");
        }
        return 0;
}



Measured memory_bytes: 3296
H,W = map(int,input().split())

a = [input() for _ in range(H)]

for i in range(H):
    for j in range(W):
        if a[i][j] == "#":
            x = i-1
            y = j+1

            if 0 <= x < H and 0 <= y < W:
                if a[x][y] == "#":
                    print("Impossible")
                    exit()
            
            x = i+1
            y = j-1
            if 0 <= x < H and 0 <= y < W:
                if a[x][y] == "#":
                    print("Impossible")
                    exit()
print("Possible")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  REP(i, 4) {
    if(s[i]=='+') ans++;
    else ans--;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n, h, w;
	ll ans = 0;
	cin >> n >> h >> w;

	REP(i, n){
		if (i + h > n) break;
		REP(j, n){
			if (j + w > n) break;
			ans++;
		}
	}

	cout << ans << endl;


}


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

int x[1010],y[1010];

int main(void){
	int w,h,n;
	cin >> w >> h >> n;
	rep(i,n) cin >> x[i] >> y[i];
	
	ll ans=0LL;
	rep(i,n-1){
		int px=x[i],py=y[i];
		int cx=x[i+1],cy=y[i+1];
		if(cx<px) swap(cx,px),swap(cy,py);
		ll cur=abs(cx-px)+abs(cy-py);
		if(py<cy) cur-=min(abs(cx-px),abs(cy-py));
		ans+=cur;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3092
from math import factorial
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


N = int(input())
D = {}
L = [[]for _ in range(N)]
count = 0
for i in range(N):
    L[i] = list(input())
    L[i].sort()
    L[i] = tuple(L[i])
    if L[i] in D:
        D[L[i]] = D[L[i]] + 1
        if D[L[i]] == 2:
            D[L[i]] = D[L[i]] + 1
    else:
        D[L[i]] = 0
for key in D:
    if D[key] > 2:
        count += cmb(D[key],2)
    else:
        count += D[key]

print(count)


Measured memory_bytes: 25860
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

C = gets.chomp

puts (C.ord + 1).chr


Measured memory_bytes: 14372
import Text.Printf
import Data.Char

main :: IO()
main = do
  [n] <- map read . words <$> getLine
  printf "%d" $ minimum $ map (\(x, y) -> convVal x + convVal y) [(x, n - x) | x <- [1 .. (n - 1)]]

convVal :: Int -> Int
convVal n = sum nList
  where nList = map digitToInt $ show n


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

using s64 = long long;

const int MaxN = 500000;
const int MaxM = 500000;
const int M = 998244353;

inline int modpow(int a, const int &n)
{
	int res = 1;
	for (int i = n; i; i >>= 1)
	{
		if (i & 1)
			res = (s64)res * a % M;
		a = (s64)a * a % M;
	}
	return res;
}

int n, m;

int fact[MaxM + 1];
int rfact[MaxM + 1];

inline int binom(int n, int m)
{
	return m < 0 ? 0 : (s64)fact[n] * rfact[m] % M * rfact[n - m] % M;
}

int main()
{
	cin >> n >> m;

	fact[0] = 1;
	for (int i = 1; i <= m; ++i)
		fact[i] = (s64)fact[i - 1] * i % M;
	rfact[m] = modpow(fact[m], M - 2);
	for (int i = m; i; --i)
		rfact[i - 1] = (s64)rfact[i] * i % M;

	int res = 0;
	for (int i = max(n, (m + 1) / 2); i <= m; ++i)
	{
		int j = m - i - (i * 2 == m);
		int t = i - n + 1;
		res = (res + binom(i + j, j) - binom(i + j, j - t)) % M;
	}

	cout << (res + M) % M << endl;

	return 0;
}

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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int n;
int p, q;
VI ps, qs;

signed main() {
    cin >> n;
    REP(i, n) {
        int a;
        cin >> a;
        p += a * pow(10, n - i - 1);
    }
    REP(i, n) {
        int a;
        cin >> a;
        q += a * pow(10, n - i - 1);
    }
    VI pi;
    VI qi;
    REP(i, n) { pi.push_back(i + 1); }
    REP(i, n) { qi.push_back(i + 1); }

    do {
        int a = 0;
        int b = 0;
        REP(i, n) {
            a += pow(10, i) * pi[i];
            b += pow(10, i) * qi[i];
        }
        ps.push_back(a);
        qs.push_back(b);
    } while (next_permutation(pi.begin(), pi.end()) && next_permutation(qi.begin(), qi.end()));

    sort(ALL(ps));
    sort(ALL(qs));

    auto x = lower_bound(ALL(ps), p) - ps.begin();
    auto y = lower_bound(ALL(qs), q) - qs.begin();

    cout << abs(x - y) << endl;
    return 0;
}

Measured memory_bytes: 1276
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, M = map(int, readline().split())
A = list(map(int, readline().split()))
thresh = sum(A) / (4 * M)
cnt = sum([a >= thresh for a in A])

if cnt >= M:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
import sys
import bisect
import numpy as np

x = int(input())
bs = [i for i in range(-100, 200)]
bspow = list(map(lambda x: x**5, bs))
# print(bspow)

for a in range(200):
    b_calc = a**5 - x
    index = bisect.bisect_left(bspow, b_calc)
    if(bspow[index] == b_calc):
        print(a, bs[index])
        sys.exit(0)


Measured memory_bytes: 27004
from fractions import gcd
from functools import reduce

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(num):
    return reduce(lcm_base, num)

n = int(input())
t = [int(input()) for i in range(n)]

t = list(set(t))
print(lcm_list(t))

Measured memory_bytes: 5460
package main

import (
	"bufio"
	"fmt"
	"math"
	"math/rand"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int
var t float64

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	d := intScanner()
	c := intSliceScanner(26)
	s := make([][]int, d)
	for i := 0; i < d; i++ {
		s[i] = intSliceScanner(26)
	}
	best := -mod
	bestSchedule := make([]int, d)
	changeNum := 1
	for x := 0; x < 1; x++ {
		schedule := make([]int, d)
		for i := 0; i < d; i++ {
			schedule[i] = rand.Intn(26)
		}
		score := calcScore(schedule, c, s, d)
		t = float64(score) * 100.
		for y := 0; y < 150000; y++ {
			changes := make([]int, changeNum)
			pres := make([]int, changeNum)
			for i := 0; i < changeNum; i++ {
				changes[i] = rand.Intn(d)
				pres[i] = schedule[changes[i]]
				schedule[changes[i]] = rand.Intn(26)
			}
			nextScore := calcScore(schedule, c, s, d)
			if prob(score, nextScore) >= math.Abs(rand.Float64()) {
				score = nextScore
			} else {
				for i := 0; i < changeNum; i++ {
					schedule[changes[i]] = pres[i]
				}
			}
			if nextScore >= best {
				best = nextScore
				copy(bestSchedule, schedule)
			}
			t *= 0.999
		}
	}
	for i := 0; i < d; i++ {
		fmt.Println(bestSchedule[i] + 1)
	}
}
func calcScore(schedule []int, c []int, s [][]int, d int) int {
	score := 0
	last := make([]int, 26)
	for i, v := range schedule {
		score += s[i][v]
		for j, _ := range last {
			last[j]++
		}
		last[v] = 0
		for j, v := range last {
			score -= c[j] * v
		}
	}
	return score
}
func prob(before int, after int) float64 {
	if before <= after {
		return 1.0
	}
	return math.Exp((float64(after) - float64(before)) / float64(t))
}


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

long long solve(const string &s, int k) {
  int n = s.size();
  long long res = 0;
  long long sum = 0;
  int d_count = 0;
  int m_count = 0;
  for (int i = 0; i < n; ++i) {
    if (i >= k) {
      switch (s[i - k]) {
        case 'D':
          sum -= m_count;
          --d_count;
          break;
        case 'M':
          --m_count;
          break;
      }
    }

    switch (s[i]) {
      case 'D':
        ++d_count;
        break;
      case 'M':
        ++m_count;
        sum += d_count;
        break;
      case 'C':
        res += sum;
        break;
    }
  }

  return res;
}

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int nq;
  cin >> nq;
  for (int i = 0; i < nq; ++i) {
    int k;
    cin >> k;
    cout << solve(s, k) << '\n';
  }
  return 0;
}


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

x = 0
y = 0

for c in a:
    if c % 2 == 1:
        x += 1
    else:
        y += 1

if x == 0 and p == 1:
    print(0)
    exit()
elif x == 0:
    print(2 ** y)
    exit()
else:
    print(2 ** y * (2 ** (x-1)))


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

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

    int len = s.length()-2;
    cout << s[0] << len << s[s.length()-1] << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;

#define pll pair<ll,ll>
#define ff first
#define snd second
#define pb push_back
#define vll vector<ll>
#define vpll vector<pll>
#define endl "\n"
#define MOD 1000000007
using namespace std;
string s;
ll const N = 1e5+1;

bool ispal(ll st,ll end)
{
        while(st<end)
        {
                if(s[st]!=s[end])
                return 0;
                st++;
                end--;
        }
        return 1;
}

void solve()
{
   
   cin>>s;
   
   ll len = s.length();
   ll f_end = ((len-1)/2)-1;
   ll s_st  = ((len+3)/2)-1;
   if(ispal(0,s.length()-1) && ispal(0,f_end) && ispal(s_st,s.length()-1))
   {
           cout<<"Yes\n";
           return;
   }
   
   cout<<"No\n";
}
 
int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
	    int t=1;
	    //cin>>t;
	    while(t--)
	    {
	            solve();
	    }
	    return 0;
}

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

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int>a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    int g=a[0];
    for(int i=0;i<n;i++){
        g=__gcd(g,a[i]);
    }
    int mx=*max_element(a.begin(),a.end());
    if(k%g==0 && k<=mx) cout<<"POSSIBLE";
    else cout<<"IMPOSSIBLE";


}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <iomanip>

using namespace std;
typedef long long ll;

const ll INF = 1e18 + 5;

void solve() {
	string a, b;
	cin >> a >> b;
	vector<vector<int>> dp(a.length() + 1, vector<int>(b.length() + 1, 0));

	int highest = 0;
	for (int i = 0; i < (int)a.size(); i++) {
		highest = 0;
		for (int j = 0; j < (int)b.size(); j++) {
			if (a[i] == b[j]) {
				if (i == 0 || j == 0) {
					highest = 1;
					dp[i][j] = 1;
				}
				else {
					highest = max(dp[i - 1][j - 1] + 1, highest);
					dp[i][j] = highest;
				}
			}
			else {
				if (i != 0) highest = max(highest, dp[i - 1][j]);
				dp[i][j] = highest;
			}
		}
	}

	/*
	for (int i = 0; i < (int)a.size(); i++) {
		for (int j = 0; j < (int)b.size(); j++) {
			cout << dp[i][j] << " ";
		}
		cout << "\n";
	}
	*/
	

	string s;
	/*
	for (int j = 0; j < b.size(); j++) {
		int rownum = a.size() - 1;
		if (dp[rownum][0] == 1 && j == 0) s.push_back(b[0]);
		else if (dp[rownum][j] - dp[rownum][j - 1] == 1) {
			s.push_back(b[j]);
		}
	}
	*/

	int start = b.size() - 1;
	int row = a.size() - 1;
	while (row >= 0) {
		bool vis = false;
		for (int j = start; j >= 0; j--) {
			if (j != 0) {
				if (dp[row][j] - dp[row][j - 1] == 1) {
					bool ok = true;
					while (ok) {
						if (row != 0) {
							if (dp[row][j] == dp[row - 1][j]) row--;
							else ok = false;
						}
						else ok = false;
					}
					s.push_back(b[j]);
					row--;
					start = j - 1;
					vis = true;
					break;
				}
			}
			else {
				if (dp[row][j] == 1) {
					s.push_back(b[j]);
					row = -1;
					break;
				}
			}
		}
		if (!vis) row--;
	}

	reverse(s.begin(), s.end());
	cout << s;

}


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

	solve();

	/*
	int t;
	cin >> t;
	while (t) {
		solve();
		cout << "\n";
		t--;
	}
	*/

}



Measured memory_bytes: 38492
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N >> M;
	cout << (M + N - 1) / M << endl;
	return 0;
}

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

int main(){
  int n;
  cin >> n; 
  vector<int> l(n),L(100000);
  for(int i=0;i<n;i++){
    cin >> l.at(i);
    L.at(l.at(i))++;
  }
  
  sort(l.begin(),l.end());
  long long ans =0;
  
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      for(int k=j+1;k<n;k++){
        if(l.at(k) < l.at(i) + l.at(j)){
          ans++;
        }
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 2020;
vector<int> g[N];
int d[N][N];
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
 
    memset(d, 255, sizeof(d));
    int n, x, y;
    cin >> n >> x >> y;
    x--;
    y--;
 
    for (int i = 1; i < n; i++) {
        g[i].push_back(i-1);
        g[i-1].push_back(i);
    }
    g[x].push_back(y);
    g[x].push_back(x);
 
    for (int i = 0; i < n; i++) {
        vector<int> q;
        q.push_back(i);
        d[i][i] = 0;
        int qj = 0;
        while (qj < q.size()) {
            int curr = q[qj];
            qj++;
            int cd = d[i][curr];
            for (int nxt : g[curr]) {
                if (d[i][nxt] == -1) {
                    d[i][nxt] = cd + 1;
                    q.push_back(nxt);
                }
            }
        }
    }
 
    map<int, int> res;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            res[d[i][j]]++;
        }
    }
    for (int i = 1; i < n; i++) {
        cout << res[i] << "\n";
    }
 
    return 0;
}


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

int w,n ;
int x,y ;

char otaku ;

int LenLine[31] ;

int main()
{
	cin >> w ;
	cin >> n ;

	for( int i = 0 ; i < w ; i ++ )
	{
		LenLine[i+1] = i+1 ;
	}

	for( int i = 0 ; i < n ; i ++ )
	{
		cin >> x >> otaku >> y ;

		swap( LenLine[x] , LenLine[y] ) ;
	}

	for( int i = 0 ; i < w ; i ++ )
	{
		cout << LenLine[i+1] << endl ;
	}

	return 0 ;
}

Measured memory_bytes: 1160
n=int(input())
if n<105:
  print(0)
else:
  ans=1
  for i in range(107,n+1,2):
    count=0
    for j in range(1,i+1):
      if i%j==0:
        count=count+1
    if count==8:
      ans=ans+1
  print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9+7
typedef long long int ll;
const int maxn = 1000000;
ll mod = INF;


int main(){

    string s;
    cin >> s;
    ll sum=0;
    for(int i=0;i<s.size();i++){
        sum+=(int)s[i]-(int)'0';
    }

    if(sum%9==0){
        cout << "Yes"<<endl;
    }else{
        cout << "No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int n=s.size();
  vector<int>a(4);
  for(int i=0;i<n;i++){
    char p=s.at(i);
    if(p=='N')a.at(0)++;
    else if(p=='S')a.at(1)++;
    else if(p=='W')a.at(2)++;
    else a.at(3)++;
  }
  int x=0;
  if(a.at(0)>0){
    if(a.at(1)>0){
      if(a.at(2)*a.at(3)>0)x++;
      else if(a.at(2)==0&&a.at(3)==0)x++;
    }
  }
  else{
    if(a.at(1)==0){
      if(a.at(2)*a.at(3)>0)x++;
      else if(a.at(2)==0&&a.at(3)==0)x++;
    }
  }
  if(x>0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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


#define ll unsigned long long
#define FASTIO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

const ll maxn = 1e8;
const int MOD = 1e9+7;

ll power(ll x, ll int y){
    int res = 1; // Initialize result

    while (y > 0) {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res * x + MOD)%MOD;

        // n must be even now
        y = y >> 1; // y = y/2
        x = (x * x)%MOD; // Change x to x^2
    }
    return res;
}


int main(){
    FASTIO
    int n;cin >> n;
    int arr[n];
    int sum = 0;
    for(int i=0;i<n;i++){
        cin >> arr[i];
        sum += arr[i];
        if(i > 0) arr[i] += arr[i-1];
    }
    int ans = INT_MAX;
    for(int i=0;i<n;i++){

        int s1 = arr[i];
        int s2 = sum - s1;
        ans = min(ans,abs(s1-s2));
    }
    cout << ans;


}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(void){
    int N;
    scanf("%d", &N);
    int *H;
    H = (int *)calloc(N,sizeof(int));
    for(int i=0; i<N; i++){
        scanf("%d", &H[i]);
    }
    int max=H[0];
    int place, frag=1;
    for(int i=0; i<N; i++){
        if(H[i]>max){
            max = H[i];
            place = i;
        }
        if(max-H[i]>1){
            frag=0;
            break;
        }
    }
    if(frag==0)
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}

Measured memory_bytes: 512