akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

public class Program
{
    private int N, W;
    private int[] v, w;
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        W = sc.NextInt();
        v = new int[N];
        w = new int[N];
        for (int i = 0; i < N; i++)
        {
            v[i] = sc.NextInt();
            w[i] = sc.NextInt();
        }

        var ans = new int[W + 1];
        for (int i = 1; i <= W; i++)
        {
            ans[i] = -1;
        }

        for (int i = 0; i < N; i++)
        {
            for (int j = W; j >= 0; j--)
            {
                if (ans[j] != -1 && j + w[i] <= W && ans[j + w[i]] < ans[j] + v[i])
                {
                    ans[j + w[i]] = ans[j] + v[i];
                }
            }
        }
        Console.WriteLine(ans.Max());
    }


    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}


class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}


Measured memory_bytes: 18324
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <sstream>
#include <list>
#include <map>

#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define repp(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define Sort(x) sort(x.begin(),x.end());
#define ll long long 
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi <vector<vector<vector<int>>> 
#define vc vector<char> 
#define vvc vector<vector<char>>
#define vvvc vector<vector<vector<char>>> 
#define INF 2000000000

using namespace std;

int main() {
	string s, ss;
	cin >> s >> ss;
	rep(i, 0, 3) {
		if (s[i] != ss[2 - i]) {
			cout << "NO" << endl;
			return 0;
}
	}

	cout << "YES" << endl;


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;
#define MAXN 2000
#define MOD 1000000007
#define LL long long
int n,k,r;
LL Comb[MAXN+5][MAXN+5];
int main(){
	scanf("%d%d",&n,&k);
	r=n-k;
	for(int i=0;i<=MAXN;i++)
		for(int j=0;j<=i;j++)
		if(!j||i==j)Comb[i][j]=1;
		else Comb[i][j]=(Comb[i-1][j]+Comb[i-1][j-1])%MOD;
	for(int i=0;i<k;i++){
		if(i==0){printf("%d\n",r+1);continue;}
		LL ans=0;
		for(int j=i;j<=r;j++)
		ans=(ans+(Comb[k-1][i]*(r-j+1))%MOD*Comb[j-1][i-1]%MOD)%MOD;
		printf("%lld\n",ans);
	}
}


Measured memory_bytes: 30080
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
// clang-format on

int N, M;

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

  cin >> N >> M;

  vector<int> sum(N);
  REP(i, N) sum[i] = -1;

  vector<int> s(N), c(N);
  REP(i, M) {
    cin >> s[i] >> c[i];
    s[i]--;  // 0-indexed
    if ((sum[s[i]] != -1 && sum[s[i]] != c[i]) || s[i] > N) {
      cout << -1 << endl;
      return 0;
    }
    sum[s[i]] = c[i];
  }

  vector<int> ans(N);
  REP(i, N) {
    if (sum[i] != -1) {
      ans[i] = sum[i];
    } else {
      ans[i] = 0;
    }
  }

  bool flag = false;
  REP(i, M) flag |= (s[i] == 0);
  if (N != 1 && ans[0] == 0 && !flag) ans[0] = 1;

  int zeroNum = 0;
  REP(i, N) {
    if (ans[i] == 0) zeroNum += 1;
  }
  if (zeroNum == N && N != 1) {
    cout << -1 << endl;
    return 0;
  }
  REP(i, N) cout << ans[i];
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/


//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    string s;
    cin >> s;
    string x = "ABC";
    if(s == x){
        cout << "ARC";
    }else{
        cout << "ABC";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3632
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();
    let n_k = lines.next().unwrap().unwrap();
    let mut n_k = n_k.split_whitespace();
    n_k.next();
    let k: i32 = n_k.next().unwrap().parse().unwrap();
    let h = lines.next().unwrap().unwrap();
    let h = h.split_whitespace().map(|s| s.parse::<i32>().unwrap());

    let ans = h.filter(|&h| h >= k).count();
    println!("{}", ans);
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    int H, A;
    cin >> H >> A;
    int ans = H / A;
    if (H % A) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
   
    
    
    int N, H;
    cin >> N >> H;
    
    vector<int> a(N), b(N);
    int mmax = 0, id = 0;
    rep(i, N) {
        cin >> a[i] >> b[i];
        if (mmax < a[i]) {
            mmax = a[i];
            id = i;
        }
    }
    
    vector<int> v;
    rep(i, N) {
        if (b[i] > mmax) v.eb(b[i]);
    }
    int dam = 0;
    
    sort(all(v), greater<int>());
    
    rep(i, sz(v)) {
        dam += v[i];
        if (dam >= H) { out(i + 1); return 0; }
    }
    
    out(sz(v) + (H - dam + (mmax - 1)) / mmax);
    
}




Measured memory_bytes: 1660
#include<bits/stdc++.h>
#include<stdio.h>
    
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define _USE_MATH_DEFINES
#define f first
//#define s second
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define INF 1000000000000000000
#define MAXN (int)(1e7)+1
#define MOD 1000000007
    
using namespace std;
    
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pwi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vector<pair<ll,ll > > > wGraph;
typedef vector<vector<ll> > graph;
//typedef vector<vector<ll> > matrix;

    
int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout<<std::fixed;
    cout<<std::setprecision(2);
    
    ll N;
    cin>>N;
    vector<ll> L(N);

    for(int i = 0; i<N; ++i){
        cin>>L[i];
    }
    
    ll resposta = 0;
    for(int i = 0; i<N; ++i){
        for(int j = i+1; j<N; ++j){
            for(int k = j+1; k<N; ++k){
                vector<ll> lados = {L[i], L[j], L[k]};
                set<ll> s;
                s.insert(L[i]);
                s.insert(L[j]);
                s.insert(L[k]);
                sort(lados.begin(), lados.end());
                if(lados[0]+lados[1] > lados[2] && s.size() == 3){
                    resposta++;
                }
            }
        }
    }
    cout<<resposta<<endl;

    return 0;   
}

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

 using namespace std;

 int main() {
   int X, Y, a;

   cin >> X >> Y;
   a = 0;
   if (X == 1) a += 300000;
   else if (X == 2) a += 200000;
   else if (X == 3) a += 100000;

   if (Y == 1) a += 300000;
   else if (Y == 2) a += 200000;
   else if (Y == 3) a += 100000;

   if (X == 1 && Y == 1) a += 400000;

   cout << a << endl;
 }


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        q_2();
    }

    private static void q_1() {
        try(Scanner scan = new Scanner(System.in)) {
            String b = scan.next();

            switch (b) {
                case "A":
                    System.out.println("T");
                    break;
                case "T":
                    System.out.println("A");
                    break;
                case "C":
                    System.out.println("G");
                    break;
                case "G":
                    System.out.println("C");
                    break;
            }
        }
    }

    private static void q_2() {
        try(Scanner scan = new Scanner(System.in)) {
            String S = scan.next();

            List<Integer> cntList = new ArrayList<>();
            int cnt = 0;

            for(int i=0; i<S.length(); i++) {
                char b = S.charAt(i);

                switch (b) {
                    case 'A':
                        cnt ++;
                        break;
                    case 'T':
                        cnt ++;
                        break;
                    case 'C':
                        cnt ++;
                        break;
                    case 'G':
                        cnt ++;
                        break;
                    default:
                        cntList.add(cnt);
                        cnt = 0;
                }
            }
            cntList.add(cnt);
            
            Integer result = Collections.max(cntList);

            System.out.println(result);
        }
    }
}


