akhauriyash/Code-Regression huggingface dataset:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a_even = [i for i in a if i % 2 == 0]

    for a in a_even:
        if not (a % 3 == 0 or a % 5 == 0):
            print('DENIED')
            exit()

    print('APPROVED')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
import java.util.*;

public class Main {

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

        String x = sc.next();

        char y = x.charAt(x.length() - 1);

        if (y == 's') {
            System.out.println(x + "es");
        } else {
            System.out.println(x + "s");
        }

        sc.close();

        }

    }



Measured memory_bytes: 38500
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

const int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n;
    cin >> n;
    vi w(n);
    rep(i, n) cin >> w[i];

    int res = INF;

    for (int t = 0; t < n-1; t++) {
        int s1 = 0, s2 = 0;
        rep(i, n) {
            if (i <= t) s1 += w[i];
            else s2 += w[i];
        }
        int d = abs(s1 - s2);
        res = min(res, d);
    }

    cout << res << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    cin>>n;
    vector<ll> x(n);
    ll sum=0;
    for(ll i=0; i<n; i++) {
        cin>>x[i];
        sum+=x[i];
    }
    ll ans=0;

    ll p = sum/n;
    ll tmp1 = 0;
    for(ll i=0; i<n; i++) {
        tmp1 += (x[i]-p)*(x[i]-p);
    }

    p = p + 1;
    ll tmp2 = 0;
    for(ll i=0; i<n; i++) {
        tmp2 += (x[i]-p)*(x[i]-p);
    }
    if (tmp1 <= tmp2){
        ans = tmp1;

    } else {
        ans = tmp2;
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<random>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll gcd(ll x, ll y) { return (y ? gcd(y, x % y) : x); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main() {
	init();
	
	int N; cin >> N;
	ll ans = 1;
	rep(i, 0, N) {
		ll a; cin >> a;
		ans = lcm(ans, a);
	}
	cout << ans << "\n";

	return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back

int main()
{
    string S;
    cin >> S;
    ll N = SZ(S);
    S += "*";

    vector<pair<char,ll>> P;
    char c = 'R';
    ll cnt = 1;
    REP(i,1,N+1) {
        if(S[i] == c) ++cnt;
        else {
            P.pb({c, cnt});
            c = (c == 'L' ? 'R' : 'L');
            cnt = 1;
        }
    }

    vec C(N, 0);
    ll prev = 0;
    // true R->R L->L
    // false R->L L->R
    ll pos = 0, n;
    FORR(p,P) {
        n = p.second;
        pos += n;
        if(p.first == 'R') {
            C[pos-1] += (n + 1) / 2;
            C[pos] += n / 2;
        }
        else {
            C[pos-n-1] += n / 2;
            C[pos-n] += (n + 1) / 2;
        }
    }

    REP(i,0,N) PS(C[i]);
    PR("");

    return 0;
}

/*

RRLLLLRLRRLL

R2 L4 R1 L1 R2 L2

*/

Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
int main(){
  int m,x,y,j,z=0;
  cin>>m;
  for(j=0;j<m;j++){
    cin>>x>>y;
    if(x==y){
      z++;
      if(z==3){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
    else z=0;
  }
  cout<<"No"<<endl;
}

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

using namespace std;
int n,i,j;
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n;
    if(n%4==0||n%7==0) {
        cout<<"Yes";
        return 0;
    }
    else
    {
        for(i=1;i<=100;i++)
            for(j=1;j<=100;j++)
             if(i*4+j*7==n)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main  {

    static int[][] dp;

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String f = in.next();
        String s = in.next();

//        System.out.println(lcs(f, s));
        lcs(f, s);
        char[] LCS = LCS(f, s);
        String ans = "";
        for (int i = 0; i < LCS.length; i++) {
            
            ans = ans += LCS[i];
            
        }
        
        System.out.println(ans);
        
    }

    static int lcs(String s1, String s2) {
        int m = s1.length();
        int n = s2.length();
        dp = new int[m + 1][n + 1];
        for (int i = 0; i <= m; i++) {
            for (int j = 0; j <= n; j++) {
                if (i == 0 || j == 0) {
                    dp[i][j] = 0;
                } else if (s1.charAt(i - 1) == s2.charAt(j - 1)) {
                    dp[i][j] = 1 + dp[i - 1][j - 1];
                } else {
                    dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
                }
            }
        }
        return dp[m][n];
    }

    static char[] LCS(String s1, String s2) {
        int m = s1.length();
        int n = s2.length();
        int index = dp[m][n];
        char word[] = new char[index];
        int i = m, j = n;
        while (i > 0 && j > 0) {
            if (s1.charAt(i - 1) == s2.charAt(j - 1)) {
                word[index - 1] = s1.charAt(i - 1);
                i--;
                j--;
                index--;
            } else if (dp[i - 1][j] > dp[i][j - 1]) {
                i--;
            } else {
                j--;
            }
        }
        return word;
    }

}


Measured memory_bytes: 100300
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl
#define CE cout<<endl

ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[1010][1010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc,cd[1010][1010];
vector<ll> va,vb,vc;

int main(){
    cin>>n>>m;
    if(m/2>=n){
        C (n*2+m)/4 E;
    }
    else{
        C m/2 E;
    }
    //C (n*2+m)/4 E;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] chars = sc.nextLine().toCharArray();
		for(int i  = 0; i < chars.length; i++){
			char c = chars[i];
			if('a' <= c && c <= 'z'){
				chars[i] = (char)(c - 32);
			}
			if('A' <= c && c <= 'Z'){
				chars[i] = (char)(c + 32);
			}
		}
		System.out.println(chars);
	}
}



Measured memory_bytes: 26292
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N;cin >> N;
    int ans[300] = {};
    REPP(i,1,201){
        int sum = 0;
        REPP(j,1,i){
            if(i % j == 0) sum++;
        }
        if(sum == 7 && i % 2 == 1){ans[i]++;}
    }
    REP(i,200){
        ans[i+1] += ans[i];
    }
    cout << ans[N] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<malloc.h>
#include<x86intrin.h>
#include<math.h>

int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

void InputIntAry(int *a,int nBuf,int N){
    char *buf,*ptr;

    buf=(char*)malloc(nBuf*sizeof(char));
    my_gets(buf,nBuf,stdin);

    ptr=strtok(buf," ");
    while(ptr!=NULL && N-->0){
        *(a++)=atoi(ptr);
        ptr=strtok(NULL," ");
    }
    free(buf);
}

int main(){
    int N,X,cnt=0;
    int L[1000];

    scanf("%d %d%*c",&N,&X);
    InputIntAry(L,5000,N);

    do{
        X -= L[cnt];
        cnt++;
    }while( X>=0 && cnt<(N+1) );

    printf("%d\n",cnt);
    
    return 0;
}

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

using namespace std;

long long n ;

long long cnt = 0 ;

void solve(long long x , long long a , long long b , long long c)
{
     if(x == n)
     {
         if(a > 0 && b > 0 && c > 0)
            cnt++;
         return ;
     }
     if(x > n)
        return ;
     if(a > 0 && b > 0 && c > 0)
        cnt++;
     solve(x * 10ll + 3ll , a+1ll , b , c) ;
     solve(x * 10ll + 5ll , a , b+1ll , c) ;
     solve(x * 10ll + 7ll , a , b , c+1ll) ;
}

int main()
{
    cin>>n ;
    solve(0 , 0, 0 ,  0) ;
    cout<<cnt<<"\n";
    return 0 ;
}


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

int main(){
  int n;
  cin >> n;
  map<int, int> a;
  for(int i = 1; i < n + 1; i++){
    int x;
    cin >> x;
    a[x] = i;
  }
  for(auto x : a){
    auto answer = x.first;
    auto number = x.second;
    cout << number << endl;
  }
}

Measured memory_bytes: 5504
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)998244353;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var N = Sarray()[0];
            var Ai = new long[N];
            var As = new long[N];
            for (var i = 0; i < N; ++i)
                Ai[i] = As[i] = Sarray()[0];
            Array.Sort(As);
            var dct = new Dictionary<long, long>();
            for (var i = 0; i < N; ++i)
                dct[As[i]] = i;
            var ans = 0L;
            for (var i = 0; i < N; ++i)
                if (i % 2 != dct[Ai[i]] % 2)
                    ++ans;
            WriteLine(ans / 2);
        }
    }
}

Measured memory_bytes: 27332
#include<iostream>
using namespace std;
int main(){
  string s;
  int n,i,ans=0;
  cin >> n >> s;
  for(i=0;i<n-2;i++){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3500
import java.util.Scanner;

public class Main {
	
	static int fib(int n) {
		int[] fib = new int[n+1];
		fib[0] = 1;
		fib[1] = 1;
		for(int i=2;i<=n;i++) {
			fib[i] = fib[i-1]+fib[i-2];
		}
		return fib[n];
	}
	
	void main() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		System.out.println(fib(n));
	}

	public static void main(String[] args) {
		new Main().main();
	}
}



Measured memory_bytes: 26328
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        
        int a = scan.nextInt();
        int b = scan.nextInt(); 
    
         if(a > b){
             System.out.println("a > b");
         }
         if(a < b){
             System.out.println("a < b");
         }
         if(a == b){
             System.out.println("a == b");
         }
    }
}



