akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S, T;
  cin >> S >> T;
  int ans = 1000;
  for(int i=0; i<=S.size()-T.size(); ++i) {
    int tmp = 0;
    for(int j=0; j<T.size(); ++j) {
      if(S[i+j] != T[j]) {
        ++tmp;
      }
    }
    chmin(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
from itertools import combinations_with_replacement

N, M, Q = map(int,input().split())
x = [_ for _ in range(1, M+1)]
y = list(combinations_with_replacement(x, N))
l = [list(map(int, input().split())) for _ in range(Q)]

ans = []
z = 0
for i in range(len(y)):
    for j in range(Q):
        if y[i][l[j][1]-1] - y[i][l[j][0]-1] == l[j][2]:
            z += l[j][3]
        ans.append(z)
    z = 0
print(max(ans))

Measured memory_bytes: 86432
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	static int res = 0;

	public static void main(String[] args) throws Exception {


		String str1=sc.nextLine();
		String str2=sc.nextLine();
		System.out.println(helper(str1,str2));

	}
	private static String helper(String str1, String str2) {
		// TODO Auto-generated method stub
		for(int i=0;i<str1.length();i++){
			if(str1.charAt(i)!=str2.charAt(str2.length()-1-i))
				return "NO";
		}
		return "YES";
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unrolled-loops")

using namespace std;

#define inp "TestCode.inp"
#define out "TestCode.out"
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FileInOut freopen(inp,"r",stdin);freopen(out,"w",stdout);
#define pb push_back
#define pf push_front
#define pof pop_front
#define mp make_pair
#define X first
#define Y second
#define pi acos(-1)
#define pii pair<int,int>
#define ppiii pair< pair <int,int> ,int>
#define INF 1000000
#define endl '\n'
#define ll long long
#define pq priority_queue
const int mod=1e9+7;
int test=1;
/*-----------------------------------------------*/
void nathan_on_osu()
{
    FAST
    #ifndef ONLINE_JUDGE
    //FileInOut
    #endif // ONLINE_JUDGE
}
/*-----------------------------------------------*/

ll a,b,c,d;

ll gcd(ll a,ll b)
{
    ll r;
    while(b>0)
    {
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}

int main()
{
    nathan_on_osu();
    cin>>a>>b>>c>>d;
    ll x,y,z,t,u,v,kk=c*d/(gcd(c,d));
    if(a%c!=0)
        x=a-(a%c)+c;
    else x=a;
    y=b-(b%c);
    if(a%d!=0)
        z=a-(a%d)+d;
    else z=a;
    t=b-(b%d);
    if(a%kk!=0)
        u=a-(a%kk)+kk;
    else u=a;
    v=b-(b%kk);
    //cout<<x<<" "<<y<<" "<<z<<" "<<t<<" "<<u<<" "<<v<<endl;
    //cout<<(y-x)/c+1<<" "<<(t-z)/d+1<<" "<<(v-u)/kk+1<<endl;
    cout<<(b-a+1)-((y-x)/c+1 + (t-z)/d+1 - (v-u)/kk-1);
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 2000
#define TRUE 1
#define FALSE 0
 
int solve(int,int);

int n,A[MAX],M[MAX];

int main()
{
	int i,q;

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

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

	for(i = 0;i < q;i++)
	{
		if(solve(0,M[i]) == 1)printf("yes\n");
		else printf("no\n");
	}

	return 0;

}

int solve(int i,int m)
{
	if(m == A[i])return TRUE;
	if(i+1 >= n)return FALSE;

	if(solve(i+1,m) || solve(i+1,m-A[i]) == 1)return TRUE;
	return FALSE;
}

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

int main(){
    int A, B, C, i;
    cin >> A >> B >> C;

    if(A*C <= B){
        cout << C;
    } else if(A > B){
        cout << 0;
    } else {
        for(i = 1; i*A <= B; i++){

        }
        cout << i-1;
    }
}

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

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<int> a(n), b(n), c(n - 1);
	rep(i, n) {
		cin >> a[i]; a[i]--;
	}
	rep(i, n) cin >> b[i];
	rep(i, n - 1) cin >> c[i];

	int ans = 0;
	rep(i, n) {
		ans += b[a[i]];
		if (i != 0 && a[i - 1] + 1 == a[i])
			ans += c[a[i - 1]];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <functional>
#include <algorithm>

#include <queue>

template<class T>
struct FlowBase {
  FlowBase(unsigned t, T u, unsigned r) : t(t), u(u), r(r) {}
  unsigned t; // tail
  T u;        // capacity
  unsigned r; // index of the reverse edge
};

template<class T>
void add_edge(std::vector<std::vector<FlowBase<T>>> &graph, unsigned s, unsigned t, T u) {
  graph[s].push_back(FlowBase<T>(t, u, graph[t].size()));
  graph[t].push_back(FlowBase<T>(s, 0, graph[s].size() - 1));
}

template<class T, class V>
void dinic_bfs(std::vector<std::vector<V>> &graph, std::vector<int> &level, unsigned s) {
  std::fill(level.begin(), level.end(), static_cast<T>(-1));
  std::queue<unsigned> que;
  level[s] = 0;
  que.push(s);
  while (!que.empty()) {
    auto v = que.front();
    que.pop();
    for (auto &e : graph[v]) {
      if (e.u > 0 && level[e.t] < 0) {
        level[e.t] = level[v] + 1;
        que.push(e.t);
      }
    }
  }
}
template<class T, class V>
T dinic_dfs(std::vector<std::vector<V>> &graph,
            std::vector<int> &level,
            std::vector<unsigned> &iter,
            unsigned s,
            unsigned t,
            T f) {
  if (s == t) { return f; }
  for (auto &i = iter[s]; i < graph[s].size(); ++i) {
    auto &e = graph[s][i];
    if (e.u > 0 && level[s] < level[e.t]) {
      T d = dinic_dfs(graph, level, iter, e.t, t, std::min(f, e.u));
      if (d > 0) {
        e.u -= d;
        graph[e.t][e.r].u += d;
        return d;
      }
    }
  }
  return static_cast<T>(0);
}
template<class T, class V>
T dinic(std::vector<std::vector<V>> graph, unsigned s, unsigned t) {
  std::vector<int> level(graph.size());
  std::vector<unsigned> iter(graph.size());
  T flow = 0;
  while (true) {
    dinic_bfs<T>(graph, level, s);
    if (level[t] < 0) { return flow; }
    std::fill(iter.begin(), iter.end(), 0);
    T f;
    while ((f = dinic_dfs<T>(graph, level, iter, s, t, std::numeric_limits<T>::max())) > 0) {
      flow += f;
    }
  }
}

int main() {
  int N;
  std::cin >> N;
  std::vector<std::pair<int, int>> red;
  std::vector<std::pair<int, int>> blue;
  for (int i = 0; i < N; ++i) {
    int x, y;
    std::cin >> x >> y;
    red.emplace_back(x, y);
  }
  for (int i = 0; i < N; ++i) {
    int x, y;
    std::cin >> x >> y;
    blue.emplace_back(x, y);
  }
  std::vector<std::vector<FlowBase<long long>>> graph(2 * N + 2);
  for (int i = 0; i < N; ++i) {
    add_edge<long long>(graph, 2 * N, i, 1);
    add_edge<long long>(graph, N + i, 2 * N + 1, 1);
    for (int j = 0; j < N; ++j) {
      if (red[i].first < blue[j].first && red[i].second < blue[j].second) {
        add_edge<long long>(graph, i, N + j, 1);
      }
    }
  }
  std::cout << dinic<long long, FlowBase<long long>>(graph, 2 * N, 2 * N + 1) << std::endl;
  return 0;
}

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

int main() {

    string s, t;

    cin >> s >> t;

    string answer;
    bool isTrue = false;

    for(int i = s.size() - t.size() + 1; i >= 0 ; --i) {

        if(s[i] != '?' && s[i] != t[0])
            continue;

        int j = 1;
        while(j < t.size()) {
            if(s[i + j] != '?' && s[i + j] != t[j])
                break;

            j++;
        }

        if(j == t.size()) {
            for(int j = 0; j < t.size(); ++j)
                s[i + j] = t[j];

            
            isTrue = true;
            break;
        }

    }

    if(isTrue == false) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    for(int i = 0; i < s.size(); ++i) {
        if(s[i] == '?')
            cout << 'a';
        else
            cout << s[i];
    }

    cout << endl;

    return 0;

}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int H, W; char s[109][10009];
int main() {
	scanf("%d%d", &W, &H);
	for (int i = 0; i < H; i++) scanf("%s", s[i]);
	int lcnt = 0, rcnt = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (s[i][j] == 'W') rcnt++;
		}
	}
	int ret = 0, sum = 999999999;
	for (int i = 0; i <= W; i++) {
		if (sum > lcnt + rcnt) sum = lcnt + rcnt, ret = i;
		if (i == W) continue;
		for (int j = 0; j < H; j++) {
			if (s[j][i] == 'E') lcnt++;
			if (s[j][i] == 'W') rcnt--;
		}
	}
	printf("%d %d\n", ret, ret + 1);
	return 0;
}

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

class Proc{
public:
	string nam;
	int tim;
	Proc(){nam="";tim=0;}
};

Proc Q[100001];

class Queue{
private:
	int fp;
	int rp;
public:
	Queue(){fp=0;rp=0;}
	int next(int p) const{return (p+1)%100001;}
	bool isFull() const{return (next(rp)==fp);}
	bool isEmpty() const{return (fp==rp);}
	void push(Proc d);
	Proc front();
	void pop();
};

void Queue::push(Proc d)
{
	if(isFull())
		return;
	
	Q[rp]=d;
	rp=next(rp);
}

Proc Queue::front()
{
	if(isEmpty()){
		Proc er;
		er.tim=-1;
		return er;
	}
		
	return Q[fp];
}

void Queue::pop()
{
	if(isEmpty())
		return;

	fp=next(fp);
}

int main()
{
	Queue que;
	
	int n,q;
	cin>>n>>q;

	for(int i=0;i<n;i++){
		Proc p;
		cin>>p.nam>>p.tim;

		que.push(p);
	}
	
	int total_tim=0;

	while(!que.isEmpty()){
		Proc p=que.front();que.pop();
		
		if(p.tim<=q){
			total_tim+=p.tim;
	
			cout<<p.nam<<' '<<total_tim<<endl;
		}
		else{
			total_tim+=q;
			p.tim-=q;
		
			que.push(p);	
		}	
	}

	return 0;
}

Measured memory_bytes: 7008
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
signed main()
{
    IOS
    int n; cin>>n;
    int arr[n];
    for(int i=0;i<n;i++) cin>>arr[i];
    bool ans;
    for(int i=0;i<n-1;i++)
    {
        if(arr[i] == arr[i+1]) ;
        else if(arr[i] < arr[i+1]) arr[i+1]--;
        else{
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<queue>
#include<iostream>
using namespace std;
int main(void)
{
	for(;;){
		queue<pair<int,int> > q;
		pair<int,int> g,s,w;
		int x,y,f[18][18],n,m,a=0;
		scanf("%d %d",&x,&y);
		if(x==0&&y==0){
			break;
		}
		s.first=1;
		s.second=1;
		q.push(s);
		g.first=x;
		g.second=y;
		for(n=0;n<18;n++){
			for(m=0;m<18;m++){
				if(n==0||n>x||m==0||m>y){
					f[n][m]=1;
				}
				else{
					f[n][m]=0;
				}
			}
		}

		scanf("%d",&n);
		for(m=0;m<n;m++){
			scanf("%d %d",&x,&y);
			f[x][y]=1;
		}

		while(!q.empty()){
			s=q.front();
			if(f[s.first+1][s.second]==0){
				w.first=s.first+1;
				w.second=s.second;
				if(w==g){
					a++;
				}
				else{
					q.push(w);
				}
			}
			if(f[s.first][s.second+1]==0){
				w.first=s.first;
				w.second=s.second+1;
				if(w==g){
					a++;
				}
				else{
					q.push(w);
				}
			}
			f[s.first][s.second]=1;
			q.pop();
		}
		printf("%d\n",a);
	}
	return 0;
}

Measured memory_bytes: 9324
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<queue>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
map<string,int >mmp;
int main()
{
    string s,t;
    int n;
    cin>>n;
    cin>>t;
    mmp[t]=1;
    bool flag=1;
    for(int i=1;i<n;i++)
    {
        cin>>s;
        if(!flag) continue;
        if(mmp[s])
        {
            flag=0;
        }
        if(t[t.size()-1]!=s[0])
        {
            flag=0;
        }
        mmp[s]=1;
        t=s;
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI acos(-1.0)
#define sq(n) ((n)*(n))

using namespace std;
using ll = long long;

int main() {
    FAST;

    int n;
    cin >> n;

    ll a, ans = 1, mx = 1000000000000000000;

    while (n--) {
        cin >> a;
        if (a == 0) ans = 0;
        if (ans <= 0) continue;
        if (mx/ans < a) ans = -1;
            else ans *= a;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

int main(){
  char c; cin >> c;
  if('A' <= c && c <= 'Z') cout << 'A' << endl;
  else cout << 'a' << endl;
  return 0;
}


Measured memory_bytes: 3616
import sys
sys.setrecursionlimit(10**7)
def dfs(i, j):
    if(c[i][j] != "1"):
        return 1
    else:
        c[i][j] = "2"

        if(0 < i):                      dfs(i - 1, j)
        if(0 < j):                      dfs(i, j - 1)
        if(i < h - 1):                  dfs(i + 1, j)
        if(j < w - 1):                  dfs(i, j + 1)
        if(0 < i and 0 < j):            dfs(i - 1, j - 1)
        if(0 < i and j < w - 1):        dfs(i - 1, j + 1)
        if(i < h - 1 and 0 < j):        dfs(i + 1, j - 1)
        if(i < h - 1 and j < w - 1):    dfs(i + 1, j + 1)
        return 1

ans=[]
while(True):
    islands=0
    w, h = map(int, input().split())
    if(w == 0 and h == 0):
        break
    c = []
    for i in range(h):
        c.append(input().split())
    for i in range(h):
        for j in range(w):
            if(c[i][j] == "1"):
                islands += dfs(i, j)
    ans.append(islands)

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


Measured memory_bytes: 7620
S=input()

S=list(S)

if(S[0]=='a'):
    if((S[1]=='b' and S[2]=='c') or (S[2]=='b' and S[1]=='c') ):
        print("Yes")
    else:
        print("No")
elif(S[0]=='b'):
    if((S[1]=='a' and S[2]=='c') or (S[2]=='a' and S[1]=='c') ):
        print("Yes")
    else:
        print("No")
elif(S[0]=='c'):
    if((S[1]=='a' and S[2]=='b') or (S[2]=='a' and S[1]=='b') ):
        print("Yes")
    else:
        print("No")
else:
    print("No")


Measured memory_bytes: 3064
#!/usr/bin/env pypy3


def get_line():
    return input()


def get_tokens():
    return get_line().split()


def get_ints():
    return [int(_) for _ in get_tokens()]


def main():

    n, = get_ints()
    if n == 1:
        print('Hello World')
    else:    
        A, = get_ints()
        B, = get_ints()
        print(A+B)
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}

} // namespace n91

#include <algorithm>
#include <bitset>
#include <iostream>
#include <numeric>
#include <utility>

namespace n91 {

void main_() {
  std::bitset<16001_z> is_sq;
  for (const auto i : rep(0_z, 127_z)) {
    is_sq.set(i * i);
  }

  usize n, d;
  std::cin >> n >> d;
  auto x = md_vec(n, d, i32());
  for (auto &v : x) {
    for (auto &e : v) {
      std::cin >> e;
    }
  }
  usize cnt = 0_z;
  for (const auto i : rep(0_z, n)) {
    for (const auto j : rep(0_z, i)) {
      i32 sum = static_cast<i32>(0);
      for (const auto k : rep(0_z, d)) {
        sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }
      if (is_sq.test(static_cast<usize>(sum))) {
        ++cnt;
      }
    }
  }
  std::cout << cnt << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 1001001001;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    vector<ll> v(n), c(n);
    rep(i, n) {
        cin >> v[i];
    }
    rep(i, n) {
        cin >> c[i];
    }
    rep(i, n) {
        if(v[i]-c[i] > 0) {
            ans += (v[i]-c[i]);
        }
    }
    cout << ans << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        ret %= MOD;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count))%MOD;
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}



Measured memory_bytes: 256
import java.io.*;

public class Main{
    public static void main(String[]args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        int count[] = new int[26];
        char abc ='a';
        
        while((str=br.readLine())!=null){
          
            for(int i=0;i<str.length();i++){
                if(Character.isLetter(str.charAt(i))){
                    count[Character.toLowerCase(str.charAt(i)) - 'a']++;
                }
            }
        }
       for(int i=0;i<26;i++){
           System.out.println(abc++ + " : " +count[i]);
    }
        
        
    }

        
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//template end

template<unsigned mod=1000000007>struct mint {
   unsigned val;
   static unsigned get_mod(){return mod;}
   unsigned inv() const{
      int tmp,a=val,b=mod,x=1,y=0;
      while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
      if(x<0)x+=mod; return x;
   }
   mint():val(0){}
   mint(ll x):val(x>=0?x%mod:mod+(x%mod)){}
   mint pow(ll t){mint res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
   mint& operator+=(const mint& x){if((val+=x.val)>=mod)val-=mod;return *this;}
   mint& operator-=(const mint& x){if((val+=mod-x.val)>=mod)val-=mod; return *this;}
   mint& operator*=(const mint& x){val=ll(val)*x.val%mod; return *this;}
   mint& operator/=(const mint& x){val=ll(val)*x.inv()%mod; return *this;}
   mint operator+(const mint& x)const{return mint(*this)+=x;}
   mint operator-(const mint& x)const{return mint(*this)-=x;}
   mint operator*(const mint& x)const{return mint(*this)*=x;}
   mint operator/(const mint& x)const{return mint(*this)/=x;}
   bool operator==(const mint& x)const{return val==x.val;}
   bool operator!=(const mint& x)const{return val!=x.val;}
};
template<unsigned mod=1000000007>struct factorial {
   using Mint=mint<mod>;
   vector<Mint> Fact, Finv;
public:
   factorial(int maxx){
      Fact.resize(maxx+1),Finv.resize(maxx+1); Fact[0]=Mint(1); rep(i,0,maxx)Fact[i+1]=Fact[i]*(i+1);
      Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*i;
   }
   Mint fact(int n,bool inv=0){if(inv)return Finv[n];else return Fact[n];}
   Mint nPr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[n-r];}
   Mint nCr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[r]*Finv[n-r];}
};

int main(){
   int n,a,b; scanf("%d%d%d",&n,&a,&b);
   mint<> res=mint<>(2).pow(n)-1,d1=1,d2=1;
   rep(i,1,a+1)d1*=(n+1-i),d1/=i;
   rep(i,1,b+1)d2*=(n+1-i),d2/=i;
   res-=d1+d2; printf("%d\n",res.val);
   return 0;
}

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

#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int a,b,c,d;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    int turn = 1;
    while (a>0 && c>0){
        if(turn){
            c -= b;
        } else {
            a -= d;
        }
        turn = 1-turn;
    }
    if(!turn) cout << "Yes\n";
    else cout << "No\n";
    
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<cmath>
#include<cstring>


using namespace std;


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

    int k;
    cin >> k;

    vector<string> v;
    set<string> t;

    for(int i = 0; i < s.length(); i++){
         for(int  j = 1; j <= k; j++){
            string l = s.substr(i,j);
            if(!t.count(l)){
                v.push_back(s.substr(i,j));
                t.insert(l);
               } 
         }
      }



    sort(v.begin(), v.end());

    cout << v[k-1];



    return 0;
}

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

int main() {
	
	ll N;
	ll t;
	ll ans = 0;
	ll first, last;
	ll b = 0;
	ll min;
	int z = 0;
	
	cin >> N;
	for(ll i=0; i<N; i++){
		cin >> t;
		
		if(t < 0) b++;
		else if(t == 0) z=1;
		
		t = abs(t);
		ans += t;
		if(i == 0) min = t;
		else min = (t < min) ? t : min;
	}
	
	if(b%2 != 0 && z == 0){
		ans -= (min * 2);
	}
	
	printf("%lld\n", ans);
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxN = 2e3+7;
const int maxM = 1e5+7;
const int maxV = 90010;
//const int INF = 1e9+9;
//const ll INF = (1ll)<<60;
const int INF = 2e9+9;
const int MOD = 1e9+7;

int n,m;
int s[maxN];
int t[maxN];
ll a[maxM];
ll b[maxM];
ll f[maxN][maxN];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&s[i]);
	}
	for(int j=1;j<=m;j++)
	{
		scanf("%d",&t[j]);
	}
	for(int i=1;i<=n;i++)
		f[i][0] = 1;
	for(int i=1;i<=m;i++)
		f[0][i] = 1;
	f[0][0] = 1;
	a[0] = 1;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			f[i][j] = (f[i-1][j]+f[i][j-1]+MOD-f[i-1][j-1])%MOD;
			if(s[i] == t[j])
			{
				f[i][j] = (f[i][j]+f[i-1][j-1])%MOD;
			}
		}
	}
	cout<<f[n][m]<<endl;
	return 0;
}


Measured memory_bytes: 33024
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  int N;
  cin >> N;
  vi a(N);
  REP(i, N) cin >> a.at(i);
  int ad2 = 0, ad4 = 0, noad = 0;
  REP(i, N) {
    if (a.at(i) % 4 == 0)
      ad4++;
    else if (a.at(i) % 2 == 0)
      ad2++;
    else
      noad++;
  }
  if (noad == 0 || noad <= ad4 || N - noad == ad4 && noad == ad4 + 1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 640
n = gets.chomp.to_i
h = gets.chomp.split(" ").map(&:to_i).reverse
prev = h[0]
ans = true

n.times do |i|
    h[i] -= 1 if prev < h[i]
    if prev < h[i] then
        ans = false
        break
    end
    prev = h[i]
end

puts ans ? "Yes" : "No"

Measured memory_bytes: 10500
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll Pow(ll a, ll n){
  if (n == 0) return 1;
  if (n % 2 == 0) return Pow(a * a % MOD, n / 2);
  else return Pow(a * a % MOD, n / 2) * a % MOD;
}

ll N, M, K;
int main(){
  scanf("%lld%lld%lld", &N, &M, &K);

  ll cnt = 1;
  for (ll i = 1; i <= K - 2; i++){
    cnt *= N * M - i - 1; cnt %= MOD;
    cnt *= Pow(i, MOD - 2); cnt %= MOD;
  }

  ll Xans = 0;
  for (ll i = 1; i <= M; i++){
    Xans += N * N * (M - i) * i;
    Xans %= MOD;
  }

  ll Yans = 0; 
  for (ll i = 1; i <= N; i++){
    Yans += M * M * (N - i) * i;
    Yans %= MOD;
  }

  ll ans = (Xans + Yans) % MOD;
  ans *= cnt; ans %= MOD;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){

  int n, m, l;
  string str;
  cin >> str;
  n = str.length();
  int r=0,b=0;
  FOR(i,n){
    if(str[i]=='0')
      r++;
    else
      b++;
  }
  chmin(r,b);
  cout << r*2 fin;
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
int n,x,y,mini;
int main(int argc,char const* argv[])
{
  cin >> n >> x >> y;
  if(x+y-n<0)
    {
      mini=0;
    }
  else
    {
      mini=x+y-n;
    }
  cout << min(x,y) << ' ' << mini << endl;
  return 0;
}


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

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int d, t, s;

int main(){
    cin >> d >> t >> s;
    if(d > t*s){
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
    return 0;
}

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


int main()
{
    int x,a;
    cin>>x>>a;
    if(x<a)
    {
        cout<<0<<endl;
    }
    else
    {
        cout<<10<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad

solve :: [[Int]] -> [Int] -> [Int]
solve matrix vector = map (\r -> foldl (+) 0 $ map (\(x, y) -> x * y) $ zip r vector) matrix

main :: IO ()
main = do
    [n, m] <- map read . words <$> getLine
    matrix <- map (map read . words) <$> replicateM n getLine
    vector <- map read <$> replicateM m getLine
    putStr $ unlines $ map show $ solve matrix vector

Measured memory_bytes: 7660
H, W, A, B = map(int, input().split())

board = [[0] * W for _ in range(H)]
for i in range(B):
    for j in range(A):
        board[i][j] = 1
for i in range(B, H):
    for j in range(A, W):
        board[i][j] = 1
assert all(sum(row) in [A, W-A] for row in board)
assert all(sum(board[i][j] for i in range(H)) in [B, H-B] for j in range(W))
for row in board:
    print("".join(map(str, row)))


Measured memory_bytes: 12020
#include <stdio.h>
#include <string.h>

int main()
{
    long long data_n[1000000];
    long long  in;
    long long n;
    long long k;
    long long q;
    int ret_scanf;

    // フォーマットに従って標準入力から入力
    ret_scanf = scanf("%lld", &n);
    if (ret_scanf == 0) return 0;
    ret_scanf = scanf("%lld", &k);
    if (ret_scanf == 0) return 0;
    ret_scanf = scanf("%lld", &q);
    if (ret_scanf == 0) return 0;
    
    for (long long i = 0; i < q; i++) {
    	data_n[i] = 0;
    }

    for (long long i = 0; i < q; i++) {
	    ret_scanf = scanf("%lld", &in);
    	if (ret_scanf == 0) return 0;
   		data_n[in - 1] = data_n[in - 1] + 1;
    }
    
    for (long long i = 0; i < n; i++) {
    	data_n[i] = k - (q - data_n[i]);
        // printf("--- %d = %d \n", i , data_n[i]);
    	if (data_n[i] <= 0) {
    		printf("No\n");
    	} else {
    		printf("Yes\n");
    	}
    }
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;
//#define local
int main()
{
#ifdef local
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif
    char s[100010];
    cin>>s;
    int cnt=0,len=strlen(s);
    for(int i=0; s[i]; i++)
        if(s[i]=='p') cnt++;
    cout<<len/2-cnt<<endl;
    return 0;
}


Measured memory_bytes: 384
/**Author:Sagor*/

#include<bits/stdc++.h>

using namespace std;
#define pri(n)          printf("%d\n",n)
#define prll(n)         printf("%lld\n",n)
#define prd(n)          printf("%lf\n",n)
#define scll(n)         scanf("%lld",&n)
#define sci(n)          scanf("%d",&n)
#define scd(n)          scanf("%lf",&n)
#define pi              acos(-1)
#define ll              long long
#define pb              push_back
#define vsort(v)        sort(v.begin(),v.end())
#define asort(n)        sort(ar,ar+n)
#define for1(i,n)       for(i=1;i<=n;i++)
#define for0(i,n)       for(i=0;i<n;i++)
#define mod             100000000


int main()
{
    /*ios_base::sync_with_stdio(false);
    cin.tie(NULL);/**Dont't use scanf of printf*/
    string st,str;
    cin>>st>>str;
    int i,cnt=0;
    for(i=0;i<3;i++){
        if(st[i]==str[i]) cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 256
import queue
k = int(input())
q = queue.Queue()
for i in range(1, 10):
    q.put(i)
for i in range(k):
    a = q.get()
    if a % 10 != 0:
        q.put(a*10+(a%10)-1)
    q.put(a*10+(a%10))
    if a % 10 != 9:
        q.put(a*10+(a%10)+1)
print(a)


Measured memory_bytes: 12452
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        int minusCount = 0;
        long min = Long.MAX_VALUE;
        boolean hasZero = false;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
            if (a[i] == 0) {
                hasZero = true;
            }
            if (a[i] < 0) {
                minusCount++;
                min = Math.min(min, -a[i]);
            } else {
                min = Math.min(min, a[i]);
            }
        }
        long total = 0;
        for (int i = 0; i < n; i++) {
            if(a[i] >= 0) total += a[i];
            else total -= a[i];
        }
        if(!hasZero && minusCount % 2 != 0) total -= (min * 2);
        System.out.println(total);
    }
}


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

int hcf(int a, int b) {
  while(a!=b) {
    if(a>b) a-=b;
    else b-=a;
  }
  return a;
}
int main() {
  int n;
  cin >> n;
  int ans=0;
  for(int i=1; i<=n; i++) {
    for(int j=1; j<=n; j++) {
      for(int h=1; h<=n; h++) {
        int a=hcf(i, j);
        ans+=hcf(a, h);
      }
    }
  }
  cout << ans;
}

Measured memory_bytes: 3584
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(__,v.size()){rep(_,v[__].size())cout<<" "<<v[__][_];cout<<endl;}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

signed main(){
	int n,m;
	cin>>n>>m;
	vi in(n+1);
	rep(i,n)cin>>in[i+1];
	rep(i,n)in[i+1]+=in[i];
	vi t;
	rep(i,n)loop(j,i+1,n+1)t.pb(in[j]-in[i]);
	int out=0;
	rep(i,50){
		int w=1ll<<(50-1-i);
		int c=0;
		rep(j,t.size())if(w&t[j])c++;
		if(c>=m){
			out+=w;
			vi nt;
			rep(j,t.size())if(w&t[j])nt.pb(t[j]);
			t=nt;
		}
	}
	cout<<out<<endl;
}


















Measured memory_bytes: 6544
#include <iostream>
#include <string>

using namespace std;

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

    for (int i = 0; i < s.length(); i++) {
        if (s == t) {
            cout << "Yes" << endl;
            return 0;
        }
        s = s[s.length()-1] + s.substr(0, s.length()-1);
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin >> a >> b >> c;
	int bb[101]={};
	int pre=a%b;
	bb[pre]++;
	while(a%b+pre){
		pre=(a%b+pre)%b;
		bb[pre]++;
		if(bb[pre]>1) break;
	}
	if(bb[c]>0) cout << "YES" << endl;
	else cout << "NO" << endl;
}


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

int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  while(1){
    C -= B;
    if(C <= 0){
      cout<<"Yes";
      break;
    }
    A -= D;
    if(A <= 0){
      cout<<"No";
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3636
/*      Chill raho be kuch nhi rakha sadness me. 
               Author: Maskman_lucifer                   */
               
#include <bits/stdc++.h>   
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long 
#define pll pair<ll,ll>
#define pb push_back
#define M 1000000007
#define lc '\n'
using namespace std;
int main()
{
    IO
    ll n;
    cin>>n;
    ll a[n][3];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    for(ll i=1;i<n;i++)
    {
        a[i][0]+=max(a[i-1][1],a[i-1][2]);
        a[i][1]+=max(a[i-1][0],a[i-1][2]);
        a[i][2]+=max(a[i-1][1],a[i-1][0]);
    }
    cout<<max({a[n-1][0],a[n-1][1],a[n-1][2]})<<lc;
    return 0;
}

Measured memory_bytes: 5956
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD (ll)1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define MAX_N (1 << 17)

int root[100010], rank[100010];

int get_root(int i) {
  while (root[i] != i) i = root[i];
  return i;
}

void Union(int i, int j) {
  i = get_root(i); j = get_root(j);
  if (rank[i] > rank[j]) {
    root[j] = i;
    rank[i] = Max(rank[i], rank[j] + 1);
  } else {
    root[i] = j;
    rank[j] = Max(rank[j], rank[i] + 1);
  }
  return;
}

int
main(int argc, char *argv[])
{
  int n, m, p[100010], q[100010];
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
    q[p[i]] = i + 1;
  }

  for (int i = 1; i <= n; i++) root[i] = i;
  int x, y;
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &x, &y);
    Union(x, y);
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i + 1 == p[i]) ans++;
    else {
      if (get_root(i + 1) == get_root(q[i + 1])) ans++;
    }
  }

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

  return 0;
}
    


Measured memory_bytes: 1664
def bisect(lst, target, l, r):
    cent = (l + r) // 2

    if r - l == 1:
        return r

    if lst[cent] == target:
        return cent
    elif lst[cent] > target:
        return bisect(lst, target, l, cent)
    else:
        return bisect(lst, target, cent, r) 

N = int(input())
sm = []
buf = 0
for i in range(N + 1):
    sm.append(i + buf)
    buf += i

mx = bisect(sm, N, 0, N)

sub = sm[mx] - N

for i in range(1, mx + 1):
    if i != sub:
        print(i)

Measured memory_bytes: 187424
#include <iostream>
#include <vector>
#include <bits/stdc++.h>

using namespace std;


long long int a,b,c[2000100],d[100010],ans =0,ant=0;

int main(){
  cin >> a >>b;
  
    for(long long int i=0;i<a;i++)
      cin >> c[i];
  
  ans +=b;
  c[0] +=b;
   for(long long int i=1;i<a;i++){
     
     if(c[0]>=c[i] && c[0] <=c[i]+b){
       ans += (c[i]+b-c[0]);
       c[0] = c[i];
       c[0] += b;
     }
     else if(c[0] <c[i]){
       c[0] = c[i];
       ans +=b;
       c[0] += b;
     }
   }
    
  cout << ans << endl;
}
  
  

 


Measured memory_bytes: 3584
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>
#include <complex>
#include <cassert>

using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const int INF = (1<<30);
const ll INFL = (1LL<<62);
const ll MOD = 1000000007;
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> ll mod_pow(ll a, ll n, T mod) { mod=(ll)mod; ll res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }
template<int mod>
struct ModInt {
    using ll = long long; ll x;
    ModInt() : x(0) {}
    ModInt(int y) : x(y >= 0 ? ll(y % mod) : (ll)((mod - (-y) % mod))) {}
    ModInt(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod)) {}
    ModInt &operator+=(const ModInt &rhs) { if((x += rhs.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &rhs) { if((x += mod - rhs.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &rhs) { x = x * rhs.x % mod; return *this; }
    ModInt &operator/=(const ModInt &rhs) { *this *= rhs.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(const ModInt &rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(const ModInt &rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(const ModInt &rhs) const { return ModInt(*this) /= rhs; }
    ModInt operator==(const ModInt &rhs) const { return x == rhs.x; }
    ModInt operator!=(const ModInt &rhs) const { return x != rhs.x; }
    friend ostream &operator<<(ostream &os, const ModInt &rhs) { return os << rhs.x; }
    friend istream &operator>>(istream &is, ModInt &rhs) { ll t; is >> t; rhs = ModInt<mod> (t); return (is); }
private:
    ModInt inverse() const { ll a = x, u = 1LL, v = 0LL, t, b = (ll)mod; while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return  ModInt(u); }
};
using mint = ModInt<MOD>;
ll floor(ll a, ll b)
{
    return (a + b - 1) / b;
}
void solve(ll s){
    ll x3, y3;
    y3 = floor(s, 1000000000);
    x3 = 1000000000 * y3 - s;
    cout << "0 0 1000000000 1 " << x3 << " " << y3 << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll s;
    cin >> s;
    solve(s);

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int n;
    int a[200000];
    int fst=0;
    int scn=0;
    int fn=0;
    int sn=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]>fst){
            scn=fst;
            sn=fn;
            fst=a[i];
            fn=i;
        }else if(a[i]>scn){
            scn=a[i];
            sn=i;
        }
    }
    
    for(int i=0;i<n;i++){
        if(i==fn){
            printf("%d\n",scn);
        }else{
            printf("%d\n",fst);
        }
    }
    return 0;
}

Measured memory_bytes: 2304
//_nebula_
#include<bits/stdc++.h>
using namespace std;
#define int long  long
#define double long double
int t;
const int M=1e9+7;
int factt(int n)
{
    int ans=1;
    for(int i=1;i<=n;i++)
    {
        ans*=i;
        ans=ans%M;
    }
    return ans;
}
int max(int a,int b,int c)
{
    return max(a,max(b,c));
}
int min(int a,int b,int c)
{
    return min(a,min(b,c));
}
int fspow(int x,int y)
{
    int ans;
    if(y==0) return 1;
    ans=fspow(x, y/2);
    if(y%2==0) return (ans*ans)%M;
    return (x*((ans*ans)%M))%M;;
}
int gcd(int x,int y)
{
    if(x<y) swap(x,y);
    if(y==0) return x;
    return gcd(x%y,y);
}
int p2(int x)
{
    int ans=0;
    while(x>=1)
    {
        ans++;
        x/=2;
    }
    return ans;
}
int v=0;
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    t=1;
    // freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //  cin>>t;
    // int tmp=t;
    while(t--)
    {
        static bool prm[1000001]={0};
        static int funn[1000001];
        vector<int>tprm;
        int tot=1e6;
        for(int i=2;i<=tot;i++)
        {
            if(!prm[i])
            {
                int itr=i;
                while(itr<=tot)
                {
                    if(!prm[itr]) funn[itr]=i;
                    prm[itr]=1;
                    itr+=i;
                }
            }
        }
        int n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++) cin>>a[i];
        bool ok=1;
        set<int>wd;
        for(int i=0;i<n;i++)
        {
            int val=a[i];
            set<int>id;
            while(val>1)
            {
                if(id.find(funn[val])==id.end())
                {
                    id.insert(funn[val]);
                }
                val/=funn[val];
            }
            for(auto it:id)
            {
                auto itr=wd.find(it);
                if(itr==wd.end())
                {
                    wd.insert(it);
                }
                else
                {
                    ok=0;
                    break;
                }
            }
            if(!ok) break;
        }
        if(ok)
        {
            cout<<"pairwise coprime\n";
            return 0;
        }
        int gc=a[0];
        for(int i=1;i<n;i++) gc=gcd(gc,a[i]);
        if(gc==1)
        {
            cout<<"setwise coprime\n";
            return 0;
        }
        cout<<"not coprime\n";
        
    }
}


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


int main() {
  string s ;
  cin >> s ;
  int n ;
  cin >> n ;
  
  double t=s.size();
  string a ;
  
  for(int i=0 ; i<(t/n) ; i++ ){
    a+=s.at(0+i*n);
  }
  
  cout << a << endl;
}

Measured memory_bytes: 256