akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define debug(x) cout << #x << " = " << x << endl
#define print(x) cout << x << endl;

struct edge
{
    ll to;
    ll cost;
    edge(ll _to, ll _cost)
    {
        to = _to;
        cost = _cost;
    }
};

struct Graph
{
    ll V;
    vector<vector<edge>> edges;

    // V is the number of vertices
    Graph(ll _V)
    {
        // init
        V = _V;
        rep(i, V)
        {
            edges.push_back({});
        }
    }

    void addEdge(ll u, ll v, ll w)
    {
        edges[u].push_back(edge(v, w));
    }

    // O((E+N)logN)
    vector<ll> dijkstra(ll s) // s: starting vertex
    {

        using node = pair<int, int>; // node.second can be reached by cost n.first

        // init min distance vector
        // d[i] is the minimum distance from s to i
        vector<ll> d(V);
        rep(i, V)
        {
            d[i] = LLONG_MAX;
        }

        // the top element is the vertex with the smallest cost
        priority_queue<node, vector<node>, greater<node>> q;

        // init start vertex
        d[s] = 0;
        q.push(node(0, s));

        // update
        while (!q.empty())
        {
            node n = q.top();
            q.pop();

            // cout << "Now at node " << n.second << endl;

            // Check all the node which connects with n
            for (edge e : edges[n.second])
            {
                // cout << "Searching edge from " << n.second << " to " << e.to << endl;
                ll cand = d[n.second] + e.cost; // Cost via n
                // cout << "Candidate cost to " << e.to << " is " << cand << endl;

                if (cand < d[e.to])
                {
                    // cout << "Update cost for " << e.to << " to " << cand << endl;
                    d[e.to] = cand;
                    q.push(node(cand, e.to)); // If via n is better, this may improve the shortest cost so need check
                }
            }
        }

        return d;
    }
};

int main()
{
    int N, X, Y;
    cin >> N >> X >> Y;

    // Init
    Graph G = Graph(N);
    rep(i, N - 1)
    {
        G.addEdge(i, i + 1, 1);
        G.addEdge(i + 1, i, 1);
    }
    G.addEdge(X - 1, Y - 1, 1);
    G.addEdge(Y - 1, X - 1, 1);

    vector<ll> shortest = G.dijkstra(0);

    // Search
    vector<vector<ll>> shortestpath;
    rep(i, N)
    {
        shortestpath.push_back(G.dijkstra(i));
    }

    vector<ll> ans(N);
    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            ans[shortestpath[i][j] - 1] += 1;
        }
    }

    rep(i, N - 1)
    {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 31744
import java.io.*;

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

    int n = Integer.parseInt(br.readLine());

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

      int x = i;

      if(x % 3 == 0)

        sb.append(" " + i);

      else{

        while(x > 0){
          if(x % 10 == 3){
            sb.append(" " + i);
            break;
          }else {
            x /= 10;
          }
        }
      }  
    }
    System.out.println(sb);
  }
}

Measured memory_bytes: 26392
#include<stdio.h>
#include<math.h>
#include<string.h>
int main(){
    long long int a,i=1,reminder,temp,divide,sum=0;
    scanf("%lld",&a);
    temp=a;
    for(;temp!=0;){
        reminder=temp%10;
        divide=temp/10;
        sum+=reminder;
        temp=divide;
    }
    if(a%sum==0) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, b, a;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
}

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

int main(){
  char alpha;
  cin >> alpha;
  int x = alpha - 'a';
  if(x>=0){
    cout << "a";
  }else{
    cout << "A";
  }
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

typedef long double ld;

const ld INF = 1e18 + 239;

int n;

vector<int> x;
vector<int> y;
vector<int> dir;

ld solve(ld t) {
	ld xf = INF;
	ld xs = -INF;
	ld yf = INF;
	ld ys = -INF;
	for (int i = 0; i < n; i++) {
		ld tx = x[i];
		ld ty = y[i];
		if (dir[i] == 0) tx += t;
		if (dir[i] == 1) tx -= t;
		if (dir[i] == 2) ty += t;
		if (dir[i] == 3) ty -= t;
		xf = min(xf, tx);
		xs = max(xs, tx);
		yf = min(yf, ty);
		ys = max(ys, ty);
	}
	return (xs - xf) * (ys - yf);
}

int xmin(int t) {
	int ans = INF;
	for (int i = 0; i < n; i++) {
		ans = min(ans, x[i] + t * (dir[i] == 'R') - t * (dir[i] == 'L'));
	}
	return ans;
}

int xmax(int t) {
	int ans = INF;
	for (int i = 0; i < n; i++) {
		ans = min(ans, x[i] + t * (dir[i] == 'R') - t * (dir[i] == 'L'));
	}
	return ans;
}



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

	cout << fixed << setprecision(16);

	cin >> n;
	x.resize(n);
	y.resize(n);
	dir.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		char c;
		cin >> c;
		if (c == 'R') dir[i] = 0;
		if (c == 'L') dir[i] = 1;
		if (c == 'U') dir[i] = 2;
		if (c == 'D') dir[i] = 3;
	}
	ld l = 0;
	ld r = 1e18 + 239;
	for (int i = 0; i < 500; i++) {
		ld tl = l + (r - l) / 3;
		ld tr = r - (r - l) / 3;
		if (solve(tl) > solve(tr)) {
			l = tl;
		} else {
			r = tr;
		}
	}
	cout << solve(r) << endl;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>
 
