akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct cake {
	int w, d;

	cake(int w, int d) {
		this->w = w;
		this->d = d;
	}

	int area() {
		return w * d;
	}
};

vector<cake> cakes;

int main() {
	int n, w, d, p, s;
	while (cin >> n >> w >> d , !(n == 0 && w == 0 && d == 0)) {
		cakes.clear();
		cakes.push_back(cake(w, d));
		for (int i = 0; i < n; i++) {
			cin >> p >> s;
			p--;
			cake c = cakes[p];
			cakes.erase(cakes.begin() + p);
			vector<cake> cutCakes;
			s %= 2 * (c.w + c.d);
			if (s < c.w) {
				cutCakes.push_back(cake(s, c.d));
				cutCakes.push_back(cake(c.w - s, c.d));
			}
			else if (s < c.w + c.d) {
				s -= c.w;
				cutCakes.push_back(cake(c.w, s));
				cutCakes.push_back(cake(c.w, c.d - s));
			}
			else if (s < 2 * c.w + c.d) {
				s -= c.w + c.d;
				cutCakes.push_back(cake(s, c.d));
				cutCakes.push_back(cake(c.w - s, c.d));
			}
			else {
				s -= 2 * c.w + c.d;
				cutCakes.push_back(cake(c.w, s));
				cutCakes.push_back(cake(c.w, c.d - s));
			}
			if (cutCakes[0].area() < cutCakes[1].area()) {
				cakes.push_back(cutCakes[0]);
				cakes.push_back(cutCakes[1]);
			}
			else {
				cakes.push_back(cutCakes[1]);
				cakes.push_back(cutCakes[0]);
			}
		}

		vector<int> areas;
		for (int i = 0; i < cakes.size(); i++) {
			areas.push_back(cakes[i].area());
		}
		sort(areas.begin(), areas.end());
		for (int i = 0; i < areas.size(); i++) {
			cout << areas[i];
			cout << (i == areas.size() - 1 ? "\n" : " ");
		}
	}
}

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

#define ll long long
#define endl "\n" 
#define FOR(n) for(int i=0 ; i<n ; i++)
#define FORa(a, n) for(ll i=a ; i<=n ; i++)
ll mod=1000000007;
ll inf=1e9;
vector<ll> dp;
void solve()
{
 int n;
 cin >> n;
 ll a[n],b[3],ans=0 ;
 FOR(n) cin >> a[i];
 for(int i=0 ; i<n-2 ; i++){
   for(int j=i+1 ; j<n-1 ; j++){
     for(int k=j+1 ; k<n ; k++){
       if(a[i]==a[j] ) break; 
       if(a[j]==a[k] || a[i]==a[k]) continue;
       b[0]=a[i] , b[1]=a[j] , b[2]=a[k];
       sort(b,b+3);
       if(b[0]+b[1]>b[2]) ans++;
     }
   }
 }
 cout << ans << endl;
}   

  


int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t=1;
  //cin >> t;
  while(t--)
    solve();
    return 0 ;
}
  

Measured memory_bytes: 3652
#include <stdio.h>
int main(void){
    int i,j,m,H,W;
    m = 1;
    while(1){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0)break;
        for(j = 0;j < H; j++){
            for(i = 0;i < W; i++){
                if((i + j)%2 == 0){
            printf("#");
                }else{
                    printf(".");
                }
            }
            printf("\n");
        } 
        printf("\n");
    
    m++;
    }
    
    
  return 0;

 }


Measured memory_bytes: 2104
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            final int n = sc.nextInt();
            final int a = sc.nextInt();
            final int b = sc.nextInt();

            long pow = pow(2, n, 1000000007);
            long nca = nCr(n, a, 1000000007);
            long ncb = nCr(n, b, 1000000007);

            long result = pow - 1;
            result = result - nca;
            if (result < 0) {
                result += 1000000007;
            }
            result = result - ncb;
            if (result < 0) {
                result += 1000000007;
            }
            System.out.println(result);

        } finally {
            sc.close();
        }
    }

    public static long nCr(int n, int r, int mod){
        long num = 1;
        for (int i=1; i<=r; i++) {
            num *= n;
            num %= mod;
            n--;
        }

        long invr = pow(factorial(r, mod), mod - 2, mod);

        return num * invr % mod;
    }

    public static long pow(long a, long x, long mod) {
        return BigInteger.valueOf(a).modPow(BigInteger.valueOf(x),  BigInteger.valueOf(mod)).longValue();
    }

    public static long factorial(long n, long mod) {
        long result = 1;
        for (long i=n; i>0; i--) {
            result *= i;
            result %= mod;
        }
        return result;
    }
}


Measured memory_bytes: 22100
#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 <unordered_map>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

