akhauriyash/Code-Regression huggingface dataset:
/*
 _____ _             _              _           _ 
|_   _| |__   ___   / \   _ __  ___| |__  _   _| |
  | | | '_ \ / _ \ / _ \ | '_ \/ __| '_ \| | | | |
  | | | | | |  __// ___ \| | | \__ \ | | | |_| | |
  |_| |_| |_|\___/_/   \_\_| |_|___/_| |_|\__,_|_|                                                

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll,ll>
#define msi         map<string,ll>
#define mis         map<ll, string>
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x) 	for(auto& a : x)
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pair<ll, ll>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define max(a,b)	(a>b?a:b)
#define min(a,b)	(a<b?a:b)

/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace __gnu_pbds;
using namespace std;
#define PI 3.141592653589793
#define N  200005
ll dp[N];
ll add(ll a,ll b,ll mod=hell)
{
	return (a+b)%mod;
}
ll sub(ll a,ll b,ll mod=hell)
{
	return (a-b+mod)%mod;
}
ll mul(ll a,ll b,ll mod=hell)
{
	return (a*b)%mod;
}
void solve()
{
	ll n,k;
	cin>>n>>k;
	rep(i,0,n+1)
	dp[i]=i;
	rep(i,1,n+1)
	dp[i]=(dp[i]+dp[i-1])%hell;
	ll ans=0;
	rep(i,k,n+2)
	{
		if(k==n+1)
			ans=(ans+1)%hell;
		else
		{
			// cout<<dp[n]-dp[n-k]<<" "<<dp[k-1]<<endl;
			ans=add(ans,sub(add(dp[n],1),add(dp[n-i],dp[i-1])));
			// ans+=dp[n]-dp[n-k]-dp[k-1]+1;
		}
	}
	cout<<ans<<endl;	
	return;
}
int main()
{
	FAST
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	TIME
	return 0;
}

Measured memory_bytes: 5332
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        var N = int.Parse(inputs[0]);
        var M = int.Parse(inputs[1]);
        var cityList = new List<City>(M);
        for (int i = 0; i < M; i++)
        {
            inputs = Console.ReadLine().Split(' ');
            var p = int.Parse(inputs[0]);
            var y = long.Parse(inputs[1]);
            var city = new City(i + 1, p, y);
            cityList.Add(city);
        }
        // 誕生年順にソートしておく
        cityList = cityList.OrderBy(ct => ct.Y).ToList();

        var dict = new Dictionary<long, List<City>>();
        for (int i = 0; i < M; i++)
        {
            var city = cityList[i];
            if (dict.ContainsKey(city.P))
            {
                dict[city.P].Add(city);
            }
            else
            {
                var list = new List<City>();
                list.Add(city);
                dict.Add(city.P, list);
            }
        }

        var codes = new string[M];
        for (int i = 1; i <= N; i++)
        {
            if (!dict.ContainsKey(i))
            {
                continue;
            }

            var list = dict[i];
            for (int j = 0; j < list.Count; j++)
            {
                var x = j + 1;
                var p = list[j].P;
                var value = p.ToString().PadLeft(6, '0') + x.ToString().PadLeft(6, '0');
                codes[list[j].id - 1] = value;
            }
        }

        foreach (var cd in codes)
        {
            Console.WriteLine(cd);
        }

    }

    struct Code
    {
        internal string value;
        internal int id;
        internal Code(int id, string value)
        {
            this.value = value;
            this.id = id;
        }
    }

    struct City
    {
        internal int id;
        internal int P;
        internal long Y;
        internal City(int id, int p, long y)
        {
            this.id = id;
            this.P = p;
            this.Y = y;
        }
    }

}



Measured memory_bytes: 48888
#include <iostream>
#include <vector>

using namespace std;
using i64 = long long int;

struct BIT{
    vector<i64> bit;
    i64 n;
    void add(i64 i, i64 x){
        ++i;
        while(i <= n){
            bit[i] += x;
            i += i & -i;
        }
    };
    BIT(i64 sz){
        n = sz;
        bit.assign(n + 1, 0);
    };
    BIT(vector<i64> a){
        n = a.size();
        bit.assign(n + 1, 0);
        for(i64 i = 0; i < a.size(); ++i){
            add(i, a[i]);
        }
    };
    i64 sum(i64 i){
        i64 ret = 0;
        ++i;
        while(i > 0){
            ret += bit[i];
            i -= i & -i;
        }
        return ret;
    };
    i64 sum(i64 l, i64 r){
        if(l == 0) return sum(r - 1);
        else return sum(r - 1) - sum(l - 1);
    };
};

void DSL_2_B(){
    i64 n, q;
    cin >> n >> q;
    BIT bit(n);
    for(i64 i = 0; i < q; ++i){
        i64 com, x, y;
        cin >> com >> x >> y;
        if(com == 0) bit.add(x - 1, y);
        if(com == 1) cout << bit.sum(x - 1, y) << endl;
    }
}

int main(){
    DSL_2_B();
}


Measured memory_bytes: 3544
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <bits/stdc++.h>
#include <cmath>
#include <stdio.h>
#include <utility>
using namespace std;
#define ll long long

int main()
{
   int a,b,c;cin>>a>>b>>c;
   map<int,int>m;
   m[a]++;
   m[b]++;
   m[c]++;
  cout<<m.size()<<endl;
return 0;
}


Measured memory_bytes: 256
// 1_abc139_a
#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>// C++
#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>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
#define MOD (1000000007)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s;
    cin >> t;
    int cnt = 0;
    rep(i, 3){
        if(s[i] == t[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>
void judge(int pe, int pm, int pj);
int main(void)
{
    int n, pe, pm, pj;
    while (1){
        scanf("%d", &n);
        if (n == 0){
            break;
        }
        for (int i = 0; i < n; ++i) {        
            scanf("%d %d %d", &pe, &pm, &pj);
            judge(pe, pm, pj);
        }
    }
}
void judge(int pe, int pm, int pj)
{
    int sum = pe + pm + pj;
    int sumem = pe + pm;
    bool flag2 = false;
    if (pm >= 80 || pe >= 80) {
        flag2 = true;
    }
    if(pe == 100 || pj == 100 || pm == 100 || sum >= 240 || sumem >= 180) {
        printf("A\n");
    } else if (sum >= 210) {
        printf("B\n");
    } else if (sum >= 150 && flag2 == true) {
        printf("B\n");
    } else {
        printf("C\n");
    }
}

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

using namespace std;
using ll =long long;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
#define leftunique(a) {sort((a).begin(),(a).end());(a).erase(unique((a).begin(),(a).end()),(a).end());}
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; }
static const ll INF = 1LL << 60;
//Write From this Line
const int dy[2] ={1,0};
const int dx[2] ={0,1};
const int limit_h = 105;
vector<string> field(limit_h);
int h, w;
int cost[110][110];
//vector<vector<int>> cost(h,vector<int> (w));
queue<pair<int,int>> que;
void bfs(void) {
	while(!que.empty()){
		int y = que.front().first;
		int x = que.front().second; // こいつらから1手すすめる
		que.pop();
		bool IS_BLACK = false;
		if(field[y][x] == '#') IS_BLACK = true;
		// 白で次行く場所が黒なら +1;
		rep(i,2){
			int ny = y + dy[i];
			int nx = x + dx[i];
			int n_cost = cost[y][x];
			if(IS_BLACK == false && field[ny][nx] == '#'){
				// 1つ前が白で、次行くのが黒ならcost + 1
				n_cost ++ ;
			}
			if(chmin(cost[ny][nx],n_cost)){
				que.push(make_pair(ny,nx));
			}
		}
	}
}

int main()
{
	cin >> h >> w;
	rep(i,h) cin >> field[i];

	bool is_black = false;
	rep(i,h) rep(j,w) cost[i][j] = 100100;

	if(field[0][0] == '#') is_black = true;
	if(is_black) cost[0][0] = 1;
	else cost[0][0] = 0;
	//rep(i,h){
	//	rep(j,w){
	//		cout << cost[i][j] <<" ";
	//	}
	//	cout << endl;
	//}
	que.push(make_pair(0,0));
	bfs();
//	rep(i,h){
//		rep(j,w){
//			cout << cost[i][j] <<" ";
//		}
//		cout << endl;
//	}
	cout << cost[h-1][w-1] << endl;
}


Measured memory_bytes: 256
class Node:
    def __init__(self):
        self.p = -1
        self.l = -1
        self.r = -1

n = int(input())
T = [Node() for _ in range(n)]
for _ in range(n):
    i,l,r = map(int,input().split())
    T[i].l = l
    T[i].r = r
    if l != -1: T[l].p = i
    if r != -1: T[r].p = i

preorder = []
inorder = []
postorder = []

def preParse(u):
    if u == -1: return
    preorder.append(u)
    preParse(T[u].l)
    preParse(T[u].r)

def inParse(u):
    if u == -1: return
    inParse(T[u].l)
    inorder.append(u)
    inParse(T[u].r)

def postParse(u):
    if u == -1: return
    postParse(T[u].l)
    postParse(T[u].r)
    postorder.append(u)

r = 0
while T[r].p != -1: r += 1
preParse(r)
inParse(r)
postParse(r)

print("Preorder",end="\n ")
print(*preorder)
print("Inorder",end="\n ")
print(*inorder)
print("Postorder",end="\n ")
print(*postorder)


Measured memory_bytes: 5624
while 1:
#n=int(raw_input())
    try:
        y,m,d=map(int,raw_input().split())
        if (y<=1868 and m<=9 and d<8) or (y<=1868 and m<=8) or y<=1867:
            print 'pre-meiji'
        elif (y<=1912 and m<=7 and d<30) or (y<=1912 and m<=6) or y<=1911:
            print 'meiji',y-1867,m,d
        elif (y<=1926 and m<=12 and d<25) or (y<=1926 and m<=11) or y<=1925:
            print 'taisho',y-1911,m,d
        elif (y<=1989 and m<=1 and d<8) or y<=1988:
            print 'showa',y-1925,m,d
        else:
            print 'heisei',y-1988,m,d
    except:
        break

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


int main() {
    string s,t;
    cin >> s >> t;
    int a,b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(s == u){
        cout << a-1 << " " << b << endl;
    }else{
        cout << a << " "<< b-1 << endl;
    }
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
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);

    int N, T;
    cin >> N >> T;
    vector<int> t(N);
    for (auto &&i : t) {
        cin >> i;
    }

    ll ans = 0;

    FOR(i, 1, N) {
        if (t[i] - t[i - 1] < T)
            ans += t[i] - t[i - 1];
        else {
            ans += T;
        }
    }
    ans += T;

    std::cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 1024
import sys
import numpy as np

input = sys.stdin.readline

n, k = map(int, input().split())

h = np.array([int(x) for x in input().split()])

# 初期化
dp = np.zeros(n, dtype=int)

for i in range(1, n):
    start = max(0, i-k)
    dp[i] = min(dp[start:i] + np.abs(h[i] - h[start:i]))
print(dp[n-1])

Measured memory_bytes: 24904
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	
	int N, W, H, x_, y_, S, T;
	
	bool map[500][500];
	
	while(true){
		cin >> N;
		if(N == 0){
			break;
		}
		cin >> W >> H;
		for(int i = 0; i < 500; i++){
			for(int j = 0; j < 500; j++){
				map[i][j] = false;
			}
		}
		for(int i = 0; i < N; i++){
			cin >> x_ >> y_;
			map[y_][x_] = true;
		}
		int sx, sy, gx, gy;
		
		cin >> S >> T;
		
		int count, max;
		
		max = 0;
		
		for(int sx = 1; sx + S - 1 <= W; sx++){
			for(int sy = 1; sy + T - 1 <= H; sy++){
				count = 0;
				for(int x = sx; x < sx + S; x++){
					for(int y = sy; y < sy + T; y++){
						if(map[y][x]){
							count++;
						}
					}
				}
				if(count > max){
					max = count;
				}
			}
		}
		printf("%d\n", max);
	}
	
	return 0;
}

Measured memory_bytes: 1388
//problem_b.go

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	//"strings"
)

const (
	mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

// -----------------------------------------

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getIntSlice(n int) []int {
	ns := []int{}
	for i := 0; i < n; i++ {
		ns = append(ns, getInt())
	}
	return ns
}

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

func getStringSlice(n int) []string {
	ss := []string{}
	for i := 0; i < n; i++ {
		ss = append(ss, getString())
	}
	return ss
}

func sortIntSlice(ns []int) []int {
	sort.Sort(sort.IntSlice(ns))
	return ns
}

func rsortIntSlice(ns []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(ns)))
	return ns
}

// -----------------------------------------

func solve() {
	s := getString()

	l := len(s)

	for i := 0; i < l; i++ {
		fmt.Fprint(wr, "x")
	}

	fmt.Fprintln(wr, "")
}

// -----------------------------------------

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}


Measured memory_bytes: 640
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    LLONG N;
    cin >> N;
    LLONG minMove = 1000000000000;
    for (LLONG a = 1, max = min(N, 1000000LL); a <= max; ++a)
    {
        if (N % a == 0)
        {
            LLONG  b = N / a;
            LLONG move = a + b - 2;
            if (move < minMove)
            {
                minMove = move;
            }
        }
    }
    cout << minMove << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 18;
pair<int, int> max1[(1 << N)], max2[(1 << N)];
int a[(1 << N)];
void upd(int i, pair<int, int> a, pair<int, int> b){
    if(a != max1[i] && a != max2[i]){
        if(a > max1[i]){
            max2[i] = max1[i];
            max1[i] = a;
        } else if(a > max2[i]){
            max2[i] = a;
        }
    }
    if(b != max1[i] && b != max2[i]){
        if(b > max1[i]){
            max2[i] = max1[i];
            max1[i] = b;
        } else if(b > max2[i]){
            max2[i] = b;
        }
    }
}
int ans[(1 << N)];
int main(){
    int n;
    scanf("%d", &n);
    int L = (1 << n);
    for(int i = 0; i < L; i++) scanf("%d", &a[i]);
    for(int mask = 0; mask < L; mask++){
        upd(mask, {a[mask], mask}, {-1, 0});
        for(int b = 0; b < n; b++){
            if(mask & (1 << b)){
                int what = mask & (~(1 << b));
                upd(mask, max1[what], max2[what]);
            }
        }
    }
    for(int i = 1; i < L; i++) ans[i] = max1[i].first + max2[i].first;
    int mx = 0;
    for(int i = 1; i < L; i++){
        mx = max(mx, ans[i]);
        printf("%d\n", mx);
    }
    return 0;
}


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

using namespace std;

const int mod = 1e9 + 7;


int N;
string A, B;
int dp[52][4][4];

int rec(int idx, int top, int bottom)
{
  if(idx == N) return (1);

  int &ret = dp[idx][top][bottom];
  if(ret == -1) {
    ret = 0;
    if(A[idx] == B[idx]) {
      for(int i = 1; i <= 3; i++) {
        if(top != i && bottom != i) {
          (ret += rec(idx + 1, i, i)) %= mod;
        }
      }
    } else {
      for(int i = 1; i <= 3; i++) {
        for(int j = 1; j <= 3; j++) {
          if(top != i && bottom != j && i != j) {
            (ret += rec(idx + 2, i, j)) %= mod;
          }
        }
      }
    }
  }
  return (ret);
}

int main()
{
  cin >> N;
  cin >> A;
  cin >> B;
  memset(dp, -1, sizeof(dp));
  cout << rec(0, 0, 0) << endl;
}



Measured memory_bytes: 256
import math
a,b,x = map(int,input().split())
if(a*a*b/2.0 >= x):
    print(math.degrees(math.atan2(b,2.0*x/a/b)))
else:
    print(math.degrees(math.atan2(2.0*(a*a*b-x)/a/a,a)))

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

int main(){
    int x, y;
    cin >> x >> y;
    
    int z = max(x, y);
    int w = min(x, y); 
    x = z;
    y = w;
    while(y > 0){
        int a = x % y;
        x = y;
        y = a;
    }
    cout << x << endl;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,h,m=0,mi=0,p,i;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>h;
        if(i==0)
            p=h;
        else
        {
            if(h<=p)
                m++;
            else
            {
                if(m>mi)
                    mi=m;
                m=0;
            }
        }
        p=h;
    }
    if(m>mi)
        mi=m;
    cout<<mi<<endl;
}




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

int main() {
  int a, b; cin >> a >> b;
  rep(i, 100+1) {
    rep(j, 100+1) {
      if (i * 2 + j * 4 == b && i+j == a) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String str = s.next();
		int na = str.length();
		int i = 0;

		int a = na;
		int z = 0;

		String ary[] = new String[na];

		for (i = 0; i < na; i++) {
			ary[i] = str.charAt(i) + "";

		}

		i = 0;
		for (i = 0; i < na; i++) {
			if (ary[i].equals("A")) {
				if (i < a) {
					a = i;
				} else {

				}
			}
			if (ary[i].equals("Z")) {
				if (i > z) {
					z = i;
				} else {

				}
			}

		}System.out.println((z-a)+1);
	}

}

Measured memory_bytes: 46560
//============================================================================
// Name        : aoj0105.cpp
// Author      : afterCmidday
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;

typedef struct{
	char word[31];
	int page;
}Quate;

int compare(const void *a,const void *b){
	Quate qa, qb;
	qa = *(Quate *)a;
	qb = *(Quate *)b;
	if(strcmp(qa.word,qb.word) != 0){
		return strcmp(qa.word,qb.word);
	}else{
		return qa.page - qb.page;
	}
}


int main() {
	char tmp[31] = "";
	Quate q[1000];
	int n = 0, i;
	while(scanf("%s%d%*c",q[n].word,&q[n].page) != EOF){
		n++;
	}
	qsort(q,n,sizeof(q[0]),compare);
	for(i = 0;i < n;i++){
		if(strcmp(tmp,q[i].word) == 0){
			printf(" %d",q[i].page);
		}else{
			if(strcmp(tmp,"") != 0){
				printf("\n");
			}
			printf("%s\n%d",q[i].word,q[i].page);
		}
		strcpy(tmp,q[i].word);
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 1112
// CountingCharacters.cc
// 与えられた英文に含まれる、各アルファベットの数を数えるプログラムを作成して下さい。
// なお、小文字と大文字は区別しません。
// 【入力】
// 複数の行にまたがる１つの英文が与えられます。
// 【出力】
// 与えられた英文に含まれる各アルファベットの数を以下に示す形式で出力して下さい：
// a : aの個数
// b : bの個数
// c : cの個数
//   .
//   .
// z : zの個数
// 【制約】
// ・英文が含む文字の数 < 1200
// 【例】
// 入力：
// This is a pen.
// 出力：
// a : 1
// b : 0
// c : 0
// d : 0
// e : 1
// f : 0
// g : 0
// h : 1
// i : 2
// j : 0
// k : 0
// l : 0
// m : 0
// n : 1
// o : 0
// p : 1
// q : 0
// r : 0
// s : 2
// t : 1
// u : 0
// v : 0
// w : 0
// x : 0
// y : 0
// z : 0
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main( void) {
  char sentence[1200];

  // 入力された英文を受け取る。
  int i = 0;
  while ( scanf( "%c", &sentence[i]) != EOF) {
    sentence[i] = tolower( (int)sentence[i]);
    i++;
  }
  sentence[i] = '\0';
  int sentence_len = i;

  // 各英文字の数を数える。
  int cnt_char[26] = {};	// 初期化(0)しておく。
  int char_num;
  for ( int i = 0; i < sentence_len; i++) {
    char_num = sentence[i] - 'a';
    if ( 0 <= char_num && char_num <= 25) cnt_char[char_num]++;
  }

  // 各英文字の数を出力する。
  for ( int i = 0; i < 26; i++) {
    printf( "%c : %d\n", (char)( i + 'a'), cnt_char[ i]);
  }

  return 0;
}



Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
# define INF 0x3f3f3f3f

#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back
#define pp popo_back
#define nl printf("\n");
#define sf scanf
#define pf printf
#define rep(i,n) for(ll i=0;i<n;i++)
#define vint vector<int> 
#define  tc int t;scanf("%d",&t);while(t--) 



int main()
{

	ll p;
	ll n;
	cin>>n;

	for (ll i=1; i<=sqrt(n); i++)
    {
        if (n%i==0)
        {
        	//cout<<"s ";
        		p=i;
                //printf("%d ", i);
        }
    }
    //cout<<p;
    //nl;
    p=max(p,n/p);
    ll g=0;
    //cout<<p;
    //nl;
    while(p)
    {
    	p=p/10;
    	g++;
    }
    cout<<g;
    nl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int ma=1e6;
  vector<bool>sosu(ma,1);
  sosu[0]=sosu[1]=0;
  for(int i=4;i<ma;i+=2)sosu[i]=0;
  for(int i=3;i<ma;i+=2)
    for(int j=i*3;j<ma;j+=i*2)sosu[j]=0;
  int in;
  while(cin>>in,in){
    int sum=0;
    int co=0;
    int i=2;
    while(co!=in){
      if(sosu[i]){co++;sum+=i;}
      i++;
    }
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 1316
#include<bits/stdc++.h>
using namespace std;
#define int unsigned long
#define BS 50
signed main(){
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  for(auto& i:a)cin>>i;
  vector<int> bit(BS,0);
  for(int i=0;i<n;++i){
    int t=a[i];
    for(int j=0;t>0;++j,t>>=1)bit[j]+=t&1;
  }
  vector<bool> suit(BS,false),lim(suit);
  for(int i=0;i<BS;++i)if(bit[i]*2<n)suit[i]=true;
  for(int i=0,t=k+1;t>0;++i,t>>=1)lim[i]=t&1;
  auto f=[&](vector<bool>& v,vector<int>& a){
    int x=0,sum=0;
    for(int i=BS-1;i>0;--i,x<<=1,x+=v[i]);
    for(auto& i:a)sum+=(i^x);
    return sum;
  };
  int ans=0;
  bool low=false;
  for(int i=0;i<BS;++i){
    int j=BS-1-i;
    if(suit[j]&&lim[j]){
      suit[j]=false;
      ans=max(ans,f(suit,a));
      suit[j]=true;
    }
    if(lim[j]&&!suit[j]){low=true; break;}
    if(!lim[j]&&suit[j])suit[j]=false;
  }
  if(low)ans=max(ans,f(suit,a));
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <iostream>
#include<cmath>
#define endl '\n'
#define sz 50000
using namespace std;

int p[9],q[9];
int main()
{
	int n;
	cin>>n;
	for(int i = 0; i<n; i++)
        cin>>p[i];
	for(int i = 0; i<n; i++)
        cin>>q[i];
	vector<int> v;
	for(int i = 0; i<n; i++)v.push_back(p[i]);
	sort( v.begin(),v.end() );
	int a=0,b=0,turn=0,tp=0,tq=0,j;
	do{
	    turn++;
        for(j = 0; j<n; j++){
                if(v[j]==p[j])a=1;
                else {a = 0;break;}
        }
        if(a)tp = turn;
        //else if(!a){
            for(int k = 0; k<n; k++){
                if(v[k]==q[k])b=1;
                else {b=0;break;}
            }
            if(b)tq = turn;
        //}
	}while(next_permutation(v.begin(),v.end()));
	cout<<abs(tp-tq)<<endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split(" ")))

flag = True
count = 0
while True:
    for i in range(n):
        if l[i] % 2 == 1:
            flag = False
            break
        l[i] = l[i] / 2
    if flag == False:
        break
    count += 1

print(count)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define per(i,n,j) for(int i=(n);i>=(j);i--)
using ll=long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF=1LL<<60;

int n;

int main(){
    cin>>n;
    vector<int> d(n);
    rep(i,0,n) cin>>d[i];
    ll ans=0;
    rep(i,0,n-1){
        ll num=0;
        rep(j,i+1,n) num+=d[j];
        ans+=d[i]*num;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define For(i,l,r) for(res i=(l),_=(r);i<=_;++i)
#define Dor(i,l,r) for(res i=(r),_=(l);i>=_;--i)
#define Sor(i,l,r) for(res i=(l),_=(r);i<_;++i)
#define fz(a,b) memset(a,b,sizeof a)
#define qd(a) while(!a.empty())a.pop()
#define JB(a,b)(T[++t]=b,E[t]=H[a],H[a]=t)
#define ll long long
#define N 100001
#define M 1000000007
char A[N],B[N];
int t;
int main() {
	cin>>A>>B;
	Sor(i,0,3)if(A[i]==B[i])++t;
	cout<<t;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
	int N, M, K;
	while(cin>>N>>M && (N || M)){
		
		//iÔÚÉå«¢lªÇÌgCÉ¨¢Ä é©
		vector<int> v(N+1);
		
		for(int i = 0; i < 3; i++){
			cin>>K;
			for(int j = 0; j < K; j++){
				int tmp;
				cin>>tmp;
				v[tmp] = i;
			}
		}

		vector<int> a(N+1), c(N+1);
		a[N] = v[N];	c[N] = 2 - v[N];

		for(int i = N; i > 1; i--)
		{
			switch(v[i-1])
			{
			case 0:

				a[i-1] = a[i];
				c[i-1] = c[i] + 2 * pow(3.0, N-i+1);
				break;

			case 1:
				a[i-1] = c[i] + pow(3.0, N-i+1);
				c[i-1] = a[i] + pow(3.0, N-i+1);
				break;

			case 2:
				
				a[i-1] = a[i] + 2 * pow(3.0, N-i+1);
				c[i-1] = c[i];
				break;
			}
		}

		int res = min(a[1], c[1]);
		if(M < res) res = -1;
		cout << res << endl;
	}
}

Measured memory_bytes: 0
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll done[100010][3];
vector<ll> edges[100010];
vector<ll> results;
ll zan = 1e9;
ll s,t;
bool saiki(ll start,ll m, ll c){
    // std::cout << start<<" "<<m<<" "<<c << std::endl;
    if(done[start][m]<=c){
        return true;
    }
    if(zan<c){
        return true;
    }
    done[start][m] = c;
    if(start == t && m==0){
        zan = min(zan,c-1);
    }
    
    for (auto e : edges[start]) {
        saiki(e,(m+1)%3,((m+1)%3==0 ? c+1 : c));
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    std::cin >> n>>m;
    Fill(done,(ll)1e9);
    
    for (int i = 0; i < m; i++) {
        ll x,y;
        std::cin >> x>>y;
        edges[x].push_back(y);
    }
    
    std::cin >> s>>t;
    
    std::queue<pair<ll,ll>> q;
    
    done[s][0] = 0;
    
    q.push({s,(ll)0});
    
    while(!q.empty()){
        pair<ll,ll> edge = q.front();
        q.pop();
        // std::cout << edge.first << std::endl;
        
        for (auto e : edges[edge.first]) {
            if(done[e][(edge.second+1)%3] > done[edge.first][(edge.second)%3]+1){
                q.push({e,(edge.second+1)%3});
                done[e][(edge.second+1)%3] = done[edge.first][(edge.second)%3]+1;
            }else{
                continue;
            }
        }
    }
    
    if(done[t][0] == (ll)1e9){
        std::cout << -1 << std::endl;
    }else{
        std::cout << done[t][0]/3 << std::endl;
    }
}


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

const int M = 105;
const int Inf = 1e9;
int N;
int x[M], y[M], h[M];
int bufx, bufy, bufh;
int X, Y, H;

bool solve(int cx, int cy) {
  int buf = bufh + abs(bufx - cx) + abs(bufy - cy);
  rep(i, N) {
    int tmp = h[i] + abs(x[i]-cx) + abs(y[i]-cy);
    if (h[i]) {
      if (buf != tmp) return false;
    }
    else {
      if (buf > tmp) return false;
    }
  }
  X = cx; Y = cy; H = buf;
  return true;
}

int main() {
  cin >> N;
  rep(i, N) cin >> x[i] >> y[i] >> h[i];
  rep(i, N) {
    if (h[i]) {
      bufx = x[i]; bufy = y[i]; bufh = h[i];
      break;
    }
  }
  bool f = false;
  for (int i = 0; i <= 100; ++i) {
    for (int j = 0; j <= 100; ++j) {
      if (solve(i, j)) {
        if (0 <= X && X <= 100 && 0 <= Y && Y <= 100 & 1 <= H) {
          f = true;
          break;
      	}
      }
    }
    if (f) break;
  }
  printf("%d %d %d\n", X, Y, H);
  return 0;
}

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

int main() {
	int D, i;
	char s[100] = "Christmas";

	scanf("%d", &D);

	for (i = 25 - D; i > 0; i--) {
		strcat(s, " Eve");
	}

	printf("%s", s);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int a[2], c[2], e, f;
bool w[31], s[3001];
si sw, ss;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a[0] >> a[1] >> c[0] >> c[1] >> e >> f;
  w[0] = true;
  s[0] = true;
  FOR(j, 0, 2)FOR(i, 0, 31) if(w[i] && i+a[j] < 31) w[i+a[j]] = true;
  FOR(i, 0, 31) if(w[i]) sw.insert(i);
  sw.erase(0);
  FOR(j, 0, 2)FOR(i, 0, 3001) if(s[i] && i+c[j] < 3001) s[i+c[j]] = true;
  FOR(i, 0, 3001) if(s[i]) ss.insert(i);
  int mas = -1, masw = 1;
  each(itr, ss){
    si::iterator itrr = sw.lower_bound(ceil((double(*itr)) / e));
    int _sw = *itr + *itrr*100;
    if(itrr == sw.end() || _sw > f) continue;
    if(mas*_sw < masw**itr){
      mas = *itr;
      masw = _sw;
    }
  }
  cout << masw << " " << mas << endl;
  return 0;
}

Measured memory_bytes: 384
import java.io.IOException;
import java.util.Scanner;
public class Main {
    public static void main (String args[]) throws IOException {
    	Scanner sc = new Scanner(System.in);
    	StringBuilder sb = new StringBuilder();
    	int max = -1000000;
        int min = 1000000;
    	int num =sc.nextInt();
    	int tmp = 0;
    	long sum = 0;
    	for (int i=0;i<num;i++){
    		int a = sc.nextInt();
    		if(a>max){
    			max=a;
    		}

    		if(min>a){
    			min=a;
    		}
    		sum = sum+a;
    	}
        sb.append(min).append(" ").append(max).append(" ").append(sum);
    	System.out.println(sb);
    }

}

Measured memory_bytes: 41604
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

bool dp[80][80][(80+80)*80];

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

    int h,w; cin >> h >> w;
    std::vector<std::vector<int>> a(h, std::vector<int>(w)); rep(i,h) rep(j,w) cin >> a[i][j];
    std::vector<std::vector<int>> b(h, std::vector<int>(w)); rep(i,h) rep(j,w) cin >> b[i][j];

    dp[0][0][abs(a[0][0]-b[0][0])] = true;

    rep(i,h) rep(j,w){

        rep(k,160*80){

            if(!dp[i][j][k]) continue;

            if(i+1 < h){
                dp[i+1][j][k+abs(a[i+1][j]-b[i+1][j])] = true;
                dp[i+1][j][abs(k-abs(a[i+1][j]-b[i+1][j]))] = true;
            }

            if(j+1 < w){
                dp[i][j+1][k+abs(a[i][j+1]-b[i][j+1])] = true;
                dp[i][j+1][abs(k-abs(a[i][j+1]-b[i][j+1]))] = true;
            }
            
        }
    }

    int ans = INF;

    rep(k, 160*80){
        if(dp[h-1][w-1][k]){ ans = k; break; }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 79488
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int q = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>();

        int[] a = new int[q];
        int[] b = new int[q];
        int[] c = new int[q];
        int[] d = new int[q];
        for(int i = 0;i < q;i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[i] = sc.nextInt();
            d[i] = sc.nextInt();
        }

        List<int[]> AList = new ArrayList<>();
        dfs(new int[n], 0, m, AList);
        
        int maxScore = 0;
        for(int i = 0;i < AList.size();i++) {
            int[] A = AList.get(i);
            int score = 0;
            for(int j = 0;j < q;j++) {
                if(A[b[j] - 1] - A[a[j] - 1] == c[j]) score += d[j];
            }
            
            if(score > maxScore) maxScore = score;
        }
        
        System.out.println(maxScore);
    }
    
    private static void dfs(int[] a, int idx, int m, List<int[]> result) {
        if(idx >= a.length) {
            result.add(a);
            return;
        }
        
        int preA = ((idx - 1) >= 0 ? a[idx - 1] : 1);
        for(int i = preA;i <= m;i++) {
            int[] newA = new int[a.length];
            for(int j = 0;j < a.length;j++) newA[j] = a[j];
            newA[idx] = i;
            dfs(newA, idx + 1, m, result);
        }
        
        return;
    }


    private static long longPow(int a, int n) {
        long result = 1;
        if(n >= 0) {
            for(int i = 0;i < n;i++) result *= a;
        }
        else {
            result = 1;
        }
            return result;
    }

}


Measured memory_bytes: 49352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

typedef pair<int, int> P;

int h, w, n;
char f[1000][1000];

int dx[] = { 0, 1, 0, -1 };
int dy[] = { -1, 0, 1, 0 };

struct Ele {
	Ele(int a, double b, P c) : g(a), h(b), p(c) {}
	bool operator<(const Ele& right) const {
		return g + h > right.g + right.h;
	}
	int g;
	double h;
	P p;
};

double euclidean(P s, P g) {
	int y = s.first - g.first;
	int x = s.second - g.second;
	return sqrt(x*x + y*y);
}

int Astar(P s, P g) {
	bool used[1000][1000] = { false };
	priority_queue<Ele> que;
	que.push(Ele(0, euclidean(s, g), s));

	while (!que.empty()) {
		Ele t = que.top();
		que.pop();

		if (t.p == g)
			return t.g;
		if (used[t.p.first][t.p.second])
			continue;
		used[t.p.first][t.p.second] = true;

		for (int i = 0; i < 4; ++i) {
			int ny = t.p.first + dy[i];
			int nx = t.p.second + dx[i];
			if (ny < 0 || ny >= h || nx < 0 || nx >= w || f[ny][nx] == 'X')
				continue;

			P np(ny, nx);
			que.push(Ele(t.g + 1, euclidean(np, g), np));
		}
	}

	return 0;
}

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

	P fac[10];
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			cin >> f[i][j];
			if ('1' <= f[i][j] && f[i][j] <= '9')
				fac[f[i][j] - '0'] = P(i, j);
			else if (f[i][j] == 'S')
				fac[0] = P(i, j);
		}
	}

	int ans = 0;
	for (int i = 0; i < n; ++i) {
		ans += Astar(fac[i], fac[i + 1]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5076
n, h, w = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(n):
    a = ab[i][0]
    b = ab[i][1]
    if a >= h and b >= w:
        ans += 1
print(ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,k,c,dp1[N],dp2[N];
bool t[N<<2],a[N];
char s[N];
int getdp1(int x){return x<1?0:dp1[x];}
int getdp2(int x){return x>n?0:dp2[x];}
void fix(int l,int r,int k,int x,int y)
{
    if(l>r||r<x||l>y) return;
    if(l>=x&&r<=y) {t[k]=true;return;}
    int m=l+r>>1;
    fix(l,m,k<<1,x,y);
    fix(m+1,r,k<<1|1,x,y);
}
void update(int l,int r,int k)
{
    if(l==r) return;
    t[k<<1]|=t[k];t[k<<1|1]|=t[k];
}
void push(int l,int r,int k)
{
    update(l,r,k);
    if(l==r)
    {
        a[l]=!t[k];return;
    }
    int m=l+r>>1;
    push(l,m,k<<1);push(m+1,r,k<<1|1);
}
int main()
{
    scanf("%d%d%d",&n,&k,&c);
    scanf("%s",s+1);
    for(int i=1;i<=n;i++)
    {
        if(s[i]=='o')
            dp1[i]=getdp1(i-c-1)+1;
        else dp1[i]=dp1[i-1];
    }
    for(int i=n;i>=1;i--)
    {
        if(s[i]=='o')
            dp2[i]=getdp2(i+c+1)+1;
        else dp2[i]=dp2[i+1];
    }
    for(int i=1;i<=n;i++)
    {
        int l=i+c+1,r=n,ans=i+1;
        while(l<=r)
        {
            int m=l+r>>1;
            if(dp1[i]+getdp2(m)>=k) ans=m,l=m+1;
            else r=m-1;
        }
        fix(1,n,1,i+1,ans-1);
    }
    for(int i=1;i<=n;i++)
        if(dp1[i]>=k)
    {
        fix(1,n,1,i+1,n);
        break;
    }
    for(int i=n;i>=1;i--)
        if(dp2[i]>=k)
    {
        fix(1,n,1,1,i-1);
        break;
    }
    push(1,n,1);
    for(int i=1;i<=n;i++)
        if(s[i]=='o'&&a[i]) printf("%d\n",i);
}


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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int a = 0;
    int b = 0;
    int c = 0;

    for (int i = 0; i < 3; i++) {
        if (s[i] == 'a') {
            a++;
        } else if (s[i] == 'b') {
            b++;
        } else if (s[i] == 'c') {
            c++;
        }
    }

    if (a == 1 && b == 1 && c == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

using namespace std;

int main(){
  int a[3];
  for(int i = 0;i<3;i++)
    cin>>a[i];
  sort(a,a+3);
  cout<<a[0]+a[1]<<endl;

  return 0;
}


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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

/* 
  //エラトステネスのふるい
  int maxNum = 100000;
  char isNotPrime[maxNum+1] = {};
  isNotPrime[0]=isNotPrime[1]=1;
  for(int i=2;i<maxNum;i++){
    if(isNotPrime[i]==1) continue;
    int num = i+i;
    while(num<=maxNum){
      isNotPrime[num]=1;
      num += i;
    }
  }
*/
// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

