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

int main(){
    string S;
    set<char> st;
    cin >> S;
    for(int i = 0;i < 4;++i){
        st.insert(S[i]);
    }
    if(st.size() == 2 and count(S.cbegin(), S.cend(), *st.begin()) == 2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import math
a, b, x = map(int, input().split())
v = a * a * b
if v / 2 >= x:
    kakudo = 90 - math.degrees(math.atan(2*x/a/b/b))
    print(kakudo)
    
else:
    kakudo = math.degrees(math.atan(2*(v-x)/a/a/a))
    print(kakudo)

Measured memory_bytes: 3064
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    string s; cin >> s;
    int k; cin >> k;
    int n = s.size();

    vector<string> v;
    for(int i=1; i<=min(n,5); i++){
        for(int j=0; j<n-i+1; j++){
            v.push_back(s.substr(j, i));
        }
    }

    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    cout << v.at(k-1) << endl;
    return 0;
}


Measured memory_bytes: 1660
/*
n×m  の行列 A と、m×1 の列ベクトルb を読み込み、
A と b の積を出力するプログラムを作成してください。

 */

#include <stdio.h>

int main(void)
{
    int n, m;
    scanf("%d %d", &n, &m);
    int A[n][m];
    int b[m];
    int sum[n];
    int i, j;

    // prep init
    //A[n][m]
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            A[i][j] = 0;
        }
    }
    // b[m]
    for (i = 0; i < m; i++)
    {
        b[i] = 0;
    }
    // sum[n]
    for (i = 0; i < n; i++)
    {
        sum[i] = 0;
    }

    // input
    // A[n][m]
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            scanf("%d", &A[i][j]);
            // printf("A[%d][%d] = %d\n", i, j, A[i][j]);
        }
    }
    //b[m]
    for (i = 0; i < m; i++)
    {
        scanf("%d", &b[i]);
        // printf("b[%d] = %d\n", i, b[i]);
    }

    // Check the contents of array
    // for (i = 0; i < n; i++)
    // {
    //     for (j = 0; j < m; j++)
    //     {
    //         // printf("A[%d][%d] = %d\n", i, j, A[i][j]);
    //     }
    // }

    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            sum[i] = sum[i] + (A[i][j] * b[j]);
            // printf("%d sum[%d] = %d\n", i, j, sum[i]);
        }
    }

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


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

