akhauriyash/Code-Regression huggingface dataset:
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <climits>
#include <numeric>
#include <functional>

#define lnd '\n'
// #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define loop(i, n) for(ll i = 0; i < n; i++)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mk make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long long int lli;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;

template <class T>
T GCD (T a, T b) {
  if(a == 0) return b;
  return GCD(b%a, a);
}

template <class T>
T LCM(T a, T b){
  return a*b/GCM(a,b);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
T modpow(T x, T p, ll mod){
    T res = 1;
    while(p > 0){
        if(p&1) res = (res*x)%mod;
        x = (x*x)%mod;
        p /= 2;
    }
    return res%mod;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

struct HASH{
  size_t operator()(const pair<long,long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
    if(p1.first != p2.first) return p1.first < p2.first;
    else return p1.second < p2.second;
}

const int INF = std::numeric_limits<int>::max();
const ll M_INF = std::numeric_limits<ll>::min();
const ll LL_INF = std::numeric_limits<ll>::max();

void solution();
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

ll result[200005] = {0};
void fact(ll n) {
   if (n >= 0) {
      result[0] = 1;
      for (ll i = 1; i <= n; ++i) {
         result[i] = i * result[i - 1];
      }
   }
}

void solution(){
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  ll mod = 1e9+7;

  ll low = 0, high = 0;
  for(int i = 1; i <= n+1; i++){
    low += i-1;
    high += n-i+1;
    if(i >= k){
      ans += (high-low)+1;
      ans = ans%mod;
    }
  }

  cout << ans << endl;
}     



Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) int(a.size())
#define clr(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=2e5+10;
const int mod=0;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
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; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n,mx=0,Q=0,vis[N],p[N],tr[2][N<<2],ans[N];
#define ls (o<<1)
#define rs (o<<1|1)
void modify(int o,int l,int r,int p,int f0,int f1) {
    if(l==r) { tr[0][o]=f0,tr[1][o]=f1;return; }
    int mid=(l+r)>>1;
    if(p<=mid) modify(ls,l,mid,p,f0,f1);
    else modify(rs,mid+1,r,p,f0,f1);
    for(int i=0;i<2;i++) tr[i][o]=max(tr[i][ls],tr[i][rs]);
}
int query(int k,int o,int l,int r,int p) {
    if(l==r) return tr[k][o];
    int mid=(l+r)>>1;
    if(p<=mid) return max(query(k,ls,l,mid,p),tr[k][rs]);
    else return query(k,rs,mid+1,r,p);
}
int check(int Hx,int Hy,int Cx,int Cy) {
    int t=Cx-Cy+Q;
    if(t>=0) {
        int mx=query(t&1,1,1,n,Hy);
        if(mx>=t) return 1;
    }
    t=Cy-Cx+Q;
    if(t>=0) {
        int mx=query(t&1,1,1,n,Hx);
        if(mx>=t) return 1;
    }
    return 0;
}
int main() {
    n=gi();
    for(int i=1;i<=n;i++) {
        p[i]=gi();
        chkmax(mx,p[i]);
        if(mx==p[i]) vis[i]=1,++Q;
    }
    for(int i=n;i;i--) {
        int f0=0,f1=0,t=query(0,1,1,n,p[i]);
        if(vis[i]) f0=t+2;
        else f1=t+1;
        t=query(1,1,1,n,p[i]);
        if(vis[i]) f1=t?t+2:0;
        else f0=t?t+1:0;
        modify(1,1,n,p[i],f0,f1);
    }
    int fl=1;
    int Hx=-inf,Hy=-inf,Cx=0,Cy=0;
    for(int i=1;i<=n;i++) {
        int _Hx=Hx,_Cx=Cx;
        if(vis[i]) --Q;
        modify(1,1,n,p[i],0,0);
        if(chkmax(Hx,p[i])) ++Cx;
        if(check(Hx,Hy,Cx,Cy)) continue;
        Hx=_Hx,Cx=_Cx,ans[i]=1;
        if(chkmax(Hy,p[i])) ++Cy;
        if(!check(Hx,Hy,Cx,Cy)) { fl=0;break; }
    }
    if(!fl) puts("-1");
    else {
        for(int i=1;i<=n;i++) putchar(ans[i]+'0');
    }
    return 0;
}


Measured memory_bytes: 8704
#include<stdio.h>
#include<math.h>

int main(void) {
	int a, b, x, y, rad=90;
	double xx = 0, yy = 0, pi;

	while (1) {
		scanf("%d,%d",&a,&b);
		if (a == 0 && b == 0)break;
		pi = acos(-1);
		xx += a*cos(pi*rad / 180); 
		yy += a*sin(pi*rad / 180);
		rad -= b;
	}
	x = xx;
	y = yy;
	printf("%d\n%d\n",x,y);
	return 0;
}

Measured memory_bytes: 604
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val k = sc.nextLong()
    val a = (0 until n).map { sc.next().toLong() }
    val b = (0 until m).map { sc.next().toLong() }
    println(problem172c(n, m, k, a, b))
}

fun problem172c(
    n: Int,
    m: Int,
    k: Long,
    a: List<Long>,
    b: List<Long>
): Int {
    val aS = mutableListOf<Long>()
    aS.add(0)
    for (i in 0 until n) {
        aS.add(aS[i] + a[i])
    }
    val bS = mutableListOf<Long>()
    bS.add(0)
    for (i in 0 until m) {
        bS.add(bS[i] + b[i])
    }
    var max = 0
    for (i in 0 until aS.size) {
        val aC = k - aS[i]
        if (aC < 0) break
        val bsResult = bS.binarySearch(aC)
        val j = if (bsResult >= 0) {
            bsResult
        } else {
            -bsResult - 2
        }
        if (aS[i] + bS[j] > k) continue
        max = Math.max(max, i + j)

    }
    return max
}


Measured memory_bytes: 84256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef pair <int,int> P;
typedef long long ll;
#define f first
#define s second
#define INF 1000000000
int tree[4][(1<<19)];
int n,d;
pair <int,pair <int,int> > star[(1<<18)];

void update(int i,int x,int flg){
  i = (1<<18)+i-1;
  tree[flg][i] = x;
  while(i){
    i = (i-1)/2;
    tree[flg][i] = max(tree[flg][i*2+1],tree[flg][i*2+2]);
  }
}

int find(int a,int b,int M,int L,int R,int flg){
  if(b <=L || a >= R) return -INF;
  if(a <=L && R <= b) return tree[flg][M];
  int nx = (L+R)/2;
  return max(find(a,b,M*2+1,L,nx,flg),find(a,b,M*2+2,nx,R,flg));
}

int main() {
  scanf("%d %d",&n,&d);
  for(int i=0;i<(1<<19);i++) 
    for(int j=0;j<4;j++) tree[j][i] = -INF;
  for(int i=0;i<n;i++)
    scanf("%d %d %d",&star[i].s.f,&star[i].s.s,&star[i].f);
  sort(star,star+n);
  for(int i=0;i<n;i++) {
    update(i,star[i].s.f,0); // max(x);
    update(i,star[i].s.s,1); // max(y);
    update(i,-star[i].s.f,2); // min(x);
    update(i,-star[i].s.s,3); // min(y);
  }
  ll now = 0,minx,maxx,miny,maxy,S=0;
  for(int i=0;i<n;i++) {
    while(now < n && star[now].f -star[i].f <=d) now++;
    maxx = find(i,now,0,0,(1<<18),0);
    maxy = find(i,now,0,0,(1<<18),1);
    minx = find(i,now,0,0,(1<<18),2);
    miny = find(i,now,0,0,(1<<18),3);
    S = max(S,((ll)maxx+minx)*((ll)maxy+miny));
  }
  printf("%lld\n",S);
  return 0;
}

Measured memory_bytes: 12460
#include <iostream>
#include <math.h>
#include <iomanip>

int a[200010];
int ans[200010];
int main(){
  int n;
  scanf("%d",&n);
  for(int i=2;i<=n;i++)scanf("%d",&a[i]);
  for(int i=2;i<=n;i++)ans[a[i]]++;
  for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
}


Measured memory_bytes: 5276
#include <algorithm>
#include <iostream>
#define lim 100
using namespace std;

int main (void){
    int K, T;
    int a[lim]={};
    int ans;
    
    cin >> K >> T;
    for(int i=0; i<T; i++){
        cin >> a[i];
    }

    sort(a, a + 100);
    /*
     for(int i=99; i>100-T-5; i--){
        cout << a[i];
    }
     */
    
    ans = a[lim-1]-1;
    for(int i = lim-2; i>=0; i--){
        if(ans != 0)
           ans -= a[i];
    }
    
    if(ans < 0){
        ans = 0;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

ans=0
rmn=0
for i in range(n):
    if a[i]<b[i]+rmn:
        if rmn>a[i]:
            rmn=b[i]
        else:
            rmn=rmn+b[i]-a[i]
        ans+=a[i]
    else:
        ans+=b[i]+rmn
        rmn=0
ans+=min(a[-1],rmn)
print(ans)

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

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    int total = a + b;
    string s; cin >> s;
    int cnt = 0, cntb = 0;
    rep(i,n){
        string ans = "Yes";
        if (s[i] == 'c') {
            ans = "No";
        }
        else if (s[i] == 'a')
        {
            if (cnt < a+b) cnt++;
            else ans = "No";
        }
        else {
            cntb++;
            if (cnt < a+b and cntb <= b) cnt++;
            else ans = "No";
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3712
# ABC_083_B_Some_Sums
N, A, B = list(map(int, input().split()))

def findSumOfDigits(N):
	sum = 0
	while N > 0:
		sum += N % 10
		N = N//10
	return(sum)
	
total = 0
for i in range(1, N+1):
	sum = findSumOfDigits(i)
	if (A <= sum and sum <= B):
		total += i
print(total)


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

int n;
double j, b;
string s[11];

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        double a;
        cin >> a >> s[i];
        if (s[i] == "JPY")
            j += a * 1.0;
        else
            b += a * 380000.0;
    }
    printf("%lf", j + b);
}


Measured memory_bytes: 256
from math import *
from statistics import *
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    input()
    xx = list(map(int, input().split()))
    yy = list(map(int, input().split()))
    d1=d2=d3=d4=0
    for x,y in zip(xx,yy):
        d=abs(x-y)
        d1+=d
        d2+=d**2
        d3+=d**3
        d4=max(d4,d)
    print(d1)
    print(d2**0.5)
    print(d3**(1/3))
    print(d4)

main()



Measured memory_bytes: 6948
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
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...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n,x;cin >> n >> x;
    int a[n];
    rep(i,n)cin >> a[i];
    int ans = 0;
    rep(i,n-1){
        int tmp = a[i] + a[i+1];
        int hoge = max(tmp - x,0ll);
        ans += max(tmp - x,0ll);
        a[i+1] = max(a[i+1] - hoge,0ll);

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


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>

using namespace std;

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

//------------------------------------------------------------------------------
const int N_MAX = 100000;

int N;
char s[N_MAX + 1];
char t[N_MAX + 2];

void input() {
  scanf("%d", &N);
  scanf("%s", s);
}

void solve() {
  REP(i, 4) {
    int f[2];
    fill(t, t + N + 2, 0);
    REP(k, 2) {
      f[k] = i >> k & 1;
      t[k] = (f[k] == 0 ? 'S' : 'W');
    }
    // printf("%d: %s\n", i, t);
    REP(k, N) {
      int g = f[0] ^ f[1] ^ (s[k] == 'o' ? 0 : 1);
      t[k + 2] = (g == 0 ? 'S' : 'W');
      f[0] = f[1]; f[1] = g;
      // printf("%d:%c:%d%d:%s\n", k, s[k], f[0], f[1], t);
    }
    bool ok = true;
    REP(k, 2) {
      if (t[k] != t[N + k]) ok = false;
    }
    if (ok) {
      t[N + 1] = '\0';
      puts(t + 1);
      return;
    }
  }
  puts("-1");
}

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


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
bool solve(int n){
	if(n <2)return false;
	for(int i =2 ; i<sqrt(n); i++) if ( n % i ==0) return false;
	return true;
}
int main(){
	int x; cin>>x;
	while(!solve(x)){
		x++;
	}
	cout<<x;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
/// functions
static long gcd(long a,long b){if(b==0){return a;}return gcd(b,a%b);}
static long Modpow(long a,long p,long m){long res=1;while(p>0){if((p&1)!=0){res=(res*a)%m;}p >>=1;a=(a*a)%m;}return res;}
static long Modmul(long a,long b,long m){return ((a%m)*(b%m))%m;}
static long ModInv(long a,long m){return Modpow(a,m-2,m);}
static long nck(int n,int r,long m){if(r>n){return 0l;}return Modmul(f[n],ModInv(Modmul(f[n-r],f[r],m),m),m);}
// end
static long[] f;
// taking inputs
static BufferedReader s;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
// ends
//......................................@uthor_Alx..............................................

public static void main(String[] args) throws  IOException{
       assign();
       long[] nab=long_arr();
       long mod=(long)1e9+7,res=Modpow(2,nab[0],mod);
       res--;
       long res1=1l,res2=1l;
      for(int i=1;i<=(int)nab[1];i++){
      	res1=(res1*(nab[0]-nab[1]+i))%mod;
      }
       for(int i=1;i<=(int)nab[1];i++){
      	res2=(res2*i)%mod;
      }
      res-=Modmul(res1,ModInv(res2,mod),mod);
      res=(res+mod)%mod;
      res1=1l;res2=1l;
      for(int i=1;i<=(int)nab[2];i++){
      	res1=(res1*(nab[0]-nab[2]+i))%mod;
      }
       for(int i=1;i<=(int)nab[2];i++){
      	res2=(res2*i)%mod;
      }
      res-=Modmul(res1,ModInv(res2,mod),mod);
      res=(res+mod)%mod;
             out.write(res+"");
        out.flush();
  }
}


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

int main(){
  int s,w;
  cin >>s>>w;
  if (w>=s) cout <<"unsafe"<<endl;
  else cout <<"safe"<<endl;
  
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=int(l);i<int(r);i++)
#define put(x) cout<<#x<<" = "<<x<<endl;
#define X first
#define Y second
#define pb push_back
#define pp pop_back
#define int num
using namespace std;
typedef long long num;
typedef pair<int,int> point;
const int maxn=1e5+10;

int n,m;

int32_t main(){
    cin>>n>>m;
    if(n>m) swap(n,m);
    if(m==1) cout<<1<<endl;
    else if(n==1) cout<<m-2<<endl;
    else cout<<(n-2)*(m-2)<<endl;
}


Measured memory_bytes: 256
//Night's template
//orzakyrt
#include <bits/stdc++.h>
#define R register
#define LL long long
#ifdef __DEBUG__
	#define Debug (fprintf(stderr,"orzyrt\n"),fflush(stderr))
	#define debug(__a...) (fprintf(stderr,__a),fflush(stderr))
	#define setfile(__a) ('orzyrt')
	#define Compile(__a) system("g++ "__a".cpp -lm -o "__a)
#else
	#define Debug ('orzyrt')
	#define debug(__a...) ('orzyrt')
	#define setfile(__a) freopen(__a".in","r",stdin);freopen(__a".out","w",stdout)
	#define Compile(__a) ('orzyrt')
#endif
template<class TT>inline TT Max(R TT a,R TT b){return a<b?b:a;}
template<class TT>inline TT Min(R TT a,R TT b){return a<b?a:b;}
template<class TT>inline TT Abs(R TT a){return a<0?-a:a;}
template<class TT>inline TT cmin(R TT &a,R TT b){(b<a)&&(a=b);}
template<class TT>inline TT cmax(R TT &a,R TT b){(a<b)&&(a=b);}
using namespace std;
template<class TT>inline void read(R TT &x){
	x=0;R bool f=false;R char c=getchar();
	for(;c<48||c>57;c=getchar())f|=(c=='-');
	for(;c>47&&c<58;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	(f)&&(x=-x);
}
//end template

namespace Night{
	string s,t;
	LL n,m,lcm;
	int main(){
		read(n);read(m);
		cin>>s>>t;
		lcm=n*m/__gcd(n,m);
		for(R int i=0;i<n;++i){
			if(i*m%n==0 && s[i]!=t[i*m/n]){
				puts("-1");
				return 0;
			}
		}
		cout<<lcm;
		return 0;
	}
}
int main(){
	return Night::main();
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1LL<<60; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
const int MAX_N = 210;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, r; cin >> n >> m >> r;
    vector<int> v(r);
    for(int i = 0; i < r; i++) { cin >> v[i]; v[i]--; }
    sort(v.begin(), v.end());
    ll dist[MAX_N][MAX_N];
    for(int i = 0; i < MAX_N; i++)
    {
        for(int j = 0; j < MAX_N; j++) dist[i][j] = INF;
        dist[i][i] = 0;
    }
    for(int i = 0; i < m; i++)
    {
        int a, b, c; cin >> a >> b >> c;
        a--, b--;
        dist[a][b] = c;
        dist[b][a] = c;
    }
    for(int k = 0; k < n; k++)
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++)
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    ll ans = INF;
    do
    {
        ll total = 0;
        for(int i = 1; i < r; i++) total += dist[v[i]][v[i - 1]];
        ans = min(ans, total);
    }
    while(next_permutation(v.begin(), v.end()));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import sys


s = sys.stdin.readline().rstrip()
x, y = map(int, sys.stdin.readline().split())

def reachable(deltas, goal):
    if not deltas:
        if goal == 0:
            return True
        else:
            return False
    
    s = sum(deltas)
    if goal < -s or s < goal:
        return False

    if (s - goal) & 1:
        return False

    a = (s - goal) // 2

    res = [False] * (a + 1)
    res[0] = True
    for d in deltas:
        for i in range(a, -1, -1):
            if res[i] and i + d <= a:
                res[i+d] = True
    return res[a]

def main():
    gx = x; gy = y
    dx = []
    dy = []
    direction = 0

    origin_x = 0
    for i in s:
        if i == 'T':
            break
        origin_x += 1
    gx -= origin_x

    tmp = 0
    for i in s[origin_x:] + 'T':
        if i == 'T':
            if direction == 0:
                if tmp != 0:
                    dx.append(tmp)
                direction = 1
            else:
                if tmp != 0:
                    dy.append(tmp)
                direction = 0
            tmp = 0
        else:
            tmp += 1

    return 'Yes' if reachable(dx, gx) & reachable(dy, gy) else 'No'
    
if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#define MAX 200001

using namespace std;

int main()
{
	int n, m;
	int arr[MAX], brr[MAX];
	vector<int> vec(MAX);
	vector<int>::iterator itr = vec.begin();

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

	scanf("%d", &m);
	for (int j = 0; j < m; j++)
	{
		scanf("%d", &brr[j]);
	}

	itr = set_intersection(arr, arr + n, brr, brr + m, vec.begin());
	vec.resize(itr - vec.begin());

	for (unsigned loop = 0; loop < vec.size(); loop++)
	{
		printf("%d\n", vec[loop]);
	}

	return 0;
}



Measured memory_bytes: 5128
# import math
# import bisect
# import heapq
# from copy import deepcopy
# from collections import deque
# from collections import Counter
# from itertools import accumulate
# from itertools import permutations
# import numpy as np


# k,x = map(int, input().split())
# n = int(input())
# p = list(map(int, input().split()))
s,t = input().split()

print(t+s)


Measured memory_bytes: 2940
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

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

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {
    ll n,k;
    priority_queue<ll> pq;
    cin >> n >> k;
    rep(i, n) {
        ll t;
        cin >> t;
        pq.push(t);
    }

    rep(i, k) {
        pq.pop();
    }

    ll ans = 0;
    rep(i, n-k) {
        ll t = pq.top();
        ans += t;
        pq.pop();
    }

    print(ans);
    
    return 0;
}


Measured memory_bytes: 2420
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String[] dayOfWeek = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
        int i = 0;
        while (!s.equals(dayOfWeek[i])) {
            i++;
        }
        System.out.println(7 - i);
        sc.close();
    }
}

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

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

    vector<int> a(n);
    int md = 0;
    multiset<int> cnt;
    //map<int, int> cnt;
    vector<int> G[110];
    for (int i = 0; i < n; ++ i) {
        cin >> a[i];
        md = max(md, a[i]);
        cnt.insert(a[i]);
        G[a[i]].push_back(i);
    }

    bool flag = true;
    int l = 0, r = 0;
    if (G[md].size() == 1) {
        flag = false;
    } else {
        //l = G[md][0];
        //r = G[md][1];
        cnt.erase(cnt.find(md));
        cnt.erase(cnt.find(md));
    }
    for (int i = 1; i < md; ++ i) {
        int d = max(md - i, i);
        if (cnt.find(d) == end(cnt)) {
            flag = false;
            break;
        } else {
            cnt.erase(cnt.find(d));
        }
    }
    for (int i = 1; i < md; ++ i) {
        int d = max(md - i, i);
        for (int j = d + 1; j <= md; ++ j) {
            while (cnt.find(j) != cnt.end()) {
                cnt.erase(cnt.find(j));
            }
            //G[j].clear();
        }
    }

    if (cnt.size()) {
        flag = false;
    }

    if (flag) cout << "Possible\n";
    else cout << "Impossible\n";

    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

int[100] WS, VS;

void main()
{
    auto nw = readln.split.to!(int[]);
    auto N = nw[0];
    auto W = nw[1];

    long[][] MEMO;
    MEMO.length = N;

    foreach (i; 0..N) {
        auto wv = readln.split.to!(int[]);
        WS[i] = wv[0];
        VS[i] = wv[1];
        MEMO[i].length = 10^^5+1;
    }

    long solve(int i, int w) {
        if (i == N) return 0;
        if (MEMO[i][w]) return MEMO[i][w];
        return MEMO[i][w] = max(
            solve(i+1, w),
            w >= WS[i] ? solve(i+1, w - WS[i]) + VS[i] : 0
        );
    }

    writeln(solve(0, W));
}

Measured memory_bytes: 81276
#include<iostream>
#include<math.h>
using namespace std;

int main() {
    int N, D; cin >> N >> D;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int X, Y; cin >> X >> Y;
        if (pow(X, 2) + pow(Y, 2) <= pow(D, 2)) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3560
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0;i < n;i++) {
			a[i] = sc.nextInt();
		}
		int num = 1;
		int ans = 0;
		boolean flag = false;
		for(int i = 0;i < n;i++) {
			if(a[i] == num) {
				num++;
			}else {
				ans++;
				flag = true;
			}
		}

		if(ans == n) {
			ans = -1;
		}
		System.out.println(ans);



	}




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

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



}


class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}


