akhauriyash/Code-Regression huggingface dataset:
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.12.28 20:13:56
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */

// ===================### char →　int ###=================== //
int ctoi(char c) {
    int ret = c - '0';
    if (0 <= ret && ret < 10) {
        return ret;
    } else {
        return -1;
    }
}

int main() {
    string s;
    cin >> s;
    int sl = s.size();

    int mi = 1000;
    rep(i, sl - 2) {
        int x1, x2, x3, x;
        x1 = ctoi(s[i]);
        x2 = ctoi(s[i + 1]);
        x3 = ctoi(s[i + 2]);
        x = x1 * 100 + x2 * 10 + x3;

        mi = min(mi, abs(x - 753));
    }

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

    /* --------------------------------- */
    return 0;
}

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

int main(void)
{
    long long N;
    cin >> N;
    vector<long long> a(N);
    for (long long i = 0; i < N; i++)
    {
        cin >> a[i];
    }

    sort(a.begin(), a.end(), greater<long long>());
    long long ans = 0;
    for (long long i = 2; i < N+1; i++)
    {
        if (i == 2)
        {
            ans += a[0];
        }
        else
        {
            ans += a[(i-1) / 2];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4832
/// You just can't beat the person who never gives up
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 1e5+5 ;
const long long mx = 1e18 ;

long long n ;
map<long long,int> cnt ;
int main(){
    cin >> n ;
    for(long long i=2;i*i<=n;++i){
        while(n%i==0){
            ++cnt[i];
            n/=i;
        }
    }
    if(n>1) ++cnt[n] ;
    long long ans = 0 ;
    for(auto go:cnt){
        int x = go.second ;
        int cur = 1 ;
        while(x>=cur){
            ++ans ;
            x -= cur++ ;
        }
    }
    cout << ans ;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main(void){
    int n,m,i,j;
    int a[100][100],b[100],c[100];
    cin >> n >> m;
    
    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    for(i = 0; i < m; i++){
        cin >> b[i];
    }
    for(i = 0; i < n; i ++){
        for(j = 0; j < m; j++){
            c[i] += a[i][j] * b[j];
        }
    }
    for(i = 0; i < n; i++){
        cout << c[i] << endl;
    }
}


Measured memory_bytes: 3116
#include <iostream>
#include <cmath>

int n;
int k;
int dp[100200];
int h[100001];

int main() {
	std::cin >> n >> k;
	for (int i = 0; i < n; i++) {
		dp[i] = 2000000000;
		std::cin >> h[i];
	}
	dp[0] = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = 1; j <= k; j++) {
			if (dp[i] + abs(h[i + j] - h[i]) < dp[i + j]) {
				dp[i + j] = dp[i] + abs(h[i + j] - h[i]);
			}
		}
	}
	std::cout << dp[n - 1] << std::endl;
}


Measured memory_bytes: 4276
#include <iostream>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <map>
#include <string.h>
#include <algorithm>

using namespace std;

class Border {
    public:
        int h;
        int p;
        int q;
};

int main(int argc, char const* argv[])
{
    int n,m,a;
    //縦線の本数，横線の本数，調べる縦線の番号
    int now_h=0;
    while (cin >> n >> m >> a) 
    {
        int ret = a;
        if (n == 0 && m == 0 && a == 0) {break;}
        vector<Border> b(m);

        //横線の取得
        for (int i = 0; i < m; i++) 
        {
            cin >> b[i].h;
            cin >> b[i].p;
            cin >> b[i].q;
        }
        

        //now_hの取得
        for (int i = 0; i <m ; i++) 
        {
            now_h = max(b[i].h, now_h);
        }

            //
            //cout << "now_h" << now_h << endl;
            //cout << "m" << m<< endl;
        //一番したまで降りる
        while (now_h >= 0) 
        {
            //
            //cout << "now_h" << now_h << endl;
            //
            //int test;
            //cin >> test;
            //適合する横棒を探す
            for (int i = 0; i < m; i++) 
            {
                //適合する横棒が存在したら、移動して下に降りる
                if (b[i].h == now_h ) 
                {
                    if (b[i].p == ret ) 
                    {
                        ret = b[i].q;
                        break;
                    }
                    else if (b[i].q == ret ) 
                    {
                        ret = b[i].p;
                        break;
                    }
                }
                //適合する横棒が存在しなかったら,移動せずに下に降りる
                else 
                {
                    continue;
                }
            }
            now_h--;
        }
        cout << ret << endl;
    }
    return 0;
}

Measured memory_bytes: 1204
n = int(input())
b = [int(i) for i in input().split()]
a = [None]*n


if n == 2:
  print(b[0]*2)
  
else:
  a[0] = b[0]

  for i in range(1, n-1):
    if b[i-1] >= b[i]:
      a[i] = b[i]

    else:
      a[i] = b[i-1]

  a[-1] = b[-1]
  print(sum(a))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define IO {ios_base::sync_with_stdio(false); cin.tie(0);}
#define ll  long long
#define pi pair<ll,ll>
ll val[3003][3003], dp[3003][3003][5],dpmx[3003][3003];

string s;
int main()
{
    IO;
    ll i, j, k, cnt=0, n, m, mod=1e9, t, mx=0, mn=LLONG_MAX, l, h, r=0, w=0, ovr=0, x, d;
    // cin>>t;
        //while(t--){
            cin>>n>>m>>k;
            for(i=1; i<=k; i++){
                cin>>j>>l>>d; val[j][l]=d;
            }
            for(i=n; i>0; i--){
                for(j=m; j>0; j--){
                    if(!val[i][j]){
                        dp[i][j][0]=max(dpmx[i+1][j],dp[i][j+1][0]);
                        dp[i][j][1]=dp[i][j+1][1];
                        dp[i][j][2]=dp[i][j+1][2];
                        dp[i][j][3]=dp[i][j+1][3];
                    }
                    else{
                        dp[i][j][0]=max(dpmx[i+1][j],dp[i][j+1][0]);
                        dp[i][j][1]=max(dpmx[i+1][j]+val[i][j],max(dp[i][j+1][1], dp[i][j+1][0]+val[i][j]));
                        dp[i][j][2]=max(dp[i][j+1][2], dp[i][j+1][1]+val[i][j]);
                        dp[i][j][3]=max(dp[i][j+1][3], dp[i][j+1][2]+val[i][j]);
                    }
                    dpmx[i][j]=max(max(dp[i][j][0],dp[i][j][1]),max(dp[i][j][2],dp[i][j][3]));
                }
            }
            cout<<dpmx[1][1]<<endl;
        //}
    return 0;
}


Measured memory_bytes: 496116
#include <bits/stdc++.h>
using namespace std;
int a[100];
int main(int argc, const char * argv[])
{
    int m,n,sum=0;
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    sort(a,a+n);
    reverse(a,a+n);
    if(a[m-1]*4*m<sum)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int k = sc.nextInt();
        long a[] = new long[k];
        for (int i = 0; i < k; i++) {
            a[k - i - 1] = sc.nextInt();
        }

        if (a[0] != 2) {
            System.out.println(-1);
            return;
        }

        long min = 2;
        long max = 2;
        for (int i = 0; i < k - 1; i++) {
            min = a[i + 1] * ((min + a[i + 1] - 1) / a[i + 1]);
            max = a[i + 1] * ((max + a[i] - 1) / a[i + 1]);

            long minA = a[i + 1] * ((min + a[i + 1] - 1) / a[i + 1]);
            if (minA > max) {
                System.out.println(-1);
                return;
            }
        }
        max += a[k - 1] - 1;

        System.out.println(min + " " + max);
    }

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


Measured memory_bytes: 59748
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > using vec = std::vector< T >;
template < class T > void print(T &x) { cout << x << "\n"; }
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;


  bool canBuy = false;
  for (int j=0;j<=N;j+=7){
    if ((N-j)%4==0){
      canBuy=true;
      break;
    }
  }
  cout <<(canBuy?"Yes":"No")<<"\n";

  // print();
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		String str = stdIn.next();
		StringBuilder sb = new StringBuilder();
		
		for(int i = 0; i < str.length(); i++){
			char x = str.charAt(i);
			if( x == 'A' || x == 'B' || x == 'C' ){
				sb.append((char)(x+23));
			} else {
				sb.append((char)(x-3));
			}
		}
		System.out.println(sb.toString());
	}
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 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;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    int n;
    cin >> n;
    int a[2*n];
    REP(i,2*n){
        cin >> a[i];
    }
    sort(a,a+2*n);
    int ans = 0;
    for(int i=0;i<2*n;i+=2){
        ans += a[i];
    }
    COUT(ans);
    return 0;
} 

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

