akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int X_sosu;
		int Y_legCount;

		X_sosu = scan.nextInt();
		Y_legCount = scan.nextInt();

		int tsuruCount, kameCount;

		for (tsuruCount = 0; tsuruCount <= X_sosu; tsuruCount++) {
			kameCount = X_sosu - tsuruCount;

			int nowLegCount = 2 * tsuruCount + 4 * kameCount;

			if (nowLegCount == Y_legCount) {
				System.out.println("Yes");
				return;
			}
		}

		System.out.println("No");

	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


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

 int K,A,B;
int pre(){
     ll X;
    cin >> X;
    ll money = 100;
  for(int i=0;;i++){
        if(X<=money){
            cout << i << endl;
            return 0;
        }
        money = money * 1.01;
    }
}




int main ()
{
  pre();
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

ll dp[114][114514];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, W, w;
	ll v;
	cin>>n>>W;
	REP(i, n+1){
		REP(j, 1000001){
			dp[i][j]=1e15;
		}
	}
	dp[0][0]=0;
	REP(i, n){
		cin>>w>>v;
		REP(j, 100001){
			if(j<v){
				dp[i+1][j]=dp[i][j];
			}
			else{
				dp[i+1][j]=min(dp[i][j], dp[i][j-v]+w);
			}
		}
	}
	int ans=0;
	REP(i, 100001){
		if(dp[n][i]<=W){
			ans=i;
		}
	}
	cout<<ans<<'\n';
	return 0;
}


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

using namespace std;

using ll = long long;

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

    ll n, i = 1;
    cin >> n;
    while (i * i <= n) {
        if (n < (i + 1) * (i + 1)) break;
        ++i;
    }
    cout << i * i << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    string s;
    cin >> s;
    if(s.back() == 's') cout << s << "es\n";
    else cout << s << "s\n";
    return 0;
}

Measured memory_bytes: 3628
k = int(input())
hp = [i for i in range(k+4)]
r, w = 1, 10
while w <= k:
  n = hp[r]
  r += 1
  nm = n % 10
  val = n * 10 + nm
        
  if nm != 0:
    hp[w] = val - 1
    w += 1
  hp[w] = val
  w += 1
  if nm != 9:
    hp[w] = val + 1
    w += 1

print(hp[k])

Measured memory_bytes: 13864
def main():
    N, W = map(int, input().split())
    dp = [[0]*(W + 1) for _ in range(N+1)]
    for i in range(1, N+1):
        w, v = map(int, input().split())
        for j in range(W + 1):
            if j - w < 0:
                dp[i][j] = dp[i-1][j]
            else:
                dp[i][j] = max([
                    dp[i-1][j-w] + v, #i番目を入れる
                    dp[i-1][j] #i番目を入れない
                ])
    print(max(dp[-1]))


if __name__ == '__main__':
    main()


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


int main()
{
    int a,b,n,i,j,k,cnt=0,mx=0;
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}







Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;


void dfs(vector<string>& matrix, int n, int m, int x, int y, const char t) {
    if(x < 0 || x >= n || y < 0 || y >= m || matrix[x][y] != t) return;
    matrix[x][y] = 'x';
    dfs(matrix, n, m, x-1, y, t);
    dfs(matrix, n, m, x+1, y, t);
    dfs(matrix, n, m, x, y-1, t);
    dfs(matrix, n, m, x, y+1, t);
}

void solve(vector<string>& matrix, int n, int m) {
    int count = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            if(matrix[i][j] != 'x') {
                dfs(matrix, n, m, i, j, matrix[i][j]);
                count++;
            }
        }
    }

    cout << count << "\n";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    while(cin >> n >> m && n != 0 && m != 0) {
        vector<string> matrix(n);
        for(int i = 0; i < n; i++) {
            cin >> matrix[i];
        }
        solve(matrix, n, m);
    }
    return 0;
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int n;
lint x;
vector<lint> s, inv;
lint memo[201][100001];

