akhauriyash/Code-Regression huggingface dataset:
"use strict";
main(require("fs").readFileSync("/dev/stdin", "UTF-8"));

function main(input) {
  let result = 0;
  input
    .split("\n")[0]
    .split(" ")
    .map(n => (result += Number(n)));
  if (result < 22) {
    console.log("win");
  } else {
    console.log("bust");
  }
}


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define MAX 10005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
#define MSET(x) memset(x, 0x3f, sizeof(x));
const int Max = 1001*105;
ll n,W,value,weight,ans;
//int knapSack[Max];

int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
    //*/
    cin >> n >> W;
    vector<ll>knapSack(Max, INT_MAX);
    knapSack[0] = 0;
    ans = 0;
    for(int i = 1; i <= n; i++){
      cin >> weight >> value;
      for(int j = ans; j >= 0; j--){
        //cerr << knapSack[j]<< " + "<< weight <<" <= "<<W<< " && "<< knapSack[j+value] << " > "<<knapSack[j] + weight;
        if(knapSack[j] + weight <= W && knapSack[j+value] > knapSack[j] + weight){
         // cerr << knapSack[j]<< " + "<< weight <<" <= "<<W<< " && "<< knapSack[j+value] << " > "<<knapSack[j] + weight;
          knapSack[j + value] = knapSack[j] + weight;
          ans = max(ans,j+value);
          //cerr <<"--> "<< ans << endl;
        }
        //cerr <<"--> "<< ans << endl;
    }
  }

    cout <<  ans << endl;

    return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define INF 1000000000

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef long double ld;

int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance(vec.begin(), itr);
  if (index != vec.size()) { // 発見できたとき
    return 1;
  } else { // 発見できなかったとき
    return 0;
  }
}

struct edge_t {
  int dest;
  int weight;
};

struct vertex_t {
  vector<edge_t> edges;
  vector<int> weight;

  // for dijkstra
  bool done; // confirm or not
  int cost;  // now cost
  int from;

  bool operator<(const vertex_t &another) const { // priority --> min
    return another.cost < cost;                   // order(cost)
  }

  bool operator>(const vertex_t &another) const { // priority --> min
    return another.cost > cost;                   // order(cost)
  }

  bool operator==(const vertex_t &another) const {
    return another.cost == cost; // order(cost)
  }

  vertex_t() {
    cost = INF;
    done = false;
  }
};

int bellman_ford(vector<vertex_t> &graph, int size, int start) {
  int i, j, k, count = 0;
  bool flag = false;
  graph[start].cost = 0;
  REP(i, size) {
    REP(j, size) {
      vertex_t cur = graph[j];
      for (edge_t edge : cur.edges) {
        if (cur.cost + edge.weight < graph[edge.dest].cost) {
          if (i == size - 1)
            flag = true;
          graph[edge.dest].cost = cur.cost + edge.weight;
        }
      }
    }
  }
  if (flag) {
    return 1;
  } else {
    return 0;
  }
}

class tree_t {
  public:
  bool is_leaf;
  tree_t *right;
  tree_t *left;

  tree_t() {
    is_leaf = false;
    right = NULL;
    left = NULL;
  }
};

vector<string> splitstr(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch : s) {
    if (ch == delim) {
      if (!item.empty())
        elems.push_back(item);
      item.clear();
    } else {
      item += ch;
    }
  }
  if (!item.empty())
    elems.push_back(item);
  return elems;
}

////////////////////////// let's code! /////////////////////////////

int i, j, k;

///// variables frequent to use /////

unsigned GetDigit(unsigned num) {
  unsigned digit = 0;
  while (num != 0) {
    num /= 10;
    digit++;
  }
  return digit;
}

int main() {

  string S;
  cin >> S;

  int len = S.length();

  vector<int> A = vector<int>();

  char prev = 'R';

  int count = 0;
  for (i = 0; i < len; i++) {
    if (S[i] == prev) {
      count++;
    } else {
      A.push_back(count);
      prev = S[i];
      count = 1;
    }
  }

  A.push_back(count);

  for (i = 0; i < A.size(); i = i + 2) {
    REP(j, A[i] - 1) {
      cout << '0' << ' ';
    }

    cout << 1 + ((A[i] - 1) / 2) + (A[i + 1] / 2) << ' ';
    cout << 1 + ((A[i + 1] - 1) / 2) + (A[i] / 2) << ' ';

    REP(j, A[i + 1] - 1) {
      cout << '0' << ' ';
    }
  }
  //cout << '0' << endl;
}


Measured memory_bytes: 1144
nums = gets.chomp.split(' ').map(&:to_i)
# a, b, c = gets.chomp.split(' ').map(&:to_i)
count = 0

max_idx = nums.index(nums.max)
min_idx = nums.index(nums.min)
nor_idx = ([0, 1, 2] - [max_idx, min_idx]).first
loop do
  break if nums.uniq.size == 1
  count += 1
  if nums[max_idx] - nums[min_idx] >= 2
    nums[min_idx] += 2 
  else
    nums[min_idx] += 1
    nums[nor_idx] += 1
  end
  
  max_idx = nums.index(nums.max)
  min_idx = nums.index(nums.min)
  nor_idx = ([0, 1, 2] - [max_idx, min_idx]).first
end

puts count

