akhauriyash/Code-Regression huggingface dataset:
import org.w3c.dom.ls.LSOutput;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.nio.Buffer;
import java.util.*;

public class Main {
    public static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

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

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void solve(int id,ArrayList<Integer> tmp,long point,int mask,int add){
        if(id==tmp.size()){
            dp[mask]=Math.max(dp[mask],point+pre[add]);
            return;
        }
        solve(id+1,tmp,point,mask,add);
        solve(id+1,tmp,point,mask^(1<<tmp.get(id)),add^(1<<tmp.get(id)));
    }
    public static final long inf=1000000000000000009l;
    public static int n;
    public static long [][]a=new long[20][20];
    public static long []pre=new long[1<<20];
    public static long []dp=new long[1<<20];
    public static FastReader r=new FastReader();
    public static void main(String[] args){
        n=r.nextInt();
        for(int i=0;i<n;++i){
            for(int j=0;j<n;++j){
                a[i][j]=r.nextInt();
            }
        }
        for(int mask=0;mask<(1<<n);++mask){
            for(int i=0;i<n;++i){
                if((mask&(1<<i))>0){
                    for(int j=i+1;j<n;++j){
                        if((mask&(1<<j))>0){
                            pre[mask]+=a[i][j];
                        }
                    }
                }
            }
        }
//        for(int mask=0;mask<(1<<n);++mask){
//            System.out.println("pre : "+pre[mask]);
//        }
        for(int mask=0;mask<(1<<n);++mask){
            dp[mask]=-inf;
        }
        dp[0]=0;
        for(int mask=0;mask<(1<<n);++mask){
            ArrayList<Integer> tmp=new ArrayList<>();
            for(int i=0;i<n;++i){
                if((mask&(1<<i))==0){
                    tmp.add(i);
                }
            }
            solve(0,tmp,dp[mask],mask,0);
        }
        System.out.println(dp[(1<<n)-1]);
    }
}


Measured memory_bytes: 57044
#include <bits/stdc++.h>
using namespace std;
int a[1000000];
int main()
{
    ios::sync_with_stdio(false);
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=1;i<=n;++i)
        a[i]=m-k;
    while(k--)
    {
        int num;
        cin>>num;
        a[num]++;
    }
    for(int i=1;i<=n;++i)
    {
        if(a[i]>=1)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream> 
#include <cstdio> 
#include <fstream> 
#include <algorithm> 
#include <cmath> 
#include <deque> 
#include <vector> 
#include <queue> 
#include <string> 
#include <cstring> 
#include <map> 
#include <stack> 
#include <set> 
using namespace std;
typedef long long ll;
const int maxn = 210000;
int a[maxn],b[maxn];
int n, ans = 0;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
	}
	for (int i = n; i >= 1; i--)
	{
		int sum = 0;
		for (int j = i+i; j <= n; j += i)
		{
			sum += b[j];
		}
		if ((a[i] == 1&&sum%2)||(a[i]==0&&sum%2==0))
		{
			b[i] = 0;
		}
		else
		{
			b[i] = 1;
			ans++;
		}
	}
	printf("%d\n", ans);
	for (int i = 1; i <= n; i++)
	{
		if (b[i])
		{
			printf("%d", i);
			if (i != n)printf(" ");
		}
	}
}

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

//整数からなる配列の総和を求める関数
int sum(vector<int> S){
    int counter = 0;
    for(int i=0; i< S.size(); i++){
        counter = counter + S.at(i);
    }
    return counter;
}

//整数からなる配列に与えられた値が何個あるか数え上げる関数
//頂点の次数を返す関数ともとれる
int search(vector<int> E, int v){
    int counter = 0;
    for(int i=0; i < E.size() ;i++){
        if(E.at(i) == v){
        counter++ ;
    }
  }
   return counter;
}


//グラフGの頂点vに接続している頂点の全体を配列で返す関数
vector<int> connect(vector<int> E, int v){
  int X_size = search(E,v);
  vector<int> X(X_size);
    int counter = 0;
    for(int i=0; i < E.size() ; i= i+2){
        if(E.at(i) == v){
            X.at(counter) = E.at(i+1) ;
            counter++;
        }
    }
    for(int j=1;j < E.size() ; j=j+2){
        if(E.at(j) == v){
            X.at(counter) = E.at(j-1);
            counter++;
        }
    }
    return X;
}


//グラフG=(V,E)と頂点vが与えられたときにVから頂点ｖを削除した後の点集合を返すような関数
//V.at(0)=0として正規化されているものとする
vector<int> vertex_delete(vector<int> V, int v){
    V.at(v) = 0;
    return V;
} 

//グラフG=(V,E)と頂点vが与えられたときにGから頂点vを削除した後の辺集合を返すような関数
//削除したところを０で上書きする
vector<int> edge_delete(vector<int> E, int v){
    for(int i=0; i < E.size() ; i= i+2){
        if(E.at(i) == v){
            E.at(i) = 0;
            E.at(i+1) = 0;
        }
    }
    for(int j=1;j < E.size() ; j=j+2){
        if(E.at(j) == v){
            E.at(j) = 0;
            E.at(j-1) = 0;
        }
    }
    return E;
}



