akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))
#define INF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

typedef long long int lli;

void swap(int* a, int* b)
{
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

void ll_swap(lli* a, lli* b)
{
    lli tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int gcd(int a, int b)
{
    if (a < b)
        swap(&a, &b);

    if (a % b == 0)
        return b;
    else
        return gcd(b, a % b);
}

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

long power(long x, int n) {
    long ans = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            ans = ans * x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
		printf("res:%lld a:%lld\n", res,a);
	}
	return res;
}


lli comb(lli n, lli r)
{
    if (n == 0)
        return 0;

    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (comb(n - 1, r - 1) + comb(n - 1, r));
}

/*
#define MAX 100000
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*/

int d(long long int N)
{
    int count = 0;

    while (N > 0)
    {
        N /= 10;
        count++;
    }

    return count;
}

int main()
{
    
    int N, M, L, K;
    int a[100000];
    char S[15];
    char T[15];

    scanf("%s%s", S, T);

    int count = 0;

    for (int i = 0; i < strlen(S); i++)
    {
        if (S[i] == T[i])
            count++;
    }
       
    if (count == strlen(S))
        printf("Yes");
    else
        printf("No");


    /*
    long long int A, B, C, K;

    scanf("%lld%lld%lld%lld", &A, &B, &C, &K);

    long long int ans = 0;

    if (A >= K)
        ans += K;
    else
    {
        ans += A;
        K -= A;
        if (K > B)
        {
            ans -= K - B;
        }
    }
    printf("%lld", ans);
    */
  
}

Measured memory_bytes: 3760
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		int N =  Integer.parseInt(W.split(" ")[0]);
		int L =  Integer.parseInt(W.split(" ")[1]);

		int t = L;
		int sum = 0;
		for(int i=0;i<N;i++){
			sum+=t;
			t++;
		}
		if(L < 0){
			if((L+N -1)< 0){
				sum -= (L+N -1);
			}
		}else if(L == 0){

		}else{
			sum -= L;
		}

		System.out.println(sum);
	}
}


Measured memory_bytes: 21844
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
      
      int a[] = new int[N];
      
      int count = 0;
      int max = 0;
      for(int i=0; i<N; i++){
      a[i] = sc.nextInt();
      }
       for(int i=1; i<N; i++){
        if(a[i-1]>=a[i]){
        count++;
        }
         else{
         max = Math.max(max,count);//maxにcount++されたものが入っていく,どんどん更新されていき最大値のcount++のものが残る
           count =0;//一旦リセットして,for文をまわして新しいcount++を更新していく
         }
       }
      max = Math.max(max,count);//elseに行かなかった場合(入力が3,2,1)
         System.out.println(max);
    }
}

Measured memory_bytes: 59224
#include <string>
#include <iostream>
#include <vector>
#include <sstream>
#include <algorithm>
#include <cctype>

// Check whether the input satisfy the requirements or not
bool CheckInput( std::string input )
{
  // If number of characters of input is less than 4 or more than 10,
  // it's not expected input!
  if( input.size() < 4 || input.size() > 10 )
    return false;

  // If the input contains non-number, return false
  if( !std::all_of(input.cbegin(), input.cend(), isdigit) )
    return false;

  return true;
}

// Return a vector of numbers which are created from 3 charracters
std::vector < int > GetNumbers( std::string target )
{
  std::vector <int> rtn;

  // loop over characters of the given string to get numbers
  for( int i=0; i<target.size(); i++ )
    {

      // Get 3 characters starting from i-th index
      std::string parts = target.substr( i, 3 );

      // if the extracted string is less than 2 charactoers, skip this loop
      if( parts.size() != 3 )
	continue;

      // Comvert the extracted string to int
      std::istringstream iss( parts );
      int number = 0;
      iss >> number;

      // store the number
      rtn.push_back( number );
    }

  return rtn;
}

// Print the minimum absolute value of differences between an element of vector and 2nd argument
void PrintMinimumDifference( std::vector <int>& numbers, const int kValue )
{
  // Differences are stored in vector
  std::vector <int> diffs;

  // Loop over all elements to calculate difference
  for( int i=0; i<numbers.size(); i++ )
    diffs.push_back( abs( numbers[i] - kValue ) );

  // Get minium value from a vector using min_element function in algorithm header
  std::cout << *min_element( diffs.begin(), diffs.end() ) << std::endl;
}