long long power(long long _x, long long _n){
    long long res = 1;
    _x %= MOD;
    while(_n > 0LL){
        if(_n & 1LL){
            res *= _x;
            res %= MOD;
        }
        _x *= _x;
        _x %= MOD;
        _n >>= 1;
    }
    return res;
}

long long moddiff(long long _a, long long _b){
    long long res = _a - _b;
    if(res < 0LL){
        long long _t = (abs(res) - 1LL) / MOD + 1LL;
        res += MOD * _t;
    }
    res %= MOD;
    return res;
}

long long fact(long long _n){
    if(_n <= 1LL){
        return 1LL;
    }
    return _n * fact(_n - 1LL) % MOD;
}

lint solve(int i, lint y){
    if(i == n){
        return y;
    }
    if(memo[i][y] >= 0LL){
        return memo[i][y];
    }

    return memo[i][y] = ((solve(i + 1, y % s[i]) * inv[n - i] % MOD) + (solve(i + 1, y) * moddiff(1, inv[n - i]) % MOD)) % MOD;
}

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

    cin >> n >> x;

    s.resize(n);
    rep(i, n){
        cin >> s[i];
    }
    SORT_INV(s);

    inv.resize(n + 1);
    rep(i, n + 1){
        inv[i] = power(i, MOD - 2);
    }

    memset(memo, -1, sizeof(memo));

    lint ans = solve(0, x) * fact(n) % MOD;
    cout << ans << endl;

    return 0;
}

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

using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;

ll powmod(ll a, ll x) {
  // calculates a^x mod MOD in logarithmic time.
  ll res = 1;
  while (x > 0) {
    if (x % 2 != 0) {
      res = (res * a) % MOD;
    }
    a = (a * a) % MOD;
    x /= 2;
  }
  return res;
}

ll inversemod(ll a) {
  // calculates the modular multiplicative of a mod m.
  //(assuming MOD is prime).
  return powmod(a, MOD - 2);
}

ll ncr(ll n, ll k) {
  // calculates C(n,k) mod MOD (assuming MOD is prime).

  ll numerator = 1; // n * (n-1) * ... * (n-k+1)
  for (int i = 0; i < k; i++) {
    numerator = (numerator * (n - i)) % MOD;
  }

  ll denominator = 1; // k!
  for (int i = 1; i <= k; i++) {
    denominator = (denominator * i) % MOD;
  }

  // numerator / denominator mod MOD.
  return (numerator * inversemod(denominator)) % MOD;
}

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

  ll x, y;
  cin >> x >> y;

  if ((x + y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  ll cnt = (x + y) / 3;
  ll d = x - y;
  ll n1 = (cnt + d) / 2;
  if (n1 < 0 || n1 > cnt) {
    cout << 0 << endl;
    return 0;
  }

  cout << ncr(cnt, n1) << endl;

  return 0;
}


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

using namespace std;

using u128 = __uint128_t;

#define int long long
#define mod 1000000007

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b;
    cin>>a>>b;
    int max = 0;
    int temp = 0;
    for(int i = 0; i< a; i++){
        temp += b*(int ) pow(10, i);
    }
    if(temp > max) max = temp;
    temp = 0;
    for(int i = 0; i< b; i++){
        temp += a *(int)pow(10,i);
    }
    if(temp > max) max = temp;
    cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 256
n,w = map(int,input().split())
a = []
p = []
for i in range(n):
    k,v = map(int,input().split())
    a.append(v)
    p.append(k)

dp = []
for i in range(n+1):
    o = []
    for j in range(w+1):
        o.append(0)

    dp.append(o)


for i in range(0,n):
    for j in range(0,w+1):
        if p[i] > j:
            dp[i+1][j] = dp[i][j]

        else:
            dp[i+1][j] = max(a[i] + dp[i][j - p[i]], dp[i][j])

print(dp[n][w])

Measured memory_bytes: 143180
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long H[] = new long[N];
		int A[] = new int[N];
		for(int i = 0 ; i < N ; ++i){
			A[i] = sc.nextInt();
			A[i] = A[i] - 1;
			H[A[i]]++;
		}
		long T = 0;
		for(long h : H){
			T += h * (h - 1) / 2;
		}
		
		for(int i = 0 ; i < N ; ++i){
			int a = A[i];
			if(H[a] == 1){
				System.out.println(T);
			}else{
				long h = H[a];
				long h1 = h * (h - 1) / 2;
				long h2 = (h - 1) * (h - 2) / 2;
				System.out.println(T - h1 + h2);				
			}
		}
	}
}


