akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t N;
	std::cin >> N;
	boost::multi_array<int64_t, 2> A(boost::extents[2][N]);
	for (int64_t i : boost::irange(0, 2))
	{
		for (int64_t j : boost::irange((int64_t)0, N))
		{
			std::cin >> A[i][j];
		}
	}

	int64_t ans = 0;
	for (int64_t i = 0; i < N; i++)
	{
		int64_t upper_candies = 0;
		for (int64_t j = 0; j < i + 1; j++)
		{
			upper_candies += A[0][j];
		}
		int64_t lower_candies = 0;
		for (int64_t j = i; j < N; j++)
		{
			lower_candies += A[1][j];
		}
		int64_t all_candies = upper_candies + lower_candies;
		ans = std::max(ans, all_candies);
	}

	std::cout << ans << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


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

int main() {
  int n;
  cin>>n;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    a.at(i)=x;
    b.at(i)=x;
  }
  sort(b.begin(),b.end());
  if(b.at(n-2)==b.at(n-1)){
    for(int i=0;i<n;i++){
      cout<<b.at(n-1)<<endl;
    }
  }
  else{
    int i=0;
    while(a.at(i)!=b.at(n-1)){
      i++;
    }
    for(int j=0;j<n;j++){
      if(j!=i){
        cout<<b.at(n-1)<<endl;
      }
      else{
        cout<<b.at(n-2)<<endl;
      }
    }
  }
}

Measured memory_bytes: 3200
#include <cstdio>
#include <cstring>

using namespace std;

int map[128][128];
int sx, sy, gx, gy;
int sc;

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

bool dfs(int ty, int tx)
{
	if (ty == gy && tx == gx){
		return (true);
	}
	
	map[ty][tx] = -1;
	
	for (int i = 0; i < 4; i++){
		if (map[ty + dy[i]][tx + dx[i]] == sc){
			if (dfs(ty + dy[i], tx + dx[i]) == true){
				return (true);
			}
		}
	}
	
	return (false);
}

int main()
{
	int w, h;
	int n;
	
	while (scanf("%d %d", &w, &h) && w){
		memset(map, -1, sizeof(map));
		scanf("%d %d", &sx, &sy);
		scanf("%d %d", &gx, &gy);
		scanf("%d", &n);
		
		for (int i = 0; i < n; i++){
			int col, dir, tx, ty;
			scanf("%d %d %d %d", &col, &dir, &tx, &ty);
			if (dir == 0){
				for (int dy = 0; dy < 2; dy++){
					for (int dx = 0; dx < 4; dx++){
						map[ty + dy][tx + dx] = col;
					}
				}
			}
			else {
				for (int dy = 0; dy < 4; dy++){
					for (int dx = 0; dx < 2; dx++){
						map[ty + dy][tx + dx] = col;
					}
				}
			}
		}
		sc = map[sy][sx];
		printf("%s\n", ~sc && dfs(sy, sx) == true ? "OK" : "NG");
	}
	
	return (0);
}

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

