akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int r, D, x;
  cin >> r >> D >> x;
  int ans = r * x - D;  
  	for (int i = 0; i < 10; i++) {
      cout << ans << endl;
      
      ans *= r;
      ans -= D;
    }
  	
}

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

using namespace std;

int main()
{
   int n,i;
   cin>>n;
   int a[n],b[n],c[n-1];
   for(i=0;i<n;i++)cin>>a[i];
   for(i=0;i<n;i++)cin>>b[i];
   for(i=0;i<n-1;i++)cin>>c[i];
   int sum=0;
   for(i=0;i<n;i++)sum=sum+b[i];
   for(i=0;i<n-1;i++)
   {
       if(a[i+1]-a[i]==1)sum=sum+c[a[i]-1];
   }
   cout<<sum;
  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

accurate=[False]*n

wa_count=[0]*n
for i in range(m):
    p, s=input().split()
    p=int(p)
    if accurate[p-1] is False and s=="WA":
        wa_count[p-1]+=1
    if accurate[p-1] is False and s=="AC":
        accurate[p-1]=True

ac_count=accurate.count(True)
wa=0
for i in range(n):
    if accurate[i]:
        wa+=wa_count[i]

print(ac_count, wa)



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

int main() {
  
  int numStones;
  cin >> numStones;
  vector<int> heights(numStones);
  for(int& height : heights) {
      cin >> height;
  }
  int costTwoBefore = 0;
  int costOneBefore = abs(heights[1] - heights[0]);

  for(int i = 2; i < numStones; i++) {
      int temp = costOneBefore;
      costOneBefore = min(costOneBefore + abs(heights[i] - heights[i-1]),
                     costTwoBefore + abs(heights[i] - heights[i-2]));
      costTwoBefore = temp;
  }

  cout << costOneBefore;

  return 0;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


const int mod = 1000000007;
const int max_n = 200005;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(max_n);



int main(){
    ll n;cin >> n;
    string s;cin >> s;
    string t;
    rep(i,2*n){
        if(i%2==0){
            if(s[i]=='B')t+='L';
            else t+='R';
        }
        else{
            if(s[i]=='W')t+='L';
            else t+='R';
        }
    }
    //cout << t <<endl;
    mint ans=1;
    ll lcnt=0;
    rep(i,2*n){
        if(t[i]=='L')lcnt++;
        else{
            ans*=lcnt;
            lcnt--;
        }
    }
    if(lcnt)cout<< 0 <<endl;
    else{
        ans*=comb.fact[n];
        cout << ans <<endl;
    }
}

Measured memory_bytes: 3972
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
import numpy as np
from collections import defaultdict
MOD = pow(10,9)+7
N = int(input())
d = [[N,0] for _ in range(60)]
A = list(map(int,input().split()))
A = np.array(A)
ans = 0
for m in range(60):
    B = (A >> m) & 1
    x = np.count_nonzero(B)
    x *= (N-x)
    x *= pow(2,m,MOD)
    ans += x
print(ans%MOD)

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

int main() {
	int N,K,count;
	cin >> N;
	vector<int> dif(N);
	
	for(int i=0;i<N;i++){
		cin >> dif.at(i);
	}
	
	sort(dif.begin(),dif.end());
	
	K = dif.at(N/2) - dif.at(N/2-1);
	
	cout << K << endl;
	
	
}



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

using namespace std;
using ll = long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;
vector<ll> ret;

int main(){
    string str;
    cin>>str;
    int one = stoi(str.substr(0,2));
    int two = stoi(str.substr(2,2));
    if((one == 0 && two >= 13) || (two == 0 && one >= 13) ||(one == 0 && two == 0)||(one >= 13 && two >= 13)){
        cout << "NA" << endl;
    }else {
        if(one >= 13 || one == 0){
            cout << "YYMM" << endl;
        }else if(two >= 13 || two == 0){
            cout << "MMYY" << endl;
        }else{
            cout << "AMBIGUOUS" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 256
N,A,B = map(int,input().split())
ans = 0
def sumofdigits(X):
    s = str(X)
    t = list(map(int,s))
    return sum(t)
    
for i in range(1,N+1):
    if A <= sumofdigits(i) <= B:
        ans += i
print(ans)        


Measured memory_bytes: 9084
import sys

n = int(input())
h_ls = [int(i) for i in sys.stdin.readline().split()]
a_ls = [int(i) for i in sys.stdin.readline().split()]

x = 1
while x <= n:
    x *= 2
tree = [0] * (2 * x)
INF = 10**18
memo_ls = [0 for i in range(n+1)]
def update(k, x):
    while k > 0:
        tree[k] = max(tree[k], x)
        k //= 2

def query(k):
    # kが最後尾の時の最大値を求める
    best = 0
    while k > 1:
        if k % 2 == 1:
            best = max(best, tree[k-1])
        k //= 2
    return best

for i, (h, a) in enumerate(zip(h_ls, a_ls)):
    best = query(h + x)
    memo_ls[h] = best + a
    update(h + x, best + a)
print(max(memo_ls))

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

#define int         long long
#define nn          101
#define kn          100001
#define mod         1000000007

int n,k;
int a[nn];

int solve(){
    int dp[n+2][k+2];

    for(int j=0;j<=k;j++){
        dp[1][j] = (j > a[1]) ? 0 : 1;
    }

    for(int i=2;i<=n;i++){
        for(int j=0;j<=k;j++){
            if(j == 0)
                dp[i][j] = dp[i-1][j];
            else
                dp[i][j] = (mod + dp[i][j-1] + dp[i-1][j] - ((j-a[i]-1 >= 0) ? dp[i-1][j-a[i]-1] : 0)) % mod;
        }
    }
    return dp[n][k];
}

int32_t main(){
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    cout<<solve();
}


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

int main(void) {
	int i, j;
	for (i = 1; i <= 9; i++) {
		for (j = 1; j <= 9; j++) {
			cout << i << "x" << j << "=" << i * j << endl;
		}
	}
}


Measured memory_bytes: 3072
#include <iostream>
using namespace std;
int tot[300];
int now[300];
char c[300];
int ans;
int maxAns;
int main() {
  int n;
  cin>>n;
  for (int i=0; i<n;++i)
  {
    cin>>c[i];
    tot[c[i]]++;
  }
  for (int i=0; i<n;++i)
  {
    now[c[i]]++;
    if (now[c[i]]==1) ans++;
    if (now[c[i]]==tot[c[i]]) ans--;
    if (ans>maxAns) maxAns=ans;
    }
  cout<<maxAns<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long k = sc.nextLong();
        n %= k;
        n = Math.min(n,k-n);
        System.out.println(n);
	}
}

Measured memory_bytes: 21716
from functools import reduce
n = int(input())
s = [int(i) for i in input().split()]
s.sort(reverse = True)

def saidaikouyakusuu(x, y):
    while x%y != 0:
        x, y = y, x%y
    return (y)

print(reduce(saidaikouyakusuu, s))  

Measured memory_bytes: 14596
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<long> vl;
typedef vector<vector<long> > vvl;
typedef vector<string> vs;

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

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

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

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    int N, K;
    cin >> N >> K;

    cout << N - K + 1<< endl;
    return 0;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String strn = input.readLine( );
		int n = Integer.parseInt(strn);
		String strk = input.readLine( );
		int k = Integer.parseInt(strk);
		String strx = input.readLine( );
		int x = Integer.parseInt(strx);
		String stry = input.readLine( );
		int y = Integer.parseInt(stry);

		int answer = 0;


		if(n>k){
			for(int i=0; i<k; i++){
				answer = answer + x;
			}
			for(int i=k; i<n; i++){
				answer = answer + y;
			}
		}else{
			for(int i=0; i<n; i++){
				answer = answer + x;
			}
		}

		System.out.println(answer);
	}

}


Measured memory_bytes: 8148
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  string s;
  cin >> s;

  int c = 0;
  for(char ch: s){
    if(ch == '1') ++c;
  }

  cout << c << endl;

  return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	ll n;
	cin >> n;
	if(n%2==0) cout << n << endl;
	else cout << 2*n << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


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

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    long int w[n+1],v[n+1],i,j;
    for(i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
    }
    long long int t[n+1][m+1];
    for(i=0;i<=m;i++)
    {
        t[0][i]=0;
    }
    for(i=1;i<=n;i++)
    {
        t[i][0]=0;
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(w[i]<=j)
            {
                t[i][j]=max(t[i-1][j],v[i]+t[i-1][j-w[i]]);
            }
            else{
                t[i][j]=t[i-1][j];
            }
        }
    }
    cout<<t[n][m]<<endl;
    return 0;
}