int main( int argc, char* argv[] )
{

  // Get input
  std::string data;
  std::cin >> data;

  // Check whether the input satisfy assumption or not
  // Assumption: input consists of 4 to 10 numbers
  if( CheckInput( data ) == false )
    {
      std::cerr << "Input should consists of 4 to 10 numbers only." << std::endl;
      return -1;
    }
  
  std::vector <int> numbers = GetNumbers( data );

  const int kValue = 753;

  // Print the minimum absolute difference from kValue
  PrintMinimumDifference( numbers, kValue );
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, a, b, c;
  c = 30;
  cin >> N;
  for (int i = 0; i < N; i++) {
    b = 0;
    cin >> a;
    for (; 1;) {
      if (a % 2 == 1) {
        break;
      }
      a /= 2;
      b++;
    }
    if (b < c) {
      c = b;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
k = []
for i in range(N):
  t = list(map(str, input().split()))
  for j in range(M):
    if t[j] == "snuke":p = [i,j]
abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
print(abc[p[1]]+str(p[0]+1))

Measured memory_bytes: 3060
//It's really tough
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(),x.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mem(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
const int N = 2e5 + 5;
const ll inf = 9e18 + 9;
const int mod = 1e9+7;
ll res;

void solve()
{
     int n;cin>>n;
     for(int i=1;i<n;i++){
         for(int j=1;i*j<n;j++){
             res++;
         }
     }
     cout<<res<<endl;
}
 
int main()
{
    IOS;ll t = 1;
    // cin>>t;
    for(int i=1;i<=t;i++)
    {
        solve();
    }
}

Measured memory_bytes: 3628
N = int(input())
A = list(map(int, input().split()))
 
s, t = 0, 0
for i in range(N):
  s += A[i]
  t += A[i]**2
s = s**2

# 割り算のmodを求めるため、逆元を求め、積に変換する
ans = (s-t) % (10**9+7)
# tmp = (2**1000000005) % (10**9+7)
tmp = 500000004
ans = (ans*tmp) % (10**9+7)
print(ans)

Measured memory_bytes: 31412
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define y_n(ans) cout<<(ans?"Yes":"No")<<endl;

int main() {
    int d, t, s;
    cin >> d >> t >> s;
    y_n(d <= s*t);
}

Measured memory_bytes: 3628
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,k = readInts()
a = readInts()
i = a.index(1)

x = i
y = n-i-1

from math import ceil

ans = float("inf")
for t in range(k):
	ans = min(ans,ceil((x-t)/(k-1))+ceil((y-k+t+1)/(k-1))+1)

print(ans)

Measured memory_bytes: 20640
N = int(input())
documents = list(map(int, input().split()))
app = True
for i in documents:
  if not i % 2 == 0:
    continue
  if not (i % 3 == 0 or i % 5 == 0):
    app = False
if app:
  print('APPROVED')
else:
  print('DENIED')


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>

#define max(a,b) ((a > b) ? a : b)
#define min(a,b) ((a < b) ? a : b)
#define abs(a) ((a < 0) ? -(a) : a)

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

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

int main() {
	int n = ri();
	int a[n];
	for (int i = 0; i < n; i++)
		a[i] = ri();
	
	int res = 0;
	for (int i = 0; i < n; i++) {
		while(!(a[i] % 2)) a[i] /=2, res++;
	}
	
	printf("%d", res);
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdbool.h>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<set>
#include<string>
#include<stdlib.h>
typedef long long ll;
using namespace std;

int main() {
	int H, W;
	string s;
	cin >> H >> W;
	vector<string>str;
	for (int i = 0;i < H;i++) {
		cin >> s;
		str.push_back(s);
	}
	for (int i = 0;i < W + 2;i++)cout << "#";
	cout << endl;
	for (int i = 0;i < H;i++) {
		cout << "#" + str[i] + "#" << endl;
	}
	for (int i = 0;i < W + 2;i++)cout << "#";
	cout << endl;
	return 0;
}
	

Measured memory_bytes: 256
x = []
y = []
while(1):
    n1,n2 = map(int,input().split())
    if n1 == 0 and n2 == 0 :
        break
    else:
        x.append(n1)
        y.append(n2)    
for i in range(len(x)):
    if(x[i]>y[i]):
        x[i],y[i] = y[i],x[i]
        print("{} {}".format(x[i],y[i]))
    else:
        print("{} {}".format(x[i],y[i]))


Measured memory_bytes: 5908
import sys
input = sys.stdin.readline
import numpy as np
S = list(input())
N = len(S)
ans = 10 ** 10
for i in range(N - 2):
    temp = S[i:i+3]
    number_ = int("".join(temp))
    ans = min(ans, abs(753-number_))
print(ans)

Measured memory_bytes: 12500
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if (n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)cout<<"hon";
    else if (n%10==0||n%10==1||n%10==6||n%10==8)cout<<"pon";
    else cout<<"bon";
    return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x)  (long long)(x).size()
#define sqr(x) (x)*(x)
#define sof sizeof
#define ins insert
#define lowerB lower_bound
#define upperB upper_bound
#define mkp make_pair
#define mkt make_tuple
#define act(a,v) (get<(long long)a>(v))
#define mod 1000000007
#define mod1 998244353
#define N 1000003
#define inf 1e18
#define minf -1e18
#define min3(a,b,c) min(a,min(b,c));
#define max3(a,b,c) max(a,max(b,c));
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define sumall(v) accumulate(all(v),(ll)0)
#define sum accumulate
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::floatfield );std::cout.precision(15)
#define PI M_PI
#define fi first
#define se second
#define here cout<<"RSSB"<<endl
#define showzero cout<<std::showpoint
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define br "\n"
#define sp " "
#define zero (ll)0
using namespace  std ;
typedef double db;
typedef long long ll ;
typedef vector<int>vi ;
//typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
typedef vector<pll>vpll;
typedef vector<string>vstr;
typedef vector<bool>vbool ;
void READ(vll &v, ll n)
{
    ll a ;
    for(ll i=0 ; i<n ; i=i+1)
    {
        cin>>a ;
        v.pb(a) ;
    }
}
void PRINT(vll &v , ll a = 0)
{
    //ll a ;
    for(ll i=a ; i<v.size() ; i=i+1)
    {
        v[i] = max((ll)0,v[i]);
        cout<<v[i]<<" " ;
    }
    cout<<"\n" ;
}
/*vbool isprime(N,true);
vll spf(N,0);
vll prime;
void sieve()
{
    isprime[0] = isprime[1] = false;
    for(ll i = 2 ; i<N ; i++)
    {
        if(isprime[i])
        {
            for(ll j=2*i ; j<N ; j+=i)
            {
                isprime[j] = false;
                if(spf[j]==0)
                {
                    spf[j] = i;
                }
            }
            prime.pb(i);
        }
    }
}*//*
ll nck(ll n , ll k ,ll m=1e18+7)
{
    ll i , j,b=1,c=1 ;
    if(n-k<k)
    {
        k = n-k ;
    }
    while(k)
    {
        b*=n ;
        c*=k ;
        ll g = __gcd(b,c) ;
        b/=g ;
        c/=g ;
        n--;
        k-- ;
    }
    return(b) ;
}*//*
long long power(long long k , long long n , long long m=mod)
{
    long long res = 1;
    while(n)
    {
        if(n%2!=0)
        {
            res = (res*k)%m ;
        }
        k = (k*k)%m ;
        n = n/2 ;
    }
    return(res) ;
}*/
ll n,m,k,l,r;
bool ok = false;
int main()
{
    FastIO ;
    PRECISION ;
    ll a,b,c,d,i,j,t,x,y,z;//,x1,y1,z1,e,f;
    ll p,q,r,u,w ;
    char ch,chr ;
    string str,st,str1,str2,str3,str4;
    //ll a1=0,a2=0,b1=0,b2=0,c1=0 ;
    //cin>>str>>str1;
    cin>>a>>b;
    c = a/b;
    a-=c*b;
    a = min(a,b-a);
    cout<<a;
}

Measured memory_bytes: 256
#include <stdio.h>
//#include <string.h>

int main() {
    int n;

    scanf("%d", &n);

    int list[n];

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

    for (int j = n - 1; j >= 0; --j) {
        printf("%d", list[j]);
        if (j)
            printf(" ");
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 2028
#include <iostream>
using std:: cout;
using std:: cin;
using std::endl;



int main() {

long num1, num2;
cin >> num1 >> num2;

if(num1 % 2 != num2 % 2) {
cout << "IMPOSSIBLE" << endl; //bc both of them need to be divided by 2
}

else {
cout << (num1 + num2) / 2 << endl; //bc k = (num1 + num2) / 2 if u add A and B
}
return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

char a[4004],b[4004];

int solve(char *s,char *t,int lenS,int lenT){
	int i,j;
	int count = 0;
	int res = 0;

	for(i=j=0;i<lenS && j<lenT;i++,j++){
		if(s[i] == t[j]){
			count++;
		}
		else{
			if(res < count) res = count;
			count = 0;
		}
	}

	if(res < count) res = count;
	return res;
}

int main(void){
	int i,j;
	int lenA,lenB;
	int ans,tmp;

	while(scanf("%s%s",a,b) != EOF){
		lenA = strlen(a);
		lenB = strlen(b);
		ans = 0;

		for(i=0;i<lenA;i++){
			tmp = solve(&a[i],b,lenA-i,lenB);
			if(ans < tmp) ans = tmp;
		}
		for(i=0;i<lenB;i++){
			tmp = solve(&b[i],a,lenB-i,lenA);
			if(ans < tmp) ans = tmp;
		}

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

	return 0;
}

Measured memory_bytes: 420
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N,T;
    string S;
    cin >> T;
    for(ll i=0;i<T;++i){
        cin >> N;
        vector<ll> A(N,0);
        for(ll i=0;i<N;++i)cin>>A[i];
        cin >> S;
        vector<ll> nl={0};
        bool ans=1;
        for(ll j=N-1;j>=0;--j){
            if(S[j]=='0'){
                ll x=A[j];
                for(auto p: nl)chmin(x,x^p);
                for(auto p: nl)chmin(p,x^p);
                if(x)nl.emplace_back(x);
            }
            else{
                ll x=A[j];
                for(auto p: nl)chmin(x,x^p);
                if(x){ans=0;break;}
            }
        }
        if(ans)prt(0)
        else prt(1)
    }
    return 0;
}


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

//最大公約数
ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}

//複数個の最大公約数
ll ngcd(vector<ll> a)
{
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size() && res != 1; i++)
  {
    res = gcd(a[i], res);
  }
  return res;
}

//最小公倍数
ll lcm(ll a, ll b)
{
  return a / gcd(a, b) * b;
}

//素因数分解
map<ll, ll> prime_factor(ll n)
{
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

//複数個の最小公倍数
ll nlcm(vector<ll> numbers)
{
  ll res;
  res = numbers[0];
  for (ll i = 1; i < numbers.size(); i++)
  {
    res = lcm(res, numbers[i]);
  }
  return res;
}

void Main()
{
  ll n; cin >> n;
  vpll ab(n);
  rep(i, n)
  {
    ll a, b; cin >> a >> b;
    ab[i] = mp(b, a);
  }
  sort(all(ab));
  ll S = 0;
  rep(i, n)
  {
    S += ab[i].second;
    if(S > ab[i].first) fin("No");
  }
  fin("Yes");
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

/*
//test時
  g++ test.cpp -o test;./test
*/


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

int c[16], x[20001];
int dp[20001][256];
int main() {
	int n, m;
	while (scanf("%d%d", &n, &m), n) {
		rep(i, m)scanf("%d", &c[i]);
		rep(i, n)scanf("%d", &x[i]);
		memset(dp, 0x3f, sizeof(dp));
		dp[0][128] = 0;
		rep(i, n)rep(j, 256) {
			if (dp[i][j] == INF)continue;
			rep(k, m) {
				int a = min(255, max(0, j + c[k]));
				dp[i + 1][a] = min(dp[i + 1][a], dp[i][j] + (x[i] - a)*(x[i] - a));
			}
		}
		int Min = INF;
		rep(j, 256)Min = min(Min, dp[n][j]);
		printf("%d\n", Min);
	}
}

Measured memory_bytes: 23256
#include <stdio.h>
#include <string.h>

int main(void)
{
    char a[50][51],b[50][51];
    int n,m,f,i,j,k,l;
    scanf("%d%d",&n,&m);
    for(i=0;i<n;i++)scanf("%s",a[i]);
    for(i=0;i<m;i++)scanf("%s",b[i]);
    for(i=0;i<=n-m;i++){
        for(j=0;j<=n-m;j++){
            f=0;
            for(k=i;k<i+m;k++)for(l=j;l<j+m;l++)if(a[k][l]!=b[k-i][l-j])f=1;
            if(f==0){
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 128
n,m = map(int, input().split())
hyou= list(map(int,input().split()))
all = sum(hyou)
min = all / 4 / m
erabu = 0
for i in range(n):
    if hyou[i] >= min:
        erabu += 1
print("Yes" if erabu >= m else "No")

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

int main() {
char ch;
while(1){
scanf("%c",&ch);
		if (isalpha(ch)) {
			if (islower(ch)) {
				printf("%c", toupper(ch));
			} else {
				printf("%c", tolower(ch));
			}
		} else {
			printf("%c", ch);
		}
		if(ch=='\n')break;
	}
}










 

        

 









Measured memory_bytes: 3164
n,m,*abc=map(int,open(0).read().split())
a=abc[:n]
a.sort()
bc=[[x,y] for x,y in zip(abc[n::2],abc[n+1::2])]
bc.sort(key=lambda x:x[1],reverse=True)
ai = 0
for b,c in bc:
    cc = b
    while ai<n and cc >0:
        if a[ai] < c:
            a[ai] = c
            cc -= 1
        ai +=1
    if ai ==n:
        break
print(sum(a))
        

Measured memory_bytes: 35420
x = int(input())
if x < 600:
  print(8)
elif x < 800:
  print(7)
elif x < 1000:
  print(6)
elif x < 1200:
  print(5)
elif x < 1400:
  print(4)
elif x < 1600:
  print(3)
elif x < 1800:
  print(2)
elif x < 2000:
  print(1)
  

Measured memory_bytes: 9192
n = gets.chomp.to_i
hash = {"1:" => 0,"2:" => 0, "3:" => 0,"4:" => 0,"5:" => 0,"6:" => 0 }
n.times do
  h = gets.chomp.to_f
  if h < 165.0
    hash["1:"] += 1
    elsif h >= 165.0 && h < 170.0
    hash["2:"] += 1
    elsif h >= 170 && h < 175.0
    hash["3:"] += 1
    elsif h >= 175.0 && h < 180.0
    hash["4:"] += 1
    elsif h >= 180.0 && h < 185.0
    hash["5:"] += 1
    elsif h >= 185.0
    hash["6:"] += 1
  end
end

hash.each do |k,v|
puts "#{k}#{"*" * v}"
end


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

import static java.lang.System.in;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String[] inputs = reader.readLine().split(" ");
        String A = inputs[0];
        String B = inputs[1];
        String C = inputs[2];
        if((A.charAt(A.length()-1) == B.charAt(0)) && (B.charAt(B.length()-1) == C.charAt(0))) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

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

#define int long long int
const int mxN = 405;
int dp[mxN][mxN];
const int INF = 1e18;

// find minimum cost to combine all elements given when x, y are combined cost = x+y
// the array elements can be considered as leaves of a binary tree
// we combine them to form nodes
// also every node represents an interval - cost for that interval should be minimized 

// dp[i][j] - min cost to combine interval [i, j]
// our ans = dp[1][n]

void solve() {
    int n;
    cin >> n;

    int a[n+1];
    for(int i=1; i<=n; i++)
        cin >> a[i];
    
    int pref[n+1];
    memset(pref, 0, sizeof(pref));
    for(int i=1; i<=n; i++)
        pref[i] = pref[i-1] + a[i];
    
    // intervals 
    for(int L=n; L>=1; L--) {
        for(int R=L; R<=n; R++) {

            if(L == R) {             // if interval consist of single node - cost = 0
                dp[L][R] = 0;
            
            } else {    
                dp[L][R] = INF;
                int sum = pref[R]-pref[L-1];

                // breaking intervals of L, R segments of left child and right child - to discpver all possibilites 
                for(int i=L; i<=R-1; i++) {
                    dp[L][R] = min(dp[L][R], dp[L][i] + dp[i+1][R] + sum);
                }
            }
        }
    }

    cout << dp[1][n] << endl;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
}

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

int main(){

  int n,m,q;

  cin >> n >> m >> q;

  int size = n;

  bool table[n];

  list<int> l;

  for(int i=0;i<n;i++){
    table[i] = true;
    l.push_back(i);
  }

  list<int>::iterator index=l.begin();

  for(int i=0;i<m;i++){
    int tmp=0,j=0;
    cin >> tmp;
    if(tmp%2==0){
      while(j!=tmp){
        index++;
        if(index==l.end()){
          index = l.begin();
        }
        j++;
      }
      table[*index] = false;
      list<int>::iterator tmp=index;
      index++;
      if(index==l.end()){
        index = l.begin();
      }
      l.erase(tmp);

    }
    else{
      while(j!=tmp){
        if(index==l.begin()){
          index = l.end();
          index--;
        }
        else{
          index--;
        }
        j++;
      }
      table[*index] = false;
      list<int>::iterator tmp=index;
      index++;
      if(index==l.end()){
        index = l.begin();
      }
      l.erase(tmp);
    }
  }

  index = l.begin();

  for(int i=0;i<q;i++){
    int ansindex,ans;
    cin >> ansindex;
    ans = (table[ansindex]) ? 1 : 0;
    cout << ans << endl;
  }

    return 0;
}

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

class Cube{
public:
	int f[6];
	Cube(){}
		void roll_z(){roll(1,2,4,3);}
		void roll_y(){roll(0,2,5,3);}//to W
		void roll_x(){roll(0,1,5,4);}//to N
		void roll(int i,int j,int k, int l){
			int t=f[i];f[i]=f[j];f[j]=f[k];f[k]=f[l];f[l]=t;
		}
		void move(char ch){
			if(ch=='E')for (int i = 0; i < 3; ++i) {roll_y();}
			if(ch=='W')roll_y();
			if(ch=='N')roll_x();
			if(ch=='S')for (int i = 0; i < 3; ++i) {roll_x();}
		}
};
bool eq(Cube c1,Cube c2){
	for (int i = 0; i < 6; ++i) {
		if (c1.f[i] != c2.f[i]) {return false;}
	}return true;
}
bool equal(Cube c1,Cube c2){
	for (int i = 0; i < 6; ++i) {
		for (int j = 0; j < 4; ++j) {
			if (eq(c1,c2)) return true;
						c1.roll_z();
		}
		if (i%2==0) {c1.roll_y();}
		else{c1.roll_x();}
	}
	return false;
}


int main() {
	Cube c1,c2;
	for (int i = 0; i < 6; ++i) cin>>c1.f[i];
	for (int i = 0; i < 6; ++i) cin>>c2.f[i];

	if (equal(c1,c2)) {cout<<"Yes"<<endl;}
	else {cout<<"No"<<endl;}

	return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD=1000000007;

int main() {
    ll A,B,C,K; cin>>A>>B>>C>>K;
    ll ans=0;
    if(K>A){
        ans+=1*A;
        K-=A;
        if(K>B){
            K-=B;
            ans+=K*-1;
        }
    }
    else{
        ans=1*K;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h> 
using namespace std; 
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define lcm(a,b)     (a*b)/__gcd(a,b)
#define bs(v,x)      binary_search(v.begin(),v.end(),x)
#define ub(v,x)      upper_bound(v.begin(),v.end(),x)
#define lb(v,x)      lower_bound(v.begin(),v.end(),x)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(a) (a).begin(),(a).end() 
#define inp(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define trace(v) for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cerr<<endl;
#define printv(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout<<"\n";
#define Pi 3.14159265
#define PII pair<ll, ll>; 
#define reset(x) memset(x,'z',sizeof(x))
#define f first
#define s second
#define mp make_pair
#define pq1 priority_queue<ll>;
#define pq2 priority_queue<ll, vector<ll>,greater<ll>>;
typedef long long ll;
typedef vector<ll> vll;
typedef bool B;
typedef double ff;
//const ll INF=1e10;
const ll MAX_N = 100005;
char en='\n';   
         
         void solve()
         {
            ll n,d;
            cin>>n>>d;
            ll ans=0,x,y;
            rep(i,0,n)
            {
               cin>>x>>y;
               ff e=sqrt(ff(x)*ff(x)+ff(y)*ff(y));
               if(e<=d)
                  ans++;
            }
            cout<<ans;
         }

         int main()
         { 
               ios_base::sync_with_stdio(false);cin.tie(NULL); 
               #ifndef ONLINE_JUDGE 
                        freopen("input.txt", "r", stdin); 
                        freopen("error.txt", "w", stderr); 
                        freopen("output.txt", "w", stdout); 
               #endif 
                        int t=1; 
                        //cin>>t; 
                        while(t--) 
                        {   
                           solve();
                           cout<<en;
                        } 
               cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
               return 0; 
         }

Measured memory_bytes: 3820
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll d,n; cin >> d >> n;
  
  if(d==0){
    if(n==100) cout << 101;
    else cout << n;
  }
  else if(d==1){
    if(n==100) cout << 10100;
    else cout << 100*n;
  }
  else{
    if(n==100) cout << 1010000;
    else cout << 10000*n;
  }
  
  cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define msg(x) debug() << x
#define int long long
const int xx = 2e5;
const int MOD = 1e9 + 7;

vector<int> fac, facInv, inv;
void facInit(int nmax)
{
    fac = facInv = inv = vector<int>(nmax + 1, 1);
    for (int i = 2; i <= nmax; i++)
    {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        facInv[i] = facInv[i-1] * inv[i] % MOD;
    }
}
int nCr(int n, int r)
{
    if (n < 0 or n<r or r<0) return 0;

    return (fac[n] * facInv[r] % MOD) * facInv[n-r] % MOD;
}


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

  int  X , Y ;
  cin >> X >> Y;
  int H = (X+Y)/3;

  if(H * 3 !=(X+Y)){
    cout << 0 << '\n';
    return 0; 
  }

  int a = (2*X - Y) / 3;
  int b = (2*Y - X) / 3;

  if(a < 0  || b < 0){
    cout << 0 << '\n';
    return 0;
  }

  int N = a + b;
  facInit(N);
  cout << nCr(N , a) << '\n';

}

Measured memory_bytes: 15872
#include<stdio.h>

int main()
{
    int a,b,e;
    char op;
    scanf("%d %c %d",&a,&op,&b);
    if(op=='+')
    {
          printf("%d",a+b);
    }
     else
    {
          printf("%d",a-b);
    }
    return 0;
}

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

typedef long long ll;

template <class T>
ostream & operator << (ostream &out, const vector<T> v) {
    for (int i = 0; i < int(v.size()); i++) {
        out << v[i] << " ";
    }
    return out;
}

ll solve() {
    int R, C, K;
    cin >> R >> C >> K;

    auto A = vector<vector<ll>>(R + 1, vector<ll>(C + 1, 0));
    for (int k = 0; k < K; k++) {
        int r, c, v; cin >> r >> c >> v; r--; c--;
        A[r][c] = v;
    }

    // dp[r, c, p] = maximum sum of value from (0, 0) to (r, c) 
    //               if p items are picked in previous C grids
    auto dp = vector<vector<vector<ll>>>(R + 1, vector<vector<ll>>(C + 1, vector<ll>(5, 0)));
    dp[0][0][1] = ((A[0][0] > 0) ? A[0][0] : 0);

    for (int r = 0; r < R; r++) {
        for (int c = 0; c < C; c++) {
            for (int p = 0; p < 4; p++) {
                // walk right and pick
                dp[r][c + 1][p + 1] = max(dp[r][c + 1][p + 1], dp[r][c][p] + A[r][c + 1]);
                // walk right and don't pick
                dp[r][c + 1][p] = max(dp[r][c + 1][p], dp[r][c][p]);
                // walk down and pick
                dp[r + 1][c][1] = max(dp[r + 1][c][1], dp[r][c][p] + A[r + 1][c]);
                // walk down and don't pick
                dp[r + 1][c][0] = max(dp[r + 1][c][0], dp[r][c][p]);
            }
        }
    }

    return *max_element(dp[R - 1][C - 1].begin(), dp[R - 1][C - 1].begin() + 4);
}

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

    cout << solve() << endl;

    return 0;
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	char s;
	int r=0,b=0;
	for (int i = 0; i < n; ++i)
	{
		cin>>s;
		if (s=='R')
		{
			++r;
		}
		else
		{
			++b;
		}
	}
	if (r>b)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
	return 0;
}


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

int id = INT_MAX;
int merge(int l, int r) {
	return min(l, r);
}

struct node {
	int val;
	int all;
	node *lch, *rch;
	int size;
	node(int v) : val(v), all(v), size(1) {
		lch = rch = nullptr;
	}
};

int count(node *t) { return t == nullptr ? 0 : t->size; }
int que(node *t) { return t == nullptr ? id : t->all; }
node *update(node *t) {
	t->size = count(t->lch) + count(t->rch) + 1;
	t->all = merge(que(t->lch), merge(t->val, que(t->rch)));
	return t;
}
node *merge(node *l, node *r) {
	if (l == nullptr || r == nullptr) return l == nullptr ? r : l;
	if (rand() % (l->size + r->size) < l->size) {
		l->rch = merge(l->rch, r);
		return update(l);
	}
	else {
		r->lch = merge(l, r->lch);
		return update(r);
	}
}
pair<node*, node*> split(node *t, int k) {
	if (t == nullptr) return make_pair(nullptr, nullptr);
	if (k <= count(t->lch)) {
		pair<node*, node*> s = split(t->lch, k);
		t->lch = s.second;
		return make_pair(s.first, update(t));
	}
	else {
		pair<node*, node*> s = split(t->rch, k - count(t->lch) - 1);
		t->rch = s.first;
		return make_pair(update(t), s.second);
	}
}
node *insert(node *t, int k, int v) {
	pair<node*, node*> s = split(t, k);
	node *r = merge(s.first, new node(v));
	r = merge(r, s.second);
	return r;
}
node *erase(node *t, int k) {
	pair<node*, node*> s1 = split(t, k), s2 = split(s1.second, 1);
	if (s2.first != nullptr) delete s2.first;
	return merge(s1.first, s2.second);
}
node *find(node *t, int k) {
	if (t == nullptr) return t;
	int c = count(t->lch);
	return k < c ? find(t->lch, k) : k == c ? t : find(t->rch, k - (c + 1));
}
int find(node *t, int l, int r) {
	if (t == nullptr) return id;
	if (r < 0 || l >= count(t)) return id;
	if (l <= 0 && r >= count(t)) return t->all;
	int c = count(t->lch);
	return merge(t->lch == nullptr ? id : find(t->lch, l, r), merge(l <= c && c < r ? t->val : id, t->rch == nullptr ? id : find(t->rch, l - (c + 1), r - (c + 1))));
}
int cnt(node *t, int v) {
	if (t == nullptr) return 0;
	if (t->val < v) return count(t->lch) + 1 + cnt(t->rch, v);
	if (t->val == v) return count(t->lch);
	return cnt(t->lch, v);
}
void print(node *t) {
	if (t == nullptr) return;
	print(t->lch);
	printf(" %d", t->val);
	print(t->rch);
}
node *shift(node *t, int l, int r) {
	pair<node*, node*> s1 = split(t, l), s2 = split(s1.second, r - l), s3 = split(s2.second, 1);
	return merge(s1.first, merge(s3.first, merge(s2.first, s3.second)));
}
void change(node *t, int k, int v) {
	if (t == nullptr) return;
	int c = count(t->lch);
	if (k < c) {
		change(t->lch, k, v);
		update(t);
	}
	else if (k > c) {
		change(t->rch, k - (c + 1), v);
		update(t);
	}
	else {
		t->val = v;
		update(t);
	}
}

int main()
{
	cin.sync_with_stdio(false);
	int n, q, x, y, z;
	cin >> n >> q;
	node *root = nullptr;
	srand((unsigned int)time(NULL));
	for (int i = 0, a; i < n; i++) {
		cin >> a;
		root = insert(root, i, a);
	}
	while (q--) {
		cin >> x >> y >> z;
		if (x == 0) {
			root = shift(root, y, z);
		}
		else if (x == 1) {
			printf("%d\n", find(root, y, z + 1));
		}
		else {
			change(root, y, z);
		}
	}
	return 0;
}

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

int N;

string Input(map<string, set<string> >& m) {
    string str;
    int count = 0;
    stringstream ss;
    cin >> str;
    for (int i = 0; i < (int)str.size(); i++) {
        if (str[i] == ':' || str[i] == ',' || str[i] == '.') {
            count++;
            str[i] = ' ';
        }
    }

    ss << str;
    string top;
    ss >> top;
    for (int i = 0; i < count - 1; i++) {
        string s;
        ss >> s;
        m[top].insert(s);
    }

    return top;
}

void solve() {
    map<string, set<string> > m;
    vector<string> sSet(N);
    for (int i = 0; i < N; i++) sSet[i] = Input(m);

    set<string> ans;
    queue<string> que;
    for (auto i : m[sSet[0]]) que.push(i);
    map<string,bool> used;
    while (que.size()) {
        string str = que.front(); que.pop();
        used[str] = true;
        if (m.find(str) == m.end()) ans.insert(str);
        else {
            for (auto i : m[str])
                if (used.find(i) == used.end()) que.push(i);
        }
    }

    cout << ans.size() << endl;
}

int main() {
    while (cin >> N, N) solve();

    return 0;
}

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

using namespace std;

int main()
{
  int A, B, Q;
  cin >> A >> B >> Q;
  vector<long long> s(A), t(B), x(Q);
  for (int i = 0; i < A; i++)
    cin >> s[i];
  for (int i = 0; i < B; i++)
    cin >> t[i];
  for (int i = 0; i < Q; i++)
    cin >> x[i];
  vector<pair<long long, long long>> start(A + B);
  for (int i = 0; i < A; i++)
  {
    int it = lower_bound(t.begin(), t.end(), s[i]) - t.begin();
    long long tmp = 1e18;
    if (0 < it)
      tmp = min(tmp, abs(s[i] - t[it - 1]));
    if (it < B)
      tmp = min(tmp, abs(s[i] - t[it]));
    start[i] = {s[i], tmp};
  }
  for (int i = 0; i < B; i++)
  {
    int it = lower_bound(s.begin(), s.end(), t[i]) - s.begin();
    long long tmp = 1e18;
    if (0 < it)
      tmp = min(tmp, abs(t[i] - s[it - 1]));
    if (it < A)
      tmp = min(tmp, abs(t[i] - s[it]));
    start[A + i] = {t[i], tmp};
  }
  sort(start.begin(), start.end());
  for (int i = 0; i < Q; i++)
  {
    int it = lower_bound(start.begin(), start.end(), pair<long long, long long>(x[i], 0)) - start.begin();
    long long ans = 1e18;
    if (0 < it)
      ans = min(ans, abs(x[i] - start[it - 1].first) + start[it - 1].second);
    if (it < A + B)
      ans = min(ans, abs(x[i] - start[it].first) + start[it].second);
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 6784
#D
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
d = []
for i in range(m):
    b, c = map(int, input().split())
    d.append([b, c])
#print(d)
d = sorted(d, key=lambda x: x[1], reverse=True)
#print(d)
k = 0
for i in range(n):
    if d[k][0] == 0:#追加できなくなる
        k += 1
        if k == len(d):  #配列末
            break
    if a[i] >= d[k][1]:  #a>=cなのでこれ以上置き換わっても意味がない
        break
    a[i] = d[k][1]  #cに置き換わった
    d[k][0] -= 1  #dの追加出来る数を１減らす
print(sum(a))

Measured memory_bytes: 26428
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>

using namespace std;

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

#define RANGE(a,i,b) ((a)<=(i)&&(i)<=(b))

#define pb push_back
#define mp make_pair

#define ALL(a) (a).begin(), (a).end()

#define SET(a,c) memset(a,c,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))

#define INF 1001001001
#define LLINF 1001001001001001001LL

typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

#define PQ priority_queue

#define FST first
#define SEC second

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

//------------------HEAD---------------------

int dp[1000][1000];//d[i][j]:??????i+1???j??\????????????????°??????????

int N,M;
int D[1000];
int C[1000];

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>M;
    rep(i,N){
        int t;
        cin>>t;
        D[i]=t;
    }
    rep(i,M){
        int t;
        cin>>t;
        C[i]=t;
    }

    rep(i,N)rep(j,M)dp[i][j]=INF;    

    rep(d,M){
        dp[0][d]=D[0]*C[d];
    }

    FOR(i,1,N){
        int mind=INF;
        FOR(d,1,M){
            mind=min(mind,dp[i-1][d-1]);
            dp[i][d]=mind+D[i]*C[d];
        }
    }

    int res=INF;
    rep(d,M){
        res=min(res,dp[N-1][d]);
    }
    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 6328
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

map<string,vector<int>> p;

int main()
{
    string str;
    int t;
    while (cin >> str >> t) p[str].push_back(t);
    for (auto it = p.begin(); it != p.end(); it++) {
        sort(it->second.begin(), it->second.end());
        cout << it->first  << endl << it->second[0];
        for (int j = 1; j < it->second.size(); j++)
            cout << " " << it->second[j];
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b; cin >> a >> b;
    cout << a * b << '\n';
    return 0;
}


Measured memory_bytes: 3644
a, b = map(int, raw_input().split())
# 1 + d(a - 1) > b
# d(a - 1) > b - 1
# d > (b - 1) / (a - 1)
d, m = divmod(b - 1, a - 1)
if m > 0:
	d += 1
print d


Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  sort(s.begin(),s.end());
  char a='a';
  for(int i=0;i<s.size();i++){
    if(a==s.at(i))
      a++;
    if(a<s.at(i))
      break;
  }
  if(a<='z')
    cout<<a<<endl;
  else
    cout<<"None"<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <ctime>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	int n; cin >> n;
	vector<int> V(n+1),W(n+1);
	rep(i,n) cin >> V[i+1] >> W[i+1];
	int M = 1<<13;
	vector<vector<pair<int,int>>> vp(M+1);
	vp[0].emplace_back(0,0);
	REP(i,1,M+1){
		if(i > n) break;
		vector<pair<int,int>> vv;
		for(auto b : vp[i/2]){
			vv.emplace_back(b);
			vv.emplace_back(b.first+W[i], b.second+V[i]);
		}
		sort(all(vv));
		int now = -1;
		for(auto b : vv){
			if(now < b.second){
				vp[i].push_back(b);
				now = b.second;
			}
		}
	}
	int q; cin >> q;
	while(q--){
		int v,L; scanf("%d%d",&v,&L);
		vector<pair<int,int>> acc;
		acc.emplace_back(0,0);
		while(v > M){
			vector<pair<int,int>> tmp;
			for(auto b : acc){
				tmp.emplace_back(b);
				tmp.emplace_back(b.first+W[v], b.second+V[v]);
			}
			acc = tmp;
			v >>= 1;
		}
		int ans = 0;
		for(auto b : acc){
			pair<int,int> pp = {L-b.first, inf};
			auto itr = lower_bound(all(vp[v]), pp);
			if(itr != vp[v].begin()){
				itr--;
				chmax(ans, (*itr).second + b.second);
			}
		}
		cout << ans << "\n";
	}
}

Measured memory_bytes: 282640
#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>;

int main() {
  int N;
  string S;
  cin >> N >> S;
  int a = 0, b = 0;
  
  rep(i, N) if (S[i] == 'R') a++;
  int ans = max(a, b);
  rep(i, N) {
    if (S[i] == 'R') a--;
    else b++;
    int now = max(a, b);
    ans = min(ans, now);
  }

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


Measured memory_bytes: 3724