//グラフG=(V,E)と頂点vが与えられたときに、ｖをスタートして各頂点をちょうど一度だけ通るようなパスの総数を返す関数
int path(vector<int> V, vector<int> E, int v){
    //頂点数N
    int N = search(V,1);
    //vの次数d
    int d = search(E,v);
    if(d == 0 && N > 1){
        return 0;
    }
    if(d == 0 && N == 1){
        return 1;
    }
    else{
        vector<int> S = connect(E,v);
        for(int j=0; j < S.size(); j++){
            S.at(j) = path(vertex_delete(V,v),edge_delete(E,v),S.at(j)) ;
        }
        return sum(S);
    }
    
}


int main(){

//入力を受け取る
int N ;
cin >> N ;

int M ;
cin >> M;

//点集合Vを用意
//V=(0 1 1 1   1 1)で初期化。V.at(0)=0とした方がわかりやすいかなと
vector<int> V(N+1);
V.at(0) = 0;
for(int i=1;i < N+1; i++){
    V.at(i) = 1;
}

//辺集合Eの読み込み
vector<int> E(2*M);
for(int i=0 ; i< 2*M ; i++){
    cin >> E.at(i);
}



//テストコード
cout << path(V,E,1) << endl;



}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  int N; cin >>N;
  vector<int> v(100010, 0);
  REP(i, N){
    int a, b; cin >>a >>b;
    v[a]++; v[b + 1]--;
  }
  FOR(i, 1, v.size()) v[i] += v[i - 1];
  int ans = 1;
  REP(i, v.size()) if(i <= v[i] + 1) ans = i - 1;
  cout <<ans <<endl;
  return 0;
}

Measured memory_bytes: 1536
def dist(a, b, x, y, h):
    return h + abs(a - x) + abs(b - y)

N = int(input())
P = []
for i in range(N):
    x, y, h = map(int, input().split())
    P.append([h, x, y])
P.sort(reverse = True)

for i in range(101):
    for j in range(101):
        H = dist(i, j, P[0][1], P[0][2], P[0][0])
        for p in P[1:]:
            if max(H - abs(p[1]-i)-abs(p[2]-j), 0) != p[0]:
                break
        else:
            print(i, j, H)
            break

Measured memory_bytes: 9076
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N)  for (int (i) = 0; (i) < (N); (i)++)

bool IsPrime(int y){
    if (y == 2) return true;
    if (y%2 == 0) return false;
    for (int i = 3; i <= ceil(sqrt(y)); i += 2){
        if (y%i == 0){
            return false;
        }
    }
    return true;
}