Measured memory_bytes: 3836
#include <stdio.h>

#define WIDTH 6
#define HEIGHT 12

enum { YET, ALREADY };

int del( void );
int search( int, int );
int search_body( int, int, char );
void fall( void );

typedef struct {
	char color;
	int state;
} FIELD;

FIELD field[ WIDTH ][ HEIGHT ];
const int dx[ 4 ] = { -1, 0, 1, 0 }, dy[ 4 ] = { 0, -1, 0, 1 };

int stack[ WIDTH * HEIGHT ];
int sp;

int main( void ) {
	int x, y, n, chain;

	scanf( "%d", &n );
	while ( n-- ) {
		for ( y = 0; y < HEIGHT; y++ )
			for ( x = 0; x < WIDTH; x++ ) {
				scanf( " %c", &field[ x ][ y ].color );
				field[ x ][ y ].state = YET;
			}

		for ( chain = 0; del(); chain++ )
			fall();

		printf( "%d\n", chain );
	}

	return 0;
}

int del( void ) {
	int x, y, del = 0;

	for ( x = 0; x < WIDTH; x++ )
		for ( y = 0; y < HEIGHT; y++ )
			if ( field[ x ][ y ].color != '.' && field[ x ][ y ].color != 'O' && field[ x ][ y ].state == YET ) {
				sp = 0;
				if ( search( x, y ) >= 4 ) {
					while ( sp-- )
						field[ stack[ sp ] / HEIGHT ][ stack[ sp ] % HEIGHT ].color = '.';

					del = 1;
				}
			}

	return del;
}

int search( int x, int y ) {
	return search_body( x, y, field[ x ][ y ].color );
}

int search_body( int x, int y, char color ) {
	int i, sum;

	stack[ sp++ ] = x * HEIGHT + y;
	field[ x ][ y ].state = ALREADY;

	sum = 0;
	for ( i = 0; i < 4; i++ ) {
		int nx = x + dx[ i ], ny = y + dy[ i ];

		if ( nx >= 0 && nx < WIDTH && ny >= 0 && ny < HEIGHT && field[ nx ][ ny ].state == YET && ( field[ nx ][ ny ].color == color || field[ nx ][ ny ].color == 'O' ) )
			if ( field[ nx ][ ny ].color == 'O' )
				stack[ sp++ ] = nx * HEIGHT + ny;
			else
				sum += search_body( nx, ny, color );
	}

	return sum + 1;
}

void fall( void ) {
	int x, y, cnt;

	for ( x = 0; x < WIDTH; x++ ) {
		cnt = 0;
		for ( y = HEIGHT - 1; y >= 0; y-- )
			if ( field[ x ][ y ].color == '.' )
				cnt++;
			else {
				field[ x ][ y + cnt ].color = field[ x ][ y ].color;
				field[ x ][ y + cnt ].state = YET;
			}

		for ( y = cnt - 1; y >= 0; y-- )
			field[ x ][ y ].color = '.';
	}
}

Measured memory_bytes: 596
x,y =map(int,input().split())

L1=[1,3,5,7,8,10,12]
L2=[4,6,9,11]
L3=[2]

if x in L1 and y in L1:
    print("Yes")
    
elif x in L2 and y in L2:
    print("Yes")

elif x in L3 and y in L3:
    print("Yes")
    
else:
    print("No")


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include <atcoder/all>
// #include <bits/stdc++.h> 
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;
using namespace atcoder;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1e9+7;
double eps = 1e-12;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln '\n'
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define zero ll(0)
#define set_bits(x) __builtin_popcountll(x)
 
ll mpow(ll a, ll b){
	if(a==0) return 0;
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}
 
ll mpow(ll a, ll b, ll p){
	if(a==0) return 0;
	if(b==0) return 1;
	ll t1 = mpow(a,b/2,p);
	t1 *= t1;
	t1 %= p;
	if(b%2) t1 *= a;
	t1 %= p;
	return t1;
}
 
ll modinverse(ll a, ll m){
	ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) return 0; 
    while (a > 1){
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    }
    if (x < 0) x += m0; 
    return x; 
}

mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
 
ll range(ll l, ll r){
	return l + mt()%(r-l+1);
}
 
ll rev(ll v){
	return mpow(v,MOD-2);
}

void solve(){
	ll n;
	cin >> n;
	dsu d(n);
	v64 a(n);
	ll order[n];
	forn(i,n) {
		ll x,y;
		cin >> x >> y;
		x--,y--;
		order[i]=x;
		a[y]=x;
	}
	ll ans[n];
	set<ll> s;
	rforn(i,n-1){
		ll x = a[i];
		auto it = s.lower_bound(x);
		ll last = x;
		while(it!=s.end()){
			d.merge(*it,x);
			last = *it;
			s.erase(it);
			it = s.lower_bound(x);
		} 
		s.insert(last);
	}
	forn(i,n){
		cout << d.size(order[i]) << ln;
	}
}
 
int main()
{
	fast_cin();
	ll t=1;
    // cin >> t;
    forn(i,t) {
    	// cout << "Case #" << i+1 << ": ";
    	solve();
    }
    return 0;
}

Measured memory_bytes: 7516
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first 
#define S second
#define PB push_back 
#define MP make_pair
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
using vl=vector<long long>;
using vvl = vector<vl>;
using vp =vector<pair<int,int>>;