int main() {
    int x;
    cin >> x;
    for (int i = 1; i <= x; i++) {
        if (100 * i <= x && x <= 105 * i) {
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

int main(){
	ll n,k;cin>>n>>k;
	vector<pair<ll,ll>> ab(n);
	for(int i=0;i<n;i++){
		cin>>ab[i].first>>ab[i].second;
	} 
	sort(ab.begin(),ab.end());
	ll ans;
	for(int i=0;i<n;i++){
		k-=ab[i].second;
		if(k<=0) {
			ans=ab[i].first;
			break;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
MOD = 10**9 + 7

count = Array.new(61, 0)
n = gets.chomp.to_i
a = gets.chomp.split.map { |item| item.to_i }

61.times do |j|
  count[j] = a.count { |item| item[j] == 1 }
end

ans = 0

61.times do |i|
  ans += ( 2**i * (n - count[i]) * count[i] ) % MOD
end

puts ans % MOD

Measured memory_bytes: 40324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s,ans;
  cin >>s;
  ll mae=10*(s[0]-48)+(s[1]-48);
  ll usiro=10*(s[2]-48)+(s[3]-48);
  if (mae==0 || usiro==0) {
    if ((mae==0 || mae>12) && (usiro==0 || usiro>12)) {
      ans="NA";
    }
    else if (mae==0) {
      ans="YYMM";
    }
    else if (usiro==0) {
      ans="MMYY";
    }
  }
  else if (mae<=12 && usiro<=12) {
    ans="AMBIGUOUS";
  }
  else if (mae<=12 && usiro>12) {
    ans="MMYY";
  }
  else if (mae>12 && usiro<=12) {
    ans="YYMM";
  }
  else {
    ans="NA";
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<algorithm>
#include<vector>
using namespace std;
int sum;
int main()
{
	string s;
	cin>>s;
	for(int i=0; i<s.length(); i++)cout<<(s[i]=='?'?'D':s[i]);
}


Measured memory_bytes: 3720
using System;
using System.IO;
using System.Text;
using static Scanner;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Solve();
        Console.Out.Flush();
    }
    static void Solve() {
        int N = ScanInt(), M = ScanInt();
        Span<int> span = stackalloc int[N];
        span.Fill(-1);
        for (int i = 0; i < M; i++) {
            int s = ScanInt(), c = ScanInt();
            if (span[s - 1] == c) continue;
            if (span[s - 1] != -1 || N > 1 && s == 1 && c == 0) {
                Console.WriteLine(-1);
                return;
            }
            span[s - 1] = c;
        }
        var sb = new StringBuilder();
        for (var i = 0; i < span.Length; i++) {
            if (span[i] == -1) sb.Append(N > 1 && i == 0 ? 1 : 0);
            else sb.Append(span[i]);
        }
        Console.WriteLine(sb.ToString());
    }
}

public static class Scanner
{
    static readonly Stream stdin = Console.OpenStandardInput();
    static readonly byte[] buffer = new byte[1024];
    static int length, p;
    static bool isEof;
    private static byte StdIn() {
        if (isEof) return 0;
        if (p < length) return buffer[p++];
        p = 0;
        if ((length = stdin.Read(buffer, 0, 1024)) > 0) return buffer[p++];
        isEof = true;
        return 0;
    }
    public static char GetChar() {
        var by = StdIn();
        while ((by < '!' || '~' < by) && !isEof) by = StdIn();
        return (char) by;
    }
    public static int ScanInt() {
        var temp = 0;
        for (var ch = GetChar(); '0' <= ch && ch <= '9'; ch = (char) StdIn()) {
            temp = temp * 10 + ch - '0';
        }
        return temp;
    }
}

Measured memory_bytes: 25796
N = int(input())
S = list(input())
ans = 0
snumber = [str(i) for i in range(10)]
for i in snumber:
    for j in snumber:
        for k in snumber:
            n = 0
            code = []
            while i != S[n] and n < N-3:
                n += 1
            if S[n] != i:
                break
            n += 1
            while j != S[n] and n < N-2:
                n += 1
            if S[n] != j:
                break
            n += 1
            while k != S[n] and n < N-1:
                n += 1
            if S[n] == k:
                ans += 1
print(ans)




Measured memory_bytes: 43372
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  
  string s;
  cin >> s;
  ll ans = 0;
  for (ll i = 0; i < s.size()-1; i++) {
    if (s[i] != s[i+1]) {
      ans++;
    }
  }
  cout << ans << '\n';
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >>  n;
    int a[n],b[n],c[n];
    for (int i=0;i<n;i++)
        cin >> a[i] >> b[i] >> c[i];
    int dpa[n+1],dpb[n+1],dpc[n+1];
    dpa[0]=0;
    dpb[0]=0;
    dpc[0]=0;
    for (int i=1;i<n+1;i++){
        dpa[i]=max(dpb[i-1]+a[i-1],dpc[i-1]+a[i-1]);
        dpb[i]=max(dpa[i-1]+b[i-1],dpc[i-1]+b[i-1]);
        dpc[i]=max(dpb[i-1]+c[i-1],dpa[i-1]+c[i-1]);

    }
    cout << max(dpa[n],max(dpb[n],dpc[n])) << endl;
    //for (int i=0;i<n+1;i++){
    //    cout << dpa[i] << " " << dpb[i] << " " << dpc[i] << endl;
    //}


}


Measured memory_bytes: 2560
object Main extends App {
  import scala.io.StdIn._
  solve
  def solve: Unit = {
    val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
    println(
      Array.tabulate(m){_ ⇒
        val Array(a, _) = readLine.trim.split(' ').map(_.toInt)
        n - a
      }.sorted.dropRight(1).filter(_ > 0).sum
    )
  }
  implicit class ScopeFunc[T](private val value: T) {
    def let[A](func:T ⇒ A): A = func(value)
    def also(func:T ⇒ Unit): T = {
      func(value)
      value
    }
  }
}




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

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


Measured memory_bytes: 3144
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;
  cin >> n;

  if(n % 2 == 0){
    cout << n << endl;
  }else{
    cout << n * 2 << endl;
  }
  return 0;
}



Measured memory_bytes: 256
require 'pp'
n = gets.to_i
nodes = Array.new(n+1){ {
  color: nil, to: [], used: false,
  blen: nil, wlen: nil
}}
# nodes[0] は使わない
(n-1).times do
  u, v, w = gets.split.map(&:to_i)
  nodes[u][:to] << [v,w]
  nodes[v][:to] << [u,w]
end

queue = []
queue << 1
nodes[1][:color] = 'b'
nodes[1][:blen] = 0
# p queue
nodes[1][:used] = true
while queue.empty?.!
  p_node = nodes[queue.pop]
  p_node[:used] = true
  p_node[:to].each do |(to, len)|
    unless nodes[to][:used]
      queue << to
      to_node = nodes[to]
      if p_node[:color] == 'b' # black
        to_node[:blen] = len
        to_node[:wlen] = p_node[:wlen] ? p_node[:wlen] + len : nil
      elsif p_node[:color] == 'w' # white
        to_node[:wlen] = len
        to_node[:blen] = p_node[:blen] ? p_node[:blen] + len : nil
      end
      to_node[:color] = to_node[:blen] % 2 == 0 ? 'b' : 'w'
    end
  end
  # pp nodes[1..-1].map.with_index(1){|a,i|[i,*a]}
  # p queue
end

# pp nodes[1..-1].map.with_index(1){|a,i|[i,*a]}
puts nodes[1..-1].map{|x|x[:color] == 'w' ? '1' : '0'}.join("\n")


Measured memory_bytes: 62460
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <numeric>
#include <iterator>

using namespace std;

namespace {

}

int main()
{
	int r, g, b;

	cin >> r >> g >> b;

	int num = r * 100 + g * 10 + b;

	if (num % 4 == 0){
		cout << "YES" << endl;

	}
	else {
		cout << "NO" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	
	st := make([]int,n)
	order := make([]int,n)
	
	for i := 0; i < n; i++ {
      fmt.Scan(&st[i])
      order[st[i]-1] = i + 1
	}
	
	for i := range order {
		fmt.Printf("%v ",order[i])
	}
}

Measured memory_bytes: 6016
while True:
    n = int(input())
    if n == -1:
        break

    ans = 0
    if n <= 10:
        ans = 1150
    elif n <= 20:
        ans = 1150 + (n - 10)*125
    elif n <= 30:
        ans = 1150 + 1250 + (n - 20)*140
    else:
        ans = 1150 + 1250 + 1400 + (n - 30)*160

    print(4280 - ans)



Measured memory_bytes: 5584
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	char lang[10 + 10];
	char ring[10 + 20];
	int n;
	int len;
	int i,j;
	int ct=0;

	cin >> lang ;

	cin >> n;

	len = strlen(lang);

	for (i = 0; i < n; i++)
	{
		cin >> ring;

		for (j = 0; j < len-1; j++)
		{
			ring[10 + j] = ring[j];
		}

		for (j = 0; j < 10; j++)
		{
			if (strncmp(lang, ring + j, len) == 0)
			{
				ct++;
				break;
			}
		}

	}

	cout << ct << endl;

	return 0;
}

Measured memory_bytes: 3108
[n, k] = [int(i) for i in input().split()] 

h = [int(i) for i in input().split()] 

def able_ride_jet(const, heights):
    """ ジェットコースターに乗れる人の身長のリストを返す関数
    """
    return list(filter(lambda x: x >= const, heights))

print(len(able_ride_jet(k, h)))

Measured memory_bytes: 11936
#include<iostream>
using namespace std;
int main(){
    int n,x,count;
    while(cin>>n>>x&&(n||x)){
        count=0;
        for(int i=1;i<=n-2;i++){
            for(int j=i+1;j<=n-1;j++){
                for(int k=j+1;k<=n;k++){
                    if(i+j+k==x)count++;                       
                }        
            }   
        }   
        cout<<count<<"\n";
    }   
}


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

int main(){
    int X,A,B;
    cin >> X >> A >> B;
    if(B<=A){
        cout << "delicious" << endl;
    }else if((B-A)<=X){
        cout << "safe" << endl;
    }else{
        cout << "dangerous" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <utility>
#include <map>
#include <algorithm>
using namespace std;

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

    int N;
    cin >> N;
    vector<pair<int, int>> vec(N);
    vector<int> per(N);
    int waru = 1;
    double av = 0;
    for (int i = 0; i < N; ++i)
    {
        int a, b;
        cin >> a >> b;
        vec[i].first = a;
        vec[i].second = b;
        per[i] = i;
        waru *= (i + 1);
    }
    do
    {
        for (int i = 0; i < N - 1; ++i)
        {
            int disx = pow(vec[per[i]].first - vec[per[i + 1]].first, 2);
            int disy = pow(vec[per[i]].second - vec[per[i + 1]].second, 2);
            av += sqrt(disx + disy);
        }
    } while (next_permutation(per.begin(), per.end()));
    cout << fixed << setprecision(10);
    cout << av / waru << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
typedef long long ll;
typedef multiset<ll> S;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
int main(){
    int n,k;cin>>n>>k;string s;cin>>s;
    s[k-1]-='A'-'a';
    cout<<s<<endl;
}

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

public class Main {
    
    static final int INF = Integer.MAX_VALUE;
    static final int WHITE = 0;
    static final int GRAY = 1;
    static final int BLACK = 2;

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[][] m = new int[n][n];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                m[i][j] = Integer.parseInt(sc.next());
                if(m[i][j] == -1) m[i][j] = INF;
            }
        }
        
        int[] color = new int[n];
        int[] d = new int[n];
        Arrays.fill(d, INF);
        int[] p = new int[n];
        d[0] = 0;
        p[0] = -1;
        
        while(true){
            int minCost = INF;
            int u = 0;
            for(int i = 0; i < n; i++){
                if(color[i] != BLACK && d[i] < minCost){
                    minCost = d[i];
                    u = i;
                }
            }
            
            if(minCost == INF) break;
            
            color[u] = BLACK;
            
            for(int v = 0; v < n; v++){
                if(color[v] != BLACK && m[u][v] != INF){
                    if(m[u][v] < d[v]){
                        d[v] = m[u][v];
                        p[v] = u;
                        color[v] = GRAY;
                    }
                }
            }
        }
        
        int ans = 0;
        for(int i = 1; i < n; i++){
            ans += m[i][p[i]];
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 39992
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
using ll = long long;
int MOD = 1e9 + 7;
using namespace std;
int main()
{
    ll n,m;
    cin >> n >> m;
    cout << (1900 * m + 100 * (n - m)) * pow(2, m);
}


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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	ll N;
	cin >> N;
	vector<string> grid(N);
	REP(i, N) cin >> grid[i];

	auto isOk = [&](ll a) -> bool
				{
					vector<string> tmp(N);
					REP(i, N) tmp[i] = grid[(i+a)%N];
					REP(h, N)REP(w, N)
					{
						if (tmp[h][w] != tmp[w][h])
							return false;
					}
					return true;
				};

	ll res{0};
	REP(h, N)
	{
		if (isOk(h))
			++res;
	}
	std::cout << res*N << std::endl;
}


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

using namespace std;
int main(){
  long n,k;
   cin >>n>>k;
  
  vector<pair<long,long>> p(n);
    
  for(int i=0;i<n;i++){
     long a,b; 
    cin >> a >> b;
    p[i]=make_pair(a,b);
  }
  
  sort(p.begin(),p.end());
  
   long ans=0;
  for(int i=0;i<n;i++){
    ans+=p[i].second;
    if(ans>=k){ cout << p[i].first << endl;
     return 0;
    }
  }

}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int w, a, b;
    cin >> w >> a >> b;

    if (a >= b) {
        cout << max(0, a-b-w) << endl;
    }
    else {
        cout << max(0, b-a-w) << endl;
    }
    return 0;
}

Measured memory_bytes: 3600
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		List<Integer> ans = new ArrayList<Integer>();
		switch (a) {
		case 1:
			ans.add(b);
			break;
		default:
			for (int i = 0; i < 2; i++) {
				int max = b + a - 1;
				int min = b - a + 1;
				for (int l = b; l <= max; l++) {
					if (!ans.contains(l)) {
						ans.add(l);
					}
				}
				for (int l = b; l >= min; l--) {
					if (!ans.contains(l)) {
						ans.add(l);
					}
				}
			}
		}
		Collections.sort(ans);
		for (int i : ans) {
			System.out.print(i + " ");
		}
		System.out.println();
	}

}


Measured memory_bytes: 25172
# n,m = map(int, input().split())
# sc = [map(int, input().split()) for _ in range(m)]
# s, c = [list(i) for i in zip(*sc)]
#
#
#
# for i in range(10**n):
#     ans = str(i)
#     if len(i) == n and all([i[s[j]-1] == str(c[j]) for j in range(m)]):
#         print(ans)
#         exit()
#
#
# print(-1)

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

s, c = [], []
for _ in range(m):
    s_, c_ = map(int, input().split())
    s.append(s_)
    c.append(c_)

for i in range(10 ** n):
    ans = str(i)
    if len(ans) == n and all([ans[s[j] - 1] == str(c[j]) for j in range(m)]):
        print(ans)
        exit()

print(-1)


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

a.sort(key=lambda x: x[1])

cnt = 0
for i in range(n):
    cnt += a[i][0]
    # print(cnt, a[i][1])
    if cnt > a[i][1]:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 53720
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

	ll n,m;
	cin >> n >> m;
	vector<ll>x(m),xd(m-1);
	rep(i, m)cin >> x[i];
	sort(all(x));
	rep(i, m - 1) {
		xd[i] = abs(x[i + 1] - x[i]);
	}
	sort(all(xd));
	ll sum = 0;
	rep(i, max(0LL, m - n))sum += xd[i];
	cout << sum << endl;
} 