const int MAX_N = 5050;
long long N, K;
long long a[MAX_N];

bool can_make[MAX_N][MAX_N];

bool check(const int id) {
    if (K <= a[id]) {
        return true;
    }

    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= K; j++) {
            can_make[i][j] = false;
        }
    }

    can_make[0][0] = true;

    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= K; j++) {
            if (can_make[i-1][j]) {
                can_make[i][j] = true;
            }
            if (i != id && j + a[i] <= K && can_make[i-1][j]) {
                can_make[i][j + a[i]] = true;
                //std::cout << i << " " << j + a[i] << std::endl;
            }
        }
    }

    for (int k = K - a[id]; k < K; k++) {
        if (can_make[N][k]) {
            return true;
        }
    }

    return false;
}

 
int main(int argc, char **argv) {
    std::cin >> N >> K;

    for (int i = 1; i <= N; i++) {
        std::cin >> a[i];
    }

    std::sort(a + 1, a + 1 + N);

    //std::cout << a[1] << " " << a[2] << " " << a[3] << std::endl;

    if (!check(N)) {
        std::cout << N << std::endl;
        return 0;
    } else if (check(1)) {
        std::cout << 0 << std::endl;
        return 0;
    }

    int lb = 1;
    int ub = N;

    while (lb + 1 < ub) {
        int mid = (lb + ub) / 2;
        if (check(mid)) {
            ub = mid;
        } else {
            lb = mid;
        }
    }

    std::cout << lb << std::endl;
    
    return 0;
}

Measured memory_bytes: 24960
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq
import math

def ri():
    return int(input())

def rl():
    return list(map(int, input().split()))


def solve():
    r = ri()
    print (2 * r * math.pi)






mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()


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

int main(){
	int a,b,sum=0;
	cin>>a>>b;
	if (a>=b){
		sum+=a;
		a--;;
	}
		else {
		sum+=b;
		b--;
}
		if (a>=b){
		sum+=a;
		a--;
	}
		else {
		sum+=b;
		b--;
}
	cout<<sum<<endl;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n , m;
pair <long,long> p[1000001];
int main(){
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        cin >> p[i].first >> p[i].second;
    }
    sort(p + 1, p + 1 + n);
    long long ans = 0;
    for(int i = 1; i <= n; i++){
        if(m < p[i].second){
            ans += m * p[i].first;
            m = 0;
        }
        else{
            ans += p[i].first * p[i].second;
            m -= p[i].second;
        }
    }
    cout << ans;
    return 0;
}


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