Measured memory_bytes: 26188
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
typedef pair<lint,pint> tint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint mo=1000000007;
lint extgcd(lint a, lint b, lint &x, lint &y) {
  lint g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
lint invMod(lint a, lint m) {
  lint x, y;
  if (extgcd(a, m, x, y) == 1) return (x + m) % m;return 0;
}
lint inv[20010010];
lint zyo[20010010];
lint rz[20010010];
//vector<lint> zyo,rz;
lint p(int a,int b){
	if(a<0 || a-b<0) return 0;
	return zyo[a]*rz[a-b]%mo;
}
int main()
{
	int h,w,k;lint out=0;
	cin>>h>>w>>k;lint x=((lint)h*w)%mo;
	inv[1] = 1;
    //REP(i,2,h+w+10) inv[i] = inv[mo%i] * (mo - mo/i) % mo;
	zyo[0]=1;rep(i,h+w+5) zyo[i+1]=zyo[i]*(i+1)%mo;
	rz[h+w+5]=invMod(zyo[h+w+5],mo);
	for(int i=h+w+5;i>0;i--) rz[i-1]=rz[i]*i%mo;
	//rz[0]=1;rep(i,h+w+5) rz[i+1]=rz[i]*inv[i+1]%mo;
	//return 0;
	//切らない
	out+=p(h+w,k)*k;out%=mo;
	//cout<<out<<endl;
	//片方切ればいい
	lint sum=0;
	rep(i,k){
		//lint t=(p(h+w-1,i)*p(h+w-i-1,k-i-1))%mo;
		//lint t=p(h+w-1,k-1);
		//cout<<i<<' '<<t<<endl;
		//t*=i+1;t%=mo;
		//out+=t*(h+w);out%=mo;
		sum+=i+1;if(sum>=mo) sum-=mo;
	}
	out+=sum*(h+w)%mo*p(h+w-1,k-1);out%=mo;
	//cout<<out<<endl;
	sum=0;
	//両方切る
	rep(i,k-1){
		//lint t=p(h+w-2,i)*p(h+w-i-2,k-i-2)%mo;
		//lint t=p(h+w-2,k-2);
		lint t=2*(k-i-1);//t%=mo;
		t*=i+1;//t%=mo;
		sum+=t;sum%=mo;
		//out+=t*x;out%=mo;
	}
	out+=sum*x%mo*p(h+w-2,k-2);out%=mo;
	cout<<out<<endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int n,m,q;
ll s1[2111][2111],s2[2111][2111],s3[2111][2111];
string s[2111];

int main(){
	cin.sync_with_stdio(false);
  cin>>n>>m>>q;
  rep(i,n)cin>>s[i];
  rep(i,n)rep(j,m)s1[i+1][j+1]=s[i][j]=='1'?1:0;
  rep(i,n+1)rep(j,m)s1[i][j+1]+=s1[i][j];
  rep(i,n)rep(j,m+1)s1[i+1][j]+=s1[i][j];
  rep(i,n)rep(j,m){
    if(s[i][j]=='1'&&s[i][j+1]=='1'){
      s2[i+1][j+2]=1;
    }
    if(s[i][j]=='1'&&s[i+1][j]=='1'){
      s3[i+2][j+1]=1;
    }
  }

  rep(i,n+2)rep(j,m+1){
    s2[i][j+1]+=s2[i][j];
    s3[i][j+1]+=s3[i][j];
  }
  rep(i,n+1)rep(j,m+2){
    s2[i+1][j]+=s2[i][j];
    s3[i+1][j]+=s3[i][j];
  }
  rep(i,q){
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    ll v=s1[x2][y2]-s1[x1-1][y2]-s1[x2][y1-1]+s1[x1-1][y1-1];
    ll e1=s2[x2][y2]-s2[x1-1][y2]-s2[x2][y1]+s2[x1-1][y1];
    ll e2=s3[x2][y2]-s3[x1][y2]-s3[x2][y1-1]+s3[x1][y1-1];
    //dbg(e1); dbg(e2);
    cout<<v-e1-e2<<endl;
  }
	return 0;
}


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


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


string st;

int mem[310][310][310];


int dfs(int l,int r,int x){
    if(r<l){
        return 0;
    }
    if(l==r){
        return 1;
    }
    if(mem[l][r][x]!=-1){
        return mem[l][r][x];
    }
    int res=max(dfs(l+1,r,x),dfs(l,r-1,x));
    if(st[l]==st[r]){
        res=max(res,dfs(l+1,r-1,x)+2);
    }
    if(x){
        res=max(res,dfs(l+1,r-1,x-1)+2);
    }
    return mem[l][r][x]=res;
}


int main(){
    cin>>st;
    int K;
    cin>>K;
    REP(i,300){
        REP(j,300){
            REP(k,301){
                mem[i][j][k]=-1;
            }
        }
    }
    cout<<dfs(0,st.size()-1,K)<<endl;
    return 0;
}

Measured memory_bytes: 112896
# frozen_string_literal: true


input = gets.chomp.split(' ').map(&:to_i)
X = input[0]
Y = input[1]
modu = 1_000_000_007
modu_list = (modu - 2).to_s(2).split('').map(&:to_i).reverse
# def derive_inverse(num, modu)
#   i = 0
#   res = 1
#   until (res % num).zero?
#     res += modu
#     i += 1
#   end
#   (1 + i * modu) / num
# end
def derive_inverse(num, modu, modu_list = [])
  result = num
  result_list = [num % modu]
  time_time = 1
  while result_list.length < modu_list.length do
    result = result**2 % modu
    time_time *= 2
    result_list << result
  end
  result = 1
  result_list.each_with_index do |e, i|
    result = result * e % modu if modu_list[i] != 0
  end
  result
end

# def derive_inverse(num, modu)
#   return num.pow(modu-2,  modu)
# end

if ((2 * Y - X) % 3).zero? && ((2 * X - Y) % 3).zero? && (2 * Y - X >= 0) && (2 * X - Y >= 0)
  m = (2 * Y - X) / 3
  n = (2 * X - Y) / 3

  answer = 1

  if m < n
    ele = m
    elem = n
  else
    ele = n
    elem = m
  end

  deno = 1
  ele.times do |i|
    deno = deno * (i + 1) % modu
    answer = answer * (elem + 1 + i) % modu
  end
  deno = derive_inverse(deno, modu, modu_list)
  answer = answer * deno % modu
else
  answer = 0
end

puts answer % modu


Measured memory_bytes: 1916
#include<stdio.h>

int main(void){
  int n,i,j,k;
  scanf("%d",&n);
  int w[n];
  for(i=0;i<n;i++){
    scanf("%d",&w[i]);
  }
  int s1,s2,min;
  s1=0;
  s2=0;
  min=1000000000;
  for(i=0;i<n;i++){
  	for(j=0;j<i;j++){
      s1+=w[j];
    }
    for(j=i;j<n;j++){
      s2+=w[j];
    }
    if(s1>=s2&&min>s1-s2){
      min=s1-s2;
    }
    if(s1<s2&&min>s2-s1){
      min=s2-s1;
    }
    //printf("%d",s1,s2);
    s1=0;
    s2=0;
  }
  
  printf("%d",min);
  
  return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	FastScanner in;
	PrintWriter out;

	void solve() {
		int a = in.nextInt();
		int b = in.nextInt();

		if (a - b * 2 >= 0) {
			out.println(a - b * 2);
		} else {
			out.println("0");
		}
	}

	void run() {
		try {
			in = new FastScanner(new File("Main.in"));
			out = new PrintWriter(new File("Main.out"));

			solve();

			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	void runIO() {

		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args) {
		new Main().runIO();
	}
}


Measured memory_bytes: 23252
from collections import Counter
from operator import mul
from functools import reduce

def combo(n):
    if n<1:
        return 0
    r = min(n-2,2)
    if r == 0: return 1
    over = reduce(mul, range(n, n - 2, -1))
    under = reduce(mul, range(1,2 + 1))
    return over // under

N=int(input())
A=list(map(int,input().split(" ")))
count=Counter(A)
com={}

for k,v in count.items():
    com[k]=combo(v)
s=sum(com.values())
for i in range(N):
    su=s-combo(count[A[i]])+combo(count[A[i]]-1)
    print(su)

Measured memory_bytes: 30896
// copied
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdio>
#include <map>
using namespace std;
typedef long long LL;
const int maxn = 2e5 + 100;
int n, k;
LL a[maxn], c[maxn*4];
map<LL, int> M;
vector<LL> V;
void Modify(int x, int s){
    for(; x <= n; x += x&(-x)) c[x] += s;
}
LL Query(int y){
    if(y <= 0) return 0;
    LL ans = 0;
    for(int x = y; x; x -= x&(-x)) ans += c[x];
    return ans;
}

int main()
{
    int x;
    scanf("%d %d", &n, &k);
    for(int i = 1; i <= n; i++) scanf("%d", &x), a[i] = x;
    LL sum = 0;
    for(int i = 1; i <= n; i++) {
        sum += a[i];
        sum -= k;
        V.push_back(sum);
    }
    sort(V.begin(), V.end());
    for(int i = 0; i < V.size(); i++) M[V[i]] = i+1;
    sum = 0;
    LL ans = 0;
    for(int i = 1; i <= n; i++){
        sum += a[i];
        sum -= k;
        ans += Query(M[sum]);
        if(sum >= 0) ans++;
        Modify(M[sum], 1);
    }
    cout<<ans<<endl;
}


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

using namespace std;
using ll = long long;

const ll md = 1e9 + 7;

int main()
{
  ios_base::sync_with_stdio (0);
  cin.tie (0);
  ll n;
  cin >> n;
  vector<ll>a (n);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<ll>suf (n);
  ll ci = n - 1;
  for (ll i = n - 2; i >= 0; i--) {
    if (a[i] > a[ci]) {
      suf[i] =  a[i] - a[ci];
    } else {
      ci = i;
    }
  }
  for (ll i = 0; i < n; i++) {
    if (suf[i] > 1) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 998244353;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int main() {
	fastio;
	int N, S;
	cin >> N >> S;

	int arr[3001];
	for (int i = 1; i <= N; ++i) cin >> arr[i];

	int dp[3001]{}, ans = 0;
	for (int i = 1; i <= N; ++i) {
		dp[0] = i;
		for (int j = S; j >= arr[i]; --j) dp[j] = (dp[j] + dp[j - arr[i]]) % MOD;
		ans = (ans + dp[S]) % MOD;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll N;
    cin>>N;
    ll A[N],c=1;
    rep(0,i,N){
        cin>>A[i];
        if(c==A[i]){
            ++c;
        }
    }
    if(c==1){
        cout<<-1<<endl;
        return 0;
    }
    cout<<N-c+1<<endl;
}


Measured memory_bytes: 1792
import sys

N, Y = map(int, input().split())

for i in range(N + 1):
    for j in range(N - i + 1):
        k = N - (i + j)
        if (i * 10000) + (j * 5000) + (k * 1000) == Y:
            print('{} {} {}'.format(i, j, k))
            sys.exit()
print('-1 -1 -1')


Measured memory_bytes: 2940
import itertools

N = int(input())
S = input()

black = [0] * (N + 1)
white = [0] * (N + 1)
for i, s in enumerate(S, 1):
  if s == '#':
    black[i] += 1
  else:
    white[i] += 1

black = list(itertools.accumulate(black))
white = list(itertools.accumulate(white))

ans = N
num_W = white[-1]
for b, w in zip(black, white):
  ans = min(ans, b + (num_W-w))

print(ans)

Measured memory_bytes: 20692
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int w = saori.saori_hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		if(a == b){
			System.out.println(0);
		} else if(a < b){
			if(a < b && b <= a+w){
				System.out.println(0);
			} else {
				System.out.println(b - (a+w));
			}
		} else {
			if(b < a && a <= b+w){
				System.out.println(0);
			} else {
				System.out.println(a - (b+w));
			}
		}
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22356
#include<stdio.h>
int main(void){
    int H,W,i,j;
    while(1){
    scanf("%d %d",&H,&W);
    if(H==0&&W==0){
        break;

    }
    for(i=0;i<H;i=i+1){

        for(j=0;j<W;j=j+1){
            printf("#");
        }
            printf("\n");

    }
    printf("\n");
    }










    return 0;
}

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

using namespace std;

#define fin cin
#define fout cout
//ifstream fin("x.in"); ofstream fout("x.out");

typedef long long i64;
const int nmax = 2e5;

int v[nmax + 1];
i64 s[nmax + 1];

i64 max4 (i64 a, i64 b, i64 c, i64 d) {
    return max(max(a, b), max(c, d));
}

i64 min4 (i64 a, i64 b, i64 c, i64 d) {
    return min(min(a, b), min(c, d));
}

int main() {
    fin.sync_with_stdio(false); fin.tie(); fout.tie();

    int n;
    fin >> n;

    for (int i = 1; i <= n; ++ i) {
        fin >> v[i];
        s[i] = s[i - 1] + v[i];
    }

    int j = 1, k = 3;
    i64 ans = 1LL << 60;

    for (int i = 2; i <= n - 1; ++ i) {
        while (j < i - 1 && s[j] < s[i] - s[j]) {
            ++ j;
        }

        while (k < n - 1 && s[k] - s[i] < s[n] - s[k]) {
            ++ k;
        }


        for (int dj = -1; dj <= 1; ++ dj) {
            for (int dk = -1; dk <= 1; ++ dk) {
                if (j + dj >= 1 && j + dj < i && i < k + dk && k + dk < n) {
                    i64 a, b, c, d;
                    a = s[j + dj];
                    b = s[i] - s[j + dj];
                    c = s[k + dk] - s[i];
                    d = s[n] - s[k + dk];
                    ans = min(ans, max4(a, b, c, d) - min4(a, b, c, d));
                }
            }
        }
    }
    fout << ans << "\n";
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int main(){
  long long N;
  long long sum=0;
  cin >> N;
  for(long long i=1;i<=N;i++){
    if(!(i%3==0) && !(i%5==0)){
      sum+=i;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using VI = vector<int>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 60;
constexpr auto mod = 1000000007;
constexpr auto MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

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

    int n, q;
    cin >> n >> q;
    int a, b;
    vector<VI> edge(n);
    FOR(i, 0, n - 1) {
        cin >> a >> b;
        edge[--a].push_back(--b);
        edge[b].push_back(a);
    }

    VI dis(n, 0);
    vector<bool> ever(n, false);
    queue<pair<int, int>> bfs;
    bfs.push({ 0,0 });
    ever[0] = true;
    while (!bfs.empty()) {
        int now = bfs.front().first;
        int num = bfs.front().second + 1;
        bfs.pop();
        for (int next : edge[now]) {
            if (ever[next])continue;
            ever[next] = true;
            dis[next] = num;
            bfs.push({ next,num });
        }
    }

    int p, x;
    VI X(n, 0);
    FOR(i, 0, q) {
        cin >> p >> x;
        X[--p] += x;
    }
    VI cnt(n, 0);
    bfs.push({ 0,X[0] });
    while (!bfs.empty()) {
        int now = bfs.front().first;
        int point = bfs.front().second;
        cnt[now] += point;
        bfs.pop();
        for (auto& next : edge[now]) {
            if (dis[next] < dis[now])continue;
            bfs.push({ next,point + X[next] });
        }
    }

    cout << cnt[0];
    FOR(i, 1, n)cout << " " << cnt[i];
    cout << "\n";
}


Measured memory_bytes: 17908
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;

int N;
string s;

int main() {
    cin >> N >> s;
    int red = 0;
    for (int i = 0; i < N; i++) {
        if (s[i] == 'R') {
            red++;
        } else {
            red--;
        }
    }
    cout << (red > 0? "Yes": "No") << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vii vector<pair<int, int> >
#define fi first
#define se second
#define int long long
int a[100005];
vi G[100005];
void dfs(int u, int p)
{
	if(G[u].size()==1) return;
	int sum=-a[u];
	for(auto v: G[u])
	{
		if(v==p) continue;
		dfs(v, u);
		sum+=a[v];
		if(a[v]>a[u])
		{
			cout<<"NO";
			exit(0);
		}
	}
	if(a[u]-sum<0 or sum<0) 
	{
		cout<<"NO";
		exit(0);
	}
	a[u]-=sum;
}
signed main()
{
//	freopen("in31.txt","r",stdin);
//	freopen("out31.txt","w",stdout);
	int n;
	cin>>n;
	for(int i=1; i<=n; i++) cin>>a[i];
	if(n==2)
	{
		if(a[1]-a[2]) return cout<<"NO", 0;
		return cout<<"YES", 0;
	}
	for(int i=1, u, v; i<=n-1; i++)
	{
		cin>>u>>v;
		G[u].emplace_back(v);
		G[v].emplace_back(u);
	}
	int root;
	for(int i=1; i<=n; i++)
	{
		if(G[i].size()>=2) root = i;
	}
//	cout<<root<<" "<<G[root].size()<<endl;
	dfs(root, 0);
//	cout<<a[root]<<" ";
	if(a[root]) cout<<"NO";
	else cout<<"YES"; 
}


Measured memory_bytes: 16788
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;


int main()
{
	int n, a[51], amax, amin, imax=1, imin=1, m=0, x1, y1;
	vector<int> x, y;

	scanf("%d", &n);
	for(int i=1; i<=n; i++){
		scanf("%d", &a[i]);
		if(i==1){
			amax=a[1];
			amin=a[1];
		}else{
			if(amax<a[i]){
				amax=a[i];
				imax=i;
			}
			if(amin>a[i]){
				amin=a[i];
				imin=i;
			}
		}
	}
	int e=0;
	if(-amin<amax){
		for(int j=1; j<n; j++){
			if(a[j]<=a[j+1] && e==0){
				continue;
			}else{
				e=1;
				if(a[j+1]>0){
					x.push_back(imax);
					y.push_back(j+1);
					imax=j+1;
					m++;
				}else{
					x.push_back(imax);
					y.push_back(j+1);
					x.push_back(imax);
					y.push_back(j+1);
					imax=j+1;
					m++;
					m++;
				}
			}
		}
	}else{
		for(int j=n; j>1; j--){
			if(a[j-1]<=a[j] && e==0){
				continue;
			}else{
				e=1;
				if(a[j-1]<0){
					x.push_back(imin);
					y.push_back(j-1);
					imin=j-1;
					m++;
				}else{
					x.push_back(imin);
					y.push_back(j-1);
					x.push_back(imin);
					y.push_back(j-1);
					imin=j-1;
					m++;
					m++;
				}
				
			}
		}
	}

	if(m==0){
		printf("%d\n", m);
	}else{
		printf("%d\n", m);
		auto itrx=x.begin();
		auto itry=y.begin();
		while(itrx!=x.end()){
			x1=*itrx;
			y1=*itry;
			printf("%d %d\n", x1, y1);
			itrx++;
			itry++;
		}
	}
	
	return 0;

}

Measured memory_bytes: 256
N = int(input())
ans = N

for i in range(1,N//2):
    A = str(i)
    B = str(N-i)
    AB_sum = 0
    for j in A:
        AB_sum += int(j)
    for j in B:
        AB_sum += int(j)
    if AB_sum < ans:
        ans = AB_sum

print(ans)


Measured memory_bytes: 2940
def resolve():
    N = int(input())
    A = list(map(int, input().split()))

    ans = 1
    if 0 in A:
        print("0")
        return
    for i in range(N):
        ans *= A[i]
        if ans > 1000000000000000000:
            ans = -1
            break
    print(ans)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 21400
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
	int n, m, q; cin >> n >> m >> q;
	int a[n + 1][n + 1];
	Rep(i, n + 1) Rep(j, n + 1){
		a[i][j] = 0;
	}
	Rep(i, m){
		int l, r; cin >> l >> r;
		a[l][r] += 1;
	}
	For(i, 1, n + 1) For(j, 1, n + 1){
		a[i][j] += a[i - 1][j];
	}
	For(i, 1, n + 1) For(j, 1, n + 1){
		a[i][j] += a[i][j - 1];
	}
	Rep(i, q){
		int l, r; cin >> l >> r;
		cout << a[r][r] - a[l - 1][r] - a[r][l - 1] + a[l - 1][l - 1] << endl;
	}
}

Measured memory_bytes: 1920
//	Problem Name: 
//
//  Created by Kushal Warke
//  Copyright © 2018 Kushal Warke. All rights reserved.
//

#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(x) ((x)<0?-(x):(x))

typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector< pair<int,int> > vpi;
typedef vector< pair<long long,long long> > vpll;

double EPS = 1e-9; 
int INF = 1000000005; 
long long INFF = 1000000000000000005LL;
const int N = 100001;
const int M = 4;
int n;
int k;
int data[N];
int cost[N];

int solve(int i) {
    if(cost[i]!=-1) {
        return cost[i];
    }
    if(i==n) {
        return cost[i] = 0;
    }
    if(i==n-1) {
        return cost[i] = abs(data[i+1] - data[i]);
    }
    int ans = INT_MAX;
    FOR(j,1,k+1) {
        if(i+j>n) break;
        ans = min(abs(data[i+j]-data[i])+solve(i+j),ans);
    }
    return cost[i] = ans;
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    cin>>k;
    FOR(i,1,n+1) {
        cin>>data[i];
        cost[i] = -1;
    }
    solve(1);
    cout<<cost[1]<<endl;
    return 0;
}



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

int main(){
        int n;
        scanf("%d", &n);
        int a[2][n];
        for(int i=0; i<2*n; i++) scanf("%d", &a[i/n][i%n]);

        int ans = 0;
        for(int i=0; i<n; i++){
                int tmp = 0;
                for(int j=0; j<n; j++){
                        if(i>=j) tmp += a[0][j];
                        if(i<=j) tmp += a[1][j];
                }
                ans = std::max(ans, tmp);
        }
        printf("%d\n", ans);
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<vector>
#include<math.h>
using namespace std;


int main() {

	int a;
	string s;
	cin >> a;
	cin >> s;
	if (a >= 3200)	cout << s << endl;
	else
	{
		cout << "red" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>
using namespace std;
typedef  long long int lint;
//typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define P pair<int,int>

int main() {
	vector<int>A(5);
	rep(i, 5) {
		cin >> A[i];
	}
	sort(A);
	reverse(A);
	rep(i, 4) {
		cout << A[i] << ' ';
	}
	cout << A[4] << endl;
}


Measured memory_bytes: 3048
//*************************************************************************
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
#include<regex>

#include<map>
using namespace std;

int main(){
	int n,a;
	cin>>n>>a;
	cout<<(n*n-a)<<endl;
	return 0;
}


Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <set>
#include <queue>
#include <cstdio>
#include <stack>
#include <list>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define lrep(i, n) for(long long i=0;i<n;i++)
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;
template <class T> T gcd(T n, T m){return m ? gcd(m, n%m):n;}

int main(){
    double a,b,x;cin>>a>>b>>x;
    double di = 2;
    if(x <= a*a*b/di){
        double ans = atan(a*b*b/di/x)*180/M_PI;
      	printf("%.15f\n", ans);
      	return 0;
    }
    else{
        double ans = atan(di*b/a - di*x/a/a/a)*180/M_PI;
      	printf("%.15f\n", ans);
      	return 0;
    }
}


Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }



int main() {
	
	string target;
	cin >> target;
	deque<char> s(target.size());
	rep(i, target.size()) s[i] = target[i];
	int q;
	cin >> q;
	int rev = 0;
	rep(i, q) {
		int t;
		cin >> t;
		if (t == 2) {
			int f;
			char c;
			cin >> f >> c; f--;
			if (rev) f = 1 - f;
			if (f == 0) s.push_front(c);
			else s.push_back(c);
		}
		else rev = 1 - rev;
	}
	if (rev) reverse(s.begin(), s.end());
	rep(i, s.size()) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 896
using System;
using System.Collections.Generic;
using System.Linq;

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var edge = new List<int[]>();
            for (int i = 0; i < N - 1; i++)
            {
                var input = ReadArrayInt();
                var a = input[0] - 1;
                var b = input[1] - 1;
                edge.Add(new int[] { a, b, 0, i });
            }
            edge = edge.OrderBy(e => e[0]).ThenBy(e => e[1]).ToList();
            var par = new int[N];
            var col = new int[N];
            var pat = 0;
            for (int i = 0; i < N - 1; i++)
            {
                if (edge[i][0] == 0)
                {
                    edge[i][2] = ++pat;
                    par[edge[i][1]] = edge[i][0];
                    col[edge[i][1]] = pat;
                }
                else
                {
                    var num = edge[i][0];
                    var cNum = 1;
                    while (true)
                    {
                        if (cNum == col[num]) cNum++;
                        edge[i][2] = cNum;
                        par[edge[i][1]] = num;
                        col[edge[i][1]] = cNum;
                        if (cNum > pat) pat = cNum;
                        cNum++;
                        if (i + 1 < N - 1 && edge[i + 1][0] == num) i++;
                        else break;
                    }
                }
            }
            edge = edge.OrderBy(e => e[3]).ToList();
            Console.WriteLine(pat);
            foreach (var e in edge)
            {
                Console.WriteLine(e[2]);
            }

            Console.WriteLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

int main(){
    string s;
    bool judge = true;
    cin >> s;
    for(int i = 0;i < s.size();i++){
        for(int j = i + 1;j < s.size();j++){
            if(s.at(i) == s.at(j))judge = false;
        }
    }
    if(judge)cout << "yes" << endl;
    else cout << "no" << endl;
}

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

using namespace std;

bool checkRow(string *row) {
    for(int i = 0; i < (*row).length(); i++) {
        if((*row)[i] != '.') return false;
    }
    return true;
}

bool checkColumn(vector<string> *board, int col) {
    for(int i = 0; i < (*board).size(); i++) {
        if((*board)[i][col] != '.') return false;
    }
    return true;
}

void delCol(vector<string> *board, int col) {
    for(int i = 0; i < (*board).size(); i++) {
        ((*board)[i]).erase(col, 1);
    }
}

int main() {
    int h, w;

    scanf("%d %d", &h, &w);

    string buf;
    vector<string> board;
    for(int i = 0; i < h; i++) {
        cin >> buf;
        if(!checkRow(&buf)) {
            board.push_back(buf);
        }
        else {
            // fprintf(stderr, "debug print : del row = %d\n", i);	// 4debug
        }
    }

    for(int i = 0; i < board[0].length(); i++) {
        if(board[0][i] == '.' && checkColumn(&board, i)) {
            delCol(&board, i);
            // fprintf(stderr, "debug print : del col = %d\n", i);	// 4debug
            i--;
        }
    }

    for(int i = 0; i < board.size(); i++) {
        cout << board[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){ 
    int a,b;

    cin>>a;
    if(a%2==1){
        b=a/2;
        cout<<(b+1)*b;
    }else{
        cout<<a/2*a/2;
    }
 
    return 0;
}

Measured memory_bytes: 256