Measured memory_bytes: 23252
#include<stdio.h>
int main(void){
    int N,i,j;
    scanf("%d",&N);
    int d[N+1],S=0,a=0;
    for(j=1;j<=N;j++){
        scanf("%d",&d[j]);
    }
    if(N==2){
        S = d[1]*d[2];
    }else{
        for(i=0;i<=N-2;i++){
        a += d[N-i];
        S += d[N-i-1]*a;
        }
    }
    printf("%d",S);
    return 0;
}

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

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

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int a, b;
  cin >> a >> b;

  // 解答
  cout << (a > b ? a - 1 : a) << endl;

  return 0;
}


Measured memory_bytes: 256
s = gets.chomp.split('')
a = []
ans = 0
[0, 1].repeated_permutation(s.length-1) do |bits|
  a.clear
  a << s[0]
  # p bits
  bits.each_with_index do |bit,i|
    # p bit
    if bit == 0
      a << s[i+1]
    elsif bit == 1
      a<< "+" + s[i+1]
    end
  end
  ans += (eval a.join)
end
p ans

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

 int main() {
 int N;
 cin >> N;
 vector<int> a(N);
 int sum = 0;

 for (int i = 0; i < N; ++i) {
 cin >> a[i];
 sum += a[i];
 }

 int mini = sum;
 int prefix_sum = 0;
 for (int i = 0; i < N; ++i) {
 cin >> a[i];
 prefix_sum += a[i];
 mini = min(mini, abs(prefix_sum - (sum - prefix_sum)));
 }

 cout << mini << endl;
 return 0;
 }