int main(){

    int X;
    cin >> X;
    for (int i = X; i <= INT_MAX; i++){
        if (IsPrime(i)){
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
a=[]
w=""
while(w!="-1 -1 -1"):
    w=input()
    a.append(w)
a.pop()
for st in a:
    s=st.split()
    m=int(s[0])
    f=int(s[1])
    r=int(s[2])
    if (m==-1 or f==-1):
        print("F")
    elif (m+f>=80):
        print("A")
    elif(m+f>=65):
        print("B")
    elif(m+f>=50):
        print("C")
    elif(m+f>=30 and r>=50):
        print("C")
    elif(m+f>=30 and r<50):
        print("D")
    else:
        print("F")



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll fac[200005],rfac[200005];
ll mod=1e9+7;
ll mul(ll a,ll b)
{
	return ((a%mod)*(b%mod))%mod;
}
ll add(ll a,ll b)
{
	return ((a%mod)+(b%mod))%mod;
}
ll gcd(ll a, ll b); 
  
// To compute x raised to power y under modulo m 
ll power(ll x, unsigned ll y, unsigned ll m); 
  
// Function to find modular inverse of a under modulo m 
// Assumption: m is prime 
ll modInverse(ll a, ll m) 
{ 
    ll g = gcd(a, m); 
    
      return power(a, m-2, m); 
} 
  
// To compute x^y under modulo m 
ll power(ll x, unsigned ll y, unsigned ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
  
    return (y%2 == 0)? p : (x * p) % m; 
} 
  
// Function to return gcd of a and b 
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b%a, a); 
} 
ll cal(ll n,ll r)
{
	//cout<<fac[n]<<" "<<rfac[n-r]<<" "<<rfac[r]<<"\n";
	return mul(fac[n],mul(rfac[n-r],rfac[r]));
}
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	fac[0]=1;
	for(ll i=1;i<200005;i++)
	{
		fac[i]=mul(fac[i-1],i);
	}
	for(ll i=0;i<200005;i++)
	{
		rfac[i]=modInverse(fac[i], mod);
	}
	ll n,k;
	cin>>n>>k;
	k=min(k,n-1);
	ll out=0;
	for(ll i=0;i<=k;i++)
	{
		//cout<<cal(n,i)<<" "<<cal(n-1,n-i-1)<<"\n";
		out=add(out,mul(cal(n,i),cal(n-1,n-i-1)));
	}
	cout<<out;
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define N 100020
#define ll long long
using namespace std;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
	while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return f?x:-x;
}
int a[N], ans;
int main(int argc, char const *argv[]) {
	int n = read();
	for (int i = 1; i <= n; i++)
		a[read()] ++;
	for (int i = 1; i <= 100000; i++)
		ans = max(ans, a[i - 1] + a[i] + a[i + 1]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>
#include <assert.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF32		INT32_MAX
#define	INF64		INT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

bool pair_comp(const pair<ll, ll> & p1, const pair<ll, ll> & p2)
{
	// sort(item.begin(), item.end(), throw_comp)のように使う
	if (p1.first != p2.first) {
		return p1.first < p2.first;
	}
	else {
		return p1.second > p2.second;
	}
}

ll gcd(ll a, ll b)
{
	// a >= b
	if (b > a) swap(a, b);
	if (b == 0) return a;
	return gcd(a % b, b);
}

// main function
int main()
{
	ll N = 0, X = 0;
	ll ans = 1;

	cin >> N >> X;
	vector< ll > x(N, 0);
	vector< ll > diff(N, 0);

	Rep(i, N) {
		cin >> x[i];
		diff[i] = abs(x[i] - X);
	}
	ans = diff[0];
	for (int i = 1; i < N; ++i) {
		ans = gcd(ans, diff[i]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
	int q,c,a,n,cnt,i;
	scanf("%d",&q);
	for(i=0;i<q;i++){
		cnt=0;
		scanf("%d %d %d",&c,&a,&n);
		while(1){
			if(c>=1&&a>=1&&n>=1){
				cnt++;
				c=c-1;
				a=a-1;
				n=n-1;
			}
			else{
				if(c>=2&&a>=1){
					cnt++;
					c=c-2;
					a=a-1;
				}
				else{
					if(c>=3){
						cnt++;
						c=c-3;
					}
					else{
						break;
					}
				}
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}


Measured memory_bytes: 2128
#include <iostream>
using namespace std;
const int MAXN=200005;
struct Edge
{
	int v,next;
}e[MAXN*2];
int h[MAXN],cnt;
void addEdge(int x,int y)
{
	e[++cnt].v=y,e[cnt].next=h[x],h[x]=cnt;
}
int dep[MAXN];
void dfs(int u,int d,int pa)
{
	dep[u]=d;
	for(int i=h[u];i;i=e[i].next)
	{
		if(e[i].v==pa)continue;
		dfs(e[i].v,d+1,u);
	}
}
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		addEdge(x,y);
		addEdge(y,x);
	} 
	dfs(1,1,-1);
	int cmax,maxi=0;
	for(int i=1;i<=n;i++)
		if(dep[i]>maxi)
			maxi=dep[i],cmax=i;
	dfs(cmax,1,-1);
	maxi=0;
	for(int i=1;i<=n;i++)
		if(dep[i]>maxi)
			maxi=dep[i],cmax=i;
	if(maxi%3==1||maxi%3==0)
		cout<<"First"<<endl;
	else
	 	cout<<"Second"<<endl;
	return 0;
}


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

bool ydp[8010][30000],xdp[8010][30000];

int main(){
    string s;
    cin>>s;
    int X,Y;
    cin>>X>>Y;
    
    vector<int> x,y;
    int n=s.size();
    int c=0;
    bool yoko=true;
    for(int i=0;i<n;i++){
        if(yoko){
            if(s[i]=='F'){
                c++;
            }
            else{
                yoko=false;
                x.push_back(c);
                c=0;
            }
        }
        else if(!yoko){
            if(s[i]=='F'){
                c++;
            }
            else{
                yoko=true;
                y.push_back(c);
                c=0;
            }
        }
    }
    if(c){
        if(yoko) x.push_back(c);
        else y.push_back(c);
    }

    int k=x.size(),l=y.size();

    xdp[0][8000]=true;
    ydp[0][8000]=true;

    xdp[1][8000+x[0]]=true;

    

    for(int i=1;i<k;i++){
        for(int d=0;d<=20000;d++){
            if(d-x[i]>=0 && xdp[i][d-x[i]]==true) xdp[i+1][d]=true;
            if(xdp[i][d+x[i]]==true) xdp[i+1][d]=true;
        }
    }

    for(int i=0;i<l;i++){
        for(int d=0;d<=20000;d++){
            if(d-y[i]>=0 && ydp[i][d-y[i]]==true) ydp[i+1][d]=true;
            if(ydp[i][d+y[i]]==true) ydp[i+1][d]=true;
        }
    }
    

    if(xdp[k][X+8000] && ydp[l][8000+Y]){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    
}

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

string solve(int n, vector<int> d, vector<int> dd) {
  int time = 0;
  for(int i=0;i<n;i++) {
    if(d[i] == dd[i]) {
      time++;
    } else {
      time = 0;
    }
    if(time == 3) {
      return "Yes";
    }
  }
  return "No";
}

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  vector<int> dd(n);
  for(int i=0;i<n;i++) {
    cin >> d[i] >> dd[i];
  }
  cout << solve(n, d, dd);
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main()
{
    int a;
    cin >> a;
    if (a == 25){
        cout << "Christmas";
    }else if (a == 24){
        cout << "Christmas Eve";
    }else if (a == 23){
        cout << "Christmas Eve Eve";
    }else if (a == 22){
        cout << "Christmas Eve Eve Eve";
    }
    return 0;
}


Measured memory_bytes: 3564
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner scn= new Scanner(System.in);
		int n=scn.nextInt();
		int m=scn.nextInt();
		int[] arr =new int[n];
		long sum=0;
		for(int i=0;i<n;i++){
		   arr[i]=scn.nextInt();
		   sum+=arr[i];
		   }
		int count=0;
		double val =(sum*1.0)/(4*m);
		for(int i=0;i<n;i++){
			if((arr[i]*1.0)>=val){
				count++;
			}
		}
		if(count>=m){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 21972
#include <iostream>
#include <string.h>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;
int main()
{
    double r;
    cin>>r;
    double pi=6.28318530717958623200;
    pi=pi*r;
    cout<<pi<<endl;
	return 0;
}


Measured memory_bytes: 3256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 1e18+10 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int MOD;
class BIT{
	public:
	//[1,i]
	int n;
	vi bit;
//	int bit[MAZ_N+1];
	BIT(int size){
		n=size;
		bit=vi(n+1);
	}
	Def query(int i){//sum
		Def s=0;
		while(i>0){
			(s+=bit[i])%=MOD;
			i-=i&-i;
		}
		return s;
	}
	void add(int i,Def x){
		while(i<=n){
			(bit[i]+=x)%=MOD;
			i+=i&-i;
		}
	}
};
int stolong(string s){
	int a=0;
	rep(i,s.size()){
		a*=10;
		a+=s[i]-'0';
	}
	return a;
}
signed main(){
	int l,r;
	while(cin>>l>>r>>MOD,l){
		int sa=r-l+1;
		BIT bit(sa);
		rep(i,sa){
			int t=l+i;
			int sum=1;
			int w=t;
			while(w){
				string q=to_string(w);
				string s="1"+string(q.size()-1,'0');
				int ne=stolong(s);
				if(w<l)break;
				(sum+=bit.query(w-l+1)-bit.query(max(l,ne)-l)+MOD)%=MOD;
				w/=10;
			}
//			cout<<i<<" "<<t<<" "<<sum<<endl;
			bit.add(i+1,sum);
		}
		cout<<bit.query(sa)<<endl;
		
	}
}


Measured memory_bytes: 3892
toInt :: String -> Int
toInt = read :: String -> Int

countTwos :: Int -> Int
countTwos n
  | mod n 2 == 0 = 1 + countTwos (div n 2)
  | otherwise = 0

judge :: [Int] -> Bool
judge a
  | mod l 2 == 0 = 2*f+t >= l
  | otherwise = 2*f+1+t >= l 
    where
      l = length a
      c = map countTwos a
      f = length $ filter (>= 2) c
      t = length $ filter (== 1) c

main = do
  n <- toInt <$> getLine
  a <- map toInt .words <$> getLine
  putStrLn $ if judge a then "Yes" else "No"


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

/*
A^5 - B^5 = X

i)   A < 0, B < 0
このとき|B| > |A|で |B|^5 - |A|^5であるが、|B|が120をこえるとXが10^9を超えるので120 * 120でおわり
ii)  A < 0, B >= 0
これはありえない
iii) A >= 0, B < 0
|A|^5 + |B|^5 なので 64 * 64でおわり
iv)  A >= 0, B >= 0
|A|^5 - |B|^5
*/


int	main(void)
{
	int x;
	cin >> x;
	for (int i = -120; i <= 120; i++)
	{
		for (int j = -120; j <= 120; j++)
		{
			if ((long long)pow(i, 5) - (long long)pow(j, 5) == x)
			{
				cout << i << " " << j << endl;
				return (0);
			}
		}
	}
}


Measured memory_bytes: 4068
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);

      String S = sc.next();
      char[] p = S.toCharArray();

  System.out.print(p[0]==p[1]||p[1]==p[2]||p[2]==p[3]?"Bad":"Good");

    }
}

Measured memory_bytes: 20948
// finish date: 2018/01/22
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    int N;
    cin >> N;
    vector<int> s(N);
    int sum = 0;
    bool flag = false;
    rep(i, N) {
        cin >> s[i];
        if(s[i]%10!=0) flag = true;
        sum += s[i];
    }
    if(!flag){
        cout<<0<<endl;
        return 0;
    }
    sort(s.begin(),s.end());
    if (sum % 10 == 0) {
        rep(i, N) {
            if (s[i] % 10 != 0) {
                sum -= s[i];
                break;
            }
        }
    }
    cout << sum << endl;

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(){
	char s1[3];
	char s2[3];
	scanf("%s", s1);
	scanf("%s", s2);
	if(s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0]){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}

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

int N, M;

int main() {
    cin >> N;
    vector<string> ans;

    if (N == 0) {
        ans.push_back("0");
    }
    else {
        while (N != 0) {
            int rest = N % (-2);
            if (rest < 0) rest += 2;
            ans.push_back(to_string(rest));
            N = (N - rest) / (-2);
        }
    }

    for (int i = ans.size() - 1; i >= 0; i--) {
        cout << ans[i];
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define MOD 30000000000000000
#define inf -100000000
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define MAXN 500005
using namespace __gnu_pbds; 
ll int power(ll int x,ll int y) 
{ 
    ll int res = 1;     // Initialize result 
   
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = res*x; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = x*x;  // Change x to x^2 
    } 
    return res; 
}
//set<ll int> s;
bool prime[500005];
void SieveOfEratosthenes(ll int n) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
     
    memset(prime, true, sizeof(prime)); 
  
    for (ll int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    
} 

int main()
{
    fast;
   // #ifndef ONLINE_JUDGE
   // freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
   // #endif
    string s,t;
    cin>>s>>t;
    if(t.substr(0,s.size())==s)
        cout<<"Yes\n";
    else
    {
        cout<<"No";
    }
}

Measured memory_bytes: 3564
#include<iostream>
#include<cstdio>
#include<ctype.h>
#include<cstdlib>
using namespace std;
inline int read(){//快读,很快！
    int x=0,f=0;char ch=getchar();
    while(!isdigit(ch))f|=ch=='-',ch=getchar();
    while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
    return f?-x:x;
}
inline void Yeah(){puts("Yes");exit(0);}//可以得到
int main(){ 
    int n=read(),m=read(),k=read();//读入
    for(int i=1;i<=n;++i){
        int kk=(k-i*m),a=n-i-i;//kk是剩下的要变成黑色的格子,a是每次增加的黑格子
        if(!kk || a && (kk>>31&1)==(a>>31&1) && kk%a==0 && kk/a<=m)Yeah();
        //!kk说明已经填完了，可以直接输出。
        //a不能等于0,否则%0会报错，
        //(kk>>31&1)==(a>>31&1)这句是判断kk和a是否同号,二进制表示的负数第一位是1
        //kk%a==0前面已经说过，就是可以组成的情况
        //kk/a必须小于等于m,因为j最多加m次
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<numeric>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(lli i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	lli n; cin >> n;
	vector<lli> a(n);
	rep(i, n) cin >> a[i];
	lli sum = accumulate(a.begin(), a.end(), 0LL);
	if(sum%(n*(n+1)/2) != 0){
		cout << "NO" << endl;
		return 0;
	}
	
	lli m = sum/(n*(n+1)/2);
	
	rep(i, n){
		lli k = m+a[i]-a[(i+1)%n];
		if(k < 0 || k%n != 0){
			cout << "NO" << endl;
			return 0;
		}	
	}
	
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		
		// 計算
		String result = "";
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < s.length(); i++){
		    char c = s.charAt(i);
		    if(c == 'B' && sb.length() > 0){
		        sb.deleteCharAt(sb.length()-1);
		    }else if(c != 'B'){
		        sb.append(c);
		    }
		}
		result = sb.toString();
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}



Measured memory_bytes: 25340
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

#define FOR(i,m,n) for(int i=(m); i<(n); i++)
#define REP(i,n) for(int i=0; i<(n); i++)
#define RFOR(i,n,m) for(int i=(n);i>=(m); i--)
#define RREP(i,n) for(int i=(n-1); (i)>=0; i--)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << endl
// #define int long long 

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = 100100100;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct mint 
{
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int dp[n];
    int h[n];
    REP(i,n) cin >> h[i];
    REP(i,n) dp[i] = 0;
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    FOR(i,2,n)
    {
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
def gcd(a, b):
    r = a % b
    if r == 0: return b
    else: return gcd(b, r)
 
def lcm(a, b):
    return a*b/gcd(a,b)
 
while True:
    try:
        x = map(int, raw_input().split(" "))
        print "%d %d" % (gcd(x[0], x[1]), lcm(x[0], x[1]))
         
    except EOFError:
        break
 

Measured memory_bytes: 4224
Module Program
  Sub Main
    Dim s=GetInts()
    Dim a=s(0)-1,b=s(1)-1
    Dim ans=a*b
    Console.WriteLine(ans)
  End Sub
  
  '/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  Function Gets() As String()
    Gets = Console.ReadLine().Split(" "c)
  End Function
  Function GetInts() As Integer()
    Dim s = Gets(), r(UBound(s)) As Integer
    For i As Integer=0 To UBound(s): r(i)=s(i): Next i
    GetInts = r
  End Function
End Module

Measured memory_bytes: 22352
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int N, K;
vector<int> Nums;
string S;

int main() {
    cin >> N >> K;
    cin >> S;
    int now = 1;
    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        if (S[i] == (char)('0' + now)) cnt++;
        else {
            Nums.push_back(cnt);
            now = 1 - now;
            cnt = 1;
        }
    }
    if (cnt != 0) Nums.push_back(cnt);

    if (Nums.size() % 2 == 0) Nums.push_back(0);

    int Add = 2 * K + 1;

    int ans = 0;
    int left = 0;
    int right = 0;
    int tmp = 0;

    for (int i = 0; i < Nums.size() ; i += 2) {
        
        int Nextleft = i;
        int Nextright = min(i + Add, (int)Nums.size());
        
        while(Nextleft > left) {
            tmp -= Nums[left];
            left++;
        }

        while(Nextright > right) {
            tmp += Nums[right];
            right++;
        }

        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

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

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}

const int N=2e5+5;

int n,m,suf[N][2],laz[N<<2],tr[N<<2];
int ans,a[N],f[N];
vector<int> po[N];

struct nood
{
	int l,r;
	inline bool friend operator < (const nood&c,const nood &d)
	{
		return c.l<d.l;
	}
};
nood c[N];

inline int min(int x,int y) 
{
	return (x>y)?y:x;
}

inline void build(int rt,int l,int r)
{
	tr[rt]=1e9;
	if(l==r) return;
	int mid=(l+r)/2;
	build(rt<<1,l,mid); 
	build(rt<<1|1,mid+1,r);
	tr[rt]=min(tr[rt<<1],tr[rt<<1|1]);
}

inline void modify(int rt,int l,int r,int pos,int val)
{
	if(l==r)
	{
		tr[rt]=min(tr[rt],val);
		return;
	}
	int mid=(l+r)/2;
	if(pos<=mid) modify(rt<<1,l,mid,pos,val);
	else modify(rt<<1|1,mid+1,r,pos,val);
	tr[rt]=min(tr[rt<<1],tr[rt<<1|1]);
}

inline int query(int rt,int l,int r,int ll,int rr)
{
	if(ll<=l&&r<=rr) return tr[rt];
	int mid=(l+r)/2;
	int ret=1e9;
	if(ll<=mid) ret=min(ret,query(rt<<1,l,mid,ll,rr));
	if(rr>mid) ret=min(ret,query(rt<<1|1,mid+1,r,ll,rr));
	return ret;
}

signed main()
{
	n=read();
	for ( int i=1;i<=n;i++ ) 
	{
		int x=read();
		a[i]=x;
		suf[i][0]=suf[i-1][0]+(x==0);
		suf[i][1]=suf[i-1][1]+(x==1);
	}
	memset(f,127/3,sizeof(f));
	m=read();
	for ( int i=1;i<=m;i++ ) c[i]=(nood){read(),read()};
	sort(c+1,c+m+1);
	for ( int i=1;i<=m;i++ ) po[c[i].l].push_back(c[i].r);
	f[0]=0;
	build(1,1,n);
	for ( int i=1;i<=n;i++ ) 
	{
		for ( int j=0;j<po[i].size();j++ )
		{
			int r=po[i][j];
			int mi=f[i-1];
			mi=min(mi,query(1,1,n,max(i-1,1),r));
			if(mi<f[r])
			{
				f[r]=mi;
				modify(1,1,n,r,mi);
			}
		}
		f[i]=min(f[i],f[i-1]+((a[i]==1)?1:-1));
	}
	printf("%d\n",f[n]+suf[n][0]);
	return 0;
}

	
			 

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

using namespace std;

int n;
vector<int> E[200010], F[200010];
int cE[200010], cF[200010];

map<pair<int, int>, int> mp;

void dfs(int u, vector<int> M[], int c[], int group) {
    c[u] = group;
    for (int v : M[u]) {
        if (!c[v]) {
            dfs(v, M, c, group);
        }
    }
}

void makeGroup(int m, vector<int> M[], int c[]) {
    int x, y;
    for (int i = 0; i < m; i++) {
        cin >> x >> y;
        M[x].push_back(y);
        M[y].push_back(x);
    }

    int group = 1;
    for (int i = 1; i <= n; i++) {
        if (c[i]) continue;
        dfs(i, M, c, group);
        group++;
    }
}

int main() {
    int k, l;
    cin >> n >> k >> l;

    makeGroup(k, E, cE);
    makeGroup(l, F, cF);

    for (int i = 1; i <= n; i++) {
        mp[{cE[i], cF[i]}]++;
    }

    for (int i = 1; i <= n; i++) {
        cout << mp[{cE[i], cF[i]}] << ' ';
    }
}


Measured memory_bytes: 27904
use std::collections::HashSet;
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let K: usize = read();
    let mut num: Vec<u64> = vec![0; K];

    let mut ans = 0;
    for i in 1..=N {
        num[i % K] += 1; // num[x] = 1以上N以下に対して、Kで割ってx余る数が何個あるか
                         // 余りの範囲は0～(K-1)
    }
    //a,b,cを余りで考えて、一意に全探索する。
    //そして、その余りをとりうる個数（num[]）を掛けることで、組み合わせの個数を求める。
    for a in 0..K {
        let b = (K - a) % K;
        let c = (K - a) % K;
        if (b + c) % K != 0 {
            continue;
        }
        ans += num[a] * num[b] * num[c];
    }
    /* TLE全探索 O(N^3)
    for a in 1..=N{
        for b in 1..=N{
            for c in 1..=N{
                if (a+b)%K == 0
                && (b+c)%K == 0
                && (c+a)%K == 0{
                    ans += 1;
                }
            }
        }
    }
    */
    println!("{}", ans);
}


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


int main(void)
{
    int *data;
    int n, i, j;
    int swapped;
    int mini;
    int temp;

    scanf("%d", &n);
    data = malloc(n * sizeof(int));

    swapped = 0;
    for (i = 0; i < n; i++) scanf("%d", &data[i]);

    for (i = 0; i < n; i++){
        mini = i;
        for (j = i; j < n; j++){
            if (data[j] < data[mini]){
                mini = j;
            }
            
        }
        temp = data[i];
        data[i] = data[mini];
        data[mini] = temp;
        if (i != mini) swapped++;
    }

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

    printf("%d\n", swapped);
    free(data);
    return (0);
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
#define ll long long 
#define P pair<int,int>
#define PP pair<P,int>
using namespace std;
int inf = 1ll << 30;

int main(){
    int x, n;
    cin >> x >> n;

    P ans;
    ans.first = inf;
    ans.second = -1;

    vector<int> vec(201,0);

    for(int i=0;i<n;i++){
        int p; cin >> p;
        vec[p]++;
    }

    for(int i=-100;i<=201;i++){
        if(((i<0) || (vec[i] == 0)) &&(abs(i-x) < ans.first)){
            ans.first = abs(i-x);
            ans.second = i;
        }
    }

    cout << ans.second << endl;
}


Measured memory_bytes: 3624
ops = {"+": lambda a, b: b + a,
       "-": lambda a, b: b - a,
       "*": lambda a, b: b * a}
def f(stack, s):
    if s in ops:
        stack.append(ops[s](stack.pop(), stack.pop()))
    else:
        stack.append(int(s))
    return stack

print reduce(f, raw_input().split(), [])[-1]
    

Measured memory_bytes: 4304
#include <iostream>

using namespace std;
int p[10001],price,c;

int main()
{
    int n,k;
    cin>>n>>k;
    for (int i=0; i<n; i++) {
        cin >> price;
        p[price]++;
    }
    price=0;
    while (k!=0){
        price++;
        for (;p[price]!=0; p[price]--,c+=price,k--)
            if (k==0)
                break;
    }
    cout<<c;
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    string s, t;
    cin >> s;
    cin >> t;
    ll n = t.size();
    s += t[n-1];
    if(s == t) Yes();
    else No();
}

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

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    string w;
    cin >> w;
    
    string ans = "Yes";
    for (int i = 'a'; i <= 'z'; ++i) {
        if (count(w.begin(), w.end(), i) % 2 == 1) ans = "No";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long dp[2020][2020];
int main() {
    int n; cin >> n;
    int a[n]; 
    int p[n]; 	
  for (int i=0;i<n;i++) 
	{
		cin >> a[i];
		p[i]=i;
	}
    sort(p, p + n, [&] (int x, int y) {
        return a[x] > a[y];
    });
    for (int i = 0; i < n; i++) {
        for (int j = 0; i + j < n; j++) {
            int k = i + j;
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + 1LL * a[p[k]] * abs(p[k] - i));
            dp[i][j + 1] = max(dp[i][j + 1], dp[i][j] + 1LL * a[p[k]] * abs(p[k] - (n - 1 - j)));
        }
    }
    long long ans = 0;
    for (int i = 0; i <= n; i++) 
        ans = max(ans, dp[i][n - i]);
    cout << ans;
}

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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;

const int MOD = 1000000007;

signed main(){
	int n, m; cin >> n >> m;
	vector<int> a(m);
	for(auto &e : a)cin >> e;
	vector<int> dp(n+1,0);
	for(auto e : a)dp[e] = -1;
	dp[0] = 1;
	for(int i = 0; i < n; i++){
		if(dp[i] == -1)continue;
		if(dp[i+1] != -1)dp[i+1] = (dp[i+1] + dp[i]) % MOD;
		if(i+2 != n+1){
			if(dp[i+2] != -1)dp[i+2] = (dp[i+2]+dp[i])%MOD;
		}
	}
	cout << dp[n] << endl;
		

	return 0;
}



Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
 
public class Main {
 
    private static final int BIG_NUM  = 2000000000;
    private static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input_str[] = new String[2];
 
        Set<String> Dictionary = new HashSet<String>();
        StringBuilder ans = new StringBuilder();
 
        try {
            int Q = Integer.parseInt(br.readLine());
 
            for(int loop = 0; loop < Q; loop++){
 
                input_str = br.readLine().split("\\s+");
 
                if(input_str[0].equals("insert")){
                    Dictionary.add(input_str[1]);
                }else{ //find
                    if(Dictionary.contains(input_str[1])){
                        ans.append("yes\n");
                    }else{
                        ans.append("no\n");
                    }
                }
            }
 
            System.out.print(ans.toString());
 
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 323852
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

int N;
int x[200010];
int y[200010];
int k;

int main(){
	scanf("%d" , &N);
	for(int i = 0 ; i * 3 < N - 1 ; ++i){
		for(int j = i % 2 ; j < N ; j += 2){
			x[k] = 3 * i + 1;
			y[k] = j;
			++k;
		}
	}
	if(N%3==1){
		for(int j = N % 2 ; j < N ; j += 2){
			x[k] = N-1;
			y[k] = j;
			++k;
		}
	}
	for(int i = 1 ; i * 3 - 1 < N ; ++i){
		x[k] = i * 3 - 1;
		y[k] = i%2;
		++k;
	}
	printf("%d\n" , k);
	repp(i,0,k){
		printf("%d %d\n" , x[i] , y[i]);
	}
	return 0;
}


Measured memory_bytes: 2688
#include <cstdio>
using namespace std;
int main(void){
	int m,d,i,j,d1,d10,cnt=0;
	scanf("%d%d",&m,&d);
	for(i=1;i<=m;i++){
		for(j=1;j<=d;j++){
			d1=j%10; d10=j/10;
			if(d1>=2&&d10>=2&&d1*d10==i){
				cnt++;
			}
		}
	}
	printf("%d",cnt);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
As = []
Bs = []
for i in range(N):
  A, B = map(int, input().split())
  As.append(A)
  Bs.append(B)
As.sort()
Bs.sort()
if N%2 == 1:
  A = As[N//2]
  B = Bs[N//2]
  r = B-A+1
else:
  A = As[(N-1)//2]+As[N//2]
  B = Bs[(N-1)//2]+Bs[N//2]
  r = B-A+1
print(r)


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
     cout << "Bad" << endl;
    else
     cout <<  "Good" << endl;
    return 0;
}


Measured memory_bytes: 256
//#define __popcnt __builtin_popcount
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define sz(a) ((int)(a).size())
#define all(n) (n).begin(),(n).end()
#define clr(v,val) memset(v , val , sizeof v)
#define EPS 1e-9
#define OO 1e9
#define PI acos(-1.0)
#define ll long long
#define endl "\n"

void file(){
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
}
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
}


ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int dx[] = { -1, 0, 1, 0, 1, 1, -1, -1 };
int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
//473,700
//7000
const int N = 2e6 + 5, mod = 1e9 + 7;

int main()
{
	/*** بسم الله الرحمن الرحيم  ***/
	//cout << fixed << setprecision(6);
//	file();
	fast();
	int n;
	cin >> n;
	vector<ll> a1(n), a2(n);
	for (int i = 0; i < n; i++){
		cin >> a1[i];
		a2[i] = a1[i];
		if (i)a1[i] += a1[i - 1];
	}
	for (int i = n - 2; i >= 0; i--)
		a2[i] += a2[i + 1];
	ll mn = 1e18;
	for (int i = 0; i + 1 < n; i++)
		mn = min(mn, abs(a1[i] - a2[i + 1]));

	cout << mn;
	
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int S = 1;
  for(int i = 0; i < N ; i++){
    if ( S - K < 0){
       S *= 2;
    }
    else{
      S += K;
    }
   // cout << i+1 << ":" << S << endl;
  }
  cout << S << endl;
}

Measured memory_bytes: 3504
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
#define mod 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

int main() {
  int x,y,z,k;
  cin >> x >> y >> z >> k;
  vector<ll> A(x), B(y), C(z);
  rep(i, 0, x) cin >> A[i];
  rep(i, 0, y) cin >> B[i];
  rep(i, 0, z) cin >> C[i];
  sort(A.begin(), A.end(), greater<ll>());
  sort(B.begin(), B.end(), greater<ll>());
  sort(C.begin(), C.end(), greater<ll>());
  vector<ll> S;
  rep(i, 0, x) rep(j, 0, y) S.push_back(A[i] + B[j]);
  sort(S.begin(), S.end(), greater<ll>());
  vector<ll> ans;
  int len = min(x * y, 3000);
  rep(i, 0, len) rep(j, 0, z) ans.push_back(S[i] + C[j]);
  sort(ans.begin(), ans.end(), greater<ll>());
  rep(i, 0, k) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 43240
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    int n;
    scanf("%d",&n);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        string str = to_string(i);
        if (str.size() % 2 != 0) ans++;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  ll W, H, x, y;
  cin >> W >> H >> x >> y;
  double ans = (double)H*W*0.5;
  int m = 0;
  if (x*2 == W && y*2 == H) {
    m = 1;
  }
  printf("%f %d", ans, m);
  return 0;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, '%d', $N);

$results = [];

for ($i=0; $i < $N; $i++) {
    fscanf(STDIN, '%s', $result);
    if (array_key_exists($result, $results)) {
        $results[$result]++;
    } else {
        $results[$result] = 1;
    }
}

echo 'AC x ' . intval($results['AC']) . PHP_EOL;
echo 'WA x ' . intval($results['WA']) . PHP_EOL;
echo 'TLE x ' . intval($results['TLE']) . PHP_EOL;
echo 'RE x ' . intval($results['RE']) . PHP_EOL;

echo PHP_EOL;


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

int main() {
    int A, B;
    cin >> A >> B;
    if(A > B){
        cout << A + (A - 1) << endl;
    }
    else if(A < B){
        cout << B + (B - 1) << endl;
    }
    else {
        cout << A + B << endl;
    }
}

Measured memory_bytes: 256