akhauriyash/Code-Regression huggingface dataset:
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<ll, ll>;
 
#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  ll x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;



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

  ll r;
  std::cin>>r;
  std::cout<<r*r;

  return 0;
}

Measured memory_bytes: 256
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_095_B.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP    PIC X(11).
    01 INP2   PIC 9(4).
    01 maxlen PIC 9(1)  VALUE 2.
    01 cur    PIC 9(2)  VALUE 1.

    01 i      PIC 9(18) VALUE 1.
    01 j      PIC 9(18).
    01 k      PIC 9(18).

    01 len    PIC 9(2).

    01 ans    PIC X(8).

    01 NX1.
        03 NX11 OCCURS 2.
            05 NX PIC 9(8).

    01 tmp    PIC 9(8).

    01 mn     PIC 9(6).
    01 sm     PIC 9(6).
    01 x      PIC 9(6).

    01 ZS     PIC Z(9).
    01 DUMMY  PIC X(1).
PROCEDURE                        DIVISION.
MAIN.
    ACCEPT INP.

    PERFORM maxlen TIMES

        PERFORM VARYING j FROM cur BY 1
            UNTIL INP(j:1) = SPACE
        END-PERFORM

        COMPUTE len = j - cur

        MOVE INP(cur:len) TO NX(i)

        COMPUTE cur = j + 1

        ADD 1 TO i

    END-PERFORM.

    MOVE 0 TO sm.
    MOVE 1001 TO mn.
    PERFORM VARYING k FROM 1 BY 1 UNTIL NX(1) < k
        ACCEPT INP2
        ADD INP2 TO sm
        COMPUTE mn = FUNCTION MIN(mn, INP2)
    END-PERFORM.

    SUBTRACT sm FROM NX(2) GIVING tmp.
    DIVIDE mn INTO tmp GIVING x.

    ADD x TO NX(1).
    MOVE NX(1) TO ZS.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    ll a, b, c, d;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    ll k = (max(a, b) - 1) / (min(a, b) + 1) + 1;
    ll l = 0, r = a;
    while (l < r) {
      ll ma = (l + r + 1) >> 1;
      ll mb = max(0LL, (ma - 1) / k);
      if (b - mb <= (a - ma + 1) * k) {
        l = ma;
      } else {
        r = ma - 1;
      }
    }
    ll t = l + max(0LL, (l - 1) / k);
    for (ll i = c; i <= min(t, d); i++) {
      putchar(i % (k + 1) ? 'A' : 'B');
    }
    for (ll i = max(t + 1, c); i <= d; i++) {
      putchar((a + b + 1 - i) % (k + 1) ? 'B' : 'A');
    }
    puts("");
  }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