Measured memory_bytes: 256
l,r = map(int,input().split())
lb = l.bit_length()
rb = r.bit_length()
ans = 0
mod = 10**9+7
def ignorel(r):
  ret = 0
  cntr = 0
  rb = r.bit_length()
  for i in range(rb-1)[::-1]:
    if r&1<<i:
      ret += 2**cntr*3**i
      cntr += 1
  ret += 2**cntr
  return ret%mod
def ignorer(l):
  cntl = 0
  ret = 0
  lb = l.bit_length()
  for i in range(lb)[::-1]:
    if l&1<<i == 0:
      ret += 2**cntl*3**i
      cntl += 1
  ret += 2**cntl
  return ret%mod
for i in range(lb+1,rb):
  ans += 3**(i-1)
  ans %= mod
if lb != rb:
  ans += ignorer(l)
  ans += ignorel(r)
  ans %= mod
  print(ans)
else:
  def from0(x):
    if x == 0:
      return 1
    elif x == 1:
      return 3
    xb = x.bit_length()
    ret = 3**(xb-1)+2*from0(x-(1<<(xb-1)))
    return ret
  def calc(l,r):
    ret = 0
    lb = l.bit_length()
    rb = r.bit_length()
    if l > r:
      return 0
    if l == r:
      return 1
    if l == 2**(lb-1):
      return ignorel(r)
    elif r == 2**rb-1:
      return ignorer(l)
    for i in range(lb)[::-1]:
      if l&1<<i == 0 and r&1<<i:
        ret += from0((1<<i)-1-(l&(1<<i)-1))
        ret += from0(r&((1<<i)-1))
        ret += calc((l&((1<<i)-1))+(1<<i),(r&((1<<i)-1))+(1<<i))
        break
    return ret%mod
  ans += calc(l,r)
  print(ans%mod)

Measured memory_bytes: 38384
using System;
class Program
{
	static void Main(string[] args)
	{
		int kazuTestcase = int.Parse(Console.ReadLine());
		//string[] kekka = new string[kazuTestcase];
		int AC=0, WA=0, TLE=0, RE=0;

		for(int count=0; count<kazuTestcase; count++)
		{
			string kekka = Console.ReadLine();
			if(kekka=="AC")
			{
				AC++;
			}else if(kekka == "WA")
			{
				WA++;
			}else if(kekka == "TLE")
			{
				TLE++;
			}else if(kekka == "RE")
			{
				RE++;
			}
		}



		//出力
		Console.WriteLine("AC x " + AC);
		Console.WriteLine("WA x " + WA);
		Console.WriteLine("TLE x " + TLE);
		Console.WriteLine("RE x " + RE);
	}
}

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

typedef long long ll;


ll f(ll b, ll n){
    if( n < b ) return n;
    return f(b,n/b) + (n%b);
}

int main(){

    ll n,s; cin >> n >> s;

    ll ans = 0;
    if( s == n ) {
	cout << n + 1 << endl;
	return 0;
    }
    for( ll b = 2; b*b <= n; b++ ) {
	if( f(b,n) == s  ){
	    cout << b << endl;
	    return 0;
	}
    }
    for( ll p = sqrt(n); p > 0; p-- ) {
	ll b = (n-s)/p + 1;
	if( b > 1 and f(b,n) == s ) {
	    cout << b << endl;
	    return 0;
	}
    }

    cout << -1 << endl;
    return 0;
}


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

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

    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        if(a % 2 == 1){
            continue;
        }
        if((a % 3 == 0) || (a % 5 == 0)){
            continue;
        }
        cout << "DENIED";
        return 0;
    }
    cout << "APPROVED";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;

ll cnt = 0;

void merge(vector<int>& a, int left, int mid, int right) {
  int n1 = mid - left, n2 = right - mid;
  vector<int> l(n1+1), r(n2+1);
  rep(i, n1) l[i] = a[left + i];
  rep(i, n2) r[i] = a[mid + i];
  l[n1] = INF;
  r[n2] = INF;
  int i = 0, j = 0;
  FOR(k, left, right) {
    if (l[i] <= r[j]) {
      a[k] = l[i++];
    }
    else {
      a[k] = r[j++];
      cnt += mid + j - k - 1;
    }
  }
}

void mergeSort(vector<int>& a, int left, int right) {
  if (left+1 < right) {
    int mid = (left + right) / 2;
    mergeSort(a, left, mid);
    mergeSort(a, mid, right);
    merge(a, left, mid, right);
  }
}

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

  mergeSort(a, 0, n);

  cout << cnt << endl;


  
  return 0;
}