UINT gcd(UINT a, UINT b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

UINT lcm(UINT a, UINT b)
{
	return a * b / gcd(a, b);
}

const UINT mod = 1000000007;
const double pi = 3.141592653589793238462;
const INT intmax = 9223372036854775807;

UINT _PowMod(UINT x, UINT y, UINT _mod)
{
	if (y == 0)
	{
		return 1;
	}
	else if (y == 1)
	{
		return x % _mod;
	}
	else if (y % 2 == 0)
	{
		auto tmp = _PowMod(x, y / 2, _mod);
		return tmp * tmp % _mod;
	}
	else
	{
		auto tmp = _PowMod(x, y / 2, _mod);
		return (tmp * tmp % _mod) * x % _mod;
	}
}


UINT PowMod(UINT x, UINT y)
{
	return _PowMod(x, y, mod);
}

UINT getModInv(UINT N)
{
	return PowMod(N, mod - 2);
}

INT nCrMod(INT start, INT n, INT r)
{
	if (n < r)
	{
		return 0;
	}
	INT a = start;
	for (size_t i = n; i >= n - r + 1; i--)
	{
		a *= i;
		a %= mod;
	}
	for (size_t i = 1; i <= r; i++)
	{
		a *= getModInv(i);
		a %= mod;
	}
	return a;
}

INT nHrMod(INT start, INT n, INT r)
{
	return nCrMod(start, n + r - 1, r);
}

INT _nCrMod(INT start, INT n, INT r)
{
	if (n <= 0)
	{
		return 0;
	}
	return nCrMod(start, n, r);
}

struct uf
{
	vector<INT> p;

	uf(INT n) : p(n)
	{
		for (size_t i = 0; i < n; i++)
		{
			p[i] = i;
		}
	}

	INT rt(INT n)
	{
		return p[n] == n ? n : p[n] = rt(p[n]);
	}

	void un(INT n, INT m)
	{
		p[rt(n)] = p[rt(m)];
	}

	bool eq(INT n, INT m)
	{
		return rt(n) == rt(m);
	}
};

bool lineCol(INT a1x, INT a1y, INT a2x, INT a2y, INT b1x, INT b1y, INT b2x, INT b2y)
{
	auto ta = (b1x - b2x) * (a1y - b1y) + (b1y - b2y) * (b1x - a1x);
	auto tb = (b1x - b2x) * (a2y - b1y) + (b1y - b2y) * (b1x - a2x);
	auto tc = (a1x - a2x) * (b1y - a1y) + (a1y - a2y) * (a1x - b1x);
	auto td = (a1x - a2x) * (b2y - a1y) + (a1y - a2y) * (a1x - b2x);

	return tc * td < 0 && ta * tb < 0;
}

INT powInt(INT a, INT b)
{
	if (b == 0)
	{
		return 1;
	}
	if (b == 1)
	{
		return a;
	}
	INT tmp = powInt(a, b / 2);
	return (b % 2 == 1 ? a * tmp * tmp : tmp * tmp);
}

INT _sMod(string n, INT mod)
{
	INT k = (n[0] - '0') % mod;
	for (size_t i = 1; i < n.length(); i++)
	{
		k *= 10;
		k += (n[i] - '0');
		k %= mod;
	}
	return k;
}

#define forin(v, n)				\
for (size_t i = 0; i < n; i++)	\
{								\
	cin >> v[i];				\
}

#define vec(t, name, n)			vector<t> name(n)
#define vec_(t, name, n, init)	vector<t> name(n, init)

#define vec2(t, name, n, m)			vector<vector<t>> name(n, vector<t>(m))
#define vec2_(t, name, n, m, init)	vector<vector<t>> name(n, vector<t>(m, init))

struct xy
{
	INT x, y;
	xy() :x(0), y(0) {}
	xy(INT _x, INT _y) : x(_x), y(_y) {}
};

int main()
{
	INT n, l;
	cin >> n >> l;

	vec(string, s, n);
	forin(s, n);

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

	for (size_t i = 0; i < n; i++)
	{
		cout << s[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc118/tasks/abc118_c

// http://ctylim.hatenablog.com/entry/2015/08/30/191553
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cstdio>

#define ALL(a) (a).begin(), (a).end()
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())
#define MAXINDEX(c) distance((c).begin(), max_element((c).begin(), (c).end()))
#define MININDEX(c) distance((c).begin(), min_element((c).begin(), (c).end()))
#define DEBUG(x) std::cerr << #x << " = " << (x) << " (" << __FILE__ << "::" << __LINE__ << ")" << std::endl;
#define ERROR(s) std::cerr << "Error::" << __FILE__ << "::" << __LINE__ << "::" << __FUNCTION__ << "::" << (s) << std::endl;
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)

#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;


void print() { std::cout << std::endl; }
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail){
  std::cout << head << ",";
  print(std::forward<Tail>(tail)...);
}

using namespace std;


int main(int argc, char **argv)
{
  int64_t N;
  int64_t m = 1000000007;
  scanf("%lld", &N);
  char *s1 = new char [N];
  char *s2 = new char [N];
  getc(stdin);
  FOR(i, 0, N){
      s1[i] = getc(stdin);
  }
  getc(stdin);
  FOR(i, 0, N){
      s2[i] = getc(stdin);
  }

  int64_t lut[2][2] = {{2,2},{1,3}};

  int64_t pre = s1[0] != s2[0];  // 0 : |, 1: =
  int64_t s = pre ? 6 : 3;
  int index = pre ? 2 : 1;
  // print(0, pre, s);
  for(int i=index;i<N;i=i+index){
    int64_t cur = s1[i] != s2[i];
    s = s * lut[pre][cur];
    pre = cur;
    index = cur ? 2 : 1;
    s = (s > (1ll<<50)) ? s%m : s;
  }

  cout << s % m << endl;

  free(s1); free(s2);
  return 0;
  }


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

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			var min = int.Parse(Console.ReadLine());
			Console.ReadLine();
			Console.ReadLine();
			Console.ReadLine();
			var max = int.Parse(Console.ReadLine());
			var k = int.Parse(Console.ReadLine());

			Console.WriteLine(max - min > k ? ":(" : "Yay!");
		}
	}
}