string a,b;
int x,y;
int main(){
	cin>>a>>b;
	int len1=a.size(),len2=b.size();
	while(len1!=x||len2!=y){
		if(len1!=x){
			printf("%c",a[x]);
			x++;
		}
		if(len2!=y){
			printf("%c",b[y]);
			y++;
		}
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

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() {
  int n, m;
  cin >> n >> m;
  int result = (n * (n - 1) / 2) + (m * (m - 1) / 2);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

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

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



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

	cin >> n;
	vector<int> data(n);
	vector<int> ans(n);
	
	rep(i, 0, n) {
		
		cin >> data[i];
		ans[i] = data[i];
	}
	
	sort(ans.begin(), ans.end());


	
	

	rep(i, 0, n) {
		if (data[i] <= ans[n / 2 - 1]) {
			cout << ans[n / 2] << endl;
		}
		else {
			cout << ans[n / 2-1] << endl;
		}
		
	}

	


}
	

Measured memory_bytes: 3840
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {
        n:usize,d:i64,a:i64,
        mut xh: [(i64,i64);n],
    }
    xh.sort();
    let x: Vec<i64> = xh.iter().map(|&x| x.0).collect::<Vec<_>>();
    let mut h: Vec<i64> = xh.iter().map(|&x| x.1).collect::<Vec<_>>();
    let mut ans = 0i64;
    let mut r = 0usize;
    let mut t = vec![0; n + 2];
    for left in 0..n {
        if left > 0 {
            t[left] += t[left - 1];
        }
        let mut now = h[left] - t[left];
        if now <= 0 {
            continue;
        }
        let cnt = (now + a - 1) / a;
        ans += cnt;
        let minus = cnt * a;
        r = x.upper_bound(&(x[left] + 2 * d));
        t[left] += minus;
        t[r] -= minus;
    }
    println!("{}", ans);
}

pub trait BinarySearch<T> {
    fn lower_bound_by<F: Fn(&T) -> bool>(&self, f: F) -> usize;
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
}
impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound_by<F: Fn(&T) -> bool>(&self, f: F) -> usize {
        let mut ng = -1;
        let mut ok = self.len() as i64;
        while (ok as i32 - ng as i32).abs() > 1 {
            let mid = (ok + ng) / 2;
            if f(&self[mid as usize]) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        ok as usize
    }
    fn lower_bound(&self, x: &T) -> usize {
        self.lower_bound_by(|y| y >= x)
    }
    fn upper_bound(&self, x: &T) -> usize {
        self.lower_bound_by(|y| y > x)
    }
}


Measured memory_bytes: 13832
import math
n = int(input())
rg = range(1, n + 1)
k = 0
for a in rg:
    for b in rg:
        g1 = math.gcd(a,b)
        for c in rg:
            g2 = math.gcd(g1,c)
            k += g2
print(k)


Measured memory_bytes: 9180
#include<stdio.h>

int main(void){
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    
    if(x >= r && x <= W-r && y >= r && y <= H-r )
        printf("Yes\n");
    else printf("No\n");
    
    return 0;
}


Measured memory_bytes: 2076
n,m=map(int,input().split())
a=[int(input())for i in range(m)]

a.append(n+1)
mod=1000000007

b=[0]*(n+1)
b[0]=1
if a[0]==1:
    b[1]=0
    count=1
else:
    b[1]=1
    count=0

if n==1:
    if m==0:
        print("1")
    else:
        print("0")
else:
    for i in range(2,n+1):
        if i==a[count]:
            b[i]=0
            count += 1
        else:
            b[i]=b[i-1]+b[i-2]
    print(int(b[n]%mod))

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;




void build(int len, int n) {
    vector<vector<int>> v;
    vector<int> ptr;
    int avail=1;
    for (int iter=0; iter<len+1; iter++) {
	vector<int> cur;
	for (int i=0; i<(int)v.size(); i++) {
	    cur.push_back(v[i][ptr[i]++]);
	}
	while ((int)cur.size() < len) {
	    assert(avail<=n);
	    cur.push_back(avail++);
	}
	v.push_back(cur);
	ptr.push_back(iter);
    }

    cout<<"Yes\n";
    cout<<v.size()<<"\n";
    for (auto w: v) {
	cout<<w.size()<<" ";
	for (int x: w) cout<<x<<" ";
	cout<<"\n";
    }
}


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

    if (n==1) {
	cout<<"Yes\n";
	cout<<"2\n";
	cout<<"1 1\n";
	cout<<"1 1\n";
	exit(0);
    }

    for (int len=2; len<=2*n && 2*len<=n+1; len++) {
	int cnt = 2*n;
	if (cnt%len) continue;
	if (cnt/len == len+1) {
	    build(len, n);
	    exit(0);
	}
    }

    cout<<"No\n";
    return 0;
}


Measured memory_bytes: 3908
import copy

N = int(input())
xy = []

for i in range(N):
    xy.append(list(map(int,input().rstrip().split())))
    
distances = [[0]*N for i in range(N)]


for i in range(N):
    for j in range(N):
        distances[i][j] = ((xy[i][0]-xy[j][0])**2+(xy[i][1]-xy[j][1])**2)**0.5

ans = 0
def calcdistance(visited,distances,total,start):
    global ans
    visited2 = copy.deepcopy(visited)
    visited2[start] = 1
    if 0 in visited2:
        for i in range(N):
            if visited2[i] == 0:
                calcdistance(visited2,distances,total+distances[start][i],i)
        return
    else:
        ans += total
        return

for i in range(N):
    calcdistance([0]*N,distances,0,i)
    
kaijo = 1
for i in range(1,N+1):
    kaijo *= i
    
print(ans/kaijo)

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

typedef long long int llint;