// 降順ソート vector<int> v;
// sort(v.begin(),v.end(),greater<int>());

signed main() {
  ll n,m;
  cin >> n >> m;
  
  if(n*2 < m){
    ll diff = (m-n*2);
    while(diff%4!=0){
      diff--;
    }
    m -= diff/2;
    n += diff/4;
    //cout << diff << endl;
  }
  //cout << n << ":" << m << endl;

  //while(n*2 < m){
  //  n += 1;
  //  m -= 2;
  //}
  
  //cout << n << ":" << m << endl;

  
  cout << min(n,m/2) << endl;
  
  return 0;
}




Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int ss(string a){
	int s=0;
	for(int i=0;i<a.size();i++){
		s=s*10+(a[i]-'0');
	} 
	 return s;
}
int main(){
	string a,b;
	int s;
	cin>>a>>b;
	s=ss(a+b);
	if(sqrt(s)==int(sqrt(s))){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	} 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define nl '\n'
#define ff first
#define ss second
//////////////////////////////////////////////////



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); srand(time(0));
  
  int n, a, b;
  cin >> n >> a >> b;
  if( (b-a)%2 ) cout << "Borys" << endl;
  else cout << "Alice" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <map>
#define N 1000005
#define mk(i, j) make_pair(i, j)
using namespace std;

