akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

#pragma warning(disable : 4996)

int n, m, c, d, imos[1111];

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

	for (int i = 0; i < m; i++)
	{
		scanf("%d", &c);
		scanf("%d", &d);

		imos[c--]++;
		imos[d--]--;
	}

	int ret = n + 1, sum = 0;

	for (int i = 0; i < n; i++)
	{
		sum += imos[i];

		if (sum > 0) ret += 2;
	}

	printf("%d\n", ret);

	return 0;
}

Measured memory_bytes: 2752
import scala.io.StdIn

object Main extends App {
  StdIn.readLine()
  val sticks = StdIn.readLine().split(' ').map(_.toInt)

  val stickIdCombinations=scala.collection.mutable.Set.empty[Set[Int]]
  for(s1 <- 0 until sticks.length){
    for(s2 <- 0 until sticks.length){
      for(s3 <- 0 until sticks.length){
        val stickLens = List(s1,s2,s3).map(sticks(_)).toSet
        if(stickLens.size == 3){
          stickIdCombinations += Set(s1,s2,s3)
        }
      }
    }
  }

  val ans = (for (stickIds <- stickIdCombinations.toList) yield {
    val List(s1, s2, s3) = stickIds.toList.map(sticks(_))
    if (s1 + s2 > s3 && s2 + s3 > s1 && s3 + s1 > s2)
      1
    else
      0
  }).sum

  println(ans)



}








Measured memory_bytes: 74728
import numpy as np
import sys
sys.setrecursionlimit(10**9)


INF=10**20
def solve(N,P,S,fact):
    ans = 0

    if not 10 % P == 0:
        d = [0] * (P+1)
        s = 0
 
        d[0] = 1
        for i in range(N):
            s += S[N-i-1] * fact[i]
            s %= P
            # s = int(s)
            d[s] += 1
            # print(s)
 
        for m in range(P):
            if d[m] > 0:
                ans += d[m] * (d[m]-1) // 2
 
    else:
        for i in range(N):
            if S[i] % P == 0:
                ans += i+1

 
    return ans

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    S = list(next(tokens))  # type: str

    fact = [pow(10,i,P) for i in range(N)]

    S = list(map(int,S))
    S = np.array(S)
    print(solve(N, P, S,np.array(fact)))


def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')

    # basic types: https://numba.pydata.org/numba-doc/0.13/types.html
    cc.export('solve', '(i8,i8,i8[:],i8[:],)')(solve)
    cc.compile()

if __name__ == '__main__':
    # cc_export()
    try:
        from my_module import solve
    except:
        cc_export()
        exit()

    main()