Measured memory_bytes: 4328
#include<iostream>

int w;

int solve(int w){
	int ans = 1150;
	if(w>10)
		ans += 125*(w-10);
	if(w>20)
		ans += 15*(w-20);
	if(w>30)
		ans += 20*(w-30);
	return ans;
}

int main(){
	while(true){
		std::cin >> w;
		if(w==-1)
			return 0;
		std::cout << 4280-solve(w) << std::endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

void solve(){
    string s;
    cin >> s;
    int ans = 0;
    for(auto c : s){
        ans = (ans + c - '0') % 9;
    }
    cout << (ans == 0 ? "Yes" : "No") << endl;
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();
}


Measured memory_bytes: 3768
h, w = map(int, input().split())
s = [0] * h
for i in range(h):
    s[i] = input()


mx = [0, 1, 1, 1, 0, -1, -1, -1]
my = [1, 1, 0, -1, -1, -1, 0, 1]
for hi in range(h):
    for wi in range(w):
        if s[hi][wi] == '#':
            print('#', end="")
            continue
        cnt = 0
        for mi in range(8):
            nx = wi + mx[mi]
            ny = hi + my[mi]
            if (nx >= w) or (ny >= h):
                continue
            if (nx < 0) or (ny < 0):
                continue
            if s[ny][nx] == '.':
                continue
            cnt += 1
        print(cnt, end="")
    print("")


Measured memory_bytes: 3444
#include <stdio.h>
#include <algorithm>
using namespace std;
int N,W,v[200],w[200];
int dp[20000][200] = {0};
int ex(int sum,int n)
{
    int res=0;
    if(dp[sum][n] != 0)return dp[sum][n];
    if(n == N)return 0;
    if(sum + w[n] > W)return ex(sum,n + 1);
    dp[sum][n] = max(ex(sum,n + 1),ex(sum + w[n],n + 1) + v[n]);
    return dp[sum][n];
}
int main()
{
    scanf("%d%d",&N,&W);
    for(int i = 0; i < N; i++)
    {
        scanf("%d%d",&v[i],&w[i]);
    }
    printf("%d\n",ex(0,0));
}

Measured memory_bytes: 9212
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	cnt := 0
	for i := 0; i < n; i++ {
		var p int
		fmt.Scan(&p)
		if p != i + 1 {
			cnt++
		}

		if cnt > 2 {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}


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

using namespace std;
typedef long long ll;

// #define DEBUG




int main()
{
#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int a, b, c;
    string ans;
    cin >> a >> b >> c;
    int d[3] = {a, b, c};
    sort(d, d+3);

    if (a == d[2]) ans = "A";
    else if (b == d[2]) ans = "B";
    else if (c == d[2]) ans = "C";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
long long n,x,arr[105],kcl;
bool ada[105];
int main(){
	cin>>x>>n;

	for(int i =1;i<=n;i++){
		cin>>arr[i];
		ada[arr[i]]=1;
	}
	kcl=1e9;
	if(!ada[x]){
		kcl=x;
	}
	
	for(int i =1;i<=n;i++){
		if(!ada[arr[i]+1]){
			if(abs(arr[i]+1-x)<=abs(kcl-x)){
				if(abs(arr[i]+1-x)==abs(kcl-x)){
					if(arr[i]+1<kcl)kcl=arr[i]+1;
				}
				else kcl=arr[i]+1;
			}
		}
		if(!ada[arr[i]-1]){
			if(abs(arr[i]-1-x)<=abs(kcl-x)){
				if(abs(arr[i]-1-x)==abs(kcl-x)){
					if(arr[i]-1<kcl)kcl=arr[i]-1;
				}
				else kcl=arr[i]-1;
			}
		}
	}
	cout<<kcl<<endl;
}

Measured memory_bytes: 3636
n, m = (int(i) for i in input().split())
abstore = [[int(i) for i in input().split()] for j in range(n)]
abstore.sort()
bought = 0
ans = 0
for a, b in abstore:
    if b < m - bought:
        bought += b
        ans += a * b
    else:
        ans += a * (m - bought)
        break
print(ans)

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;

template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}


int main(int argc, char *argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG = 1;}

  int N; cin>>N;
  ll a[N]; CINA(a,N);
  ll ans = 0LL;
  int idx1 = 0;
  int idx2 = -1;
  ll temp = 0LL;
  ll semp = 0LL;
  while(idx2<N){
    ++idx2;
    temp ^= a[idx2];
    semp += a[idx2];
    if(temp!=semp){
      while(temp!=semp){
        temp ^= a[idx1];
        semp -= a[idx1];
        ans += (idx2-idx1);
        ++idx1;
      }
    }
  }
  ll n = idx2-idx1;
  ans += n*(n-1)/2+n;
  printf("%Ld\n",ans);

}

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

int main(void){
    int n,a;
    std::cin >> n >> a;

    if(n > a && n < 500){
        std::cout << "No";
        return 0;
    }

    int box = n%500;
    if(n <= a || box <= a){
        std::cout << "Yes";
        return 0;
    }

    else std::cout << "No";
    return 0;
}



Measured memory_bytes: 256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())[:-1]
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
A,B = map(int,input().split())
print(A*B)

Measured memory_bytes: 10552
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
using namespace std;


void solve(vector<string> board){
	vector< vector<int> > flag(9, vector<int>(9, 1));
	for(int y=0;y<9;y++){
		vector<int> check(10, 0); 
		for(int x=0;x<9;x++){
			int n = board[y][x] - '0';
			check[n]++;
		}
		for(int x=0;x<9;x++){
			int n = board[y][x] - '0';
			if(check[n] > 1)flag[y][x] = false;
		}
	}
	for(int x=0;x<9;x++){
		vector<int> check(10, 0); 
		for(int y=0;y<9;y++){
			int n = board[y][x] - '0';
			check[n]++;
		}
		for(int y=0;y<9;y++){
			int n = board[y][x] - '0';
			if(check[n] > 1)flag[y][x] = false;
		}
	}
	for(int y=0;y<9;y+=3){ 
		for(int x=0;x<9;x+=3){
			vector<int> check(10, 0);
			for(int dy=0;dy<3;dy++)for(int dx=0;dx<3;dx++){
				int ny = y + dy;
				int nx = x + dx;
				int n = board[ny][nx] - '0';
				check[n]++;
			}
			for(int dy=0;dy<3;dy++)for(int dx=0;dx<3;dx++){
				int ny = y + dy;
				int nx = x + dx;
				int n = board[ny][nx] - '0';
				if(check[n] > 1)flag[ny][nx] = false;
			}
		}
	}
	for(int y=0;y<9;y++){
		for(int x=0;x<9;x++){
			if(!flag[y][x])cout << "*";
			else cout << " ";
			cout << board[y][x];
		}
		cout << endl;
	}
}

int main(){
	int n;
	scanf("%d\n", &n);
	for(int t=0;t<n;t++){
		vector<string> board;
		for(int i=0;i<9;i++){
			string tmp, str;
			getline(cin, tmp);
			for(int j=0;j<tmp.size();j++)if(tmp[j] != ' ')str += tmp[j];
			board.push_back(str);
		}
		if(t > 0)cout << endl;
		solve(board);
	}
	return 0;
}

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

int main()
{
	string S;

	cin >> S;

	int a = S.length();
	int b = 0;
	int count = 0;

	for (int i = 0; i < (a / 2); i++) {
		if (S[i] != S[a + b - 1])
			count++;
		b--;
	}

	cout << count << endl;
	return 0;

}

Measured memory_bytes: 256
n, ma, mb = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
x.insert(0, [0, 0, 0])
inf = 114514
dp = [[[inf] * (10 * n + 1) for _ in range(10 * n + 1)] for _ in range(n + 1)]
for i in range(n + 1):
    dp[i][0][0] = 0
suma, sumb = 0, 0
for i in range(1, n + 1):
    suma += x[i][0]
    sumb += x[i][1]
    for j in range(suma + 1):
        for k in range(sumb + 1):
            dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j][k])
            if j >= x[i][0] and k >= x[i][1]:
                dp[i][j][k] = min(dp[i - 1][j][k], dp[i - 1][j - x[i][0]][k - x[i][1]] + x[i][2])
