akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
using namespace std;


int main()
{
  int d,g,*p,*c,ta,tc[10],ttc,ans=10000,tmp,req;
  cin >> d >> g;
  p = new int[d];
  c = new int[d];
  for(int i=0;i<d;i++)cin >> p[i] >> c[i];

  for(int i=0;i<pow(2,d);i++)
  {
      ta=0;
      ttc=0;
      for(int j=0;j<d;j++)
      {
        tc[j]=0;
        if(i&int(pow(2,j)))
        {
          tc[j]=p[j];
          ttc+=p[j];
          ta+=(j+1)*p[j]*100;
          ta+=c[j];
        }
      }
      for(int j=d-1;j>=0;j--)
      {
        if(ans<=ttc)break;
        if(ta>=g)break;
        req = min(p[j]-tc[j],int(ceil(((g-ta)/100.0)/(j+1))));
      //cout << i <<':' << j<< ':' <<ta<<':'<< int(ceil(((g-ta)/100.0)/(j+1))) << endl;
        tc[j]+=req;
        ttc+=req;
        ta+=req*(j+1)*100;
      }
      if(ta>=g)
      if(ttc<ans){ans=ttc;}//for(int k=0;k<d;k++)cout << i << ':' << k << ':' << tc[k] << endl;}
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
typedef long long ll ; 
#define M 1000000007
 
#define PI 3.141592653589793238462643383279502884197169
using namespace std; 



int main()
{

int x;
cin>>x;
if(x>=30)
cout<<"Yes";
else cout<<"No";

    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    string s;
    cin >> s;
    int a = s[0] - '0';
    int b = s[1] - '0';
    int c = s[2] - '0';
    int d = s[3] - '0';

    for (int i = 0; i < 8; i++) {
        int bb = b;
        int cc = c;
        int dd = d;
        if (i >> 2 & 1) bb *= -1;
        if (i >> 1 & 1) cc *= -1;
        if (i >> 0 & 1) dd *= -1;
        if (a + bb + cc + dd == 7) {
            cout << a;
            if(bb >= 0) cout << "+";
            cout << bb;
            if(cc >= 0) cout << "+";
            cout << cc;
            if(dd >= 0) cout << "+";
            cout << dd << "=7" << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let l: usize = it.next().unwrap().parse().unwrap();
    let r: usize = it.next().unwrap().parse().unwrap();
    const MOD: u64 = 1_000_000_007;
    let mut dp = [[0u64; 2]; 2];
    for shift in (0..60).rev() {
        let (x, y) = ((l >> shift) & 1, (r >> shift) & 1);
        let mut next = [[0; 2]; 2];
        for i in 0..2 {
            for j in 0..2 {
                let v = dp[i][j] % MOD;
                if x == 0 || i == 1 {
                    next[i][j | y] += v;
                }
                if (x == 0 || i == 1) && (y == 1 || j == 1) {
                    next[i][j] += v;
                }
                if y == 1 || j == 1 {
                    next[i | if x == 0 {1} else {0}][j] += v;
                }
            }
        }
        if 1 >= (l >> shift) && 1 <= (r >> shift) {
            next[if x == 0 {1} else {0}][if 1 < (r >> shift) {1} else {0}] += 1;
        }
        dp = next;
    }
    let mut ans = 0;
    for i in 0..2 {
        for j in 0..2 {
            ans += dp[i][j];
        }
    }
    ans %= MOD;
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int len = scanner.nextInt();
		int nums[] = new int[len];
		int counts = 0;

		for (int i = 0; i < len; i++) {
			nums[i] = scanner.nextInt();
		}
		int flag = 1;
		while (flag == 1) {
			flag = 0;
			if (nums.length > 1) {
				for (int i = 1; i < nums.length; i++) {
					if (nums[i-1] > nums[i]) {
						int tmp = nums[i-1];
						nums[i-1] = nums[i];
						nums[i] = tmp;
						flag = 1;
						counts++;
					}
				}
			}
		}

		new Main().arrayToString(nums);
		System.out.println(counts);
	}

	public void arrayToString(int[] arr) {
		for (int i = 0; i < arr.length; i++) {

			if (i == arr.length - 1) {
				System.out.println(arr[i]);
			} else {
				System.out.print(arr[i] + " ");
			}
		}
	}

}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))
#define each(i, map) for (auto& i : map)

int main()
{
    long long X; cin >> X;

    long long cnt = 0;
    double now = 100;
    while (true) {
        if (now >= X) break;
        now = floor(now + (now * 0.01));
        ++cnt;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
using namespace std;

const int64_t INF = 1LL << 60;

int main(void){
  int N,K;
  cin >> N >> K;
  vector<int> h;
  vector<int64_t> dp;
  for(int i=0;i<N;i++){
    int tmp;
    cin >> tmp;
    h.push_back(tmp);
    dp.push_back(INF);
  }
  
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  
  for(int i=2;i<N;i++){
    for(int j=1;j<=K;j++){
      if(i-j <0){break;}
      dp[i] = min(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
    }
  }
  
  cout << dp[N-1] << endl;
}


Measured memory_bytes: 1780
// ------------------------------------
// Date:2018/ 4/ 3
// Problem:D- joisino's travel d.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 201;

int N, M, R;

int e[MAX_N][MAX_N];

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

  cin >> N >> M >> R;

  REP(i, N) {
    REP(j, N) {
      if (i == j) e[i][j] = 0;
      else e[i][j] = INF;
    }
  }
  
  vector< int > r(R);
  REP(i, R) {
    cin >> r[i];
    r[i]--;
  }
  sort(ALL(r));

  bool f, t;
  REP(i, M) {
    CIN(a, b, c);
    a--; b--;
    /*
    EACH(ri, r) {
      if (ri == a) f = true;
      if (ri == b) t = true;
    }
    if (!(f && t)) continue; 
    */
    e[a][b] = c;
    e[b][a] = c;
  }

 
  REP(k, N) {
    REP(i, N) {
      REP(j, N) {
	e[i][j] = min(e[i][j], e[i][k] + e[k][j]);
      }
    }
  }

  int ans = INF;
  /*
  REP(i, N) {
    REP(j, N) {
      ans = max(ans, e[i][j]);
    }
  }
  */
  do {
    int tmp = 0;
    REP(i, r.size() - 1) {
      tmp += e[r[i + 1]][r[i]];
    }
    ans = min(ans, tmp);
  } while(next_permutation(ALL(r)));
  
  cout << ans << endl;

  /*
  REP(i, N) {
    REP(j, N) {
      cout << e[i][j];
      if (j != N - 1) cout << " ";
    }
    cout << endl;
  }
  */
    
  return 0;
}



Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
    int h, r;

    scanf("%d %d", &h, &r);
    if (h + r > 0){
        puts("1");
    }
    else if (h + r == 0){
        puts("0");
    }
    else {
        puts("-1");
    }

    return 0;
}

Measured memory_bytes: 580
#include <stdio.h>
int main (void){
int n,a[100],i;
scanf("%d",&n);
for(i=1;i<=n;i++){
	scanf("%d",&a[i]);
	}
for(i=n;i>=2;i=i-1){
	printf("%d ",a[i]);
	}
printf("%d\n",a[1]);
return 0;	
}

Measured memory_bytes: 1828
#include <cstdio>
#include <cstdint>
#include <numeric>
#include <vector>
#include <algorithm>
#include <utility>

int gcd(int m, int n) {
  while (n) std::swap(m %= n, n);
  return m;
}

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

  intmax_t res = 0;
  for (int a = 1; a <= k; ++a)
    for (int b = 1; b <= k; ++b)
      for (int c = 1; c <= k; ++c)
        res += gcd(gcd(a, b), c);

  printf("%jd\n", res);
}


Measured memory_bytes: 1732
import java.util.Scanner;

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

        int A1 = sc.nextInt();
        int A2 = sc.nextInt();
        int A3 = sc.nextInt();

        System.out.println(A1 + A2 + A3 >= 22 ? "bust" : "win");
    }
}