int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	int sum=0;	
	a[n-1]/=2;
	for(int i=0;i<n;i++)
	{
		sum+=a[i];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()


def main():
    T = list(input() + 'E')
    ans = 0
    for i, t in enumerate(T):
        if t == 'P':
            if T[i + 1] == 'D' or T[i + 1] == '?': 
                ans += 1
                T[i + 1] = 'D'
        elif t == 'D':
            ans += 1
        elif t == '?':
            ans += 1
            T[i] = 'D'
    T.pop()
    print("".join(T))




if __name__ == "__main__":
    main()


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


int main(void) {
	int n;
	cin >> n;
	vector <int> vec[2];
	int v;
	for (int i = 0; i < n; i++) {
		cin >> v;
		vec[(i&1)].push_back(v);
	}
	std::sort(vec[0].begin(), vec[0].end());
	std::sort(vec[1].begin(), vec[1].end());

	int vec_cnt = n/2;
	vector  <pair <int, int>> same_vec[2];

	for (int i = 0; i < 2; i++) {
		int same_cnt = 0;
		int preval = 0;
		for (unsigned int j = 0; j < vec[i].size(); j++) {
			int thisval = vec[i].at(j);
			if (preval != thisval) {
				same_vec[i].push_back(make_pair(same_cnt, preval));
				same_cnt = 0;
			}
			preval = thisval;
			same_cnt++;
		}
		// last
		same_vec[i].push_back(make_pair(same_cnt, preval));
	}
	for (int i = 0; i < 2; i++) {
		std::sort(same_vec[i].begin(), same_vec[i].end(),
			[](const pair <int, int>& x, const pair <int, int>& y) {return x.first > y.first;});
	}

	int ans = n;
	int tmp_ans = 0;

	tmp_ans = n/2 - same_vec[0].at(0).first;
	if (same_vec[0].at(0).second != same_vec[1].at(0).second) {
		tmp_ans += (n/2 - same_vec[1].at(0).first);
	} else {
		tmp_ans += (n/2 - same_vec[1].at(1).first);
	}
	ans = std::min(ans, tmp_ans);

	tmp_ans = n/2 - same_vec[1].at(0).first;
	if (same_vec[0].at(0).second != same_vec[1].at(0).second) {
		tmp_ans += (n/2 - same_vec[0].at(0).first);
	} else {
		tmp_ans += (n/2 - same_vec[0].at(1).first);
	}
	ans = std::min(ans, tmp_ans);

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


Measured memory_bytes: 1784
#include<cstdio>
#define N 300003
int a[N],i,l,m,n,r,s,x;
inline void solve(){for(s=0,i=2;i<n;i+=2)if(m<=a[i-1]-s)s=s<a[i]?s:a[i];}
int main()
{
    scanf("%d",&n);
    for(i=1;i<=n;i++)scanf("%d",a+i);
    for(i=2;i<=n;i+=2)x+=a[i],a[i]=-a[i];
    for(i=1;i<=n;i++)a[i]+=a[i-1];
    if(~n&1)return 0*printf("%d %d\n",a[n]>0?x+a[n]:x,a[n]>0?x:x+a[n]);
    for(l=0,r=x+a[n]+x;l<r;)m=l+r+2>>1,solve(),m<=a[n]-s?l=m:r=m-1;
    return 0*printf("%d %d\n",x+l,x+a[n]-l);
}

Measured memory_bytes: 1280
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

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

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

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

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	s := Scanner()
	x, y := intScanner(), intScanner()
	f := true
	p := make([]int, 1, len(s))
	q := make([]int, 0, len(s))
	for i := 0; i < len(s); i++ {
		if f {
			if string(s[i]) == "F" {
				p[len(p)-1]++
			} else {
				f = false
				q = append(q, 0)
			}
		} else {
			if string(s[i]) == "F" {
				q[len(q)-1]++
			} else {
				f = true
				p = append(p, 0)
			}
		}
	}
	dpx := make([][]bool, len(p))
	dpy := make([][]bool, len(q)+1)
	dpx[0] = make([]bool, 16001)
	dpy[0] = make([]bool, 16001)
	dpx[0][p[0]+8000] = true
	dpy[0][8000] = true
	p = p[1:]
	for i, v := range p {
		dpx[i+1] = make([]bool, 16001)
		for j := 0; j < 16001; j++ {
			if j-v >= 0 {
				dpx[i+1][j] = dpx[i+1][j] || dpx[i][j-v]
			}
			if j+v < 16001 {
				dpx[i+1][j] = dpx[i+1][j] || dpx[i][j+v]
			}
		}
	}
	for i, v := range q {
		dpy[i+1] = make([]bool, 16001)
		for j := 0; j < 16001; j++ {
			if j-v >= 0 {
				dpy[i+1][j] = dpy[i+1][j] || dpy[i][j-v]
			}
			if j+v < 16001 {
				dpy[i+1][j] = dpy[i+1][j] || dpy[i][j+v]
			}
		}
	}
	if dpx[len(dpx)-1][x+8000] && dpy[len(dpy)-1][y+8000] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

#define int long long

using namespace std;

typedef pair<int, int> pii;

const int MAXN = 100 * 1000 + 123;








int n, m, f[MAXN];
bool mark[MAXN];
vector<pii> g[MAXN];

void dfs(int);

int32_t main() {
    memset(f, 15, sizeof f);
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        g[--l].push_back({--r, d}), g[r].push_back({l, -d});
    }
    for (int i = 0; i < n; i++)
        if (!mark[i])
            dfs(i);
    for (int i = 0; i < n; i++)
        for (auto ss : g[i]) {
            int u, x;
            tie(u, x) = ss;
            if (f[u] != f[i] + x)
                return cout << "No", 0;
        }
    cout << "Yes";
    return 0;
}
void dfs(int v) {
    mark[v] = true;
    for (auto ss : g[v]) {
        int u, q;
        tie(u, q) = ss;
        if (!mark[u]) {
            f[u] = f[v] + q;
            dfs(u);
        }
    }
}

Measured memory_bytes: 15616
#include <iostream>
#include <cmath>

int main(){
    int n,max,ans=0;
    std::cin>>n;
    int a[n],b[n]={0},c=2;
    for(int i=0;i<n;i++){
        std::cin>>a[i];
    }

    max=a[0];
    for(int i=1;i<n;i++){
        if(a[i]>max) max=a[i];
    }

    for(int i=0;i<n;i++){
        for(int j=2;j<sqrt(max);j++){
            if(a[i]!=j && a[i]%j==0) break;
            if(j==(int)sqrt(max)) b[i]=1;
        }
    }
    
    for(int i=0;i<n;i++){
        if(b[i]==1) ans++;
    }
    
    std::cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,x,n) for(int i=x;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=3005,INF=1<<29;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N;cin>>N;
        if(N==0) break;
        
        int ans=0;
        
        for(int a=0;a*a<=N;a++){
            for(int b=a;a*a+b*b<=N;b++){
                for(int c=b;a*a+b*b+c*c<=N;c++){
                    int rem=N-a*a-b*b-c*c;
                    if(int(sqrt(rem))*int(sqrt(rem))==rem&&c<=int(sqrt(rem))) ans++;
                }
            }
        }
        
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3140
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    bool is_prime(Int x) {
        if (x <= 1) return false;

        for (int i = 2; i * i <= x; ++i) {
            if (x % i == 0) {
                return false;
            }
        }
        return true;
    }

    void solve() {

//        Int A, B, K;
//        cin >> A >> B >> K;
//        Int dec = min(A, K);
//        A -= dec;
//        K -= dec;
//        dec = min(B, K);
//        B -= dec;
//        K -= dec;
//
//        cout << A << " " << B << endl;

        Int N;
        cin >> N;
        for (Int x = N;; ++x) {
            if (is_prime(x)) {
                cout << x << endl;
                break;
            }
        }
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, long long>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

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

  ll N; cin >> N;

  // 1/w = 4/N - 1/h - 1/n
  // = (4hn - Nn - nh)/Nhn
  for(int h=1; h<=3500; h++) {
    for(int n=1; n<=3500; n++) {
      ll u = N*h*n;
      ll d = 4*h*n - N*n - N*h;
      // 1/w = d/u;
      if (d > 0 && u > 0 && u%d == 0) {
        cout << h << ' ' << n << ' ' << u/d << endl;
        return 0;
      }
    }
  }
}

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

int main(){
  int a,b,c,k;cin>>a>>b>>c>>k;
  if(a >= k)cout << k << endl;
  else if(a + b>= k)cout << a << endl;
  else cout << a - (k - a - b) << endl;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<vector>
using namespace std;

int main(){
    int a,b,k,cnt=0;
    vector<int> v;
    scanf("%d %d %d",&a,&b,&k);
    for(int i=1;i<=100;i++){
        if(a%i==0&&b%i==0){
            v.push_back(i);
        }
    }
    printf("%d\n",v[v.size()-k]);
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
long long int X,ans,upp=123456,low=0;
	scanf("%lld",&X);
	while(upp-low!=1){
		ans=(upp+low)/2;
		if(((ans*(ans-1))/2)>=X){
			upp=ans;
		} else{
			low=ans;
		}
	}
	printf("%lld\n",low);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pair<int,int>>

vector<vi> vec;
vector<vi> dp;
int n;

int solve(int i, int p){
    if (i == n)
        return 0;
    if (dp[i][p] != -1)
        return dp[i][p];
    int x[3];
    x[0] = x[1] = x[2] = 0;
    for (int j = 0 ; j < 3 ; ++j){
        if (j!=p)
            x[j] = solve(i+1, j)+vec[i][j];
    }
    dp[i][p] = max(max(x[0], x[1]), x[2]);
    return dp[i][p];
}

int main(){
    ios::sync_with_stdio(0);
    cin >> n;
    vec.assign(n, vi(3,0));
    dp.assign(n, vi(3,-1));
    for (int i = 0 ; i < n ; ++i)
        cin >> vec[i][0] >> vec[i][1] >> vec[i][2];
    cout << max(solve(0, 0),max(solve(0,1), solve(0, 2)));
    return 0;
}


Measured memory_bytes: 17408
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <queue>

using namespace std;

int main(){
    int n; cin >> n;
    vector<pair<int, int>> ai(n);
    for(int i=0; i<n; ++i){
        int a; cin >> a;
        ai[i]={a, i};
    }
    sort(ai.begin(), ai.end());
    for(int i=0; i<n; ++i){
        cout << ai[i].second+1 << (i==n-1 ? '\n' : ' ');
    }
    return 0;
}


Measured memory_bytes: 1536
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    assert_eq!(!0usize, std::usize::MAX); //🙊
    assert!(0 == 0); //😇
    let s1 = io.chars();
    let s2 = io.chars();
    let s3 = io.chars();

    io.write((s1[0] as u8 - b'a' + b'A') as char);
    io.write((s2[0] as u8 - b'a' + b'A') as char);
    io.write((s3[0] as u8 - b'a' + b'A') as char);
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


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

int main() {
  string a, beginning, num, end,answer;
  cin >> a ;
  beginning = a[0]; 
  end = a[a.size()-1];
  num = std::to_string(a.size()-2);
  answer = beginning+num+end;
  cout << answer<< endl;
}




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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define FOR(i,a) for (int i=0;i<(a);++i)
#define FORD(i,a) for (int i=(a)-1;i>=0;i--)
#define FORT(i,a,b) for (int i=(a);i<=(b);++i)
#define FORTD(i,b,a) for (int i=(b);i>=(a);--i)
#define trav(i,v) for (auto i : v)
#define all(v) v.begin(),v.end()
#define ad push_back
#define fr first
#define sc second
#define mpr(a,b) make_pair(a,b)
#define pir pair<int,int>
#define all(v) v.begin(),v.end()
#define make_unique(v) v.erase(unique(all(v),v.end()))
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define dbg(x);
#define dbgv(v);
#define srng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define y1 EsiHancagorcRepa
#ifdef ALEXPC
#define dbg(x); cout<<#x<<" = "<<x<<endl
#define dbgv(v); cout<<#v<<" = ["; trav(tv,v)cout<<"tv,";cout<<"]"<<endl
#endif

//const int N=100,M=N*N;
const ll MOD=1000*1000*1000+7;

const int N=1e5+6;

vector<int> g[2*N];
ll qan1[2*N],qan2[2*N];
bool col[2*N];
void dfs(int v,int comp){
    if (v>N) qan1[comp]++;
    else qan2[comp]++;
    col[v]=true;
    trav(to,g[v]){
        if (!col[to])dfs(to,comp);
    }
}

int main(){
    fastio;
    srng;
    int n,k;
    cin>>n>>k;
    if (k>(n-1)*(n-2)/2){
        cout<<-1<<endl;
        return 0;
    }
    vector<pir> pat;
    FORT(i,2,n){
        pat.ad({1,i});
    }
    int qan=(n-1)*(n-2)/2;
    while(qan!=k){
        FORT(i,2,n){
            FORT(j,i+1,n){
                pat.ad({i,j});
                qan--;
                if (qan==k)break;
            }
            if (qan==k)break;
        }
    }
    cout<<pat.size()<<endl;
    trav(tv,pat){
        cout<<tv.fr<<" "<<tv.sc<<endl;
    }
    return 0;
}


Measured memory_bytes: 6400
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
using namespace std;

int main() {
  string s;
  cin >> s;
  if (s[0] == '7' ||
      s[1] == '7' ||
      s[2] == '7') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <unordered_map>
#include <cmath>
#include <stdlib.h>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <sstream>

using namespace std;
typedef long long ll;

int main()
{
  ll ans = 0;
  ll n, k;
  cin >> n >> k;
  ll r, s, p;
  cin >> r >> s >> p;
  string t;
  cin >> t;

  auto calc_point = [p, r, s](char h) {
    ll point;
    if (h == 'r')
    {
      point = p;
    }
    else if (h == 's')
    {
      point = r;
    }
    else if (h == 'p')
    {
      point = s;
    }
    return point;
  };

  vector<int> hands(n, 0);
  ll total = 0;

  for (ll i = 0; i < n; i++)
  {
    auto h = t.at(i);
    ll point = calc_point(h);

    if (i - k >= 0)
    {
      // k個前が同じである
      if (t.at(i - k) == h)
      {
        if (hands[i - k] == 0)
        {
          hands[i] = 1;
          total += point;
        }
      }
      else
      {
        hands[i] = 1;
        total += point;
      }
    }
    else
    {
      hands[i] = 1;
      total += point;
    }
  }

  cout << total << endl;
}


Measured memory_bytes: 896
import itertools


def is_bright(switch, status, p):
    count = 0
    for s in switch:
        if status[s - 1]:
            count += 1
            
    return count % 2 == p


n, m = map(int, input().split())
switches = list()
for i in range(m):
    tmp = input().split()
    switches.append(list(map(int, tmp[1:])))

ps = list(map(int, input().split()))

count = 0
for status in itertools.product(*[[True, False]] * n):
    for switch, p in zip(switches, ps):
        if not is_bright(switch, status, p):
            break
    
    else:
        count += 1

print(count)

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

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    ll n, k;
    cin >> n >> k;
    n %= k;
    cout << min(k-n, n);
    return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  
  int jg = (a * b) % 2;
  if (jg == 0) {
    cout << "Even" << endl;
  }else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.12f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 1010101;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// mod.m での a の逆元 a^ { -1 } を計算する
long long modinv(long long a, long long m) {
	long long 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;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x /gcd(x, y) * y );
}

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank2[x] == rank2[y]) {
			rank2[x]++;
		}
	}
}


ll dx[8] = { 1,-1,0,0,1,1,-1,-1 };
ll dy[8] = { 0,0,1,-1,1,-1,1,-1 };
char c[2010][2010];
ll dp[101010][20];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n+1);
	vector<ll>res(n + 1);
	rep(i, n) {
		cin >> a[i + 1];
	}
	ll ans = 0;
	for (ll i = n ;i >= 1;--i) {
		ll res2 = 0;
		ll target = i;
		ll kazu = 1;
		while (target*kazu <= n) {
			res2 += res[target * kazu];
			kazu++;
		}
		if (res2 % 2 != a[i]) {
			res[i]++;
			ans++;
		}
	}
	cout << ans << endl;
	rep(i, n + 1) {
		if (res[i])cout << i << endl;
	}
	return 0;
}