Measured memory_bytes: 87112
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = Long.parseLong(sc.next());
        int x = 0;
        long n = N;
        while(n > 0) {
            x += n % 10;
            n /= 10;
        }
        if(N % x == 0) System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 21844
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int a[1001],d,m,n,p;
  while(cin>>n>>m&&n+m){
    for(i=0;i<n;i++)
      cin>>a[i];
    p=0;
    for(i=0;p<n-1;i++){
      cin>>d;
      p+=d+a[p+d];
    }
    cout<<i<<endl;
    for(;i<m;i++)
      cin>>d;
  }
  return 0;
}

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


int main(){
  int N;
  cin >> N;
  long count=0;
  int num=0;
  for(int i=0; i<N; i++){
    int a; cin >> a;
    if(a==i+1) num++;
    else{
      if(num==1) count++;
      else if(num%2==0) count+=num/2;
      else count+=num/2+1;
      num=0;
    }
  }
  if(num==1) count++;
  else if(num%2==0) count+=num/2;
  else count+=num/2+1;
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <string>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(n, N) cin >> A[n];

    ll all = abs(A[0]);
    REP(n, N-1) {
        all += abs(A[n] - A[n+1]);
    }
    all += abs(0 - A[N-1]);

    REP(n, N) {
        ll tmp = all;
        if (n == 0) {
            tmp -= abs(A[0]);
            tmp -= abs(A[0] - A[1]);
            tmp += abs(A[1]);
        }
        else if (n == N-1) {
            tmp -= abs(A[N-1]);
            tmp -= abs(A[N-1] - A[N-2]);
            tmp += abs(A[N-2]);
        }
        else {
            tmp -= abs(A[n] - A[n-1]);
            tmp -= abs(A[n] - A[n+1]);
            tmp += abs(A[n+1] - A[n-1]);
        }
        cout << tmp << endl;
    }

    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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;
}