int h, w, n, cnt[N], u[9] = { 0, 0, 0, 1, 1, 1, 2, 2, 2 }, v[9] = { 0, 1, 2, 0, 1, 2, 0, 1, 2 };
long long num[15]; 
map <pair<int, int>, int> mp; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

bool check(int x, int y, int xx, int yy)
{
	if(x < 1 || x > h || y < 1 || y > w) return 1;
	if(xx < 1 || xx > h || yy < 1 || yy > w) return 1;
	return 0; 
}

int main()
{
	h = read <int> (), w = read <int> (), n = read <int> ();
	num[0] = 1ll * (h - 2) * (w - 2);
	for(int x, y, id, i = 1; i <= n; i++)
	{
		x = read <int> (), y = read <int> ();
		for(int j = 0; j < 9; j++)
		{
			if(check(x + u[j], y + v[j], x + u[j] - 2, y + v[j] - 2)) continue; 
			if(!mp[mk(x + u[j], y + v[j])])
				mp[mk(x + u[j], y + v[j])] = ++cnt[0]; 
			id = mp[mk(x + u[j], y + v[j])];
			num[cnt[id]]--; num[++cnt[id]]++; 
		}
	}
	for(int i = 0; i <= 9; i++)
		printf("%lld\n", num[i]); 
	return 0; 
}