Measured memory_bytes: 6292
import sys
a = list(map(int,input().split()))

j1 = int(a[0]==a[1])
j2 = int(a[1]==a[2])
j3 = int(a[2]==a[0])

if (j1 * j2 * j3) != 0 or (1-j1)*(1-j2)*(1-j3) !=0 :
  print('No')
else:
  print('Yes')


Measured memory_bytes: 38384
#include <iostream>
#include <cstdlib>
#include <string>
#include <typeinfo>
using namespace std;
int main()
{
    int n;
    double x, ans = 0;
    string s;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x >> s;
        if (s == "JPY")
        {
            ans += x;
        }
        else
        {
            ans += x * (380000.0);
        }
    }
    cout << ans << endl;
    return 0;
}


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

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

    static class CBoxesAndCandies {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long x = in.nextLong();
            long a[] = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextLong();
            }
            long c = 0;
            for (int i = 1; i < n; i++) {
                if ((a[i] + a[i - 1]) > x) {
                    long temp = a[i] + a[i - 1] - x;
                    c += temp;
                    if (a[i - 1] > x) {
                        a[i] = 0;
                    } else {
                        a[i] -= temp;
                    }
                }
            }
            out.println(c);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 41228
#include<iostream>
using namespace std;
int main(){
    int m,f,b;
    cin >> m >> f >> b;
    if(m >= b){
        cout << 0 << endl;
    }else if(m + f >= b){
        cout << b - m << endl;
    }else{
        cout << "NA" << endl;
    }
}


