akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<string> split(const string &s, char delim){
	vector<string> ret;
	stringstream ss(s);
	string x;
	while(getline(ss, x, delim)) if(!x.empty()) ret.push_back(x);
	return ret;
};

bool f(string s){
	while(s.front() == '(') s = s.substr(1);
	while(s.back() == ')') s.pop_back();
	auto s1 = split(s, '&');
	bool check[256][2] = { 0 };
	for(auto t : s1){
		int j = 0;
		if(t.size() == 2) j = 1;
		if(check[t.back()][1 - j]) return false;
		check[t.back()][j] = 1;
	}
	return true;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	string s;
	while(cin >> s, s != "#"){
		auto s1 = split(s, '|');
		bool ok = false;
		for(auto v : s1){
			if(f(v)){
				ok = true;
				break;
			}
		}
		if(ok) cout << "yes" << endl;
		else cout << "no" << endl;
	}
}

Measured memory_bytes: 3176
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long

int n;
int a[101];

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

  int sum=0;
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(i%2==0 && a[i]%2==1) sum++;}

  
  
  
  
  printf("%d\n",sum);
  
  return 0;
}


Measured memory_bytes: 1736
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace atcoder_問題
{
    class Program
    {
        static void Main(string[] args)
        {
            int a=Convert.ToInt32(Console.ReadLine());
            int b = Convert.ToInt32(Console.ReadLine());
            int c = Convert.ToInt32(Console.ReadLine());
            int d = Convert.ToInt32(Console.ReadLine());
            int e = Convert.ToInt32(Console.ReadLine());
            int f = Convert.ToInt32(Console.ReadLine());
            if (e - a <= f)
            {
                Console.WriteLine("Yay!");
            }
            else
            {
                Console.WriteLine(":(");
            }
            Console.Read();
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int p[3], sum;
	while (cin>>p[0]>>p[1]>>p[2])
	{
		sort(p, p + 3);
		sum = p[0] + p[1] + p[2];
		cout << sum - p[2] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;
type I = usize;

fn main() {
    input!{
      n: usize,
      k: usize,
      s: chars,
    }
    let mut sums = vec![];
    let mut cnt = 0;
    for i in 0..n {
        if i > 0 && s[i] != s[i-1] {
            sums.push((cnt, s[i-1]));
            cnt = 0;
        }
        cnt += 1;
    }
    sums.push((cnt, s[n-1]));

    let n = sums.len();
    let mut acm = vec![0; n+1];
    for i in 0..n {
        acm[i+1] = acm[i] + sums[i].0;
    }
    let mut ans = 0;
    for l in 0..n {
        let mut r;
        if sums[l].1 == '1' {
            r  = l+2*k;
        } else {
            r  = l+2*k-1;
        }
        r = min(r, n-1);
        ans = max(acm[r+1] - acm[l], ans);
    }
    println!("{}", ans);
}


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

ll a[40]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
	ll k;
	cin>>k;
	k--;
	cout<<a[k];
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long dp[100][100],sum[100][100],a[100];
int n,l,r;
int main()
{
	cin>>n>>l>>r;
	for (int i=0;i<=n;i++)
	{
		sum[0][i]=0;
		sum[i][0]=1;
		sum[i][i]=1;
	}
	memset(dp,-1,sizeof(dp));
	dp[0][0]=0;
	for (int i=1;i<=n;i++)
		cin>>a[i];
	for (int i=1;i<=n;i++)
	{
		dp[i][0]=0;
		for (int j=1;j<=i&&j<=r;j++)
		{
			long long x=dp[i-1][j],y=dp[i-1][j-1]+a[i];
			if (x==y)
			{
				dp[i][j]=x;
				sum[i][j]=sum[i-1][j]+sum[i-1][j-1];
			}
			else if(x>y)
			{
				dp[i][j]=x;
				sum[i][j]=sum[i-1][j];
			}
			else
			{
				dp[i][j]=y;
				sum[i][j]=sum[i-1][j-1];
			}
		}
	}
	int pos=0;
	long long k=0;
	for (int i=l;i<=r&&i<=n;i++)
	{
		if(pos==0)
	     {
             pos=i;
             k=sum[n][i];
         }
         else if(dp[n][i]*pos>dp[n][pos]*i)
         {
            pos=i;
            k=sum[n][i];
         }
         else if(dp[n][i]*pos==dp[n][pos]*i)
         {
            k+=sum[n][i];
         }
	}
	printf("%.6f\n",dp[n][pos]*1.0/pos*1.0);
	cout<<k;
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}
		long answer = 0;
		long xor = a[0];
		long sum = a[0];
		int l = 0, r = 0;
		while (l < n) {
			while (r + 1 < n && (xor ^ a[r + 1]) == sum + a[r + 1]) {
				r++;
				xor ^= a[r];
				sum += a[r];
			}
			answer += r - l + 1;
			xor ^= a[l];
			sum -= a[l];
			l++;
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 82004
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e16;
typedef array<int, 3>arr3;
void die(string s) { cout << s << endl; exit(0); }
int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 };


void solve() {
	vector<int>v(4);
	REP(i, 4)cin >> v[i];
	VSORT(v);
	if (v[0] == 1 && v[1] == 4 && v[2] == 7 && v[3] == 9)print("YES");
	else print("NO");
}


signed main() {
	solve();
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  string s;
  cin >> s;
  int ans = 0;
  int n = s.size();
  int cnt = 0;
  int i = 0;
  while(i < n){
    if(s.at(i) == 'R'){
      cnt++;
      if(ans < cnt) ans = cnt;
    }
    else{
      if(ans < cnt ) ans = cnt;
      cnt = 0;
    }
    ++i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl '\n'
#define PI acos(-1)
typedef long long ll;
//	Table is the complete reverse of dp
//	Always think of the pattern (LCM, GCD)
//	Be careful of unsigned
//	double epsilon = FLT_EPSILON;
//	Think of a solution that gets TLE and optimize it

int main()
{
    cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false);
    int n, k, *x, **dp;
    const int MOD = 1e9 + 7;
    cin >> n >> k;
    x = new int[n];
    dp = new int *[n + 1];
    for(int i = 0; i < n; i++)
    {
    	cin >> x[i];
    	dp[i] = new int[k + 1];
    	dp[i][0] = 1;
    }
    dp[n] = new int[k + 1];
    for(int i = 0; i <= k; i++)
    	dp[n][i] = 1;
    for(int i = n - 1; i >= 0; i--)
    	for(int rem = 1; rem <= k; rem++)
    	{
    		int &ret = dp[i][rem];
    		ret = dp[i][rem - 1];
    		if(x[i] < rem)
    			ret += ((dp[i + 1][rem] - dp[i + 1][rem - x[i] - 1]) % MOD + MOD) % MOD;
    		else
    			ret += dp[i + 1][rem];
    		if(ret >= MOD)
    			ret -= MOD;
    	}
    cout << ((dp[0][k] - dp[0][k - 1]) % MOD + MOD) % MOD;
}


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

using namespace std;

int main()
{
    long long cnt[10010];
    long long ans = 0;
    string s;
    int n,p;
    
    cin >> n >> p >> s;
    
    if(p == 2 || p == 5)
    {
        for(int i = 0;i < n;i++) 
            if((s[i] - '0') % p == 0) 
                ans += i + 1;
    }
    else
    {
        cnt[0] = 1;
        long long cur = 0,t = 1;
        for(int i = n - 1;i >= 0;i--)
        {
            cur = (cur + (s[i] - '0')*t) % p;
            t = t*10%p;
            ans += cnt[cur]++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 644
/*
ID: htc9811
LANG: C++
TASK: 
*/

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<cstdio>
#include<cstring>
#include<queue>
#include<deque>
#include<stack>
#include<ctime>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<utility>
#include<cctype>
#include<bitset>
#include<list>
using namespace std;

const int N=2e5+5;
int n;
int a[N];
long long ans;

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",a+i);
	for(int i=0;i<n;i++) if(a[i]>i){
		puts("-1");
		return 0;
	}
	for(int i=1;i<n;i++){
		if(a[i]==a[i-1]+1) ans++;
		else if(a[i]>a[i-1]+1){
			puts("-1");
			return 0;
		}
		else ans+=a[i];
	}
	printf("%lld\n",ans);
	return 0;
}

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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N;
  cin >> N;
  vector<int> a(N);
  int ans = INF;
  rep(i, N)
    cin >> a[i];
  for (int i = -100; i <= 100; i++) {
    int sum = 0;
    rep(j, N) {
      sum += (a[j]-i)*(a[j]-i);
    }
    ans = min(sum, ans);
  }
  cout << ans << endl;
}


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

#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<ll>
#define all(x) x.begin() , x.end()

using namespace std;
void OJ();

const int MAX = 1e5 + 9;

ll n;
set<ll> s; vector<ll> st;
map<ll,set<int>> mp;
vector<pair<ll,ll>> vec;
ll dp[MAX];

ll go( int i ){
    if ( i >= n ){
        return 0;
    }
    if ( i+1 == n ){
        return 1;
    }

    ll& ret = dp[i];
    if ( ~ret ){
        return ret;
    }

    ret = 0;
    ret = max( ret , go(i+1) );

    int r = st[i] + *mp[st[i]].begin();
    int idx = lower_bound( all(st) , r ) - st.begin();
    if ( idx < st.size() ){
        ret = max( ret , go(idx) + 1 );
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);// OJ();

    cin >> n; vec.resize(n); int idx = 0;
    for ( auto& i : vec ){
        cin >> i.F >> i.S;
    }
    sort( all(vec) );
    for ( auto& i : vec ){
        s.insert(i.F - i.S);
        mp[ i.F - i.S ].insert( 2*i.S );
        idx++;
    }

    for ( ll i : s ) st.pb(i);
    memset(dp , -1 , sizeof dp);
    cout << go(0);
    return  0;
}

void OJ(){
#ifndef ONLINE_JUDGE
       freopen( "inp.c"         , "r" , stdin  );
       //freopen( "OutPut.txt"   , "w" , stdout );
#endif // ONLINE_JUDGE
}
ll binEXP( ll x , ll pw , ll MOD )
{ ll res=1; while(pw>0){ pw%2 ? res *= x : 0; x *= x; x%=MOD; pw /= 2; res%= MOD; } return res%=MOD; }


Measured memory_bytes: 28532
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long code(long a, long b);

long n;
long a[1005][1005];
long vis[1005];
std::set<long> waitList;
std::priority_queue<long> dayAdd[1000005];
long matchCnt = 0;

int main(){
    scanf("%ld", &n);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n-1; j++){
            scanf("%ld", &a[i][j]);
            a[i][j]--;
        }
    }
    for(int i = 0; i < n; i++){
        dayAdd[1].push(code(i, a[i][0]));
        vis[i]++;
    }
    for(long ans = 1; ans < 1000005; ans++){
        if(dayAdd[ans].empty()){
            if(matchCnt == n*(n-1)/2){
                printf("%ld\n", ans-1);
                return 0;
            }else{
                printf("-1\n");
                return 0;
            }
        }
        while(!dayAdd[ans].empty()){
            long chal = dayAdd[ans].top();
            dayAdd[ans].pop();
            if(waitList.count(chal) == 0){
                waitList.insert(chal);
            }else{
                matchCnt++;
                waitList.erase(chal);
                long x = chal/n;
                long y = chal%n;
                if(vis[x] < n-1){
                    dayAdd[ans+1].push(code(x, a[x][vis[x]]));
                    vis[x]++;
                }
                if(vis[y] < n-1){
                    dayAdd[ans+1].push(code(y, a[y][vis[y]]));
                    vis[y]++;
                }
            }
        }
    }
}

long code(long a, long b){
    return std::min(a, b)*n + std::max(a, b);
}


Measured memory_bytes: 55040
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   for(int i=0;i<(n);++i)
#define SORT(c)    sort((c).begin(),(c).end())
const double EPS = 1e-10;//sample:if((double)>=(double)+EPS)
#define CLR(a) memset((&a), 0 ,sizeof(a))//clear memory
#define dump(x)  cerr << #x << " = " << (x) << endl;//debug
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//cin,cout release
//std::cin.tie(0);
//ios::sync_with_stdio(false);
void aprint(int A[], int n){
  for(int i=0;i<n-1;i++)printf("%d ",A[i]);
  printf("%d\n",A[n-1]);
}

void insertion_sort(int A[], int n){
  for(int i = 0;i < n;i++){
    int temp = A[i];
    int j = i - 1;
    while(j >= 0 && A[j] > temp){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = temp;
    aprint(A,n);
  }

}

int main(void){
  int n;
  cin>>n;
  int arr[100];
  for(int i=0;i<n;i++) cin>>arr[i];
  insertion_sort(arr,n);
  return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0) return 0;
		for(int i=0;i<n;i++){
			int a,b,c;
			cin>>a>>b>>c;
			if(a==100||b==100||c==100) cout<<"A"<<endl;
			else if(a+b>=180||a+b+c>=240) cout<<"A"<<endl;
			else if(a+b+c>=210) cout<<"B"<<endl;
			else if(a+b+c>=150&&(a>=80||b>=80)) cout<<"B"<<endl;
			else cout<<"C"<<endl;
		}
	}
}

Measured memory_bytes: 3068
import bisect

n = int(input())
xyu_180_1 = {}
xyu_180_2 = {}
xyu_90_1 = {}
xyu_90_2 = {}
xyu_90_3 = {}
xyu_90_4 = {}
for i in range(n):
    x, y, u = input().split()
    x = int(x)
    y = int(y)
    if u == "U":
        xyu_180_2.setdefault(x, {"U":[], "D":[]})
        xyu_180_2[x][u].append(y)
        xyu_90_1.setdefault(x + y, {"R":[], "U":[]})
        xyu_90_1[x + y][u].append(x - y)
        xyu_90_2.setdefault(x - y, {"U":[], "L":[]})
        xyu_90_2[x - y][u].append(x + y)
    elif u == "R":
        xyu_180_1.setdefault(y, {"R":[], "L":[]})
        xyu_180_1[y][u].append(x)
        xyu_90_1.setdefault(x + y, {"R":[], "U":[]})
        xyu_90_1[x + y][u].append(x - y)
        xyu_90_4.setdefault(x - y, {"D":[], "R":[]})
        xyu_90_4[x - y][u].append(x + y)
    elif u == "D":
        xyu_180_2.setdefault(x, {"U":[], "D":[]})
        xyu_180_2[x][u].append(y)
        xyu_90_3.setdefault(x + y, {"L":[], "D":[]})
        xyu_90_3[x + y][u].append(x - y)
        xyu_90_4.setdefault(x - y, {"D":[], "R":[]})
        xyu_90_4[x - y][u].append(x + y)
    elif u == "L":
        xyu_180_1.setdefault(y, {"R":[], "L":[]})
        xyu_180_1[y][u].append(x)
        xyu_90_2.setdefault(x - y, {"U":[], "L":[]})
        xyu_90_2[x - y][u].append(x + y)
        xyu_90_3.setdefault(x + y, {"D":[], "L":[]})
        xyu_90_3[x + y][u].append(x - y)
time = float("inf")
for i in xyu_180_1.values():
    if i["R"] and i["L"]:
        num = i["L"]
        num.sort()
        for j in i["R"]:
            num2 = bisect.bisect(num, j)
            if num2 != len(num):
                temp = (num[num2] - j) * 5
                time = min(time, temp)
for i in xyu_180_2.values():
    if i["U"] and i["D"]:
        num = i["D"]
        num.sort()
        for j in i["U"]:
            num2 = bisect.bisect(num, j)
            if num2 != len(num):
                temp = (num[num2] - j) * 5
                time = min(time, temp)
for i in xyu_90_1.values():
    if i["R"] and i["U"]:
        num = i["U"]
        num.sort()
        for j in i["R"]:
            num2 = bisect.bisect(num, j)
            if num2 != len(num):
                temp = (num[num2] - j) * 5
                time = min(time, temp)
for i in xyu_90_2.values():
    if i["U"] and i["L"]:
        num = i["L"]
        num.sort()
        for j in i["U"]:
            num2 = bisect.bisect(num, j)
            if num2 != len(num):
                temp = (num[num2] - j) * 5
                time = min(time, temp)
for i in xyu_90_3.values():
    if i["D"] and i["L"]:
        num = i["L"]
        num.sort()
        for j in i["D"]:
            num2 = bisect.bisect(num, j)
            if num2 != len(num):
                temp = (num[num2] - j) * 5
                time = min(time, temp)
for i in xyu_90_4.values():
    if i["R"] and i["D"]:
        num = i["D"]
        num.sort()
        for j in i["R"]:
            num2 = bisect.bisect(num, j)
            if num2 != len(num):
                temp = (num[num2] - j) * 5
                time = min(time, temp)
if time == float("inf"):
    print("SAFE")
else:
    print(time)

Measured memory_bytes: 372804
n = int(input())
a_n = [int(x) for x in input().split()]

a_min = 1
cnt = 0
for a in a_n:
    if a == a_min:
        a_min = a + 1
    else:
        cnt += 1

if cnt == len(a_n):
    print(-1)
else:
    print(cnt)

Measured memory_bytes: 26268
#include <cstdio>
#include <vector>
#define ll long long
const ll maxn = 1e5+5;
struct edge{
    ll to, w;
    edge(ll x, ll y):to(x), w(y){}
    edge(){}
}e[maxn << 1];
ll deep[maxn];
ll N, cnt;
std::vector<edge> to[maxn];
void add_edge(ll x, ll y, ll z) {
    to[x].push_back(edge(y,z));
} 
void add(ll x, ll y, ll z) {
    add_edge(x, y, z);
    add_edge(y, x, z);
}
void dfs(ll x, ll fa) {
    for(ll i = 0; i < to[x].size(); i++) {
	if(to[x][i].to != fa) {
	    deep[to[x][i].to] = deep[x] + to[x][i].w;
	    dfs(to[x][i].to, x);
	}
    }
}
ll M, K;
int main() {
#ifdef orz
    freopen("input", "r", stdin);
#endif
    scanf("%lld", &N);
    for(ll i = 1; i < N; i++) {
	ll x, y, z;
	scanf("%lld %lld %lld", &x, &y, &z);
	add(x, y, z);
    }	
    scanf("%lld %lld", &M, &K);
    dfs(K, 0);
    for(ll i = 1; i <= M; i++) {
	ll x, y;
	scanf("%lld %lld", &x, &y);
	printf("%lld\n", deep[x] + deep[y]);
    }	
    return 0;
}


Measured memory_bytes: 15232
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define pi pair<int,int>
#define fi first
#define se second

#define FOR(var, to)          for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)

#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)

#define MOD 1000000007
#define INF (1 << 30)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

static inline s64 rs64() {
  s64 a;
  scanf("%" SCNd64, &a);
  return a;
}

static inline void wi(int a) {
  printf("%d", a);
}

static inline void wu64(u64 a) {
  printf("%" PRIu64, a);
}

static inline void ws64(s64 a) {
  printf("%" PRId64, a);
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
  string s;
  cin >> s;
  int k = ri();
  vector<string> subs;
  for(int i = 0; i < (int)s.size(); i++) {
      for (int j = 1; i+j <= (int)s.size() && j <= k; j++) {
          // cout << s.substr(i,j) << endl;
          subs.push_back(s.substr(i,j));
      }
  }
  sort(subs.begin(), subs.end());
  // cout << subs.size() << endl;
  FROMTO(i,0,subs.size()-2) {
      if (subs[i] == subs[i+1]) subs[i] = "";
  }
  int i = 0;
  int ii = 0;
  while(i<k) {
      if (subs[ii] != "") i++;
      ii++;
  }
  cout << subs[--ii] << endl;
  return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	ll n, k;
	cin >> n >> k;
	
	if( n % k == 0 ) {
		cout << 0 << endl;
	} else {
		cout << min(n % k, abs(k - n % k)) << endl;
	}
	
	return 0;
}


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

#define int long long int
#define fi first
#define so second
#define ps push_back
#define ld long double
#define mod 1000000007

signed main()
{
    int n,i,ct=0;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++) cin>>a[i];
    for(i=n-2;i>=0;i--)
    {
        if(a[i]>a[i+1]+1) break;
        if(a[i]==a[i+1]+1) a[i]--;
    }
    if(i<0) cout<<"Yes";
    else cout<<"No";

}


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

struct card{
    char suit;
    int num;
};

void print_card (vector<card> A){
    for(auto iter_A = A.begin(); iter_A != (A.end()-1); iter_A++){
        cout << (*iter_A).suit << (*iter_A).num <<  " ";
    }
    cout << (*(A.end()-1)).suit << (*(A.end()-1)).num << "\n";
}

vector<card> & bubbleSort(vector<card> &A, int N){

    bool flag = true;
    int i = 0;
    int count = 0;

    while(flag){
        flag = false;
        for (int j = N-1; j > i; --j){
            if(A[j].num < A[j-1].num){
                count++;
                swap(A[j], A[j-1]);
                flag=true;
            }
        }
        i++;
    }
    print_card(A);
    return A;
}

vector<card> & selectionSort(vector<card> &A, int N){

    int count = 0;

    int min_idx = 0;
    for (int i = 0; i < N; i++){
        min_idx = i;
        for (int j = i; j < N; j++){
            if(A[min_idx].num > A[j].num){
                min_idx = j;
            }
        }
        if(i != min_idx){
            swap(A[min_idx], A[i]);
            count++;
        }
    }
    print_card(A);
    return A;
}


// main
int main(){
   // 入力
    int N;
    scanf("%d%*c", &N);
    vector<card> b_card(N), s_card(N);

    for (int i = 0; i < N; ++i){
        scanf("%c%d%*c", &b_card[i].suit, &b_card[i].num);
        s_card[i] = b_card[i];
    }

    bubbleSort(b_card, N);
    cout << "Stable" << "\n";
    selectionSort(s_card, N);
    bool flag = true;
    for(auto b_itr = b_card.begin(), s_itr = s_card.begin(); b_itr!=b_card.end(); ++b_itr, ++s_itr){
        if((*b_itr).suit != (*s_itr).suit){
            cout << "Not stable" << "\n";
            flag = false;
            break;
        }
    }
    if (flag){
        cout << "Stable" << "\n";
    }

    return 0;
}





Measured memory_bytes: 3220
fun readInts() = readLine()!!.split(' ').map(String::toInt)

fun <T> Iterable<T>.groupingCount(): Map<T, Int> {
    val map = mutableMapOf<T, Int>()
    for (element in this) {
        map[element] = map.getOrElse(element) { 0 } + 1
    }
    return map
}

fun main(args: Array<String>) {
    readLine()
    val aa = readInts().groupingCount()
    var ans = 0
    for ((e, cnt) in aa) {
        if (e < cnt) {
            ans += cnt - e
        } else if (e > cnt) {
            ans += cnt
        }
    }
    println(ans)
}


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

typedef long long i64;
#define put(n) cout<<(n)<<"\n"
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);(i)++)
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);(i)--)
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