Measured memory_bytes: 38604
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 600;
bool A[MAXN + 5][MAXN + 5];
double f[MAXN + 5], g[MAXN + 5], d[MAXN + 5];
int main() {
	int n, m; scanf("%d%d", &n, &m);
	for(int i=1;i<=m;i++) {
		int a, b; scanf("%d%d", &a, &b);
		A[a][b] = true, d[a]++;
	}
	for(int i=n;i>=1;i--) {
		f[i] = 0;
		for(int j=i+1;j<=n;j++)
			if( A[i][j] )
				f[i] += (f[j] + 1) / d[i];
	}
	double ans = f[1];
	for(int i=n;i>=1;i--) {
		if( d[i] > 1 ) {
			int mx = -1;
			for(int j=i+1;j<=n;j++)
				if( A[i][j] ) {
					if( mx == -1 || f[j] > f[mx] )
						mx = j;
				}
			g[i] = 0;
			for(int j=i+1;j<=n;j++)
				if( A[i][j] ) {
					if( j != mx ) {
						g[i] += (g[j] + 1) / (d[i] - 1);
					}
				}
			for(int j=i-1;j>=1;j--) {
				g[j] = 0;
				for(int k=j+1;k<=n;k++)
					if( A[j][k] )
						g[j] += (g[k] + 1) / d[j];
			}
			ans = min(ans, g[1]);
		}
		g[i] = f[i];
	}
	printf("%.7lf\n", ans);
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define endl "\n"     
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

const int N=3005;

int cache[N][N][2];
int a[N];

int dp(int i,int j,int p)
{
     if(i==j)
          return (p?a[i]:-1*a[i]);
     int &ans=cache[i][j][p];
     if(ans!=-1)
          return ans;
     if(p)
          return ans=max(a[i]+dp(i+1,j,p^1),a[j]+dp(i,j-1,p^1));
     else
          return ans=min(dp(i+1,j,p^1)-a[i],dp(i,j-1,p^1)-a[j]);
}

int32_t main()
{
     memset(cache,-1,sizeof cache);
     int n;
     cin>>n;
     for(int i=1;i<=n;i++)
          cin>>a[i];
     cout<<dp(1,n,1);     
}

Measured memory_bytes: 141568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

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

	ll N,A,B,C,D,E,M;
	cin >> N >> A >> B >> C >> D >> E;
	M = min({A,B,C,D,E});
	ll ans = (N+M)/M+4;
	if(N%M==0){
		ans = N/M+4;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int             long long int
#define pb              push_back
#define se              second
#define mp              make_pair
#define fi              first
#define del(a,vec)      vec.erase(std::remove(vec.begin(), vec.end(), a), vec.end());
#define search(f,l,v)   binary_search(f,l,v)
#define iter(a,b)       vector<int>::iterator a,b
#define lower(v,num)    lower_bound (v.begin(), v.end(), num);
#define upper(v,num)    upper_bound (v.begin(), v.end(), num); 
#define removecopy(a)   unique(a.begin(), a.end()); 
#define vi              vector<int> 
#define pi              pair<int,int>    
#define vpi             vector<pi>      
#define mlbb            ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)    
int mod =1000000007;
namespace Rahul{
    bool isPrime(int n) 
    {if (n <= 1)  return false; if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; }
    int pow (int x, int n,int mod) {//calculate x^n
    if (n == 0) return 1;

    int res = pow (x, n / 2,mod);

    res = (res * res) % mod;
    if (n % 2) res = (res * x ) % mod;

    return res;
    }
    int _gcd(int a,int b)
    {
        if(a==0)
            return b;
        else    
            return _gcd(b%a,a);
    }
    //s.erase(s.find(2)) where s={1,2,3,3,2}; 
};
using namespace Rahul;
int32_t main()
{
    mlbb;
    
        int h,n;
        cin>>h>>n;
        vector< pair<int,int> > val;
        for(int i = 0; i < n ; i ++){
            int a,b;
            cin>>a>>b;
            val.pb(mp(a,b));
        }
        sort(val.begin(),val.end());
        vector< int > dp[h+1];

        unordered_map<int,int>minv;
        
        minv[0] = 0;
        for(int i = 1; i <= h ; i++){
            
            int minn = 1e15;
            for(int k =0 ;k < n ;k ++){
                
                int num = max(0,int32_t(i-val[k].fi));
                
                int ans = minv[num] + val[k].se;
                minn = min(ans,minn);
                
            }
            minv[i] = minn;
            
        }
        int ans = minv[h];
        cout<<ans<<endl;
}


Measured memory_bytes: 896
#include <iostream>
#include <queue>
#include <vector>
#include <string>
using namespace std;

int main() {

	long long int h, w;
	cin >> h >> w;

	vector< string > v;
	v.push_back( "######################" );

	for ( long long int i = 0; i < h; i++ ) {
		string in;
		cin >> in;
		v.push_back( "#" + in + "#" );
	}
	v.push_back( "######################" );

	long long int ans = 0;

	for ( long long int sy = 1; sy <= h; sy++ ) {
		for ( long long int sx = 1; sx <= w; sx++ ) {
			if ( v[sy][sx] == '#' ) continue;
			bool f[22][22] = {};
			queue< pair< long long int, pair< long long int, long long int > > > q;
			q.push( make_pair( 0, make_pair( sy, sx ) ) );
			while ( q.size() > 0 ) {
				long long int k = q.front().first;
				long long int y = q.front().second.first;
				long long int x = q.front().second.second;
				q.pop();
				if ( f[y][x] ) continue;
				f[y][x] = true;
				ans = max( ans, k );
				if ( v[y - 1][x] == '.' ) q.push( make_pair( k + 1, make_pair( y - 1, x ) ) );
				if ( v[y + 1][x] == '.' ) q.push( make_pair( k + 1, make_pair( y + 1, x ) ) );
				if ( v[y][x - 1] == '.' ) q.push( make_pair( k + 1, make_pair( y, x - 1 ) ) );
				if ( v[y][x + 1] == '.' ) q.push( make_pair( k + 1, make_pair( y, x + 1 ) ) );
			}
		}
	}

	cout << ans << endl;

}


Measured memory_bytes: 256
/*
     Author:Raghav Bansal
     IIIT Una
                  */
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BOLT ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define X first
#define Y second
#define endl "\n"
using namespace std;
void solve() {
	int k, a, b;
	cin >> k >> a >> b;
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			cout << "OK" << endl;
			return;
		}
	}
	cout << "NG" << endl;
}
int32_t main() {
	BOLT;
	solve();
}

Measured memory_bytes: 3648
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int d = sc.nextInt();
      String s = sc.next();
      boolean tobuB = false;
      if(s.substring(a-1,c).contains("##"))System.out.println("No");
      else if(s.substring(b-1,d).contains("##"))System.out.println("No");
      else if(c<d)System.out.println("Yes");
      else{
        if(s.substring(b-2,d+1).contains("..."))tobuB=true;
        if(tobuB)System.out.println("Yes");
        else System.out.println("No");
      }
    }
}


Measured memory_bytes: 26672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()
template <int MOD>
class ModInt {
  long long x;

 public:
  ModInt(long long v = 0) : x(v % MOD) {
    if (x < 0) x += MOD;
  }

