akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

ll inf=1ll<<60,mod=1000000007;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int i,a[100000],n,ans=0;
	cin>>n;
	for (i=0;i<n;i++){
		cin>>a[i];
	}
	for (i=0;i<n;i++){
		if (a[i]==i+1){
			if (a[i+1]==i+2){
				ans++;
				i++;
			}
			else {
				ans++;
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ve vector
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
struct point
{
    ll x,y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll h,w;
    cin>>h>>w;
    ve <string> arr(h);
    rep (i,0,h)
    {
        cin>>arr[i];
    }
    ll dp[h][w];
    rep (i,0,h)
    {
        rep (j,0,w)
        {
            dp[i][j]=0;
        }
    }
    if (arr[0][0]=='#')
        dp[0][0]=1;
    rep (i,1,w)
    {
        if (arr[0][i]=='#'&&arr[0][i-1]=='.')
        {
            dp[0][i]=dp[0][i-1]+1;
        }
        else
        {
            dp[0][i]=dp[0][i-1];
        }
    }
    rep (i,1,h)
    {
        if (arr[i][0]=='#'&&arr[i-1][0]=='.')
        {
            dp[i][0]=dp[i-1][0]+1;
        }
        else
        {
            dp[i][0]=dp[i-1][0];
        }
    }
    rep (i,1,h)
    {
        rep (j,1,w)
        {
            ll ans1,ans2;//ans1 left, ans2 up
            if (arr[i][j]=='#'&&arr[i-1][j]=='.')
            {
                ans1=dp[i-1][j]+1;
            }
            else
            {
                ans1=dp[i-1][j];
            }
            if (arr[i][j]=='#'&&arr[i][j-1]=='.')
            {
                ans2=dp[i][j-1]+1;
            }
            else
            {
                ans2=dp[i][j-1];
            }
            dp[i][j]=min(ans1,ans2);
        }
    }
    cout<<dp[h-1][w-1]<<"\n";
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define N 1005
using namespace std;
int n,m,a[N],ans;

int main(){
  cin>>n>>m;
  for(int i=0;i<n;i++)cin>>a[i];
  int idx=0;
  while(1){
    int mina=100,maxa=0;
    for(int i=0;i<m;i++){
      mina=min(mina,a[idx]);
      maxa=max(maxa,a[idx]);
      idx++;
      if(idx==n)idx=0;
    }
    ans+=maxa-mina;
    if(!idx)break;
  }
  cout<<ans<<endl;
  return 0;
}

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

int main(){
	int m,f,r;
	while(1){
		cin >> m >> f >> r;
		if((m == f && f == r) && r == -1)break;
		if(m == -1 || f == -1) cout << "F";
		else if(m+f>=80)cout << "A";
		else if(m+f<80 && m+f>=65)cout << "B";
		else if(m+f<65 && m+f>=50)cout << "C";
		else if(m+f<50 && m+f>=30 && r>=50)cout << "C";
		else if(m+f<50 && m+f>=30 && r<50)cout << "D";
		else cout << "F";

		cout << endl;		
	}

	return 0;
}

Measured memory_bytes: 3056
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONG_INF 800000000000000000
int dp[300000][50] = {};
int main() {
	int n, a, b;
	cin >> n >> a >> b;
	vector<pair<int, int>> wow;
	REP(i, n) {
		int c, d,e;
		cin >> c >> d >> e;
		wow.push_back(make_pair(e,d*a - b*c));
	}
	for (int i = 0;i < 300000;++i) {
		for (int q = 0;q < 50;++q) {
			dp[i][q] = 1000000000;
		}
	}
	sort(wow.begin(), wow.end());
	for (int i = 0;i < n;++i) {
		for (int q = 100;q < 300000;q++) {
			if (q + wow[i].second <= 300000 && q + wow[i].second >= 0) {
				dp[q + wow[i].second][i + 1] = min(dp[q][i] + wow[i].first, dp[q + wow[i].second][i + 1]);
			}
			dp[q][i + 1] = min(dp[q][i], dp[q][i + 1]);
		}
		dp[150000 + wow[i].second][i + 1] = min(wow[i].first,dp[150000+wow[i].second][i+1]);
	}
	if (dp[150000][n] != 1000000000) {
		cout << dp[150000][n] << endl;
	}
	else cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 58880
#include <stdio.h>
#define mod 998244353
typedef long long ll;

ll fact[300001];

ll mul(ll a, ll b) {
  return a * b % mod;
}

ll rev(ll a) {
  ll ans = 1, b = mod - 2;
  while(b) {
    if(b & 1) ans = mul(ans, a);
    a = mul(a, a), b >>= 1;
  }
  return ans;
}

ll cmb(ll a, ll b) {
  return mul(fact[a], mul(rev(fact[b]), rev(fact[a - b])));
}

ll gcd(ll a, ll b) {
  ll t;
  while(b) t = a % b, a = b, b = t;
  return a;
}

int main(void) {
  ll i, j, k, n, a, b, ans = 0;
  scanf("%lld%lld%lld%lld", &n, &a, &b, &k);
  fact[0] = 1;
  for(i = 1; i <= n; ++i) fact[i] = mul(fact[i - 1], i);
  for(i = 0; i <= n && a * i <= k; ++i) if(!((k - a * i) % b) && (k - a * i) / b <= n) {
    ans += mul(cmb(n, i), cmb(n, (k - a * i) / b));
    ans %= mod;
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 2560
wordlist = []
m = ""
num = gets.to_i

for i in 1..num do
  	word = gets.chomp 

  	if wordlist.include?(word)
            puts "No"
            exit
        end
  wordlist.push(word)

  if i > 1
  	if word[0] != m
            puts "No"
            exit
    end
  end
  m = word[-1]
end
puts "Yes"

Measured memory_bytes: 1788
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_3-C: Doubly Linked List

#include <cstdio>

template <typename T>
class DoublyLinkedList {
  struct Node {
    Node* prev_;
    Node* next_;
    T x_;
  };
  Node sentinel_;
public:
  DoublyLinkedList()
  {
    sentinel_.prev_ = sentinel_.next_ = &sentinel_;
  }

  void insert_elem_to_first(const T& x)
  {
    Node* np = new Node();
    np->x_ = x;
    np->prev_ = &sentinel_;
    np->next_ = sentinel_.next_;
    np->prev_->next_ = np;
    np->next_->prev_ = np;
  }

  void delete_first_elem(const T& x)
  {
    delete_node(search_first_elem(x));
  }

  void delete_first_node()
  {
    delete_node(sentinel_.next_);
  }

  void delete_last_node()
  {
    delete_node(sentinel_.prev_);
  }
private:
  void delete_node(Node* np)
  {
    if (np) {
      np->next_->prev_ = np->prev_;
      np->prev_->next_ = np->next_;
      delete np;
    }
  }

  Node* search_first_elem(const T& x) const
  {
    Node* np = sentinel_.next_;
    for (;np != &sentinel_; np = np->next_) {
      if (np->x_ == x) return np;
    }
    return nullptr;
  }
public:
  void print(const char* sep=" ") const
  {
    const char* out_sep = "";
    for (const Node* np = sentinel_.next_; np != &sentinel_; np = np->next_) {
      printf("%s%d", out_sep, np->x_);
      out_sep = sep;
    }
    puts("");
  }
};

int main()
{
  unsigned int n;
  std::scanf("%d", &n);
  DoublyLinkedList<int> list;

  for (auto i = 0U; i < n; ++i) {
    char buf[11+1]; // max_length == "deleteFirst".size()+1('\0')
    int x;
    std::scanf("%11s", buf);
    if (buf[0] == 'i') { // insert x
      std::scanf("%d", &x);
      list.insert_elem_to_first(x);
    } else if (buf[6] == 'F') { // deleteFirst
      list.delete_first_node();
    } else if (buf[6] == 'L') { // deleteLast
      list.delete_last_node();
    } else { // (buf[6] == '\0') // delete x 
      std::scanf("%d", &x);
      list.delete_first_elem(x);
    }
  }
  list.print();
}

// eof

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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    int n;
    cin >> n >> s;
    for(int i=0; i<s.length(); i++){
        int c = (int)s[i];
        c -= (int)'A';
        c += n;
        c %= 26;
        c += (int)'A';
        s[i] = (char)c;
    }
    cout << s;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

using namespace std;

int main()
{
    int X, t;
    if (scanf("%d%d", &X, &t) < 2) return 0;

    printf("%d\n", X - t < 0 ? 0 : X - t);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long  LL;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define F first
#define S second
inline int read(){
    int x = 0; char ch = getchar(); bool positive = 1;
    for (; !isdigit(ch); ch = getchar())	if (ch == '-')	positive = 0;
    for (; isdigit(ch); ch = getchar())	x = x * 10 + ch - '0';
    return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
    }
    write(a); puts("");
}
const int N=100005;
int k,dist[N],ans,oo=1000000005;
priority_queue<pair<int,int> > q;
#include<string>
int main(){
	ans=oo;
    cin>>k;
    for(int i=0;i<k;i++)dist[i]=oo;
    dist[0]=0;
    q.push(mp(0,0));
    while(!q.empty()){
        pair<int,int> zs=q.top(); q.pop();
        zs.first=-zs.first;
        if(zs.first>dist[zs.second])continue;
        for(int i=0;i<10;i++){
        	int u=(zs.second*10+i)%k;
			if(zs.second!=0&&u==0)ans=min(ans,dist[zs.second]+i);
			if(dist[zs.second]+i<dist[u]){
            dist[u]=dist[zs.second]+i;
            q.push(mp(-dist[u],u));
        }}
    }
    cout<<ans<<endl;
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

//グラフ関連
struct Edge {
    ll to, cap, rev;
    Edge(ll _to, ll _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

class UnionFind {
    vector<int> data;
    int num;

  public:
    UnionFind(int size) : data(size, -1), num(size) {}
    bool unionSet(int x, int y) {
        x = root(x);
        y = root(y);
        if(x != y) {
            if(data[y] < data[x])
                swap(x, y);
            data[x] += data[y];
            data[y] = x;
            num--;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
    int numSet() {
        return num;
    }
};

void solve() {
    ll n, m;
    cin >> n >> m;

    vec<ll> a(n);
    REP(i, n) {
        cin >> a[i];
    }

    UnionFind uni(n);
    REP(i, m) {
        ll x, y;
        cin >> x >> y;
        uni.unionSet(x, y);
    }

    if(uni.numSet() == 1) {
        cout << 0 << en;
        return;
    }

    map<ll, multiset<ll>> mp;
    multiset<ll> st;
    REP(i, n) {
        int r = uni.root(i);
        mp[r].insert(a[i]);
        st.insert(a[i]);
    }

    ll ans = 0;
    for(auto i : mp) {
        ll cost = *i.second.begin();
        st.erase(st.find(cost));
        ans += cost;
    }

    ll k = mp.size() - 2;
    auto it = st.begin();
    while(k and it != st.end()) {
        ans += *it;
        k--;
        it++;
    }

    if(k == 0)
        cout << ans << en;
    else
        cout << "Impossible" << en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}


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

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

  int ans=0;
  for(int i=0; i<n; i++){
    int x;
    cin>>x;
    ans+=min(x, k-x)*2;
  }
  cout<<ans<<endl;
}


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

string str;

int main(void){
	cin >> str;
	int n=str.size();
	string s2="";
	for(int i=0;i<n;i++){
		if(str[i]!='x'){
			s2+=str[i];
		}
	}
	bool flag=true;
	int n2=s2.size();
	for(int i=0;i<n2/2;i++){
		if(s2[i]!=s2[n2-i-1])flag=false;
	}
	if(!flag){
		printf("-1\n");
		return 0;
	}
	int l=0,r=n-1;
	int cnt=0;
	while(l<r){
		if(str[l]==str[r]){
			l++;
			r--;
		}else{
			if(str[l]=='x'){
				cnt++;
				l++;
			}else{
				cnt++;
				r--;
			}
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n,m,k;
int a,b;
vi v[100001];
int l[100001],g[100001],ans[100001];
int cnt,bian;
void dfs(int x){
	l[x]=bian;
	cnt++;
	rep(i,v[x].size()){
		if(l[v[x][i]]!=-1)
		continue;
		dfs(v[x][i]);
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m>>k;
	memset(l,-1,sizeof(l));
	rep(i,m){
		cin>>a>>b;
		a--,b--;
		v[a].pb(b);
		v[b].pb(a);
	}
	rep(i,n){
		if(l[i]==-1){
			cnt=0;
			dfs(i);
			g[bian]=cnt;
			bian++;
		}
	}
	rep(i,n){
		ans[i]=g[l[i]]-v[i].size()-1;
	}
	rep(i,k){
		cin>>a>>b;
		a--,b--;
		if(l[a]==l[b]){
			ans[a]--;
			ans[b]--;
		}
	}
	rep(i,n)
	cout<<ans[i]<<" ";
	re 0;
}


Measured memory_bytes: 7552
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int x, a; cin >> x >> a;
  int ans = x < a ? 0 : 10;

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


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

int main() {
  int N,sum=0;
  cin>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++)
  {cin>>vec.at(i);}
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  
  for(int i=0;i<N;i++){
    if(i%2 == 0)
    { sum+=vec[i];}
    else
    { sum-=vec[i];}
  }
  cout<<sum<<endl;
}


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

int main() {
	int N;
	cin >> N;
	vector<pair<int, int>> seat(N);
	int ans = 0;
	for (int i = 0;i < N;++i) {
		cin >> seat[i].first >> seat[i].second;
		ans += seat[i].second - seat[i].first + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A, B, C = [[int(i) for i in input().split()] for j in range(3)]
score = 0
for i in range(len(A)):
    score += B[A[i] - 1]
    if i > 0 and A[i] - A[i-1] == 1:
        score += C[A[i-1] - 1]
print(score)

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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

int main()
{

	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n,m;
	cin >> n;
	map<int,int> ck;
	rep(i,n){
		int d; cin >>d;
		ck[d]++;
	}
	bool ok=true;
	cin >> m;
	rep(i,m){
		int t; cin >>t;
		if( !ck.count(t) || ck[t] <=0 ) ok=false;
		ck[t]--;
	}
	cout <<(ok? "YES":"NO") <<"\n";
	return 0;

}


Measured memory_bytes: 9600
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

# (int(x) for x in input().split())
s = input().strip()
if s[-1] == 's':
    print(s + 'es')
else:
    print(s + 's')

Measured memory_bytes: 64932
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

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

	FastScanner sc;
	
	void run() {
		sc = new FastScanner();
		int n = sc.nextInt();
		int ans = 0;
		for (int i = 1; i <= n; i++) {
			ans += i;
		}
		
		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: 7892
#include <bits/stdc++.h>

using namespace std;

template<class INT>
INT mod_pow(INT n, INT k, INT p){
    if (k == 0)
        return 1;
    if (k % 2 == 0){
        INT res = mod_pow(n, k / 2, p);
        return res * res % p;
    }
    return mod_pow(n, k - 1, p) * n % p;
}

template<class INT>
vector<INT> fact(INT n, INT p=INT(1e9 + 7)){
    vector<INT> f(n + 1);
    f[0] = 1;
    for (INT i = 0; i < n; i++)
        f[i + 1] = (i + 1) * f[i] % p;
    return f;
}

template<class INT>
vector<INT> invfact(INT n, const vector<INT> &f, INT p=INT(1e9 + 7)){
    vector<INT> inv(n + 1);
    inv[n] = mod_pow<INT>(f[n], p - 2, p);
    for (INT i = n; i > 0; i--)
        inv[i - 1] = inv[i] * i % p;
    return inv;
}

template<class INT>
INT comb(INT a, INT b, const vector<INT> &f, const vector<INT> &invf, INT p=(INT)(1e9 + 7)){
    if (a < b)
        return 0;
    if (a < 0 or b < 0)
        return 0;
    return f[a] * invf[b] % p * invf[a - b] % p;
}

int main(){
    int64_t n, a, b;
    cin >> n >> a >> b;
    int64_t p = 1e9 + 7;
    int64_t ca = 1;
    for (int64_t i = 1; i <= a; i++){
        ca *= n - i + 1;
        ca %= p;
        ca *= mod_pow(i, p - 2, p);
        ca %= p;
    }
    int64_t cb = 1;
    for (int64_t i = 1; i <= b; i++){
        cb *= n - i + 1;
        cb %= p;
        cb *= mod_pow(i, p - 2, p);
        cb %= p;
    }
    cout << (mod_pow(2L, n, p) - (ca + cb + 1) % p + p) % p << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	D = inputInt()
	C = inputList()
	S = []
	ans = []
	for i in range(D):
		s = inputList()
		S.append(s)
		ans.append(17)

	for i in range(D):
		print(ans[i])



#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 73072
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define MODB 998244353
#define INF 9223372036854775807
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
signed main()
{
  int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x;
std::vector< pair<int,int> > v(x);
rep(i,x){
  std::cin >> v[i].first>>v[i].second;
}
sort(all(v),compare_by_b);
rep(i,x){
  if(n+v[i].first<=v[i].second){
    n+=v[i].first;
  }else{
    std::cout << "No" << '\n';
    return 0;
  }
}
std::cout << "Yes" << '\n';
}


Measured memory_bytes: 3328
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

signed main() {
	string s;
	cin >> s;
	rep(i, (1 << 4)) {
		int bit[5];
		rep(j, 4) bit[j] = i / (1 << j) % 2;
		string now = "";
		rep(j, 4) {
			if (bit[j]) now += 'A';
			if (j == 0) now += "KIH";
			else if (j == 1) now += 'B';
			else if (j == 2) now += "R";
		}
		if (now == s) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <stack>
using namespace std;

inline int getint()
{
	static char c;
	while ((c = getchar()) < '0' || c > '9');

	int res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;
}

template <class T>
inline void relax(T &a, const T &b)
{
	if (b > a)
		a = b;
}

typedef long long s64;

const int MaxN = 5000;
const int MaxM = 200;

int n, m;
int len[MaxN + 1];
int val[MaxN + 1][MaxM + 1];

s64 delta[MaxN + 1];

int sta[MaxM + 1][MaxN + 1];
int sta_n[MaxM + 1];

inline int query(int i, int k = 0)
{
	return sta[i][sta_n[i] - k];
}

int main()
{
	cin >> n >> m;
	for (int i = 1; i < n; ++i)
		len[i] = getint();
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
			val[i][j] = getint();

	s64 res = 0;
	for (int l = n; l >= 1; --l)
	{
		s64 sum = 0;
		for (int i = 1; i <= m; ++i)
		{
			while (sta_n[i] && val[query(i)][i] <= val[l][i])
			{
				if (sta_n[i] > 1)
				{
					int p = query(i);
					int q = query(i, 1);
					delta[q] -= val[q][i] - val[p][i];
				}

				--sta_n[i];
			}

			sta[i][++sta_n[i]] = l;

			if (sta_n[i] > 1)
			{
				int q = query(i, 1);
				delta[q] += val[q][i] - val[l][i];
			}

			sum += val[l][i];
		}

		s64 dist = 0;
		for (int r = l; r <= n; ++r)
		{
			sum += delta[r];
			relax(res, sum - dist);
			dist += len[r];
		}
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 6528
#include <cstdio>

int main(){
    char b[2];
    scanf("%c", b);
    if (b[0]=='A') printf("T");
    if (b[0]=='T') printf("A");
    if (b[0]=='C') printf("G");
    if (b[0]=='G') printf("C");
    return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;


int main() {
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ll a, b, k;
	cin >> a >> b >> k;
	ll t = min(a, k);
	a -= t;
	k -= t;
	t = min(b, k);
	b -= t;
	cout << a << " " << b;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)

N = int(input())
G = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    G[u].append((v, w))
    G[v].append((u, w))

C = [-1 for _ in range(N)]


def dfs(pos, color):
    C[pos] = color
    for e in G[pos]:
        if C[e[0]] != -1:
            continue
        # odd
        if e[1] & 1:
            c = 1 - color
            dfs(e[0], c)
        # even
        else:
            c = color
            dfs(e[0], c)


dfs(0, 0)
for i in range(N):
    print(C[i])


Measured memory_bytes: 79488
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n;
string s;

signed main() {
	int i;
	
	cin >> s;
	n = s.length();
	
	int bc = 0;
	int ans = 0;
	for (i = n - 1; i >= 0; ) {
		if (i >= 1 && s[i - 1] == 'B' && s[i] == 'C') {
			i -= 2;
			bc++;
		}
		else if (s[i] == 'A') {
			ans += bc;
			i--;
		}
		else {
			bc = 0;
			i--;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	long long ans=1,sol=0;
	for(int i=1;i<=n;i++){
		ans=(ans*10)%1000000007;
	}
	sol=(sol+ans)%1000000007;
	ans=2;
		for(int i=1;i<=n;i++){
		ans=(ans*9)%1000000007;
	}
	sol=(1000000007+sol-ans)%1000000007;
	ans=1;
		for(int i=1;i<=n;i++){
		ans=(ans*8)%1000000007;
	}
	sol=(sol+ans)%1000000007;
	cout<<sol;
	return 0;
}

Measured memory_bytes: 3520
S = list(input())
T = list(input())
n = len(S)
ans = 'No'
if len(S) == len(T):
    for i in range(n):
        if S == T:
            ans = 'Yes'
        else:
            tmp = T[0]
            T.remove(tmp)
            T.append(tmp)
            
print(ans)


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

/*
  let's try computer shogi!!!
 */

/*
  解説を書く余裕が無くなってきた
 */

int main(){
  int N;
  vector<long long int> A;
  cin >> N;
  A.resize(N);
  for(int i=0;i<N;++i){
    cin >>A[i]; 
  }

  long long int total = 0;
  while(1){
    bool stop = true;
    for(int i=0;i<N;++i){
      if(A[i] >= N){
	total += A[i]/N;
	for(int j=0;j<N;++j){
	  if(j!=i){
	    A[j] += A[i]/N;
	  }
	}
	A[i] = A[i]%N;
	stop = false;
	/*
	for(int k=0;k<N;++k){
	  cout<<A[k]<<" ";
	}
	cout<<endl;
	*/
      }
    }
    if(stop){
      break;
    }
  }
  cout<<total<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = int_fast64_t;

int main(){
        ll n;
        scanf("%ld", &n);

        std::vector<std::vector<ll>> dist(n, std::vector<ll>(n)), use(n, std::vector<ll>(n, 1));
        for(ll i=0; i<n; i++) for(ll j=0; j<n; j++) scanf("%ld", &dist[i][j]);

        for(ll i=0; i<n; i++){
                for(ll j=0; j<n; j++){
                        if(i==j) continue;
                        for(ll k=0; k<n; k++){
                                if(i!=k and j!=k and dist[i][j]==dist[i][k]+dist[k][j]){
                                        use[i][j] = 0;
                                }else if(dist[i][j]>dist[i][k]+dist[k][j]){
                                        puts("-1");
                                        return 0;
                                }
                        }
                }
        }

        ll ans = 0;
        for(ll i=0; i<n; i++){
                for(ll j=0; j<n; j++){
                        if(use[i][j]) ans +=  dist[i][j];
                }
        }
        printf("%ld\n", ans/2);
        return 0;
}

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

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)
#define TRACE(x) cerr << #x << " = " << x << endl

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

const int mod = 1e9 + 7;

int add(int x, int y) {x += y; if(x >= mod) return x - mod; return x;}
int sub(int x, int y) {x -= y; if(x < 0) return x + mod; return x;}
int mul(int x, int y) {return (ll) x * y % mod;}

const int MAXN = 1e4 + 5;
const int MAX = 1e6 + 5;

int n, a[MAXN], divisor[MAX], mn[MAX];

int pot(int b, int p){
  if(p % 2){
    if(p == 1) return b;
    return mul(pot(b, p - 1), b);
  }
  else{
    if(p == 0) return 1;
    int tmp = pot(b, p / 2);
    return mul(tmp, tmp);
  }
}

unordered_map<int, int> rastavi(int x){
  unordered_map<int, int> M;
  while(x != 1){
    M[divisor[x]] ++;
    x /= divisor[x];
  }
  return M;
}

void spoji(unordered_map<int, int> &A, unordered_map<int, int> &B){
  for(auto it : B){
    A[it.first] += it.second - ( min(A[it.first], B[it.first]) );
  }
}

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

  FOR(i, 2, MAX)
    for(int j = i; j < MAX; j += i){
      if(divisor[j]) continue;
      divisor[j] = i;
    }

  unordered_map<int, int> lcm;
  cin >> n;
  REP(i, n){
    cin >> a[i];
    unordered_map<int, int> tmp = rastavi(a[i]);
    spoji(lcm, tmp);
  }

  ll nzv = 1;
  for(auto it : lcm)
    nzv = mul(nzv, pot(it.first, it.second));

  ll sol = 0;
  REP(i, n)
    sol = add(sol, mul(nzv, pot(a[i], mod - 2)));
  cout << sol;
}


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

#define ff first
#define ss second
#define vi vector<int>
#define fo(n) for(int i = 0;i < int(n);i++)
#define foo(a,b) for(int i = int(a);i <= int(b);i++)
#define mk make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define fastio ios_base:: sync_with_stdio(false)


const int MAXN = 1e6;
const int mod = 1e9 + 7;
const int inf = 1e9;



int main(){

	
	fastio;
	int n,L;
	cin >> n >> L;

	int sum = 0;
	int deleted = INT_MAX;

	for(int i = 1;i <= n;i++){
		sum += (L+i-1);

		if(abs(L+i-1) < abs(deleted))
			deleted = (L+i-1);
	}

	cout << sum-deleted << endl;

	return 0;
 }	

Measured memory_bytes: 256
N,Q=map(int,input().split())
ans=[0]*N
ki=[[] for _ in range(N)]
for i in range(N-1):
 a,b=map(int,input().split())
 ki[a-1].append(b-1)
 ki[b-1].append(a-1)
for i in range(Q):
 p,q=map(int,input().split())
 ans[p-1]+=q
# dfs
stack = [0]
visited = ["False"] * N
while stack:
 ne = stack.pop()
 if visited[ne] == "False":
  visited[ne] = "True"
  for j in ki[ne]:
   if visited[j] == "False":
    ans[j]+=ans[ne]
    stack.append(j)
L=[str(a) for a in ans]
L=' '.join(L)
print(L)

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


int main(void){
  int x,y,z; cin >> x >> y >> z;
  cout << z << " " << x << " " << y << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 100100;
ll a[N][3];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int n;
	ll k;
	scanf("%d%lld", &n, &k);
	for (int i = 0; i < n; i++) {
		a[i][2] = k + 3 * n - 1 - i;
		if (2 * i < n) {
			a[i][0] = k + n / 2 + i;
			a[i][1] = k + 2 * n - 1 - 2 * i;
		} else {
			int p = (2 * i - n) / 2;
			a[i][0] = k + p;
			a[i][1] = k + 2 * n - 2 - 2 * p;
		}
	}
	for (int i = 0; i < n; i++) {
		if (a[i][0] + a[i][1] > a[i][2]) {
			printf("-1\n");
			return 0;
		}
	}
	for (int i = 0; i < n; i++)
		printf("%lld %lld %lld\n", a[i][0], a[i][1], a[i][2]);

	return 0;
}


Measured memory_bytes: 4608
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn=2010;
const int INF=1e9+10;

int n,w[maxn],b[maxn];
char c;
int p;
int dp[maxn][maxn],cw[maxn][maxn],cb[maxn][maxn];
int bitw[maxn*2],bitb[maxn*2];

int getw(int p)
{
	int ans=0;
	while(p>0)
	{
		ans+=bitw[p];
		p-=(p&(-p));
	}
	return ans;
}

int getb(int p)
{
	int ans=0;
	while(p>0)
	{
		ans+=bitb[p];
		p-=(p&(-p));
	}
	return ans;
}

void updatew(int p)
{
	while(p<=2*n)
	{
		bitw[p]++;
		p+=(p&(-p));
	}
	return;
}

void updateb(int p)
{
	while(p<=2*n)
	{
		bitb[p]++;
		p+=(p&(-p));
	}
	return;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2*n;i++)
	{
		c=getchar();
		c=getchar();
		scanf("%d",&p);
		if (c=='W') w[p]=i; else b[p]=i;
	}
	
	for(int i=1;i<=2*n;i++) bitw[i]=0;
	for(int i=1;i<=n;i++)
	{
		int tmp=getw(2*n)-getw(w[i]);
		for(int j=0;j<=n;j++)
			cw[i][j]+=tmp;
		updatew(w[i]);
	}
	
	for(int i=1;i<=2*n;i++) bitb[i]=0;
	for(int i=0;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
			cw[j][i]+=getb(2*n)-getb(w[j]);
		if (i<n) updateb(b[i+1]);
	}
	
	for(int i=1;i<=2*n;i++) bitb[i]=0;
	for(int i=1;i<=n;i++)
	{
		int tmp=getb(2*n)-getb(b[i]);
		for(int j=0;j<=n;j++)
			cb[i][j]+=tmp;
		updateb(b[i]);
	}
	for(int i=1;i<=2*n;i++) bitw[i]=0;
	for(int i=0;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
			cb[j][i]+=getw(2*n)-getw(b[j]);
		if (i<n) updatew(w[i+1]);
	}
	
	for(int i=0;i<=n;i++)
		for(int j=0;j<=n;j++)
			dp[i][j]=INF;
	dp[0][0]=0;
	for(int i=0;i<=n;i++)
		for(int j=0;j<=n;j++)
		{
			if (i>0) dp[i][j]=min(dp[i][j],dp[i-1][j]+cw[i][j]);
			if (j>0) dp[i][j]=min(dp[i][j],dp[i][j-1]+cb[j][i]);
		}
	printf("%d\n",dp[n][n]);
	return 0;
}

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

using namespace std;

int main(){
  long long L,R; cin >> L >> R;

  int ans = 2018;
  R = min(R, L+4038);
  for (long long i = L; i <= R; ++i ) {
    for (long long j = i + 1; j <= R; ++j ) {
      int mod = (i * j) % 2019;
      ans = min(mod,ans);
    }
  }
  cout << ans << endl;
  return 0;
}
  

Measured memory_bytes: 256
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
s = input()
counter = Counter(s)

ans = "Yes"
if len(counter) !=2:
    ans = "No"
for i,v in counter.items():
    if v != 2:
        ans = "No"

print(ans)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する



Measured memory_bytes: 3316
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	int N=in(),K=in();
	
	cout << (K==1? 0 : N-K) << endl;
	return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
#define mod 1000000007
bool isPrime[1000001];
ll power(ll a,ll b)
{
    ll result = 1;
    while(b>0)
    {
        if(b%2)
        {
            result = (a*result)%mod;
        }
        a = (a*a)%mod;
        b = b/2;
    }
    return result;
}
int gcd(int a,int b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
void sieve()
{
    memset(isPrime,1,sizeof(isPrime));
    isPrime[0] = isPrime[1] = 0;
    for(int i=2;i*i<=1000000;i++)
    {
        if(isPrime[i])
        {
            for(int j=i*i;j<=1000000;j+=i)
            {
                isPrime[j] = 0;
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int t,n;
    t = 1;
    for(int i=0;i<t;i++)
    {
       ll x;
       cin>>x;
       ll m = 100;
        for (int i = 1; i < 1001001001; ++i)
        {
            m = m+(m/100);
            if (m >= x)
            {
                cout << i << endl;
                return 0;
             }
        }      
   }
    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000

int main() {
	long long x, y, z;
	long long s, ans;
	scanf("%lld %lld", &x, &y);
	y = y / 2;
	if (x < y) {
		ans = x;
		y -= x;
		ans += (y / 2);
	}
	else ans = y;


	printf("%lld\n", ans);


	return 0;
}


Measured memory_bytes: 128
import java.io.*;
import java.util.*;
 
public class Main {
  private static boolean debug = false;
  private static boolean elapsed = false;
 
  private static PrintWriter _err = new PrintWriter(System.err);
 
  private void solve(Scanner sc, PrintWriter out) {
    StringBuilder sA = new StringBuilder(sc.nextLine());
    StringBuilder sB = new StringBuilder(sc.nextLine());
    StringBuilder sC = new StringBuilder(sc.nextLine());
 
    Map<Character, StringBuilder> map = new HashMap<>();
    map.put('a', sA);
    map.put('b', sB);
    map.put('c', sC);
 
    char ch = 'a';
    while (true) {
      StringBuilder sb = map.get(ch);
      if (sb == null) {
        throw new RuntimeException(ch + ": Invalid input");
      }
      if (sb.length() == 0) {
        break;
      }
      ch = sb.charAt(0);
      sb.deleteCharAt(0);
    }
    out.println(Character.toUpperCase(ch));
  }
  private long C(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    for (long i = r; i > 1; --i) {
      res /= i;
    }
    return res;
  }
  private long P(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    return res;
  }
  /*
   * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
   * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
   */
  public static void main(String[] args) {
    long S = System.currentTimeMillis();
 
    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new Main().solve(sc, out);
    out.flush();
 
    long G = System.currentTimeMillis();
    if (elapsed) {
      _err.println((G - S) + "ms");
    }
    _err.flush();
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end();
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<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(){
	ll N,H;
	cin>>N>>H;
	vector<ll> a(N),b(N);
	rep(i,N) cin>>a[i]>>b[i];

	ll a_max=*max_element(a.begin(),a.end());
	sort(b.begin(),b.end());
	reverse(b.begin(),b.end());
	ll ans=0;
	rep(i,N){
		if(a_max<b[i]){
			H-=b[i];
			ans++;
			if(H<=0) break;
		}
	}
	if(H>0) ans+=(H+(a_max-1))/a_max;
	cout<<ans<<endl;

}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long ll;

int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  int a;
  if(n < k) {
    a = x * n;
  } else {
    a = x * k + y * (n - k);
  }
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int num;
  int ashi;
  int flag=0;
  cin >> num;
  cin >> ashi;
  for(int i=0;i<=num;i++){
    int turu=i;
    int kame=num-i;
    if(turu*2+kame*4==ashi)flag=1;
  }
  if(flag==0)cout << "No" <<endl;
  else cout << "Yes" <<endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<utility>
#include<iomanip>
#include<algorithm>
#include<climits>
#include<list>
#include<stack>
#include<queue>
#define ff first
#define ss second 
#define li list<int>
#define vi vector<int>
#define ll long long
#define vvi vector<vector<int> >
#define vii vector<pair<int,int> >
#define forl(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define custom  pair<int,pair<int,int> >
#define mod 1000000007
using namespace std;
class node{
    public:
        int data;
        node*left;
        node*right;

        node(int d){
            data = d;
        }
};
double dp[3001][3001];
double solve(double* v,int i,int n,int x){
    if(x==0){
        return 1;
    }
    if(i==n){
        return 0;
    }
    if(dp[i][x]>-0.9){
        return dp[i][x];
    }
    double op1=v[i]*solve(v,i+1,n,x-1);
    double op2=(1-v[i])*solve(v,i+1,n,x);
    return dp[i][x]=op1+op2;
}
int main(){
    int n;
    cin>>n;
    double v[n];
    memset(dp,-1,sizeof dp);
    //dp[0][0]=1;
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    cout<<setprecision(10)<<solve(v,0,n,(n+1)/2)<<endl;
    return 0;
}                  


Measured memory_bytes: 70912
#include <iostream>
 
using namespace std;
 
int main()
{
    int n;
    cin>>n;
    int d[n],sum=0;
    for(int i=0; i<n; ++i){
        cin>>d[i];
    }
    int i, j;
    for(i=0;i<n-1;i++){
        for(j=i+1; j<n; ++j){
            sum=sum+(d[i]*d[j]);
        }
    }
    cout<<sum;
    cout<<'\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;

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

    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    vector<int> p_sum(n+1,0);
    vector<double> E(n);

    rep(i, n)
    {
        cin >> p[i];
        p_sum[i+1]=p_sum[i]+p[i];
    }

    ll max_val = 0;
    int idx = 0;
    ll tmp_val;
    double max_E = 0;
    ll test=0;
    rep(i, n - k + 1)
    {
        tmp_val = p_sum[i+k]-p_sum[i];
        if (max_val < tmp_val)
        {
            idx = i;
            max_val = tmp_val;
        }
    }

    // pre calcSum
    vector<double> num_sum(1001, 0);
    reps(i, 1001, 1)
    {
        num_sum[i] = num_sum[i - 1] + (double)i;
    }


    reps(i, idx + k, idx)
    {
        max_E += num_sum[p[i]] / (double)p[i];
    }

    cout << fixed << setprecision(10) << max_E << endl;
 //   system("pause");
    return 0;
}

Measured memory_bytes: 3456
#include<iostream>
using namespace std;
int ans,ans1;
int main(){
	string s;
	cin>>s;
	int n=s.size();
		for(int i=0;i<=n-1;i+=2){
			if(s[i]!='0') ans++;
		}
		for(int i=1;i<=n-1;i+=2){
			if(s[i]!='1') ans++;
		}
		for(int i=0;i<=n-1;i+=2){
			if(s[i]!='1') ans1++;
		}
		for(int i=1;i<=n-1;i+=2){
			if(s[i]!='0') ans1++;
		}
		ans=min(ans,ans1);
		cout<<ans<<endl;
} 

Measured memory_bytes: 512