Measured memory_bytes: 79104
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final long n = scanner.nextLong();
        final long sqrt = (long) Math.sqrt(n) + 1;

        long answer = Long.MAX_VALUE;
        for (long i = sqrt; i >= 1; i--) {
            if (n % i == 0) {
                answer = Math.min(answer, n / i + i - 2);
            }
        }

        System.out.println(answer);
    }
}


Measured memory_bytes: 23764
import numpy as np
n,d = map(int, input().split())
p = []
for i in range(n):
  p.append(list(map(int, input().split())))
p = np.array(p)
dist = []
for i in range(n-1):
  for j in range(n-i-1):
    dist.append(p[i]-p[i+j+1])
c = 0
for i in range(n*(n-1)//2):
  if np.linalg.norm(dist[i], ord=2) % 1 == 0:
    c +=1
print(c)

Measured memory_bytes: 21496
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

dict1 = {"A":"00000",\
        "B":"00001",\
        "C":"00010",\
        "D":"00011",\
        "E":"00100",\
        "F":"00101",\
        "G":"00110", \
        "H":"00111", \
        "I":"01000", \
        "J":"01001", \
        "K":"01010", \
        "L":"01011", \
        "M":"01100", \
        "N":"01101", \
        "O":"01110", \
        "P":"01111", \
        "Q":"10000", \
        "R":"10001", \
        "S":"10010", \
        "T":"10011", \
        "U":"10100", \
        "V":"10101", \
        "W":"10110", \
        "X":"10111", \
        "Y":"11000", \
        "Z":"11001", \
        " ":"11010", \
        ".":"11011", \
        ",":"11100", \
        "-":"11101", \
        "'":"11110", \
        "?":"11111"}

dict2 = {"101":" ",\
         "000000":"'",\
         "000011":",", \
         "10010001":"-", \
         "010001":".",\
         "000001":"?",\
         "100101":"A",\
         "10011010":"B",\
         "0101":"C",\
         "0001":"D",\
         "110":"E",\
         "01001":"F",\
         "10011011":"G",\
         "010000":"H",\
         "0111":"I",\
         "10011000":"J",\
         "0110":"K",\
         "00100":"L",\
         "10011001":"M",\
         "10011110":"N",\
         "00101":"O",\
         "111":"P",\
         "10011111":"Q",\
         "1000":"R",\
         "00110":"S",\
         "00111":"T",\
         "10011100":"U",\
         "10011101":"V",\
         "000010":"W",\
         "10010010":"X",\
         "10010011":"Y",\
         "10010000":"Z"}

d1 = {v:k for k, v in dict1.items()}
d2 = {v:k for k, v in dict2.items()}


N = list(get_input())

for l in range(len(N)):
    S1 = N[l]
    S2 = ""

    for i in range(len(S1)):
        S2 = S2 + d2[S1[i]]

    S3 = ""
    while S2 != "":
        if len(S2) >= 5:
            s = S2[0:5]
            S3 = S3 + d1[s]
            S2 = S2[5:]
        else:
            while len(S2) < 5:
                S2 = S2 + "0"
            S3 = S3 + d1[S2]
            break

    print(S3)



Measured memory_bytes: 5732
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef long double ld;
const double E = 1e-7;
const ll INF = 1e17;
#define forn(i, s, f) for (int i = s; i < f; ++i)
#define ft first                                                 
#define sec second
#define fora(i, n) for (auto i : n)
#define sz(a) (int)(a).size()
#define sort_(a) sort(a.begin(), a.end())
#define pb push_back
#define mp make_pair
#define rsort_(a) sort(a.begin(), a.end()); reverse(a.begin(), a.end())
#define fast_ cin.tie(0), ios_base::sync_with_stdio(false)
// ____________________________________________________________
#define cina(a) forn(i,0,sz(a)) cin >> a[i]
#define cinpr(a) cin >> a.ft >> a.sec 
//--------------------------------------------------------------
 
int main() {
    int k; cin >> k;
    set<int> s;
    ll ans = 1;
    ll cur = 7;
    while (true) {
        cur %= k;
        if (cur == 0) {
            cout << ans;
            break;
        } 
        if (s.find(cur) != s.end()) {
            cout << -1;
            break;
        }
        s.insert(cur);
        cur = cur * 10 + 7;
        ans++;
    }
}

Measured memory_bytes: 50424
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

void solve()
{
    int n;
    cin>>n;
    vl a(n),b(n),c(n);
    vector<vl> dp(n,vl(3,-INF));
    for(int i=0;i<n;i++) {
        cin>>a[i];
        cin>>b[i];
        cin>>c[i];
    }

    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];

    for(int i=1;i<n;i++) {
        dp[i][0] = max(dp[i-1][2],dp[i-1][1])+a[i];
        dp[i][1] = max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2] = max(dp[i-1][0],dp[i-1][1])+c[i];
    }

    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    
}

