akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();

            out.println(b - a == c - b ? "YES" : "NO");

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 22996
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		int n,c;
		String b;
		Scanner scan=new Scanner(System.in);
		n=scan.nextInt();
		int a[][]=new int[4][13];
		for(int i=0;i<n;i++)
		{
		b=scan.next();
		c=scan.nextInt();
		if(b.equals("S"))a[0][c-1]=1;
		else if(b.equals("H"))a[1][c-1]=1;
		else if(b.equals("C"))a[2][c-1]=1;
		else if(b.equals("D"))a[3][c-1]=1;}
		for(int i=0;i<4;i++) {
		for(int j=0;j<13;j++){
		if(a[i][j]==0 && i==0){
		System.out.println("S "+(j+1));}
		else if(a[i][j]==0 && i==1){
		System.out.println("H "+(j+1));}
		else if(a[i][j]==0 && i==2){
		System.out.println("C "+(j+1));}
		else if(a[i][j]==0 && i==3){
		System.out.println("D "+(j+1));}
		   }         
		} 
	}
}

Measured memory_bytes: 18068
#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 for1(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define endl '\n'
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, a, b, p[100];
	cin >> n >> a >> b;
	int cnt0 = 0, cnt1 = 0, cnt2 = 0;
	rep(i, n) {
		cin >> p[i];
		if (p[i] <= a) {
			cnt0++;
		} else if ((a < p[i]) && (p[i] <= b)) {
			cnt1++;
		} else if (b < p[i]) {
			cnt2++;
		}
	}
	int min = 10000;
	if (min > cnt0) min = cnt0;
	if (min > cnt1) min = cnt1;
	if (min > cnt2) min = cnt2;
	cout << min << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inAr ll ar[n];for(ll i=0;i<n;i++) cin>>ar[i];
#define loop for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL);
  #define endl "\n"
  #define mod int(1e9 +7)
typedef long long int ll;
using namespace std;

#define INFI LLONG_MAX
int main(){ 
int n;cin>>n;
inAr
int flag=0;
int flag1=0;
for(int i=0;i<n;i++)
{
	if(ar[i]%2==0)
	{
	flag1++;
		if(ar[i]%3==0 or ar[i]%5==0)
		{
			flag++;
		}
	}
}
if(flag==flag1)
cout<<"APPROVED";
else
cout<<"DENIED";
		
	}
	




		




	
	
	
	









   
    


Measured memory_bytes: 256
# ALDS1_2_A - Bubble Sort
def main():
    N, *A = map(int, open(0).read().split())
    ans = 0
    for i in range(N):
        for j in range(N - 1, i, -1):
            if A[j] < A[j - 1]:
                A[j], A[j - 1] = A[j - 1], A[j]
                ans += 1
    print(*A)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 5608
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int r, c;
  while (cin >> r >> c, r+c) {
    bool senbei[c][r];
    REP(i,r)
      REP(j,c)
        cin >> senbei[j][i];
    int ans = 0;
    for (int i=0; i<(1<<r); ++i) {
      int hoge = 0;
      REP(k,c) {
        int tmp = 0;
        REP(j,r)
          tmp += ((i >> j) & 1) ^ senbei[k][j];
        hoge += max(r-tmp,tmp);
      }
      ans = max(ans,hoge);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 960
a;f;j;n;s;u;v;w;C[37000];D[3001][3001];M[3001];*c=C;main(m){for(;++n%3+scanf("%d",&w);u=v,w-=v=w)for(s=2;n%3?0:s++<6e3+2?u-v|v-w||!j?*++c=u,*++c=s/3,*++c=fmax(v-w?:D[s/3][v]+1,M[s/3]),*++c=v,*++c=w,*++c=j=j?fmax(D[u][u]+1,m):1e7:++f:c>C?w=*c,v=c[~s|-2],u=c[s%2-2],c-=s%2*3,D[u][v]>w||(D[u][v]=w),M[u]>w||(M[u]=w),m=m>w?m:w:0;u=v,v=w,w=a)a=u;printf("%d",m+=f/6e3-1e7);}

Measured memory_bytes: 25684
import java.io.*;
import java.util.*;

public class Main {
	
	static int c,d,n,m;
	static int adj[][] = {{-1,0},{1,0},{0,-1},{0,1}};
	static int maj[][];
	static int board[][];
	
	static boolean legal(int x, int y) {
		if(x<0||y<0||x>=n||y>=m||board[x][y]==1) return false;
		else return true;
	}
	
	static void majGen() {
		int i=0;
		for(int x=-2;x<=2;x++) {
			for(int y=-2;y<=2;y++) {
				maj[i][0] = x; maj[i][1] = y; i++;
			}
		}
	}
	
	public static void main(String[] args) {
        FastScanner in = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        n = in.nextInt();m = in.nextInt();
        int a = in.nextInt()-1;int b = in.nextInt()-1;
        int c = in.nextInt()-1;int d = in.nextInt()-1;
        board = new int[n][m];
        maj = new int[25][2];
        majGen();
        for(int i=0;i<n;i++) {
        	char ch[] = in.next().toCharArray();
        	for(int j=0;j<m;j++) {
        		if(ch[j]=='#') board[i][j] = 1;
        	}
        }
        int dis[][] = new int[n][m];
        for(int x=0;x<n;x++) Arrays.fill(dis[x], 1_000_000_000);
        ArrayDeque<Integer> qx = new ArrayDeque<>();
        ArrayDeque<Integer> qy = new ArrayDeque<>();
        qx.add(a);qy.add(b);
        dis[a][b] = 0;
        while(!qx.isEmpty()) {
        	int curX = qx.removeFirst(), curY = qy.removeFirst();
        	for(int x[] : adj) {
        		int nx = curX+x[0], ny = curY+x[1];
        		if(legal(nx,ny)) {
        			if(dis[nx][ny]>dis[curX][curY]) {
        				dis[nx][ny] = dis[curX][curY];
        				qx.addFirst(nx);
        				qy.addFirst(ny);
        			}
        		}
        	}
        	for(int x[] : maj) {
        		int nx = curX+x[0], ny = curY+x[1];
        		if(legal(nx,ny)) {
        			if(dis[nx][ny]>dis[curX][curY]+1) {
        				dis[nx][ny] = dis[curX][curY]+1;
        				qx.addLast(nx);
        				qy.addLast(ny);
        			}
        		}
        	}
        }
        out.println((dis[c][d]==1e9)?"-1":dis[c][d]);
        out.flush();
	}
	
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		
		String next() {
			while(!st.hasMoreTokens())
				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());
		}
		
		int[] readArray(int n) {
			int a[] = new int[n];
			for(int i=0;i<n;i++) a[i] = nextInt();
			return a;
		}
		
		long[] readArray(int n,long x) {
			long a[] = new long[n];
			for(int i=0;i<n;i++) a[i] = nextLong();
			return a;
		}
		
	}
}











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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int sign(int x) { return (x > 0) - (x < 0); }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const deque<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const set<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