  ModInt& operator+=(const ModInt& r) {
    x += r.x;
    if (x >= MOD) x -= MOD;
    return *this;
  }

  ModInt& operator-=(const ModInt& r) {
    x -= r.x;
    if (x < 0) x += MOD;
    return *this;
  }
  ModInt& operator*=(const ModInt& r) {
    x = (x * r.x) % MOD;
    return *this;
  }
  ModInt& operator/=(const ModInt& r) {
    *this *= r.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt& r) const { return ModInt(*this) += r; }
  ModInt operator-(const ModInt& r) const { return ModInt(*this) -= r; }
  ModInt operator*(const ModInt& r) const { return ModInt(*this) *= r; }
  ModInt operator/(const ModInt& r) const { return ModInt(*this) /= r; }
  bool operator==(const ModInt& r) const { return x == r.x; }
  bool operator!=(const ModInt& r) const { return x != r.x; }

  ModInt inverse() const {
    long long a = x, b = MOD, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt<MOD> pow(long long n) const {
    ModInt ret(1), mul(x);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream& operator<<(ostream& os, const ModInt& x) { return os << x.x; }

  friend istream& operator>>(istream& is, ModInt& x) { return is >> x.x; }

  int getMod() { return MOD; }
};
using mint = ModInt<1000000007>;

int N;
vector<vector<int>> a;

int main() {
  cin >> N;
  a.resize(N, vector<int>(N));
  rep(i, N) rep(j, N) cin >> a[i][j];

  vector<vector<mint>> dp(N + 1, vector<mint>(1 << N, 0));

  dp[0][0] = 1;

  rep(i, N) {
    int s = (1 << (i + 1)) - 1;
    while (s < (1 << N)) {
      rep(j, N) {
        if (((s >> j) & 1) && a[i][j]) dp[i + 1][s] += dp[i][s & ~(1 << j)];
      }

      int x = s & -s, y = s + x;
      s = (((s & ~y) / x) >> 1) | y;
    }
  }

  mint ans = 0;
  rep(s, 1 << N) ans += dp[N][s];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 377216
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>


using namespace std;

int main(){

	long long N, M, Q;
	cin >> N >> M >> Q;

	long long A[N+1][N+1];

	for(int i = 0; i <= N; i++){
		for(int j = 0; j <= N; j++){
			A[i][j] = 0;
		}
	}

	for(long long m = 0; m < M; m++){
		int l, r;
		cin >> l >> r;
		A[l][r]++;
	}

	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= N; j++){
			A[i][j] += A[i][j-1];
			A[i][j] += A[i-1][j];
			A[i][j] -= A[i-1][j-1];
		}
	}

	for(long long i = 0; i < Q; i++){
		int p, q;
		cin >> p >> q;
		cout << A[q][q] - A[q][p-1] - A[p-1][q] + A[p-1][p-1] << endl;
	}

	return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;
typedef vector<LL> VEC;


const LL INF=1<<30;
const LL MOD=1000000007;

LL gcd(LL a,LL b){
    if(b==0)return a;

    return gcd(b,a%b);
}

LL kaijo(LL n){
    LL ans=1;
    for(LL i=1;i<=n;++i){
        (ans*=i)%=MOD;
    }
    return ans;
}


int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int ma=min(b,d);
    int mi=max(a,c);
    cout<<max(0,ma-mi)<<endl;
}

Measured memory_bytes: 256
import numpy as np

NMC = list(map(int,input().split(" ")))
B = np.array(list(map(int,input().split(" "))))
A = [np.array(list(map(int,input().split(" ")))) for i in range(NMC[0])]
_ = []
for i in range(NMC[0]):
    _.append(np.dot(B,A[i])+NMC[2]>0)
print(_.count(True))

Measured memory_bytes: 14328
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include <bits/stdc++.h>


using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
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; }

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


//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class ATOrT {
public:
    void solve(istream& cin, ostream& cout) {
      int n, a, b; cin >> n >> a >> b;
      cout << min(a*n, b) << endl;
    }
};

signed main() {
  SPEED;
  ATOrT solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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


E = int(C / B)
F = C % B

if C % B != 0 :
    E += 1

G = int(A / D)
H = A % D

if A % D != 0 :
    G += 1

if E > G:
    print('No')
else :
    print('Yes')

Measured memory_bytes: 9128
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    int n;
    cin >> n;
    int x[102]={};
    REP(i, 26){
        REP(j, 16){
            x[min(101, i*4 + j*7)]++;
        }
    }
    if (x[n]>0) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    //cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPR(i, n) for (int i = (n); i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) std::cout << (x) << std::endl
typedef long long ll;

int main() {
    string s;
    cin >> s;
    int len = s.size();
    REP(i, len) {
        cout << 'x';
    }
    cout << endl;
}

Measured memory_bytes: 256
n = int(input())
ai = [int(input()) for i in range(n)]

tmp = ai[n-1]
ans = 0
ren = 0

if ai[0] != 0:
    print(-1)
    exit()

for i in range(1,n):
    if tmp - 1 > ai[n-i-1]:
        print(-1)
        exit()
    #print(i,n-i-1)
    if tmp - 1 == ai[n-i-1]:
        tmp -= 1
        ren += 1
        #print(ai[n-i-1],n-i-1)
    else:
        ans += ai[n-i]
        ans += ren
        #print(ans,ans,ans)
        tmp = ai[n-i-1]
        ren = 0

ans += ai[0]
ans += ren
    
print(ans)

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

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

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	double r;
	cin >> r;
	cout << DOUBLE << r*r*pi << " " << 2*r*pi << endl;
	return 0;
}