Measured memory_bytes: 3100
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}
ll kai(vector<ll> A, ll key) {
	ll an = 0;
	rep(i, A.size()) {
		an += (A.at(i) - 1) / key;
	}
	return an;
}
// index が条件を満たすかどうか
bool isOK(int index,vector<ll> A, int K) {
	if (kai(A,index) <= K) return true;
	else return false;
}

// 汎用的な二分探索のテンプレ
int binary_search(ll MA,vector<ll> A,ll K) {
	int left = 0; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = MA; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, A,K)) right = mid;
		else left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
vector<ll> fact, factinv, inv;
ll mod = 1e9 + 7;
void prenCkModp(ll n) {
	fact.resize(n + 5);
	factinv.resize(n + 5);
	inv.resize(n + 5);
	fact.at(0) = fact.at(1) = 1;
	factinv.at(0) = factinv.at(1) = 1;
	inv.at(1) = 1;
	for (ll i = 2; i < n + 5; i++) {
		fact.at(i) = (fact.at(i - 1) * i) % mod;
		inv.at(i) = mod - (inv.at(mod % i) * (mod / i)) % mod;
		factinv.at(i) = (factinv.at(i - 1) * inv.at(i)) % mod;
	}

}
ll nCk(ll n, ll k) {
	if (n < 0 || k < 0){
		return 1;
	}
	else if (n < k) {
		return 0;
	}
	return fact.at(n) * (factinv.at(k) * factinv.at(n - k) % mod) % mod;
}