int main(){
    int ans = 0;

    int N,H;
    cin>>N>>H;


    vector<int> B(N+1,-1);
    int max_a = -1;
    FOR(i,0,N){
        int a;
        cin>>a>>B[i];
        max_a = max(a,max_a);
    }
   
    sort(rall(B));

    int damage = 0;
    for(int i=0; damage < H;){
        if(B[i] > max_a){
            damage += B[i];
            ++i;
            ++ans;
        }
        else{
            damage += max_a;
            ++ans;
        }
    }
    
    put(ans);
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int N, M, K;
vector<ll> A, B;

void input(void){
	cin >> N >> M >> K;
	A.resize(N);
	B.resize(M);
	for (auto& ai : A)
		cin >> ai;
	for (auto& bi : B)
		cin >> bi;
}

vector<ll> acc_A, acc_B;

void build(void){
	acc_A.resize(N + 1, 0);
	for (int i = 1; i <= N; ++i)
		acc_A[i] = acc_A[i - 1] + A[i - 1];
	acc_B.resize(M + 1, 0);
	for (int i = 1; i <= M; ++i)
		acc_B[i] = acc_B[i - 1] + B[i - 1];
}

// x冊の本を読むのに必要な分数
ll need_time(int x){
	ll res = (1LL << 60); // INF
	for (int i = 0; i <= x; ++i){
		if (i > N) break;
		if ((x - i) > M) continue;
		ll tmp = acc_A[i] + acc_B[x - i];
		res = min(res, tmp);
	}
	return res;
}

int main(void){
	input(); build();
	int ok = 0, ng = 400001;
	while (ng - ok > 1){
		int mid = (ok + ng) / 2;
		ll need = need_time(mid);
		if (need <= K) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
	return 0;
}

Measured memory_bytes: 9572
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

#define MAX_N 17
int t[MAX_N][MAX_N] = {};
int dp[MAX_N][1 << MAX_N] = {};
int N;
int dfs(int i, int mask) {
	dump(i);
	dump(bitset<MAX_N>(mask));
	if (dp[i][mask] != INF) {
		dump(dp[i][mask]);
		return dp[i][mask];
	}
	rep(j, 0, N) {
		if (mask&(1 << j)) {
			int add = t[j][0];
			rep(k, 0, N) {
				if (j == k)continue;
				if (mask&(1 << k))
					add = min(add, t[j][k + 1]);
			}
			dp[i][mask] = min(dfs(i - 1, mask ^ (1 << j)) + add, dp[i][mask]);
		}
	}
	dump(dp[i][mask]);
	return dp[i][mask];
}

signed main() {
	for (; cin >> N&&N;) {
		memset(dp, 0x3f, sizeof(dp));
		rep(i, 0, N) rep(j, 0, N + 1) cin >> t[i][j];

		dp[0][0] = 0;
		cout << dfs(N, (1 << N) - 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 11800
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
ll gcd(ll a,ll b){
	if(!b) re a;
	else re gcd(b,a%b);
}
ll lcm(ll a,ll b){
	re a/gcd(a,b)*b;
}
ll ans=1;
signed main(){
	ios_base::sync_with_stdio(0);
	int n;
	cin>>n;
	while(n--){
		ll t;
		cin>>t;
		ans=lcm(ans,t);
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 3592
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  if (n <= 9) {
    cout << n << '\n';
    return 0;
  }
  ll ans = 0;
  string n_str = to_string(n), subst = n_str.substr(1);
  subst.pop_back();
  int subst_val = (subst.empty() ? 0 : stoi(subst));
  int n_len = n_str.length();
  vector<ll> ten(10, 1);
  FOR(i, 1, 10) ten[i] = ten[i - 1] * 10;
  FOR(i, 1, n + 1) {
    string s = to_string(i);
    int fr = s.back(), ba = s.front();
    if (fr == '0') continue;
    string init = "";
    if (fr == ba) {
      init += fr;
    } else {
      init += fr;
      init += ba;
    }
    if (stoi(init) > n) continue;
    FOR(len, init.length(), n_len) ans += ten[max(len - 2, 0)];
    string t = "";
    t += fr;
    while (t.length() + 1 < n_len) t += '0';
    t += ba;
    if (stoi(t) > n) continue;
    if (n_str.front() > fr) {
      ans += ten[t.length() - 2];
    } else if (t.length() == 2) {
      ++ans;
    } else {
      if (n_str.back() >= ba) {
        ans += subst_val + 1;
      } else {
        ans += subst_val;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


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

using namespace std;
 
template <class T> using V = vector<T>;

using ll = long long;
using vll = V<ll>;

 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)

const int MOD = 1000000007;
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
    cin>>n;
  vll A(1100,1);
  FOR(i,2,n+1){
    ll now=i;
    ll up=sqrt(now)+1;
    FOR(j,2,up){
      while(now%j==0){
        now/=j;
        A[j]++;
      }
    }
    if(now!=1){
      A[now]++;
    }
  }

  ll ans=1;
  FOR(i,2,n+1){
    ans*=A[i];
    ans%=MOD;
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
// I can

#include<bits/stdc++.h>
using namespace std;

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const ll maxn=100000,mod=1e9+7;

int n,a[maxn];
ll memo[maxn][2];

ll go(int pos,int par){
    if(pos==n) return 0;

    if(memo[pos][par]!=-1) return memo[pos][par];
    ll ans;
    if(par){
        ll val=-a[pos];
        if(pos==n-1) ans=val+go(pos+1,0);
        else ans=max(val+go(pos+1,0),a[pos]+go(pos+1,1));
    }
    else{
        if(pos==n-1) ans=a[pos]+go(pos+1,0);
        else  ans=max(a[pos]+go(pos+1,0),-a[pos]+go(pos+1,1));
    }
    return memo[pos][par]=ans;
}

int main(){
sync

    memset(memo,-1,sizeof(memo));
    cin>>n;
    forn(i,n) cin>>a[i];
    cout<<go(0,0);
    return 0;
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define mod 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
string s[110];
lol mem[120][120];
lol tan(int x,int y,bool hen){
  if((x<0)||(y<0)) return mod;
  if(mem[x][y]!=-1) return mem[x][y];
  bool r=false;
  if(s[x][y]=='#') r=true;
  if(x==0&&y==0) return mem[0][0]=((r&&(!hen))?1:0);
  lol ans=tan(x-1,y,r);
  ans=min(ans,tan(x,y-1,r));
  if(r&&(!hen)){
    ans++;
  }
  mem[x][y]=ans;
  return ans;
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol n,a,b,c,d;
  int h,w;
  cin >>h>>w;
  for(int i=0;i<h;i++){
    cin >>s[i];
  }
  memset(mem,mod,sizeof(mem));
  if(s[0][0]=='.') mem[0][0]=0;
  else mem[0][0]=1;

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      lol r=mem[i][j];
      if((i+1)!=h){
        if(s[i+1][j]=='#'){
          if(s[i][j]=='#') mem[i+1][j]=min(mem[i+1][j],r);
          else mem[i+1][j]=min(mem[i+1][j],r+1);
        }else mem[i+1][j]=min(mem[i+1][j],r);
      }
      if((j+1)!=w){
        if(s[i][j+1]=='#'){
          if(s[i][j]=='#') mem[i][j+1]=min(mem[i][j+1],r);
          else mem[i][j+1]=min(mem[i][j+1],r+1);
        }else mem[i][j+1]=min(mem[i][j+1],r);
      }
    }
  }
  cout <<mem[h-1][w-1]<<'\n';
      
  return (0);
}


Measured memory_bytes: 384
package main

import (
    "fmt"
)

func main() {
    var (
        n, count int
        list []int
    )
    fmt.Scan(&n)
    list = make([]int, n)
    for i:=0; i < n; i++ {
        fmt.Scan(&list[i])
    }
    count = bubble_sort(list, n)
    list_print(list)
    fmt.Println(count)
    
}

func bubble_sort(a []int, n int) (count int){
    var (
        flag bool = true
    )
    count = 0
    for flag {
        flag = false
        for i := n - 1 ; i > 0 ; i-- {
            if a[i] < a[i-1] {
                a[i], a[i-1] = a[i-1], a[i]
                flag = true
                count++
            }
        }
    }
    return 
}

func list_print(list []int) {
    var i int
    for i=0; i<len(list); i++ {
        if i == 0 {
            fmt.Print(list[i])
        } else {
            fmt.Print(" ", list[i])
        }
    }
    fmt.Print("\n")
}



Measured memory_bytes: 1148
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    String a =sc.next();
    int A =a.length();
    String D [] =a.split("",0);
    String b =sc.next();
    String E[] =b.split("",0);
    int B =b.length();
    String c =sc.next();
    String F[] =c.split("",0);
    if((D[A-1].equals(E[0]))&&(E[B-1].equals(F[0]))){System.out.println("YES");}
    else{System.out.println("NO");}
  }
}


Measured memory_bytes: 27048
'use strict'
function Main(input) {
	let lines = input.split("\n");
    let N = Number(lines[0])
    let out = 0
    for(let i = 0; i <= N; i ++) {
        out+= i
    }
    console.log(out)
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import java.util.Scanner;

class Main {
    static Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
        int K = in.nextInt(), S = in.nextInt();
        int sum = 0;
        for(int i = 0; i <= K; i++){
            for(int j = 0; j <= K; j++){
                if(i + j >= S - K && i + j <= S){
                    sum++;
                }
            }
        }
        System.out.println(sum);
    }

}

Measured memory_bytes: 23124
/*
AizuOnline A0089
Title
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
#define max(x,y) (((x)>(y))?(x):(y))
int hisi[100][100];
int runsum[100][100];
char buf[1000];
//
int count_comma(char * s)
{
  int cnt,i;
  for(i=0,cnt=0;i<strlen(s);i++)
    cnt += ((s[i]==',')?1:0);
  return(cnt);
}

main()
{
  int i,j,f,l,n,cnt,oldn;
  int flag;  //orikaesi
  char *p;
  j=0;cnt=0;flag=0;oldn=0;
  while(1)
    {
      fgets(buf,sizeof(buf),stdin);
      l=strlen(buf);
      //printf("L:%d ",l);
      n=count_comma(buf)+1;
      //printf("cm %d\n",n);
      if(n==1)
	cnt++;
      if(n==oldn-1)
	flag=1;
     
      //
      hisi[j][1]=atoi(strtok(buf,",\0"));
      
      for(i=2;i<=n;i++)
	{
	  hisi[j][i]=atoi(p=strtok(NULL,",\0"));

	}
      if(j==0)
      	runsum[j][1]=hisi[j][1];
      else 
	for(i=1;i<=n;i++)
	  if(flag==0)
	    runsum[j][i]=hisi[j][i]+max(runsum[j-1][i-1],runsum[j-1][i]);
	  else
	    {
	    runsum[j][i]=hisi[j][i]+max(runsum[j-1][i],runsum[j-1][i+1]);
	    //printf("*");
	    }
#ifdef DEBUG
      for(i=1;i<=n;i++)
	printf("%d ",runsum[j][i]);
      printf("\n");
#endif
      if(cnt==2)
	break;
      j++;
      oldn=n;
    }
  printf("%d\n",runsum[j][1]);
  
return(0);
}

Measured memory_bytes: 612
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;
int main(void){
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  if(s < t){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
  return 0;
}

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

using namespace std;

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

    vector<int> a;
    for (int i = 1; i <= n; ++i) {
        a.emplace_back(i);
    }

    do {
        for (int i = 0; i < n; ++i) {
            cout << (i ? " " : "") << a[i];
        }
        cout << endl;
    } while (next_permutation(a.begin(), a.end()));

    return 0;
}


Measured memory_bytes: 3164
#include <stdio.h>
 
int main(){
    int i,left, right, mid,key, ans=0,n,q,s[100000],t[50000];
    scanf("%d",&n);
    for(i=0;i<n;i++)
      scanf("%d",&s[i]);
    scanf("%d",&q);
    for(i=0;i<q;i++)
      scanf("%d",&t[i]);
    for(i=0;i<q;i++){
        key=t[i];
		 left=0;
		 right=n;
    while(left<right) {
        mid=(left+right)/2;
        if(s[mid]==key){
          ans++;
          break;
        } else if(key<s[mid])
          right=mid;
        else
          left=mid+1;
    }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 2316
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String[] sl = s.split("");
		int c = 0;
		for (int i = 0; i < sl.length; i++) {
			if (sl[i].equals("1")) {
				c += 1;
			}
		} System.out.println(c);

		}
	}

Measured memory_bytes: 25172
n, m, c = map(int, input().split())
B = list(map(int, input().split()))
A = [0] * n
for i in range(n):
    A[i] = list(map(int, input().split()))
ans = 0

for i in range(n):
    sumA = 0
    for j in range(m):
        sumA += A[i][j] * B[j]
    if sumA > -c :
        ans += 1

print(ans)

Measured memory_bytes: 3064
# import itertools
# import math

N, K = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)

mod = 10**9+7

# print(list(itertools.combinations(range(6), 3)))
# A = range(6)
# N = 6
# K = 3

# 二項係数を素数で割った余り
def combMod(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
    # fact = [-1 for _ in range(n+1)]
    # fact[0] = 1
    # fact[1] = 1
    # inv = [-1 for _ in range(n+1)]
    # inv[0] = 0
    # inv[1] = 1
    # factinv = [-1 for _ in range(n+1)]
    # factinv[0] = 1
    # factinv[1] = 1
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
p = mod
    
for i in range(2, N + 1):
    # fact[i] = ((fact[i-1] * i) % p)
    # inv[i] = ((-inv[p % i] * (p // i)) % p)
    # factinv[i] = ((factinv[i-1] * inv[i]) % p)
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)




ans = 0
for i in range(N):
    num = combMod(i, K-1, mod) % mod
    ans += num * A[i] % mod
    ans -= num * A[N-i-1] % mod
    ans %= mod

print(ans)

Measured memory_bytes: 20416
#include <cstdio>
int main() {
	int x, a, b;
	scanf("%d %d %d", &x, &a, &b);
	if(b-a <= 0) printf("delicious\n");
	else if(b-a <= x) printf("safe\n");
	else printf("dangerous\n");
	return 0;
}

Measured memory_bytes: 128
N, M, X = map(int, input().split())
CA = [list(map(int, input().split())) for i in range(N)]
ans = -1
for i in range(1 << N):
    rikai = [0]*M
    buy = 0
    ok=1
    for j in range(N):
        if (i >> j) & 1:
            for k in range(M):
                rikai[k] += CA[j-1][k+1]
            buy += CA[j-1][0]
    for a in rikai:
        if a >= X:
            continue
        else:
            ok=0
            break
    if ok==1:
        if ans == -1:
            ans = buy
        else:
            ans = min(ans, buy)
print(ans)


Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define PI 3.1415926535897932
#define MOD 1000000007;
using namespace std;
long long GCD(long long A,long long B){
  if(B==0){
    return A;
  }
  else{
    return GCD(B,A%B);
  }
}
long long LCM(long long A,long long B){
  long long g=GCD(A,B);
  return A/g*B;
}
long long num_order(long long X){
  long long ans=0;
  while(true){
    if(X==0){
      break;
    }
    else{
      X/=10;
      ans++;
    }
  }
  return ans;
}
int main() {
  
  int A,B;
  cin>>A>>B;
  
  char ans;
  
  
  if(A+B==15){
    ans='+';
  }
  else if(A*B==15){
    ans='*';
  }
  else{
    ans='x';
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3588
N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(int, input().split())) for _ in range(N)]

from itertools import permutations

colors = tuple(i for i in range(C))

table = [[0 for i in range(C)] for j in range(3)]
for color in colors:
    for col in range(N):
        for row in range(N):
            table[(col+row)%3][color]+=D[c[col][row]-1][color]
            
ans = 10**9    
for i, j, k in permutations(colors, 3):
    ans = min(ans, table[0][i]+table[1][j]+table[2][k])

print(ans)

Measured memory_bytes: 45788
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

#ifdef LOCAL  //デバッグ出力
#define dout cout
#define debug() if (true)
#else
#define dout \
  if (false) cout
#define debug() if (false)
#endif

using namespace std;
int main() {
  int a;
  cin >> a;
  cout << a*a;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdlib.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(void) {
    int n;
    cin >> n;
    
    int counts = 1;
    double tax_rate = 1.08;
    int unit_cost = 1;
    int total_cost = 0;
    
    while (unit_cost <= n) {
        total_cost = unit_cost * counts * tax_rate;
        while (total_cost <= n) {
            if (total_cost == n) {
                cout << counts << endl;
                return 0;
            }
            counts++;
            total_cost = unit_cost * counts * tax_rate;
        }
        unit_cost++;
    }
    
    cout << ":(" << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int i;
  string s;
  vector<string> l{"abc","acb","bac","bca","cab","cba"};
  cin >> s;
  for (i=0;i<6;i++) if (s==l.at(i)) break;
  if (i==6) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
/*************************************************************************
	> File Name: 1.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Blog: https://blog.csdn.net/Pig_cfbsl 
	> Created Time: 2020/6/14 20:01:11
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define LL long long
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	int x=read(),y=read(),a;
	For(i,0,x){
		a=2*i+4*(x-i);
		if(a==y){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 3636
import java.util.*;
public class Main{
    public static void main(String[] args)throws Exception{


        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt() * 100 + sc.nextInt() * 10 + sc.nextInt();

        System.out.println(a % 4 == 0? "YES":"NO");

    }
}

Measured memory_bytes: 23124