int main(){
  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h){
    cin >> s[i];
  }
  vector<vector<int>> cnt(h,vector<int>(w));
  rep(i,h){
    vector<int> done(w);
    rep(j,w){
      if(s[i][j]=='#')continue;
      if(done[j])continue;
      int l = 0;
      while(j+l<w){
        if(s[i][j+l]=='#')break;
        l++;
      }
      rep(k,l){
        done[j+k] = 1;
        cnt[i][j+k] += l;
      }
    }
  }
  rep(i,w){
    vector<int> done(h);
    rep(j,h){
      if(s[j][i]=='#')continue;
      if(done[j])continue;
      int l = 0;
      while(j+l<h){
        if(s[j+l][i]=='#')break;
        l++;
      }
      rep(k,l){
        done[j+k] = 1;
        cnt[j+k][i] += l;
      }
    }
  }
  int ans = 0;
  rep(i,h){
    rep(j,w){
      ans = max(ans,cnt[i][j]);
    }
  }
  ans = ans - 1;
  cout << ans << endl;
}

Measured memory_bytes: 20096
#include <iostream>

using namespace std;

int main()
{
    int n, k;
    int ans = 1;
    cin >> n >> k;
    while(n--)
    {
        if(ans < k)
        {
            ans *= 2;
        }
        else
        {
            ans += k;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
int main(){
    int n;
    cin >> n;
    vector <int> d(n);
    for (size_t i = 0; i < n; i++){
        cin >> d[i];
    }

    sort(d.begin(), d.end());
    d.erase(unique(d.begin(), d.end()), d.end());
    cout << d.size() << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const int mod=1e9+7;
const vi emp;
const int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int n,x;
vi a;

int main(){
	cin>>n>>x;
	ll sum=0;
	a=vi(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	ll ans=sum;
	vvi dp(n,vi(n));
	dp[0]=a;
	for(int i=1;i<n;i++){
		ll res=(ll)i*x;
		for(int j=0;j<n;j++){
			res+=dp[i][j]=min(dp[i-1][j],a[(j-i+n)%n]);
		}
		ans=min(ans,res);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 16128
#include <iostream>

using namespace std;

int main()
{
	int N;
	int temp;

	cin >> N;

	int i, j;

	int res = 0;
	bool flg;
	int max = 0;

	for (i = 0; i < N; i++)
	{
		cin >> temp;
		if (temp >= max)
		{
			res++;
			max = temp;
		}
	}

	printf("%d", res);
	 
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>


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

  int S_NUM[26];
  for(int i = 0; i < 26; i++) {
    S_NUM[i] = 0;
  }

  char S[100000];
  scanf("%s", S);
  for(int i = 0; i < N; i++) {
    S_NUM[S[i] - 'a']++;
  }

  uint64_t SUM = 1;
  for(int i = 0; i < 26; i++) {
    SUM = SUM * (S_NUM[i] + 1) % (1000000000+7);
  }
  SUM--;
  printf("%ld\n", SUM);

  return 0;
}


Measured memory_bytes: 256
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
//Using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> Ordered_set;

#define ll              long long
#define int             long long
#define ld             long double
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<vi>
#define vip            vector<pii>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define lb(x)           (x&(-x))
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define itr(it,v)          for(auto it:v)
#define show(arr,n)     for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fir(i,k,n)       for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ff               first 
#define ss               second
#define deb(x) cout << #x << "=" << x << endl
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define check(x) (x && cout<<"Yes\n")||(cout<<"No\n");
#define fin(s)          freopen(s,"r",stdin);  
#define fout(s)         freopen(s,"w",stdout);

const ld pi = 3.141592653589793238462643383279502884;
const int xd[]={-1,0,1,0};
const int yd[]={0,-1,0,1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0,  1, -1, 1, -1, 0, 1 };

int expo(int a,int b,int m);
int mmi(int a,int m);
void ipgraph(int m);

const int N=5*(1e5)+10;
vii adj(N);
int a[N];

void  solve(){

}
int32_t main()
{
    FIO
    int n; cin>>n;
    mii m;
    set<int> s;
    fi(i,n) {
        cin>>a[i];
        m[a[i]]++;
        s.insert(a[i]);
    }
    vi v;
    itr(it,s) v.pb(it);
    int ans=0;
    sort(all(v));
    fi(j,v.size()){
        for(int i=2*v[j];i<=v[v.size()-1];i+=v[j]){
            if(m.find(i)!=m.end()) m[i]=0;
        }
    }
    itr(it,m) {
        if(it.second<=1)
        ans+=it.second;
    }
    cout<<ans<<"\n";
    return 0;

}
void ipgraph(int m){
    int i, u, v;
    while(m--){
          cin>>u>>v;
         u--, v--;
    adj[u].pb(v);
    adj[v].pb(u);
    }
}
int expo(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return a;
    int val=(expo(a,b/2,m)*expo(a,b/2,m))%m;
    if(b & 1) return (val*a)%m;
    else return val;
}
int mmi(int a,int m){
    return expo(a,m-2,m);
}

Measured memory_bytes: 40484
def examA():
    Alpha = [chr(i) for i in range(97, 97+26)]
    S = SI(); N = len(S)
    ans = -1
    for i in range(N):
        for s in Alpha:
            cur = [s for s in S]
            for l in range(i):
                for k in range(N-1):
                    if cur[k+1]==s:
                        cur[k]=s
 #           print(cur)
            if len(Counter(cur[:N-i]))==1:
                ans = i
                break
        if ans>=0:
            break
    print(ans)
    return

def examB():
    N = I()
    A = LI()
    d = defaultdict(int)
    for a in A:
        d[a] +=1
    l = min(d); r = max(d)
    ans = "Yes"
    if l>=N:
        ans = "No"
    if r-l>1:
        ans = "No"
    if d[l]>l:
        ans = "No"
    if (r-d[l])*2+d[l]>N:
        ans = "No"
    if r==l and (N-l==1 or N//2>=l):
        ans = "Yes"
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examB()


Measured memory_bytes: 61488
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<complex>
#include<unordered_map>
#define deg(x) cout<<#x<<"="<<x<<endl;
#define fd(x) for(int i=0;i<x;i++)
#define fdd(a,x) for(int i=a;i<x;i++)
#define fx(x,n) for(int i=n-1;i>=x;i--)
#define mst(x) memset(x,0,sizeof(x));
#define fi first
#define se second
#define TB ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define ok "ok"
#define HH puts("");
#define ls rt<<1
#define rs rt<<1|1
#define pb(a,b) a.push_back(b);
#define FIN  freopen("1.in","r",stdin);
#define FOUT freopen("1.out","w",stdout);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<string,int> pss;
typedef unsigned long long ull;
const ll mod=1e18;
const ll inf=1e18;
const double eps=1e-8;
const double pi=acos(-1);



int main(){
    TB
    int a,b;
    cin>>a>>b;
    fdd(1,10004){
        double aa=i*0.08,bb=i*0.1;
        int aaa=aa,bbb=bb;
        if(aaa==a&&bbb==b){
            cout<<i<<'\n';
            return 0;
        }
    }
    cout<<-1<<'\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
typedef long long ll;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (C >= A && C <= B) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
	using namespace std;
	int main() {
	int A, B, M;
	cin >> A >> B >> M;
	vector<int> a(A);
	vector<int> b(B);
	for (int i = 0; i < A; i++)cin >> a[i];
  	for (int i = 0; i < B; i++)cin >> b[i];
	int minA = *min_element(a.begin(), a.end());
	int minB = *min_element(b.begin(), b.end());
	int ans = minA+minB;
	for (int i = 0; i < M; i++) {
		int x, y, c;
		cin >> x >> y >> c; x--; y--;
		ans = min(ans, a[x] + b[y] - c);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long int
using namespace std;
int dp[100010],n,k,a[100010];
int solve(int i)
{
  if(i==0)
    return 0;
  if(dp[i]!=-1)
    return dp[i];
  int m=INT_MAX;
  for(int j=1;j<=i&&j<=k;j++)
  m=min(m,abs(a[i]-a[i-j])+solve(i-j));
  return dp[i]=m;
}
signed main()
{
  memset(dp,-1,sizeof(dp));
  cin>>n>>k;
  for(int i=0;i<n;i++)
    cin>>a[i];
  cout<<solve(n-1)<<"\n";
  // cout<<dp[n-1]<<"\n";
  return 0;
}

Measured memory_bytes: 11372
N = int(input())
W = list(map(int, input().split()))


sum1 = 0
sum2 = sum(W)
min_tmp = 1e+6

for i in range(N):
    sum1 += W[i]
    sum2 -= W[i]
    tmp = abs(sum1 - sum2)
    min_tmp = min(tmp, min_tmp)

print(min_tmp)

Measured memory_bytes: 3064
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int  w,h,ans;
    cin>>w>>h;
    if (h==1 or w==1)
        cout << 1 << endl;
    else if (h&1^1)
        cout << (h/2)*w << endl;
    else {
        int  half=w/2;
        if (w%2==0)
            cout << (h/2)*half + ((h+1)/2)*half << endl;
        else 
            cout << (((h/2)*half)+(((h+1)/2)*(half+1))) << endl;
    }
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3628
from collections import Counter
from operator import itemgetter
N = int(input())
S = [input() for _ in range(N)]

L = Counter(S)
L = L.most_common()
maxi = L[0][1]
L.sort(key=itemgetter(0))

for i in range(len(L)):
    if L[i][1] == maxi:
        print(L[i][0])

Measured memory_bytes: 45112
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

	static void exec(Scanner in, PrintStream out) {
		in.nextInt();
		int Q = in.nextInt();
		String S = in.next();
		int[] t = new int[S.length()];
		for (int i = 0; i < t.length - 1; i += 1) {
			if (S.charAt(i) == 'A' && S.charAt(i + 1) == 'C') {
				t[i + 1] = t[i] + 1;
			} else {
				t[i + 1] = t[i];
			}
		}
		for (int i = 0; i < Q; i += 1) {
			int l = in.nextInt();
			int r = in.nextInt();
			out.println(t[r - 1] - t[l - 1]);
		}
	}

	public static void main(String[] args) {
		exec(new Scanner(System.in), System.out);
	}

}


Measured memory_bytes: 69316
#include <bits/stdc++.h>
typedef long long ll;
#define forn(i, start, end) for (ll i = start; i < ll(end); i++)
#define input(arr, n) forn(i, 0, n) cin >> arr[i];
#define MOD 1000000007
#define vll vector<ll>
#define vpll vector<pair<ll, ll>>
#define vvll vector<vector<ll>>
#define mll map<ll, ll>
#define mcl map<char, ll>
#define sc set<char>
#define sll set<ll>
#define ssll stack<ll>
#define CHK(param) cout << #param << " is : " << param << "\n";
#define pb push_back
#define ppb pop_back
#define mk make_pair
#define f first
#define s second
#define all(x) (x).begin(), (x).end()
#define LAUV                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define TC       \
    ll TTTT;     \
    cin >> TTTT; \
    while (TTTT--)
using namespace std;

int32_t main()
{
    LAUV;
    // TC
    {
        ll x, y;
        cin >> x >> y;
        forn(i, 0, x + 1)
        {
            ll t = x - i;
            if ((2 * i + 4 * t) == y)
            {
                cout << "Yes\n";
                return 0;
            }
        }
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3624
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


Measured memory_bytes: 75144
def calc(N, A):
    Amax = [0, 0]
    for a in A:
        if (a > Amax[0]):
            Amax[1] = Amax[0]
            Amax[0] = a
        elif (a > Amax[1]):
            Amax[1] = a
    result = ''
    for a in A:
        if (a == Amax[0]):
            result += str(Amax[1]) + '\n'
        else:
            result += str(Amax[0]) + '\n'
    return result


N = int(input())
A = [int(input()) for _ in range(N)]
print(calc(N, A))

Measured memory_bytes: 15140
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }

    static Scanner cin;

    void calc()
    {
        var N = cin.nextInt();
        long[] A = cin.ArrayLong(N);
        long[] ret = new long[N];
        long x = 0;

        for(var i = 0;i < N; i++)
        {
            if(i % 2 == 1)
            {
                x -= A[i];
            }
            else
            {
                x += A[i];
            }
        }
        ret[0] = x / 2;
        for(var i = 0;i < N-1; i++)
        {
            ret[i + 1] = A[i] - ret[i];
        }

        for(var i = 0;i < N-1; i++)
        {
            Console.Write(ret[i] * 2);
            Console.Write(" ");
        }
        Console.Write(ret[N-1] * 2);

    }


    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 31064
#include<bits/stdc++.h>
using namespace std;
int n,a[100],ans=0,flag=1;
int check(int x,int y)
{
    int b[100];
    for(int i=1; i<=n; i++)
        b[i]=a[i];
    swap(b[x],b[y]);
    for(int i=2; i<=n; i++)
        if(b[i]<b[i-1])
            return 0;
    return 1;
}
int main()
{
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d",&a[i]);
    for(int i=2; i<=n; i++)
        if(a[i]<a[i-1])
        {
            flag=0;
            break;
        }
    if(flag)
    {
        printf("YES");
        return 0;
    }
    for(int i=1; i<=n; i++)
        for(int j=i+1; j<=n; j++)
            if(check(i,j))
            {
                printf("YES");
                return 0;
            }
    printf("NO");
    return 0;
}


Measured memory_bytes: 256
module Main where

import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    [n, m] <- fmap read . words <$> getLine :: IO [Int]
    let p = fromIntegral $ 100 * (n - m) + 1900 * m
    let s = 0.5 ^ m
    let t = 1.0 - s
    let f k = (p * k) * s * (t ^ (floor $ k - 1.0))
    let ans = sum $ takeWhile (>= 0.000001) $ fmap f [1..]
    print $ ceiling ans

Measured memory_bytes: 892
#include <iostream>

int main()
{
	int x, y;
	std::cin >> x >> y;

	for (int crane = 0; crane <= x; ++crane)
	{
		if (crane * 2 + (x - crane) * 4 == y)
		{
			std::cout << "Yes" << std::endl;

			return 0;
		}
	}

	std::cout << "No" << std::endl;

	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main()
{/// Standing in The hall of Fame
    ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);
    int h , w , k , x[105]{} , y[105]{};
    char g[105][105];
    cin >> h >> w;
    for(int i = 1 ; i <= h ; i++)
        for(int j = 1 ; j <= w ; j++)
            cin >> g[i][j];
    for(int i = 1 ; i <= h ; i++){
        k = 1;
        for(int j = 1 ; j <= w ; j++)
            if(g[i][j] == '#')k = 0;
        x[i] = k;
    }
    for(int i = 1 ; i <= w; i++){
        k = 1;
        for(int j = 1 ; j <= h ; j++)
            if(g[j][i] == '#')k = 0;
        y[i] = k;
    }
    //cout << "==========================\n";
    for(int i = 1 ; i <= h ; i++){
        if(x[i])continue;
        for(int j = 1; j <= w ; j++){
            if(y[j])continue;
            cout << g[i][j];
        }
        cout << "\n";
    }
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  int c0 = 0;
  for(int i = 0;i<S.size();i++){
    if(S[i] == '0'){
      c0++;
    }
  }
  int c1 = S.size()-c0;
  if(c0 == 0 || c1 == 0){
    cout << 0 << endl;
  }
  else{
  cout << 2*min(c0,c1) << endl;
  }
}

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll N, A, B; cin >> N >> A >> B;
    cout << N/(A+B) * A + min(A, N %(A+B)) << endl;
    return 0;
}


Measured memory_bytes: 256
int main(){
  int N,a,t,s=0;
  scanf("%d",&N);
  while(N--){
    scanf("%d",&a);
    asm volatile(
      "bsf %0,%1":"=r"(t):"r"(a)
    );
    s+=t;
  }
  printf("%d\n",s);
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using P = std::tuple<int,int>;
using ll = long long;

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

ll N, S;

ll test(ll n, ll b){
    if(n < b){return n;}
    return n % b + test(n / b, b);
}

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

    std::cin >> N >> S;

    if(N < S){
        std::cout << -1 << std::endl;
        return 0;
    }
    
    for(ll i=2;i<=std::min(N,1000000ll);++i){
        ll cur = test(N, i);
        
        if(cur == S){
            std::cout << i << std::endl;
            return 0;
        }
    }

    if(N > 1000000){
        ll res = 1001001001001001001ll;
        for(ll a=1;a<=std::min(S,1000000ll);++a){
            ll b = S - a, x = (N - b) / a;

            if((N - b) % a == 0 && b < x){
                res = min(res, x);
            }
        }

        if(res < 1001001001001001001ll){
            std::cout << res << std::endl;
            return 0;
        }
    }

    if(N == S){
        std::cout << N + 1 << std::endl;
        return 0;
    }
    
    std::cout << -1 << std::endl;
}


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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);

		int n=sc.nextInt();
		String s=sc.next();

		ArrayList<String>slimes= new ArrayList<>();
		for(int i=0;i<n;i++) {
			slimes.add(s.substring(i,i+1));
		}
		//System.out.println(slimes);
		int count=0;
		for(int j=0;j<slimes.size();j++) {
			if(j==0) {
				count+=1;
			}else {
				//System.out.println(slimes.get(j-1));
				//System.out.println(slimes.get(j));

				if(slimes.get(j).equals(slimes.get(j-1))) {

				}else {
					count+=1;
				}

			}
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 31696
/*
    In the name of
        "ALLAH"
    And say "AL-HAMD-U-LILLAH"
*/

#include<bits/stdc++.h>
#define   ll   long long
#define   llu  unsigned long long
#define   _    printf("\n")
int      take() {
    int n;
    scanf("%d",&n);
    return n;

}
double  ttake() {
    double n;
    scanf("%lf",&n);
    return n;
}
ll     takes() {
    ll n;
    scanf("%lld",&n);
    return n;

}

#define  Int            take()
#define  Dnt            ttake()
#define  LL             takes()
#define  done           {return 0;}
#define  fr(i,x,n,a)    for(int i=x;i<=n;i+=a)
#define  FR(a,b,x)      for(int i=(a);i<=(b);i+=(x))
#define  rfr(i,x,n,a)   for(int i=x;i>=n;i--)
int      cas;
#define  print          printf("Case %d:",++cas)
#define  vi             vector<int>
#define  vl              vector<ll>
#define  pb              push_back
#define  pii             pair<int,int>
#define  vii             vector<pii>
#define  pll             pair<ll,ll>
#define  pil             pair<int,ll>
#define  pli             pair<ll,int>
#define  mk              make_pair
#define  fill(x,v)       memset(x,v,sizeof x)

using    namespace      std;

bool     approximatelyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool     essentiallyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) > fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool     definitelyGreaterThan(float a, float b, float epsilon) {
    return (a - b) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool     definitelyLessThan(float a, float b, float epsilon) {
    return (b - a) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
#define  STR            {struct info}
#define  dbg(x)         {cout<<"ekhane"<<x<<endl;}
#define  SS             second
#define  FF             first
#define  PQ             priority_queue
#define  great          greatest
#define  less           lesser
#define  mii            map<int,int>
#define  mil            map<int,ll>
#define  mll            map<ll,ll>
#define  msb            map<string,bool>
#define  V              vector
#define  M              100005
#define  pf             printf
//////////////////////////////////////////


int main(){

    ll a = LL , b = LL , c = LL , x = LL , y = LL ;
    ll ans = 1000000000000000000 ;

    fr( i , 0 , max( x , y ) , 1 ){
        ll d = i ;
        ll e = 2 * d * 1ll * c ;
        ll f = ( x - i ) * 1ll * a ;
        ll g = ( y - i ) * 1ll * b ;
        ll m = e ;
        if( f > 0 ) m += f ;
        if( g > 0 ) m += g ;
        ans = min( ans , m ) ;
    }
pf("%lld\n",ans) ;
    done;
}



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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')

typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
const int mod = 1e9 + 7;
ll power(ll a, ll b)
{
    ll ans = 1 % mod;
    while (b > 0)
    {
        if (b & 1)
        {
            ans = ans * a % mod;
        }
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    int n;
    cin >> n;
    vector<ll> a(n + 1);
    ll mx = -1;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        //mx = max(mx, a[i]);
    }
    ll ans = 0;
    for (int bit = 0; bit < 60; bit++)
    {
        ll cnt0 = 0, cnt1 = 0;
        for (int i = 1; i <= n; i++)
        {
            ll cur = a[i];
            if ((cur >> bit) & 1)
            {
                cnt1++;
            }
            else
            {
                cnt0++;
            }
        }
        ans = (ans + cnt0 % mod * cnt1 % mod * ((1ll << bit) % mod) % mod) % mod;
    }
    cout << ans << "\n";
    //cout << len << "\n";
    return 0;
}

Measured memory_bytes: 5548
import Data.List

main :: IO ()
main = do
  str <- getLine
  let n = length str
  putStrLn $ if  length "KIHBR" <= n
    && n <= length "AKIHABARA"
    && solve str then "YES" else "NO"

solve :: String -> Bool
solve str = go str == "KIHBR" && f str && g str
  where
    f ss = all (\ls -> length ls == 1) $
           group ss
    go ss = map head $
            filter (\ls -> head ls /= 'A') $
            group ss
    g ss = isInfixOf "KIH" ss


Measured memory_bytes: 380
n = int(input())
cont = [0 for i in range(10050)]

for x in range(1,105):
  for y in range(1,105):
    for z in range(1,105):
      v = x**2 + y**2 + z**2 + z*x + y*z + x*y
      if v <= 10001:
        cont[v]+=1

for i in range(1,n+1):
  print(cont[i])


Measured memory_bytes: 74008
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#pragma comment(linker,"/STACK:102400000,102400000")
#define INF 0x3f3f3f3f
#define maxm 1500
typedef long long ll;
using namespace std;
int mp[maxm][maxm]{0};
int t[maxm][maxm]{0};
int calRectangle(int (&vec)[maxm],int w,int time)
{
    int result=0;
    stack<int> stk;
    vec[w+1]=0;
    //if(true){for(int i=1;i<=w;i++)cout<<vec[i]<<" ";cout<<endl;}
    for(int i=1;i<=w+1;)
    {
        if(stk.empty()/*Stuck is empty*/||vec[stk.top()]<=vec[i]/*The list upper*/)
        {
            stk.push(i);/*Stuck <- i(pointer)*/
            i++;
        }
        else
        {
            int temp=stk.top();/*Save the topStuck pointer*/
            stk.pop();/*Find the former pushed pointer*/
            result=max(result,vec[temp]*(stk.empty()?(i-1):(i-stk.top()-1)));
            //i--;/*Keep the value of i(i--++=1)*/
        }
    }
    //cout<<result<<endl;
    return result;
}
int main()
{
    int h,w,pt,res=0;
    cin>>h>>w;
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
            cin>>mp[i][j];
    for(int j=1;j<=w;j++)
    {
        pt=1;
        for(int i=1;i<=h;i++)
            if(!mp[i][j])
                t[i][j]=pt++;
            else
            {
                t[i][j]=0;
                pt=1;
            }
    }
    //for(int i=1;i<=h;i++){for(int j=1;j<=w;j++)cout<<t[i][j]<<" ";cout<<endl;};
    for(int i=1;i<=h;i++)
        res=max(res,calRectangle(t[i],w,i));
    cout<<res<<endl;
    return 0;
}
//Do not use memset !



Measured memory_bytes: 19564
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef long long LL;
typedef pair<int , int > P;
const int maxn=3005;
const LL INF=1e13+5;
LL DP[maxn][maxn][4];
int rc[maxn][maxn];
int main()
{
    memset(DP, 0, sizeof DP);
    memset(rc, 0, sizeof rc);
    LL R , C , K;
    cin >> R >> C >> K;
    while(K--)
    {
        int a, b, c;
        cin >> a >> b >> c;
        rc[a][b]=c;
    }
    for(int i=R;i>=1;i--)
    for(int k=C;k>=1;k--)
    {
       // cout << DP[i][k+1][1] << ' '<< DP[i][k+1][2] << ' '<< DP[i][k+1][3] << endl;
        //cout << DP[i+1][k][1] << ' '<< DP[i+1][k][2] << ' '<< DP[i+1][k][3] << endl;
        //cout << endl;
        for(int n=1;n<=3;n++)
        {
            if(!rc[i][k])
            DP[i][k][n]=max(DP[i+1][k][n], DP[i][k+1][n]);
            else
            {
                 LL max1=0;
                 if(n==1)
                for(int x=1;x<=3;x++) max1=max(max1, DP[i+1][k][x]+rc[i][k]);
                if(n!=1&&DP[i][k+1][n-1]==0)
                {
                    DP[i][k][n]=0;
                    continue;
                }
                max1=max(DP[i][k+1][n], max(DP[i][k+1][n-1]+rc[i][k], max1));
                DP[i][k][n]=max1;
            }
        }

    }
    LL ans=-4;
    for(int i=1;i<=3;i++)
        ans=max(ans, DP[1][1][i]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 321128
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
	int n;
    cin>>n;
	int i;
	int count=1;
	long long max1=0,max2=0;
	long long a[100000];
	for(int i=0;i<=n-1;i++) {
		cin>>a[i];
	}
	sort(a,a+n);
	for(i=0;i<n;i++){
		if(a[i]==a[i+1])
			count=2;
		else 
			count=1;
		if(count>=2) {
			max1=max2; max2=a[i];   
			i=i+1;             
			count=1;  
		}
	}
	cout<<max1*max2<<endl;	
	return 0;	
}

Measured memory_bytes: 1024
// Ver19.03
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

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

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <unistd.h>
#define ll long long
#define inf 1000000007
#define inf16 0x3f3f3f3f
#define INF 1000000000000000007LL
#define VI vector<int>
#define VPII vector<pair<int, int> >
#define VLL vector<ll>
#define PII pair<int, int>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
using namespace std;

ll x, y;

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	cin >> x >> y;

	if(x%y==0)
		cout << -1;
	else
		cout << x;
}

Measured memory_bytes: 764
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)



int main(void){
	ll n,m,p,y;
	cin>>n>>m;
	vector< pair<ll,ll> > V[100004];
	int ANSP[100004];
	int ANSN[100004];
	rep(i,m){
		cin>>p>>y;
		ANSP[i+1] = p;
		pair<ll,ll> pa;
		pa.first = y;
		pa.second = i+1;
		V[p].push_back(pa);
	}
	rep(i,n+1){
		sort(V[i].begin(),V[i].end());
		rep(j,V[i].size()){
			ANSN[V[i][j].second] = j+1;
		}
	}
	reps(i,(int)m){
		cout<<setfill('0')<<setw(6)<<right<<ANSP[i]<<setfill('0')<<setw(6)<<ANSN[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 8832
#include <iostream>
#include <vector>
#include <map>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define pb push_back

int main(void)
{
  char b;
  cin >> b;
  char a;
  if (b == 'A') a = 'T';
  else if (b == 'C') a = 'G';
  else if (b == 'G') a = 'C';
  else a = 'A';
  cout << a << endl;
  return 0;
}


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

MOD = 10 ** 9 + 7
p = int(n**0.5)


a = [i for i in range(1, p+1)]

for x in range(p, 0, -1):
    if n // x != p:
        a.append(n // x)

dp = [[0 for _ in range(len(a))] for _ in range(k)]

m = len(a)

temp = 0
b = [0] * m
for i, x in enumerate(a):
    b[i] = x - temp
    temp = x

for i in range(m):
    dp[0][i] = b[i]

for i in range(k-1):
    temp = 0
    for j in range(m-1, -1, -1):
        temp = (temp + dp[i][m-1-j]) % MOD
        dp[i+1][j] = temp * b[j] % MOD

#print(dp)

print(sum(dp[-1]) % MOD)


Measured memory_bytes: 121628