akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        char[] s1 = br.readLine().toCharArray();
        int len1 = s1.length;
        char[] s2 = br.readLine().toCharArray();
        int len2 = s2.length;

        int[][] dp = new int[len1 + 1][len2 + 1];
        for(int i = 0; i <= len1; i++) {
            dp[i][0] = i;
        }
        for(int j = 1; j <= len2; j++) {
            dp[0][j] = j;
        }

        for(int i = 0; i < len1; i++) {
            for(int j = 0; j < len2; j++) {
                int tmp = Math.min(dp[i + 1][j], dp[i][j + 1]) + 1;
                if(s1[i] == s2[j]) dp[i + 1][j + 1] = Math.min(tmp, dp[i][j]);
                else dp[i + 1][j + 1] = Math.min(tmp, dp[i][j] + 1);
            }
        }

        System.out.println(dp[len1][len2]);

        br.close();
    }
}


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

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

    for(int steps = 0; steps <= 100; ++steps) {
        if(a % 2 or b % 2 or c % 2) {
            cout << steps << "\n";
            return 0;
        }

        int aa = (b + c) / 2;
        int bb = (a + c) / 2;
        int cc = (a + b) / 2;

        a = aa, b = bb, c = cc;
    }

    cout << "-1\n";
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long int gcd(long long int x, long long int y) { return (x % y)? gcd(y, x % y): y; }
long long int lcm(long long int x, long long int y) { return x / gcd(x, y) * y; }
int main(){
	long long int N,M,a=1,b,sum=0,soin=0,s,pre;
	cin>>N>>M;
	cin>>a;
	pre=a;
	while(pre%2==0){soin++;pre/=2;}
	a/=2;
	for(long long int i=1;i<N;i++){
		cin>>b;
		pre=b;
		s=0;
		while(pre%2==0){s++;pre/=2;}
		a=lcm(a,b/2);
		if(a>M||s!=soin){cout<<0;return 0;}
	}
	for(long long int i=1;;i+=2){
		if(a*i<=M)sum++;
		else break;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 7;
int a, b, c, k;
int main()
{
    scanf("%d%d%d%d", &a, &b, &c, &k);
    if(a >= k) {
        printf("%d\n", k);
    }
    else if(a + b >= k) {
        printf("%d\n", a);
    }
    else {
        printf("%d\n", a - (k - a - b));
    }
}


Measured memory_bytes: 3760
#include <iostream>

#include <string>


using namespace std;


void Print(string& str,int a,int b){
    string str1="";
    for(int i=a;i<=b;++i ){
        str1+=str[i];
    }
 
    cout<<str1<<endl;
}

void reverse(string& str,int a,int b){
    string str1="";
    for(int i=0;i!=a;++i){
        str1+=str[i];
    }
    for(int i=b;i>=a;--i){
        str1+=str[i];
    }
    for(int i=b+1;i!=str.size();++i){
        str1+=str[i];
    }
    swap(str,str1);
}

void replace(string& str,int a,int b,string& p){
    string str1="";
    for(int i=0;i!=a;++i){
           str1+=str[i];
       }
       for(int i=a;i<=b;++i){
           str1+=p[i-a];
       }
       for(int i=b+1;i!=str.size();++i){
           str1+=str[i];
       }
    swap(str,str1);
    
}

int main(){
    
    string str;
    cin>>str;
    
    int n;
    cin>>n;
    while(n){
        string s;
        cin>>s;
        
        if(s=="replace"){
            int a,b;
            cin>>a>>b;
            string p;
            cin>>p;
            replace(str,a,b,p);
        }else if(s=="reverse"){
            int a,b;
            cin>>a>>b;
            reverse(str,a,b);
        }else if(s=="print"){
            int a,b;
            cin>>a>>b;
            Print(str,a,b);
        }
        
        
        
        --n;
        
    }
    

    
}



Measured memory_bytes: 3204
#include<stdio.h>
typedef long long int lli;
int main() {
  lli n,k;
  scanf("%ld %ld", &n, &k);
  lli arr[n];
  lli temp = 0;
  int flag=0;

  for(lli k=0;k<n;k++){
    scanf("%ld", &arr[k]);
  }
  lli ans=0;
  for(lli i=0;i<n-k;i++){
    if(arr[i]<arr[i+k]){
      printf("Yes\n");
    }
    else{
      printf("No\n");
    }
  }
}




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

int main (){
    
    int a,b,ab;
cin >> a >> b;
ab = a+b;
if(a%3 == 0|| b % 3 == 0 || ab % 3 == 0){
cout << "Possible" << endl;
}
else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n=0,ans;
  cin >>n;
  while(n!=-1){
    ans=0;
    if(n>30){
      ans+=(n-30)*160;
      n=30;
    }
    if(n>20){
      ans+=(n-20)*140;
      n=20;
    }
    if(n>10)
      ans+=(n-10)*125;
    cout <<4280-(ans+1150)<<endl;
    cin>> n;
  }
  return 0;
}



Measured memory_bytes: 3068
000010 IDENTIFICATION  DIVISION.
000020 PROGRAM-ID.     MAIN.
000030 ENVIRONMENT     DIVISION.
000040 DATA            DIVISION.
000050 WORKING-STORAGE  SECTION.
000060 01 R        PIC XXX.
000070 *      
000080 PROCEDURE DIVISION.
000090 *
000100 ACCEPT R.
000110 IF R(1:1) = R(3:1) THEN
000120 	DISPLAY "Yes"
000130 ELSE
000140 	DISPLAY "No"
000150 END-IF.
000160 STOP RUN.

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
struct rule{
  string a;
  string b;
  string c;
};
int main(){
  while(1){
    
    int n,m;
    cin >> n >> m;
    if(n==0&&m==0)break;
    rule r[1100];
    rule p[1100];
    vector<int> ok(m,0);
    for(int i=0;i<n;i++){
      cin >> r[i].a >>r[i].b >> r[i].c;
    }
    for(int i=0;i<m;i++){
      cin >> p[i].a >>p[i].b >> p[i].c;
    }
    int f=0;
    for(int i=0;i<n;i++){
      if(r[i].a[0]=='p'){
	f=1;
      }
      else f=0;
    
      //cout << f << endl;
      for(int j=0;j<m;j++){
	int fl=0;
	//cout << r[i].b << " "<<p[j].c<< endl;
	for(int k=0;k<r[i].b.size();k++){
	  if(r[i].b[k]!='?'&&r[i].b[k]!=p[j].a[k]){
	    fl=1;
	    break;
	  }
	  if(r[i].c[k]!='?'&&r[i].c[k]!=p[j].b[k]){
	    fl=1;
	    break;
	  }
	}
	if(fl==0){
	  ok[j]=f;
	}
      }
    }
    int co=0;
    for(int i=0;i<m;i++){
      if(ok[i]==1)co++;
      // cout << ok[i] << endl;
    }
    cout << co << endl;  
    for(int i=0;i<m;i++){
      if(ok[i]==1)cout <<p[i].a << " "<< p[i].b << " "<< p[i].c<< endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3416
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    int n;
    cin >> n;
    string s;
    cin >> s;

    vector<int> num_black(n, 0);
    if(s[0] == '#') num_black[0] = 1;

    rep1(i, n){
        if(s[i] == '#') num_black[i] = num_black[i-1] + 1;
        else num_black[i] = num_black[i-1];
    }

    int res = min(n-num_black[n-1], num_black[n-1]);
    rep1(i, n){
        res = min(res, n-i-(num_black[n-1]-num_black[i-1])+num_black[i-1]);
    }

    cout << res << endl;

    return 0;
}

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

int main(){
    int k,a,b;
    cin >> k >> a >> b;
    for(int i = a;i <= b;i++){
        if(i % k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define VFOR(i, s, n) for(int i = s; i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define PB push_back
#define MP make_pair
using ll = long long;
using Pii = pair<int, int>;
const int MOD = 1000000007;
const int INF = 1000000000;

vector<bool> visited;
//es[i][j].first = to, second = cost
vector<vector<int>> es;
vector<int> c;

void dfs(int cur){
    visited[cur] = true;
    REP(i, es[cur].size()){
        if(visited[es[cur][i]]) continue;
        c[es[cur][i]] += c[cur];
        dfs(es[cur][i]);
    }
}

int main(){
    int n, q; cin >> n >> q;
    visited.resize(n, false);
    es.resize(n);
    c.resize(n, 0);
    REP(i, n-1){
        int a, b; cin >> a >> b;
        --a; --b;
        es[a].PB(b); es[b].PB(a);
    }
    REP(i, q){
        int p, x; cin >> p >> x;
        c[p-1] += x;
    }
    dfs(0);
    REP(i, n){
        if(i) cout << " ";
        cout << c[i];
    }
    return 0;
}


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


int main(){
    int n;
    cin >> n;
    vector<int> s(n);
    int sum=0;
    for(int i=0; i<n; i++){
        cin >> s.at(i);
        sum += s.at(i);
        //cout << s.at(i) << endl;
    }
    //cout << s.at(0) << endl;
    vector<int> t(n);
    for(int tt=0; tt<n; tt++){
        int T=0;
        if(tt!=0){
            for(int i=0; i<tt; i++){
                T += s.at(i);

            }
            t.at(tt) = abs(sum - 2*T);
        }else{
            t.at(0) = abs(sum - 2*s.at(0));
        }
    }
    int min=10000;
    for(int i=0; i<n; i++){
        if(min > t.at(i)) min = t.at(i);
        //cout << t.at(i) << " ";
    }
    //cout << s.at(0) << endl;
    cout << min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

ll pcnt[55];
ll cnt[55];

ll calc(int N, ll X){
  if(N < 0 || X < 0) return 0;
  if(N == 0) return 1;
  if(X+1 == cnt[N]) return pcnt[N];
  ll middle = cnt[N]/2;

  if(middle <= X){
    return pcnt[N-1] + 1 + calc(N-1, X-middle-1);
  }else{
    return calc(N-1, X-1);
  }
}


int main(){
  int N;
  ll X;
  cin >> N >> X;

  pcnt[0] = 1;
  cnt[0] = 1;
  rep(i,50){
    pcnt[i+1] = 2*pcnt[i] + 1;
    cnt[i+1] = 2*cnt[i] + 3;
  }

  cout << calc(N, X-1) << 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))
//-------------------------------------------------------

int A,B,C,K;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A>>B>>C>>K;
	
	if(K<=A+B) {
		cout<<min(A,K)<<endl;
	}
	else {
		cout<<A-(K-(A+B))<<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: 3640
/**
 *    author:  zjsdut
 *    created: 2020/03/09 12:09:01
 **/
#include <bits/stdc++.h>

using namespace std;

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

template <typename A, typename B> bool chkmin(A &a, const B &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}

template <typename A, typename B> bool chkmax(A &a, const B &b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}

template <typename T> istream &operator>>(istream &stream, vector<T> &vec) {
  for (auto &x : vec)
    stream >> x;
  return stream;
}

void scan() {}

template <class T, class... Args> void scan(T &a, Args &... rest) {
  cin >> a;
  scan(rest...);
}

using ll = long long;
using vl = vector<ll>;
using vb = vector<bool>;
using vi = vector<int>;
using pii = pair<int, int>;
template <typename T> using vv = vector<vector<T>>;
#define rng(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define up(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define down(i, b, a) for (int i = int(b); i >= int(a); i--)
#define rep(n)                                                                 \
  for (int _iter_##n = 0, _num_##n = (int)n; _iter_##n < _num_##n; ++_iter_##n)
#define FOR(x, cont) for (const auto &x : cont)
#define For(x, cont) for (auto &x : cont)
#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ep emplace
#define SZ(x) (int)(x).size()
#define UNIQ(vec) (vec).erase(unique(all(vec)), end(vec))
#define LB(cont, x) int(lower_bound(all(cont), x) - begin(cont))
#define UB(cont, x) int(upper_bound(all(cont), x) - begin(cont))

template <typename T>
ostream &operator<<(ostream &stream, const vector<T> &vec) {
  if (!vec.empty()) {
    stream << vec[0];
    for (size_t i = 1; i != vec.size(); ++i)
      stream << ' ' << vec[i];
  }
  return stream;
}

template <typename T> void print(const vector<T> &t) { cout << t << '\n'; }

template <typename T> void print(const vector<vector<T>> &t) {
  for (const auto &row : t) {
    print(row);
  }
}

template <typename T> void print(const T &t) { cout << t << ' '; }

template <typename T, typename... Args>
void print(const T &t, const Args &... rest) {
  print(t);
  print(rest...);
}

template <typename T> void println(const T &t) { cout << t << '\n'; }

template <typename T, typename... Args>
void println(const T &t, const Args &... rest) {
  print(t);
  println(rest...);
}

int main() {
#if defined LOCAL
  ifstream in("in.txt");
  cin.rdbuf(in.rdbuf());
#endif
  int n, k;
  scan(n, k);
  vi h(n);
  scan(h);
  if (k >= n) {
    println(0);
    return 0;
  }
  sort(all(h));
  println(accumulate(h.begin(), h.begin() + n - k, 0ll));
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define fi first
#define se second
#define pr(x) cerr<<#x<<"="<<(x)<<endl
#define pri(x,lo) {cerr<<#x<<"={";for (int ol=0;ol<=lo;ol++)cerr<<x[ol]<<",";cerr<<"}"<<endl;}
#define inf 100000000
#define N 1000100
map<ll,ll> mp;
ll sum[N],ans,a[N],i,n;
int main()
{
	scanf("%lld",&n);
	mp[0]++;
	for (i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		sum[i]=sum[i-1]+a[i];
	}
	for (i=1;i<=n;i++)
	{
		ans+=mp[sum[i]];
		mp[sum[i]]++;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 18432
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int d[MAXn];
int main(){
  IOS();
  int n,x;
  cin>>n>>x;
  REP(i,n) cin>>d[i];
  sort(d,d+n);
  int ans = 0;
  REP(i,n-1){
    if( x <= 0 ) break;
    if( x < d[i] ) break;
    x -= d[i];
    ans++;
  }
  if( x == d[n-1] ) ans++;
  cout<<ans<<endl;
}


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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(abs(b-a)<=d && abs(c-b)<=d){
    cout << "Yes";
  }
  else if(a==c){
    cout << "Yes";
  }
  else if(abs(a-c)<=d){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int p[110000];
long long gcd(long long a,long long b){
	while(a){
		b%=a;swap(a,b);
	}return b;
}
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	std::sort(p,p+a);
	long long ret=p[0]%mod;
	for(int i=1;i<a;i++){
		ret=ret*gcd(i,p[i])%mod;
	}
	printf("%lld\n",ret);
}

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

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll ar[M],br[M];

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

	ll i,a,b,m,mn1 = 1e18,mn2 = 1e18,ans,x,y,c;

	cin >> a >> b >> m;

	for(i=1;i<=a;++i)
	{
		cin >> ar[i];
		mn1 = min(ar[i],mn1);
	}
	for(i=1;i<=b;++i)
	{
		cin >> br[i];
		mn2 = min(br[i],mn2);
	}
	ans = mn1+mn2;
	for(i=1;i<=m;++i)
	{
		cin >> x >> y >> c;
		ans = min(ans,ar[x]+br[y]-c);
	}

	ans = max(ans,0ll);

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

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

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

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  int a,b,c; cin>>a>>b>>c;
  cout<<c<<" "<<a<<" "<<b<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    std::size_t n;
    std::cin >> n;

    std::size_t r = 0;
    std::size_t b = 0;

    for (std::size_t i = 0; i != n; ++i) {
        char c;
        std::cin >> c;
        if (c == 'R') {
            ++r;
        }
        else if (c == 'B') {
            ++b;
        }
    }
    if (r > b) {
        std::cout << "Yes" << std::endl;
    }
    else {
        std::cout << "No" << std::endl;
    }
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

max = max(a,b,c,d,e)
min = min(a,b,c,d,e)

if k < max-min:
    print(":(")
else:
    print("Yay!")


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

struct Node {
    Node* prev;
    Node* next;
    long long value;
};

Node* nil;

void init() {
    nil = (Node*) malloc(sizeof(Node));
    nil->prev = nil;
    nil->next = nil;
}

void insertNode (long long value) {
    Node* n = (Node*) malloc(sizeof(Node));
    n->value = value;

    n->next = nil->next;
    nil->next->prev = n;
    nil->next = n;
    n->prev = nil;

}

Node* findNode(long long  value) {
    Node* cur = nil->next;
    while (cur != nil) {
        if (cur->value == value) return cur;
        cur = cur->next;
    }
    return NULL;
}

void deleteNode (Node* n) {
    if (n == NULL) return;
    n->next->prev = n->prev;
    n->prev->next = n->next;
    free(n);
    n = NULL;
}

void deleteFirst() {
    deleteNode(nil->next);
}
void deleteLast() {
    deleteNode(nil->prev);
}

void printList() {
    Node* cur = nil->next;
    while (cur != nil) {
        if (cur->prev != nil) printf(" ");
        printf("%lld", cur->value);
        cur = cur->next;
    }
    printf("\n");
}

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

    init();

    for (int i = 0; i < N; ++i) {
        char c[100];
        long long value;
        scanf("%s", c);
        std::string str = c;
        if (str == "insert") {
            scanf("%lld", &value);
            insertNode(value);
        }
        else if (str == "delete") {
            scanf("%lld", &value);
            deleteNode(findNode(value));
        }
        else if (str == "deleteFirst") {
            deleteFirst();
        }
        else if (str == "deleteLast") {
            deleteLast();
        }
    }

    printList();

    return 0;
}

Measured memory_bytes: 34000
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 19 20:52:57 2020

@author: over-
"""

K,N=map(int,input().split())
A=input().split()
A=[int(i) for i in A]

L=[]
for i in range(1,N):
    L.append(A[i]-A[i-1])

L.append(A[0]+K-A[-1])
M=max(L)
ans=K-M
#print(A)
print(ans)

Measured memory_bytes: 26420
#include<stdio.h>

int shori(int,int);
int data[101][101], suuji[101];

int main(){

  int i, j, n;

  scanf("%d",&n);
  
  for(i = 0; i < n; i++)
    {
      if(i != 0)data[i][i] = 0;
      scanf("%d%d",&suuji[i],&suuji[i+1]);
    }

  for(j = 1; j <= n; j++)
    {
      for(i = 1; i <= n - j; i++)
	{
	  data[i][i+j] = shori(i,i+j);
	}
    }
  printf("%d\n",data[1][n]);

  return 0;
}

int shori(int x, int y)
{
  int i, min = 0, temp;
  for(i = x; i < y; i++)
    {
      temp = data[x][i] + data[i + 1][y] + (suuji[x - 1] * suuji[i] * suuji[y]);
      if(i == x || temp < min)min = temp;
    }
  return min;
}



Measured memory_bytes: 2112
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N = 6;
  int ans = 0;

  for (int i = 0; i < N; i++) {
    int x;
    scanf("%1d", &x);
    ans += x;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3772
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			int[] a = new int[n+2];
			for(int i=1;i<=n;i++) a[i] = sc.nextInt();
			a[0] = 4;
			a[n+1] = 5;
			
			int max = 0;
			for(int i=1;i<=n;i++){
				for(int j=1;j<=3;j++){
					if(a[i]!=j){
						int p = i+1;
						int q = i-1;
						int r = j;
						int sum = 0;
						while(true){
							while(a[p]==r) p++;
							while(a[q]==r) q--;
							if(p-q-1-sum<4){
								max = Math.max(max, sum);
								break;
							}
							sum = p-q-1;
							
							if(a[p]!=a[q]){
								max = Math.max(max, sum);
								break;
							}
							r = a[p];
						}
					}
				}
			}
			System.out.println(n-max);
		}
	}

}

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

using namespace std;

#define PI 3.1415926535897932

//typedef long long ll;


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

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 **/


int main(){
    int mod=1000000007;
    int d,n;
    scanf("%d %d",&d,&n);
    if (n==100) n++;
    if (d==0) {
        printf("%d\n",n);
    } else if (d==1) {
        printf("%d\n",n*100);
    } else {
        printf("%d\n",n*10000);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int n, a[100009];
ll m, ans, sum[100009];
ll solve(ll x)
{
    ll cnt=0;
    ans=0;
    for(int i=1; i<=n; i++)
    {
        int id=lower_bound(a+1,a+n+1,x-a[i])-a;
        cnt+=n-id+1;
        if(id<=n)
            ans+=(sum[n]-sum[id-1])+1LL*(n-id+1)*a[i];
    }
    return cnt;
}
int main()
{
    IO
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=1; i<=n; i++)
        sum[i]=sum[i-1]+a[i];
    ll low=1, high=a[n]*2+1;
    while(low<high)
    {
        ll mid=(low+high)/2;
        if(solve(mid)>=m)
            low=mid+1;
        else
            high=mid;
    }
    solve(low);
    cout<<ans+(m-solve(low))*(low-1);
}


Measured memory_bytes: 1408
// cardgame.cpp
#include <iostream>
using namespace std;

int main(){
	for(;;){
		int n=0;	// nを0でリセット
		int i,j;
		int a[10000], b[10000];
		int a_point=0, b_point=0;
		cin >> n;	// nを取得
		if(n==0)
			break;;
		for(i=0;i<n;++i){	// カードを配る
				cin >> a[i];
				cin >> b[i];
		}
		for(j=0;j<n;++j){
			if(a[j]>b[j])
				a_point+=(a[j]+b[j]);
	        else if(a[j]<b[j])
				b_point+=(a[j]+b[j]);
			else if(a[j]==b[j]){
				a_point+=a[j];
				b_point+=b[j];
			}
		}
		cout << a_point << " " << b_point << endl;
	}
	return 0;	
}

Measured memory_bytes: 1236
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt(),
			c = sc.nextInt(), d = sc.nextInt();
		System.out.println( (l - Math.max((a+c-1)/c, (b+d-1)/d)) );
	}
}

Measured memory_bytes: 17160
#整数の入力
N = int(input())

#スペース区切りの整数の入力リスト
X_list = list(map(int, input().split()))

ans_list = []



for i in range(100):
  ans = 0
  for j in range(N):
    ans += (X_list[j]-(i+1))**2
  ans_list.append(ans)
print(min(ans_list))

Measured memory_bytes: 3060
import collections
s=int(input())
count=[]
count.append(s)
def is_even(num):
	return num % 2 == 0
def calc(a):
	if is_even(int(a)):
		return (int((a)/2))
	else:
		return (int((a)*3+1))

check=(s) not in [1,2,4]
while (s) not in [1,2,4]:
	calc(s)
	s=calc(s)
	count.append(s)
	continue
else:
	print (len(count)+3)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mat vector<vector<int>>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll


auto max(auto a){auto ans=a[0];for(auto i:a)if(i>ans)ans=i;return ans;}
auto min(auto a){auto ans=a[0];for(auto i:a)if(i<ans)ans=i;return ans;}
void print(auto a){for(auto i:a)cerr<<i<<' ';cerr<<'\n';}



signed main()
{
	fio
	inp(n)
	inpa(a,n)
	int ans=0;
	fo(i,n)
	{
		for(int j=i+1;j<n;j++)
			ans+=a[i]*a[j];
	}
	cout<<ans<<'\n';
	printclock;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc067/tasks/arc078_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

enum { BLACK, WHITE };
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> G[n];
    REP(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    queue<int> qu;
    vector<int> color(n, INF);
    vector<int> cnt(2, 0);
    color[0] = BLACK;
    color[n - 1] = WHITE;
    qu.push(0);
    qu.push(n - 1);
    while (!qu.empty()) {
        int pos = qu.front();
        qu.pop();
        int co = color[pos];
        for (auto x : G[pos]) {
            if (color[x] == INF) {
                color[x] = co;
                qu.push(x);
                cnt[co]++;
            }
        }
    }
    if (cnt[BLACK] > cnt[WHITE]) {
        cout << "Fennec" << endl;
    } else {
        cout << "Snuke" << endl;
    }
    // for (auto x : color) {
    //     cout << x << " ";
    // }

    return 0;
}


Measured memory_bytes: 6144
#include <stdio.h>

int main() {
  int n, x;
  int i, j, k;
  int cnt;
  
  while (1) {
    scanf("%d%d", &n, &x);
    if (n==0 && x==0) break;
    cnt=0;
    for (i = 1; i <= n; i++)
      for (j = i+1; j <= n; j++)
	for (k = j+1; k <= n; k++)
	  if (i+j+k == x) cnt++;
    
    printf("%d\n", cnt);
  }
  

  return 0;
}


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

int main() {
	
	int n; cin >> n;
	int tmp = 0;
	bool ok = false;
	for (int i = 0; i < n; i++) {
		int a, b; cin >> a >> b;
		if (a == b) {
			tmp++;
		}
		else {
			tmp = 0;
		}
		if (tmp == 3) {
			ok = true;
		}
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3628
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

ll modinv(ll num){ // pow(num, mod-2)%mod
  ll ret=1LL;
  ll power=MOD-2;
  while(power>0LL){
    if(power&1)ret=(ret*num)%MOD;
    num=(num*num)%MOD;
    power>>=1;
  }
  return ret;
}

ll comb(ll n, ll m){
  ll ans=1LL;
  for(ll i=1LL;i<=m;i++){
    ans*=n-m+i;
    ans%=MOD;
    ans*=modinv(i);
    ans%=MOD;
  }
  return ans;
}

int main(){
  int x, y;cin>>x>>y;
  if((x+y)%3==0){
    int s = y-(x+y)/3;
    int t = x-(x+y)/3;
    if(s<0 || t<0){cout<<0<<endl;return 0;}
    cout<<comb(ll(s+t), ll(min(s, t)))<<endl;
  }else{
    cout<<0<<endl;
  }
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll X;
  cin>>X;
  ll A, B;
  for(ll i=-3000;i<3000;++i) {
    for(ll j=-3000;j<3000;++j) {
      if(X==i*i*i*i*i-j*j*j*j*j) {
        A = i;
        B = j;
      }
    }
  }
  cout<<A<<" "<<B<<endl;
}



Measured memory_bytes: 3608
import math
import copy

def ord(N,n):#N,nは正の整数、Nで割り切れる回数、許容はN^1000
    if n%N!=0:
        return 0
    else:
        return 1+ord(N,n//N)

def primenubertable(N):#素数表　１００００ぐらいまでは時間内に計算できそう
    import math
    X=[1]*N
    X[0]=0
    X[1]=0
    i=2
    P=[]
    while math.sqrt(N)>=i:
        if X[i]==1:
            for j in range(i+1,N):
                if j%i==0:
                    X[j]=0
        i=i+1
    for i in range(0,N):
        if X[i]==1:
            P.append(i)
    return P

def factor(n):
    if n==0 or n==1:
        return 1
    else:
        return n*factor(n-1)

A=int(input())

N=factor(A)
P=primenubertable(100)
order=[]

for i in range(0,len(P)):
    x=ord(P[i],N)
    order.append(x)
a=0
b=0
c=0
d=0
e=0
for i in range(0,len(order)):
    if order[i]>=2:
        a=a+1
    if order[i]>=4:
        b=b+1
    if order[i]>=14:
        c=c+1
    if order[i]>=24:
        d=d+1
    if order[i]>=74:
        e=e+1
D=b*(b-1)//2
answer=D*(a-2)+c*(b-1)+d*(a-1)+e
print(answer)


Measured memory_bytes: 3572
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    ($arg:expr) => (println!("{:?}",$arg));
}


#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}



fn main() {


  input! { 
         n: i32, 
         m: i32,
         switch: [[i32]; m],
         state: [i32; m]
    }

    let mut zenken2 :Vec<Vec<i32>> = Vec::new();
    fn rec(pos :i32, s : &mut Vec<i32>,n:i32,zenken:&mut Vec<Vec<i32>>){
        if pos >= n as i32 {
            zenken.push(s.to_vec());
            return;
        }
        for i in 0..2 {
            s.push(i);
            let pos2 = pos + 1;
            rec(pos2, s, n, zenken);
            s.pop();
        }
    }
    
    rec(0,&mut Vec::new(),n,&mut zenken2);
    //mydbg!(zenken2.len());
    
    let mut result = 0;
    'start : for item in zenken2{
        for (index,p) in state.iter().enumerate(){
            let sw = &switch[index as usize];
            let mut sum = 0;
            for i in 0..sw.len(){
                let switch_no = sw[i]-1;
                sum += item[switch_no as usize];
            }  
            if sum % 2 != *p{
                continue 'start;
            }
        }
        //mydbg!(result);
        result += 1;
    }

   
   
   println!("{}",result);


}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		int sH = in.nextInt();
		int sM = in.nextInt();
		int eH = in.nextInt();
		int eM = in.nextInt();
		int stM = in.nextInt();

		int diffHr = eH - sH;
		int diffM = eM - sM;
		System.out.print(((diffHr * 60) + diffM - stM));

		in.close();
	}

}


Measured memory_bytes: 35840
#include<stdio.h>
int main()
{
	int r,c;
	int i,j;
	int sheet[101][101] = {0};
	

	scanf("%d %d",&r,&c);
	
	for(i = 0;i < r;i++){
		for(j = 0;j < c;j++){		
			scanf("%d",&sheet[i][j]);
			sheet[i][c] += sheet[i][j];
			sheet[r][j] += sheet[i][j];
			sheet[r][c] += sheet[i][j];
		}
	}
	
	
	for(i = 0;i <= r;i++){
		for(j = 0;j < c;j++)
			printf("%d ",sheet[i][j]);
			printf("%d\n",sheet[i][j]);
		
	}
	
	
return 0;
}


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 100005;

int n;

int main() {

	FAST;

	cin >> n;
	cout << ((n < 1200) ? "ABC\n" : "ARC\n");
	return 0;	
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=1000000007LL;
const ll MOD=998244353LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};

const ll MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
    COMinit();
    vl vec(500000);
    vec[0]=1;
    
    ll n,m,k;cin>>n>>m>>k;
    rep(i,300000)vec[i+1]=vec[i]*(m-1)%MOD;
    ll ans=0;
    rep(i,k+1){
        ll d=COM(n-1,i)*m%MOD;
        d*=vec[n-1-i];
        d%=MOD;
        ans+=d;
        ans%=MOD;
        //cout<<d<<" ";
    }
    
    //cout<<endl;
    //cout<<vec[n-1]<<COM(n-1,0)
    cout<<ans<<endl;
}

    

Measured memory_bytes: 18920
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REP(i, n) for(ll i = 1; i < (ll)(n); i++)
#define P pair<ll, ll>
typedef long long ll;
const ll mod = 1e9+7;

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

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(int x, int y){
  if(x % y == 1) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(int x, int y){
  return x * y / gcd(x, y);
}
// n個の最大公約数
ll ngcd(vector<int> a){
  int res;
  res = a[0];
  for(int i=1; i<a.size() && res!=1; i++){
    res = gcd(res, a[i]);
  }
  return res;
}
// n個の最小公倍数
ll nlcm(vector<int> a){
  int res;
  res = a[0];
  REP(i, a.size()){
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(int x){
  int i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
int digsum(int x){
  int res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  double n, t, a;
  cin >> n >> t >> a;
  map<double, int> mp;
  double ans = 1001001001;
  rep(i,n) {
    double h;
    cin >> h;
    double tem = abs(a - (t - (h / 1000 * 6)));
    mp[tem] = i+1;
    ans = min(ans, tem);
  }
  cout << mp[ans] << endl;
}






Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int extractMax(int []);
void insert(int [], int);
void increaseKey(int [], int, int);
void maxHeapify(int [], int);
int parent(int);
int left(int);
int right(int);

int A[1000000], H = 0;

int main(){
  char s[10];
  int k;

  while(1){
    scanf("%s", s);
    
    if(s[0] == 'e' && s[1] == 'n') break;
    else if(s[0] == 'e') printf("%d\n", extractMax(A));
    else if(s[0] == 'i'){
      scanf("%d", &k);
      insert(A, k);
    }
  }
  
  return 0;
}

int extractMax(int A[]){
  int max;
  
  if(H < 1) exit(1);
  
  max = A[1];
  A[1] = A[H];
  H--;
  maxHeapify(A, 1);
  return max;
}

void insert(int A[], int key){
  H++;
  A[H] = INT_MIN;
  increaseKey(A, H, key);
}

void increaseKey(int A[], int i, int key){
  int temp;
  
  if(key < A[i]) exit(1);
  A[i] = key;
  while(i > 1 && A[parent(i)] < A[i]){
    temp = A[i];
    A[i] = A[parent(i)];
    A[parent(i)] = temp;
    i = parent(i);
  }
}

void maxHeapify(int A[], int i){
  int l = left(i);
  int r = right(i);
  int large, temp;

  if(l <= H && A[l] > A[i]) large = l;
  else large = i;

  if(r <= H && A[r] > A[large]) large = r;

  if(large != i){
    temp = A[i];
    A[i] = A[large];
    A[large] = temp;
    maxHeapify(A, large);
  }
}

int parent(int i){ return i/2; }

int left(int i){ return i*2; }

int right(int i){ return i*2+1; }

Measured memory_bytes: 4504
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;


void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y == NIL){
    root=z;
  }else{
    if(z->key < y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }
}

void inorder(Node u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u ==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
  
      if ( com[0] == 'i' ){
	scanf("%d", &x);
	insert(x);
      } else if ( com[0] == 'p' ){
	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
      }
    }
  

    return 0;
}

Measured memory_bytes: 24040
def main():
    N = input()
    len_N = len(N)
    K = int(input())
    dp = [[[0] * 2 for _ in range(K + 5)] for _ in range(len_N + 5)]
    dp[0][0][0] = 1
    for i in range(len_N):
        tmp = int(N[i])
        for j in range(K+1):
            # l : 1 => N より小さいことが確定 
            for l in range(2):
                for x in range(10):
                    if l == 0:
                        if x > tmp:
                            continue
                        elif x == tmp:
                            if x == 0:
                                dp[i+1][j][0] += dp[i][j][0]
                            else:
                                dp[i+1][j+1][0] += dp[i][j][0]
                        else:
                            if x == 0:
                                dp[i+1][j][1] += dp[i][j][0]
                            else:
                                dp[i+1][j+1][1] += dp[i][j][0]
                    if l == 1:
                        if x == 0:
                            dp[i+1][j][1] += dp[i][j][1]
                        else:
                            dp[i+1][j+1][1] += dp[i][j][1]
    
    print(dp[len_N][K][0] + dp[len_N][K][1])


        




if __name__ == "__main__":
    main()

Measured memory_bytes: 40176
package main

import (
	"fmt"
)

func main() {
	var n int
	max := 0
	fmt.Scan(&n)
	l := make([]int, n)
	for i:=0; i<n; i++ {
		var nn int
		fmt.Scan(&nn)
		if max < nn {
			max = nn
		}
		l[i] = nn
	}

	sum := 0
	cnt := 0
	for i:=0; i<n; i++ {
		if l[i] == max && cnt == 0 {
			cnt++
			continue
		}
		sum += l[i]
	}

	if max < sum {
		fmt.Print("Yes")
	} else {
		fmt.Print("No")
	}

}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
    int x,y,p,m,a;
    cin >>x>>y;
    p=x+y;
    m=x-y;
    a=x*y;
    if ((p>=m&&p>=a)||(p==m||p==a))
        cout<<p<<endl;
    else if(m>=p&&m>=a)
        cout<<m<<endl;
    else if(a>=p&&a>=m)
        cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
q=[0]*(n+1)
q[0]=1
p=0
for i in a:
    if q[i-1]>0:
        q[i]=q[i-1]
        p=max(p,i)
print(-1 if p==0 else n-p)

Measured memory_bytes: 26268
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[100000],b[100000];
  int ans=0;
  rep(i,n) cin>>a[i]>>b[i];
  repn(i,n-1){
    if((ans+a[i])%b[i]){
      ans+=b[i]-(ans+a[i])%b[i];
    }
  }
  cout<<ans<<endl;
    
  return 0;
}


Measured memory_bytes: 1792
l1 = [1,3,5,7,8,10,12]
l2 = [4,6,9,11]
l3 = [2]

x, y = map(int, input().split())
if x in l1 and y in l1:
    print("Yes")
elif x in l2 and y in l2:
    print("Yes")
elif x in l3 and y in l3:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064