signed main() {
  int a,b,c,d; cin >> a >> b >> c >> d;
  int ans = - (int)1000000000*(int)1000000000;
  chmax(ans, a*c);
  chmax(ans, b*c);
  chmax(ans, a*d);
  chmax(ans, b*d);
  cout << ans << endl;
  
}

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

int main() {
  int a[10][10]={},x,y,z,count=0, max=0;
  while(scanf("%d%*c%d%*c%d",&x,&y,&z)==3) {
    if(z>2) {
      if(y-2>=0) a[x][y-2]++;
      if(y+2<10) a[x][y+2]++;
      if(x-2>=0) a[x-2][y]++;
      if(x+2<10) a[x+2][y]++;
    }
    if(z>1) {
      if(y+1<10 && x-1>=0) a[x-1][y+1]++;
      if(y+1<10 && x+1<10) a[x+1][y+1]++;
      if(y-1>=0 && x-1>=0) a[x-1][y-1]++;
      if(y-1>=0 && x+1<10) a[x+1][y-1]++;
    }
    if(z>0) {
      if(y+1<10) a[x][y+1]++;
      if(y-1>=0) a[x][y-1]++;
      if(x-1>=0) a[x-1][y]++;
      if(x+1<10) a[x+1][y]++;
      a[x][y]++;
    }
  }
  for(int i=0; i<10; i++) {
    for(int j=0; j<10; j++) {
      if(a[i][j]==0) count++;
      if(a[i][j]>max) max=a[i][j];
    }
  }
  cout << count << endl << max << endl;
  return 0;
}