signed main() {
  int X,N,T;
  cin>>N>>X>>T;
  rep(i,110000)if(X*i>=N)fin(i*T);
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a;
  map<int,int> mp;
  int val;
  for(int i=0;i<n;i++){
    cin >> val;
    a.push_back(val);
    mp[val] = i;
  }
  sort(a.begin(),a.end());
  int ans = 0;
  for(int i=0;i<n;i++){
    ans += abs(mp[a.at(i)]-i)%2;
  }
  ans /= 2;
  cout << ans << endl;
}

Measured memory_bytes: 5368
#include "math.h"
#include "stdio.h"
#include <iostream>
using namespace std;

/** Problem0010 : CIrcumscribed Circle of a Triangle **/
int main()
{
	int N;
	double X1, Y1, X2, Y2, X3, Y3;
	double a, b, c, d, e, f, l, m, n;
	cin >> N;
	for (int i=0; i<N; i++) {
		cin >> X1 >> Y1 >> X2 >> Y2 >> X3 >> Y3;
		a = X1-X2; b = Y1-Y2; c = -(X1*X1+Y1*Y1-X2*X2-Y2*Y2);
		d = X2-X3; e = Y2-Y3; f = -(X2*X2+Y2*Y2-X3*X3-Y3*Y3);
		l = (c*e - b*f)/(e*a - b*d); m = (c*d - a*f)/(b*d - a*e);
		n = -(X1*X1+Y1*Y1+l*X1+m*Y1);
		printf("%.3f %.3f %.3f\n",l*-0.5,m*-0.5,sqrt(l*l+m*m-n*4.0)/2.0);
	}
	return 0;
}

Measured memory_bytes: 1244
//AtCoder Beginner Contest 175
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 1e6 + 5;
const double E = 1e-9;

//------------------------------------------------------------------------------
string s;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	/*ifstream cin("input.txt");
	ofstream cout("output.txt");*/
	cin >> s;
	s+='S';
	int ans = 0, cnt = 0;
	for (int i = 0; i < 4; i++)
	{
		if (s[i] == 'R')
			++cnt;
		else
		{
			ans = max(ans, cnt);
			cnt = 0;
		}
	}
	cout << ans << "\n";
	return 0;
}
//15-08-2020 17:32:57
//------------------------------------------------------------------------------

Measured memory_bytes: 3608
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.nextString();

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < s.length(); i++) {
                if (i % 2 == 0) sb.append(s.charAt(i));
            }

            out.println(sb.toString());
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



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