Measured memory_bytes: 11092
n = int(input())
a = [int(input())-1 for _ in range(n)]
ans = 1
place = a[0]
for i in range(n):
    if place == 1:
        break
    else:
        place = a[place]
        ans += 1
if place == 1:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 7084
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd
readInt = lambda: int(sys.stdin.readline())
readIntN = lambda: [int(v) for v in sys.stdin.readline().split(' ')]



def main():
    n = readInt()
    result = 'Hello World'
    if n == 2:
        a = readInt()
        b = readInt()
        result = a + b
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5140
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val s = sc.nextInt()
    val w = Array(n) { 0 }
    val v = Array(n) { 0 }
    for (i in 0 until n) {
        w[i] = sc.nextInt()
        v[i] = sc.nextInt()
    }
    val dp = Array(n + 1) { Array(n + 1) { Array(305) { 0 } } }
    for (i in 0 until n) {
        for (j in 0 until n) {
            for (k in 0..300) {
                dp[i + 1][j][k] = Math.max(dp[i + 1][j][k], dp[i][j][k])
                if (k + j * w[0].toLong() + w[i] <= s) {
                    dp[i + 1][j + 1][k + w[i] - w[0]] = Math.max(dp[i + 1][j + 1][k + w[i] - w[0]], dp[i][j][k] + v[i])
                }
            }
        }
    }
    var max = 0
    for (j in 0..n) {
        for (k in 0..300) {
            max = Math.max(max, dp[n][j][k])
        }
    }
    println(max)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 125340
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	buf := make([]byte, 1024 * 1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)

	h := nextInt()
	w := nextInt()
	cy := nextInt() - 1
	cx := nextInt() - 1
	dy := nextInt() - 1
	dx := nextInt() - 1

	maze := make([]string, h)

	for i := 0; i < h; i++ {
		maze[i] = next()
	}

	fmt.Println(traverse(maze, h, w, cy, cx, dy, dx))
}

type Element struct {
	y int
	x int	
	s int
}

type Heap []Element

func (h Heap) Len() int {
	return len(h)
}

func (h Heap) Less(i int, j int) bool {
	return h[i].s < h[j].s
}

func (h Heap) Swap(i int, j int) {
	h[i], h[j] = h[j], h[i]
}

func (h *Heap) Push(x interface{}) {
	*h = append(*h, x.(Element))
}

func (h *Heap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n - 1]
	*h = old[:n-1]
	return x
}

func traverse(maze []string, h int, w int, cy int, cx int, dy int, dx int) int {
	var s [][]int = make([][]int, h)
	for i := 0; i < h; i++ {
		s[i] = make([]int, w)
		for j := 0; j < w; j++ {
			s[i][j] = math.MaxInt32
		}
	}

	s[cy][cx] = 0
	
	var q *Heap = &Heap{}
	heap.Init(q)
	heap.Push(q, Element{cy, cx, 0})

	for q.Len() > 0 {
		var e Element = heap.Pop(q).(Element)

		for i := -1; i <= 1; i++ {
			for j := -1; j <= 1; j++ {
				if i * j != 0 {
					continue
				}

				if !isValid(maze, h, w, e.y + i, e.x + j) {
					continue
				}

				if s[e.y + i][e.x + j] <= e.s {
					continue
				}

				heap.Push(q, Element{e.y + i, e.x + j, e.s})
				s[e.y + i][e.x + j] = e.s
			}
		}

		for i := -2; i <= 2; i++ {
			for j := -2; j <= 2; j++ {
				if !isValid(maze, h, w, e.y + i, e.x + j) {
					continue
				}

				if e.s + 1 >= s[e.y + i][e.x + j] {
					continue
				}

				heap.Push(q, Element{e.y + i, e.x + j, e.s + 1})
				s[e.y + i][e.x + j] = e.s + 1
			}
		}
	}

	m := s[dy][dx]
	if m == math.MaxInt32 {
		return -1;
	} else {
		return m
	}
}

func isValid(maze []string, h int, w int, i int, j int) bool {
	if i < 0 || i >= h {
		return false
	}

	if j < 0 || j >= w {
		return false
	}

	if maze[i][j] == '#' {
		return false
	}

	return true
}


Measured memory_bytes: 29592
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char *argv[]) {
    std::string input;
    std::vector<std::string> fives;
    std::vector<std::string> sevens;

    for (int count = 0; count < 3; count++) {
        std::getline(std::cin, input, ' ');
        input.erase(input.find_last_not_of("\n") +1 );

        if (input == "5") {
            fives.push_back(input);
        }   
        if (input == "7") {
            sevens.push_back(input);
        }   
    }   

    if (fives.size() == 2 && sevens.size() == 1) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }   
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  string S; cin >> S;
  map<char, int> m;
  for (char c : S) m[c]++;
  if (m.size() != 2) cout << "No" << endl;
  else if (m.begin()->second != 2) cout << "No" << endl;
  else cout << "Yes" << endl;
}


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