Measured memory_bytes: 1208
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
ll MOD=1000000007;

int main(){
  string s,t; cin>>s>>t;
  int ans = 0;
  rep(i,3) if (s[i]==t[i]) ans++;
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

int main() {
    int n; cin >> n;
    vector<int> a;
    int cur = 0;
    for (int i = 0; i < n; ++i) {
        int ai; cin >> ai;
        if (ai != cur) {
            a.push_back(ai);
            cur = ai;
        }
    }
    int ans = 1;
    int dir = -1;
    for (int i = 1; i < (int)a.size(); ++i) {
        if (dir < 0) {
            if (a[i] > a[i - 1]) {
                dir = 1;
            } else {
                dir = 0;
            }
        } else {
            if (dir) {
                if (a[i] < a[i - 1]) {
                    ++ans;
                    dir = -1;
                }
            } else {
                if (a[i] > a[i - 1]) {
                    ++ans;
                    dir = -1;
                }
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3840
import java.util.Scanner;
//* alds1_2_B *//
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int input[] = new int[N];
        int minj,i,j,tmp,k;
        int count = 0;
        for (int x =0 ; x < N ; x++){
            input[x] = sc.nextInt();
        }
        for (i=0; i <N; i++){
            minj = i;
            for (j =i; j < N; j++){
                if(input[j] < input[minj]){
                    minj = j;
                }
            }
            if(i != minj) {
                tmp = input[minj];
                input[minj] = input[i];
                input[i] = tmp;
                count++;
            }
        }
        for(k=0; k<N-1;k++){
            System.out.print(input[k]+ " ");
        }
        if(k == N-1){
            System.out.println(input[k]);
        }
        System.out.println(count);
    }

}


Measured memory_bytes: 26264
#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 all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

int N,M;
cin >> N >> M;
vector<pair<ll ,ll>> D(N);
rep(i,N) cin >> D[i].first >> D[i].second;
sort(all(D));

ll ans = 0;
rep(i,N) {
    if(D[i].second < M) {
        ans += D[i].first * D[i].second;
        M -= D[i].second;
    }else {
        ans += D[i].first * M;
        break;
    }
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){

    llong N, M;
 
    cin >> N  >> M;
 
    llong S = N;
    llong C = M;
 
    llong ret = 0;
    ret += min(S, C/2);
 
    S -= ret;
    C -= ret * 2;
 
    ret += C / 4;
 
    cout << ret << endl;
 
    return 0;
}


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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int n, m;
    cin >> n >> m;

    ll K;
    cin >> K;

    vector<ll> a(n + 1, 0), b(m);
    for (int i = 0; i < n; i++) {
        cin >> a[i + 1];
        a[i + 1] += a[i];
    }

    for (int i = 0; i < m; i++) {
        cin >> b[i];
        if (i > 0) b[i] += b[i - 1];
    }

    int ans = 0;
    for (int i = 0; i <= n; i++) {
        if (a[i] > K) continue;
        int num = upper_bound(b.begin(), b.end(), K - a[i]) - b.begin();
        ans = max(ans, num + i);
    }
    cout << ans << newl;

    return 0;
}

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

int main() {
  int n, y;
  cin >> n >> y;
  int A, B, C, x, t = 0;
  for(int a = 0;a <= n;a++) {
    for(int b = 0;a + b <= n;b++) {
      int c = n - a - b;
      int t = (10000*a)+(5000*b)+(1000*c);
      if(t == y) {
        A = a;
        B = b;
        C = c;
        x++;
        break;
      }
    }
  }
  if(x != 0) {
  	cout << A << " " << B << " " << C << endl;
  } else {
    cout << -1 << " " << -1 << " " << -1 << endl;
  }
}


Measured memory_bytes: 3632
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,copy
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = []
for _ in range(n):
    tmp = inpl()
    tmp = [x-1 for x in tmp] + [-1]
    # print(tmp)
    a.append(deque(tmp))
md = [0] * n
nx = [-1] * n
for i in range(n):
    nx[i] = a[i].popleft()
q = deque(range(n))

while q:
    x = q.popleft()
    y = nx[x]
    if nx[y] == x:
        d = max(md[x], md[y])
        md[x] = md[y] = d+1
        nx[x] = a[x].popleft()
        nx[y] = a[y].popleft()
        q.append(x); q.append(y)
if any(x for x in a):
    print(-1)
else:
    print(max(md))

Measured memory_bytes: 106712
N,K =map(int,input().split())
V =[int(i)for i in input().split()]
V.append("dami-")
ans = 0
for i in range(min(N,K)):
    i += 1
    for j in range(i+1):
        get = V[0:j] +V[j-i-1:-1]
        get.sort()
        for n in range(min(K-i,len(get))):
            if get[n]<0:
                get[n]=0
            else:
                break
        su =sum(get)
        if ans < su:
            ans = su
print(ans)

Measured memory_bytes: 3064
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

    READV(N);
    ld ans=ceil(((ld)N)/((ld)1.08));
    if (floor(ans*1.08)==N)
    {
        cout<<(ll)ans<<endl;
    }
    else
    {
        cout<<":("<<endl;
    }
    
    

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define MOD 1000000007
#define For(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
vector<pair<int,int> > p;
main(){
	int N,temp;
	cin >> N;
	long long ans = 1;
	For(i,1,N) {
		scanf("%d",&temp);
		p.push_back(make_pair(temp,1));
	}
	For(i,1,N) {
		scanf("%d",&temp);
		p.push_back(make_pair(temp,-1));		
	}
	sort(p.begin(),p.end());
	int currentS = 0;
	For(i,0,p.size()-2){
		if(currentS*p[i].second < 0){
			(ans *= abs(currentS)) %= MOD;
//			cout << i << "==" <<  currentS << endl;
		}
		currentS += p[i].second;
	}
	cout << ans;
}


Measured memory_bytes: 2420
#include "bits/stdc++.h"

using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ll long long
#define li long int
#define ld long double
#define lld long long double

#define pb push_back
#define mk make_pair
#define F first
#define S second

#define all(v) (v).begin(),(v).end()
#define fill(a) memset(a, 0, sizeof(a))

const int MX = 1e6;
const int MI = -1e6;
const int MOD = 1e9 + 7;
const string ALPHA = "abcdefghijklmnopqrstuvwxyz";
const double PI = 3.1415926535;

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

const int mod=1e9+7;
inline int add(int x,int y){
  x+=y;
  if (x>=mod) return x-mod;
  return x;
}
inline int sub(int x,int y){
  x-=y;
  if (x<0) return x+mod;
  return x;
}
inline int mul(int x,int y){
  return (x*1ll*y)%mod;
}
inline int power(int x,int y){
  int ans=1;
  while(y){
    if (y&1) ans=mul(ans,x);
    x=mul(x,x);
    y>>=1;
  }
  return ans;
}
inline int inv(int x){
  return power(x,mod-2);
}

int main()
{
  IOS;
  int n, m;
  cin >> n >> m;
  int arr[n];
  int t=0;
  for (int i=0; i<n; i++)
    {
      cin >> arr[i];
      t+=arr[i];
    }
  //int ans=(1/(4*t))*m;
  int cnt=0;
  for (int i=0; i<n; i++)
    {
      if (arr[i]*4*m>=t)
	cnt++;

    }
  if (cnt>=m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3664
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<iomanip>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{"; for(auto nth : list){ cout << nth << " ";}cout << "}" << endl;

using namespace std;

string table[]={"qwertasdfgzxcvb","yuiophjklnm"};


int main(){

		int n;
		vector<string> list;
		cin >> n;
		
		for(int i=0;i<n;i++){
			string str;
			cin >> str;
			list.push_back(str);	
		}

		cin >> n;
		
		bool flag=false,s_flag=false;

		for(int i=0;i<n;i++){
			string str;
			cin >> str;
			for(int k=0;k<list.size();k++){
				if(list[k]==str){
					if(flag==false){
						cout << "Opened by " << str << endl; 
						flag = true;
					}
					else if(flag==true){
						cout << "Closed by " << str << endl;
						flag = false;
					}
					s_flag=true;
				}
			}
			if(!s_flag){
				cout << "Unknown " << str << endl;
			}
			s_flag=false;
		}

}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>a>>b;

    cur = 1;

    while(cur<b){
        cur--;
        cur += a;
        cnt++;
    }

    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
  string n;
  cin >> n;
  int k = 0;
  for (int i = 0; i < n.length(); i++) {
    k += n[i] - 48;
  }
  if (k % 9 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3672
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        int a, b, c;
        double s, l, h;
        Scanner sc = new Scanner(System.in);
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        h = b * Math.sin(Math.toRadians(c));
        s = a * h / 2;
        l = a + b + Math.sqrt((a - b*Math.cos(Math.toRadians(c))) * (a - b*Math.cos(Math.toRadians(c))) + h * h);
        System.out.printf("%f\n%f\n%f\n", s, l, h);
    }
}


Measured memory_bytes: 26312
X, Y = map(int, input().split())
ans = 0
if X == 1:
    ans += 300000
elif X == 2:
    ans += 200000
elif X == 3:
    ans += 100000
if Y == 1:
    ans += 300000
elif Y == 2:
    ans += 200000
elif Y == 3:
    ans += 100000
if X == Y == 1:
    ans += 400000
print(ans)
  

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define ll long long
#define N 100007
#define inf 1000000007
#define pb push_back
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define mp make_pair
using namespace std;
int n;
bool bol(int n){
	int s=0,k=n;
	while (n>0){
		s+=n%10;
		n/=10;
	}
	if (k%s==0) return 1; else return 0;
}
main(){
	cin>>n;
	if (bol(n)) cout<<"Yes"; else cout<<"No";
}

Measured memory_bytes: 256