Measured memory_bytes: 21844
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
//#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 4000000;
const int mod = 998244353;
int t[N], suf[N], p[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   // freopen("input.txt", "r", stdin);
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    for (int i = 1; i <= n; i++){
        t[i] = t[i - 1] + (s[i - 1] == 'x');
    }
    t[n + 1] = t[n];
    int pr = -1e9;
    for (int i = 1; i <= n; i++){
        if (s[i - 1] == 'x'){
            p[i] = p[i - 1];
        } else{
            if (pr + c < i){
                p[i] = p[i - 1] + 1;
                pr = i;
            } else p[i] = p[i - 1];
        }
    }
    pr = 2e9;
    for (int i = n; i >= 1; i--){
        if (s[i - 1] == 'x'){
            suf[i] = suf[i + 1];
        } else{
            if (pr - c > i){
                suf[i] = suf[i + 1] + 1;
                pr = i;
            } else suf[i] = suf[i + 1];
        }
    }
    for (int i = 1; i <= n; i++){
        if (suf[i + 1] + p[i - 1] < k){
            cout << i << endl;
        }
    }
}


Measured memory_bytes: 8724
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;


class Program {


	static long mod = 1000000007;
	//static long mod =998244353; 
	static void Main(string[] args) {

		char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

		//int n = int.Parse(Console.ReadLine());
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res = "";
		int res = 0;

		int h = int.Parse(Console.ReadLine());
		int w = int.Parse(Console.ReadLine());
		int n = int.Parse(Console.ReadLine());
		int b = Math.Max(h, w);

		res = n / b;
		if ( n % b > 0 ) { res++; }



			Console.WriteLine(res);

		return;

	}