Measured memory_bytes: 3276
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


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


int main(){
	string n;
	int tmp;
	int x[3];
	cin >> n;
	rep(i, 3) {
		tmp = (int) n[i] - 48;
		if (tmp == 1) tmp = 9;
		else if (tmp == 9) tmp = 1;
		x[i] = tmp;
	}
	printf("%d", x[0]*100 + x[1]*10 + x[2]);


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
constexpr int mod = 1e9 +7;
constexpr int MAXN = 1e5 + 7;
inline long long read()
{
	char c = getchar();long long flag = 1, ans = 0;;
	while(c < '0' || c > '9'){if(c == '-')flag = -1; c = getchar();}
	while(c >= '0' && c <= '9'){ans = ans * 10 + c - '0'; c = getchar();}
	return (ans * flag);
}
long long qp(long long a, long long b, long long p) {
    long long ans = 1;
    for(; b; b >>= 1) {
        if(b & 1) ans = 1ll * ans * a % p;
        a = 1ll * a * a % p;
    }
    return ans;
}
// C'est la vie
int fac[MAXN], ifac[MAXN];
int C(int a, int b) {
    int res = 1ll * fac[a] * ifac[b] % mod * ifac[a - b] % mod;
    return res;
}
int main() {
    int n = read(), k = read();
    vector<int> ve(n + 2, 0);
    for(int i = 1; i <= n; ++ i) {
        ve[i] = read();
    }
    sort(ve.begin() + 1, ve.begin() + n + 1);
    for(int i = 1; i <= n; ++ i) {
        if(ve[i] < 0) ve[i] += mod;
    }
    fac[0] = 1;
    for(int i = 1; i <= n; ++ i) fac[i] = 1ll * fac[i - 1] * i % mod;
    ifac[n] = qp(fac[n], mod - 2, mod);
    for(int i = n - 1; i >= 0; -- i) ifac[i] = 1ll * ifac[i + 1] * (i + 1) % mod;
    int ans1 = 0, ans2 = 0;
    for(int i = k; i <= n; ++ i) {
        ans1 += 1ll * ve[i] * C(i - 1, k - 1) % mod;
        if(ans1 >= mod) ans1 -= mod;
    }
    for(int i = 1; i <= n - k + 1; ++ i) {
        ans2 += 1ll * ve[i] * C(n - i, k - 1) % mod;
        if(ans2 >= mod) ans2 -= mod;
    }
    cout << (ans1 - ans2 + mod) % mod << endl;
    system("pause");
}

Measured memory_bytes: 1656
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m,tv=0;
  double mn;
  cin>>n>>m;
  int a[n],count=0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    tv+=a[i];
  }
  //cout<<tv<<endl;
  for(int i=0;i<n;i++)
  {
    mn=(double)tv/(4*m);
   	if(a[i]>=mn)
     count++;
  }
  //cout<<mn<<endl;
 // cout<<count<<endl;
  if(count>=m)
    cout<<"Yes";
  else
    cout<<"No";
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
 
    n = int(input())
    a = list(map(int, input().split()))
    q = int(input())
    d = [0 for _ in range(10 ** 5)]
    ans = sum(a)
 
    for ai in a:
        d[ai - 1] += 1
 
    for i in range(q):
        bi, ci = map(int, input().split())
        bi_count = d[bi - 1]
        # 操作による差分を操作前の和に加える
        ans += (ci - bi) * bi_count
        print(ans)
        # 操作による要素の差分を操作前の値に加える
        d[ci - 1] += d[bi - 1]
        d[bi - 1] = 0
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 20252
import math

n = int(input())
divs = []
for i in range(1, int(math.sqrt(n)) + 1):
    if n % i == 0:
        j = n // i
        if i != j:
            divs.append(j)
        divs.append(i)
divs.sort()

m = len(divs)
ans = 0
for i in range(1, m):
    z = divs[i]
    z2 = z
    prime = True
    for j in divs[1:i]:
        if z2 % j == 0:
            while z2 % j == 0:
                z2 //= j
            if z2 != 1:
                prime = False
    if prime:
        if n % z == 0:
            n //= z
            ans += 1
print(ans)


Measured memory_bytes: 68112
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int X[110];