int main()
{
    fastio;
    int t;
    t = 1;
    //cin >> t;
    //int test=t;
    
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        cout << newl;
    }

    return 0;
}

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

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  long long a, b, k;
  cin >> a >> b >> k;
  if (a > k) {
    cout << a - k << " "<< b << endl;
  } else if (a + b > k) {
    cout << 0 << " " << a + b - k << endl;
  } else {
    cout << "0 0" << endl;
  }
}

Measured memory_bytes: 256
n, l = map(int, input().split())
num = 200
for i in range(1, n+1):
    if abs(num) >= abs(l+i-1):
        num = abs(l+i-1)
        x = i
cnt = 0
for j in range(1, n+1):
    cnt += j
print((l-1)*(n-1) + cnt - x)

Measured memory_bytes: 9132
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define intt int64_t
#define all(vec) vec.begin(), vec.end()

int main() {
    int n;
    scanf("%d", &n);
    vector<int> vec(n);
    rep(i,n) scanf("%d", &vec.at(i));
    sort(all(vec));
    int ans = 0;
    for (int i=vec.at((n-1)/2)+1; i<=vec.at((n-1)/2+1); i++) ans++;
    printf("%d\n", ans);
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <unordered_set>

int main() {
  int n;
  std::unordered_set<std::string> keihin;
  std::cin >> n;
  for(int i=0; i<n; i++) {
    std::string s;
    std::cin>>s;
    keihin.insert(s);
  }
  std::cout<<keihin.size()<<std::endl;
}

Measured memory_bytes: 17560
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main{
	public static void main(String[]args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		int n=0;
		
		while((str=br.readLine())!=null){
			n=Integer.parseInt(str);
			for(int i=1;i<=n;i++){
				int x=i;
				if(x%3==0){
					System.out.print(" "+i);
					continue;
				}
				do{
					if(x%10==3){
						System.out.print(" "+i);
						break;
					}
					x/=10;
				}while(x!=0);
			}
			System.out.print("\n");
			break;
		}
		br.close();
	}
}

Measured memory_bytes: 21972
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();

            char s1 = S[0];
            char s2 = S[1];
            char s3 = S[2];

            char t1 = T[0];
            char t2 = T[1];
            char t3 = T[2];
            int i = 0;
            if(s1 == t1)
            {
                i++;
            }
            if(s2 == t2)
            {
                i++;
            }
            if(s3 == t3)
            {
                i++;
            }
            Console.WriteLine(i);
        }
    }
}