typedef pair<int,int> P;
string s;
int k;
ll INF = 1000000000000;



int main(){
    ll A;
    string B;
    cin >>A>>B;
    ll C = (B[0]-'0')*100+(B[2]-'0')*10+(B[3]-'0');
    cout <<A*C/100<<endl;
}


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

int main(){
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  for(int i=0;i<m;i++){  
    cin >> b.at(i);
  }
  vector<vector<int>> a(n, vector<int>(m));  
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin >> a.at(i).at(j);
    }
  }
  int sum;
  int cnt = 0;
  for(int i=0;i<n;i++){
    sum = 0;
    for(int j=0;j<m;j++){
      sum += b.at(j) * a.at(i).at(j);
    }
    if(sum > (-1) * c){
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
int main(void){
   int N,K;
   cin>>N>>K;
   int num[N];
   for(int i=0;i<N;i++){
       cin>>num[i];
   }
   int a,b;
   int sum=0;
   for(int i=0;i<N;i++){
       a=abs(K-num[i]);
       b=num[i];
       if(a>=b) sum+=2*b;
       else sum+=2*a;
   }
   cout<<sum;
   return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll unsigned long long
#define inf 1000000007 //10^9+7
#define sort(vec) sort(vec.begin(),vec.end());
#define rever(vec) reverse(vec.begin(),vec.end());
#define unsort(vec) sort(vec); rever(vec);
#define gcd __gcd
using namespace std;

int main() {
  string s,t;
  cin>>s>>t;
  ll e=t.size();
  ll f=s.size();
  vector<char>T(e);
  vector<char>S(f);
  for(ll i=0;i<e;i++) {
    T.at(i)=t.at(i);
  }
  for(ll i=0;i<f;i++) {
    S.at(i)=s.at(i);
  }
  sort(S);
  unsort(T);
  for(ll i=0;i<min(e,f);i++) {
    if(T.at(i)>S.at(i)) {
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  if(f<e) {
    bool can=true;
    for(ll i=0;i<f;i++) {
      if(T.at(i)!=S.at(i)) {
        can=false;
        break;
      }
    }
    if(can) {
      cout<<"Yes"<<endl;
    }
    else {
      cout<<"No"<<endl;
    }
  }
  else {
    cout<<"No"<<endl;
  }
}

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

int main(){
	int n ; cin >> n ;
	vector<int> card(n) ;
	for(int i=0;i<n;i++) cin >> card.at(i) ;
	sort(card.begin(),card.end()) ;
	reverse(card.begin(),card.end()) ;
	int a,b ;
	a = b = 0 ;
	for(int i=0;i<n;i++){
		if(i%2==0) a += card.at(i) ;
		else b += card.at(i) ;
	}
	cout << a-b << endl ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(void){
    int n; cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a.at(i);
    int sum=0;
    rep(i,n)sum+=a.at(i)-1;
    cout<<sum<<endl;
}

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

long long N, A, B, C, D;

bool check(long long k) {
    long long l, r;
    l = A + k*C;
    r = A + k*D;
    l += -1 * (N - 1 - k) * D;
    r += -1 * (N - 1 - k) * C;
    return l <= B && B <= r;
}

int main() {
    cin >> N >> A >> B >> C >> D;

    bool ok = false;
    for (long long k=0; k<N; k++) {
        if (check(k)) {
            ok = true;
            break;
        }
    }

    cout << (ok ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define vll vector<ll>
#define fast ios:: sync_with_stdio(false),cin.tie(0);
#define COUT cout<<fixed<<setprecision(12)
#define SET set<ll,greater<ll>>gquiz
#define ITERATOR set<ll,greater<ll>> :: iterator itr
#define V vector<ll>vector
#define sz size()
//#define A vector<pair<ll,ll>>vect
ll N=100000,M=100000;
#define B vect.push_back(make_pair(N,M));
ll MOD=1000000007;
 
ll gcd(ll a,ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
/*ll ncr(ll n,ll r)
{
	if(n==1 || r==0)
	return 1;
	if(r>n/2)
	r=n-r;
	ll ans=1;
	for(ll i=1;i<=r;i++)
	{
		ans=((ans * n )/i);
		n--;
	}
	return ans;
}*/
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow(ll a,ll b,ll m)
{
	ll ans=1;
	while(b>0)
	{
		if(b&1)
			ans=(ans*a)%m;
		b=b/2;
		a=(a*a)%m;
	}
	return ans;
}
 
ll modinv(ll k)
{
	return pow(k,MOD-2,MOD);
}

ll ncr(ll n,ll c)
{
    ll t=1;
    c=min(c,n-c);
    for(ll i=1;i<=c;i++)
    {
     	t=(t*(n-i+1))%MOD;
        t=(t*modinv(i))%MOD;
	}
    return t;
}
int main()
{
	ll n,a,b;
	cin>>n>>a>>b;
	ll k=pow(2,n,1000000007);
    k=(k-1)%MOD;
   // cout<<k;
   
    ll x=ncr(n,a);
    ll y=ncr(n,b);
    k=(((k-x)%MOD)-y+MOD+MOD)%MOD;
    cout<<k;
}

Measured memory_bytes: 380
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	String[] week = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "All"};
	String[] ecTime = {"Day", "Night", "All"};
	int[] ecTimeSpan = {0, 6*60, 18*60, 24*60};
	int WEEK = 7 * 24 * 60;
	int DAY = 24 * 60;
	int MIN = 60;
	boolean[] is;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int s = sc.nextInt(), n = sc.nextInt(), t = sc.nextInt();
			String wd = sc.next(), time = sc.next();
			int p = sc.nextInt(), m = sc.nextInt();
			if( s == 0 && n == 0) break;

			int ecD = 0;
			for(;ecD<7;ecD++) if(week[ecD].equals(wd))break;
			int ecT = 0;
			for(;ecT<3;ecT++) if(ecTime[ecT].equals(time)) break;

			boolean[] all = new boolean[2 * WEEK];
			for(int i=0;i<2*WEEK;i++) {
				int min = i%DAY, day = i/DAY;
				if(ecD == day || ecD == 7) {
					if(ecT == 0 && ecTimeSpan[1] <= min && min < ecTimeSpan[2]) all[i] = true;
					if(ecT == 1 && ( ( ecTimeSpan[0] <= min && min < ecTimeSpan[1]) ||
									 ( ecTimeSpan[2] <= min && min < ecTimeSpan[3]))) all[i] = true;
					if(ecT == 2 ) all[i] = true;
				}
			}
			int max = 0;
			for(int day = 0;day<7;day++) for(int min=0;min<60*24;min++) {
				int cnt = 0;
				for(int st = 0;st<m;st++) {
					int start = (day * DAY + min + st * t) % WEEK;
					int end = start + s;
					if(all[start] && all[end]) cnt++;
				}
				max = max(max, cnt);
			}

			double prob = 1.0 - 1.0 / p;
			double ret = 1.0;
			for(int i=0;i<max * n;i++) ret *= prob;
			System.out.printf("%.10f\n",1-ret);
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

Measured memory_bytes: 25844
#include<bits/stdc++.h>
using namespace std;
int n,w,total;
int a[1000];
int dp[1001];

int solve(){
  if(n==0)return 0;
  if(w==0)return total;
  
  fill(dp,dp+n+1, 1e9);
  dp[0]=0;
  for(int i=0;i<n;i++){
    int sum=0;
    for(int j=i+1;j<=n;j++){
      sum+=a[j-1];
      dp[j]=min( dp[j], dp[i]+ abs(sum-w) );
    }
  }

  int res=max(0,total-w);
  for(int i=0;i<n;i++){
    total-=a[i];
    res=min(res, dp[i+1] + max(0, total-w ) );
  }
  return res;
  
}

int main(){
  for(int tc=1;;tc++){
    cin>>n>>w;
    if(n==0&&w==0)break;
    total=0;
    for(int i=0;i<n;i++){
      cin>>a[i];
      total+=a[i];
    }
    cout<<"Case "<<tc<<": "<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 3020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
vector<P> query[26];
int typ[200005]={0};
ll n;
bool L_ok(ll l){
  int qr_num=-1;
  while(1){
    int n_type=typ[l];
    if(query[n_type].size()==0) return true;
    int n_qr=upper_bound(query[n_type].begin(),query[n_type].end(),P(qr_num,99))-query[n_type].begin();
    if(n_qr==query[n_type].size()) return true;
    qr_num=query[n_type][n_qr].first;
    int dis=query[n_type][n_qr].second;
    if(dis==0) l--;
    else l++;
    if(l<=0) return false;
  }
}
bool R_ok(ll l){
  int qr_num=-1;
  while(1){
    int n_type=typ[l];
    if(query[n_type].size()==0) return true;
    int n_qr=upper_bound(query[n_type].begin(),query[n_type].end(),P(qr_num,99))-query[n_type].begin();
    if(n_qr==query[n_type].size()) return true;
    qr_num=query[n_type][n_qr].first;
    int dis=query[n_type][n_qr].second;
    if(dis==0) l--;
    else l++;
    if(l>n) return false;
  }
}
int main(){
  ll q;
  cin>>n>>q;
  string s;
  cin>>s;
  for(int i=0;i<n;i++){
    typ[i+1]=(int)(s[i]-'A');
  }
  for(int i=0;i<q;i++){
    char a,d;
    cin>>a>>d;
    if(d=='L') query[(int)(a-'A')].push_back(P(i,0));
    else query[(int)(a-'A')].push_back(P(i,1));
  }
  ll llb=0,lrb=n+1;
  while(lrb-llb>1){
    ll mid=(llb+lrb)/2;
    if(L_ok(mid)) lrb=mid;
    else llb=mid;
  }
  ll rlb=0,rrb=n+1;
  while(rrb-rlb>1){
    ll mid=(rlb+rrb)/2;
    if(R_ok(mid)) rlb=mid;
    else rrb=mid;
  }
  cout<<max((ll)0,rlb-llb)<<endl;
}


Measured memory_bytes: 5748
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// bool dfs(int* now, int num, int target) {

// }

vector<int> naive(int n, int y) {
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n - i; j++) {
            int k = max(0, n - i - j);
            // cout << i << " " << j << " " << k << " " << endl;
            int prod = 10000 * i + 5000 * j + 1000 * k;
            // cout << prod << endl;
            if (prod == y) return vector<int>{i, j, k};
        }
    }
    return vector<int>{-1, -1, -1};
}
int main(){
    int N, Y;
    cin >> N >> Y;
    // 3^N == Yとなるか全探索により確かめる
    vector<int> a = naive(N, Y);
    for (auto aa: a)
        cout << aa << " ";
    cout << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		String a = "No";
		for(int i=1; i<10; i++) {
			for(int j=1; j<10; j++) {
				if(N == i*j) {
					a = "Yes";
				}
			}
		}
		System.out.println(a);
	}

}

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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 500005
#define all(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define rt return
using namespace std;

void test_cases(){
  
  string s; cin >> s;
  int n = s.size();
  if(s[n - 1] == 's') s += "es";
  else s += 's';
  cout << s;
}

int32_t main(){
	IOS;
	int tt = 1; 
	// cin >> tt;
	while(tt--){
		test_cases();   
    cout << endl; 	
	}
	return 0;
}


Measured memory_bytes: 3664
#include<stdio.h>
#include<string.h>
int main()
{
    char s[105];
    int i,len,f1=0;
    gets(s);
    len=strlen(s);
    for(i=0;i<len;i++)
    {
        if(s[i]=='R' && i%2!=0)
            {
                f1=1;
            }
        else if(s[i]=='L'&&i%2==0)
        {
            f1=1;
        }

    }

    if(f1==1)
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
a,b,c,x,y = [int(i) for i in input().split()]

if x <= y:
    ans1 = min(c * x * 2 + b * (y - x), c * y * 2)
    #print('a')
else: #x > y
    ans1 = min(c * y * 2 + a * (x - y), c * x * 2)
    #print('b')
ans2 = a * x + b * y
print(min(ans1, ans2))


Measured memory_bytes: 2940
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
using ll=long long;

int result(int rafi)
{
    int  m= 0;
    while(rafi % 100 == 0)
    {
        rafi=rafi/100;
        ++m;
    }
    return m;
}
int main()
{
    int a,b,ans=0;
    cin>>a>>b;
    int cnt=0;
    while(b>cnt)
    {
        ++ans;
        if(result(ans) == a)
            ++cnt;
    }
    cout <<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
//
#define int long long
#define ALL(x) (x).begin(), (x).end()
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))
// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;
// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((a) >> (b)) & 1
#define bitcount(a) __builtin_popcountll((a))
//
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;
//
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0};
const int dy[] = {0, -1, 1, 0, 0};
//
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

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

  double ave = (double)sum / N;
  int ans = 0;
  double min = INF;
  for (int i = 0; i < N; i++) {
    double tmp = abs(a[i] - ave);
    if (min > tmp) {
      ans = i;
      min = tmp;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void funDP(vector<int>t,int k) {
	vector<int>dp(t.size()+1, 0);
	dp[0] = 0;
	dp[1] = abs(t[1] - t[0]);
	for (int i = 2; i < t.size(); i++) {
			dp[i] = dp[i - 1] + abs(t[i] - t[i - 1]);
	}
	for (int i = 2; i < t.size(); i++) {
		for (int j = 1; j <= k; j++) {
			if (i - j < 0)
				break;
			dp[i] = min(dp[i], dp[i - j] + abs(t[i] - t[i - j]));
		}
	}
	cout << dp[t.size() - 1]<<"\n";
}
int main()
{
	int r,k;
	cin >> r>>k;
	
	vector<int>v(r);
	for (auto&& x : v)
		cin >> x;
	funDP(v,k);
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

typedef pair<int,int> P;
const int INF = 1e+8;
// 入力
int w, h, n;
char c[1001][1001];
// 4近傍
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};
// d[y][x] := スタートから(x,y)までの最短距離 (未探索のときは INF )
int d[1001][1001];

// 文字 s から文字 s+1 までの最短距離を返す. (s は'0'-'8')
int bfs(char s){
	int sx, sy, gx, gy;
	// 初期化とスタート位置とゴール位置を探す.
	for(int y=0 ; y < h ; y++ ){
		for(int x=0 ; x < w ; x++ ){
			d[y][x] = INF;
			// 処理しやすいように 'S' を '0' に置き換える.
			if( c[y][x] == 'S' ) c[y][x] = '0';
			if( c[y][x] == s ) sx = x, sy = y;
			if( c[y][x] == s+1 ) gx = x, gy = y;
		}
	}
	// スタート位置をキューに入れる
	queue<P> q;
	q.push( P(sx,sy) );
	d[sy][sx] = 0;
	int res = INF;
	while( !q.empty() ){
		int x = q.front().first;
		int y = q.front().second;
		int cost = d[y][x];
		q.pop();
		
		// ゴールのとき
		if( x == gx && y == gy ){
			res = cost;
			break;
		}
		
		// 4方向探索
		for(int i=0 ; i < 4 ; i++ ){
			int mx = x + dx[i];
			int my = y + dy[i];
			if( mx < 0 || my < 0 || w <= mx || h <= my ) continue;
			if( c[my][mx] == 'X' ) continue;
			
			if( cost+1 < d[my][mx] ){
				d[my][mx] = cost + 1;
				q.push( P(mx,my) );
			}
		}
	}
	return res;
}

int main(){
	cin >> h >> w >> n;
	for(int y=0 ; y < h ; y++ ){
		cin >> c[y];
	}
	int ans = 0;
	for(int i=0 ; i < n ; i++ ){
		ans += bfs(i+'0');
	}
	cout << ans << endl;
}

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

#define max 100000

//qsort(d, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}

int main()
{
    int a, b;
    
    scanf("%d %d", &a, &b);
    
    if(a>9||b>9)
        printf("%d", -1);
    else
        printf("%d", a*b);
    
    return 0;
}



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

int main(){
    int n,m,c,cnt=0,ans=0;
    cin>>n>>m>>c;

    vector<int> b(m);
    for(int i=0;i<m;i++){
        cin>>b.at(i);
    }
    for(int i=0;i<n;i++){
        for(int i=0;i<m;i++){
            int a;
            cin>>a;
            cnt+=(a*b.at(i));
        }
        if(cnt+c>0) ans++;
        cnt=0;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var m=Arr.shift()-0;
var n=Arr.shift()-0;
var M=[];
var check=[];
for(var i=0;i<m;i++)M[i]=[];
for(var i=0;i<m;i++)check[i]=false;
for(var i=0;i<n;i++){
   var v=Arr.shift().split(" ").map(Number);
   M[v[0]-1].push(v[1]-1);
}
var L=[]; 
for(var i=0;i<m;i++){
   visit(i);
}
function visit(x){
   if(check[x]==true)return;
   else check[x]=true;
   M[x].forEach(function(v){
      visit(v);
   });
   L.push(x);
}
L.reverse();
L.forEach(function(v){
   console.log(v+1);
});

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

int main(){
  vector<char> c(9);
  REP(i,9) cin>>c.at(i);
  cout<<c.at(0)<<c.at(4)<<c.at(8);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  char c[200];
  scanf("%s", c);
  int n = strlen(c) - 2;
  for (int i = 0; i < n; i += 2) {
    bool check = 0;
    for (int j = 0; j < (n - i) / 2; j++) {
      if (c[j] != c[j + (n - i) / 2]) {
        check = 1;
        break;
      }
    }
    if (check)
      continue;
    else {
      printf("%d\n", n - i);
      return 0;
    }
  }
  return 0;
}

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

using namespace std;

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

int main() {
	int n, l;
	cin >> n >> l;
	vector<string> str(n);
	REP(i, n) cin >> str[i];
	
	sort(str.begin(), str.end());
	REP(i, n) cout << str[i];
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect_left
import heapq

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
p = LIST()
xy = [LIST() for _ in range(M)]

class UnionFind:
   def __init__(self, n):
       self.par = [i for i in range(n+1)]
       self.rank = [0] * (n+1)
   # 検索
   def find(self, x):
       if self.par[x] == x:
           return x
       else:
           self.par[x] = self.find(self.par[x])
           return self.par[x]
   # 併合
   def union(self, x, y):
       x = self.find(x)
       y = self.find(y)
       if self.rank[x] < self.rank[y]:
           self.par[x] = y
       else:
           self.par[y] = x
           if self.rank[x] == self.rank[y]:
               self.rank[x] += 1
   # 同じ集合に属するか判定
   def same_check(self, x, y):
       return self.find(x) == self.find(y)

tree = UnionFind(N)

for x, y in xy:
	tree.union(x, y)

ans = 0
for i in range(N):
	if i+1 == p[i]:
		ans += 1
	elif tree.same_check(i+1, p[i]):
		ans += 1
print(ans) 


Measured memory_bytes: 38124
k,n=list(map(int,input().split()))
a=list(map(int,input().split()))

b=[]
for i in range(n-1):
    b.append(a[i+1]-a[i])
b.append(a[0]+k-a[-1])

s=sum(b)
m=max(b)
print(s-m)

Measured memory_bytes: 26444
#include<bits/stdc++.h>
using namespace std;
inline void read(int &x)
{
	char c=getchar();
	x=0;
	while (c>'9'||c<'0')
		c=getchar();
	while (c>='0'&&c<='9')
	{
		x=x*10+c-'0';
		c=getchar();
	}
}
const int N=305;
int a[N][N],p[N],f[N],n,m,ans=23333333,pos,b[N];
int main()
{
	read(n);
	read(m);
	for (int i=1;i<=n;++i)
		for (int j=1;j<=m;++j)
			read(a[i][j]);
	for (int i=1;i<=n;++i)
		p[i]=1;
	for (int i=1;i<=m;++i)
	{
		memset(f,0,sizeof(f));
		for (int j=1;j<=n;++j)
		{
			while (b[a[j][p[j]]]&&p[j]<=m)
				++p[j];
			++f[a[j][p[j]]];
		}
		pos=1;
		for (int j=2;j<=m;++j)
			if (f[j]>f[pos])
				pos=j;
		b[pos]=1;
		/*for (int i=1;i<=m;++i)
			cout<<f[i]<<' ';
		cout<<'\n';*/
		ans=min(ans,f[pos]);
	}
	cout<<ans;
}

Measured memory_bytes: 640
/*
██████╗  ███████╗  
██╔══██╗ ██╔════╝ 
██████╔╝ ███████╗ 
██╔══██╗ ╚════██║  
██║  ██║ ███████║      
╚═╝  ╚═╝ ╚══════╝                                                                                                             
*/

#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define haha(j,a,n) for(int j=a;j<n;j++)
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define endl "\n"
#define bc(v) v.begin(),v.end()
#define vl vector<ll>
#define vi vector<int>
#define why 1000000007
#define NUM 100005
#define F first
#define S second
#define bhar(a) rep(i,a.size()) cin>>a[i];
#define show(a) rep(i,a.size()) cout<<a[i]<<" ";
#define sott(a) sort(bc(a))
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define mapp map<ll,ll>
#define dkac cout<<fixed<<setprecision(15);
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define yeah(n) while(n--)
ll gcd(int a, int b){if(b==0) return a; else return gcd(b,a%b);}
ll bitfun(ll x){
  return (x&(-x));
}
void solve(){
  ll n,m; cin>>n>>m;
  cout<<n*(n-1)/2+m*(m-1)/2;
}
int main(){
    ios
    int t=1; 
    //cin>>t;
    yeah(t){
      solve();
    }
}

Measured memory_bytes: 256
N, W = map(int, raw_input().split())
P = [map(int, raw_input().split()) for i in xrange(N)]
V = sum(v for v, w in P)
dp = [W+1]*(V+1)
dp[0] = 0
for v, w in P:
    for i in xrange(V-v, -1, -1):
        dp[i+v] = min(dp[i+v], dp[i]+w)
for i in xrange(V, -1, -1):
    if dp[i] <= W:
        print i
        break

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

int sum(int n){
    int ret=0;
    while(n!=0){
        ret += n%10;
        n /= 10;
    }
    return ret;
}

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    int ans=0;
    for(int i=1; i<=n; i++){
        int ret = sum(i);
        if(a <= ret && ret <= b){
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
x,y=map(int,input().split())
mod=pow(10,9)+7
if (2*x-y)%3!=0 or (2*y-x)%3!=0:
  print(0)
  exit(0)
a=(2*x-y)//3
b=(2*y-x)//3

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

print(cmb(a+b,a,mod))

Measured memory_bytes: 122068
s = gets.chomp

result = 0

# AA...ABCの形を探す
i = 0
a_count = 0
a_flag = false
while i < s.length do
  if a_flag
    if s[i] == "A"
      a_count += 1
      i += 1
    elsif s[i] == "B" && s[i+1] == "C"
      result += a_count
      i += 2
    else
      a_count = 0
      a_flag = false
      i += 1
    end
  else
    if s[i] == "A"
      a_count = 1
      a_flag = true
      i += 1
    else
      i += 1
    end
  end
end

puts result


Measured memory_bytes: 14796
let rec q()=Scanf.scanf"%d %d
"(fun m d->if m<>0&&d<>0then(let rec($)i z=if i>=m then z else(i+1)$(z+[|0;31;29;31;30;31;30;31;31;30;31;30|].(i))in q(print_endline([|"Wednes";"Thurs";"Fri";"Satur";"Sun";"Mon";"Tues"|].((d+(0$0))mod 7)^"day"))));;q()

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

int func(int N) {
  int res = 0;
  while (N) {
    res += N % 10;
    N /= 10;
  }
  return res;
}

int main() {
  int N;
  cin >> N;
  int s = func(N);
  if (N % s == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3500
import sys
import math
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

X=int(input())
c=0
m=100
while(m<X):
    m=math.floor(m*1.01)
    c+=1

print(c)

Measured memory_bytes: 9184
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main()
{
	int N, X, Y;
	cin >> N >> X >> Y;
	map<int, int> ans;
	X--, Y--;
	rep(i, 0, N) {
		rep(j, i + 1, N) {
			ans[min(j - i, abs(X - i) + abs(Y - j) + 1)]++;
		}
	}
	rep(d, 1, N) {
		printf("%d\n", ans[d]);
	}
	return 0;
}


Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }
  sort(ALL(a));
  ll ans = 0;
  REP(i, n) FOR(j, i + 1, n) FOR(k, j + 1, n) {
    if (a[i] == a[j] || a[j] == a[k] || a[k] == a[i]) {
      continue;
    }
    if (a[i] + a[j] > a[k]) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int N,X,T;
  cin>>N>>X>>T;
  if(N%X == 0){
    cout << N*T/X << endl;
  }
  else{
    cout << ((N/X)+1)*T << endl;
  }
  return 0;
}


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

int N,number;
string status = "APPROVED";
int main(){
  cin >> N;
  for (int i = 0;i<N;i++){
    cin >> number;
    if (number % 2 == 1){
      continue;
    }
    else if (number % 3 == 0 || number % 5 == 0){   
      continue;
    }
    else{
      status = "DENIED";
      break;
    }
  }
  cout << status;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
long double pi=3.14159265358979323846L;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    vector<int> p(n),q(n);
    rep(i,0,n)cin>>p[i];
    rep(i,0,n)cin>>q[i];
    vector<int> v;
    rep(i,1,n+1)v.push_back(i);
    int na=0,nb=0;
    int now=0;
    do{
        if(v==p)na=now;
        if(v==q)nb=now;
        now++;
    }while(next_permutation(v.begin(),v.end()));
    cout<<abs(na-nb)<<endl;
}


Measured memory_bytes: 256
N=int(input())
B=list(map(int, input().split()))
#a 空
for i in range(N):
    if i+1<B[i]:
        print(-1)
        exit()

ans=[]

while len(B)>0:
    now=0
    for i in range(len(B)):
        if i+1==B[i]:
            now=i
    ans.append(B[now])
    B.pop(now)
ans=ans[::-1]
for a in ans:
    print(a)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;


void solve(){
	int h,w,m;
	cin >> h >> w >> m;
	int c[w+1], r[h+1];
	int a[m],b[m];
	memset(c,0,sizeof(c));
	memset(r,0,sizeof(r));
	int rm = 1, cm = 1;
	for (int i = 0; i < m; i++){
		cin >> a[i] >> b[i];
		r[a[i]]++;
		c[b[i]]++;
		rm = max(rm,r[a[i]]);
		cm = max(cm,c[b[i]]);
	}
	int rmc = 0, cmc = 0;
	for (int i = 0; i <= h; i++)
		if (r[i] == rm)
			rmc++;
	for (int j = 0; j <= w; j++)
		if (c[j] == cm)
			cmc++;
	ll cnt = cmc*rmc;
	for (int i = 0; i < m; i++){
		if (r[a[i]] == rm and c[b[i]] == cm)
			cnt--;
	}
	int f = 1;
	if(cnt)
		f = 0;
	cout << rm + cm - f<< endl;
}

int main(){
	int TC = 1;
	//cin >> TC;
	for (int tcc = 1; tcc <= TC; tcc++){
		//cout << "Case #"<< tcc << ": ";
		solve();
	}
	return 0;
		
}

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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m = M)
{
  int ret = n % m;
  if (ret < 0)
    ret += m;
  return ret;
}

int exp(int n, int k)
{
  if (k == 0)
    return 1;
  if (k == 1)
    return n;
  int ax = exp(n, k / 2);
  ax = mod(ax * ax);
  if (k % 2)
    ax = mod(ax * n);
  return ax;
}

int gcd(int a, int b)
{
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
//#define MULTIPLE_TEST_CASE
void solution()
{
  int n, m;
  cin >> n >> m;
  vector<vector<char>> mat(n, vector<char>(m));
  int dist[n][m];
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < m; j++)
    {
      cin >> mat[i][j];
      dist[i][j] = INF;
    }
  }
  set<tuple<int, int, int>> s;
  dist[a - 1][b - 1] = 0;
  s.insert(mt(0, a - 1, b - 1));

  function<bool(int, int)> valid = [&](const int nx, const int ny) {
    return nx >= 0 && nx < n && ny >= 0 && ny < m && mat[nx][ny] == '.';
  };

  while (s.size() > 0)
  {
    int x, y, d;
    tie(d, x, y) = *s.begin();
    s.erase(s.begin());
    if (dist[x][y] != d)
      continue;

    //cout << "at " << x << " " << y << " " << dist[x][y] << endl;

    for (int i = x - 2; i <= x + 2; i++)
    {
      for (int j = y - 2; j <= y + 2; j++)
      {
        if (!valid(i, j))
          continue;

        if (dist[i][j] <= d + (abs(i - x) + abs(j - y) > 1))
          continue;

        dist[i][j] = d + (abs(i - x) + abs(j - y) > 1);
        s.insert(mt(dist[i][j], i, j));
      }
    }
  }
  if (dist[c - 1][d - 1] == INF)
    dist[c - 1][d - 1] = -1;
  cout << dist[c - 1][d - 1] << endl;
}

int32_t main()
{
  //DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--)
    solution();
}


Measured memory_bytes: 13008
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int K = sc.nextInt();
      String S = sc.next();
      String T = S.substring(K-1,K).toLowerCase();
      System.out.println(S.substring(0,K-1)+ T +
                         S.substring(K,N));
    }
}

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

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        b:chars,
    }
    let mut ans:char= 'A';
    if b[0] =='A' {
        ans='T';
    }else if b[0] =='T' {
        ans='A';
    }else if b[0] == 'C' {
        ans='G';
    }else if b[0]=='G' {
        ans='C';
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    ll a, b, n;
    cin>>a>>b>>n;
    ll ans = (min(n, b-1)*a)/b;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
void solve()
{
    int n;
    cin >> n;
    int one[n], two[n], three[n];
    for (int i = 0; i < n; i++)
    {
        cin >> one[i] >> two[i] >> three[i];
    }
    int dp[n][4] = {0};
    dp[0][1] = one[0];
    dp[0][2] = two[0];
    dp[0][3] = three[0];
    for (int i = 1; i < n; i++)
    {
        dp[i][1] += max(dp[i - 1][2], dp[i - 1][3]) + one[i];
        dp[i][2] += max(dp[i - 1][1], dp[i - 1][3]) + two[i];
        dp[i][3] += max(dp[i - 1][1], dp[i - 1][2]) + three[i];
    }
    cout << max(dp[n - 1][3], max(dp[n - 1][2], dp[n - 1][1])) << endl;
}
int main()
{

    int t;
    //cin >> t;
    t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 2944
N=int(input())
D={}

for i in range(N):
    s,p=input().split()
    p=int(p)
    if s not in D:
        D[s]=[(p,i+1)]
    else:
        D[s].append((p,i+1))

name=sorted(D)
#print(name,D)
for n in name:
    d=sorted(D[n], reverse=True)
    for t in d:
        p,n=t
        print(n)

Measured memory_bytes: 3064