ans = 114514
for i in range(1, 10 * n + 1):
    for j in range(1, 10 * n + 1):
        if i * mb == j * ma:
            ans = min(ans, dp[n][i][j])
print(ans if not ans == 114514 else -1)

Measured memory_bytes: 127400
#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> ;
const int INF = 1e9;
const int MOD = 1000000007;
int n = 100005;

vector<vector<P>> graph(n,vector<P>());
vector<bool> has_connected(n,false);

ll prim(){
    ll res = 0;
    priority_queue<P,vector<P>,greater<P>> pq;
    pq.push(P(0,0));
    while(!pq.empty()){
        P now = pq.top();
        pq.pop();
        int c,k;
        tie(c,k) = now;
        if(has_connected[k]) continue;
        res += c;
        has_connected[k] = true;
        for(P next:graph[k]){
            if(has_connected[next.second]) continue;
            pq.push(next);
        }
    }
    return res;
}

int main(){
    cin >> n;
    vector<P> X(n),Y(n);
    rep(i,n){
        cin >> X[i].first >> Y[i].first;
        X[i].second = Y[i].second = i;
    }

    sort(X.begin(),X.end());
    sort(Y.begin(),Y.end());

    rep(i,n-1){
        int s = X[i].second;
        int t = X[i+1].second;
        int w = X[i+1].first - X[i].first;
        graph[s].push_back(P(w,t));
        graph[t].push_back(P(w,s));
    }

    rep(i,n-1){
        int s = Y[i].second;
        int t = Y[i+1].second;
        int w = Y[i+1].first - Y[i].first;
        graph[s].push_back(P(w,t));
        graph[t].push_back(P(w,s));
    }

    ll ans = prim();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11000
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
pragma(inline, true) T[] Reads(T)() { return readln.split.to!(T[]); }
alias reads = Reads!int;
pragma(inline, true) void scan(Args...)(ref Args args) {
    string[] ss = readln.split;
    foreach (i, ref arg ; args) arg = ss[i].parse!int;
}

void main() {
    int k, x; scan(k, x);
    foreach (i; x-k+1..x+k) {
        writef("%s ", i);
    }
    writeln();
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private static final long MOD = 1_000_000_007;

    private void solve(Scanner sc) {
        int n = sc.nextInt();
        int m = sc.nextInt();
        long sum1 = 0;
        for (int i = 0; i < n; ++i) {
            long x = sc.nextInt();
            sum1 = (sum1 + (i * x - (n - i - 1) * x)) % MOD;
        }
        long sum2 = 0;
        for (int i = 0; i < m; ++i) {
            long y = sc.nextInt();
            sum2 = (sum2 + (i * y - (m - i - 1) * y)) % MOD;
        }

        _out.println((sum1 * sum2) % MOD);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 65052
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[200010],b[200010];
  //memset(a,0,sizeof(a));
   memset(b,0,sizeof(b));
   for(int i=2;i<=n;i++){
       cin>>a[i];
   }for(int i=2;i<=n;i++){
       b[a[i]]++;
   }for(int i=1;i<=n;i++){
       cout<<b[i]<<endl;
   }}

Measured memory_bytes: 5196
n, T = map(int, input().split())
c = [0]*n
t = [0]*n
for i in range(n):
    c[i], t[i] = map(int, input().split())

DEKAI = 1<<30
MIN = DEKAI
for i in range(n):
    if t[i] <= T:
        MIN = min(MIN, c[i])

if MIN == DEKAI:
    print("TLE")
else:
    print(MIN)

Measured memory_bytes: 3064
S=input()
if S=='zyxwvutsrqponmlkjihgfedcba':
  print(-1)
  exit()
alp='abcdefghijklmnopqrstuvwxyz'
N=len(S)
if N<26:
  T=S+alp
  i=0
  while T.index(alp[i])<N:
    i+=1
  print(S+alp[i])
  exit()
  
i=-1
nums=[alp.index(S[i])]
while max(nums)==nums[-1]:
  i-=1
  nums.append(alp.index(S[i]))

out=S[:-len(nums)]
tmp=26
for i in nums[:-1]:
  if i>nums[-1] and tmp>i:
    tmp=i
    
print(out+alp[tmp])


Measured memory_bytes: 3064
package main

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

func main() {
	array := nextInts(5)
	l := nextInt()
	if (array[4] - array[0]) > l {
		fmt.Printf(":(")
	} else {
		fmt.Printf("Yay!")
	}
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func MaxIn2Values(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinIn2Values(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 640
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
counts =0
max1 = 0
for i in set(s):
  counts = s.count(i) - t.count(i)
  max1 = max(max1,counts)
print(max1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
#define inf 1e9
#define F first
#define S second
#define dbg(x) cout<<#x<<" value : "<<x<<"\n";
#define rep(i,j,k) for(int i = (j); i <= (k); i++)
#define rep__(i,j,k) for(int i = (j); i < (k); i++)
#define per(i,j,k) for(int i = (j); i >= (k); i--)
#define per__(i,j,k) for(int i = (j); i > (k); i--)
#define mst(a,b) memset(a,b,sizeof(a))
#define sf(n) scanf("%d",&n)
#define stf(n,m) scanf("%d%d",&n,&m)
#define pf(n) printf("%d\n",n)
#define sllf(n) scanf("%lld",&n)
#define pllf(n) printf("%lld\n",n)
const int N=3e3+10;
const int mod=1e9+7;
int main()
{
	int n,m;
	stf(n,m);
	if(m*2>=n)cout<<"0"<<endl;
	else cout<<n-m*2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
bool s[100005];
int ns[100005];
int ns2[100005];
int main(){
	int i,j,k;
	int a,b;
	int n;
	memset(s,false,sizeof(s));
	s[2]=true;
	for(i=3;i<100000;i++){
		s[i]=true;
		for(j=2;j<400;j++){
			if(i<=j)break;
			if(i%j==0){
				s[i]=false;
				break;
			}
		}
	}
	for(i=2;i<=100000;i++){
		ns[i]=ns[i-1];
		if(i%2==0)continue;
		if(s[i] && s[(i+1)/2])ns[i]++;
	}
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a>>b;
		ns2[i]=ns[b]-ns[a-1];
	}
	for(i=0;i<n;i++){
		cout<<ns2[i]<<endl;
	}
	return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 6;
int h, w, k, res;
char grid[N][N];

int main() {
    cin >> h >> w >> k;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> grid[i][j];
        }
    }
    for (int p = 0; p < (1 << h); ++p) {
        for (int q = 0; q < (1 << w); ++q) {
            int cnt = 0;
            for (int i = 0; i < h; ++i) {
                for (int j = 0; j < w; ++j) {
                    if ((p & (1 << i)) == 0 && (q & (1 << j)) == 0 && grid[i][j] == '#') {
                        ++cnt;
                    }
                }
            }
            if (cnt == k) {
                ++res;
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3620
/**
 *  winners never quit
**/

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define pp pop_back
#define mp make_pair
typedef long long Long;
void FastIO(){
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
}

const int N = 1e5;

int main()
{
  FastIO();
  int tc, ca = 0;
  Long n;
  cin >> n;
  Long ts = 26;
  string ans;
  while (n){
    if (n%ts==0){
      ans += 'z';
      n--;
      n /= ts;
    }
    else {
      ans += char((n%ts)+96);
      n /= ts;
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <cassert>
#include <algorithm>
using namespace std;

#define DEBUG (0)

#if DEBUG
#define DPRINTF(...)  printf("D(L%d) %s: ", __LINE__, __func__); printf(__VA_ARGS__)
#else
#define DPRINTF(...)
#endif // DEBUG

int main()
{
  const int MAX_S = 10000;
  const int MAX_T = 500;
  int numOfS, numOfT;
  int s[MAX_S], t[MAX_T];

  cin >> numOfS; cin.ignore();
  for (int i = 0; i < numOfS; i++) {
    cin >> s[i];
  }

  cin >> numOfT; cin.ignore();
  for (int i = 0; i < numOfT; i++) {
    cin >> t[i];
  }

#if DEBUG
  DPRINTF("ARRAY S :");
  for (int i = 0; i < numOfS; i++)
    cout << " " << s[i];
  cout << endl;

  DPRINTF("ARRAY T :");
  for (int i = 0; i < numOfT; i++)
    cout << " " << t[i];
  cout << endl;
#endif

  sort(s, s + numOfS);
  sort(t, t + numOfT);

#if DEBUG
  DPRINTF("ARRAY S :");
  for (int i = 0; i < numOfS; i++)
    cout << " " << s[i];
  cout << endl;

  DPRINTF("ARRAY T :");
  for (int i = 0; i < numOfT; i++)
    cout << " " << t[i];
  cout << endl;
#endif

  int cnt = 0;
  int i = 0, j = 0;
  while (i < numOfS && j < numOfT)
  {
    if (s[i] == t[j])
    {
      DPRINTF("MATCH : %d\n", s[i]);
      cnt++;
      i++;
      j++;
    }
    else if (s[i] > t[j])
    {
      j++;
    }
    else // s[i] < t[j]
    {
      i++;
    }
  }

  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste

// #include "UnionFind.hpp"
// #include "power.hpp"

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int ans = 0;
    if (N <= 100) {
        for (int i = 1; i <= N; i++) {
            if ((N / i) == (N % i)) ans += i;
        }
    } else {
        for (int i = 1; i < sqrt(N) ; i++) {
            int temp = N % i;
            // cout << i << " " << temp << " " << N / i << " " << N % i << endl;
            if (temp == 0) {
                ans += ((N / i) - 1);
                // cout << ans << " " << i << endl;
            } 
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1234567;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    string S;
    cin >> S;
    int ans = 0;
    int cnt = 0;
    for(int i = 0; i < S.size(); i++) {
        if(S[i] == 'W') {
            ans+=i-cnt;
            cnt++;
        }
    }
    cout << ans << endl;
}


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

int main() {
	vector<char> o(4);
	rep(i, 4) {
		cin >> o[i];
	}
	sort(o.begin(), o.end());
	if (o[0] == o[1] && o[1] != o[2] && o[2] == o[3]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

struct Node {
    int key;
    Node *next, *prev;
};

Node *nil;

Node* listSearch(int key) {
    Node *cur = nil->next;
    while (cur != nil && cur->key != key) {
        cur = cur->next;
    }
    return cur;
}

void init() {
    nil = new Node;
    nil->next = nil;
    nil->prev = nil;
}

void printList() {
    Node *cur = nil->next;
    int isf = 0;
    while (true) {
        if (cur == nil)
            break;
        if (isf++ > 0)
            printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

void deleteNode(Node *t) {
    if (t==nil)
        return;
    // cout << t->key << endl;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    // cout << nil->prev->key << endl;
    deleteNode(nil->prev);
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}

void insert(int key) {
    Node *x = new Node;
    x->key = key;

    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}



int main()
{
    int i, n, key;
    // int size = 0;
    string com;

    // int np = 0, nd = 0;
    scanf("%d", &n);
    init();

    for (int i = 0; i < n; i++)
    {
        // scanf("%s%d", com, &key);
        cin >> com;
        if (com == "insert")
        {
            // cout << key << endl;
            scanf("%d", &key);
            insert(key);
            // np++;
            // size++;
        }
        else if (com=="delete") {
            scanf("%d", &key);
            deleteKey(key);

        }
        else if (com == "deleteFirst")
        {
            deleteFirst();
            // nd++;
            // size--;
        }
        else
        {
            // cout << "a" << endl;
            deleteLast();
            // nd++;
            // size--;
        }
        // cout << nil->prev->key << " ";
        // printList();
    }
    printList();
}


Measured memory_bytes: 34592
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String str = in.nextLine();
        String ans = name(str);
        System.out.println(ans);
    }

    public static String name(String str) {
        char endChar = str.charAt(str.length() - 1);
        if (endChar == 's') {
            return str + "es";
        } else {
            return str + "s";
        }
    }
}




Measured memory_bytes: 38460
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        scanner.nextInt();
        final int m = scanner.nextInt();
        final List<IslandRelation> islandRelations = new ArrayList<>();

        for (int i = 0; i < m; i++) {
            final int a = scanner.nextInt();
            final int b = scanner.nextInt();
            islandRelations.add(new IslandRelation(a, b));
        }

        islandRelations.sort(Comparator.comparingInt(x -> x.right));

        final Set<Integer> brokenBridges = new HashSet<>();
        int previousBrokenBridge = islandRelations.get(0).right - 1;
        brokenBridges.add(previousBrokenBridge);
        for (final IslandRelation islandRelation : islandRelations) {
            if (islandRelation.left <= previousBrokenBridge) {
                continue;
            }

            previousBrokenBridge = islandRelation.right -1;
            brokenBridges.add(previousBrokenBridge);
        }

        System.out.println(brokenBridges.size());
    }

    static class IslandRelation {
        int left;
        int right;

        IslandRelation(final int left, final int right) {
            this.left = left;
            this.right = right;
        }
    }
}


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

using namespace std;
typedef long long ll;
int mod=1e9+7;
const int N=2e5+100;

struct edge
{
    int to,nex;
}ed[N<<1];
int head[N];
int tot=1;
void add_edge(int u,int v)
{
     ed[tot].to=v;
     ed[tot].nex=head[u];
     head[u]=tot++;
}
int dis[N],vis[N],siv[N];
void spfa()
{
    memset(dis,0x3f,sizeof dis);
    queue<int>q;q.push(1);vis[1]=1,dis[1]=0;
    while(q.size()){
        int k=q.front();q.pop();vis[k]=0;
        for(int i=head[k];i;i=ed[i].nex){
            int kk=ed[i].to;
            if(dis[kk]>dis[k]+1){
                dis[kk]=dis[k]+1;
                siv[kk]=k;
                if(!vis[kk]){
                    q.push(kk);
                    vis[kk]=1;
                }
            }
        }
    }
}
int main()
{
    int n,m;scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        add_edge(u,v);
        add_edge(v,u);
    }
   spfa();
   for(int i=2;i<=n;i++){
      if(!siv[i])  {printf("No\n");return 0;}
   }
   printf("Yes\n");
   for(int i=2;i<=n;i++) printf("%d\n",siv[i]);
    return 0;
}


Measured memory_bytes: 8928