Measured memory_bytes: 1792
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 10000000
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

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

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

func nextFloat() float64 {
	sc.Scan()
	f, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func main() {
	n, k := nextInt(), nextInt()
	mp := make(map[int]bool)
	for i := 0; i < k; i++ {
		d := nextInt()
		for j := 0; j < d; j++ {
			a := nextInt() - 1
			mp[a] = true
		}
	}

	cnt := 0
	for i := 0; i < n; i++ {
		if !mp[i] {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 1784
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll a, b, q;
    cin>>a>>b>>q;
    vl ss(a), ts(b), xs(q);
    cin>>ss>>ts>>xs;

    for (auto x : xs) {
        auto sit = lower_bound(rng(ss), x);
        ll sl = *(sit - 1), su = *sit;
        auto tit = lower_bound(rng(ts), x);
        ll tl = *(tit - 1), tu = *tit;
        ll ans = LINF;
        if (sit != ss.begin() && tit != ts.begin()) chmin(ans, max(x - sl, x - tl));
        if (sit != ss.end() && tit != ts.end()) chmin(ans, max(su - x, tu - x));
        if (sit != ss.begin() && tit != ts.end()) chmin(ans, 2 * (x - sl) + tu - x);
        if (sit != ss.end() && tit != ts.begin()) chmin(ans, 2 * (x - tl) + su - x);
        if (sit != ss.end() && tit != ts.begin()) chmin(ans, 2 * (su - x) + x - tl);
        if (sit != ss.begin() && tit != ts.end()) chmin(ans, 2 * (tu - x) + x - sl);
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3712
# D
from math import factorial


N, K = map(int, input().split())


def p(a, b):
    return factorial(a) // factorial(a-b)
    
    
def c(a, b):
    return p(a, b) // factorial(b)
    
    
for i in range(1, K+1):
    print(0 if N-K+1-i<0 else c(N-K+1, i)*(c(K-1,i-1))%(10**9+7))

Measured memory_bytes: 3316
A, B, C = map(int, input().split())

if any([A % 2, B % 2, C % 2]):
	print(0)
	exit()

if A == B == C:
	print(-1)
	exit()

count = 0
while all([A % 2 == 0, B % 2 == 0, C % 2 == 0]):
    A, B, C = ((B+C)//2, (A+C)//2, (A+B)//2)
    count += 1
print(count)


Measured memory_bytes: 3060
n, m = list(map(int, input().split()))
x = list(map(int, input().split()))
if n >= m:
    print(0)
    exit()
x.sort()
dif = []
for i in range(m - 1):
    dif.append((x[i + 1] - x[i], i + 1))
dif.sort(key = lambda x: x[0], reverse = True)
split = set()
for i in range(n - 1):
    split.add(dif[i][1])
ans = 0
minn, maxx = x[0], x[0]
for i in range(m):
    if i in split:
        ans += maxx - minn
        minn = x[i]
    maxx = max(x[i], maxx)
ans += maxx - minn
print(ans)

Measured memory_bytes: 19904
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
for i in range (1, N):
  A[i] += A[i-1]
A = Counter(A)
k = 0
for j in A.values():
  k += j*(j-1)//2
k += A.get(0,0)
print(k)

Measured memory_bytes: 39592
N = int(input())
W = list(map(int,input().split()))

ans = float("inf")

for T in range(1,N+1):
    n = 0
    S1 = []
    S2 = []
    for i in range(N):
        if i >= T:
            S1.append(W[i])
        else:
            S2.append(W[i])

    n = abs(sum(S1) - sum(S2))
    ans = min(ans, n)

print(ans)

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

using namespace std;

void dfs(int v,vector<vector<int>>& vertex, int d[], int f[]);

int cnt = 1;

int main(){
    int n;
    cin >> n;
    int num;
    int tmp2;
    int d[n] = {};
    int f[n] = {};
    vector<vector<int>> vertex;
    vector<int> tmp;
    for(int i=0;i<n;i++){
        cin >> num;
        cin >> num;
        for(int j=0;j<num;j++){
            cin >> tmp2;
            tmp.push_back(tmp2-1);
        }
        vertex.push_back(tmp);
        tmp.clear();
    }
    dfs(0, vertex, d, f);
    for(int i=0;i<n;i++){
        if(d[i]==0){
            dfs(i, vertex, d, f);
        }
    }
    for(int i=0;i<n;i++){
        cout << i+1 << " " <<  d[i] << " " << f[i] << endl;
    }
    return 0;
}

void dfs(int v, vector<vector<int>>& vertex, int d[], int f[]){
    d[v] = cnt++;
    for(int i : vertex[v]){
        if(d[i]==0){
            dfs(i, vertex, d, f);
        }
    }
    f[v] = cnt++;
}


Measured memory_bytes: 3160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int a = 0;
		int b = 0;

		while(true){
			String str = br.readLine();
			String[] s = str.split(" ");

			a = Integer.parseInt(s[0]);
			b = Integer.parseInt(s[1]);
			if((a == 0)||(b == 0)){
				break;
			}
			if((a <= 300) &&(b <= 300)){

				for(int i = 0; i < a; i++){
					for(int j = 0; j < b; j++){
						if(((i + j)% 2)==0){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
					System.out.println();
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 32612
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll=long long;  
using pLL = std::pair<ll, ll>;

#define SORT(v) std::sort(v.begin(), v.end())
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,ans=0,temp=0;
    cin >> N;
    vector<int> a(N);
    for(int i=0;i<N;++i){
        cin >> a[i];
        ans+=a[i];
        temp=max(temp,a[i]);
    }
    cout << ans-temp/2 <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <functional>
#include <vector>
using namespace std;

struct obj {
	int C;
	int S;
	int F;
};

vector<obj> list;

int func(int begin, int i) {
	
	if (begin == i)
	{
		return list[i].S + list[i].C;
	}

	int tmp = func(begin, i - 1);

	int base = list[i].S;
	while (true)
	{
		if (tmp <= base)
		{
			break;
		}

		base +=  list[i].F;
	}

	return base + list[i].C;
}

int main(void) {
	
	int N;
	cin >> N;

	list.resize(N - 1);
	for (int i = 0; i < N - 1; i++)
	{
		obj tr;
		cin >> tr.C >> tr.S >> tr.F;
		list[i] = tr;
	}
	
	for (int i = 0; i < N - 1; i++)
	{
		cout << func(i, N - 2) << endl;
	}

	cout << 0 << endl;

	return 0;
}

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

int n, x[10], y[10];
double sum;

int main(){
	scanf("%d", &n);
	for(int i=0; i<n; i++) scanf("%d %d", &x[i], &y[i]);
	for(int i=0; i<n; i++) for(int j=0; j<n; j++) sum += std::hypot(x[i]-x[j], y[i]-y[j]);
	printf("%.10lf\n", sum/(double)n);
	return 0;	
}


Measured memory_bytes: 256
/*
 * 2332.cc: Space-Time Sugoroku Road
 */

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

/* constant */

const int MAX_N = 100000;
const int INF = 1 << 30;

/* typedef */

typedef pair<int,int> pii;

/* global variables */

int ps[MAX_N], dists[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> ps[i];

  for (int i = 0; i < n; i++) dists[i] = INF;
  dists[0] = 0;

  priority_queue<pii,vector<pii>,greater<pii> > q;
  q.push(pii(0, 0));

  while (! q.empty()) {
    pii u = q.top(); q.pop();
    int &ud = u.first, &ui = u.second;
    if (dists[ui] != ud) continue;
    if (ui == n - 1) break;
    
    if (ps[ui] != 0) {
      int vi = ui + ps[ui];
      if (dists[vi] > ud) {
	dists[vi] = ud;
	q.push(pii(ud, vi));
      }
    }
    else {
      for (int d = 1; d <= 6; d++) {
	int vi = ui + d, vd = ud + 1;
	if (dists[vi] > vd) {
	  dists[vi] = vd;
	  q.push(pii(vd, vi));
	}
      }
    }
  }

  printf("%d\n", dists[n - 1]);
  return 0;
}

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

typedef long long ll;

int main() {
  int N, M;
  cin >> N >> M;
  vector<ll> X(M);
  for (int i = 0; i < M; i++) cin >> X[i];


  sort(X.begin(), X.end());
  vector<ll> diffs;
  for (int i = 1; i < M; i++) diffs.push_back(X[i] - X[i-1]);
  sort(diffs.begin(), diffs.end(), greater<ll>());
  ll res = X.back() - X[0];
  for (int i = 0; i < min((int)diffs.size(), N-1); i++) res -= diffs[i];
  cout << res << endl;
  return 0;
}

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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> 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 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 int maxn = 1000000 + 1000;
i64 dp[maxn][2];
char s[maxn];

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
#endif

    cin >> (s + 1);
    int len = strlen(s + 1);
    dp[len][0] = s[len] - '0';
    dp[len][1] = 10 - (s[len] - '0');
    for (int i = len - 1; i >= 1; --i) {
        int num = s[i] - '0';
        dp[i][0] = min(dp[i + 1][0] + num, dp[i + 1][1] + num + 1);
        dp[i][1] = min(dp[i + 1][0] + (10 - num), dp[i + 1][1] + (10 - num - 1));
    }
    cout << min(dp[1][0], dp[1][1] + 1) << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 16896
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) int((a).size())
#define LOWB(x) (x & (-x))
#define UNIQUE(a) sort(ALL(a)), (a).erase(unique(ALL(a)), (a).end())
#define INF 1e9
#define INF_LL 4e18
#define rep(i,a,b) for(__typeof(b) i=a; i<(b); ++i)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
/*-----------------------------------*/
int n;
vi c, v;

int main() {
  cin >> n;
  c.resize(n);
  v.resize(n);
  for (int i=0; i<n; i++) cin >> v[i];
  for (int i=0; i<n; i++) cin >> c[i];

  int best = 0;
  for (int i=0; i<(1<<n); i++) {
    int x = 0, y = 0;
    for (int j=0; j<n; j++) if (i & (1<<j)) {
      x += v[j];
      y += c[j];
    }
    best = max(best, x - y);
  }
  cout << best << endl;
  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize,
        a: [i64; n],
        q: usize,
        bc: [(i64, i64); q]
    }

    let mut map = HashMap::new();
    for &v in &a {
        *map.entry(v).or_insert(0) += 1i64;
    }
    let mut sum = a.iter().sum::<i64>();

    for (from, to) in bc {
        if let Some(&num) = map.get(&from) {
            sum += num * (to - from);
            map.remove(&from);
            *map.entry(to).or_insert(0) += num;
        }
        println!("{}", sum);
    }
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, x;
    cin >> N >> x;
    vector<ll> a(N);
    REP(i, N)
    {
        cin >> a[i];
    }

    ll ans = LONG_MAX;
    vector<ll> minA(N, LONG_MAX);
    REP(i, N)
    {
        ll magicSum = x * i;
        REP(j, N)
        {
            ll currentIndex = (j + i) % N;
            minA[j] = min(minA[j], a[currentIndex]);
            magicSum += minA[j];
        }
        ans = min(ans, magicSum);
    }

    cout << ans << endl;
}


Measured memory_bytes: 384
x = int(input())
kouho = []
for i in range(300):
    kouho.append([i**5,i])
    kouho.append([-i**5,-i])
for i in range(len(kouho)):
    for j in range(len(kouho)):
        if kouho[i][0]-kouho[j][0] == x:
            print(kouho[i][1],kouho[j][1])
            exit()

Measured memory_bytes: 9172
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
typedef long long lint;
typedef std::pair<lint, lint> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = 1e-9;
constexpr double PI=3.141592653589793238462643383279;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	if (!b)return T(1);
	if (b & 1)return mypow(a, b - 1) * a;
	T memo = mypow(a, b >> 1);
	return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	lint memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int main(){
	int a,b,c,d,e;
	std::cin>>a>>b>>c>>d>>e;
	std::cout<<(c-a)*60+(d-b)-e<<std::endl;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


int main(){
	int a, b, c, x, ans = 0;
	cin >> a >> b >> c >> x;

	for (int i = 0; i <= a; i++){
		for (int j = 0; j <= b; j++){
			for (int k = 0; k <= c; k++){
				if (500*i + 100*j + 50*k == x){
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    int n;
    cin>>n;
    int a[n][3];
    int b[n][3];
    for(int i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    b[0][0]=a[0][0];
    b[0][1]=a[0][1];
    b[0][2]=a[0][2];
    for(int i=1;i<n;i++)
    {
        b[i][0]=max(b[i-1][1]+a[i][0],b[i-1][2]+a[i][0]);
        b[i][1]=max(b[i-1][0]+a[i][1],b[i-1][2]+a[i][1]);
        b[i][2]=max(b[i-1][1]+a[i][2],b[i-1][0]+a[i][2]);
    }
    cout<<max(max(b[n-1][0],b[n-1][1]),b[n-1][2]);
    return 0;
}


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

#define rep(i,n) for(ll i = 0; i < (n); i++)
#define REP(i,n) for(ll i = 1; i < (n); i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n")
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;

const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1; 


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

  int n;
  cin >> n;
  vi t(n+1), x(n+1), y(n+1);
  t[0] = x[0] = y[0] = 0;
  rep(i,n) cin >> t[i+1] >> x[i+1] >> y[i+1];
  bool ans = true;
  REP(i,n+1){
    int dist = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]);
    int time = t[i]-t[i-1];
    if(!(time >= dist && time % 2 == dist % 2)) ans = false;
  }
  YesorNo(ans);
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
using namespace std;

int main(){
    long long int lucas[87];
    
    int n;
    cin >> n;
    
    lucas[0] = 2;
    lucas[1] = 1;
    
    for(int i = 2; i <= n; i++){
        lucas[i] = lucas[i-1] + lucas[i-2];
    }
    
    cout << lucas[n] << endl;
}


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

typedef long long int ll;

ll absl(ll n)
{
	if(n<0)
	{
		return -1*n;
	}
	return n;
}
int main()
{
	ll n,w,i,j,w1,v1;
	cin>>n>>w;
	vector<ll> dp(w+1,0);
	for(i=0;i<n;i++)
	{
		cin>>w1>>v1;
		for(j=w;j>=w1;j--)
		{
			if(w1<=j)
			{
				dp[j]=max(dp[j],v1+dp[j-w1]);
			}
		}
	}
	cout<<dp[w];
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
#define sz  2010
using namespace std;

int main()
{

     string a,b,c;
     ll x,y;
     cin>>a;
     cin>>b;
     cin>>x>>y;
     cin>>c;

     if(c==a)x--;
     else if(c==b)y--;

     cout<<x<<" "<<y<<endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define double /*long*/ double
#define endl '\n'
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vppll vector<pair<pll,pll>>
#define mp make_pair
#define pb push_back
#define mapll map<ll,ll>
#define fir first
#define sec second
#define _cin ios_base::sync_with_stdio(0);  cin.tie(0);
#define fo(i,b) for(i=0;i<b;i++)
#define repa(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define all(x) (x).begin(), (x).end()
#define s(v) v.size()
const long long int MAX = (ll)(1e18+1);
const long long int MIN = (ll)(-1e18-1);
const long long int mod = (ll)(1e9+7);
using namespace std;

ll max(ll a,ll b,ll c) {return max(max(a, b), c);}
ll min(ll a,ll b,ll c) { return min(min(a, b), c);}
ll max(ll a,ll b) {return (a>b) ? a : b;}
ll min(ll a,ll b) {return (a<b) ? a : b;}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power_mod(ll a, ll n, ll mod_){ ll p=1; while(n){ if(n%2){ p=(p*a)%mod_;} n/=2; a=(a*a)%mod_;} return p%mod_;}
                                                 /*Code Begins*/


int main(){
    _cin;
    // cout << setprecision(15);
    ll mn = MAX, mx = MIN;
    ll n, t, m, k, i, j,  sum=0,  prev, flag=0, cnt=0;
    ll x=0, y=0, fx, diff, tot=0, l , r;
    int TC=1;
    // cin >> TC;
while(TC--){
    cin >> n >> m;
    vpll a(n);
    fo(i,n) cin >> a[i].first >> a[i].second;
    vll dp(100001,MAX);
    dp[0]=0;
    fo(i,n){
        for(j=100000;j>=a[i].second; j--){
            dp[j] = min(dp[j-a[i].second]+a[i].first, dp[j]);
        }
    }
    repb(i,100000,0) if(dp[i]<=m) break;
    cout << i;
}
 return 0;      
}

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

struct Point {
    int x, y;

    Point() = default;
    Point(int x, int y) : x(x), y(y) {}

    Point operator+(const Point &rhs) const {
        return Point(x + rhs.x, y + rhs.y);
    }

    Point operator-(const Point &rhs) const {
        return Point(x - rhs.x, y - rhs.y);
    }

    long long operator*(const Point &rhs) const {
        return 1ll * x * rhs.x + 1ll * y * rhs.y;
    }

    long long operator%(const Point &rhs) const {
        return 1ll * x * rhs.y - 1ll * y * rhs.x;
    }
};

int sign(long long x) {
    if (x > 0) return 1;
    if (x == 0) return 0;
    if (x < 0) return -1;
}

bool intersect(Point p1, Point p2, Point p3, Point p4) {
    if (max(p1.x, p2.x) < min(p3.x, p4.x) || max(p3.x, p4.x) < min(p1.x, p2.x)) return false;
    if (max(p1.y, p2.y) < min(p3.y, p4.y) || max(p3.y, p4.y) < min(p1.y, p2.y)) return false;
    return sign((p3 - p1) % (p4 - p1)) * sign((p3 - p2) % (p4 - p2)) <= 0 &&
           sign((p1 - p3) % (p2 - p3)) * sign((p1 - p4) % (p2 - p4)) <= 0;
}

int contain(const vector<Point> &ps, Point p) {
    // ps is not necessarily convex.
    int n = (int)ps.size();
    for (int i = 0; i < n; ++i) {
        Point a = ps[i], b = ps[(i + 1) % n];
        // on segment
        if ((p - a) * (b - a) >= 0 && (p - b) * (a - b) >= 0 && (p - a) % (b - a) == 0) return 1;
    }
    Point q = Point(1000000000, p.y);
    int res = 0;
    for (int i = 0; i < n; ++i) {
        Point a = ps[i], b = ps[(i + 1) % n];
        if (intersect(a, b, p, q) && p.y >= min(a.y, b.y) && p.y < max(a.y, b.y)) res ^= 1;
    }
    // ps contains p.
    if (res == 1) return 2;
    return 0;
}

int main() {
    int n; cin >> n;
    vector<Point> ps(n);
    for (int i = 0; i < n; ++i) cin >> ps[i].x >> ps[i].y;
    int q; cin >> q;
    while (q--) {
        Point p; cin >> p.x >> p.y;
        cout << contain(ps, p) << endl;
    }
    return 0;
}



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

void Main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int k;
	cin >> k;
	rep(i, k) {
		if (b <= a) {
			b = 2*b;
		} else if (c <= b) {
			c = 2*c;
		}
	}
	if (a < b && b < c) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

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: 3648
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        int n = sc.nextInt();
        Set<Integer> aSet = new HashSet<>(n);
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            min = Math.min(min, a);
            aSet.add(a);
        }

        while (aSet.size() > 1) {
            Set<Integer> nextSet = new HashSet<>(n);
            nextSet.add(min);
            int nextMin = min;
            for (Integer a : aSet) {
                if (min != a) {
                    Integer tmp = a % min;
                    if (tmp != 0) {
                        nextSet.add(tmp);
                        nextMin = Math.min(nextMin, tmp);
                    }
                }
            }

            aSet = nextSet;
            min = nextMin;
        }
        System.out.println(min);
    }
}


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

int arr[100100];

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


Measured memory_bytes: 640