int main(){
    int N; cin >> N;
    int count = 0;
    for(int i = 0; i < N; i++){
        int p; cin >> p;
        if(p != i + 1) count++;
    }
    cout << (count <= 2 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl;
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2


int main() {
	int n;
	cin >> n;
	vector<ll>a(n);
	vector<vector<ll>>sum(2, vector<ll>(202020, 0));
	ll f = 1;
	rep(i, 0, n)cin >> a[i];
	rep(i, 0, n) {
		sum[0][i + 1] = f * a[i] + sum[0][i];
		sum[1][i + 1] = -f * a[i] + sum[1][i];
		f *= -1;
	}
	rep(i, n, 2*n) {
		sum[0][i+1] = f * a[i%n] + sum[0][i];
		sum[1][i+1] = -f * a[i%n] + sum[1][i];
		f *= -1;
	}

	vector<ll>ans(n);
	rep(i, 0, n) {
		ans[i] = sum[i % 2][i+n] - sum[i%2][i];
	}

	rep(i, 0, n) {
		if (i)cout << " ";
		cout << ans[i];
	}
	cout << endl;
	
	

	return 0;
}

Measured memory_bytes: 6100
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		if (N.equals("Sunny")){System.out.println("Cloudy");}
		if (N.equals("Cloudy")){System.out.println("Rainy");}
		if (N.equals("Rainy")){System.out.println("Sunny");}
		sc.close();
	}
}



Measured memory_bytes: 20948
#include<bits/stdc++.h>
using namespace std;
char str[100005];
deque<char>dq;
int main()
{
    char ch[5];
    int q, t, x;
    scanf("%s %d", str, &q);
    for(int i=0; str[i]; i++)
    dq.push_back(str[i]);
    bool f= 0;
    while(q--)
    {
        scanf("%d", &t);
        if(t==1)f^= 1;
        else
        {
            scanf("%d %s", &x, ch);
            if(f)
            {
                if(x==2)dq.push_front(ch[0]);
                else dq.push_back(ch[0]);
            }
            else
            {
                if(x==1)dq.push_front(ch[0]);
                else dq.push_back(ch[0]);
            }
        }
    }
    while(!dq.empty())
    {
        if(!f)printf("%c", dq.front()), dq.pop_front();
        else printf("%c", dq.back()), dq.pop_back();
    }
    puts("");
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}


ll i,j,k,ii,jj;
ll n,m,w;
ll a,b,c,d,e,g,h,r;
ll l,ans,num;
ll x[800005],y[500005],z[500005];
bool dame,flag;
char s[500005],t[500005];
bool used[505][505];
ll dp[300][300];
ll kyo;

int main(){
    cin >> h >> w >> n;
	for(i=0;i<n;i++){
		cin >> a >> b;
		x[i] = 300000 * a + b;
	}
	for(i=n;i<h+n;i++){
		x[i] = 300000 * (i - n) + w + 1;
	}
	for(i=n+h;i<n+h+w;i++){
		x[i] = 300000 * (h + 1) + (i - n - h);
	}
	n = n + h + w;
	sort(x,x+n);
	a = 1;
	b = 1;
	while(1){
		//下に行けるか判定
		//pe(a);p(b);
		c = lb(x,x+n,(a+1)*300000+1+b) - lb(x,x+n,(a+1)*300000+1);
		if(c >= 1){
			break;
		}else{
			a++;
		}
		//右に動いてみる
		c = lb(x,x+n,a * 300000 + b + 2) - lb(x,x+n,a*300000+b+1);
		if(c == 0)b++;
	}
	p(a);




    return 0;
}

Measured memory_bytes: 31616
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
)

var N, K int

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()

	fmt.Sscanf(scanner.Text(), "%d %d", &N, &K)

	hs := make([]int, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &hs[i])
	}

	sort.Sort(sort.IntSlice(hs))

	ans := math.MaxInt64
	for i := 0; i < N-K+1; i++ {
		diff := hs[i+K-1] - hs[i]
		ans = min(ans, diff)
	}
	fmt.Println(ans)
}

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


Measured memory_bytes: 5504
#include <cstdio>
#include <iostream>

using namespace std;


int a[100010];
int pr[100010];



int find(int p) {
    if(pr[p] == p) return p;
    return pr[p] = find(pr[p]);
}

int main(void) {
    int ans = 0;
    int N, M;
    cin >> N >> M;

    for(int i = 1; i <= N; i++) {
        cin >> a[i];
        pr[i] = i;
    }
    for(int i = 1; i <= M; i++) {
        int x, y;
        cin >> x >> y;
        if(find(x) != find(y)) pr[find(y)] = find(x);
    }
    for(int i = 1; i <= N; i++) {
        if (find(i) == find(a[i])) ans++;
    }
    cout << ans << endl;
    return 0;
    
}
    


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

#define ll long long

int main()
{
    int a,b,c;
    //string
    //ll
    cin>>a>>b>>c;
    if(a==b&&b==c)
        cout<<"No\n";
    else if(a==b||b==c||c==a)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}



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