int main(){
	int a1,a2,a3,b1,b2,b3;
	int x[4][4];
	
	for(int i=1; i<=3; i++){
		for(int j=1; j<=3; j++){
			cin>>x[i][j];
		}
	}
	
	a1=0;
	b1=x[1][1]-a1;
	b2=x[1][2]-a1;
	b3=x[1][3]-a1;
	
	a2=x[2][1]-b1;
	a3=x[3][1]-b1;
	
	if(a2+b2==x[2][2] && a2+b3==x[2][3] && \
	   a3+b2==x[3][2] && a3+b3==x[3][3]){
		 cout<<"Yes"<<endl;
		 return 0;
	}
	
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 384
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let a: i64 = iter.next().unwrap().parse().unwrap();
    let b: i64 = iter.next().unwrap().parse().unwrap();

    println!("{}", if a <= 9 && b <= 9 { a * b } else { -1 });
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int f[1050][5050];
int p[1050],x[1050];

int main() {
  int n;
  cin >> n;
  for(int i=2;i<=n;i++) {
    cin >> p[i];
  }
  for(int i=1;i<=n;i++) cin >> x[i];
  for(ll i=n;i;i--) {
    for(ll j=x[p[i]];j>=0;j--) {
      f[p[i]][j]=min(x[i]<=j?f[p[i]][j-x[i]]+f[i][x[i]]:(ll)1e9,f[i][x[i]]<=j?f[p[i]][j-f[i][x[i]]]+x[i]:(ll)1e9);
    }
  }
  if(f[1][x[1]]<(ll)1e9) {
    cout << "POSSIBLE" << endl;
  }
  else {
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 19840
k = int(input())
len_map = dict()
cur = [i for i in range(1,10)] # cur list
total = cur
counter = 9
cur_digit_len = 1
while counter < 10**5:
    tmp = []
    for sample in cur:
        sample_str = str(sample)
        if int(sample_str[-1]) > 0:
            tmp.append(int(sample_str + str(int(sample_str[-1])-1)))
        tmp.append(int(sample_str + sample_str[-1]))
        if int(sample_str[-1]) < 9:
            tmp.append(int(sample_str + str(int(sample_str[-1])+1)))
    total.extend(tmp)
    counter += len(tmp)
    cur = tmp
print(total[k-1])

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

using ll = long long;
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
#define repi(n) for (int i = 0; i < n; i++)
#define repj(n) for (int j = 0; j < n; j++)
#define repk(n) for (int k = 0; j < n; k++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define repv(itr) for (auto&& v : itr)
#define swap(x, y)    \
  {                   \
    auto ___temp = x; \
    x = y;            \
    y = ___temp;      \
  }

const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}

ll a[100000];
int main() {
  int n;
  cin >> n;
  repi(n) cin >> a[i];

  int minuscount = 0;
  repi(n) if (a[i] < 0) minuscount++;
  if (minuscount % 2) {
    ll absmin = LLONG_MAX;
    repi(n) absmin = min(absmin, abs(a[i]));
    ll x = 0;
    repi(n) x += abs(a[i]);
    cout << x - absmin * 2 << endl;
  } else {
    ll x = 0;
    repi(n) x += abs(a[i]);
    cout << x << endl;
  }
}


Measured memory_bytes: 1024
import string
import collections
a_prime=[]
b_prime=[]
a,b = map(int, input().split())
def getPrime(a):
  prime=[]
  for i in range(2,int(a**0.5//1)+1):
    if a%i==0:
      while a%i == 0:
        a=a//i
      prime+=[i]
  if a!=1:
    prime.append(a)

  return prime
a_prime=getPrime(a)
b_prime=getPrime(b)
print(len(set(a_prime) & set(b_prime))+1)

Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for(int i = 0;i < 1000;i++){
        string t = "";
        if(i < 10)t += '0';
        if(i < 100)t += '0';
        t += to_string(i);
        int cnt = 0;
        rep(j,n){
            if(s[j] == t[cnt])cnt++;
            if(cnt == 3){
                ans++;
                //cout << t << endl;
                break;
                }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3740
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def ceil(a, b):
  return (a + b - 1) // b

def main():
  n = int(input())
  nt, na = 1, 1
  for i in range(n):
    t, a = map(int, input().split())
    r = max([ceil(nt, t), ceil(na, a)])
    nt, na = r*t, r*a
  print(nt + na)

if __name__=='__main__':
  main()



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
 
int main() {
  int n,k;
  string s;
  cin>>n>>k>>s;
  vector<int>a;
  vector<int>b;
  a.push_back(-1);
  if(s.at(0)=='0'){
    b.push_back(-1);
  }
  rep(i,n-1){
    if(s.at(i)=='0'&&s.at(i+1)=='1'){
      a.push_back(i);
    }
    if(s.at(i)=='1'&&s.at(i+1)=='0'){
      b.push_back(i);
    }
  }
  b.push_back(n-1);
  int si=b.size();
  if(si<=k){
    cout<<n<<endl;
  }
  else{
    int ma=0;
    rep(i,si-k){
      ma=max(ma,b.at(i+k)-a.at(i));
    }
    cout<<ma<<endl;
  }
}

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

class DisjointSet {
public:
  vector<int> rank, p;

  DisjointSet() {}
  DisjointSet(int size) {
    rank.resize(size, 0);
    p.resize(size,0);
    for(int i=0; i < size; i++) makeSet(i);
  }

  void makeSet(int x) {
    p[x] = x;
    rank[x] = 0;
  }

  bool same(int x, int y) {
    return findSet(x) == findSet(y);
  }

  void unite(int x, int y) {
    link(findSet(x), findSet(y));
  }
  void link(int x, int y) {
    if (rank[x] > rank[y]) {
      p[y] = x;
    } else {
      p[x] = y;
      if (rank[x] == rank[y]) {
        rank[y]++;
      }
    }
  }
  int findSet(int x) {
    if (x != p[x]) {
      p[x] = findSet(p[x]);
    }
    return p[x];
  }
};

int main(){
	int n, a, b, q;
  int t;

  cin >> n >> q;
  DisjointSet ds = DisjointSet(n);

  for (int i = 0; i < q; i++ ) {
    cin >> t >> a >> b;
    if ( t == 0) ds.unite(a,b);
    else if ( t == 1) {
      if (ds.same(a,b)) cout << 1 << endl;
      else cout << 0 << endl;
    }
  }
  return 0;
}



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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int sum = accumulate(a.begin(), a.end(), 0);
    int ave = sum / n;
    int can1 = ave, can2 = ave + 1;
    int ans1 = 0, ans2 = 0;
    for(int i = 0; i < n; i++) {
        ans1 += (a[i] - can1) * (a[i] - can1);
        ans2 += (a[i] - can2) * (a[i] - can2);
    }
    int ans = min(ans1, ans2);
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;


int main(){
    string s;
    cin >> s;
    int cnt=0;
    int p;
    for(int i=0;i<s.size();i++){
        if(s[i] == 'A'){
            p=i;
            break;
        }
    }
    for(int i=s.size()-1;i>=0;i--){
        if(s[i] == 'Z'){
            p = i-p+1;
            break;
        }
    }
    cout << p <<endl;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする


def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N=len(v)
    size=len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    print(N-K+1)




if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <utility>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

namespace BasicMath {
    // 最大公約数を求める(ユークリッドの互除法) 
    // O(log max(a, b)) time, O(1) space
    static UInt GreatestCommonDivisor(UInt a, UInt b);

    UInt GreatestCommonDivisor(UInt a, UInt b) {
        if (b == 0) {
            return a;
        } else {
            if (a < b) {
                std::swap(a, b);
            }
            return GreatestCommonDivisor(b, a % b);
        }
    }
#define GCD GreatestCommonDivisor
}

using namespace BasicMath;

int main(void) {
    Int n;
    cin >> n;
    VI a(n);
    for (Int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    Int result = a[0];
    for (Int i = 0; i < n; ++i) {
        result = GCD(result, a[i]);
    }
    cout << result << endl;

    return 0;
}



Measured memory_bytes: 4048
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	int a=0,b=0,c=0;
	while(n--)
	{
		int x;
		cin>>x;
		if(x%4==0)
			a++;
		else if(x%2==0)
			b++;
		else c++;
	}
	if(c==0)
	{
		cout<<"Yes\n";
		return 0;
	}
	if(a>=c-1)
	{
		if(b==0||(a-(c-1))>0)
		{
			cout<<"Yes\n";
			return 0;
		}
	}
	cout<<"No\n";
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def inpl(): return tuple(map(int, input().split()))

N, Z, W = inpl()

A = inpl()

# X全取り
p1 = abs(A[-1] - W)

# X１残し
if N > 1:
    p2 = abs(A[-1] - A[-2])
else:
    p2 = p1

print(max(p1, p2))


Measured memory_bytes: 3188
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.function.BiFunction;
import java.util.Scanner;
import java.util.function.BinaryOperator;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TheBalance solver = new TheBalance();
        try {
            int testNumber = 1;
            while (true)
                solver.solve(testNumber++, in, out);
        } catch (UnknownError e) {
            out.close();
        }
    }

    static class TheBalance {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int d = in.nextInt();
            if (a == 0 && b == 0 && d == 0) {
                throw new UnknownError();
            }

            BinaryOperator<Pair> check = new BinaryOperator<Pair>() {

                public Pair apply(Pair p1, Pair p2) {
                    if (p1.sum() < p2.sum()) {
                        return p1.clone();
                    } else if (p1.sum() > p2.sum()) {
                        return p2.clone();
                    } else {
                        if (p1.first * a + p1.second * b < p2.first * a + p2.second * b) {
                            return p1.clone();
                        } else {
                            return p2.clone();
                        }
                    }
                }
            };
            Pair ans = new Pair((int) 2e4, (int) 2e4);
            for (int ac = 0; ac < 1e5; ac++) {
                Pair cand = new Pair(ac, (int) 2e4);
                if ((d - a * ac) >= 0 && (d - a * ac) % b == 0) {
                    cand.second = (d - a * ac) / b;
                    ans = check.apply(ans, cand);
                }
                if ((a * ac + d) % b == 0) {
                    cand.second = (a * ac + d) / b;
                    ans = check.apply(ans, cand);
                }
                if ((a * ac - d) >= 0 && (a * ac - d) % b == 0) {
                    cand.second = (a * ac - d) / b;
                    ans = check.apply(ans, cand);
                }
            }
            out.println(ans.first + " " + ans.second);
        }

        class Pair {
            public int first;
            public int second;

            public Pair(int f, int s) {
                this.first = f;
                this.second = s;
            }

            public int sum() {
                return this.first + this.second;
            }

            public Pair clone() {
                return new Pair(this.first, this.second);
            }

        }

    }
}




Measured memory_bytes: 92304
use std::collections::HashMap;
use itertools::Itertools;

#[macro_use]
macro_rules! error {
    ($($arg:tt)+) => (
        println!($($arg)+);
    )
}

fn main() {
    let mut input_buffer = String::new();
    let stdin = std::io::stdin();
    if let Err(err) = stdin.read_line(&mut input_buffer) {
        error!("Cannot read a line from stdin: {}", err);
        return;
    }
    let input_buffer = input_buffer.trim();
    
    let sequence_length: usize = match input_buffer.parse() {
        Ok(n) => n,
        Err(err) => {
            error!("\"{}\" is not a positive integer: {}", input_buffer, err);
            return;
        },
    };

    if sequence_length == 0 {
        error!("The length has to be a positive (non-zero) even integer. ");
        return;
    }
    if sequence_length % 2 != 0 {
        error!("The length of sequence has to be even. ");
        return;
    }
    
    let mut input_buffer = String::new();
    if let Err(err) = stdin.read_line(&mut input_buffer) {
        error!("Cannot read a line from stdin: {}", err);
        return;
    }
    let input_buffer = input_buffer.trim();
    
    let sequence = input_buffer
        .split(' ')
        .map(|s| s.parse::<i32>())
        .collect::<Result<Vec<_>, _>>();
    let sequence = match sequence {
        Ok(s) => s, 
        Err(err) => {
            error!("\"{}\" are not integers: {}", input_buffer, err);
            return;
        }, 
    };

    if sequence.len() != sequence_length {
        error!("The length of sequence is different from reserved one: {} reserved, {} used. ", sequence_length, sequence.len());
        return;
    }

    let mut even_items: HashMap<i32, i32> = HashMap::new();
    let mut odd_items: HashMap<i32, i32> = HashMap::new();
    for pair in sequence.chunks(2) {
        *even_items.entry(pair[0]).or_insert(0) += 1;
        *odd_items.entry(pair[1]).or_insert(0) += 1;
    }
    let even_items = even_items;
    let odd_items = odd_items;

    let even_items_sorted: Vec<(i32, i32)> = even_items.into_iter().sorted_by(|a, b| a.1.cmp(&b.1)).rev().collect();
    let odd_items_sorted: Vec<(i32, i32)> = odd_items.into_iter().sorted_by(|a, b| a.1.cmp(&b.1)).rev().collect();

    let even_max = even_items_sorted[0];
    let odd_max = odd_items_sorted[0];
    if even_max.0 != odd_max.0 {
        println!("{}", sequence_length as i32 - (even_max.1 + odd_max.1));
    }
    else {
        let odd_max2 = *odd_items_sorted.get(1).unwrap_or(&(even_max.0 + 1, 0i32));
        let even_max2 = *even_items_sorted.get(1).unwrap_or(&(odd_max.0 + 1, 0i32));
        println!("{}", sequence_length as i32 - std::cmp::max(even_max2.1 + odd_max.1, even_max.1 + odd_max2.1));
    }
}


Measured memory_bytes: 4624
while line = gets
    a,b =line.split.map{|item| item.to_i}
    printf("%d %d\n", a.gcd(b), a.lcm(b))
end

#または

#loop do 
    #line = gets 
    #break unless line
    #a,b = line.split.map(&:to_i)

    
#while 繰り返し続ける条件 do
    #繰り返したい処理
#end
#(doは省略可能)

#while文で入力ファイルを行ごとに取得している
#getsは標準入力もしくは第一引数の内容を，文字列として一行ずつ得ることができる
#ここではgetsの内容をlineに入れて，lineがnilになるまでwhileで繰り返しています．

#while line = gets で.「lineがnilになるまで、getsする」つまり、
#「全部の行の入力を得るまで繰り返す」.ということになる.これが「繰り返し続ける条件」



Measured memory_bytes: 6864
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pll pair<ll,ll>
#define sll set<ll>
#define msll multiset<ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define vpl vector<pll>
#define gll greater<ll>
#define gpl greater<pll>
#define spl set<pll>
#define mspl multiset<pll>
#define lb lower_bound
#define bp __builtin_popcount
#define ub upper_bound
#define prq priority_queue
#define mp make_pair
#define pb push_back
#define mem(x,y) memset(x, y, sizeof x)
#define endl "\n"
#define sz(x) (ll)x.size()
#define sqr(x) x*x
#define rapido ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef long double ld;
ll mx = INT_MAX;
ll mn = INT_MIN;
ll INF = 1e18+10;
ll MOD = 1e9+7;
const ll maxs = (1<<11);
const ll lg = 22; 
ll fast(ll base , ll expo){ ll res = 1; while(expo>=1){ if(expo%2) res *= base; base *= base; expo /= 2; } return res; }

ll R,C,K;
string S[6];

void init(){
    mx = INT_MIN; mn = INT_MAX; INF = 1e18+10;
}

// ll go(ll r, ll c, ll rmask, ll cmask, ll black){
//     if(black==K) return 1;
//     if(r==R || c==C) return 0;
//     ll ans = go(r+1, c+1, rmask , cmask, black);
//     if(((rmask & (1<<r)) == 0) and ((cmask & (1<<c)) == 0)){
//         ll cnt = 0;
//         for(ll i=0; i<R; i++){
//             for(ll j=0; j<C; j++){
//                 if(i==r and j==c and ((rmask & (1<<i))==0) and ((cmask & (1<<j))==0)) 
//                     if(S[i][j]=='#') cnt++;
//             }
//         }
//         ans += go(r+1, c+1, (rmask | 1<<r), (cmask | 1<<c), black - cnt);
//     }
//     if(((rmask & (1<<r)) == 0)){
//         ll cnt = 0;
//         for(ll i=0; i<C; i++){
//             if((cmask & (1<<i))==0) 
//                 if(S[r][i]=='#') cnt++;
//         }
//         ans += go(r+1, c, (rmask | 1<<r), cmask, black - cnt);
//     }
//     if(((cmask & (1<<c)) == 0)){
//         ll cnt = 0;
//         for(ll i=0; i<R; i++){
//             if((rmask & (1<<i))==0) 
//                 if(S[i][c]=='#') cnt++;
//         }
//         ans += go(r, c+1, rmask, (cmask | 1<<c), black - cnt);
//     }
//     return ans;
// }

ll go(){
    ll ans = 0;
    ll rmask = 1<<R, cmask = 1<<C; 
    for(ll i=0; i<rmask; i++){
        for(ll j=0; j<cmask; j++){
            ll black = 0;
            for(ll r=0; r<R; r++){
                for(ll c=0; c<C; c++){
                    if(((i & (1<<r)) == 0) || ((j & (1<<c)) == 0)) continue;
                    if(S[r][c] == '#') black++;
                }
            }
            if(black == K) ans++;
        }
    }
    return ans;
}

void code_idhr_h(){
    cin>>R>>C>>K;
    for(ll i=0; i<R; i++) cin>>S[i];
    ll black = 0;
    for(ll i=0; i<R; i++){
        for(ll j=0; j<C; j++){
            if(S[i][j]=='#') black++;
        }
    }
    cout<<go();
}

int main(){
    rapido;
    ll T=1; //cin>>T;
    //pre();
    while(T--){
        init();
        code_idhr_h();
    }
    return 0;
}

Measured memory_bytes: 3644
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=5000005;
int n,p[N],q[N],lst,i,j,k,l,head[N],adj[N],nxt[N],flow[N],cap[N],cur[N],d[N],bg,ed,ans,tot;
bool v[N];
void addedge(int u,int v,int w)
{
	adj[++l]=v;
	nxt[l]=head[u];
	head[u]=l;
	cap[l]=w;
	adj[++l]=u;
	nxt[l]=head[v];
	head[v]=l;
	cap[l]=0;
}
void dfs1(int x)
{
	addedge(x,tot,100000000);
	addedge(tot,x,100000000);
	v[x]=true;
	if(!v[p[x]])
		dfs1(p[x]);
}
void dfs2(int x)
{
	addedge(n+x,tot,100000000);
	addedge(tot,n+x,100000000);
	lst=x;
	v[x]=true;
	if(!v[q[x]])
		dfs2(q[x]);
}
bool bfs()
{
	int i;
	for(i=1;i<=tot;++i)
		d[i]=100000000;
	q[bg=ed=1]=tot-1;
	d[q[bg]]=0;
	while(bg<=ed)
	{
		for(i=head[q[bg]];i;i=nxt[i])
			if(flow[i]<cap[i]&&d[adj[i]]==(100000000))
			{
				d[adj[i]]=d[q[bg]]+1;
				q[++ed]=adj[i];
			}
		++bg;
	}
	return d[tot]!=(100000000);
}
int dfs(int x,int a)
{
	if(x==tot||a<=0)
		return a;
	int g,h=0;
	for(;cur[x];cur[x]=nxt[cur[x]])
		if(d[adj[cur[x]]]==d[x]+1&&(g=dfs(adj[cur[x]],min(a,cap[cur[x]]-flow[cur[x]])))>0)
		{
			flow[cur[x]]+=g;
			flow[cur[x]&1?cur[x]+1:cur[x]-1]-=g;
			a-=g;
			h+=g;
			if(a<=0)
				break;
		}
	return h;
}
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;++i)
	{
		scanf("%d",p+i);
		++p[i];
	}
	for(i=1;i<=n;++i)
	{
		scanf("%d",q+i);
		++q[i];
	}
	tot=2*n;
	for(i=1;i<=n;++i)
		if(!v[i])
		{
			++tot;
			dfs1(i);
		}
	for(i=1;i<=n;++i)
		v[i]=false;
	for(i=1;i<=n;++i)
		if(!v[i])
		{
			++tot;
			dfs2(i);
		}
	tot+=2;
	ans=0;
	for(i=1;i<=n;++i)
		if(p[i]==i&&q[i]==i)
			++ans;
		else if(p[i]==i&&q[i]!=i)
			addedge(tot-1,n+i,1);
		else if(p[i]!=i&&q[i]==i)
			addedge(i,tot,1);
		else if(p[i]==q[i])
			addedge(i,n+i,1),addedge(n+i,i,1);
		else
			addedge(i,n+i,1);
	while(bfs())
	{
		for(i=1;i<=tot;++i)
			cur[i]=head[i];
		ans+=dfs(tot-1,100000000);
	}
	printf("%d",n-ans);
	return 0;
}


Measured memory_bytes: 47488
#include<cstdio>
#include<functional>
#include<algorithm>
#include<queue>
#include<vector>
#define MM 210000000000000000
using namespace std;
typedef pair<long long,int> P;
typedef pair<int,int> P1;
long long leng[100001],sum,mn,aa;
vector<int> mati[100001],cost[100001];
P m2[100001];
int main(void)
{
	int i,j,n,m,a,b,c,x,y;
	int flg[100001];
	priority_queue<P,vector<P>,greater<P> > que;
	P1 qq;
	P ppp;
	scanf("%d %d %d",&n,&m,&c);
	sum=0;
	for(i=0;i<m;i++)	{
		scanf("%d %d %d",&a,&b,&x);
		mati[a].push_back(b);
		mati[b].push_back(a);
		cost[a].push_back(x);
		cost[b].push_back(x);
		sum+=x;
	}
	for(i=1;i<=n;i++)	leng[i]=MM;
	que.push(P(0,1));
	while(que.size()!=0)	{
		ppp=que.top();	que.pop();
		aa=ppp.first;	b=ppp.second;
		if(aa<leng[b])	{
			leng[b]=aa;
			for(i=0;i<mati[b].size();i++)	{
				que.push(P(aa+cost[b][i],mati[b][i]));
			}
		}
	}
//	for(i=1;i<=n;i++)	printf(" %d",leng[i]);	printf("\n");
	for(i=0;i<n;i++)	{
		m2[i].first=leng[i+1];
		m2[i].second=i+1;
		flg[i+1]=0;
	}
	m2[i].first=MM;	m2[i].second=n+1;
	sort(m2,m2+n+1);
	mn=sum;
	i=0;
	while(i<n)	{
		while(1)	{
			x=m2[i].second;
			for(j=0;j<mati[x].size();j++)	{
				y=mati[x][j];
				if(flg[y]==1)	{
					sum-=cost[x][j];
				}
			}
			flg[x]=1;
			i++;
			if(m2[i-1].first!=m2[i].first)	break;
		}
//		printf("i=%d sum=%lld\n",i,sum+m2[i-1].first*c);
		mn=min(mn,sum+m2[i-1].first*c);
	}
	printf("%lld\n",mn);
	return 0;
}


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")

using ll = std::int64_t;
using vint = std::vector<int>;
using vll = std::vector<ll>;
using vstr = std::vector<std::string>;
using pint = std::pair<int, int>;
using usetint = std::unordered_set<std::int32_t>;
using usetstr = std::unordered_set<std::string>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    int n;
    cin >> n;
    vstr w(n);
    rep(i, n)cin >> w[i];

    usetstr s;
    string prev;
    rep(i, n) {
        if (i == 0) {
            s.insert(w[i]);
        }
        else {
            if (s.count(w[i]) == 1) {
                No; return;
            }
            if (w[i].front() != prev.back()) {
                No; return;
            }
            s.insert(w[i]);
        }
        prev = w[i];
    }
    Yes;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

int main() {
    int n;
    cin >> n;
    V<ll> a(n), b(n);
    ll as = 0, bs = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        as += a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        bs += b[i];
    }

    ll c = bs - as;
    if (c < 0) {
        cout << "No" << endl;
        return 0;
    }

    ll oneuse = 0, twouse = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] < b[i]) {
            twouse += (b[i] - a[i] + 1) / 2;
        } else {
            oneuse += a[i] - b[i];
        }
    }
    if (twouse <= c && oneuse <= c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;
ll n, m, com[100100][35], ans;
const ll mod = 1000000007;
vector<ll> sosu;
map<ll, ll> mp;

bool so(ll x){
    bool u = true;
    for (ll j = 2; j <= sqrt(x); j++){
        if (x % j == 0) u = false;
    }
    return u;
}

int main(void){
    // Your code here!
    ans = 1;
    cin >> n >> m;
    if (m == 1){
        cout << 1 << endl;
        return 0;
    }
    for (ll i = 1; i <= sqrt(m); i++){
        if (m % i) continue;
        if (i == 1){
            if (so(m)) sosu.push_back(m);
        } else {
            if (so(i)) sosu.push_back(i);
            if (so(m / i)) sosu.push_back(m / i);
        }
    }
    for (ll i = 0; i < sosu.size(); i++){
        ll p = m;
        while(p % sosu[i] == 0){
            mp[sosu[i]]++;
            p /= sosu[i];
        }
    }
    for (ll i = 0; i < 100050; i++) com[i][0] = 1;
    for (ll i = 0; i < 34; i++) com[0][i] = 1;
    for (ll i = 1; i < 100050; i++){
        for (ll j = 1; j < 34; j++){
            (com[i][j] = com[i - 1][j] + com[i][j - 1]) %= mod;
        }
    }
    for (auto itr = mp.begin(); itr != mp.end(); ++itr){
        (ans *= com[n - 1][itr->second]) %= mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 27648
import java.util.Scanner;


public class Main{
	public static void main(String[] args) {
		new Main().run();
	}

	void run(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n;
			n = sc.nextInt();
			if(n == 0){
				break;
			}
			int sum = 1;
			int i = 2;
			int count = 0;
			while(true){
				if((n - sum) < i){
					break;
				}
				if((n - sum) % i == 0){
					count++;
				}
				sum = sum + i;
				i = i + 1;
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 18136
#include <iostream>
using namespace std;
int ans[500][500];
int main()
{
	int n,k=1;
	scanf("%d",&n);
	while (k*(k-1)/2<n)
	k++;
	if (k*(k-1)/2==n)
	{
		printf("Yes\n%d\n",k);
		int cur=1;
		for (int i=0;i<k-1;i++)
		{
			for (int j=i;j<k-1;j++)
			ans[i][j]=cur+j-i;
			for (int j=i+1;j<k;j++)
			ans[j][i]=cur+j-i-1;
			cur+=k-i-1;
		}
		for (int i=0;i<k;i++)
		{
			printf("%d",k-1);
			for (int j=0;j<k-1;j++)
			printf(" %d",ans[i][j]);
			printf("\n");
		}
	}
	else
	printf("No");
}

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

int main() {
  int h, w;
  cin >> h >> w;
  
  char a[h][w];

  for(int i = 0; i < h+2; i++) {
    for(int j = 0; j < w+2; j++) {
      if (i == 0 || i == h+1 || j == 0 || j == w+1) cout << '#';
      else {
        cin >> a[i-1][j-1];
        cout << a[i-1][j-1];
      }
    }
    cout << endl;
  }
}

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

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

  int cnt = 4;
  while (1) {
    if (n == 4 || n == 2 || n == 1) break;
    if (n%2==1) n = 3*n + 1;
    else n /= 2;
    cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
using System;
using System.Windows;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static int time;

    static void Main(string[] args)
    {
        time = 0;
        //入力を受け取る
        var n = int.Parse(Console.ReadLine());
        mynode[] M = new mynode[n + 1];
        var S = new MyStack();

        for(int i = 1; i < n + 1; i++)
        {
            M[i] = new mynode();
        }

        //各ノードの情報を初期化する
        for (int i = 1; i < n + 1; i++)
        {
            var ukv = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var u = ukv[0];
            var k = ukv[1];
            M[i].initialize(u, k);

            for (int j = 0; j < k; j++)
            {
                M[i].RegistAdjacenxy(M[ukv[2 + j]]);
            }
        }


        //スタックで探索を管理
      　for(int i = 1; i < n + 1; i++){
        RegistStack(M[i], S);
       }
        //探索終了時間の登録
        //while (S.IsEmpty() != -1)
        //{
          //  time++;
           // S.pop().finish = time;
       // }

        //結果の出力
        for (int i = 1; i < n + 1; i++)
        {
            Console.WriteLine(M[i].id + " " + M[i].find + " " + M[i].finish);
        }

        
    }

    static void RegistStack(mynode m, MyStack S)
    {
        //対象ノードが登録済かどうかを調べる
        if (m.find == -1)
        {
            time++;
            m.find = time;
            foreach (mynode k in m.adjacency)
            {
                S.push(m);
                if (k != null)
                {
                    RegistStack(k, S);
                }
            }
            time++;
            m.finish = time;
          　　
        }
    }
}

class MyStack
{
    public mynode[] datas = new mynode[1000];
    public int point = -1;
    public void push(mynode data)
    {
        this.point++;
        datas[point] = data;
    }
    public mynode pop()
    {
        mynode result = datas[this.point];
        this.point--;
        return result;
    }

    public int IsEmpty()
    {
        return point;
    }
}

class mynode
{
    public int id;
    public int find = -1;
    public int finish = -1;
    //隣接するノードを登録する用の変数
    public mynode[] adjacency = null;
    int point = 0;

    public void initialize(int id, int depth)
    {
        this.id = id;
        this.adjacency = new mynode[depth];
    }

    public void RegistAdjacenxy(mynode m)
    {
        this.adjacency[this.point] = m;
        this.point++;
    }
}


Measured memory_bytes: 18264
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define sort(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

unsigned int randxor()
{
	static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned int t;
	t = (x ^ (x << 11)); x = y; y = z; z = w; return(w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

//10進数を2進数に変換_63個の要素を持つ配列
vector<int> Convert10to2(ll n) {
	vector<int> ans(63);
	rep(i, 63) {
		ans[i] = n % 2;
		n -= n % 2;
		n /= 2;
	}
	return ans;
}
//2進数を10進数に変換_63個の要素を持つ配列
ll Convert2to10(vector<int> a) {
	ll ans=0;
	ll j = 1;
	rep(i, a.size()) {
		ans += a[i] * j;
		if (i != a.size() - 1) {
			j *= 2;
		}
	}
	return ans;
}
//XORを計算
vector<int> CalcXOR2to2(vector<int> a, vector<int> b) {
	rep(i, 63) {
		if (a[i] != b[i]) {
			a[i] = 1;
		}
		else {
			a[i] = 0;
		}
	}
	return a;
}


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



Measured memory_bytes: 256
#include <stdio.h>


int main()
{
  int a, b;
  
  scanf("%d %d", &a, &b);

  if (a > b)
    printf("a > b\n");
  else if (a < b)
    printf("a < b\n");
  else
    printf("a == b\n");
  
  return 0;
}



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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,a;
bool f;

signed main() {
    cin >> n;
    rep(i,n) cin >> a, f |= a%2;
    if (f) cout << "first" << endl;
    else cout << "second" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define int long long int
#define float double
#define pb push_back
#define FF first
#define SS second
#define N 201000
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i++)
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define pii pair<int,int>
#define mp make_pair
#define INF 1000000000000000000
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int dp[N]={};

signed main() 
{
    speed;
    //freopen("input.tXt","r",stdin);
    //freopen("output.tXt","w",stdout);

    int n,W;
    cin>>n>>W;
    rep(i,1,n)
    {
        int a,b;
        cin>>a>>b;
        for(int j=W-a;j>=0;j--) dp[j+a]=max(dp[j+a],dp[j]+b);
    }
    cout<<dp[W];

}   

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

uint64_t N;
std::vector<std::pair<uint64_t, uint64_t>> task;

int main(int argc, char const* argv[])
{
    std::cin >> N;
    uint64_t a, b;
    while (std::cin >> a >> b) {
        task.emplace_back(b, a);
    }
    std::sort(task.begin(), task.end());
    uint64_t time = 0;
    for (const auto& e : task) {
        time += e.second;
        if (time > e.first) {
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    std::cout << "Yes" << std::endl;
    return 0;
}


Measured memory_bytes: 6256
#include <bits/stdc++.h>
#define int long
#define ll long long
#define IOS cin.tie(0); ios::sync_with_stdio(false)
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    IOS;
    string S,T; cin >> S >> T; 
    map<char,vector<int>> m; 
    bool can2=true; vector<int> res(T.size(),0);
    rep(i,S.size()){
        m[S[i]].push_back(i);
    }
    rep(i,T.size()){    
        bool can=false; bool can3=true;
        vector<int>& v=m[T[i]];
        if(v.empty()){can2=false; break;}
        if(!i)res[i]=v[0];
        else{
             auto itr = upper_bound(v.begin(),v.end(),res[i-1]);
             if(itr==v.end())res[i]=v[0];
             else res[i]=*itr;
        }
    }
    if(can2){
        int x=0;
        for(int i=1;i<T.size();i++)if(res[i-1]>=res[i])x++;
        cout << x*S.size()+*(res.end()-1)+1 << endl;
    } 
    else cout << -1 << endl;
    

    return 0;
}


Measured memory_bytes: 2504
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
char s[100005];
int dp[100005][13]; //dp[i][j]表示到第i个字符为止，除以13余j(j表示的是到i-1为止模13余j)有多少种情况
// 难在找出状态转移方程
int main()
{
   // cout<<mod<<'\n';
    
    scanf("%s", s + 1);
    int n = strlen(s + 1);
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++)
    {
        if (s[i] != '?')
        {
            s[i] -= '0';
            for (int j = 0; j < 13; j++)
            {
                dp[i][(j * 10 + s[i]) % 13] = (dp[i][(j * 10 + s[i]) % 13] + dp[i - 1][j]) % mod;
            }
        }
        else
        {
            for (int k = 0; k < 10; k++)
            {
                for (int j = 0; j < 13; j++)
                {
                    dp[i][(j * 10 + k) % 13] = (dp[i][(j * 10 + k) % 13] + dp[i - 1][j]) % mod;
                }
            }
        }
    }
    printf("%d\n", dp[n][5]);
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong N;
  vector<llong> A;
  set<llong> s;

  cin >> N;
  A.resize(N);
  for (auto &in: A) {
    cin >> in;
    s.insert(in);
  }

  cout << (s.size() == N ? "YES": "NO") << endl;

  return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) rep2(i,0,n)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
ll x,k,d;
int main()
{
	cin>>x>>k>>d;
	x=abs(x);
	if(x/d>=k) re(abs(x-k*d))
	k-=x/d;
	if(k%2==0) re(abs(x%d))
	re(abs(d-x%d))
	return 0;}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long lol;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{0};
    lol n, a, b; cin >> n >> a >> b;
    lol k = a + b;
    lol k2 = n%k;
    lol k3 = min(k2, a);
    result = (n/k)*a + k3;

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3556
#include<iostream>
#include<string>
#include <bits/stdc++.h>
#include<vector>
#include <algorithm>
#include <functional>
#include<stdio.h>
using namespace std;

int main(){
  long int x;
  cin >> x;
  int i,j;
  for(i=-200;i<=200;i++){
    for(j=-200;j<=200;j++){
      if(pow(i,5)-pow(j,5) == x){
        cout << i << " " << j << endl;
        goto OUT;
      }

    }

  }
  OUT:
  return 0;

}


Measured memory_bytes: 4096
#include <iostream>

using namespace std;

int main(){

    int i, num, reverse, count = 0;
    int A, B;
    cin >> A >> B;

    for(i = A; i <= B; i++){
        reverse = 0;
        num = i;
        while(num){
            reverse *= 10;
            reverse += num % 10;
            num /= 10;
        }
        if(reverse == i) count++;
    }

    cout << count << endl;

    return 0;
}

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

struct StNode
{
  StNode* m_poParnt;
  StNode* m_poLeft;
  StNode* m_poRigt;
  int m_nKey;

  StNode(int nNo) :
    m_poParnt(nullptr), m_poLeft(nullptr), m_poRigt(nullptr), m_nKey(nNo)
  { }
};

void fnInsert(StNode*& rpoRoot, StNode* poNewMe)
{
  StNode*  poParnt = nullptr;
  StNode** ppoNode = &rpoRoot;

  while (*ppoNode)
  {
    poParnt = *ppoNode;
    if (poNewMe->m_nKey < poParnt->m_nKey)
      ppoNode = &poParnt->m_poLeft;
    else
      ppoNode = &poParnt->m_poRigt;
  }
  poNewMe->m_poParnt = poParnt;
  *ppoNode = poNewMe;
}

StNode* fnFind(StNode* poRoot, int nNo)
{
  StNode* poNode = poRoot;
  while (poNode)
    if (nNo == poNode->m_nKey)
      return poNode;
    else if (nNo < poNode->m_nKey)
      poNode = poNode->m_poLeft;
    else
      poNode = poNode->m_poRigt;

  return nullptr;
}

void fnInOrder(StNode* poNode)
{
  if (!poNode)  return;

  fnInOrder(poNode->m_poLeft);
  cout << " " << poNode->m_nKey;
  fnInOrder(poNode->m_poRigt);
}

void fnPreOrder(StNode* poNode)
{
  if (!poNode)  return;

  cout << " " << poNode->m_nKey;
  fnPreOrder(poNode->m_poLeft);
  fnPreOrder(poNode->m_poRigt);
}

void fnBinSchTree(StNode*& rpoRoot)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  for (int i = 0; i < nMaxSiz; ++i)
  {
    string sCmd;
    cin >> sCmd;
    if (sCmd[0] == 'i')
    {
      int nNo;
      cin >> nNo;
      StNode* poNewNod = new StNode(nNo);
      fnInsert(rpoRoot, poNewNod);
    }
    if (sCmd[0] == 'f')
    {
      int nNo;
      cin >> nNo;
      if (fnFind(rpoRoot, nNo))
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
    if (sCmd[0] == 'p')
    {
      fnInOrder(rpoRoot);
      cout << endl;
      fnPreOrder(rpoRoot);
      cout << endl;
    }
  }
}

void fnPstOrder(StNode* poNode)
{
  if (!poNode)  return;

  fnPstOrder(poNode->m_poLeft);
  fnPstOrder(poNode->m_poRigt);
  delete poNode;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  StNode* poRoot = nullptr;

  fnBinSchTree(poRoot);
//fnPstOrder(poRoot);
  return 0;
}

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

int main() { 
  
  long long A , B ;
  cin >> A >> B;
  int i ;
  i = 100000 ;
  long N ;
  N = A*B ;
  
  while (i > 0){
    if ( A % i == 0 && B % i == 0 ){
      N /= i ;
      A /= i ;
      B /= i ;

    }
    i-- ;
  }
  cout << N << endl;
}

Measured memory_bytes: 256
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <queue>

#define MAXCHAR 255
#define ll long long

using namespace std;
const ll dividend = 1000000007;
const ll limit = pow(10, 18);

ll funcComb(int n, int k) 
{
	ll output = 1;
	int sum = n + k;
	vector<int> dividends;
	for (int i = 0; i < k; i++)
	{
		dividends.push_back(k - i);
	}
	for (int i = 0; i < k; i++)
	{
		output *= sum - i;
		for (auto it = dividends.begin(); it != dividends.end(); it++)
		{
			if (*it == 0)
				continue;
			if (output % *it == 0)
			{
				output /= *it;
				*it = 0;
			}
		}
		if (output > dividend)
		{
			output %= dividend;
		}
	}

	return output;
}

vector<bool> outputs;

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

	string output;
	for (int i = 0; i < 3; i++)
	{
		output += input[i];
	}
	cout << output << endl;

	return 0;

}

Measured memory_bytes: 3604