	//	int配列をスペース区切りの文字列に変換
	static string stringBuilderArrayInt(int[] a) {
		StringBuilder sb = new StringBuilder();

		for ( int i = 0; i < a.Length; i++ ) {
			sb.Append(a[i] + " "); 
		}
		if ( sb.Length > 1 ) {
			sb = sb.Remove(sb.Length - 1, 1);
		}
		return sb.ToString(); ;
	}


	//	文字列strをindex番目からdで上書き
	static string strOverWrite(string str, int i, string s) {
		return str.Remove(i, s.Length).Insert(i, s);
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}



}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

using namespace std;

struct node {
	int to[26];
	int sz;
	node() { for (int i = 0; i < 26; ++i) to[i] = -1; sz = 0;}
};

node t[1000007];
int sz = 1;
int n;

int main(){
#ifdef LOCAL
	freopen("B_input.txt", "r", stdin);
	//freopen("B_output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	cin >> n;
	vector<string> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];

	sort(all(a), [](const string& a, const string& b) {
		return a.size() < b.size();
	});

	ll ans = 0;

	for (int i = 0; i < n; ++i) {
		reverse(all(a[i]));
		int v = 0;

		vector<int> cnt(26, 0);
		for (char c : a[i]) cnt[c - 'a'] ++;

		for (int j = 0; j < a[i].size(); ++j) {
	
			for (int to = 0; to < 26; ++to) if (cnt[to]) {
				if (t[v].to[to] != -1) ans += t[t[v].to[to]].sz;
			}

			cnt[a[i][j] - 'a']--;

			int now = a[i][j] - 'a';
			if (t[v].to[now] == -1) t[v].to[now] = sz++;
			v = t[v].to[now];
		}
		++t[v].sz;
	}

	cout << ans;
}


Measured memory_bytes: 114820
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n; cin >> n;
  vector<ll> a(n);
  REP(i,n) cin >> a[i];
  ll ans = 0;
  REP(i,60) {
    ll x = 0;
    REP(j,n) if (a[j]>>i&1) x++;
    ll now = x*(n-x)%MOD; // 0と1を一つずつ選ぶ
    REP(j,i) now = now*2%MOD; // 2のi乗
    ans += now;
    ans %= MOD;
  }
  COUT(ans);
  return 0;
}


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

int main() {
  double a, b, c;
  cin >> a >> b;
  c = (a+b)/2;
  int d;
  d = (int)c;
    if(c-d>0){
    d += 1;
    }
  cout << d << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <utility>
using i64 = long long;

int main() {
    int n, m;
    std::cin >> n >> m;
    std::vector<std::vector<int>> g(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        std::cin >> a >> b;
        --a; --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    std::vector<int> ret(n, -1);
    std::deque<int> q { 0 };
    ret[0] = 0;
    while (!q.empty()) {
        const int v = q.front();
        q.pop_front();
        for (const int to : g[v]) {
            if (ret[to] >= 0) continue;
            ret[to] = v;
            q.push_back(to);
        }
    }

    std::cout << "Yes\n";
    for (int i = 1; i < n; i++) std::cout << ret[i] + 1 << '\n';
    std::cout << std::flush;

    return 0;
}


Measured memory_bytes: 10268
x = int(input())

affordable_set = {0}
for i in range(1,21):
    tmpset = affordable_set
    for j in range(6):
        shift = 100 + j
        tmpset = tmpset.union({j + shift for j in affordable_set})
    affordable_set = affordable_set.union(tmpset)

if x >= 2000:
    print(1)
else:
            
    if x in affordable_set:
        print(1)
    else:
        print(0)

Measured memory_bytes: 3444
#include<iostream>
#include <math.h>
using namespace std;
int main()
{
    // 整数の入力
    long int q;
    cin >> q;
    long int a[105], b[105];
    // スペース区切りの整数の入力
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i];
    }



    for (int i = 0; i < q; i++) {
        long int tk = a[i] * b[i];
        long int count = 0;
        long int max = a[i] * b[i] - 1;
        long int fxmax = a[i] * b[i] - 1;
        long int min = 1;

        long int minlank = 0;
        long int maxlank = 0;


        long int sq;
        long int cc=0;
        if (a[i] > b[i]) {
            minlank = b[i];
            maxlank = a[i];
        } else {
            minlank = a[i];
            maxlank = b[i];
        }

        // if (minlank > 1) {
        //     count = (minlank - 1) * 2;
        //     min = minlank ;
        //     max = fxmax / (minlank );
        // } else { //minlank==1のとき
        //     sq = sqrt(maxlank);
        //     if (maxlank == sq * sq)sq--;
        //     count = (sq - 1) * 2 - 1;
        //     if (sq * (sq + 1) < tk) {
        //         count += 2;
        //     } else {
        //         count += 1;
        //     }
        //     cout << count << endl;
        //     continue;
        // }


        sq = sqrt(tk);
        if (tk == sq * sq)sq--;
        count = (sq-1)*2;
        if (sq >= minlank)count--;
        if (sq*(sq+1) < tk){
            count +=2;
        }else{
            count++;
        }



        // cc = count;
        // sq = sqrt(maxlank);
        // if (maxlank == sq * sq)sq--;

        // count = (sq - 1) * 2 - 1;
        // if (sq * (sq + 1) < tk) {
        //     count += 2;
        // } else {
        //     count += 1;
        // }
        // count += cc;

        // while (true) {
        //     if (max * min < tk) {
        //         if (max == min) {
        //             count += 1;
        //         } else {
        //             count += 2;
        //         }
        //         if (a[i] == max || a[i] == min)count--;
        //         if (b[i] == max || b[i] == min)if (count > 0)count--;
        //         min++;
        //         max = fxmax / (min);
        //     } else {
        //         max--;
        //     }
        //     if (max < min)break;
        // }



        cout << count << endl;
    }


    return 0;
}