int main() {
	int N, K;
	cin >> N >> K;
	int ans=0;
	while(N>0){
		N /= K;
		++ans;
	}
	cout << ans << endl;
	return 0;
}

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

int main(void){
  int n,x,y,i,j;
  cin >> n >> x >> y;
  vector<int> a(n,0);
  
  int d,p;
  for(i=1;i<=n-1;i++){
    for(j=i+1;j<=n;j++){
      p=0;
      if(i>x){
        p=i-x;
      }else{
        p=x-i;
      }
      if(j>y){
        p=p+j-y;
      }else{
        p=p+y-j;
      }
      p++;
      if(j-i>p){
        d=p;
      }else{
        d=j-i;
      }
      a.at(d)++;
    }
  }
  
  for(i=1;i<=n-1;i++){
    cout << a.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cstdint>
#include <cmath>
using namespace std;
using i64 = int64_t;

void solve() {
	int n;
	cin >> n;
	string s, t;
	s.reserve(n);
	t.reserve(n);
	cin >> s >> t;
	string u;
	u.reserve(2 * n);
	for (int i = 0; i < n; ++i) {
		u.push_back(s[i]);
		u.push_back(t[i]);
	}
	cout << u << endl;
}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int n, x, max;
    int a, b, c;
    int ans;
 
    while (1) {
        scanf("%d%d", &n, &x);
        if (n == 0 && x == 0) break;
 
        ans = 0;
        max = x; if (max > n) max = n;
        for (a = 1; a <= max; a++) {
            for (b = a + 1; b <= max; b++) {
                c = x - a - b;
                if (c > b && c <= n) ans++;
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 2056
using System;
using System.Collections.Generic;

namespace noteCsharp
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] inputstr = Console.ReadLine().Split(char.Parse(" "));
                int a = int.Parse(inputstr[0]);
                int b = int.Parse(inputstr[1]);
                int c = int.Parse(inputstr[2]);
                if(a==-1 && b==-1 && c == -1)
                {
                    return;
                }
                if(a==-1 || b ==-1){
                    Console.WriteLine("F");
                    continue;
                }
                if ((a + b) >= 80)
                {
                    Console.WriteLine("A");
                    continue;
                }
                if ((a + b) >= 65)
                {
                    Console.WriteLine("B");
                    continue;
                }
                if ((a + b) >= 50)
                {
                    Console.WriteLine("C");
                    continue;
                }
                if((a+b)>=30 && c >= 50)
                {
                    Console.WriteLine("C");
                    continue;
                }
                if ((a + b) >= 30)
                {
                    Console.WriteLine("D");
                    continue;
                }
                Console.WriteLine("F");
            }
        }
    }
}



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

int main()
{
	int count=0;
	cin >> count;

	int num[count];
	int tmp;
	int ans=0;

	for(int i=0; i<count; i++)
	{
	  cin >> num[i];
	}

	while(true)
	{
		tmp = 0;
		for(int i=0; i<count; i++)
		{
			tmp = tmp + num[i] % 2;
			num[i]=num[i]/2;
		}
		if(tmp > 0) break;
		ans++;
	}

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

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

using namespace std;

#define N 210000

int a[30], b[30];
char s1[N], s2[N];

int main() {
    while (scanf("%s", s1) != EOF) {
        scanf("%s", s2);
        memset(a, 0, sizeof(a));
        memset(b, 0, sizeof(b));
        int i, n = strlen(s1);
        for (i = 0; i < n; ++i) {
            a[s1[i] - 'a']++;
            b[s2[i] - 'a']++;
        }
        sort(a, a + 26); sort(b, b + 26);
        for (i = 0; i < 26; ++i) {
            if (a[i] != b[i]) break;
        }
        if (i < 26) puts("No");
        else puts("Yes");
    }
    return 0;
}


Measured memory_bytes: 512
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{

    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var A = new long[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = long.Parse(Console.ReadLine());
        }

        var coefs = new int[N];
        for (int i = 1; i < N; i += 2)
        {
            coefs[i - 1]--;
            coefs[i]++;
            if (i + 1 < N)
            {
                coefs[i]++;
                coefs[i + 1]--;
            }
        }


        var sum1 = Sum(A, coefs, N);

        // 符号の反転
        for (int i = 0; i < N; i++)
        {
            coefs[i] *= -1;
        }

        var sum2 = Sum(A, coefs, N);

        var ans = Math.Max(sum1, sum2);
        Console.WriteLine(ans);
    }

    static long Sum(long[] A, int[] coefs, int N)
    {
        coefs = coefs.OrderBy(c => c).ToArray();
        A = A.OrderBy(a => a).ToArray();
        var sum = 0L;
        for (int i = 0; i < N; i++)
        {
            sum += coefs[i] * A[i];
        }
        return sum;
    }
}



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