Measured memory_bytes: 118468
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n, p, f = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p;
    if (p != i)
      f++;
  }
  if (f > 2)
    cout << "NO";
  else
    cout << "YES";
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int r, D, x[11]; 

	scanf("%d %d %d", &r, &D, &x[0]);

	for(int i = 0; i < 10; i++){
		x[i + 1] = r * x[i] - D;
		printf("%d\n", x[i + 1]);
	}


	return 0;
}


Measured memory_bytes: 128
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            int[] a = new int[n];
            bool[] flag = new bool[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = cin.ReadInt;
                a[i]--;
            }
            int cur = 0, cnt = 0;
            while (!flag[cur] && !flag[1])
            {
                flag[cur] = true;
                cur = a[cur];
                cnt++;
            }
            Console.WriteLine(flag[1] ? $"{cnt - 1}" : "-1");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 34688
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count=0
tot = 0
for i in range(A+1):
  for j in range(B+1):
    tot = i*500 + j*100
    
    if (X-tot)%50==0 and C>=(X-tot)//50>=0:
      count+=1
      
print(count)

Measured memory_bytes: 9184
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Comparator;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
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);
        BGuidebook solver = new BGuidebook();
        solver.solve(1, in, out);
        out.close();
    }

    static class BGuidebook {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            ArrayList<node> a = new ArrayList<>();
            HashMap<Integer, Integer> map = new HashMap<>();
            for (int i = 0; i < n; i++) a.add(new node(in.next(), in.nextInt(), i));
            Collections.sort(a, new Comparator<node>() {

                public int compare(node o1, node o2) {
                    if (o1.x.compareTo(o2.x) == 0) {
                        return o2.val - o1.val;
                    } else {
                        return o1.x.compareTo(o2.x);
                    }
                }
            });
            for (int i = 0; i < n; i++) out.println(a.get(i).indi + 1);
        }

        class node {
            String x;
            int val;
            int indi;

            node(String x, int val, int indi) {
                this.x = x;
                this.val = val;
                this.indi = indi;
            }

        }

    }

    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: 21460
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;
    int ans = 700;
    cin >> s;
    if (s[0] == 'o')
        ans += 100;
    if (s[1] == 'o')
        ans += 100;
    if (s[2] == 'o')
        ans += 100;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
count = 0
result = 0
for i in range(1, N+1):
  if i % 2 != 0:
    count = 0
    for j in range(1, i+1):
      if i % j == 0:
        count += 1
    if count == 8:
      result += 1
print(result)

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

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

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


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


int main(){
  int k,s;
  int ans = 0;
  
  cin >> k >> s;

  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
      if(s >= i + j && s-i-j <= k){
        ans++;
      }
    }
  }

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


Measured memory_bytes: 256
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

p1 = p2 = p3 = p4 = 0

for i in range(n):
    p1 += abs(x[i] - y[i])
    p2 += abs(x[i] - y[i]) ** 2
    p3 += abs(x[i] - y[i]) ** 3
    p4 = max(p4, abs(x[i] - y[i]))

p2 = p2 ** (1 / 2)
p3 = p3 ** (1 / 3)

print("%f\n%f\n%f\n%f\n" % (p1, p2, p3, p4))



Measured memory_bytes: 5640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

#define INF 0xc0c0c0c0
#define NINF 0x3f3f3f3f

#define FOR(i, a, b) for((i)=a; i<b; ++(i))
#define EFOR(i, a, b) for((i)=a; i>b; --(i))

#define MLC(n, type) (type*)malloc(n*sizeof(type))
#define CLC(n, type) (type*)calloc(n, sizeof(type))