//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 25956
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
const int MAX = 1000000;
const int MOD = 1000000007;
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;
    }
}
// 二項係数計算 COMinit()を先に使用すること
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 main(){
	int n,k;
    cin>>n>>k;
    int p=n-k;
    COMinit();
    for(int i=1;i<=k;i++){
        ll ans=(COM(p+1,i)*COM(k-1,i-1))%MOD;
        OUT(ans);
    }
	return 0;
}

Measured memory_bytes: 23680
import java.util.*;

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 count = 0;
        for(int i=0;i<=N;i++){
            int num=i;
            int sum=0;
            while(num!=0){
                sum+=num%10;
                num/=10;
            }
            if(A<=sum && sum<=B){count+=i;}
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 22868
import sys
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
l = []
sumA = sum(A)
sumB = sum(B)

tmp = 0
cnt = 0
if sumA < sumB:
    print("-1")
    sys.exit()
else:
    for i in range(N):
        if A[i] >= B[i]:
            l.append(A[i]-B[i])
        else:
            tmp += A[i]-B[i]
            cnt += 1
l.sort(reverse=True)

j = 0
while tmp < 0:
    tmp += l[j]
    cnt += 1
    j += 1

print(cnt)

Measured memory_bytes: 18356
int main(void) {
    int i,j,H,W;
    
    while (1) {
    scanf("%d",&H);
    scanf("%d",&W);
        if (H==0&&W==0){
            break;
        }
        for(i=0;i<H;i++){
            for(j=0;j<W;j++){
                if((i+j)%2==1){
                    printf(".");
                } else {
                    printf("#");
                 
                }
            }
    printf("\n");
    }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};


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

    ll N,W;
    cin >> N >> W;
    vector<ll> v(N);
    vector<ll> w(N);
    ll sum=0;

    rep(i,N){
        cin >> w[i] >> v[i];
        sum += v[i];
    }
    vector<vector<ll>> dp(N+1,vector<ll> (sum+1,INF));
    dp[0][0] = 0;
    rep(i,N){
        rep(j,sum+1){
            if(j-v[i] >= 0) dp[i+1][j] = min(dp[i][j-v[i]]+w[i],dp[i][j]);
            else dp[i+1][j] = dp[i][j];
        }
    }
    ll ans = 0;
    rep(j,sum+1){
        if(dp[N][j] <= W) ans = max(ans,j);
    }

    cout << ans << endl;

    cout << endl;
    return 0;
}


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

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

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

int main(){

  ll n;
  cin >> n;

  vector<vector<pair<ll, ll>>> g(n);

  rep(i, n-1){
    ll a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    g[a].push_back(make_pair(b, c));
    g[b].push_back(make_pair(a, c));
  }

  ll q, k;
  cin >> q >> k;
  k--;

  vector<ll> mini(n, IINF);
  mini[k] = 0;
  queue<pair<ll, ll>> qu;
  rep(i, (int)g[k].size()){
    qu.push(make_pair(g[k][i].first, g[k][i].second));
  }

  while(!qu.empty()){
    auto tmp = qu.front();
    qu.pop();
    mini[tmp.first] = tmp.second;

    rep(i, (int)g[tmp.first].size()){
      if(mini[g[tmp.first][i].first] == IINF)
        qu.push(make_pair(g[tmp.first][i].first, tmp.second + g[tmp.first][i].second));
    }
  }

  rep(i, q){
    ll x, y;
    cin >> x >> y;
    x--;y--;
    cout << mini[x] + mini[y] << endl;
  }

	return 0;
}


Measured memory_bytes: 10736
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
typedef double dd;
#define For(i,j,k) for (int i=j;i<=k;++i)
#define Forr(i,j,k) for (int i=j;i>=k;--i)
#define Set(a,p) memset(a,p,sizeof(a))
using namespace std;

template<typename T>bool chkmax(T &a,T b) { return a<b?a=b,1:0; }
template<typename T>bool chkmin(T &a,T b) { return a>b?a=b,1:0; }

const int maxn=100000+100;
const int maxm=3000+10;
int n,m,ans;
int s0[maxm][maxm],s1[maxm][maxm];

inline void file() {
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
}

inline void read(int &x) {
	x=0;
	int p=1;
	char c=getchar();
	while (!isdigit(c)) {if (c=='-') p=-1; c=getchar();}
	while (isdigit(c)) {x=(x<<1)+(x<<3)+(c-'0'); c=getchar();}
	x*=p;
}

inline void init() {
	read(n); read(m);
	For (i,1,n) {
		int x,y,z; read(x); read(y);
		char ss[10]; scanf("%s",ss);
		if (ss[0]=='W') z=0; else z=1;
		x%=(2*m); y%=(2*m);
		if (z==0) s0[x][y]++;
		else s1[x][y]++;
	}
	For (i,1,2*m) s0[i][0]=s0[i][0]+s0[i-1][0];
	For (j,1,2*m) s0[0][j]=s0[0][j]+s0[0][j-1];
	For (i,1,2*m) For (j,1,2*m) s0[i][j]=s0[i][j]+s0[i-1][j]+s0[i][j-1]-s0[i-1][j-1];
	For (i,1,2*m) s1[i][0]=s1[i][0]+s1[i-1][0];
	For (j,1,2*m) s1[0][j]=s1[0][j]+s1[0][j-1];
	For (i,1,2*m) For (j,1,2*m) s1[i][j]=s1[i][j]+s1[i-1][j]+s1[i][j-1]-s1[i-1][j-1];
/*	For (i,0,2*m-1) {
		For (j,0,2*m-1) printf("%d ",s1[i][j]);
		cout << endl;
	}*/
}

inline void solve() {
	For (i,0,m-1) For (j,0,m-1) {
		int M=2*m-1;
		int a0=s0[i][j]+(s0[i][M]-s0[i][j+m])+(s0[M][M]-s0[M][j+m]-s0[i+m][M]+s0[i+m][j+m])+(s0[M][j]-s0[i+m][j])+(s0[i+m][j+m]-s0[i+m][j]-s0[i][j+m]+s0[i][j]);
		int a1=s1[i][j]+(s1[i][M]-s1[i][j+m])+(s1[M][M]-s1[M][j+m]-s1[i+m][M]+s1[i+m][j+m])+(s1[M][j]-s1[i+m][j])+(s1[i+m][j+m]-s1[i+m][j]-s1[i][j+m]+s1[i][j]);
		chkmax(ans,a0+s1[M][M]-a1); chkmax(ans,a1+s0[M][M]-a0);
	}
	printf("%d\n",min(ans,n));
}

int main() {
//	file();
	init();
	solve();
	return 0;
}

Measured memory_bytes: 49408
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double lb;

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


int main() {
    ll A,B;
    cin >> A >> B;

    ll temp=0,count=0;
    for(ll i=A;i<=B;i++){
        temp = i % 10000;
        ll go = (i-temp)/10000;

        temp = temp - (i % 1000);
        ll yon = temp/1000;

        temp = (i % 1000) - (i % 100);
        ll san = temp/100;

        temp = (i % 100) - (i % 10);
        ll ni = temp/10;

        ll iti = i % 10;

        if(go == iti && ni == yon){
            count++;
        }
    }

    

    cout << count << endl;

}


Measured memory_bytes: 3512
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
using namespace std;

struct Ink{
	int y,x,size;
	Ink(){}
	Ink(int _y,int _x,int _size){
		y=_y; x=_x; size=_size;
	}
};

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

int N;
bool found;

bool can(int fld[10][10],int y,int x,int size){
	for(int k=0;k<4;k++){
		int ny = y+dy[size][k],
			nx = x+dx[size][k];
		if(ny<0 || 10<=ny || nx<0 || 10<=nx || fld[ny][nx]==0) return false;
	}
	return true;
}

void dye(int fld[10][10],int y,int x,int size,int v){
	for(int k=0;k<4;k++){
		int ny = y+dy[size][k],
			nx = x+dx[size][k];
		fld[ny][nx] += v;
	}
}

void dfs(int fld[10][10],vector<Ink> &ink,int y,int x){
	if(found) return;
	bool white = true;
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			if(fld[i][j]>0 && i*10+j<(y*10+x)-20) return;
			if(fld[i][j]>N-ink.size()) return;
			if(fld[i][j]!=0){
				white = false;
			}
		}
	}
	if(white && ink.size()==N){
		for(int i=0;i<ink.size();i++){
			printf("%d %d %d\n",ink[i].x,ink[i].y,ink[i].size+1);
			found = true;
		}
		return;
	}

	for(int i=y;i<10;i++){
		for(int j=(i==y)?x:0;j<10;j++){
			if(fld[i][j]==0) continue;
			fld[i][j]--;
			int size;
			for(size=0;size<3;size++){
				if(can(fld,i,j,size)==false) break;
				dye(fld,i,j,size,-1);
				ink.push_back(Ink(i,j,size));
				dfs(fld,ink,i,j);
				ink.pop_back();
			}
			for(int size_ = size; size--;){
				dye(fld,i,j,size,1);
			}
			fld[i][j]++;
		}
	}
}