using namespace std;

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

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n;
	string s;
	cin >> n >> s;
	rep (i, s.size()) {
	  cout << char((s[i] - 'A' + n) % 26 + 'A');
	}
	cout << endl;
    
    return 0;
}



Measured memory_bytes: 3684
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char const* argv[]) {
    std::string s, ans("");
    std::cin >> s;

    for (int i = 0; i < s.length(); i++) {
        if (s.at(i) == '0' || s.at(i) == '1') {
            ans += s.at(i);
        } else if (ans == "") {

        } else {
            ans.erase(--ans.end());
        }
    }

    std::cout << ans << '\n';



    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main()
{
  long long int n,i;
  cin>>n;
  long long int sum=0;
  for(i=1;i<=n;i++)
  {
    if(i%3==0 || i%5==0)
    {
      continue;      
    }
    else
    {
        sum+=i;
    }
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 3624
def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y,x%y)

n = int(input())
t = [int(input()) for i in range(n)]

if n == 1:
    ans = t[0]
else:
    lcd = t[0]*t[1]//gcd(t[0],t[1])
    for i in range(2,n):
        lcd = lcd*t[i]//gcd(lcd,t[i])
    ans = lcd

print(ans)

Measured memory_bytes: 3064
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define ll long long
#define ull unsigned long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

vector<vector<ll> > dp;
int N, W;
vector<ll> w, v;
const ll INF = 1e14;

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

	cin >> N >> W;
	w.resize(N);
	v.resize(N);
	REP(i, N) cin >> w.at(i) >> v.at(i);
	
	dp = vector<vector<ll> >(N, vector<ll>(N*1000+1, INF));
	dp[0][0] = 0;
	dp[0][v[0]] = w[0];
	FOR(i, 1, N) {
		REP(j, 1000*N+1) {
			if(j-v[i] >= 0) dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]] + w[i]);
			else dp[i][j] = dp[i-1][j];
		}
	}
	for(ll i = 1000*N; i != 0; i--) {
		if(dp[N-1][i] <= W) {
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 79488
#include<iostream>
#include<cstring>
#include<string>
#include<unordered_set>
#include<vector>
using namespace std;
const int N = 200003;
typedef pair<int, int> PII;
string s;
int n, p2[11], p5[11];
vector<PII> db, it;
int dbc[14][8], itc[14][8];
long long cnt;
int f[25][25];
double a[N];
char c[20];

void get25(int x)
{
	++cnt;
	int cnt2 = 0, cnt5 = 0;
	while(x%2 == 0)
	{
		++cnt2;
		x >>= 1;
	}
	while(x%5 == 0)
	{
		++cnt5;
		x /= 5;
	}
	++f[10+cnt2][10+cnt5];
}

int main()
{
	cin >> n;
	memset(f, 0, sizeof f);
	for(int i = 0; i < n; ++i)
	{
		scanf("%s", c);
		int j = 0, x = 0;
		long long res = 0;
		while(c[j] && c[j] != '.')
		{
			res = res * 10 + c[j] - '0';
			++j;
		}
		if(c[j])
		{
			++j;
			while(c[j])
				res = res * 10 + c[j] - '0', ++x, ++j;
		}
		int n2 = -x, n5 = -x;
		while(res % 2 == 0)
		{
			++n2;
			res >>= 1;
		}
		while(res % 5 == 0)
		{
			++n5;
			res /= 5 ;
		}
		if(n2 >= 0 && n5 >= 0) ++cnt;
		if(n2 >= 15) n2 = 14;
		if(n5 >= 15) n5 = 14;
		++f[n2 + 10][n5 + 10];
	}
	long long res = cnt * (cnt-1)/2;

	for(int i = 10; i < 25; ++i)
		for(int j = 10; j < 25; ++j)
		{
			long long s = 0;
			for(int x = max(0, 20 - i); x < 25; ++x)
				for(int y = max(0, 20 - j); y < 25; ++y) if(x < 10 || y < 10)
					s += f[x][y];
			res += s * f[i][j];
		}
	for(int i = 0; i < 10; ++i)
		for(int j = 11; j < 25; ++j)
		{
			long long s = 0;
			for(int x = 20 - i; x < 25; ++x)
				for(int y = max(0, 20 - j); y < 10; ++y)
					s += f[x][y];
			res += s * f[i][j];
		}
//	for(int i = 0; i < 10; ++i)
//		for(int j = 0; j < 10; ++j)
//		{
//			long long s = 0;
//			for(int x = 20 - i; x < 25; ++x)
//				for(int y = 20 - j; y < 25; ++y)
//					s += f[x][y];
//			res += s * f[i][j];
//		}
//	for(int i = 0; i < 10; ++i)
//		for(int j = 10; j < 25; ++j)
//		{
//			long long s = 0;
//			for(int x = 20 - i; x < 25; ++x)
//				for(int y = 10; y < 25; ++y)
//					s += f[x][y];
//			res += s * f[i][j];
//		}
//	for(int i = 10; i < 25; ++i)
//		for(int j = 0; j < 10; ++j)
//		{
//			long long s = 0;
//			for(int x = 10; x < 25; ++x)
//				for(int y = 20 - j; y < 25; ++y)
//					s += f[x][y];
//			res += s * f[i][j];
//		}
	cout << res << endl;
	return 0;

}


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

int main(void){
  int a,b;
  if(scanf("%d %d",&a,&b)==2){
    if(b%a==0){
      printf("%d",a+b);
    }else{
      printf("%d",b-a);
    }
  }
  return 0;
}


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

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

  double tan;
  if (x>= 0.5*a*a*b){
    tan = 1.0*(a*a*b - x)/(0.5*a*a*a);
  }
  else {
    tan = 0.5*a*b*b/x;
  }

  cout << fixed << setprecision(10);
  cout << 180.0*atan(tan)/pi << endl;

}

 

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, a, b;
    cin >> n >> a >> b;
    int plan1 = n * a;
    int plan2 = b;
    cout << min(plan1, plan2);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+7;

int main() {
    ios::sync_with_stdio(false);
    Int n, m;
    cin >> n >> m;
    if (abs(n - m) > 1) {
        dump(0);
    }
    else {
        Int a = 1;
        for (Int i = 1; i <= n; i++) a = a * i % mod;
        Int b = 1;
        for (Int i = 1; i <= m; i++) b = b * i % mod;
        Int res = a * b % mod;
        if (n == m) res = res * 2 % mod;
        dump(res);
    }
    return 0;
} 


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

{
	int n,d;
	cin>>n;
	 d=n%10;
	
	 
	 
	 
	if(d==2|| d==4 || d==5|| d==7|| d==9)
	{
		cout<<"hon"<<endl;
	}
	if(d==0|| d==1|| d==6|| d==8)
	{
		cout<<"pon"<<endl;
		
	}
	if(d==3)
	{
		cout<<"bon"<<endl;
	}

	
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int>vi;
#define pb push_back
#define sc(n) scanf("%d",&n)
#define lsc(n) scanf("%lld",&n)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(i=0LL;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define rev1(i,n) for(i=n;i>0;i--)
#define in insert
#define IT ::iterator
#define F first
#define S second
#define pr(n) printf("%d\n",n)
#define lpr(n) printf("%lld\n",n);


void solve()
{
   int n;
   cin >> n;
   string s;
   cin >> s;
   int i,sz=s.size();
   rep(i,sz)
   {
       int q=s[i];
       q+=n;
       if(q>90)q-=26;
       s[i]=q;
   }
   cout << s ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tc=1;
   // cin >> tc;
    while(tc--)
    {
        solve();
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define Rrep(i,n) for(int i=((int)n-1); i>=0; i--)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e15
#define MOD 10e9+7

typedef vector<int> vint;
typedef long long ll;



int main()
{
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        
        int x;
        cin>>x;

        if(!x){cout<<1<<endl;}
        else{cout<<0<<endl;}

        return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

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

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class A
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var (N, R) = Scanner.Scan<int, int>();
            Console.WriteLine(N >= 10 ? R : (R + (100 * (10 - N))));
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 28300
/*
Aldew
PROB: Fencing
CLASSIFICATION:
DIFFICULTY:
*/

#include <bits/stdc++.h>
#define check(x) cout<<(#x)<<": "<<x<<" ";
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


typedef long long ll;
typedef unsigned long long ull;

using namespace std;

//void io()
//{
//    #ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    #endif
//}

vector <int> factors(int x) {
    vector <int> result;
    int i = 1;
    while(i*i <= x) {
        if(x % i == 0) {
            result.push_back(i);
            if(x/i != i) {
                result.push_back(x/i);
            }
        }
        i++;
    }
    return result;


}
unsigned nChoosek( unsigned n, unsigned k )
{
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;

    int result = n;
    for( int i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i;
    }
    return result;
}


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

    map<string, int> d;
    string s;
    while (n --){
        cin >> s;
        d[s] ++;

    }

    cout << "AC x " << d["AC"] << endl;
    cout << "WA x " << d["WA"] << endl;
    cout << "TLE x " << d["TLE"] << endl;
    cout << "RE x " << d["RE"] << endl;



    return 0;
}



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

int main() {

    string in;
    cin >> in;


    string ans = "No";
    if(in.at(0) == '7') ans = "Yes";
    if(in.at(1) == '7') ans = "Yes";
    if(in.at(2) == '7') ans = "Yes";

    cout << ans << endl;

}   

Measured memory_bytes: 3600
import sys
import numpy as np

M = 1000000007  # type: int


def solve(N: int, K: int, a):
    dp = np.zeros(K + 1, dtype=np.int64)
    dp[0] = 1
    for x in a:
        cm = np.cumsum(dp)
        dp = cm.copy()
        dp[x + 1 :] -= cm[: -x - 1]
        dp %= M
    return dp[K]


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    a = np.array([int(next(tokens)) for _ in range(N)], dtype=np.int64)
    print(solve(N, K, a))


if __name__ == "__main__":
    main()


Measured memory_bytes: 14808
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string S, T;
	cin >> S >> T;

	vector<char> pairS(26, '?'), pairT(26, '?');
	for (int i = 0; i < S.length(); i++) {
		if (pairS[S[i] - 'a'] == '?') pairS[S[i] - 'a'] = T[i];
		if (pairS[S[i] - 'a'] != T[i]) { 
			cout << "No" << "\n";
			return 0;
		}
	}
	for (int i = 0; i < T.length(); i++) {
		if (pairT[T[i] - 'a'] == '?') pairT[T[i] - 'a'] = S[i];
		if (pairT[T[i] - 'a'] != S[i]) {
			cout << "No" << "\n";
			return 0;
		}
	}

	cout << "Yes" << "\n";

	return 0;
}

Measured memory_bytes: 916
import sys
import itertools
import math
from collections import deque
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
s = S()

ans = 0
for i in range(10):
  for j in range(10):
    for k in range(10):
      num = str(i) + str(j) + str(k)
      st = 0
      for n in num:
        for x in range(st, N):
          if s[x] == n:
            st = x+1
            break
        else:
          break
      else:
        ans += 1

print(ans)

Measured memory_bytes: 42332
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int N, W;
LL w[101], v[101];
LL dp[101010];

int main(){
    INIT;
    cin >> N >> W;
    REP(i, 101010)dp[i] = HINF<LL>();
    dp[0] = 0;
    REP(i, N){
        cin >> w[i] >> v[i];
        for(int j = 101009;j >= v[i];j--){
            dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
        }
    }
    LL ans = 0;
    REP(i, 101010){
        if(dp[i] <= W)ans = i;
    }
    cout << ans << endl;
}

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

const ll INF = 1000000009;

void solve(){
  int n;
  string s;
  cin >> n >> s;
  ll ans = 0;
  vector<vector<int>> rgb(n+1, vector<int>(3));
  for(int i = n-1; i >= 0; i--){
    for(int j = 0; j < 3; j++)  rgb[i][j] = rgb[i+1][j];
    if(s[i] == 'R') rgb[i][0]++; 
    if(s[i] == 'G') rgb[i][1]++;
    if(s[i] == 'B') rgb[i][2]++;
  }

  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
      if(s[i] == s[j])  continue;
      set<char> a = {'R', 'G', 'B'};
      a.erase(s[i]);
      a.erase(s[j]);
      int st = -1;
      if(*a.begin() == 'R') st = 0;
      else if(*a.begin() == 'G')  st = 1;
      else  st = 2;
      ans += rgb[j+1][st];
      // cout << i << " " << j << " " << rgb[j+1][st] << "\n";
      if(j+j-i < n && s[j+j-i] == *a.begin())  ans--;
    }
  }

  cout << ans << "\n";
}

int main(){
#ifndef LOCAL
  ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
#endif
  // int t;cin >> t;while(t--) solve();
  solve();
}


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


int main() {
  int A,B;
  cin>>A>>B;
  if(A>12){
    cout<<B<<endl;
  }
  else if(A<=5){
    cout<<"0"<<endl;
  }
  else{
    cout<<B/2<<endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int ans = Integer.MAX_VALUE;
        for(int i = 0; i < n-k+1; i++){
            ans = Math.min(ans, a[i+k-1] - a[i]);
        }
        System.out.println(ans);
    }
}

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

long long sum,a[400],n;
const long long md=998244353;

long long powmod(long long i,int j){
  long long res=1;
  while(j--){
	res=(res*i)%md;
  }
  return res;
}

void addmod(long long & a,long long b){
  a%=md;b%=md;
  a+=b;
  a%=md;
}

int main(){
  cin>>n;  
  for(int i=0;i<n;++i){
	cin>>a[i];
	sum+=a[i];
  }
  vector<long long> dp1[400];
  vector<long long> dp2[400];
  for(int i=0;i<400;++i){
	dp1[i].resize(90310,0);
	dp2[i].resize(90310,0);
  }
  dp1[0][0]=dp2[0][0]=1;

  
  long long Rover=0,ReqB=0;
  for(int i=0;i<n+1;++i){
	for(int j=0;j<=sum;++j){
	  addmod(dp1[i+1][j],dp1[i][j]*2);
	  addmod(dp1[i+1][j+a[i]],dp1[i][j]);
	  
	  addmod(dp2[i+1][j],dp2[i][j]);
	  addmod(dp2[i+1][j+a[i]],dp2[i][j]);
	  
	  if(j>=(sum+1)/2&&i==n)
		addmod(Rover,dp1[i][j]);
	}
  }
  if(sum%2==0)ReqB=dp2[n][sum/2];
  cout<<(powmod(3,n)-(Rover*3)%md+(ReqB*3)%md+md)%md<<endl;
}


Measured memory_bytes: 566784