Measured memory_bytes: 256
input()
listnum = list(map(int, input().split()))

for i in range(int(input())):
    eachq = list(map(int, input().split()))
    newlist = listnum[eachq[0]:eachq[1]]
    newlist.reverse()
    listnum = listnum[:eachq[0]] + newlist + listnum[eachq[1]:]

print(" ".join(map(str, listnum)))



Measured memory_bytes: 5640
def main():
    # input
    n = int(input())
    li = [tuple(map(int, input().split())) for _ in range(n)]

    l = 0
    for i in range(n-1):
        for j in range(i+1, n):
            l += ( (li[i][0]-li[j][0])**2 + (li[i][1]-li[j][1])**2 ) ** 0.5

    print(l*(n-1)/(n*(n-1)/2))

    # calc


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <stdio.h>
#define max 200000

int main(void) {
  long long i, j, k, n, sum[max], now = 0;
  bool prime[max];
  for(i = 0; i < max; ++i) prime[i] = true;
  prime[0] = prime[1] = false;
  for(i = 2; i < 500; ++i) if(prime[i]) for(j = 2; i * j < max; ++j) prime[i * j] = false;
  sum[0] = 0;
  for(i = 1; i < max; ++i) if(prime[i]) {
    now++;
    sum[now] = sum[now - 1] + i;
  }
  while( 1 ) {
    scanf("%lld", &n);
    if(!n) break;
    printf("%lld\n", sum[n]);
  }
  return 0;
}


Measured memory_bytes: 2908
from collections import Counter

n = int(input())
A = Counter(list(map(int, input().split())))
x = [0, 0]
for a in A:
    if A[a] >= 2:
        x.append(a)
    if A[a] >= 4:
        x.append(a)
x.sort()
print(x[-1] * x[-2])


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



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

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

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;

vector<ll> zalgo(string S){
  vector<ll>A(S.length());
  int c = 0;
  for (int i = 1; i < S.size(); i++){
      if (i+A[i-c] < c+A[c]) {
        A[i] = A[i-c];
      } else {
        int j = max(0ll, c+A[c]-i);
        while (i+j < S.size() && S[j] == S[i+j]) ++j;
        A[i] = j;
        c = i;
      }
  }
  A[0]=S.length();
  return A;
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<ll>k(n,1);

  vector<ll>a(n),b(n);
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  rep(bit,30){
    string ts="";
    rep(j,n){
      if(b[j]&(1ll<<bit))ts+="1";
      else ts+="0";
    }
    rep(j,n){
      if(a[j]&(1ll<<bit))ts+="1";
      else ts+="0";
    }

    rep(j,n){
      if(a[j]&(1ll<<bit))ts+="1";
      else ts+="0";
    }

    string tt="";
    rep(j,n){
      if(b[j]&(1ll<<bit))tt+="0";
      else tt+="1";
    }
    rep(j,n){
      if(a[j]&(1ll<<bit))tt+="1";
      else tt+="0";
    }

    rep(j,n){
      if(a[j]&(1ll<<bit))tt+="1";
      else tt+="0";
    }
    auto zs=zalgo(ts),zt=zalgo(tt);
    rep(i,n){
      if(zs[i+n]>=n||zt[i+n]>=n){
        k[i]&=1;
      }
      else k[i]=0;
    }
  }
  rep(i,n){
    if(k[i]){
      cout<<i<<" "<<(a[i]^b[0])<<endl;
    }
  }
  return 0;

}