int main(){
	int fld[10][10];
	cin>>N;
	for(int i=0;i<10;i++)for(int j=0;j<10;j++) cin>>fld[i][j];
	vector<Ink> ink;
	dfs(fld,ink,0,0);
	return 0;
}

Measured memory_bytes: 1176
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

bool check(vector<int> v){
	int sum = 0;
	for (int i = 0; i < v.size(); i++){
		if (v[i] != 0) sum++;
	}
	if (sum == 1){
		return true;
	}else{
		return false;
	}
}


int main(){
	while(1){
		int n; cin >> n;
		int p; cin >> p;
		if (n == 0 and p == 0) break;
		int wan = p;
		vector<int> player_have(n);
		int player = 0;
		int idx = 0;
		while(wan != 0 or !check(player_have) ){
			player = idx%n;
			//cout << "wan = " << wan <<  endl;
			if (wan > 0){
				player_have[player] += 1;
				wan -= 1;
			}else if (wan == 0){
				wan = player_have[player];
				player_have[player] = 0;
			}
			idx++;;
		}
		cout << player << endl;
		player_have.clear();
	
	}

return 0;
}

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

int main() {
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;
  if (x>=r && W-x>=r && y>=r && H-y>=r) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3088
package main

import "fmt"

func main() {

	var a int
	var b int
	var c int
	var x int

	var cnt int = 0

	fmt.Scan(&a, &b, &c, &x)
	for indexA := 0; indexA <= a; indexA++ {
		for indexB := 0; indexB <= b; indexB++ {
			for indexC := 0; indexC <= c; indexC++ {
				if indexA*500+indexB*100+indexC*50 == x {
					cnt++
				}
			}
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
n = gets.to_i
first = gets.chomp.split(' ').map(&:to_i)
second = gets.chomp.split(' ').map(&:to_i)
down_time = 0
max = 0
while down_time < n #下に下がるタイミングを全探索
  i = 0#列番号
  sum = 0
  while i < down_time #実際の足しあわせ
    sum += first[i]
    i += 1
  end
  if i == down_time
    sum += first[down_time]
  end
  while i < n
    sum += second[i]
    i += 1
  end
  if sum > max
    max = sum
  end
  down_time += 1
end
puts max

Measured memory_bytes: 14296
const input = require("fs").readFileSync("/dev/stdin", "utf8")
let cin = input.split(/ |\n/), cid = 0
const next = () => cin[cid++]
const nexts = (n) => cin.slice(cid, cid+=n).map(j=>parseInt(j))

function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

const [N, K] = nexts(2)
let A = nexts(N)

for (let j = 0; j < K; j++) {
    let Ans = Array(N+1).fill(0)
    for (let i = 0; i < N; i++) {
        Ans[Math.max(0, i-A[i])]++
        Ans[Math.min(N, A[i]+i+1)]--
    }
    if (Ans[0] === N && Ans[N] === -N) return console.log(Array(N).fill(N).join(' '))
    for (let i = 1; i < N; i++) {
        Ans[i] += Ans[i-1]
    }
    A = Ans;
}
console.log(A.slice(0, N).join(' '))


Measured memory_bytes: 70776
#include <stdio.h>
 
int main() {
    char c;
    int n = 0;
    int cnt = 0;
    while((c = getchar()) != '\n') {
        if(c == 'R') {
            if(++n == 4) {
                cnt++;
                n = 0;
            }
        } else {
            if(--n == -4) {
                n = 0;
            }
        }
    }
    printf("%d\n", cnt);
}



Measured memory_bytes: 2092
package main

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

//util
var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func printList(list []int) {
	buf := bufio.NewWriter(os.Stdout)
	for _, v := range list {
		buf.Write([]byte(fmt.Sprintf(" %d", v)))
	}
	buf.Write([]byte("\n"))
	buf.Flush()
}

//solve
//単純な場合
func matrixChainMultiplication() {
	//行列が1つだけのとき
	for i := 1; i <= n; i++ {
		m[i][i] = 0
	}
	for l := 2; l <= n; l++ {
		for i := 1; i <= n-l+1; i++ {
			j := i + l - 1
			m[i][j] = 1 << 21
			//kまでで区切る
			for k := i; k <= j-1; k++ {
				m[i][j] = min(m[i][j], m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j])
			}
		}
	}
}

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

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

const MAX = 100

var n int
var p [MAX + 1]int

//m[i][j]: Mi * Mi+1 * ... * Mjを計算するときに必要なスカラー乗算の最小回数
var m [MAX + 1][MAX + 1]int

func main() {
	sc.Split(bufio.ScanWords)
	n = nextInt()
	for i := 1; i <= n; i++ {

		p[i-1] = nextInt() //行数
		p[i] = nextInt()   //列数
	}

	matrixChainMultiplication()
	fmt.Println(m[1][n])
}



Measured memory_bytes: 1176
#include <iostream>
#include<stdio.h>
using namespace std;
#define int long long

signed main(){
    // Your code here!
   int n;
   int sum = 0;
   cin >> n;
   for(int i=1; i <=n; i ++){
       if( i%3 != 0 && i%5 != 0 ){
           sum += i;
       }
   }
   cout << sum;
}


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

#define pb push_back
#define mp make_pair
#define st first
#define nd second
typedef pair < int , int > pp;
const int mod = 1e9 + 7;
const int N   = 1e5 + 5;

map < int , int > M[N];
vector < int > V[N], path;
int L[N];

void f(int x){
    for(; V[x].size() ;){
        int y = V[x].back();
        V[x].pop_back();
        if(M[x][y] == 1) continue;
        M[x][y] = M[y][x] = 1;
        f(y);
    }
	path.pb(x);
}

signed main(){
    int n, m;
    cin >> n >> m;
    for(int i=1; i<=m; i++){
        int x, y;
        scanf("%d%d", &x, &y);
        V[x].pb(y); V[y].pb(x);
    }
	
	int t = 0;
    for(int i=1; i<=n; i++){
        t = max(t, (int)V[i].size());
        if(V[i].size() % 2 == 1){
            cout << "No";
            return 0;
        }
    }


    f(1);
    if(path.size() != m+1){
        cout << "No";
        return 0;
    }

	
	if(t >= 6){
	    cout << "Yes";
	    return 0;
	}
	

    memset(L, -1, sizeof L);
    int a = N;
    for(int i=1; i<path.size()-1; i++){
    	int x = path[i];
        if(L[x] != -1) { a = i; break; }
        L[x] = i;
    }
    
    memset(L, -1, sizeof L);
    int b = -1;
    for(int i=path.size()-2; i>=1; i--){
    	int x = path[i];
        if(L[x] != -1) { b = i; break; }
        L[x] = i;
    }
    
    if(a<b){
        cout << "Yes";
        return 0;
    }
    
    memset(L, -1, sizeof L);
    int mx = -1;
    for(int i=0; i<path.size(); i++){
    	int x = path[i];
    	
    	if(i == path.size()-1 && L[x] == 0) continue;
    	
    	if(L[x] != -1 && mx > L[x]){
    	    cout << "Yes";
    	    return 0;
    	}
    	
    	mx = max(mx , L[x]);
        L[x] = i;
    }
    
       
    cout << "No";
    return 0;
}

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

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

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
template<typename T = int>
T in() {T a; cin >> a; return a;}
/***** MAIN *****/
signed main() {
  int n = in();
  map<char, int> mp;
  REP(i,n) {
    string s; cin >> s;
    ++mp[s[0]];
  }
  int ans = 0;
  string mar = "MARCH";
  REP(i,5) {
    REPS(j,i+1,5) {
      REPS(k,j+1,5) {
        ans += mp[mar[i]]*mp[mar[j]]*mp[mar[k]];
      }
    }
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
N,K = map(int,input().split())
x = list(map(int,input().split()))
INF = 3*10**8+1

x_plus,x_minus,x_zero = [],[],0
for i in range(N):
    if x[i] < 0:
        x_minus.append(x[i])
    elif x[i] == 0:
        x_zero += 1
    else:
        x_plus.append(x[i])
for i in range(len(x_minus)//2):
    x_minus[i],x_minus[len(x_minus)-i-1] = x_minus[len(x_minus)-i-1],x_minus[i]

ans = INF
if 0 <= K-1-x_zero and K-1-x_zero < len(x_plus):
    ans = min(ans,x_plus[K-1-x_zero])
if 0 <= K-1-x_zero and K-1-x_zero < len(x_minus):
    ans = min(ans,-x_minus[K-1-x_zero])
for i in range(K):
    if i < len(x_plus) and 0 <= K-i-2-x_zero and K-i-2-x_zero < len(x_minus):
        tmp1 = 2*x_plus[i]-x_minus[K-i-2-x_zero]
        tmp2 = x_plus[i]-2*x_minus[K-i-2-x_zero]
        ans = min(ans,tmp1,tmp2)
if ans == INF:
    ans = 0
print(ans)


Measured memory_bytes: 14252
#include<iostream>
using namespace std;
long long a[100010];
long long sum = 1;
int f, n;
int main() {
    cin >> n;
   
    for (int i = 0; i <n; i++) {
        cin >> a[i];
        if (a[i]==0) f=1;
    }
    if (f==1) {
        cout<< 0<<endl;
        return 0;
    }
    for (int i = 0; i < n; i++) {
        if (a[i] <= 1000000000000000000 / sum) {
            sum *= a[i];
        } else {
            cout<<-1<<endl;
            return 0;
        }
    }
    cout << sum<<endl;
    return 0; 
}

Measured memory_bytes: 4376
#include<bits/stdc++.h>	
 
#define f first
#define s second
#define pb push_back
 
#define ll long long
 
#define int ll
 
#define mp make_pair
  
using namespace std;
                       
 
const int inf = 1e9 + 7;
 
const ll ll_inf = 1e18 + 7;
const int K = 2e5;
const int N = 2e5 + 300;
                                         
ll binpow (ll a, ll n)
{
	if(n == 0)
		return 1ll;
    ll res = 1;
    while (n) {
        if (n & 1)
        {
            res *= a;
            res %= inf;
        }      	
        a *= a;
        n >>= 1;
        a %= inf;
    }                          
    return res;
}   
          
  
 
void boost()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}  
 
int n,dp[2010][2010]; 
 
pair<int, int> a[2020];
 
int rec(int l, int r, int v) 
{
	if(l == r) 
		return 0;              
 
	if(dp[l][r] != -1) 
		return dp[l][r];
	dp[l][r] = max(rec(l + 1, r, v - 1) + abs(l - a[v].s) * a[v].f, rec(l, r - 1, v - 1) + abs(r - 1 - a[v].s) * a[v].f);
	return dp[l][r];
}
 
main() 
{
	cin >> n;
	for (int i = 0;i <= n + 1;i++)
	{
		for (int j = 0;j <= n + 1;++j)
			dp[i][j] = -1;
	}
	for(int i = 1;i <= n;++i) 
	{
		cin >> a[i].f;
		a[i].s = i;
	}
	sort(a + 1, a + n + 1);         
	cout << rec(1, n + 1, n);
}

Measured memory_bytes: 35148
#include <bits/stdc++.h>
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)
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;}

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n, w; cin >> n >> w;
  vll wv(n), vv(n);
  REP(i, n) cin >> wv.at(i) >> vv.at(i);
  vvll dp(n+1, vll(n*1000+1, HIGHINF));
  dp.at(0).at(0) = 0;
  REP(i, n) {
    REP(j, n*1000+1) {
      if (j>=vv.at(i)) chmin(dp.at(i+1).at(j), dp.at(i).at(j-vv.at(i)) + wv.at(i));
      chmin(dp.at(i+1).at(j), dp.at(i).at(j));
    }
  }
  ll ans = 0;
  REP (i, n*1000+1) if (dp.at(n).at(i) <= w) ans=i;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 80256