#define MAXN 100001

void solver(char *pcStr, int nStrLen) {
	if (pcStr == nullptr || nStrLen <= 0) {
		return;
	}

	int dp[MAXN] = {0};

	int i = 0;
	int j = 0;
	int nCount = 0;

	FOR(i, 2, nStrLen) {
		j = i - 1 - dp[i-1];

		if (j == 0)
			continue;

		if (pcStr[i] != pcStr[j]) {
			nCount += 2;
			dp[i] = 2 + dp[i-1] + dp[j-1];
		}
	}

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

	return;
}

int main() {
	int i,n;
	char a[MAXN] = {0};

	scanf("%s", a+1);
	n = strlen(a+1);

	solver(a, n+1);
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(void){
	
	int a,b,c,d,e,f;
	int g,h,i,j,k,n;
	int ans;
	
	scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
	
	g = a * 1;
	
	h = b * 5;
	
	i = c * 10;
	
	j = d * 50;
	
	k = e * 100;
	
	n = f * 500;
	
	ans = g + h + i + j + k + n;
	
	if(ans >= 1000){
		ans = 1;
		}else{
			 ans = 0;
		}
	
	
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 1028
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    s = input().rstrip()
    ans = ''
    for i in range(len(s)):
        if (i+1) %2 == 1:
            ans = ans + s[i]
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3812
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid  + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k=left; k<right; k++) {
    if(L[i].value <= R[j].value) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right) {
  if(left+1 < right) {
    int mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j].value <= x.value) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if(p<r) {
    q = partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for(i=0;i<n;i++) {
    scanf("%s %d",S,&v);
    A[i].suit =  B[i].suit  = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++) {
    // マージソートとクイックソートの結果を比べる
    if(A[i].suit != B[i].suit) stable = 0;
  }

  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }

  return 0;
}


Measured memory_bytes: 4016
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(X: int):
    dp = [False] * 110000
    
    dp[0] = True
    for i in range(100001):
        if dp[i]:
            for j in range(6):
                dp[i+100+j] = True

    print(1 if dp[X] else 0)
    

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3828
// Problem : A - Kth Term
// Contest : Panasonic Programming Contest 2020
// URL : https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

/*/ Author:Amar1503/*/
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define fio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ull unsigned long long
#define ll long long
#define inf INT_MAX
#define mninf INT_MIN
#define Mod 1000000007
#define endl "\n"
#define cp(x) cout<<(x)<<" "
#define cl(x) cout<<(x)<<endl
#define ct(x,y) cout<<(x)<<" "<<(y)<<endl;
#define nl   cout<<endl
//const double PI=3.1415926535897932384626433832;
//looping
#define For(i,a,b) for(int i=a;i<b;i++)
#define test(t)  int (t); cin>>(t); while((t)--)
#define array(a,n) int (n); cin>>(n); int a[n]; for(int i=0;i<(n);i++) cin>>a[i];
#define trace(x) clog<<#x<<": "<<x<<" "<<endl
#define trace2(x,y) clog<<#x<<": "<<x<<"     "<<#y<<" "<<y<<endl
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define printv(v)  for(int i=0;i<(v).size();i++) cout<<v[i]<<" "
//containers
#define F first
#define S second
#define pb emplace_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(v) (v).begin(),(v).end()
#define mp make_pair
#define itr(it, a) for(auto it = (a).begin(); it != (a).end(); it++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ers(v)   sort(all(v)); (v).erase(unique(all(v)),(v).end())
#define printmatrix(a,n,m) for(int i=0;i<n;i++){ for(int j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
typedef vector<int> vi;
typedef vector< vector< int > > vvi;
typedef pair <int, int> pii;
typedef vector < pair <int, int> > vpii;
// cout<<"\nTime Elapsed : " << 1.0*clock() /CLOCKS_PER_SEC << " s\n";
int dx[8]={1,-1,0,0,1,1,-1,-1};
int dy[8]={0,0,1,-1,1,-1,1,-1};
//#define int long long
/*/----------------------------Code begins----------------------------------/*/
int32_t main(){
fio;
int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k;
cin>>k;
cout<<a[k-1];


}









Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main(void){
	int i=0,j=0,k=0;
	char T[10002]={NULL},*TN,buf[1001]={NULL};
	char bufW[11]={NULL},W[13]={NULL},SPACE[]=" \0",END[]={"END_OF_TEXT"};

	strcat(W,SPACE);
	gets(bufW);
	strcat(W,bufW);
	strcat(W,SPACE);
	while(1){
		gets(buf);
		if(strstr(buf,END)) break;
		strcat(T,SPACE);
		strcat(T,buf);
	}
	strcat(T,SPACE);

	while(T[i]!=NULL){
		T[i]=tolower(T[i]);
		i++;
	}
	while(W[j]!=NULL){
		W[j]=tolower(W[j]);
		j++;
	}
	TN=T;
	while((TN=strstr(TN,W))!=NULL){
		TN+=(j-1);
		k++;
	}
	printf("%d\n",k);
	return 0;
}