Measured memory_bytes: 60032
package main

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

func main() {
	N := ReadInt()
	S := Read()
	ints := make(map[int]bool)
	iUsed := make(map[int]bool)
	ijUsed := make(map[int]bool)
	for i := 0; i < N-2; i++ {
		ni := int(S[i] - '0')
		if iUsed[ni] {
			continue
		}
		iUsed[ni] = true
		for j := i + 1; j < N-1; j++ {
			nj := int(S[j] - '0')
			if ijUsed[ni*10+nj] {
				continue
			}
			ijUsed[ni*10+nj] = true
			for k := j + 1; k < N; k++ {
				found := ni*100 + nj*10 + int(S[k]-'0')
				ints[found] = true
			}
		}
	}
	fmt.Println(len(ints))
}

var sc = bufio.NewScanner(os.Stdin)

func init()        { sc.Buffer(make([]byte, 256), 1e9); sc.Split(bufio.ScanWords) }
func Read() string { sc.Scan(); return sc.Text() }

func ReadInt() int {
	v, e := strconv.Atoi(Read())
	if e != nil {
		panic(e.Error())
	}
	return v
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  string s;
  cin>>s;
  int ans=0;
  REP(i,4){
    if(s[i]=='+'){
      ans++;
    }else{
      ans--;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

def main():
    ans = 'Yes'
    n = int(input())
    now = [0,0]
    pt = 0
    for i in range(n):
        t, x, y = map(int, input().split())
        d = abs((x - now[0]) + (y - now[1]))
        if d > abs(t - pt) or (t - pt)%2 != d%2:
            ans = "No"
            break
        now = [x, y]
        pt = t
    print(ans)

if __name__ == '__main__':
    main()

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

using namespace std;

#define fo(i,CApiTaL_N) for(int i=0; i<CApiTaL_N; i++)
#define Fo(i,k,CApiTaL_N) for(int i=k; i<CApiTaL_N; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it=a.begin(); it!=a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

int t=1;
const int mxN=1e5, mxH=1e4;
int n;
vi h(mxN+1), dp(mxN+1);

void test_case(){
    cin>>n;
    fo(i,n)cin>>h[i+1];
    dp[1]=0,dp[2]=abs(h[2]-h[1]);
    Fo(i,3,n+1){
        dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]));
    }
    cout<<dp[n]<<endl;
}

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

    // cin>>t;
    while(t--){
        test_case();
    }
    
    return 0;
}

Measured memory_bytes: 3772