int main(){
	int a=1;
	int acnt=0,bcnt=0;
	string S;
	cin >> S;

	for(const auto& c : S){
		if(c-'0'!=a){
			acnt++;
		}else{
			bcnt++;
		}
		a= !a;
	}
	if(acnt<bcnt){
		cout << acnt;
	}else{
		cout << bcnt;
	}

	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
#define LP(i, a, b) for (int i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (int i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-13

#define INF 1e9
int const MaxSize = 150 + 1;
int n;
int s[MaxSize];

int main() {
	ios_base::sync_with_stdio(false);
	//freopen("/Users/george/A_1.in", "r", stdin);
	cin >> n;
	int t = 0;

	LP(i, 0, n)
	{
		cin >> s[i];
		t += s[i];
	}

	sort(s, s + n);

	if (t % 10) {
		cout << t;

	} else {
		LP(i, 0, n)
		{
			if (s[i] % 10) {
				cout << t - s[i] << endl;
				return 0;

			}
		}
		cout << 0;
	}

	return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
ll A[200100];

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

    std::cin >> N;

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

    ll x = 0;
    ll cnt = 0;

    for(int i=0,j=0;i<N;i+=1){
        while(j < N && (x & A[j]) == 0){
            x |= A[j];
            j += 1;
        }
        
        cnt += j - i;
        x &= ~A[i];
    }

    std::cout << cnt << std::endl;
}


Measured memory_bytes: 1792
import java.security.KeyStore.TrustedCertificateEntry
import java.util
import java.util.regex.Pattern
import java.util.{ArrayList, Collections, Comparator, List => JList}

import scala.math._
import scala.collection.mutable
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.util.{Failure, Success, Try}

object Main{
  val LINE_SEPARATOR = "\n"
  def main(args: Array[String]): Unit = {
    if (sys.env.getOrElse("TEST", "")=="1"){
      println(test());
    }else{
      val input=io.Source.stdin.getLines().mkString(LINE_SEPARATOR);
      println(solve(input).trim());
    }
  }

  def init (nRows: Int, nCols: Int, default: Int) = Array.tabulate(nRows,nCols)( (x,y) =>  default)

  def sortIgnoreCase1(list: JList[String]): JList[String] = {
    val r = new ArrayList[String](list)
    Collections.sort(r, new Comparator[String] {
      override def compare(o1: String, o2: String): Int = o1.compareToIgnoreCase(o2)
    })
    r
  }

  def solve(input: String): String = {
    val n = input.split(LINE_SEPARATOR).head.toInt
    val s = input.split(LINE_SEPARATOR).tail.head
    val candidate = for (i <- 0 to 9; j <- 0 to 9; k <- 0 to 9) yield (i, j, k)
    candidate.count { c =>
      s.split(c._1.toString, 2).tail.headOption.flatMap( x =>
        x.split(c._2.toString, 2).tail.headOption.flatMap(y =>
          y.split(c._3.toString, 2).tail.headOption
        )
      ).isDefined
    }.toString
  }

  def divisors(n: Long): Vector[Long] = {
    val halfList = (1 to sqrt(n).toInt).toVector.filter(_ % n == 0).map(_.toLong)
    val reversedList = if (sqrt(n).floor == sqrt(n)) halfList.reverse.tail.map(n/_) else halfList.reverse.map(n/_)
    halfList ++ reversedList
  }

  def gcd(m: Long, n: Long): Long = n match {
    case 0 => m
    case _ => gcd(n, m % n)
  }
  def lcm(a: Long, b: Long): Long = a * b / gcd(a, b)

  val tests=List(
    """4
      |0224""".stripMargin -> """3
                                    |
                                              |
                                         |""".stripMargin,
    """6
      |123123""".stripMargin -> """17
                                              |
                                      |""".stripMargin,
    """19
      |3141592653589793238""".stripMargin -> """329
                                          |""".stripMargin
  )

  def test():String= {
    return tests.map{case (i,o)=>(i.trim(),o.trim())}
      .zipWithIndex.map{
      case ((input,outputExpect),i)=>{
        val output=solve(input).trim();
        s"test${i+1}:"+(if(output==outputExpect){
          "Passed"
        }else{
          s"Failed\nexpect:\n${outputExpect}\noutput:\n${output}"
        })
      }}
      .mkString("\n");
  }
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    for (int i = 0; i < sz(s); i++) {
        if (s[i] == '?') s[i] = 'D';
    }
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 3752
using System;
using System.Text;

namespace ITP1_7_D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int m = int.Parse(input[1]);
            int l = int.Parse(input[2]);

            int[,] A = MakeMap(n, m);
            int[,] B = MakeMap(m, l);
            long[,] C = new long[n, l];
            for(int i = 0; i < n; i++)
            {
                for(int j = 0; j < m; j++)
                {
                    for(int k = 0; k < l; k++)
                    {
                        C[i, k] += A[i, j] * B[j, k];
                    }
                }
            }

            StringBuilder sb = new StringBuilder();
            for(int i = 0; i < n; i++)
            {
                sb.Append(C[i, 0]);
                for(int j = 1; j < l; j++)
                {
                    sb.Append(" " + C[i, j]);
                }
                sb.AppendLine();
            }
            Console.Write(sb);
        }

        static int[,] MakeMap(int a,int b)
        {
            int[,] ret = new int[a, b];
            for(int i = 0; i < a; i++)
            {
                int[] nums = ReadLine();
                for(int j = 0; j < b; j++)
                {
                    ret[i, j] = nums[j];
                }
            }
            return ret;
        }

        static int[] ReadLine()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
    }
}