Measured memory_bytes: 552
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>

using namespace std;

#define PI 3.1415926535

int m[2], d[2];

int main() {
	for (int i = 0; i < 2; i++) {
	cin >> m[i] >> d[i];
    }
	if (m[0] == m[1]-1 && d[1] == 1) {
		cout << 1 << endl;
		return 0;
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll findans(ll h){
	if(h==1){
		return 1;
	}
	else return 2*findans(h/2)+1;
}
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll h;
	cin>>h;
	cout<<findans(h);
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define len(x) ((int)(x).size())
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long ll;

const ll LINF = 1e18;
const int INF = 1e9;
const int MOD = 1e9+7;

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

int main(){
	fastio;
	int n;
	cin >> n;
	vector<int> v(n+1);
	map<int, int> m;
	for(int i = 1; i <= n; i++){
		cin >> v[i];
		m[v[i]] = i;
	}	
	for(auto it = m.begin(); it != m.end(); it++){
		cout << it->second << ' ';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

int main(){
  ll k, a, b; cin >> k >> a >> b;

  ll ans = 0;
  if(b-a > 2){
    ans = a + (b-a) * ((k-a+1)/2) + ((k-a+1)%2);
  } else {
    ans = 1 + k;
  }

  cout << ans << endl;

  return 0;
}


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

int gcd( int m, int n ){
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;

	while( m != n ){
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}
int lcm( int m, int n ){
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	return ((m / gcd(m, n)) * n); 
}
int main(){
	int m, n;
	while(cin >> m >> n){
		cout << gcd(m,n) << " " << lcm(m,n) << endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
 
 
int main()
{
	int N, M, count = 0, sum = 0;
	vector<int> A;
 
	cin >> N >> M;
 
	for(int i=0; i<N; i++){
		int tmp;
		cin >> tmp;
		A.push_back(tmp);
		sum += tmp;
	}
 
	for(int i=0; i<N; i++){
		if(A[i]*(4*M) >= sum){
			count++;
		}
		if(count >= M){
			break;
		}
	}
 
	if(count >= M){
		cout << "Yes";
	}else{
		cout << "No";
	}
 
 
 
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int x,a,b;
    scanf("%d %d %d",&x,&a,&b);
    if(b<=a)
        printf("delicious\n");
    else if(b>a&&b<=a+x)
        printf("safe\n");
    else if(b>=a+x)
        printf("dangerous\n");
    return 0;
}



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

int main()
{
  string s, t;
  cin >> s >> t;

  int ans = t.size();

  for (int start = 0; start <= s.size() - t.size(); start++)
  {
    int diff = 0;
    for (int i = 0; i < t.size(); i++)
    {
      if (t.at(i) != s.at(start + i))
        diff++;
    }
    ans = min(ans, diff);
  }

  cout << ans;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define db(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define ll long long
#define ld long double
#define pll pair<ll, ll>
#define MOD 1000000007
#define FOR(i, n) for(ll i = 0; i < n; i++)
using namespace std;
const long long INF = 3*1e18;

int main() {
    ios::sync_with_stdio(0);    
    cin.tie(0);
    int x, y , z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <functional>
#include <bitset>

using namespace std;

int main()
{
	//vector< vector<int>> vec(3);
	//for (int ic = 0; ic < 3; ic++) {
	//	vec[ic] = vector<int>(2);
	//}
	//cin >> vec[0][0] >> vec[0][1];
	//cin >> vec[1][0] >> vec[1][1];
	//cin >> vec[2][0] >> vec[2][1];

	//vector<int> vec_city(4);


	vector<int> vec(6);
	cin >> vec[0] >> vec[1];
	cin >> vec[2] >> vec[3];
	cin >> vec[4] >> vec[5];

	vector<int> vec_city(4);


	int a1 = 0, a2 = 0, a3 = 0, a4 = 0;
	for(int ic=0; ic<6; ic++){
		vec_city[vec[ic]-1]++;
	}

	int buf_h1 = 0;
	if (vec_city[0] == buf_h1 || vec_city[1] == buf_h1 || vec_city[2] == buf_h1 || vec_city[3] == buf_h1) {
		cout << "NO";
		return 0;
	}

	buf_h1 = 3;
	if (vec_city[0] == buf_h1 || vec_city[1] == buf_h1 || vec_city[2] == buf_h1 || vec_city[3] == buf_h1) {
		cout << "NO";
		return 0;
	}

	cout << "YES";





	return 0;
}

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

int main() {
	// your code goes here
	long long int h;
	cin>>h;
	  long long int i=1,c=0;
	while(h>0)
	 { c=c+i;
	   i=i*2;
	   h/=2;
	 }
	cout<<c;
	return 0;
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ull Pow(ull a , ull b){
	if(b == 0) return 1 ;
	ull c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c) % mod)) % mod;
	return (c * c) % mod ;
}
ll countDivisibles(ll A, ll B, ll M) 
{ 
    // Add 1 explicitly as A is divisible by M 
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
    // A is not divisible by M 
    return (B / M) - (A / M); 
} 
int main(){
	IOS;
	cout.precision(30) ;
	int n , m; cin >> n >> m ;
	vector<bool> visited(n + 1 , false) ;
	int x ;
	for(int i = 0 ; i < m ; i++) {cin >> x; visited[x] = true ;}
	vector<ll> dp(n + 1 , 0) ;
	dp[0] = 1 ;
	if(!visited[1]) dp[1] = 1 ;
	for(int i = 2 ; i <= n ;i++){
		if(!visited[i]){
			add(dp[i] , dp[i - 1]) ;
			add(dp[i] , dp[i - 2]) ;
		}
	}
	cout << dp[n] << endl; 
	
	return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))

count = 0

for i in range(1, len(a)):
    
    current = a[i]
    
    while i > 0:
        if current < a[i-1]:
            count += 1
            break
        i -= 1
        
print(n - count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int x, y;
	while (true) {
		cin >> x >> y;
		if (x == 0 && y == 0) break;
		if (x > y) swap(x, y);
		printf("%d %d\n", x, y);
	}
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}



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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	
	int sum = a + b + c + d;
	
	cout << sum / 60 << endl;
	cout << sum % 60 << endl;
	
	return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
using pii = pair<int, int>;


int main()
{
    int n;
    cin >> n;
    queue<int> a[n];
    
    rep(i, 0, n)
        rep(j, 0, n - 1)
        {
            int aa;
            cin >> aa;
            --aa;
            a[i].push(aa);
        }


    vector<pii> que;
    auto append_fn = [&](int i){
        if (a[i].size() == 0) return;
        int j = a[i].front();
        if (a[j].size() == 0) return;
        if (a[j].front() == i)
        {
            if (i > j) swap(i, j);
            que.push_back(pii(i, j));
        }
    };

    rep(i, 0, n)
        append_fn(i);

    int day = 0;
    while(que.size() > 0)
    {
        ++day;
        sort(que.begin(), que.end());
        que.erase(unique(que.begin(), que.end()), que.end()); 

        vector<pii> que2;
        swap(que, que2);

        for (auto match: que2)
        {
            int i, j;
            tie(i, j) = match;
            a[i].pop();
            a[j].pop();
        }
        for (auto match: que2)
        {
            int i, j;
            tie(i, j) = match;
            append_fn(i);
            append_fn(j);
        }
    }

    rep(i, 0, n)
    if (a[i].size() != 0)
    {
        puts("-1");
        return 0;
    }
    cout << day << endl;
    return 0;
}

Measured memory_bytes: 4736
using System;

namespace tst
{
    class Program
    {
        static void Main(string[] args)
        {
            //nは繰り返しの回数
            int n = int.Parse(Console.ReadLine());
            //iまでの最小値とiとの差を保存しておけばよい
            //極力二重ループや配列を使わない
            int sub = -1000000000;
            int min = int.Parse(Console.ReadLine());
            for (int i = 1; i <= n-1; i ++){
                int k = int.Parse(Console.ReadLine());
                //現在の差が過去の差より大きいなら更新
                if (sub <= k - min) sub = k - min;
                //最小値の更新
                if (min >= k) min = k;
            }
            Console.WriteLine(sub);
        }
    }
}


Measured memory_bytes: 24120
import sys
import math
import re
import io

def main():
    a = int(input())
    b = int(input())
    (a, b) = (min(a,b), max(a,b))
    if a == 1 and b ==  2:
        print(3)
    elif a == 1 and b ==  3:
        print(2)
    else:
        print(1)


if __name__ == "__main__":
    main()


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

#define int				long long
#define FOR( i, m, n )	for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )		FOR( i, 0, n )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )		(a).begin(), (a).end()
#define MP				make_pair

typedef pair<int, int> P;

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

bool is_prime[1000001];
bool dp[1000001];

signed main(){
	fill( is_prime, is_prime + 1000001, true );
	is_prime[0] = is_prime[1] = false;

	REP( i, 1000001 ) {
		if( is_prime[i] ) {
			for( int j = i * i; j < 1000001; j += i ) {
				is_prime[j] = false;
			}
		}
	}

	int n, x;
	while( cin >> n >> x, n, x ) {
		fill( dp, dp + 1000001, false );

		vector<int> v( n );
		REP( i, n ) cin >> v[i];
		
		dp[0] = true;
		REP( i, x ) {
			if( dp[i] ) {
				REP( j, v.size() ) {
					if( i + v[j] <= x ) {
						dp[i + v[j]] = true;
					}
				}
			}
		}

		int ans = 0;
		REPR( i, x ) {
			if( dp[i] && is_prime[i] ) {
				ans =i;
				break;
			}
		}

		if( ans ) cout << ans << endl;
		else	  cout << "NA" << endl;

	}

}



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

#include <vector>
#include <algorithm>
#include <limits>
#include <unordered_set>
#include <array>
#include <queue>

using namespace std;


int main() {
    int d, t, s;
    cin >> d >> t >> s;
    if (d <= t * s) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 3632
N = int(input())
A = list(map(int, input().split()))
if set(A) == 1:
  print(0)
  exit()
  
ans = 1<<60
for i in range(-100, 101):
  cost = 0
  for a in A:
    cost += (a-i)**2
  ans = min(ans, cost)
print(ans)  

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

vector<int> vec={8,9,5,7};
int solve(int n){
    vector<int> d(n);
    vector<vector<int>> q(n);
    for(int i=0;i<n;i++){
        cin>>d[i];
        q[i].resize(d[i]);
        int t;
        cin>>t;
        for(int j=0;j<d[i];j++){
            cin>>q[i][(j+(d[i]-t))%d[i]];
        }
    }
    vector<vector<int>> gcdv(25,vector<int>(25,0));
    for(int i=0;i<25;i++){
        for(int j=0;j<25;j++){
            if(i!=0 && j!=0) gcdv[i][j]=__gcd(i,j);
        }
    }
    vector<vector<int>> tq(24);
    for(int i=0;i<24;i++){
        tq[i].assign(i+1,0);
    }
    for(int i=0;i<n;i++){
        if(d[i]==11) for(int j=0;j<d[i];j++) tq[21][j]+=q[i][j],tq[21][j+11]+=q[i][j];
        else for(int j=0;j<d[i];j++) tq[d[i]-1][j]+=q[i][j];
    }
    int cnt=0;
    auto calc=[&](vector<int> v){
        int res=0;
        for(int i=0;i<24;i++){
            int sc=-1e9;
            for(int j=0;j<i+1;j++){
                bool isok=true;
                for(int k=0;k<vec.size();k++){
                    int g=gcdv[vec[k]][i+1];
                    isok=isok && (v[k]%g==j%g);  
                    cnt++;
                }
                if(isok) sc=max(sc,tq[i][j]);
            }
            res+=sc;
        }
        return res;
    };
    function<int(int,vector<int>)> dfs=[&](int idx,vector<int> v){
        if(idx==vec.size()) return calc(v);
        int res=0;
        for(int i=0;i<vec[idx];i++){
            v[idx]=i;
            res=max(res,dfs(idx+1,v));
        }
        return res;
    };
    
    vector<int> tmp(vec.size());
    int ret=dfs(0,tmp);
    return ret;
}
int main(){
    int n;
    while(cin>>n,n){
        cout<<solve(n)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3000
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;






int main(void) {
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    cout << min(A,B) + min(C,D) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define long long long
template<class T> inline signed size(const T& t) { return t.size(); }

signed main() {
    int N; cin >> N;
    vector<long> A(N); for(int l = 0; l < N; l++) cin >> A[l];
    vector<long> vs;
    unordered_map<long, int> vm;
    {
        set<long> s0 = {0};
        for(int l = 0, l_M = size(A); l < l_M; l++) s0.insert(A[l]);
        for(auto& sv0: s0) vs.push_back(sv0);
        for(int l = 0, l_M = size(s0); l < l_M; l++) vm[vs[l]] = l;
    }

    int s = size(vs);
    vector<int> g(s);
    for(int i = 0; i < N; i++) g[vm[A[i]]]++;
    for(int j = s-1-1; j >= 0; j--) g[j] += g[j+1];
    if(0) { //dbg
        for(int l = 0, l_M = size(vs); l < l_M; l++) cout << (l ? " " : "") << vs[l];
        cout << '\n';
        for(int l = 0, l_M = size(g); l < l_M; l++) cout << (l ? " " : "") << g[l];
        cout << '\n';
    }

    long now = 0;
    for(int i = 0; i < N; i++) {
        if(A[i] <= now) {
            cout << 0 << '\n';
        } else {
            long a = 0;
            for(int k = vm[now]+1; k <= vm[A[i]]; k++) {
                a += g[k] * (vs[k] - vs[k-1]);
                if(0) { //dbg
                    cout << k << ' ' << a << '\n';
                }
            }
            cout << a << '\n';
            now = A[i];
        }
    }
    return 0;
}


Measured memory_bytes: 11384
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

vector<ll> a,b,p,q;
int main(int argc,char** argv){
	ll n,m,k;
	cin>>n>>m>>k;
	p.pb(0ll),q.pb(0ll);
	rep(i,n){
		ll x;
		cin>>x;
		a.pb(x);
		p.pb(p[i]+a[i]);
	}
	rep(i,m){
		ll x;
		cin>>x;
		b.pb(x);
		q.pb(q[i]+b[i]);
	}
	int mx=0;
	rep(j,n+1){
		int i=j-1;
		if(p[i+1]>k)break;
		int l=0,r=m,mid,cur=0;
		while(l<=r){
			mid=(l+r)/2;
			if(p[i+1]+q[mid]<=k){
				l=mid+1;
				cur=mid+i+1;
			}
			else{
				r=mid-1;
			}
		}
		mx=max(mx,cur);
	}
	cout<<mx;
	return 0;
}

Measured memory_bytes: 11408