void solve(long long sx, long long sy, long long tx, long long ty){
	string dirx = "RL";
	string diry = "UD";
  string ans = "";
  int dx = sx > tx ? 1 : 0;
  int dy = sy > ty ? 1 : 0;

  for ( long long i = 0; i < abs(sx - tx); i++ ) {
    ans = ans + dirx[dx];
  }
  for ( long long i = 0; i < abs(sy - ty); i++ ) {
    ans = ans + diry[dy];
  }
  for ( long long i = 0; i < abs(sx - tx); i++ ) {
    ans = ans + dirx[!dx];
  }
  for ( long long i = 0; i < abs(sy - ty); i++ ) {
    ans = ans + diry[!dy];
  }

  ans = ans + dirx[!dx];
  for ( long long i = 0; i < abs(sy - ty) + 1; i++ ) {
    ans = ans + diry[dy];
  }
  for ( long long i = 0; i < abs(sx - tx) + 1; i++ ) {
    ans = ans + dirx[dx];
  }
  ans = ans + diry[!dx];
  ans = ans + dirx[dx];
  for ( long long i = 0; i < abs(sy - ty) + 1; i++ ) {
    ans = ans + diry[!dy];
  }
  for ( long long i = 0; i < abs(sx - tx) + 1; i++ ) {
    ans = ans + dirx[!dx];
  }
  ans = ans + diry[dx];

  cout << ans << endl;

}

int main(){	
	long long ty;
	long long tx;
	long long sx;
	long long sy;
	scanf("%lld",&sx);
	scanf("%lld",&sy);
	scanf("%lld",&tx);
	scanf("%lld",&ty);
	solve(sx, sy, tx, ty);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_pair tree<pair<int,int>,null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_mutiset tree<int,null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> pi; 
#define PI 3.1415926535897932384
#define FOR(i,vv,n) for(int i=vv;i<n;i++)
#define FORR(i,n,vv) for(int i=n-1;i>=vv;i--)
#define ve vector 
#define maxind(v) (max_element(v.begin(),v.end())-v.begin())
#define minind(v) (min_element(v.begin(),v.end())-v.begin())
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007ll
#define INF 1000000000000000000ll
#define PRECISE cout.precision(18);
#define all(v) v.begin(),v.end()
#define BS(v,n) binary_search(all(v),n)
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(all(v),greater <ll>())
#define uni(v) v.resize(unique(all(v))-v.begin())
#define F first
#define S second
#define GET(i,p) get<p>(i)

ll maxn=365;
ll d=0;
ve <ll> c(26);
ve <ve <ll>> v(maxn,ve <ll> (26));
ve <ll> last(26,-1);
ve <ll> assigned(maxn,-2);
ll ini=0;
//ll a[26][365][2];

ll score(){
	ll sats=0;
	FOR(i,0,d){
	FOR(j,0,26){
		sats-=c[j]*(i-last[j]);
	 }
	ll take=assigned[i];
	sats+=v[i][take]+c[take]*(i-last[take]);
	last[take]=i;
	//cout<<sats<<"\n";
}
return sats;
}

pair <ll,ll> fun1(ll da,ll q){

ll x1=-1,x2=d;
FORR(i,da,0)
if(assigned[i]==q){
	x1=i;
	break;
}
FOR(i,da+1,d)
if(assigned[i]==q){
	x2=i;
	break;
}
return make_pair(x1,x2);
}

ll modify(ll da,ll q){
pair <ll,ll> a1=fun1(da,assigned[da]);
pair <ll,ll> a2=fun1(da,q);
ll z=ini;
ll f=assigned[da];
z-=v[da][f];
z-=c[f]*(da-a1.F)*(a1.S-da);
z+=v[da][q];
z+=c[q]*(da-a2.F)*(a2.S-da);
return z;
}

void change(ll da,ll q){
 	assigned[da]=q;
}





int main(){
	

    FAST
//	PRECISE


cin>>d;
FOR(i,0,26)
cin>>c[i];



FOR(i,0,d)
	FOR(j,0,26)
		cin>>v[i][j];
set <tuple <ll,ll,ll>,greater <tuple<ll,ll,ll>> > s;
FOR(i,0,d){
FOR(j,0,26)
s.insert({v[i][j]-c[j]*10,i,j});
} 


ve <ll> dummy(d);
FOR(i,0,d){
dummy[i]=rand()%26;
}
assigned=dummy;
ini=score();


while(!s.empty()){
	ll x1=GET(*s.begin(),1);
	ll x2=GET(*s.begin(),2);
	ll z=modify(x1,x2);
	if(z>ini){
		ini=z;
		change(x1,x2);
	}
	s.erase(s.begin());
}


ll it=1000000;
while(it>0){
	it--;
	ll x1=rand()%d;
	ll x2=rand()%26;
	x1=rand()*x1;x2=rand()*x2;
	x1%=d;x2%=26;
	ll z=modify(x1,x2);
	if(z>ini){
		ini=z;
		change(x1,x2);
	}
}

FOR(i,0,d)
cout<<assigned[i]+1<<"\n";




return 0;
 }

Measured memory_bytes: 4324
*s, = input()
*t, = input()

dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]

for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j] + 1
        else:
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])

ans = ""

i, j = len(s), len(t)
while i > 0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans = s[i-1] + ans
        i -= 1
        j -= 1

print(ans)