int main() {
  int d;
  cin >> d;
  if (d == 25) cout << "Christmas" << endl;
  if (d == 24) cout << "Christmas Eve" << endl;
  if (d == 23) cout << "Christmas Eve Eve" << endl;
  if (d == 22) cout << "Christmas Eve Eve Eve" << endl;
  return 0;
}

Measured memory_bytes: 256
Scanf.scanf "%d" (fun d ->
    let c = Array.init 26 (fun _ -> Scanf.scanf " %d" (fun c -> c)) in
    let s = Array.init d (fun _ ->
        Array.init 26 (fun _ ->
            Scanf.scanf " %d" (fun s -> s)))
    in
    let last = Array.make 26 (-1) in
    let f a = a * (a - 1) / 2 in
    for i = 0 to d - 1 do
        let rec loop j mi mx =
            if j = 26 then (last.(mi - 1) <- i; Printf.printf "%d\n" mi) else
                if s.(i).(j) + c.(j) * c.(j) * (i - last.(j)) > mx then loop (j + 1) (j + 1) s.(i).(j)
                                                           else loop (j + 1) mi mx
        in
        loop 0 0 0
    done
)

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

int main() {
  int n,q;
  	cin>>n>>q;
  string S;
 	cin >>S;
	vector<int>vec(n);
  
  for(int i=1;i<n;i++){
    if(S.at(i)=='C'&&S.at(i-1)=='A') vec[i]+=1+vec[i-1];
    else vec[i]+=vec[i-1];
  }
    int l=0;
    int r=0;
  for(int j=0;j<q;j++){
	cin>>l>>r;
    cout<<vec[r-1]-vec[l-1]<<endl;
  }
}


Measured memory_bytes: 1536
#include<stdio.h>
#define N 100000

struct Card{
  char c;
  int n, index;
};

int Partition( struct Card A[], int p, int r ){
  int x;
  int i,j;
  struct Card c;
  x = A[r].n;
  i = p - 1;
  for( j = p; j < r; j++ ){
    if( A[j].n <= x){
      i++;
      c = A[i];
      A[i] = A[j];
      A[j] = c;
    }
  }
  c = A[i+1];
  A[i+1] = A[r];
  A[r] = c;

  return i+1;
}

void QuickSort( struct Card A[], int p, int r ){
  int q;
  if( p < r ){
    q = Partition( A, p, r );
    QuickSort( A, p, q-1 );
    QuickSort( A, q+1, r );
  }
}

int isStable( struct Card A[], int n ){
  int i;
  for( i = 1; i < n; i++ ){
    if( A[i-1].n == A[i].n ){
      if( A[i-1].index > A[i].index ){
    return 0;
      }
    }
  }
  return 1;
}

int main(){
  int n, i=0;
  struct Card A[N];

  scanf("%d", &n);

  while(i<n){
    scanf(" %c %d", &A[i].c, &A[i].n);
    A[i].index = i;
    i++;
  }

  QuickSort( A, 0, n-1 );

  if( isStable(A, n) == 1 ){
    printf("Stable\n");
  }
  else{
    printf("Not stable\n");
  }

  for( i = 0; i < n; i++ ){
    printf("%c %d\n", A[i].c, A[i].n);
  }
  return 0;
}

Measured memory_bytes: 1780
n,k = map(int, input().split())
for x in range(n+1):
    for y in range(n+1):
        if x+y>n:
            continue
        z = n-(x+y)
        if x*10000+y*5000+z*1000 == k:
            print(x,y,z)
            exit(0)
print(-1,-1,-1)


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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] nums = {sc.nextInt(), sc.nextInt(), sc.nextInt()};
        Arrays.sort(nums);
        int k = sc.nextInt();
        int ans = nums[0] + nums[1] + (int) (nums[2] * Math.pow(2, k));
        System.out.println(ans);
    }

}


Measured memory_bytes: 23380
N, K = [int(a) for a in input().split()]
K -= 1
num_list = []
for i in range(N):
    num_list.append(int(input()))

num_list.sort()
beaut_list = [b-a for a, b in zip(num_list[:-K], num_list[K:])]

print(str(min(beaut_list)))


Measured memory_bytes: 12748
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <functional>
#include <algorithm>
#include <cassert>
#include <queue>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define ri rd<int>
typedef long long LL;
using namespace std;
const int maxN = 1e5 + 7;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

int X, Y, Z;
int n, m;
struct rec {
	int a, b, c;
	bool operator < (const rec &v) const {return a - b < v.a - v.b;}
}a[maxN]; 
LL pre[maxN], suf[maxN];
priority_queue<int> q;
LL ans = 0;

int main() {

	X = ri(), Y = ri(), Z = ri(), n = X + Y + Z;
	rep (i, 1, n) a[i].a = ri(), a[i].b = ri(), a[i].c = ri();
	sort(a+1, a+n+1);

	pre[0] = 0; 
	while (!q.empty()) q.pop();
	rep (i, 1, n) {
		pre[i] = pre[i-1] + a[i].b;
		int x = a[i].c - a[i].b;
		pre[i] += x;
		if (q.size() < Y || x < q.top()) {
			if (q.size() == Y) {
				pre[i] += q.top();
				q.pop();
			}
			q.push(x);
			pre[i] -= x;
		}
	}

	suf[n+1] = 0;
	while (!q.empty()) q.pop();
	per (i, n, 1) {
		suf[i] = suf[i+1] + a[i].a;
		int x = a[i].c - a[i].a;
		suf[i] += x;
		if (q.size() < X || x < q.top()) {
			if (q.size() == X) {
				suf[i] += q.top();
				q.pop();
			}
			q.push(x);
			suf[i] -= x;
		}
	}

	rep (i, 1, n) if (i >= Y && n - i >= X) ans = max(ans, pre[i] + suf[i+1]);

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

	return 0;
}