Measured memory_bytes: 10196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e9+7
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 long long int gcd(long long int m,long long int n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
long long int lcm(long long int number1,long long int number2){
	return number1 * number2 / gcd(number1,number2);	

}
int main(){
  ll A,B,C,D,E,F;
  cin>>A>>B>>C>>D>>E>>F;
  
  double max2=0;
  ll sugar=0;
  ll water=0;
  
  for(ll i=0;i*100*A<F;i++){//A
    for(ll j=0;j*100*B<F;j++){//B
      for(ll k=0;k*C<F;k++){//C
        for(ll m=0;m*D<F;m++){//D
          if(k*C+m*D+A*100*i+B*100*j>F){
            continue;//ここのIFは順番が逆だとアウト
          }
          
          if(max(i,j)==0){
            continue;
          }
          
        double unko=double(double(k*C+m*D)/double(A*100*i+B*100*j+k*C+m*D));
          
          if(max2<=unko&&(k*C+m*D)<=E*(A*i+B*j)){
            max2=double(double(k*C+m*D)/double(A*100*i+B*100*j+k*C+m*D));
          sugar=(k*C+m*D);
            water=(A*100*i+B*100*j);
          }
          }
        }
      }
    }
  
  
  cout<<water+sugar<<" "<<sugar<<endl;
}

Measured memory_bytes: 256
n, t = gets.split.map(&:to_i)
c = []
n.times do
  c << gets.split.map(&:to_i)
end
ans = 1000
flg = 0
c.each do |i|
  if i[1] <= t
    if i[0] <= ans
      flg = 1
      ans = i[0]
    end
  end
end
if flg == 0
  puts 'TLE'
else
  puts ans
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define int long long
constexpr int MOD = 1000000000 + 7;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(10);

    int n;
    vector<pair<int, int>> arm_ranges;
    cin >> n;
    arm_ranges.reserve(n);
    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        arm_ranges.push_back({a + b, a - b});
    }

    // 区間スケジューリング
    // ロボットの腕が動く範囲の終端が最も原点に近いロボットを貪欲的に取り除かないことにしていく

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

    int count = 0;
    int end_of_latest_arm = -MOD;
    for (int i = 0; i < n; i++)
    {
        if (end_of_latest_arm <= arm_ranges[i].second)
        {
            end_of_latest_arm = arm_ranges[i].first;
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#define N 4

int main(void){
    int tmp, sumA=0, sumB=0;
    
    for (int i=0; i<N; i++){
        scanf("%d", &tmp);
        sumA += tmp;
    }
    for (int i=0; i<N; i++){
        scanf("%d", &tmp);
        sumB += tmp;
    }
    printf("%d\n", sumA>sumB?sumA:sumB);
    return 0;
}

Measured memory_bytes: 1020
#include <stdio.h>
#include <stdlib.h>
#define N 100
#define A 1000

int main(void){
  int n,i,temp,j,k;
  int a[N];

  scanf("%d",&n);
  if(n<0||n>N)exit(1);  
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(k=0;k<n;k++){
    if(k!=n-1) printf("%d ",a[k]);
    else printf("%d\n",a[k]);
  }
  for(j=1;j<n;j++){
    temp=a[j];
    i=j-1;
    while(i>=0 && a[i] > temp){
      a[i+1]=a[i];
      i=i-1;
    }
    a[i+1]=temp;
    for(k=0;k<n;k++){
      if(k!=n-1) printf("%d ",a[k]);
      else printf("%d\n",a[k]);
    }
  }
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  
  int maxcount = 0;
  int maxvalue = 0;
  int secondmaxvalue = 0;
  
  for(int i=0; i<n; i++){
    cin >> vec.at(i);

    if (vec.at(i) == maxvalue) {
      maxcount += 1;
    }
    
    if (vec.at(i) > maxvalue ){
      secondmaxvalue = maxvalue;
      maxvalue = vec.at(i);
      maxcount = 1; 
    }
    
    if (vec.at(i) > secondmaxvalue && vec.at(i) < maxvalue){
      secondmaxvalue = vec.at(i);
    }

  }

  if (maxcount == 1){
    for(int i=0; i<n; i++){
      if (vec.at(i) == maxvalue) {
        cout << secondmaxvalue << endl;
      }
      else {
        cout << maxvalue << endl;      
      }
    }
  }
  else {
    for(int i=0; i<n; i++){
      cout << maxvalue << endl;
    }
  }
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> H(N);
  
  for (int i=0; i<N; i++) {
    cin >> H.at(i);
  }
  
  sort(H.begin(),H.end());
  reverse(H.begin(),H.end());
  
  int sum=1;
  
  for (int i=0; i<N-1; i++) {
    if (H.at(i)-H.at(i+1) > 0) {
      sum++;
    }
  }
  
  cout << sum << endl;
}

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

int dh[4]={1,0,-1,0};
int dw[4]={0,1,0,-1};

int main() {
  int H, W;
  cin >> H >> W;

  ll INF = 1e9;
  vector<vector<ll>> board(H, vector<ll>(W, -1));

  ll countWhite = 0;
  rep0(i, H) {
    string s; cin >> s;
    rep0(j, W) {
      if (s[j] == '#') {
        board[i][j] = INF;
      } else {
        countWhite++;
      }
    }
  }

  queue<pair<ll, ll>> q;
  board[0][0] = 0;
  q.push(make_pair(0, 0));
  while(!q.empty()) {
    pair<ll, ll> p = q.front();
    q.pop();
    ll h = p.first;
    ll w = p.second;
    rep0(i, 4) {
      ll nh = h + dh[i];
      ll nw = w + dw[i];
      if (nh < 0 || nw < 0 || nh >= H || nw >= W) {
      } else if (board[nh][nw] == -1) {
        board[nh][nw] = board[h][w] + 1;
        q.push(make_pair(nh, nw));
      }
    }
  }

  ll ans;
  if (board[H - 1][W - 1] == -1) ans = -1;
  else ans = countWhite - board[H - 1][W - 1] - 1;

  cout << ans << BR;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n;
    scanf("%lld",&n);
    ll a[n];
    ll sum = 0;
    for (int i = 0; i < n; i++){
        scanf("%lld",&a[i]);
        sum += a[i];
    }
    ll N = (ll)n*(n+1)/2;
    if (sum % N){
        printf("NO");
        return 0;
    }
    ll k = sum/N;
    ll x = a[0];
    for (int i = 0; i < n-1; i++){
        a[i] -= a[i+1];
    }
    a[n-1] -= x;
    ll ct = 0;
    for (int i = 0; i < n; i++){
        if (k+a[i] < 0 || (k+a[i])%n){
            printf("NO");
            return 0;
        }
        ct += (k+a[i])/n;
    }
    printf("YES\n");
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>
#include <climits>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vvi;
typedef vector <ll> vl;
typedef vector <vector <ll>> vvl;
typedef vector <bool> vb;
typedef vector <vector <bool>> vvb;

//const int kINF = INT_MAX;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

template <typename type>
ostream &operator<<(ostream &out, const vector <type> &massive) {
    for (const type &i : massive) {
        out << i << ' ';
    }
    return out;
}

template <typename type>
void print(const vector <type> &massive, const string &sep, const string &end) {
    if (!massive.empty()) {
        cout << massive[0];
        for (int i = 1; i < massive.size(); ++i) {
            cout << sep << massive[i];
        }
    }
    cout << end;
}

template <typename type>
void print(const vector <type> &massive) {
    print(massive, " ", "\n");
}

template <typename type>
void print(const type &element, const string &end) {
    cout << element << end;
}

template <typename type>
void print(const type &element) {
    print(element, "\n");
}

int main() {
    fast();

    //freopen("../input.txt", "r", stdin);

    int a, b, c, k;
    cin >> a >> b >> c >> k;

    int want = 0;
    while (a >= b) {
        b *= 2;
        ++want;
    }
    while (b >= c) {
        c *= 2;
        ++want;
    }

    if (want <= k) {
        print("Yes");
    } else {
        print("No");
    }


    return 0;
}


Measured memory_bytes: 3652
import java.io.*;

class Main{
	public static void main(String []args)throws IOException{
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      	String str = br.readLine();
      	String s[] = str.split(" ");
      	int A = Integer.parseInt(s[0]);
      	int B = Integer.parseInt(s[1]);
      	int C = Integer.parseInt(s[2]);
      	int K = Integer.parseInt(s[3]);
      
      	int maxSum = 0;
      	
      	if(K - A >= 0)
          maxSum = A;
      	else{
          maxSum = K;
          K = 0;
        }
      	K = K - A;
      	if(K > 0)
          K = K - B;
      	if(K > 0)
          maxSum = maxSum + K * (-1);
      System.out.println(maxSum);
    }
}

Measured memory_bytes: 25328
/*input
6 6
..#..#
......
#..#..
......
.#....
....#.
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=1005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int n,m;
string s[maxn];

pii operator + (pii A,pii B){
	return MP(A.F+B.F,A.S+B.S);
}
const pii dir[]={MP(0,1),MP(0,-1),MP(1,0),MP(-1,0)};

vector<pii> q;
int pt=0;
int dis[maxn][maxn];
bool vis[maxn][maxn];


bool val(pii A){
	return 0<=A.F&&A.F<n&&0<=A.S&&A.S<m;
}

int main(){
	IOS;
	cin>>n>>m;
	REP(i,n) cin>>s[i];
	REP(i,n) REP(j,m){
		if(s[i][j]=='#'){
			q.pb(MP(i,j));
			dis[i][j]=0;
			vis[i][j]=1;
		}
	}

	while(pt<SZ(q)){
		pii cur=q[pt++];

		REP(i,4){
			pii nxt=cur+dir[i];
			if(!val(nxt)) continue;
			if(vis[nxt.F][nxt.S]) continue;
			dis[nxt.F][nxt.S]=dis[cur.F][cur.S]+1;
			vis[nxt.F][nxt.S]=1;
			q.pb(nxt);
		}
	}
	int ans=0;
	REP(i,n) REP(j,m) ans=max(ans,dis[i][j]);
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 15980
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#define int long long
using namespace std;

int a, b, c, k;

signed main() {
	cin >> a >> b >> c >> k;
	k %= 2;
	for (int i = 0; i < k; i++) {
		int aa = b + c;
		int bb = c + a;
		int cc = a + b;
		a = aa;
		b = bb;
		c = cc;
	}
	cout << a - b << endl;
	return 0;
}

Measured memory_bytes: 256
l=[]
while True:
  a, op, b = list(map(str,input().split()))
  a = int(a)
  b = int(b)
  if op=="?":
    break
  elif op == "+":
    e = a + b
  elif op == "-":
    e = a - b
  elif op == "*":
    e = a * b
  else :
    e = a // b
  l.append(e)

for ele in l:
  print(ele)


Measured memory_bytes: 5600
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int a,b,ans;
  std::cin >> a >> b;
  if(b>=a) ans=a;
  else ans=a-1;
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
ll mod=998244353;

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    string s,s1="red";
    cin>>s;
    if(n<3200)cout<<s1;
    else cout<<s;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define debug(x) cerr << (x) << '\n';
#define bits(x,i) ((x >> i) & 1)
using namespace std;
int s,w;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> s >> w;
    cout << (w >= s ? "unsafe" : "safe");
}

Measured memory_bytes: 3648
h, w, k = map(int, input().split())
cnt = 0
cntrem = 0
answer = 0
b = []
flag = [[0] * w for _ in range(h)]
for i in range(h):
    b.append(input())
    cnt += b[i].count('#')
# print(cnt)
copy = b
for i in range(2 ** h):
    cntrem = 0
    flag = [[0] * w for _ in range(h)]

    for j in range(h):
        if (i >> j) & 1:
            cntrem += b[j].count('#')

            for roop_w in range(w):
                flag[j][roop_w] = 1
    # print('firstrem', end=' ')
    # print(cntrem)
    tmp = cntrem
    for ka in range(2 ** w):
        cntrem = tmp
        for l in range(w):
            if (ka >> l) & 1:
                for roop_h in range(h):
                    # print(flag)
                    # print(b[roop_h][l])
                    if flag[roop_h][l] == 0 and b[roop_h][l] == '#':
                        cntrem += 1

                # cntrem += b[j].count('#')

        # print(cnt - cntrem)
        if cnt - cntrem == k:
            answer += 1

print(answer)


Measured memory_bytes: 9252
/**
 * Author: Behradm
 * Created: 03-05-2020 16:30:52
 * In the Name of God
**/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define LOCAL

#ifdef LOCAL
	#define debugi(x) cerr << "{" << #x << "}: " << (x) << '\n'
	#define debug(v, begin, end) cerr << "{ | "; for(auto i = begin; i < end; i++){cerr << #v << "[" << i << "]: " << v[i] << " | ";} cerr << " }\n"
	#define debugp(a, b) cerr << "\n{ " << a << " " << b << " }\n"
#else
	#define debugi(x) 42
	#define debug(v, begin, end) 42
	#define debugp(a, b) 42 
#endif

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	cout.tie(0);
	cout.precision(6);
	string s;
	cin >> s;
	if (s == "ABC")
		cout << "ARC";
	else
		cout << "ABC";
	return 0;
}



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

int inf = (1 << 30);
int mod = 1e9;
long long long_inf = (1LL << 60);

bool check(string S){
    string s = S.substr(S.length() / 2);
    bool flag = true;
    for(int i = 0; i < s.length(); i++){
        if(s[i] != S[i]){
            flag = false;
            break;
        }
    }
    return flag;
}

int main(){

    string S;
    cin >> S;

    while(S.length() != 0){
        S.pop_back();
        S.pop_back();
        if(check(S)){
            cout << S.length() << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
mod = pow(10,9)+7
c = 0
cnt = 0
for i in range(K,N+1):
    temp1 = 0.5*(K+cnt)*(K+cnt-1)
    temp2 = (K+cnt)*0.5*(2*N-(K+cnt-1))
    c += temp2 - temp1 + 1
    c = c%mod
    cnt += 1
c += 1
print(int(c))

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

int main() {
	int n, a[128], r[128] = {0};
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(a[i] < 3200)
			r[a[i] / 400]++;
		else
			r[8]++;
	}
	int ans = 0;
	for(int i = 0; i < 8; i++){
		if(r[i] > 0)
			ans++;
	}
	if(ans == 0)
		cout << "1 " << r[8] << endl;
	else
		cout << ans << " " << ans + r[8] << endl;
	return 0;
}

Measured memory_bytes: 256
import bisect as bi
import sys
N = int(sys.stdin.readline())
C = [int(sys.stdin.readline()) for i in range(N)]
inf = 10000000000
lis = [inf for i in range(N)]
for c_i in C:
    lis[bi.bisect_left(lis, c_i)] = c_i
print(bi.bisect_left(lis, inf))

Measured memory_bytes: 12520
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
//typedef pair<int, int> P;
struct P {
	int x, y;
	P(int x, int y):x(x), y(y){}
	P(){}
};

/** Problem0234 : Aizu Buried Treasure **/
int W, H;
int field[10][10];
int dp[11][11][11][11][51];
int F, M, O;

int solve(int y, int x, int l, int r, int o)
{
	//cerr << y << " " << x << " " << l << " "<< r << " " << o << endl;
	
	if (y == H-1) return o<=0 ? INF : 0;
	if (o<=1) return INF;
	
	if (dp[y][x][l][r][o] != -1) return dp[y][x][l][r][o];
	
	int res=INF;
	
	// 左に
	if (0<l) {
		int no = min(o - (x-(l-1)) + max(0, field[l-1][y]), M);
		int e = max(0, -field[l-1][y]);
		res = min(res, e+solve(y, l-1, l-1, r, no));
	}
	
	// 右に
	if (r<W-1) {
		int no = min(o - ((r+1)-x) + max(0, field[r+1][y]), M);
		int e = max(0, -field[r+1][y]);
		res = min(res, e+solve(y, r+1, l, r+1, no));
	}
	
	// 下に
	for (int i=l; i<=r; i++) {
		int no = min(o - 1 - abs(x-i) + max(0, field[i][y+1]), M);
		int e = max(0, -field[i][y+1]);
		res = min(res, e+solve(y+1, i, i, i, no));
	}
	
	return dp[y][x][l][r][o] = res;
}

int main()
{
	while (cin>>W>>H, W||H) {
		cin>>F>>M>>O;
		rep(y, H) rep(x, W) cin>>field[x][y];
		
		if (O<=1) { cout<<"NA"<<endl; continue; }
		
		memset(dp, -1, sizeof(dp));
		
		int ans=INF;
		rep(i, W) {
			int o = min(O-1+max(0, field[i][0]), M);
			int e = max(0, -field[i][0]);
			ans = min(ans, e+solve(0, i, i, i, o));
		}
		
		if (ans<=F) cout << ans << endl;
		else		cout << "NA" << endl;
	}
}

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

int main(){
  int N;
  double T, A;
  cin >> N >> T >> A;


  vector<double> H(N);
  for (int i = 0; i < N; i++)
  {
    cin >> H.at(i);
  }
  
  int near = 0;
  double tmp;

  for (int i = 0; i < N; i++)
  {
    tmp = T - H.at(i) * 0.006;
    if (abs(A - tmp) < abs(A - (T - H.at(near) * 0.006))){
      near = i;
    } 
  }
  cout << near + 1 << endl;
}

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

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

    bool flag = true;
    for (int i = 0; i < S.size(); i++)
    {
        if (i % 2 == 0)
        {
            if (S[i] == 'L')
            {
                flag = false;
            }
        }
        else
        {
            if (S[i] == 'R')
            {
                flag = false;
            }
        }
    }
    if (flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private int n;
    private long a;
    private long b;
    private long[] x;
 
    private void solve(Scanner sc) {
        n = sc.nextInt();
        a = sc.nextLong();  
        b = sc.nextLong();
        x = new long[n];
        for (int i = 0; i < n; ++i) {
            x[i] = sc.nextLong();
        }
 
        long cost = 0;
        for (int i = 0; i < n - 1; ++i) {
            if ((x[i + 1] - x[i]) * a > b) {
                cost += b;
            } else {
                cost += (x[i + 1] - x[i]) * a;
            }
        }
        _out.println(cost);
    }
    private long C(long n, long r) {
        long res = 1;
        for (long i = n; i > n - r; --i) {
            res *= i;
        }
        for (long i = r; i > 1; --i) {
            res /= i;
        }
        return res;
    }
    private long P(long n, long r) {
        long res = 1;
        for (long i = n; i > n - r; --i) {
            res *= i;
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 51988
#include <iostream>
#include <stack>

using namespace std;

stack<char> sta;
string str;

int main(int argc, char *argv[])
{
    int count = 0;
    cin >> str;
    
    for (char & ch : str)
    {
        if (sta.empty())
        {
            sta.emplace(ch);
        }
        else if (sta.top() == ch)
        {
            sta.emplace(ch);
        }
        else
        {
            sta.pop();
            ++count;
        }
    }
    
    cout << 2 * count << endl;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

#define bit(b, i) (((b) >> (i)) & 1)

#define UQns(v) v.erase(unique(ALL(v)), v.end())
#define UQ(v) sort(ALL(v)); UQns(v)

int n, a[1 << 18];
vector<pair<int, int>> dp[1 << 18];

int t[1 << 18];

void f(int a, int b) {
	dp[a][2] = dp[b][0];
	dp[a][3] = dp[b][1];
	sort(RALL(dp[a]));
	unique(ALL(dp[a]));
}

int main() {
	cin >> n;
	inc(i, 1 << n) { cin >> a[i]; }
	/*
	inc(i, 1 << n) {
	inc(j, i) {
		setmax(t[i | j], a[i] + a[j]);
	}
	}
	*/
	// inc(i, 1 << n) { cout << t[i] << endl; } cout << endl;
	
	inc(i, 1 << n) {
		dp[i].EB(a[i], i);
		inc(k, 3) { dp[i].EB(-1, -1); }
	}
	
	inc(i, 1 << n) {
	inc(j, n) {
		if(bit(i, j) == 0) { f(i | (1 << j), i); }
	}
	}
	
	int ma = 0, ma_t = 0;
	incID(i, 1, 1 << n) {
		setmax(ma, dp[i][0].FI + dp[i][1].FI);
		cout << ma << "\n";
		setmax(ma_t, t[i]);
		// cout << ma - ma_t << endl;
	}
	
	return 0;
}


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

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

typedef long long int64;

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

  vector<vector<int>> x(n, vector<int>(d));

  for(vector<int>& row: x) {
    for(int& val: row) {
      cin >> val;
    }
  }

  int cnt = 0;

  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      double tmp = 0.0;
      for(int k=0; k<d; k++){
        tmp += pow(x[i][k] - x[j][k], 2);
      }
      if(ceil(sqrt(tmp)) == floor(sqrt(tmp))) cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}

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

using namespace std;

int N, M;
int DpDistSum[100000];

int main() {
	int s, a, curPos, total;

	memset(DpDistSum, 0, sizeof(DpDistSum));
	cin >> N >> M;
	for (int i = 1; i < N; ++i) {
		cin >> s;
		DpDistSum[i] = DpDistSum[i - 1] + s;
	}
	total = 0;
	curPos = 0;
	for (int i = 0; i < M; ++i) {
		cin >> a;
		total = (total + abs(DpDistSum[curPos + a] - DpDistSum[curPos])) % 100000;
		curPos += a;
	}
	cout << total << endl;

	return 0;
}


Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
int n, a, odd = 0, even = 0, four = 0, flag = 0;
int main () {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &a);
        if(a % 2 == 1) {
            odd++;
        }else{
            even++;
            if(a % 4 == 0) {
                four++;
            }
        }
    }
    if(four >= odd) {
        flag = 1;
    }
    if(four == odd - 1 && four == even) {
        flag = 1;
    }
    if(flag) {
        printf("Yes\n");
    }else {
        printf("No\n");
    }
    return 0;
}



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

int main()
{
    int N, A;
    std::cin >> N;

    std::vector<int> data(N, 0);

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

    for (int i = 0; i < N; ++i)
    {
        std::cout << data[i] << std::endl;
    }

    return 0;
}


Measured memory_bytes: 4052
#include <iostream>

using namespace std;

const int Max = 10000000;
bool prime[Max];
int main()
{
  int in;
  for(int i=0; i<Max; i++){
    prime[i] = true;
  }
  prime[1] = false;
  for(int i=2; i<Max; i++){
    if(prime[i]){
      for(int s=i*2; s<=Max; s+=i){
	prime[s] = false;
      }
    }
  }
  while(cin>>in){
    int cnt=0;
    for(int i=1; i<=in; i++){
      if(prime[i]){
	cnt++;
      }
    }
      cout << cnt << endl;
  }
}

Measured memory_bytes: 10924
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int ans=0;
  int t=n;
  while (t>0){
    ans+=t%10;
    t/=10;
  }
  if (n%ans==0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007

using namespace std;

int main(){
    int K,N;
    cin >> K >> N;
    int A[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    int MAX = 0;
    for (int i = 0; i < N-1; i++)
    {
        MAX = max(A[i+1] - A[i], MAX);
    }
    MAX = max(A[0] + K - A[N-1] , MAX);
    cout << K - MAX << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  int sum=a[0];
  int l=0,r=1;
  ll res=0;
  while(1)
  {
    while(r<n&&((sum^a[r])==sum+a[r]))
    {
      sum^=a[r];
      r++;
    }
    res+=r-l;
  //  cout<<l<<" "<<r<<" "<<sum<<endl;

    if(l==n-1)break;
    sum^=a[l];
    l++;
    if(r==l){r++;sum^=a[r-1];}
  }
  cout<<res<<endl;

  return 0;

}


Measured memory_bytes: 1024