akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vll>;
using vb = vector<bool>;
 
const int INF = 2e9+5;
const ll LLINF = (1LL << 60) + 5;
 
/*
  filippos
  Contest : AtCoder DP contest
  Task : U - Grouping
*/
 
int main(){
  cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);

  int n; cin >> n;
  vvi v(n, vi(n));
  for(auto &x : v)
    for(auto &i : x)
      cin >> i;

  vll mask_value(1<<n, 0);
  for(int mask = 0; mask < (1 << n); mask++){
    ll &value = mask_value[mask];
    vi indexes;
    for(int i = 0; i < n; i++)
      if(mask & (1 << i))
        indexes.push_back(i);
    for(int i = 0; i < indexes.size(); i++)
      for(int j = i + 1; j < indexes.size(); j++)
        value += v[indexes[i]][indexes[j]];
  }

  vll memo(1 << n, -1);
  function<ll(int)> dp = [&](int state){
    ll &ans = memo[state];
    if(ans != -1) return ans;
    ans = 0;
    // iterate over all masks is too slow (2^2N = 2^32)
    // so we iterate only over valid masks (should be less lol)
    vi indexes;
    for(int i = 0; i < n; i++)
      if(!(state & (1 << i)))
        indexes.push_back(i);
    // iterate over submasks
    for(int sub = 1; sub < (1 << indexes.size()); sub++){
      int mask = 0;
      for(int j = 0; j < indexes.size(); j++)
        mask |= ((((sub >> j) & 1)) << indexes[j]);
      // dp for each mask
      ans = max(ans, mask_value[mask] + dp(state | mask));
    }
    return ans;
  };

  cout << dp(0);

  return cout << endl, 0;
}

Measured memory_bytes: 1280
#include <cstdio>
#include <cmath>
#include <limits>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric> // 最大公約数が使える
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
const int inf = 1000000000; //10^9