Measured memory_bytes: 16580
#include<bits/stdc++.h>
using namespace std;
void pre(){}
void solve(){
    long long int n,w,x,y,a,b;cin>>n>>w;
    long long int dp[n+1][w+1];
    for(long long int j=0;j<=w;j++){
        dp[0][j]=0;
    }
    long long int inp[n][2];
    for(long long int i=0;i<n;i++){cin>>inp[i][0];cin>>inp[i][1];}
    pair<long long int,long long int>arr[n];
    for(long long int i=0;i<n;i++)arr[i]={inp[i][1],inp[i][0]};
    sort(arr,arr+n);
    //---DP---
    for(long long int i=1;i<=n;i++){
        for(long long int j=0;j<=w;j++){
            dp[i][j]=dp[i-1][j];
        }
        for(long long int j=0;j<=w;j++){
            if(j+arr[i-1].second<=w){
                dp[i][j+arr[i-1].second] = max(dp[i][j+arr[i-1].second],dp[i-1][j]+arr[i-1].first);
            }
        }
    }
    long long int ans = 0;
    for(long long int i=0;i<=n;i++){
        long long int a = 0;
        for(long long int j=0;j<=w;j++){
            a=max(dp[i][j],a);
            dp[i][j]=a;
        }
    }
    cout<<dp[n][w]<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}

Measured memory_bytes: 79232
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>
#include <array>

using namespace std;

template<typename M, typename N>
istream& operator>>(istream&is, pair<M,N> & p){is >> p.first >> p.second; return is;}
template<typename M>
istream& operator>>(istream&is, vector<M> & v){for(auto &it:v) is >> it; return is; }
template<typename M>
istream& operator>>(istream&is, vector<vector<M>> & v){for(auto &it:v) is >> it; return is; }
template<typename M, typename N>
ostream& operator<<(ostream&os, const pair<M,N> &p){os << p.first << ' ' << p.second << '\n';return os;}
template<typename M>
ostream& operator<<(ostream&os, const vector<M> &v){for(auto it: v)os << it << ' ';cout << '\n';return os;}
template<typename M>
ostream& operator<<(ostream&os, const vector<vector<M>> &v){for(auto it: v)os << it;return os;}

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mn(x) *min_element((x).begin(),(x).end())
#define mx(x) *max_element((x).begin(),(x).end())
#define acc(x) accumulate((x).begin(),(x).end(),0ll)
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef  unsigned long long  ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

const ld pi=acos(-1);
const ll inf=(ll)1e9+10;
//const int mod=1000000007;
const int mod=998244353;

int n,m,k;
const int N=3e5+10;





int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n;
    cin >> n;
    string s="ACL";
    for(int i=0; i<n; i++){
        cout << s;
    }
    cout << el;
    return 0;
}








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