ll dp[100002];
void res() {
	for (ll n = 0; n < 102; n++) {
		for (ll v = 0; v < 100002; v++) {
			dp[n] = 1e12;
		}
	}
}
int main() {
	ll N, S = 0, mod = (1e9 + 7),an=0;
	cin >> N;
	vector<ll> A(N);
	rep(i, N) {
		cin >> A.at(i);
		S += A.at(i);
	}
	
	rep(i, N - 1) {
		S -= A.at(i);
		an += (S % mod) * A.at(i);
		an %= mod;
	}
	cout << an << endl;
}


Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
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; }
const ll INF = 1LL << 60;


int main(){
    int n,p;
    cin >> n >> p;
    string s;
    cin >> s;
    vector<int> a(n);
    rep(i,n) a[n-1-i] = s[i] -'0';
    //rep(i,n) cout << "a:" << a[i] << endl;

    ll ans = 0;
    if(10%p==0){
        rep(i,n){
            if(a[i]%p == 0) ans += n-i;
        }
    }else{
        vector<int> d(n+1); //index i+1=iけためまでの累積和
        int ten = 1;
        d[0] = 0;
        rep(i,n){
            int now = a[i]*ten % p;
            d[i+1] = (d[i] + now) % p;
            ten = (ten * 10) % p;
        }
        //rep(i,n+1) cout << d[i] << endl;
        map<int,ll> mp;
        rep(i,n+1) mp[d[i]]++;
        rep(i,p) ans += max((ll)0, mp[i]*(mp[i]-1)/2);
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  string a, b;
  cin >> a >> b;
  
  sort (a.begin(),a.end());
  sort (b.begin(),b.end());
  reverse (b.begin(),b.end());
  
  if (a < b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>

using namespace std;
int main()
{
	int n;
	int a1 = 0;
	int a2 = 0;
	int a3 = 0;
	int tmp = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{		
		scanf("%d", &tmp);
		if (tmp % 4 == 0) {
			a1++;
		}
		else if (tmp % 2 == 0)
		{
			a2++;
		}
		else {
			a3++;
		}
	}
	if ((a2 > 0 && a1 >= a3)||(a2==0&&a1>=a3-1))printf("Yes");
	else printf("No");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
  vector<int> v(5);
  int res = 0;
  for(int i=0;5>i;++i) cin >> v[i];
  int aaa = v[0] % 10;
  for(int x:v){
    res += x/10 * 10;
    if (x%10 > 0) res +=10;
    if (x%10 < aaa && x%10 > 0){aaa = x%10;}
  }
  cout << ((aaa > 0)? res -10 + aaa: res) << endl;
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

template<typename T1,typename T2> using M = map< T1, T2>;
using Mii = M<int, int>;

int f(int n){
    if(n%2==0){
        return n/2;
    }else{
        return 3*n+1;
    }
}

int main(){
    int n;
    cin>>n;
    Vi h(n);
    REP(i,n) cin>>h[i];

    Vi t(n);
    int cnt = 0;
    while(1){
        REP(i,n){
            if(t[i] != h[i]){
                t[i]++;
                if(i!=n-1 && t[i+1] == h[i+1]){
                    cnt++;
                }
                if(i==n-1){
                    cnt++;
                }
            }
        }
        bool flag = true;
        REP(i,n){
            if(t[i] != h[i]) flag = false;
        }
        if(flag) break;
    }

    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define il inline
#define RG register
#define ll long long
#define N (2005)
 
using namespace std;
 
int g[N][N],h[N][N],mx[N],st[N],n,m,ans;
 
il int gi(){
  RG int x=0,q=1; RG char ch=getchar();
  while ((ch<'0' || ch>'9') && ch!='-') ch=getchar();
  if (ch=='-') q=-1,ch=getchar();
  while (ch>='0' && ch<='9') x=x*10+ch-48,ch=getchar();
  return q*x;
}
 
il char gc(){
  RG char ch=getchar();
  while (ch!='#' && ch!='.') ch=getchar(); return ch;
}
 
int main(){
  n=gi(),m=gi(),ans=max(n,m);
  for (RG int i=1;i<=n;++i)
    for (RG int j=1;j<=m;++j) g[i][j]=gc()=='#';
  for (RG int i=1;i<n;++i)
    for (RG int j=1;j<m;++j)
      h[i][j]=g[i][j]^g[i][j+1]^g[i+1][j]^g[i+1][j+1]^1;
  for (RG int i=1,top;i<n;++i){
    top=0;
    for (RG int j=1;j<m;++j) h[i][j]?++mx[j]:mx[j]=0;
    for (RG int j=1;j<=m;++j){
      while (top && mx[st[top]]>=mx[j])
	ans=max(ans,(j-st[top-1])*(mx[st[top]]+1)),--top;
      st[++top]=j;
    }
  }
  cout<<ans; return 0;
}

Measured memory_bytes: 31616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
public static void main(String[] args) throws IOException {

BufferedReader br =new BufferedReader (new InputStreamReader (System.in));

String line = br.readLine( );
String[] list = line.split(" ");
int a = Integer.parseInt(list[0]);
int b = Integer.parseInt(list[1]);
int c = Integer.parseInt(list[2]);

System. out. println(c>=a&&c<=b?"Yes":"No");
}}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#include <vector>
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

using namespace std;
#define int long long
using ll = long long;
const int MX = 1e6;
const ll inf = 1e13;
const int mod = 1e9+7;
double p;

int c[MX];
int vis[MX];
vector<vector<int>> g;
void dfs(int v) {
    vis[v]=1;
    for(auto cv: g[v]) {
        if(vis[cv]>0) continue;
        c[cv]+=c[v];
        dfs(cv);
    }
}

signed main() {
    int n,q;
    cin >> n >> q;
    g.resize(n);
    rep(i,n-1) {
        int a,b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    rep(i,q) {
        int p,x;
        cin >> p >> x;
        p--;
        c[p]+=x;
    }
    dfs(0);
    rep(i,n)cout << c[i] <<" "<< flush;
    cout << "" << endl;
    return 0;
}



Measured memory_bytes: 26704
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<ctype.h>


int main ()
{
   int r, area1, area2, result;
   scanf("%d", &r);
   area1 = (22/7)*1;
   area2 = (22/7)*r*r;
   result = area2 / area1;
   printf("%d", result);


 return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define rep(i,n) for(long long  i = 0; i < n; i++)
#define rep2(i,a,n) for(long long  i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

using namespace std;

long long ans = 0;
vector<int> cnt(5,0);

void solve(vector<int> index)
{
    ll comb = 1;
    //for(auto v : index ) cout << v << ","; cout << endl;
    for(auto v : index ) {
        
        if(cnt[v] == 0) { return; }
        comb *= cnt[v];
    }
    ans += comb;
}

void recursive_comb(int n, int k, vector<int> v)
{
    if(k==0) { 
        solve(v); 
        return; 
    } else {
        if(n < 0) { return; }
        //solve(bit);
        recursive_comb(n-1, k, v);
        v[k-1] = n;
        recursive_comb(n-1, k-1, v);
    }
}

void comb(int n, int k)
{
    vector<int> v(k,0);
    recursive_comb(n-1, k, v);
}

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

    vector<string> s(n); rep(i,n) { cin >> s[i]; }

    enum index { M, A, R, C, H};

    rep(i,n) { 
        if(s[i][0] == 'M') { cnt[M]++; }
        if(s[i][0] == 'A') { cnt[A]++; }  
        if(s[i][0] == 'R') { cnt[R]++; }
        if(s[i][0] == 'C') { cnt[C]++; }
        if(s[i][0] == 'H') { cnt[H]++; }
    }

    n = 0;
    rep(i,5) { if(cnt[i] != 0) n++; } 
    if(n < 3) {
        cout << 0 << endl;
    } else {
        comb(5, 3);
        cout << ans << endl;
    }

    return 0;
}
    



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

using namespace std;

using lli = long long int;

const lli mod = 1e9 + 7;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    lli ans, a, n, i, j, k;
    
    ans = 0;
    cin >> n;
    
    vector<lli> cnt(60);
    
    
    
    for(i = 0; i < n; ++i)
    {
        cin >> a;
        j = 0;
        while(a)
        {
            if (a % 2 == 1)
            {
                cnt[j] += 1;
            }
            a /= 2;
            ++j;
        }
    }
    
    for(i = 0; i < 60; ++i)
    {
        a = 1;
        a = a << i;
        a %= mod;
        k = (cnt[i] * (n - cnt[i])) % mod;
        ans = (ans  +  ((a * k) % mod)) % mod;
    }
    
    
    cout << ans;
    
    return 0;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
using namespace std;

int n;
long long a[210000];

long long add(long long &sum, bool plus) {
    if (plus) {
        if (sum >= 1) return 0;
        else {
            long long res = abs(sum - 1);
            sum = 1;
            return res;
        }
    }
    else {
        if (sum <= -1) return 0;
        else {
            long long res = abs(sum + 1);
            sum = -1;
            return res;
        }
    }
}

int main() {
    while (cin >> n) {
        cin >> a[0];
        long long psum = a[0], msum = a[0];
        long long plus = add(psum, true), minus = add(msum, false);
        for (int i = 1; i < n; ++i) {
            cin >> a[i];
            psum += a[i];
            msum += a[i];
            if (i & 1) {
                plus += add(psum, false);
                minus += add(msum, true);
            }
            else {
                plus += add(psum, true);
                minus += add(msum, false);
            }
        }
        cout << min(plus, minus) << endl;
    }
}





Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

void push(int *, int);
int pop(int *);
int isEmpty(void);
int isFull(void);

int top = 0;

int main(){
  int i, S[1000];
  char x[100];

  while(scanf("%s", x)!=EOF){

    if(x[0] == '+'){
      S[top - 1] += pop(S);
    }
    else if(x[0] == '-'){
      S[top - 1] -= pop(S);
    }
    else if(x[0] == '*'){
      S[top - 1] *= pop(S);
    }
    else{
      i = atoi(x);
      push(S, i);
    }
  }

  printf("%d\n", S[top]);

  return 0;
}

void push(int *S, int x){
  /*if(isFull()){
    fprintf(stderr, "OverFlow\n");
    return 0;
    }*/
  top++;
  S[top] = x;
}

int pop(int *S){
  /*if(isEmpty()){
    fprintf(stderr, "UnderFlow\n");
    return 0;
    }*/
  top--;
  return S[top + 1];
}

int isFull(){
  if(top >= 99) return 1;
  else return 0;
}

int isEmpty(){
  if(top == 0) return 1;
  else return 0;
}

Measured memory_bytes: 552