int main(){
    


    
   int N,K;
   cin >> N >> K;
   int ans=0;
   vector<int>A(N,0);
   
   
   for (int i = 0; i < K; i++)
   {
       int d;
       cin >> d;
       for (int j = 0; j < d; j++)
       {
           int a;
           cin >> a;
           A[a-1] = 1;
       }
   }
   for (int i = 0; i < N; i++)
   {
       if(A[i]==0){
           ans++;
       }
   }
   cout << ans << endl;
   

   /*
   vector<int> A(N);
   iota(A.begin(),A.end(),1);
   int ans=0;
   
   
    for(int i=0;i<K;i++){
        int d;
        cin >> d;
        cout << d << endl;

        vector<int>B(N);
        for(int j=0;j<N;j++){
            int a;
            cin >> a;
        cout << a << endl;
            B.push_back(a);
        }
            int b = B.size();

       for (int j = 0; j < b; j++)
       {
           for (int k = 0; k < N; k++)
           {
               if(A[k]==B[j]){
                   A[k]=0;
               }
           }
           
       }
    }
           

    
    

   for (int i = 0; i < N; i++)
   {
       if(A[i]!=0){
           ans ++;
       }
   }
   
   cout << ans << endl;
   */
   
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include<stdio.h>
#include<functional>
using namespace std;
typedef long long ll;
int main() {
    int A;
    int B;
    int C;
    cin >> A>>B>>C;
    int ans;
    ans=int(B/A);
    if (ans>=C){
        ans=C;
    }
    else{
        ans=ans;
    }
    cout<<ans<<endl;
    return 0;

}

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

int main(){
    int ali=0,bob=0;

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

    sort(a, a+N, greater<int>());

    for(int i=0; i<N; i++){
        if(i%2==0){
            ali+=a[i];
        }else{
            bob+=a[i];
        }
    }
    cout<<ali-bob<<endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007


int main()
{
  int N;
  cin >> N ;
  double ans=0;
  rep(i, N){
  double x;
    string xx;
    cin >> x >> xx;
    if(xx=="BTC")
      x*=380000;
    ans+=x;
  }
  

printf("%.20lf\n", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	double r;
	cin>>r;
	setprecision(20);
	cout<<2*PI*r;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n, k;
	cin >> n >> k;
	cout << min(n % k, (k - (n % k)) % k);

	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
from itertools import product
def resolve():
    n,ma,mb=map(int,input().split())
    ABC=[tuple(map(int,input().split())) for _ in range(n)]
    M=400

    dp=[[INF]*(M+1) for _ in range(M+1)]
    dp[0][0]=0

    for a,b,c in ABC:
        ndp=[a[:] for a in dp]
        for x,y in product(range(M+1),repeat=2):
            if(x+a<=M and y+b<=M):
                ndp[x+a][y+b]=min(ndp[x+a][y+b],dp[x][y]+c)
        dp=ndp

    ans=INF
    for x,y in product(range(1,M+1),repeat=2):
        if(x*mb==y*ma): ans=min(ans,dp[x][y])
    if(ans==INF): ans=-1
    print(ans)
resolve()

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

int main() {
  int h, w;
  cin >> h >> w;

  for (int i = 0; i < w + 2; i++) cout << '#';
  cout << endl;

  for (int i = 0; i < h; i++) {
    cout << '#';
    for (int j = 0; j < w; j++) {
      char c;
      cin >> c;
      cout << c;
    }
    cout << '#' << endl;
  }

  for (int i = 0; i < w + 2; i++) cout << '#';
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp fixed << setprecision
#define pb(x) push_back(x)
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    ll N, K;
    cin >> N >> K;
    ll a = N%K;
    cout << min(a, K-a) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    ll N,H;
    cin>>N>>H;
    vector<ll> a(N),b(N);
    vector<ll> c(N+1,0);
    rep(i,N) cin>>a.at(i)>>b.at(i);
    sort(a.begin(),a.end(),greater<ll>());
    sort(b.begin(),b.end(),greater<ll>());
    rep(i,N) c.at(i+1)=c.at(i)+b.at(i);
    ll ans = H/a.at(0);
    if(H%a.at(0)){
        ans++;
    }
    rep(i,N+1){
        ll tmp=H-c.at(i);
        if(tmp<=0){
            ans=min(ans,(ll)i);
            continue;
        }
        ll cnt=tmp/a.at(0);
        if(tmp%a.at(0)){
            cnt++;
        }
        ans=min(ans,i+cnt);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include <stdio.h>
#define n (10)
int main(void)
{
	int a,b;
	for(a=1;a<n;a++){
				for(b=1;b<n;b++){
							printf("%dx%d=%d",a,b,a*b);
							printf("\n");
							}
				}
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define rep(i,N) for(int i=1;i<N;i+=1)
using namespace std;
int main() {
  string S[]={"SUN","SAT","FRI","THU","WED","TUE","MON"};
  string T;
  cin>>T;
  if(T==S[0]) {
    cout<<'7'<<endl;
  }
  rep(i,7) if (T==S[i]) {
    cout<<i<<endl;
  }
}
  

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

inline int funcS(long n){
    int ans = 0;
    do {
        ans += (n % 10);
        n /= 10;
    } while(n > 0);
    return ans;
}

int main(){
    long n; cin >> n;
    if (n % funcS(n) == 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    int h,w,memo = 0,ans = 10000000;
    cin >> h >> w;
    int cell[h][w];
    
    rep(i,0,h){
        rep(j,0,w){
            cin >> cell[i][j];
        }
    }
    
    rep(i,0,h){
        rep(j,0,w){
            memo = 0;
            rep(k,0,h){
                rep(l,0,w){
                    memo += min(abs(i-k)*cell[k][l],abs(j-l)*cell[k][l]);  
                }
            }
            ans = min(ans,memo);
        }
    }
  
  	cout << ans << endl;
    return 0;
}


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

#define ll long long

int t,n;

void solve() {
	cin>>n;
	string s;
	unordered_map<string,int> mp;
	mp["AC"]=0;mp["WA"]=0;mp["TLE"]=0;mp["RE"]=0;
	for(int i=0;i<n;++i) {
		cin>>s;
		mp[s]++;
	}
	cout<<"AC x "<<mp["AC"]<<'\n';
	cout<<"WA x "<<mp["WA"]<<'\n';
	cout<<"TLE x "<<mp["TLE"]<<'\n';
	cout<<"RE x "<<mp["RE"]<<'\n';
}

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

	//cin >> t;
	//while(t--) 
		solve();
	//return 0;
}


Measured memory_bytes: 3664
#include <stdio.h>
#define min(a, b) ((a)>(b) ? (b) : (a))

int main(){
  int n;  scanf("%d", &n);
  long long int ans = 10000000000;
  for(int i=0; i<n; i++){
    long long int a;
    long long int count = 0;
    scanf("%lld", &a);
    while(!(a%2)){
      a /= 2;
      count++;
    }
    ans = min(ans, count);
  }
  printf("%lld\n", ans);
}


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

int main() {
  double b;
  int R, G;
  cin >> R;
  cin >> G;
  /*G = (R + b) / 2;
    G = (R / 2) + (b / 2);
    (b / 2) = G - (R / 2); */
  b = (G * 2) - R;
  cout << b << endl;
}


Measured memory_bytes: 256
fun main(arr:Array<String>) {
    val ans = if (canComplete()) "Yes" else "No"
    println(ans)
}

class Work(val require:Long, val limit:Long)

fun canComplete():Boolean {
    val workCount = readLine()!!.toInt()
    var works = Array<Work>(workCount, {Work(0,0)})
    (0..workCount-1).forEach{
        val (a,b) = readLine()!!.split(" ").map { it.toLong() }
        works[it] = Work(a, b)
    }
    works = works.sortedBy { it.limit }.toTypedArray()
    var now = 0.toLong()
    works.forEach {
        now = now + it.require
        if(now > it.limit) {
            return false
        }
    }
    return true
}

Measured memory_bytes: 132528
#include<bits/stdc++.h>
#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 each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  ll n,m;
  cin >> n >> m;
  vl a(n);
  rep(i,n) cin >> a[i];

  ll l = n/__gcd(n,m), cur = 0;
  ll sum = 0;
  rep(azu,l){
    ll min_v = a[cur], max_v = a[cur];
    rep(i,m){
      chmin(min_v, a[cur]);
      chmax(max_v, a[cur]);
      cur = (cur + 1) % n;
    }
    sum += max_v - min_v;
  }
  cout << sum << endl;
}

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

typedef long long ll;
typedef long double ld;
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 
#define printVerdict(verdict) cout << (verdict ? "Yes": "No") << '\n'
#define printDecimal(d) printf("%.9f\n", d)
#define inrange(val, start, end) (val >= start && val <= end)
#define var(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const ll inf = 0x3f3f3f3f;

template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) { cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n'; }
template <class T1, class T2>
void printPair(pair<T1, T2> p) { cout << p.first << " " << p.second << '\n'; }
template <class T>
void printArray(vector<T> arr) { for (int i = 0; i<size(arr); i++) {cout << arr[i] << " ";} cout << '\n'; } 

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	vector<int> left(n), right(n);
	for (int i = 0; i<n; i++) cin >> left[i] >> right[i];
	bool possible = false;
	for (int i = 0; i<n-2 && !possible; i++) {
		if (left[i] == right[i] && left[i+1] == right[i+1] && left[i+2] == right[i+2]) possible = true;
	}
	printVerdict(possible);
	
}



Measured memory_bytes: 3620
/*
23280701537353
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
//#define   Y            imag()
//#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
//#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
//#define    dp(a,b)          (((conj(a))*(b)).real())
//#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
//#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     PT                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
using namespace __gnu_pbds;
int dcmp(double a,double b){   return fabs(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
ll setBit1(ll num, int idx) {return num | (1ll<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(int num, int idx) {return num ^ (1<<idx);}
void FS(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
int a[100];
int main()
{
    int n;
    cin>>n;
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]!=i)
            cnt++;
    }
    if(cnt<=2)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}





























Measured memory_bytes: 256
l = gets.chomp.split(' ')
k = l[0].to_i
s = l[1].to_i
cnt = 0

(0..k).each do |x|
  (0..k).each do |y|
    if s - (x + y) <= k && s - (x + y) >= 0
      cnt += 1
    end
  end
end

puts cnt


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repA(i,n) for(int i=n; i>=0; i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())
typedef long long ll;
const ll mod = 1e9+7;//998244353
int t = 1;
/*
int rooms,psgs;
vector<int> a[(int)1e5 + 3];
vector<int> p((int)1e5 + 3 , 0);
vector<bool> v((int)1e5 + 3, false);

void dfs(int cur) {
  vector<int>
  for(auto &i:a[cur]) {
    if(v[i])  continue;
    p[i] = cur;
    v[i]=true;
  }
}*/

int calc(int x) {
  long double ans = 0.25;
  ans = sqrt((long double)x*2 + ans);
  ans -=0.5;
  return (int)ans;
}

void solve(int BYasD) {
  ll n; cin>>n;
  int cnt = 0;
  while(n%2 == 0) {
    cnt++;
    n = n/2;
  }
  int ans = 0;
  ans += calc(cnt);
  for(int i=3; i<=sqrt(n); i+=2) {
    cnt = 0;
    while(n%i == 0) {
      cnt++;n=n/i;
    }
    ans += calc(cnt);
  }
  if(n!=1)  ans++;
  cout<<ans<<'\n';
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  #endif
  //cin>>t;
  rep(i,t)  {
  //  cout<<"Case #"<<(i+1)<<'\n';
    solve(i);
  //  cout<<'\n';
  }
  return 0;
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define test(t) for(cin>>t;t;--t)
#define rep(i,n) for(ll i=0;i<n;i++)
#define repr(i,k,n) for(ll i=k;i<n;i++)
#define repr_r(i,n) for(ll i=n-1;i>=0;i--)
#define pb push_back
#define f first
#define sec second
#define in cin>>
#define out cout<<
#define optimize ios_base::sync_with_stdio(0);cin.tie(NULL);
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll>pll;

int main(){
	optimize
    int n, m; cin >> n >> m;
    int ans = 0;
    for(int i = 1; i <= n-1; i++) ans += i;
    for(int i = 1; i <= m-1; i++) ans += i;
    cout << ans ;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define P pair<long,long>
#define all(a) a.begin(),a.end()
using namespace std;

signed main(){
    int n; cin>>n;
    vector<double> x(n);
    vector<string> u(n);
    double ans=0;
    rep(i,n){
        cin>>x.at(i)>>u.at(i);
        if(u.at(i)=="JPY") ans+=x.at(i);
        else ans+=380000*x.at(i);
    }
    cout<<ans<<endl;
}


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

using namespace std;

int a[100000];

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

	int n;
	cin >> n;
	for( int i = 0; i < n; i++ )cin >> a[i];
	sort(a, a + n);
	int r = -1;
	double mid = a[n - 1] / 2.0;
	for( int i = 0; i < n; i++ )
	{
		if( abs(a[i] - mid) < abs(r - mid) )r = a[i];
	}
	cout << a[n - 1] << " " << r << endl;

	return 0;
}


Measured memory_bytes: 640
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 入力
		int n = sc.nextInt();

		// 計算
		int result = n * n * n;

		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <typename T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const vector<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
void ce(void){cerr << '\n';}
template <typename T>
void ce(const T n){cerr << n << '\n';}
template <typename T>
void cesp(const T n){cerr << n << ' ';}
template <typename T>
void ce(initializer_list<T> v){for(T i : v) cesp(i); ce();}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18L+1;
constexpr ll MOD = 1e9L+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void){
	ll n, d;
	cin >> n >> d;

	ll ans = n / (2 * d + 1);

	if(ans * (2 * d + 1) < n) ans++;
	co(ans);

	return 0;
}


Measured memory_bytes: 3680
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	count := 0
	for i:=n;i>0; {
		i /= 10
		count++
	}
	ans := 0
	for i:=3;i<=count;i++ {
		ans += dfs(n, i, "")
	}
	fmt.Println(ans)
}

func dfs(n int, digits int, sitigosan string) int {
	if digits == 0 {
		val, _ := strconv.Atoi(sitigosan)
		if val <= n && strings.Contains(sitigosan, "7") && strings.Contains(sitigosan, "5") && strings.Contains(sitigosan, "3") {
			return 1
		} else {
			return 0
		}
	}
	return dfs(n, digits-1, sitigosan+"3") + dfs(n, digits-1, sitigosan+"5") + dfs(n, digits-1, sitigosan+"7")
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#include<chrono>
using namespace std;
using namespace chrono;
#define all(a) a.begin(), a.end()
#define sz(x) (int(x.size()))
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef vector<string> vs;
template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
	in >> P.first >> P.second;
	return in;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, vector<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	const ll INF = 9e18;
	int n, k;
	cin >> n >> k;
	vl h(n), d(n, INF);
	cin >> h;
	d[0] = 0;
	for(int i = 1; i < n; i ++){
		for(int j = 1; j <= k && i >= j; j ++){
			d[i] = min(d[i], d[i - j] + abs(h[i] - h[i - j]));
		}
	}
	cout << d.back();
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> pippi;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<61;
int iinf=1<<30;
double pi=3.14159265358979323846;
double pi2=pi/2.0;
double eps=1e-8;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
//#define endl "\n"
int dh[4]={1,0,-1,0};
int dw[4]={0,1,0,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<int,int,custom_hash>
ll gcd(ll a,ll b){
    if(a<0)a=-a;
    if(b<0)b=-b;
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    if(k<0)return 0;
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    ll d;cin>>d;
    ll ans=0;
    rep(i,0,n){
        ll a,b;cin>>a>>b;
        if(a*a+b*b<=d*d)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define int long long 

int32_t main() {
  ios::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);

  int n;
  cin >> n;
  
  int lim = log2(n) / 2;
  vector<int> c(n + 1), w(n + 1);
  vector<vector<int>> dp(1<<lim, vector<int> (1e5+5, 0));
  for (int i = 1; i <= n; ++i) cin >> c[i] >> w[i];

  for (int i = 1; i < min((1ll<<lim), n+1); ++i) {
    for (int j = 1; j <= 1e5; ++j) {
      dp[i][j] = max(dp[i][j-1], dp[i/2][j]);
      if (j >= w[i]) dp[i][j] = max(dp[i][j], dp[i/2][j - w[i]] + c[i]);
    }
  }

  int q;
  cin >> q;
  
  while (q--) {
    int v, l;
    cin >> v >> l;
  
    vector<pair<int, int>> p;
    p.emplace_back(0, 0);

    while (v >= (1<<lim)) {
      int s = p.size();
      for (int i = 0; i < s; ++i) {
        if (p[i].second + w[v] <= l)
          p.emplace_back(p[i].first + c[v], p[i].second + w[v]);
      }
      v /= 2;
    }

    int ans = 0;
    for (int i = 0; i < (int)p.size(); ++i) {
      int wt = p[i].second;
      ans = max(ans, p[i].first + dp[v][l - wt]);
    }
    cout << ans << '\n';
  }
}


Measured memory_bytes: 208972
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const int MAX_N = 100000;
ll fact[MAX_N + 1];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll ans;
    fact[0] = 0;
    fact[1] = 1;
    ll fs = 1;
    for (int i = 2; i < MAX_N + 1; i++){
        fs = (fs*i) % MOD;
        fact[i] = (fact[i-1] + fs) % MOD;
    }
    while (1){
        int N, R;
        cin >> N;
        if (N == 0) break;
        vector<int> word(N);
        for (int i = 0; i < N; i++) word[i] = i;
        word.push_back(0);
        ans = 0;
        cin >> R;
        vector<int> s;
        for (int i = 0; i < R; i++){
						int s1, s2;
            cin >> s1 >> s2;
						s.push_back(s1);
            s.push_back(s2);
            s1--; s2--;
            s.push_back(s1);
            s.push_back(s2);
            swap(word[s1], word[s2]);
        }
				s.push_back(0);
        s.push_back(N);
        sort(s.begin(), s.end());
        s.erase(unique(s.begin(), s.end()), s.end());
        for (int i = 0, R = s.size() - 1; i < R; i++){
            ans =(ans + word[s[i]] * (fact[N - s[i] - 1] - fact[N - s[i+1] - 1] + MOD)) % MOD;
            for (int j = i + 1, dif = s[i+1] - s[i]; j < R; j++){
                word[s[j]] -= (word[s[j]] > word[s[i]] ? dif : 0);
            }
        }
        cout << ans % MOD << endl;
    }
    return 0;
}

Measured memory_bytes: 2792
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

class union_find{
	vector<int> parent;
public:
	vector<int> marked;
	int root(int a){return parent[a]==a||marked[a]?a:(parent[a]=root(parent[a]));}
	union_find(int n):parent(n),marked(n){for(int i=1;i<n;i++)parent[i]=i;}
	int same(int a,int b){return root(a)==root(b);}
	int unite(int a,int b){
		int x=root(a),y=root(b);//if(x==y)return 0;
		parent[x]=y;
		return 1;
	}
};

int main(){
	int N,M;
	for(;~scanf("%d%d",&N,&M)&&N;){
		vector<int>parent(N);
		for(int i=1;i<N;i++)scanf("%d",&parent[i]),parent[i]--;
		union_find uf(N);
		vector<pair<char,int> >query;
		for(int i=0;i<M;i++){
			char s[2];int n;
			scanf("%s%d",s,&n),n--;
			if(*s=='Q'||!uf.marked[n]){
				if(*s=='M')uf.marked[n]=1;
				query.emplace_back(*s,n);
			}
		}
		for(int i=1;i<N;i++)if(!uf.marked[i])uf.unite(i,parent[i]);
		reverse(query.begin(),query.end());
		long long R=0;
		for(auto &e:query){
			if(e.first=='Q')R+=uf.root(e.second)+1;
			else uf.marked[e.second]=0,uf.unite(e.second,parent[e.second]);
		}
		printf("%lld\n",R);
	}
}

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

int main(){
  string S;
  cin>>S;
  if(S=="RRR"){
    cout<<3<<endl;
    return 0;
  }
  if(S=="RRS"||S=="SRR"){
    cout<<2<<endl;
    return 0;
  }
  if(S=="SSS"){
    cout<<0<<endl;
    return 0;
  }
  cout<<1<<endl;
  return 0;
}



Measured memory_bytes: 3616
#include<stdio.h>
int k,s,ans;
int main(){
	scanf("%d %d",&k,&s);
	for(int i=0;i<=k;i++){
		for(int j=0;j<=k;j++){
			if((s-i-j)<=k&&(s-i-j)>=0){
			ans++;
			}
		}
	}
	printf("%d",ans);
}

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

using namespace std;
typedef long long ll;

int n, m, p;
int a[8][8][8];

bool check() {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        int c = a[i][j][k];
        if (c == 0) continue;
        for (int di = -1; di <= 1; di++) {
          for (int dj = -1; dj <= 1; dj++) {
            for (int dk = -1; dk <= 1; dk++) {
              if (di == 0 && dj == 0 && dk == 0) continue;
              int ni = i + di * (m - 1), nj = j + dj * (m - 1), nk = k + dk * (m - 1);
              if (ni >= 0 && ni < n && nj >= 0 && nj < n && nk >= 0 && nk < n) {
                bool res = true;
                for (int l = 0; l < m; l++) {
                  res &= a[i + di * l][j + dj * l][k + dk * l] == c;
                }
                if (res) return true;
              }
            }
          }
        }
      }
    }
  }
  return false;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  while (cin >> n >> m >> p, n) {
    fill(a[0][0], a[7][7], 0);
    int x, y;
    int win = 0, cnt = 0, turn = 1;
    for (int i = 0; i < p; i++) {
      cin >> x >> y;
      x--, y--;
      int h = 0;
      while (a[x][y][h] != 0) h++;
      a[x][y][h] = turn;
      if (win == 0 && check()) win = turn, cnt = i + 1;
      turn *= -1;
    }
    if (win == 0) cout << "Draw" << endl;
    else cout << (win > 0 ? "Black" : "White") << " " << cnt << endl;
  }

  return 0;
}


Measured memory_bytes: 3108
n,k=map(int,input().split())
x=[0]*n;y=[0]*n
for i in range(n):x[i],y[i]=map(int,input().split())

ans=1e20
for i in range(n):
    for j in range(i+1, n):
        for a in range(n):
            for b in range(a+1, n):
                cnt=0
                x1=min(x[i],x[j])
                x2=max(x[i],x[j])
                y1=min(y[a],y[b])
                y2=max(y[a],y[b])
                for c in range(n):
                    if x1<=x[c]<=x2 and y1<=y[c]<=y2: cnt+=1
                if cnt>=k:
                    ans=min(ans,(x2-x1)*(y2-y1))
print(ans)

Measured memory_bytes: 56412
#include<bits/stdc++.h>
#include<bitset>
using  namespace std;
#define ll long long
#define pb push_back
#define sc second
#define fr first
#define mp make_pair
const int N = 100 + 10 , Max = 2e5 + 10;
const ll  MOD = 1e9 + 7 , OO = 1e9 ;
int n , a[N];
int dp[N][N][3];
int main() {
    int n , k;
    cin >> n >> k;
    if(k == 1)
        n = k ;
    cout << n - k << endl;
}



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

int main()
{
    long int h[500];
    long m,n;
    cin>>n;
    for (long i=0;i<n;i++)

{
    cin>>h[i];

}

sort(h,h+n);
m=h[n-1]-h[0];
cout<<m<<endl;
  return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

template<class V,int NV> class SegTree_max {
public:
	vector<V> val;
	static V const def=0;
	V comp(V l,V r){ return max(l,r);};
	
	SegTree_max(){val=vector<V>(NV*2,def);};
	V getval(int x,int y,int l=0,int r=NV,int k=1) { // x<=i<y
		if(r<=x || y<=l) return def;
		if(x<=l && r<=y) return val[k];
		return comp(getval(x,y,l,(l+r)/2,k*2),getval(x,y,(l+r)/2,r,k*2+1));
	}
	void update(int entry, V v) {
		entry += NV;
		val[entry]=v; //上書きかチェック
		while(entry>1) entry>>=1, val[entry]=comp(val[entry*2],val[entry*2+1]);
	}
};

int N,Q;
int T,X,Y;
SegTree_max<int,1<<20> st;
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>Q;
	FOR(i,N) cin>>x, st.update(i,x);
	FOR(j,Q) {
		cin>>T>>X>>Y;
		if(T==1) {
			st.update(X-1,Y);
		}
		else if(T==2) {
			cout<<st.getval(X-1,Y)<<endl;
		}
		else {
			X--;
			int ret=N+1;
			for(i=20;i>=0;i--) if(ret-(1<<i)>X && st.getval(X,ret-(1<<i))>=Y) ret-=1<<i;
			cout<<ret<<endl;
		}
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

ll n, a, b, c;
vll ls;
ll ans = INF;
void dfs(vll& as, vll& bs, vll& cs, ll asum, ll bsum, ll csum, ll d){
  if(d == n){
    if(as.empty() || bs.empty() || cs.empty()) return;
    ll tmp = 0;
    tmp += max(0LL, ((ll)as.size() - 1))*10;
    tmp += abs(a - asum);
    tmp += max(0LL, ((ll)bs.size() - 1))*10;
    tmp += abs(b - bsum);
    tmp += max(0LL, ((ll)cs.size() - 1))*10;
    tmp += abs(c - csum);
    chmin(ans, tmp);
    return;
  }
  as.push_back(ls[d]);
  dfs(as, bs, cs, asum + ls[d], bsum, csum, d+1);
  as.pop_back();
  bs.push_back(ls[d]);
  dfs(as, bs, cs, asum, bsum + ls[d], csum, d+1);
  bs.pop_back();
  cs.push_back(ls[d]);
  dfs(as, bs, cs, asum, bsum, csum + ls[d], d+1);
  cs.pop_back();
  dfs(as, bs, cs, asum, bsum, csum, d+1);
}

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  cin >> n >> a >> b >> c;

  ls.resize(n);
  rep(i, n) cin >> ls[i];

  vll as, bs, cs;
  dfs(as, bs, cs, 0, 0, 0, 0);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3628
N = int(input())
ga, sa, ba = map(int, input().split())
gb, sb, bb = map(int, input().split())
def solve(N, P):
    V = []; W = []
    for w, v in P:
        if w < v:
            V.append(v); W.append(w)
    if len(V) == 1:
        v = V[0]; w = W[0]
        k = N // w
        return N - k*w + k*v
    if len(V) == 2:
        w1, w2 = W
        M = w1 * w2
        dp = [i for i in range(M+1)]
        for v, w in zip(V, W):
            if v <= w:
                continue
            for k in range(w, M+1):
                dp[k] = max(dp[k], dp[k-w] + v)
        for i in range(M):
            dp[i+1] = max(dp[i+1], dp[i])
        ans = 0
        for i in range(M):
            k, r = divmod(N, (i+1))
            ans = max(ans, dp[i+1] * k + dp[r])
        return ans
    dp = [i for i in range(N+1)]
    for v, w in zip(V, W):
        if v <= w:
            continue
        for k in range(w, N+1):
            dp[k] = max(dp[k], dp[k-w] + v)
    return max(dp)

A = solve(N, [[ga, gb], [sa, sb], [ba, bb]])
B = solve(A, [[gb, ga], [sb, sa], [bb, ba]])
print(B)

Measured memory_bytes: 124008
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll sunuke(ll m){
  ll ret=m;
  ll dig=0;
  ll digsum=0;
  ll temp=m;
  while(temp>0){
    dig++;
    digsum+=temp%10;
    temp/=10;
  }
  double sun=double(m)/(double)digsum;
  for(int i=0;i<dig;i++){
    ll power=pow(10,i+1);
    ll x=m-(m%power)+power-1;
    ll digsumx=0;
    ll tempx=x;
    while(tempx>0){
      digsumx+=tempx%10;
      tempx/=10;
    }
    double sunx=(double)x/(double)digsumx;
    if(sun>sunx){
      sun=sunx;
      ret=x;
    }
  }
  return ret;
}

int main(){
  ll n;
  cin >> n;
  ll t=0;
  rep(i,n){
    ll y=sunuke(t+1);
    cout << y << endl;
    t=y;
  }
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

int main () {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s[i];
  int m;
  cin >> m;
  vector<string> t(m);
  rep(i,m) cin >> t[i];

  map<string,int> blue, red;
  rep(i,n) blue[s[i]]++;
  rep(i,m) red[t[i]]++;
  
  
  int ans = 0;
  rep(i,n) {
    ans = max(ans, blue[s[i]]-red[s[i]]);
  }
  cout << ans << endl;
  return 0;
}

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

int n, m, rm, ans[100010];

int main(){
	scanf("%d%d", &n, &m);
	for(int x, y; n--; ){
		scanf("%d%d", &x, &y);
		int b = y + 1;
		for(int j = 1; j * j <= m; j++){
			int tx = (x + j - 1) / j, ty = y / j;
			ans[tx]++;
			ans[min(b, ty + 1)]--;
			b = tx;
		}
		for(int i = 1; i < b; i++){
			if((x - 1) / i < y / i){
				ans[i]++; ans[i + 1]--;
			}
		}
	}
	for(int i = 1; i <= m; i++){
		ans[i] += ans[i - 1];
		printf("%d\n", ans[i]);
	}
}

Measured memory_bytes: 1280
#include <set>
#include <cstdio>
#include <vector>
#include <algorithm>
typedef long long ll;

int n,m,k,Fac[205],Inv[205],Ans=1;
int Tim,Low[55],Dfn[55],Sta[55],Top;
std::vector<int> G[55];
const int p=1000000007;

int Gcd(const int a,const int b){return b?Gcd(b,a%b):a;}
ll Pow(ll a,ll b,ll s=1){for(;b;b>>=1,a=a*a%p)if(b&1)s=s*a%p;return s%p;}
inline ll C(const int n,const int m){return (ll)Fac[n]*Inv[m]%p*Inv[n-m]%p;}

void DFS(const int x,bool Root=false)
{
    Low[x]=Dfn[x]=++Tim,Sta[++Top]=x;
    for(int y:G[x])
        if(!Dfn[y])
        {
            DFS(y),Low[x]=std::min(Low[x],Low[y]);
            if(Low[y]==Dfn[x])
            {
                std::set<int> Dcc;
                int Cnt=1,Siz=0;
                do Dcc.insert(Sta[Top]),++Cnt;
                while(Sta[Top--]!=y);
                Dcc.insert(x);
                for(int u:Dcc)for(int v:G[u])if(Dcc.count(v))++Siz;
                if((Siz>>=1)<Cnt)Ans=(ll)Ans*k%p;
                else if(Siz==Cnt)
                {
                    ll Sum=0;
                    for(int i=0;i<Cnt;++i)Sum=(Sum+Pow(k,Gcd(i,Cnt)))%p;
                    Ans=(ll)Ans*Sum%p*Pow(Cnt,p-2)%p;
                }
                else Ans=(Ans)*C(Siz+k-1,k-1)%p;
            }
        }
        else Low[x]=std::min(Low[x],Dfn[y]);
    if(Root)--Top;
}

int main()
{
    scanf("%d%d%d",&n,&m,&k);
    for(int i=Fac[0]=1;i<=m+k;++i)Fac[i]=(ll)Fac[i-1]*i%p;
    Inv[m+k]=Pow(Fac[m+k],p-2);
    for(int i=m+k;i>=1;--i)Inv[i-1]=(ll)Inv[i]*i%p;
    for(int i=1,x,y;i<=m;++i)scanf("%d%d",&x,&y),G[x].push_back(y),G[y].push_back(x);
    for(int i=1;i<=n;++i)if(!Dfn[i])DFS(i,true);
    return printf("%d\n",Ans),0;
}


Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000009]={0};
void facto() {fact[0]=1LL;fact[1]=1LL;for(int i=2;i<=1000008;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1LL; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res%mod;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	facto();
	int x,y;
	cin>>x>>y;
	if((2*x-y)%3==0 && (2*y-x)%3==0)
	{
		int m=(2*x-y)/3;
		int n=(2*y-x)/3;
		if(n<0 || m<0)
		{
			cout<<"0";
			return 0;
		}
		int ans=ncr(n+m,n)%mod;
		cout<<ans<<endl;
	}
	else
		cout<<"0";
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}

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

int main() {
    char a[27];
    int i, j, c = 0;

    scanf("%s", a);

    for (i = 0; i < strlen(a); i++) {
        for (j = i + 1; j < strlen(a); j++) {
            if (a[i] == a[j])
                c++;
        }
    }
    if (c == 0)
        printf("yes");
    else
        printf("no");
}

Measured memory_bytes: 1704