int main(){
    int a, b, k;
    cin >> k >> a >> b;
    for(int i = 1; i <= 1000; i++){
        if(a <= k * i && k * i <= b){
            cout << "OK\n";
            return 0;
        }
    }
    cout << "NG\n";
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <bitset>
#include <map>
#include <climits>
#include <set>
#include <cmath>

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<set<int>> sets;
    for (int i = 0; i < N; ++i)
    {
        int k;
        cin >> k;
        set<int> s;
        for (int j = 0; j < k; ++j)
        {
            int l;
            cin >> l;
            s.insert(l);
        }
        sets.push_back(s);
    }
    set<int> intersection = sets[0];
    for (int i = 1; i < N; ++i)
    {
        set<int> tmp;
        set_intersection(intersection.begin(), intersection.end(),
                         sets[i].begin(), sets[i].end(), inserter(tmp, tmp.end()));
        intersection = tmp;
    }
    cout << intersection.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
	using namespace std;
	int main() { 
	    
	    int n;
	    cin >> n;
	    vector<int> arr(n,0);
	    long sum =0;
	    for(int i=0 ; i<n ;i++){
	    	cin>> arr[i] ;
	    	sum += arr[i];
	    }

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

	    cout << arr[0] << " " << arr[n-1] << " " << sum << endl;


	    return 0;
	}


Measured memory_bytes: 3196
#!/usr/bin/env python3
N, M = map(int, input().split())
a = [0] * N
b = [0] * N
for i in range(N):
    a[i], b[i] = map(int, input().split())
c = [0] * M
d = [0] * M
for i in range(M):
    c[i], d[i] = map(int, input().split())

for i in range(N):
    x = 0
    y = 0
    dist = 10**20
    ans = 0
    for j in range(M):
        x = abs(a[i] - c[j])
        y = abs(b[i] - d[j])
        if x + y < dist:
            dist = x + y
            ans = j + 1
    print(ans)


Measured memory_bytes: 9172
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  rep(i,1000000)
    if((1+i)*i>=2*n)break;
  cout<<i<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    stack<char> st;
    rep(i, S.length()) {
        if (S[i] != 'B') st.push(S[i]);
        else if(st.size() && S[i] == 'B') st.pop();
    }
    string A;
    while(st.size()) {
        A += st.top();
        st.pop();
    }
    reverse(A.begin(), A.end());
    cout << A << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>


int main()
{
	int n,m;
	int i,j,k,l;
	int ans,sum;

	while(1)
	{
		scanf("%d %d",&n,&m);
		if((n==0)&&(m==0)){break;}
		else
		{
			int date[102]={0};

			for(i=0;i<n;i++)
			{
				int o;
				int buf;
				scanf("%d",&o);
				for(j=0;j<o;j++)
				{
					scanf("%d",&buf);
					date[buf]++;
				}
			}

			ans=0;
			sum=0;

			for(j=1;j<102;j++)
			{
				if(date[j]>sum)
				{
					sum=date[j];
					ans=j;
				}
			}

			if(sum>=m){printf("%d\n",ans);}
			else{printf("0\n");}
		}
	}
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n,k;cin>>n>>k;
  vector<ll>a(n);
  rep(i, n)cin>>a[i];

  ll result = INF;
  rep(bits, pow(2, n)){
    if(__builtin_popcount(bits)<k)continue;

    vector<ll>ca(a);
    ll tmp=0;
    rrep(i, n){
      if( !(bits>>i&1) )continue;

      ll current_height = ca[n-1-i];
      ll pre_max = 0;
      rep(j, n-1-i)pre_max = max<ll>(pre_max, ca[j]);
      ll alter_height = max<ll>(pre_max+1, current_height);
      ll diff = alter_height - current_height;
      tmp += diff;
      ca[n-1-i] = alter_height;
    }
    result = min<ll>(result, tmp);
  }

  cout<<result<<endl;

  return 0;
}

Measured memory_bytes: 256
def min_max(a, b, c):
    """Returns the minimum value and the maximum value
    in a, b, c.

    >>> min_max(1, 2, 3)
    (1, 3)
    >>> min_max(1, 3, 2)
    (1, 3)
    >>> min_max(2, 3, 1)
    (1, 3)
    >>> min_max(2, 1, 3)
    (1, 3)
    >>> min_max(3, 1, 2)
    (1, 3)
    >>> min_max(3, 2, 1)
    (1, 3)
    """
    if a < b:
        if b < c:
            return (a, c)
        elif a < c:
            return (a, b)
        else:
            return (c, b)
    else:
        if a < c:
            return (b, c)
        elif b < c:
            return (b, a)
        else:
            return (c, a)


def run():
    vals = [int(x) for x in input().split()]
    x, y = min_max(*vals)
    print(x, y)


if __name__ == '__main__':
    run()



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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, K; scanf("%d %d", &N, &K);
  vector<ll> X(N), Y(N);
  vector<pair<ll, ll>> P(N);
  for (int i = 0; i < N; ++i) {
    scanf("%lld %lld", &X[i], &Y[i]);
    P[i] = make_pair(X[i], Y[i]);
  }
  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end());
  ll ans = numeric_limits<ll>::max();
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      for (int k = 0; k < N; ++k) {
        for (int l = k + 1; l < N; ++l) {
          ll a = X[i], b = X[j], c = Y[k], d = Y[l];
          int cnt = count_if(P.begin(), P.end(),
                             [a, b, c, d](pair<ll, ll> p) {
                               return a <= p.first and p.first <= b and
                               c <= p.second and p.second <= d;
                             });
          if (cnt >= K) {
            ans = min(ans, abs(X[i] - X[j]) * abs(Y[k] - Y[l]));
          }
        }
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

template<typename T>
struct CumulativeSum{
private:
    vector<T> s;
public:
    void init(vector<T>& v){
        s.push_back(0);
        for(int i=0; i<v.size(); i++){
            s.push_back(s.back() + v[i]);
        }
    }
    T sum(int l, int r){
        l = (l < 0 ? 0 : l);
        r = (r >= s.size() ? s.size()-1 : r);
        return s[r] - s[l];
    }
};

string S, T;
vector<int> tmp;
CumulativeSum<int> SA, SB, TA, TB;
int Q;

signed main(){
    cin >> S >> T;

    tmp.assign(S.size(), 0);
    rep(i, S.size()){
        if(S[i] == 'A') tmp[i] = 1;
    }
    SA.init(tmp);
    tmp.assign(S.size(), 0);
    rep(i, S.size()){
        if(S[i] == 'B') tmp[i] = 1;
    }
    SB.init(tmp);
    tmp.assign(T.size(), 0);
    rep(i, T.size()){
        if(T[i] == 'A') tmp[i] = 1;
    }
    TA.init(tmp);
    tmp.assign(T.size(), 0);
    rep(i, T.size()){
        if(T[i] == 'B') tmp[i] = 1;
    }
    TB.init(tmp);

    cin >> Q;
    rep(i, Q){
        int ls, rs, lt, rt;
        cin >> ls >> rs >> lt >> rt;
        if((SA.sum(ls-1, rs)-SB.sum(ls-1,rs)+333333)%3
            == (TA.sum(lt-1, rt)-TB.sum(lt-1, rt)+333333)%3){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }
}

Measured memory_bytes: 5728
n = int(input())
arr = list(map(int,input().split()))
arr.sort()

count = 0

for a in range(n-2):
    k = a+2
    for j in range(a+1,n):
        while (k < n and arr[a] + arr[j] > arr[k]):
            k+=1
        
        if k>j:
            count += k-j-1
        
print(count)

Measured memory_bytes: 42860
#include <bits/stdc++.h>
                                        #include<iostream>
                                        #include<cstdio>
                                        #include<vector>
                                        #include<queue>
                                        #include<map>
                                        #include<cstring>
                                        #include<string>
                                        #include <math.h>
                                        #include<algorithm>
                                    //    #include <boost/multiprecision/cpp_int.hpp>
                                        #include<functional>
                                #define int long long
                                        #define inf  1000000007
                                        #define pa pair<int,int>
                                        #define ll long long
                                        #define pal pair<double,pa>
                                        #define ppa pair<int,int>
                                        #define ppap pair<pa,pa>
                                        #define ssa pair<string,int>
                                        #define  mp make_pair
                                        #define  pb push_back
                                        #define EPS (1e-10)
                                        #define equals(a,b) (fabs((a)-(b))<EPS)
                                  #define VI vector<int>
                                        using namespace std;


int gcd(int a,int b){
	if(a<b) return gcd(b,a);
	if(b==0) return a;
	if(a%b==0) return b;
	return gcd(b,a%b);
}
int dp[30][2002]={0};
           signed main(){
               int n;
  cin>>n;
           	dp[0][0]=1;
           	
           	for(int i=1;i<=n;i++){
           	int k;
           		cin>>k;
           		for(int j=0;j<=2000;j++){
           			if(dp[i-1][j])dp[i][j]=1;
           			if(j>=k){
           				if(dp[i-1][j-k])dp[i][j]=1;
           				
           			}
           		}
           	
           	}
            
           	int q;
           	cin>>q;
           	
           	for(int i=0;i<q;i++){
           	int  u;
           		cin>>u;
           		cout<<(dp[n][u] ? "yes":"no")<<endl;
           	
           	}
           	
           }
             

Measured memory_bytes: 3188
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {
            var K = cin.ReadInt;
            var S = cin.ReadInt;

            var ans = 0;

            for (int i = 0; i <= K; i++){
                for (int j = 0; j <= K; j++){
                    int z = S - i - j;
                    if (0 <= z && z <= K){
                        ans += 1;
                    }
                }
            }

            WriteLine(ans);
        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);

int main() {
string s;
cin >> s;
rep(i,4)cout << s.at(i);
cout <<" ";
for(int i = 4; i < 12; i++)cout << s.at(i);
cout << endl;
}


Measured memory_bytes: 3528
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

char s[205], t1[205], t2[205];

int main()
{
	scanf("%s", s);
	int len = strlen(s);
	int w = len;
	for (int j = 1; j <= 200; j++){
		int tot = -1;
		for (int i = 0; i <= (len - 3) / 2; i++)	t1[i] = s[i];
		for (int i = (len - 3) / 2 + 1; i < len - 1; i++){
			t2[++tot] = s[i];	
		}
		t2[++tot] = '\0';
//		puts(t2);
		if (strcmp(t1, t2) == 0){
//			puts(t1);
//			puts(t2);
			if (len == 1)	len++;
			printf ("%d\n", len - 1);
			return 0;
		}
		else{
//			puts(t1);
//			puts(t2);
			len--;
//			printf ("%d\n", len);
			memset(t1, 0, sizeof(t1));
			memset(t2, 0, sizeof(t2));
		}
	}
}

			


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
                    
                    
int main(){
    string s, t;
    cin >> s >> t;
    int ans = 0;

    for(int i = 0; i < s.size(); i++) {
        if(s[i] != t[i]) {
            ans++;
        }
    }

    cout << ans << endl;
            
}

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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  string a, b;
  cin >> a >> b;
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());
  if (a < b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int i;
  if(a>b){
    for(i=0;i<a;i++) cout << b;
    cout << "\n";
    return 0;
  }
  else if(b>=a){
    for(i=0;i<b;i++) cout << a;
    cout << "\n";
    return 0;
  }
}

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

bool isNum(char i) {
    if ('0' <= i && i <= '9') return true;
    else return false;
}
int main(void) {
    int A,B;cin>>A>>B;
    string S;cin>>S;
    for (int i = 0; i < S.size(); i++) {
        if (i == A) {
            if (S[i] != '-') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (!isNum(S[i])) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        String W = sc.next();
        int count = 0;
        while (sc.hasNext()){
            String T = sc.next();
            T = T.toLowerCase();
            if (T.equals("END_OF_TEXT"))
                break;
            if (T.equals(W))
                count++;
        }
        System.out.println(count);
    }
}



Measured memory_bytes: 26392
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <string>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
const int dx[2] = {1,0};
const int dy[2] = {0,1};

struct state{int x,y,ct;};

string judge_length(string s1, string s2){
	if(s1.size() > s2.size()){
		return s1;
	}else if(s1.size() < s2.size()){
		return s2;
	}else{
		REP(i,s1.size()){
			if(s1[i] > s2[i])return s1;
			else if(s1[i] < s2[i])return s2;
		}
	}
	return s1;
}

int main(){
	int w,h;
	while(cin >> w >> h,w){
		vector<vector<char> > mp(h+1,vector<char>(w+1));
		string s;
		REP(i,h){
			cin >> s;
			REP(j,w){
				if(s[j] - '0' > 9){
					mp[i+1][j+1] = -1;
				}else{
					mp[i+1][j+1] = s[j];
				}
			}
		}
		vector<vector<string>> dp(h+1,vector<string>(w+1));
		string max_num;
		for(int i = 1;i<h+1;i++){//dp
			for(int j = 1;j<w+1;j++){
				if(mp[i][j] < 0)continue;
				dp[i][j] = judge_length(dp[i-1][j],dp[i][j-1]) + mp[i][j];
				if(dp[i][j][0] == '0')dp[i][j].erase(dp[i][j].begin());
				max_num = judge_length(max_num,dp[i][j]);
			}
		}
	cout << max_num << endl;
	}
	return 0;
}

Measured memory_bytes: 3312
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define INF (int) 2e9
#define MOD (int) 1e9 + 7

int main(){
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    rep(i, n){
        int h;
        cin >> h;
        if(h>=k) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>

int main(){
  long long int N, X, L;
  scanf("%lld%lld", &N, &X);
  
  long long int D = 0;
  long long int ans = 1;
  for(long long int i = 0; i < N; i++){
    scanf("%lld", &L);
    D += L;
    if(D <= X){
      ans++;
    }
  }
  
  std::cerr << "Answer:" << std::endl;
  std::cout << ans << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long int 
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define from(i,n)       for(int i=0;i<(int)n;i++)
#define from_j(i,j,n)   for(int i=j;i<(int)n;i++)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}
 
int32_t main()
{
    c_p_c();
    int n,m; cin>>n>>m;
    string s[n];
    from(i,n)cin>>s[i];
    int arr[n][m];
    
    from(i,n){
        from(j,m){
            if(s[i][j]=='#')arr[i][j]=-1;
            else arr[i][j]=0;
        }
    }
    if(!arr[0][0])arr[0][0]=1;
    from(i,n){
        from(j,m){
            if((i==0)&&(j==0))continue;
            if(arr[i][j]==-1){
                arr[i][j]=0;
                continue;
            }
            else if(i==0){
                arr[i][j]= arr[i][j-1];
            }
            else if(j==0){
                arr[i][j]=arr[i-1][j];
            }
            else arr[i][j] = (arr[i-1][j]+arr[i][j-1])%mod;
        }
    }
    // from(i,n){
    //     from(j,m){
    //         cout<<arr[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    
    
    
    cout<<arr[n-1][m-1];
    return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

template<class T> inline bool chmin(T &a,T b){
    if (a>b){
        a=b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if (a<b){
        a=b;
        return true;
    }
    return false;
}

const int MAX_N=100010;

int N;
vector<vector<int>> G(MAX_N);
vector<ll> dp1(MAX_N,1),dp2(MAX_N,1);

void dfs(int v,int p){
    for (auto nv:G[v]){
        if (nv==p) continue;
        dfs(nv,v);
        dp1[v]*=dp1[nv]+dp2[nv];
        dp2[v]*=dp1[nv];
        dp1[v]%=MOD,dp2[v]%=MOD;
    }
}

int main(){
    cin >> N;
    rep(i,N-1){
        int s,t;
        cin >> s >> t;
        --s,--t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    dfs(0,-1);
    cout << (dp1[0]+dp2[0])%MOD << endl;
}

Measured memory_bytes: 14208