Measured memory_bytes: 3448
from sys import stdin
nii=lambda:map(int,stdin.readline().split())

def main():
  n,m=nii()

  tree=[[] for i in range(n)]
  for i in range(m):
    a,b=nii()
    a-=1
    b-=1
    tree[a].append(b)
    tree[b].append(a)

  for i in tree[0]:
    for j in tree[i]:
      if j==n-1:
        print('POSSIBLE')
        exit()
  print('IMPOSSIBLE')

if __name__=="__main__":
  main()

Measured memory_bytes: 38296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main()
{
	ll n, c, p, ans=0;
	cin >> n;
	cin >> p;
	for (ll i=1; i<n; i++)
	{
		cin >> c;
		ll d = 0;
		if (c < p)
		{
			d = p - c;
			ans += d;
		}
		p = c + d;
	}
	cout<<ans<<"\n";
 
	return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>

void judge(int x){
  while(x > 0){
    if(x%10 == 7){
      printf("Yes\n");
      break;
    }
    x /= 10;
    if(x == 0){
      printf("No\n");
    }
  }
  return ;
}
int main(void){
  int num;
  scanf("%d",&num);
  judge(num);
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    string s;
    cin >> s;
    int n = (int)s.size();
    for (int i = 0; i < n; i++) {
        s[i] = 'x';
    }
    cout << s << endl;
    return 0;
}

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

using namespace std;


bool kaibun(string input) {
    char l, r;
    for (unsigned int i = 0; i < ((input.size() + 1) / 2); i++) {
        l = input.at(i);
        r = input.at(input.size() - 1 - i);
        if (l != r) {
            return false;
        }
    }
    return true;
}


int main(void) {
    string S, S1, S2;

    cin >> S;

    S1 = S.substr(0, (S.size() - 1) / 2);
    S2 = S.substr(((S.size() - 1) / 2) + 1, S.size() - 1);

    if (!kaibun(S1)) {
        cout << "No" << endl;
        return 0;
    } else if (!kaibun(S2)) {
        cout << "No" << endl;
        return 0;
    }

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

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, ans;
char A[MAXN];

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


Measured memory_bytes: 384
#include <string>
#include<iostream>
using namespace std;
int main()
{
    string b;

    cin>>b;

    if(b == "A") cout<<'T'<<endl;
    if(b == "T") cout<<'A'<<endl;
    if(b == "G") cout<<'C'<<endl;
    if(b == "C") cout<<'G'<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
#define DBL_INF 1.0e18

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

int n;
vv<double> cost;
vector<double> d;
deque<bool> used;

void dijkstra(int s) {
  d.assign(n+2, DBL_INF);
  used.assign(n+2, false);
  d[s] = 0;

  while (true) {
    int v = -1;
    rep (u, n+2) {
      if (!used[u] && (v == -1 || d[u] < d[v])) {
        v = u;
      }
    }
    if (v == -1) {
      break;
    }
    used[v] = true;
    rep (u, n+2) {
      d[u] = min(d[u], d[v] + cost[v][u]);
    }
  }
}

int main() {
  ll xs, ys, xg, yg;
  scanf("%lld %lld %lld %lld", &xs, &ys, &xg, &yg);
  scanf("%d", &n);
  cost.assign(n+2, vector<double>(n+2, 0));
  vll x(n+2), y(n+2), r(n+2);
  x[0] = xs;
  y[0] = ys;
  r[0] = 0;
  FOR (i, 1, n+1) {
    scanf("%lld %lld %lld", &x[i], &y[i], &r[i]);
  }
  x[n+1] = xg;
  y[n+1] = yg;
  r[n+1] = 0;
  rep (i, n+2) {
    FOR (j, i+1, n+2) {
      ll dx = x[i] - x[j];
      ll dy = y[i] - y[j];
      double c = max(0.0, sqrt(dx*dx + dy*dy) - r[i] - r[j]);
      cost[i][j] = cost[j][i] = c;
    }
  }
  dijkstra(0);
  printf("%.12f\n", d[n+1]);
  return 0;
}


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

  int main(void){

        int x;
	scanf("%d",&x);


	if(x < 1 || 3000 < x){
	  printf("存在しません\n");
	  exit(0);

	}else if(x < 1200){

	   printf("ABC\n");

	}else if(x <= 3000){

	   printf("ARC\n");

}

}





Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


int main(){
    ll n;
    cin >> n;
    ll a[n];
    
    ll iMin = INF;
    REP(i,n)
    {
        cin >> a[i];
        iMin = min(iMin,abs(a[i]));
    }

    //min(abs(a[i]))な気がする
    //0ならやってもやらなくてもよい...が難しそう-> 0がある時点ですべて正にできる?
    //->minが0になる

    //bool zero = false;
    REP(i,n-1)
    {
        if(a[i] < 0)
        {
            a[i] = -1 * a[i];
            a[i+1] = -1 * a[i+1];
        }
        else if(a[i] == 0)
        {
            //zero = true;
            break;
        }
    }

    ll res = 0;
    REP(i, n)
    {
        res += abs(a[i]);
    }
    if(a[n-1] < 0)
    {
        res -= iMin * 2;
    }

    cout << res << endl;

    return 0;    
}



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

using namespace std;

int main() {
		int N;
		cin >> N;
		vector<int> x(N), y(N), h(N);
		for ( int i = 0; i < N; i++ ){
				cin >> x[i] >> y[i] >> h[i];
		}

		int MAX = 100;

		for (int posY = 0; posY <= MAX; posY++) {
				for (int posX = 0; posX <= MAX; posX++) {
						int needH = -1;
						for (int i = 0; i < N; i++) {
								if (h[i] > 0) {
										int tmp = h[i] + abs(posY - y[i]) + abs(posX - x[i]);
										if (needH == -1) {
												needH = tmp;
										} else {
												if (needH != tmp) {
														needH = -2;
														break;
												}
										}
								}
						}
						if (needH == -2) continue;

						for (int i = 0; i < N; i++) {
								if (h[i] == 0) {
										int dist = abs(posY - y[i]) + abs(posX - x[i]);
										if (needH > dist) {
												needH = -2;
												break;
										}
								}
						}
						
						if (needH == -2) continue;

						cout << posX << " " << posY << " " << needH << endl;
						return 0;
				}
		}

		return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    string s; cin >> s;
    ll ans = 0;
    rep(i, s.size()){
        if(i%2 == 0){
            if(s[i] == 'p') ans--; 
        }
        else{
            if(s[i] == 'g') ans++;
        }
    }
    cout << max(0LL, ans) << endl;
}

Measured memory_bytes: 3720
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		int ans = (n + "").length();
		for (long i = 1; i <= Math.sqrt(n); i++) {
			if (n % i == 0 && ((n / i)+"").length() < ans) {
				ans = ((n / i) + "").length();
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <cstring>


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

int BIT[1000001];

int sum(int idx)
{
	int ret = 0;
	while (idx > 0)
	{
		ret += BIT[idx];
		idx -= idx & -idx;
	}
	return ret;
}

const int N = 1000000;
void add(int idx, int num)
{
	while (idx <= N)
	{
		BIT[idx] += num;
		idx += idx & -idx;
	}
}

signed main()
{
	int n;
	while (cin >> n && n)
	{
		memset(BIT, 0, sizeof(BIT));
		int ans = 0;
		vector<int> arr(n);
		rep(i, n) cin >> arr[i];
		rep(i, n)
		{
			ans += i - sum(arr[i]);
			add(arr[i], 1);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 5108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>

using namespace std;

void solve(int n, long long k, vector< pair<int, int> > AB) {
    long long x = 0;
    long long y = 0;
    long long ret = 0;
    long long mas1, mas2;
    long long z;
    long long f = 2;
    mas1 = 3;
    mas2 = 1;
    for (int i = 0; i < 30; i++) {
        if ((k | f) == k) {
            z = (k & ~mas1) | mas2;
            for (int i = 0; i < AB.size(); i++) {
                if ((z | AB[i].first) == z) {
                    x += AB[i].second;
                }
            }
            ret = max(ret, x);
        }
        x = 0;
        f = f << 1;
        mas1 = (mas1 << 1) +1;
        mas2 = (mas2 << 1) +1;
    }
    for (int i = 0; i < AB.size(); i++) {
        if ((k | AB[i].first) == k) {
            y += AB[i].second;
        }
    }
    ret = max(ret, y);
    std::cout << ret << std::endl;
}

int main() {
    struct timeval start,end;
    long long span;
    int n;
    long long k;

    gettimeofday(&start,NULL);

    std::cin >> n >> k;
    vector< pair<int, int> > AB(n);
    for (int i = 0; i < n; i++) {
        std::cin >> AB[i].first >> AB[i].second;
    }
    solve(n, k, AB);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 1920
N = int(input())
a = [int(i) for i in input().split()]

x, y, z = 0, 0, 0
for i in range(N) :
    if a[i] % 4 == 0 :
        x += 1
    elif a[i] % 2 == 0 :
        y += 1
    else :
        z += 1
        
if y > 0 :
    z += 1
    
if z <= x + 1 :
    print('Yes')
else :
    print('No')

Measured memory_bytes: 62960
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x) // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<ll> a(1, 0), b(1, 0);
    for (ll i = 0; i < n; i++)
    {
        ll t;
        cin >> t;
        a.push_back(t + a.back());
    }
    for (ll i = 0; i < n; i++)
    {
        ll t;
        cin >> t;
        b.push_back(t + b.back());
    }
    ll m = 0;
    for (ll i = 0; i < n; i++)
    {
        m = max(m, a[i + 1] + b.back() - b[i]);
    }
    cout << m << endl;
}

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

int main(){
    //入力
    string s;
    cin >> s;

    //処理
    //１だったら加算
    int gu_color_zero=0;
    int ki_color_zero=0;
    int gu_color_one=0;
    int ki_color_one=0;
    for(int i=0;i<s.size();i++)
    {
        if(i%2==0&&s[i]=='1')
        {
            gu_color_one++;
        }
        else if(i%2==0&&'0')
        {
            gu_color_zero++;
        }
        if(i%2==1&&s[i]=='1')
        {
            ki_color_one++;
        }
        else if(i%2==1&&s[i]=='0')
        {
            ki_color_zero++;
        }
    }
    int ans=0;
    ans=min(gu_color_one+ki_color_zero,gu_color_zero+ki_color_one);

    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int n;

bool include3(int i){
    while(i>1){
        if(i%10==3)return true;
        else i/=10;
    }
    return false;
}

int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        if(i%3==0)cout<<" "<<i;
        else if(include3(i))cout<<" "<<i;
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3096
import math
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
result = 0

for i in range(N):
    for j in range(N):
        if i != j:
            result += math.sqrt((xy[i][0] - xy[j][0])**2 + (xy[i][1] - xy[j][1])**2)

print(result / N)



Measured memory_bytes: 9124
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np
 
N = INT()
a = N//100
N %= 100
b = N//10
N %= 10
c = N
 
if a == 7 or b == 7 or c == 7:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 27296
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  vl a(n);
  rep(i,n)cin>>a[i];
  ll ans=0;
  rep(i,n){
    if(i!=n-1&&a[i]%2==1&&a[i+1]!=0){
      a[i+1]--;
      a[i]++;
    }
    ans+=a[i]/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;
const int MOD = 1000000007;
const double pi = acos(-1);

int main() {
    int x; cin >> x;
    cout << !x << endl;
}

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

using namespace std;
using ll = long long;


int main()
{
    vector<ll> t(2), a(2), b(2);
    cin >> t[0] >> t[1] >> a[0] >> a[1] >> b[0] >> b[1];
    if(b[0] > a[0]) {
        swap(a[0], b[0]);
        swap(a[1], b[1]);
    }

    ll ad = t[0] * a[0] + t[1] * a[1];
    ll bd = t[0] * b[0] + t[1] * b[1];
    cerr << bd - ad << endl;

    if(bd - ad < 0) {
        cout << 0 << endl;
    }
    if(bd - ad == 0) {
        cout << "infinity" << endl;
    }
    if(bd - ad > 0) {
        ll sa = a[0] *t[0] - b[0] * t[0];
        cout << (sa / (bd - ad))*2 + 1 - ((sa % (bd - ad)) == 0)<< endl;
    }

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#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 all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
const int LMAX=2010;
int main(){
	int a,b;
	while(cin>>a>>b,a+b){
		vi amr(b+1);
		amr[a]=1;
		int co=1;
		while(1){
			co++;
			a*=10;
			a%=b;
			if(amr[a]){
				int t=co-amr[a];
				cout<<co-t-1<<" "<<t<<endl;
				goto end;
			}
			if(a==0){
				cout<<co-1<<" 0"<<endl;
				break;
			}
			amr.pb(a);
			amr[a]=co;
		}
		end:;
	}
}

Measured memory_bytes: 12936
s = input()
t = input()
ls = len(s)
lt = len(t)
ans = []
for i in range(ls-lt+1):
    for j in range(lt):
        if s[i+j] == "?":
            continue
        if s[i+j] != t[j]:
            break
    else:
        ans.append((s[:i]+t+s[i+lt:]).replace("?","a"))
ans.sort()
if ans:
    print(ans[0])
else:
    print("UNRESTORABLE")

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

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

typedef long long ll;

char a[51][51];
char b[51][51];

int main(){
	int n, m;
	
	cin >> n >> m;
	
	REP(i,n) scanf("%s", a+i);
	
	REP(i,m) scanf("%s", b+i);
	
	/*cout << "a" << endl;
	REP(i,n) printf("%s\n", a+i);
	
	cout << "b" << endl;
	REP(i,m) printf("%s\n", b+i);
	*/
	
	int f = 0;
	
	REP(i,n-m+1){
		REP(j,n-m+1){
			if (a[i][j] == b[0][0]){
				f = 1;
				REP(k,m){
					REP(l,m){
						if (a[i+k][j+l] != b[k][l]){
							f = 0;
							break;
						}
					}
					if (f == 0) break;
				}
			}
			if (f == 1) break;
		}
		if (f == 1) break;
	}
	
	if (f) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream> 
 #include <queue>
 #include <vector>
 #include <string>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;

////////////////いろいろあるよ//////////////////////////////////
int main(){
	int X,Y;
  	cin >> X >> Y;
  	if(X>=(Y-2*X)/2 && (Y-2*X)%2==0 && Y>=2*X)cout << "Yes" << endl;
  	else cout << "No" << endl;
}


Measured memory_bytes: 3632
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
 int h,w,k;
 cin>>h>>w>>k;
 V<string> s(h);
 for(int i=0;i<h;i++)cin>>s[i];
 int ans=0;
   for(int i=0;i<(1<<h);i++){
	   for(int j=0;j<(1<<w);j++){
		   int cnt=0;
		   for(int k=0;k<h;k++){
			   if(i&(1<<k))continue;
			   for(int r=0;r<w;r++){
				   if(j&(1<<r))continue;
				   if(s[k][r]=='#')cnt++;
			   }
		   }
		   if(cnt==k)ans++;
	   }
   }
   cout<<ans<<"\n";
}

Measured memory_bytes: 3616