Measured memory_bytes: 112988
#include <stdio.h>
int main(void){
	int n,m;
	char s[100001],t[100001];
	scanf("%d %d",&n,&m);
	scanf("%s",&s);
	scanf("%s",&t);
	int a,b,c;
	if(n>m){
		a=n;
		b=m;
	}else{
		a=m;
		b=n;
	}
	while(1==1){
		c=a%b;
		if(c==0){
			break;
		}
		a=b;
		b=c;
	}
	long long int ans;
	ans = 1;
	ans = ans*n/b*m;

	int i;
	for(i=0;i<b;i++){
		if(s[(n/b)*i]!=t[(m/b)*i]){
			ans = -1;
			break;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int a[105];
int main(){
	int N;
	int ans = 1000000000;
	scanf("%d",&N);
	for(int i = 1; i <= N; i++){
		scanf("%d",&a[i]);
	}
	for(int i = -100; i <= 100; i++){
		int cost = 0;
		for(int j = 1; j <= N; j++){
			cost += (a[j]-i) * (a[j]-i);
		}
		ans = min(ans,cost);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define max4(a,b,c,d) max(max(a,d),max(b,c))
#define MAX   1e9
#define MIN  -1e9
#define PI 3.14159265358979
#define eps 1e-9
typedef map<int,int> mpi;
typedef set<int> seti;
typedef multiset<int> mseti;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(long long int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(long long int i = a; i >= (n); --i)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define trav(a, x) for(auto& a : x)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl
#define inp(a,start,len) for(long long int i = start;i < len;i++) cin>>a[i]
struct Interval{ll start,end;};
bool compare(Interval i1, Interval i2) {return (i1.start < i2.start);}

ll vis[100001];

int main(){
	fio;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ll T = 1;
	// cin>>T;
	while(T--){
		ll n,x,m;
		cin>>n>>x>>m;
		ll getFirst = -1;
		ll nx = x;
		vis[x] = 1;
		while(getFirst == -1){
			x = (x*x)%m;
			if(vis[x])
				getFirst = x;
			vis[x] = 1;
		}
		ll ans = 0;
		ll used = 0;
		ll cycleLength = 1;
		x = nx;
		while(x!=getFirst){
			ans = (ans+x);
			used++;
			x = (x*x)%m;
		}
		n = n - used;
		x = getFirst;
		ll reached = 0;
		ll prefix[m+1];
		prefix[0] = 0;
		prefix[1] = x;
		while(!reached){
			x = (x*x)%m;
			if(x == getFirst){
				reached = 1;
				break;
			}
			cycleLength++;
			prefix[cycleLength] = (prefix[cycleLength-1] + x);
		}
		ll rot = n/cycleLength;
		ans = ans + rot*prefix[cycleLength];
		n = n%cycleLength;
		ans = ans + prefix[n];
		cout<<ans;
	}
	return 0;
}


Measured memory_bytes: 4816
import java.io.*;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader bf =new BufferedReader(new InputStreamReader(System.in));
		String t;
		int w,f;
		while((t=bf.readLine())!=null){
			w=Integer.parseInt(t);
			f=0;
			for(int i=0;i<10;i++)if((w>>>i&1)==1){System.out.print(((f==0)?"":" ")+(int)(1<<i));f++;}System.out.print("\n");
		}
	}
}

Measured memory_bytes: 8804
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a,b,c = LI()
    ans = 10 ** 5
    ans = min(ans, a + b)
    ans = min(ans, a + c)
    ans = min(ans, c + b)
    print(ans)
    return

#B
def B():
    n = II()
    w = LI()
    ans = inf
    for i in range(n):
        ans = min(ans, abs(sum(w[:i]) - sum(w[i:])))
    print(ans)
    return

#C
def C():
    n, m = LI()
    a = IR(m)+[inf]
    dp = [0] * (n + 3)
    dp[0] = 1
    for i in range(n + 1):
        if a[bisect_left(a, i + 1)] != i + 1:
            dp[i + 1] += dp[i] % mod
        if a[bisect_left(a, i + 2)] != i + 2:
            dp[i + 2] += dp[i] % mod
    print(dp[n] % mod)
    return

#D
def D():
    return


#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 49116
#include <iostream>
#include <vector>

using namespace std;

void abc_160a();

void abc_161a();

int main()
{
  //abc_160a();
  abc_161a();

}

void abc_160a()
{
  string S;
  cin >> S;

  if (S[2] == S[3] && S[4] == S[5]) cout << "Yes\n";
  else cout << "No\n";
}

void swap(int& a, int& b)
{
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
}

void abc_161a()
{
  int x, y, z;
  cin >> x >> y >> z;

  swap(x, y);
  swap(x, z);

  cout << x << " " << y << " " << z << "\n";
}


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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define INF (1 << 30)

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

const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int main() {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	printf("%s\n", (b - a == c - b) ? "YES" : "NO");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

void dfs(int cur,int num, int N, string s){
  if(cur==N){
    cout << s << endl;
    return ;
  }
  rep(i,num){
    string t;
    t.push_back('a'+i);
    if(i==num-1)dfs(cur+1,num+1,N,s+t);
    else dfs(cur+1,num,N,s+t);
  }
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  dfs(0,1,N,"");
  return 0;
}


Measured memory_bytes: 1536
A, B, C, D = map(int, input().split())

# aとbの小公倍数を返す関数
def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b) #再帰定義
    
#B以下のCの倍数の個数
div_c = int(B//C)
#B以下のDの倍数の個数
div_d = int(B//D)
#B以下のC,Dの倍数の個数
mygcd = gcd(C, D)#C,Dの最大公約数
l = int((C*D)//mygcd) #C,Dの最少公倍数
div_gcd = int(B//l)
myansB = B - div_c -div_d + div_gcd

#A以下のCの倍数の個数
div_cA = int((A-1)//C)
#B以下のDの倍数の個数
div_dA = int((A-1)//D)
#B以下のC,Dの倍数の個数
div_gcdl = int((A-1)//l)
myansA = A-1 - div_cA - div_dA + div_gcdl

print(myansB-myansA)




Measured memory_bytes: 3064
import math

a, b, h, m = map(int, input().split())

hour = h * (360 / 12) + m * (1/2)
mini = m * (360 / 60)
dig = hour - mini
dig = dig if dig < 180 else 360 - dig
# print('dig', dig)

c = (a**2 + b**2) - (2*a*b*math.cos(math.radians(dig)))
print(math.sqrt(c))

Measured memory_bytes: 9512
#include <stdio.h>
#include <map>
#include <algorithm>
#include <math.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;

#define MP(x,y) make_pair(x,y)

const ll INF = 1LL<<60;

struct SegTree{
	ll data[1<<25];
	int s;
	void Initialize(pll* d,int len){
		s=1;
		while(s<len)s<<=1;
		for(int i=0;i<len;i++)
			data[s+i] = d[i].second;
		for(int i=len;i<s;i++)
			data[s+i] = -INF;
		for(int i=s-1;i>=1;i--)
			data[i] = max(data[i*2],data[i*2+1]);
	}
	ll _rmq(int b,int e,int l,int r,int i){
		if(r<=b || e<=l)
			return -INF;
		if(b<=l && r<=e)
			return data[i];
		return max(_rmq(b,e,l,(l+r)/2,i*2),_rmq(b,e,(l+r)/2,r,i*2+1));
	}
	ll RMQ(int b,int e){
		if(e<=b)
			return -INF;
		return _rmq(b,e,0,s,1);
	}
};
SegTree seg;

void Calc(pll* ds,ll* vs,ll* ps,int l,int s){
	struct cc{
		pll* dest;
		ll* vals;
		ll* pres;
		int len;
		void _calc(int c,int idx,ll v,ll p){
			if(c == len)
				dest[idx] = MP(v,p);
			else{
				_calc(c+1,idx*3,v-vals[c],p-pres[c]);
				_calc(c+1,idx*3+1,v+vals[c],p+pres[c]);
				_calc(c+1,idx*3+2,v,p);
			}
		}
	};
	cc c = cc{ds,vs,ps,l};
	c._calc(0,0,0,0);
	
	sort(ds,ds+s);
}

pll avp[1<<24],bvp[1<<24];

int power3(int k){
	if(k==0)
		return 0;
	else if(k==1)
		return 3;
	else
		return 3*power3(k-1);
}

int main(){
	int n;
	ll d;
	scanf("%d%lld",&n,&d);
	ll vals[30];
	ll pres[30];
	
	for(int i=0;i<n;i++)
		scanf("%lld%lld",vals+i,pres+i);
	
	int size1 = power3(n-n/2);
	int size2 = power3(n/2);
	
	Calc(avp,vals+n/2,pres+n/2,n-n/2,size1);
	Calc(bvp,vals,pres,n/2,size2);
	
	seg.Initialize(bvp,size2);
	int l=0;
	int r=0;
	ll ans=0;
	for(int i=size1-1;i>=0;i--){
		if(abs(avp[i].first)<=d)
			ans = max(ans,avp[i].second);
		while(l<size2 && bvp[l].first + avp[i].first < -d) l++;
		while(r<size2 && bvp[r].first + avp[i].first <= d) r++;
		ans = max(ans,avp[i].second+seg.RMQ(l,r));
	}
	
	printf("%lld\n",ans);
}

Measured memory_bytes: 787452
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#include<math.h>
using namespace std;
int main(){
   string s;
   while(cin>>s){
   	string ss=s;
   	reverse(s.begin(),s.end());
   	int flag=0;
   	for(int i=0;i<s.length();i++){
   		if(s[i]!=ss[i]){
   			flag=1;
		   }
	   }
	   if(flag==0) cout<<"Yes"<<endl;
	   else cout<<"No"<<endl;
   }
   return 0; 
} 

Measured memory_bytes: 256
n = int(input())
aa = list(sorted(map(int, input().split())))
x = max(aa)
y = aa[0]
for i in range(1, n - 1):
    if abs(x / 2 - y) > abs(x / 2 - aa[i]):
        y = aa[i]
print("{} {}".format(x, y))


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi p(n);
    rep(i, n) cin >> p[i];
    int ans = 0;
    for (int i=0; i<n-2; ++i) {
        if (p[i] < p[i+1] && p[i+1] < p[i+2]) ++ans;
        if (p[i] > p[i+1] && p[i+1] > p[i+2]) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Mon Sep  7 22:04:16 2020

@author: liang
"""

N = int(input())
A = [int(x) for x in input().split()]
d = [0]*N

for a in A:
    d[a-1] += 1
#print(d)
score = 0
for  a in d:
    score += a*(a-1)//2
#print(score)
for a in A:
    print(score - d[a-1] + 1)

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

using namespace std;

int main(){
	
	int d,n;
	
	cin >> d >> n;
	
	if(n==100) n+=1;
	
	for(int i= 0;i<d;i++) n*=100;
	
	cout << n << endl;
	
	return 0;
	
}

Measured memory_bytes: 256
/*
* @Author: wxyww
* @Date: 2020-03-15 20:59:58
* @Last Modified time: 2020-03-15 21:17:16
*/
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int N = 1010;
#define pi pair<int,int>
ll read() {
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9') {
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
int d[N],x[N],y[N];
int main() {
	int n = read();
	int cnt1 = 0,cnt0 = 0;
	for(int i = 1;i <= n;++i) {
		x[i] = read(),y[i] = read();
		if((x[i] + y[i]) & 1) cnt1++;
		else cnt0++;
		if(cnt0 && cnt1) {
			puts("-1");return 0;
		}
	}
	int m = 0;
	for(int i = 30;i >= 0;--i) d[++m] = 1 << i;

	if(cnt0) d[++m] = 1;

	printf("%d\n",m);
	for(int i = 1;i <= m;++i) printf("%d ",d[i]);
	puts("");
	for(int i = 1;i <= n;++i) {
		for(int j = 1;j <= m;++j) {
			if(abs(x[i]) > abs(y[i])) {
				if(x[i] > 0) {x[i] -= d[j];	printf("R");}
				else {x[i] += d[j];printf("L");}
			}
			else {
				if(y[i] > 0) {y[i] -= d[j];printf("U");}
				else {y[i] += d[j];printf("D");}
			}
		}
		// printf("%d %d\n",x[i],y[i]);
		puts("");
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<iosfwd>
#include<sstream>
#include<math.h>
#define N 100
using namespace std;
int main(){
    long long k,a,b;
    long long bis=1;
    cin >> k >> a >> b;
    // ・1使い、bisを+1
    // ・2使い、bisを+(b-a) :最低aまい必要
    if((b-a)<=2){ cout << bis+k << endl;}
    else{
        int h= a-1; //最低でもこの回数叩かないと
        if(k<=h) cout << bis+k << endl;
        else{
            if((k-h)%2== 1) h++;
            // cout << (b-a) << endl;
            // cout << ((k-h)/2) << endl;
            // cout << (b-a)*((k-h)/2) << endl;
            long long t= bis+h+(b-a)*((k-h)/2);
            cout << t << endl; 
        }
    }
    

}

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

N, W = map(int, input().split())
vs = []
ws = []
for i in range(N):
    v, w = map(int, input().split())
    vs.append(v)
    ws.append(w)

dp = dict()
dp[0] = 0
max_v = 0
for i in range(N):
    tmp = dp.copy()
    for k, v in tmp.items():
        dp.setdefault(k+vs[i], float('inf'))
        dp[k+vs[i]] = min(v + ws[i], dp[k+vs[i]])
        if dp[k+vs[i]] <= W:
            max_v = max(max_v, k+vs[i])

#print(dp)
print(max_v)


Measured memory_bytes: 6972
import java.util.*;
import java.lang.*;
 
 //O(100000000)
public class Main {
    public static void main(String[] args) {

        Scanner sc  = new Scanner(System.in);

        int cnt = 0;

        long N = Long.parseLong(sc.next());

        long A; 
        long B;
        long C=0;
        long D=1000000001;
            //   10000000000
        
        for(int i=0;i<N;i++){
         A = Long.parseLong(sc.next());
         B = Long.parseLong(sc.next());
         C = Math.max(C,A);
         D = Math.min(D,B);
          
        }
        

        System.out.print(C+D);
        System.out.println();
    }

}

Measured memory_bytes: 50936
def B():
    # M: 01 ~ 12, Y: 00 ~ 99
    S = input()
    ans = ['YYMM','MMYY','AMBIGUOUS','NA']
    YYMM = False
    MMYY = False
    AMB = False
    NA = False
    
    Sxx__ = S[0] + S[1]
    S__xx = S[2] + S[3]
    M = [str(i) if i >9 else '0' + str(i) for i in range(1,13)]
    Y = [str(i) if i >9 else '0' + str(i) for i in range(0,99)]
    if Sxx__ in M and S__xx in Y:
        MMYY = True
    if Sxx__ in Y and S__xx in M:
        YYMM = True

    if YYMM is True and MMYY is True:
        print(ans[2])
    elif YYMM is False and MMYY is False:
        print(ans[3])
    elif YYMM is True:
        print(ans[0])
    elif MMYY is True:
        print(ans[1])
        
 
if __name__ == '__main__':
    B()

Measured memory_bytes: 3064
#include <bits/stdc++.h> 
    #include<ext/pb_ds/assoc_container.hpp> 
    #include<ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    using namespace std;
    template <typename T>
    using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
    #define int long long  
    typedef long double ld;
    #define pb push_back
    #define f(i,a,b) for(int i=a;i<b;i++)
    #define fd(i,a,b) for(int i=a-1;i>=b;i--)
    #define pf push_front
    #define fi first
    #define se second
    #define INF 1e10
    const double pi=3.14159265358979323;
    const int mod=998244353;
 /*   int gcd(int a, int b) 
    { 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
    } 
    void swap(int a,int b)
    {
      int temp=a;
      a=b;
      b=temp;
    } 
    int  binpow(int  a,int  b) 
    {
    int res = 1;
    while (b > 0) {
        if (b%2 == 1)
            res = (res * a)%mod;
        a = (a* a)% mod;
        b >>= 1;
    }
    return res;
}
    int modinv(int y)
    {
        return binpow(y,mod-2);
    }

    int fact[500000+5];
    void precal()
    {
    fact[0]=1;
    for(int i=1;i<500000+5;i++)
    {
        fact[i]=(i*fact[i-1])%mod;
    }
}*/
int mm[1000000+5]={};
    signed main() {

 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    #ifndef ONLINE_JUDGE
      if(fopen("INPUT.txt","r"))
      {
      freopen ("INPUT.txt" , "r" , stdin);
      freopen ("OUTPUT.txt" , "w" , stdout); 
      }
    #endif  
    // -------------------------------------Code starts here--------------------------------------------------------------------- 
    int t=1; 
    //cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int a[n];
        
        f(i,0,n)
        {
            cin>>a[i];
            mm[a[i]]++;
        }
        int cnt=0;
        f(i,0,n)
        {
            bool flag=true;
            for(int j=2;j<=sqrt(a[i]);j++)
            {
                if(a[i]%j==0)
                {
                    if(mm[j]>0 || mm[a[i]/j]>0)
                        flag=false;
                }
            }
            if(mm[1]>0 && a[i]!=1)
                flag=false;
            if(mm[a[i]]>1)
                flag=false;
            if(flag)
                cnt++;
        }
        cout<<cnt<<endl;
    }
}


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

int main(){
  int x;
  cin >> x;
  if(x==0) cout << 1 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 3592
A,B=[int(i) for i in input().split()]
def f(x):
	a=x%4
	if a==3:
		return bin(0)
	elif a==0:
		return bin(x)
	elif a==1:
		return bin(1)
	elif a==2:
		return bin(x+1)
res=[]
A=f(A-1)
B=f(B)
for i,j in zip(A[-1:1:-1],B[-1:1:-1]):
	if i==j:
		res.append('0')
	else:
		res.append('1')
if len(A)>len(B):
	p=A[0:2+abs(len(B)-len(A))]+"".join(res[::-1])
else:
	p=B[0:2+abs(len(B)-len(A))]+"".join(res[::-1])
print(int(p,0))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long x=sc.nextLong();
		long y=sc.nextLong();
		if(x-y==1 || x-y==-1 || x==y)System.out.println("Brown");
		else System.out.println("Alice");
	}
}

Measured memory_bytes: 25684
// AOJ 0572: Card Game is Fun
// 2017.10.29 bal4u@uu

#include <stdio.h>

int a[5003], b[5003];

char buf[25105], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int la, lb, i, j, k, t, ans;

	fgets(p=buf, 16, stdin), la = getint(), p++, lb = getint();
	fgets(p=buf, 25100, stdin);
	for (i = 0; i < la; i++) a[i] = getint(), p++;
	fgets(p=buf, 25100, stdin);
	for (i = 0; i < lb; i++) b[i] = getint(), p++;

	for (ans = 0, i = 0; i < lb; i++) {
		for (k = 0, t = i, j = 0; t < lb && j < la; j++) {
			if (a[j] == b[t]) { t++; if (++k > ans) ans = k; }
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

int main() {
    int N,a,b,c,d;
    cin >> N;
    a = N % 10;
    b = N % 100 / 10;
    c = N % 1000 / 100;
    d = N / 1000;
    if (a == b && b == c) {
        cout << "Yes" << endl;
    }
    else if (b == c && c == d ){
        cout << "Yes" << endl;
    }
    else if(a == b && b == c && c == d){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import sys
N = int(input())
As = list(map(int, input().split()))

if any(a == 0 for a in As):
    print(0)
    sys.exit()

mul = 1
for a in As:
    mul *= a
    if mul > 1e+18:
        print(-1)
        sys.exit(0)
print(mul)


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/22  Problem: ABC 053 A / Link: http://abc053.contest.atcoder.jp/tasks/abc053_a  ----- */


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

	LL N; 
	cin >> N;
	string ans = (N < 1200 ? "ABC" : "ARC");
	
	
	cout << (ans) << "\n";

	return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    string s;
    cin >> s;
    int ans = s.size(), n = s.size();
    rep(i, 2) {
        int cnt = 0;
        rep(j, n) {
            if ((j%2==0) ^ (s[j]!=(char)i+'0')) ++cnt;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 636
import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer
import scala.io.StdIn._
object Main extends App {

  val Array(n, m, s, g) = readLine.trim.split(' ').map(_.toInt)
  val bus = Array.tabulate(m){i ⇒
    val Array(u, v, t, c) = readLine.trim.split(' ').map(_.toInt)
    Bus(i, u - 1, v - 1, t, t + c)
  }.sortBy(_.start)
  val busStop = Array.fill(n){ArrayBuffer[Bus]()}
  val rank = Array.fill(m){0}
  for (b ← bus) {
    busStop(b.from).append(b)
    rank(b.id) = busStop(b.from).length
  }
  val minTime = Array.fill(m){Int.MaxValue}
  minTime(busStop(s - 1).head.id) = busStop(s - 1).head.start
  val queue = mutable.PriorityQueue()(Ordering.by[(Bus, Int), Int](_._2).reverse)
  queue.enqueue((busStop(s - 1).head, busStop(s - 1).head.start))
  while (queue.nonEmpty) {
    val (current, time) = queue.dequeue()
    if (minTime(current.id) == time) {
      if (busStop(current.from).length > rank(current.id)) {
        val next = busStop(current.from)(rank(current.id))
        if (minTime(next.id) > time + next.start - current.start) {
          minTime(next.id) = time + next.start - current.start
          queue.enqueue((next, minTime(next.id)))
        }
      }
      val i = lowerBound(busStop(current.to)){_.start >= current.reach}
      if (i < busStop(current.to).length) {
        val next = busStop(current.to)(i)
        if (minTime(next.id) > time + next.start - current.reach) {
          minTime(next.id) = time + next.start - current.reach
          queue.enqueue((next, minTime(next.id)))
        }
      }
    }
  }
  println(bus.filter(_.to == g - 1).map{bus ⇒ minTime(bus.id)}.min)
  def lowerBound[T](array: ArrayBuffer[T])(predicate: T ⇒ Boolean): Int = {
    var left = 0
    var right = array.length
    while (left < right) {
      val mid = (left + right) / 2
      if (predicate(array(mid)))  right = mid
      else left = mid + 1
    }
    right
  }
  case class Bus(id: Int, from: Int, to: Int, start: Int, reach: Int)
}


Measured memory_bytes: 476412
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int n = sc.nextInt();
			final int m = sc.nextInt();
			
			if(n == 0 && m == 0){
				break;
			}
			
			List<Integer> t_list = new ArrayList<Integer>(n);
			int t_sum = 0;
			List<Integer> h_list = new ArrayList<Integer>(n);
			int h_sum = 0;
			
			for(int i = 0; i < n; i++){
				int num = sc.nextInt();
				t_list.add(num);
				t_sum += num;
			}
			
			for(int i = 0; i < m; i++){
				int num = sc.nextInt();
				h_list.add(num);
				h_sum += num;
			}
			
			int t_op = 1000000, h_op = 1000000;
			
			for(int t_num : t_list){
				for(int h_num : h_list){
					
					if(t_sum - t_num + h_num == h_sum - h_num + t_num){
						if(t_op + h_op > t_num + h_num){
							t_op = t_num;
							h_op = h_num;
						}
					}
					
					
				}
			}
			
			if(t_op > 100 && h_op > 100){
				System.out.println(-1);
			}else{
				System.out.println(t_op + " " + h_op);
			}
			
		}
		
	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

int main(int argc, char const *argv[])
{
    ll n, x;
    cin >> n >> x;
    vector<ll> v(n);
    rep(i, n) { cin >> v[i]; }
    auto tmp = v;
    ll ans1 = 0, ans2 = 0;
    rep(i, 1, n)
    {
        if (v[i - 1] + v[i] > x)
        {
            ll diff = (v[i - 1] + v[i]) - x;
            ans1 += diff;
            v[i] = max(0ll, v[i] - diff);
        }
    }
    v = tmp;
    for (int i = n - 2; i >= 0; i--)
    {
        if (v[i + 1] + v[i] > x)
        {
            ll diff = (v[i + 1] + v[i]) - x;
            ans2 += diff;
            v[i] = max(0ll, v[i] - diff);
        }
    }
    cout << min(ans1, ans2) << endl;

    return 0;
}


Measured memory_bytes: 1792