akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;
int main(){

  
  while(true){
    int n;
    cin >> n;
    //    for(int i = 0;i < 10;i++){}

    if(n == 0)return 0;
    
    int a[n+1];
    for(int i = 0;i < n;i++){
      cin >> a[i];
    }
    a[n+1]=100000000;
    int tmp = 0;

    int flag = 0;
    
    for(int i = 0;i < n;i++){
      
      /*if(n-1 == i){
	if(flag == 0){
	  flag = 1;	  
	  cout << a[i];
	}else {
	  
	  cout << " " <<  a[i];
	}
	}*/
      if(a[i]+1 == a[i+1]){
	tmp = a[i];
	i++;
	while(a[i]+1==a[i+1]){
	  i++;
	}
	if(flag == 0){
	  flag = 1;
	  
	  cout << tmp << "-" << a[i];
	}else {
	  
	  cout <<" "<<tmp << "-" << a[i];
	}
	
      }else{
	if(flag == 0){
	  flag = 1;	  
	  cout << a[i];
	}else {
	  
	  cout << " " <<  a[i];
	}
      }

      //if(flag != 0)
   
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int k,s,cnt;
int main(){
    cin>>k>>s;
    for(int x=0;x<=k;x++)    for(int y=0;y<=k;y++)    if(s>=x+y&&s-x-y<=k) cnt++;
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int firstInt = input.nextInt();
        int secondInt = input.nextInt();
        if (firstInt * secondInt % 2 == 0){
            System.out.println("Even");
        }
        else {
            System.out.println("Odd");
        }
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <deque>
#include <cstdio>
#include <queue>
using namespace std;
typedef pair<int,pair<int,int> > NODE;
#define SUM first
#define Y second.first
#define X second.second
#define ppp(a,b,c) make_pair(a,make_pair(b,c))
int main(){
	int a;char b;
	int u = 0;
	int mx = 0;
	int ret = 0;
	int done[100][100];
	for(int i=0;i<100;i++)
	for(int j=0;j<100;j++)
	done[i][j] = -1;
	vector< deque<int> > data(1);
	while(~scanf("%d%c",&a,&b)){
		if(b == ','){
			data[u].push_back(a);
		}else{
			data[u].push_back(a);
			mx = max<int>(data[u].size(),mx);
			if(data[u].size()<mx){
				int tmp = data[u].size();
				for(int i=0;i<mx-tmp;i++){
					data[u].push_front(-1);
					data[u].push_back(-1);
				}
			}
			u++;
			data.resize(data.size()+1);
		}
	}
	/*for(int i=0;i<data.size();i++){
	for(int j=0;j<data[i].size();j++){
		printf("%3d",data[i][j]);
	}
	cout << endl;
	}
	*/
	queue<NODE> Q;
	Q.push(ppp(data[0][0],0,0));
	while(Q.size()){
		NODE q = Q.front();Q.pop();
		if(q.SUM <= done[q.Y][q.X]){
			continue;
		}else{
			done[q.Y][q.X] = q.SUM;
		}
		if(data[q.Y+1].empty()){
			ret = max(ret,q.SUM);
			continue;
		}
		if(~data[q.Y+1][q.X])Q.push(ppp(q.SUM+data[q.Y+1][q.X],  q.Y+1,q.X  ));
		if(~data[q.Y+1][q.X+1])Q.push(ppp(q.SUM+data[q.Y+1][q.X+1],q.Y+1,q.X+1));
	}
	/*for(int i=0;i<data.size();i++){
	for(int j=0;j<data[i].size();j++){
		printf("%3d",done[i][j]);
	}
	cout << endl;
	}*/
	cout << ret << endl;
		
}

Measured memory_bytes: 0
import java.util.Scanner;
 
public class Main {
    static int cnt;
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
 
        cnt = 0;
        int m = 1 + (int) (Math.log(n) * Math.log(2));
        int[] G = new int[m];
        G[0] = 1;
        for (int i = 1; i < m; i++) {
            G[i] = G[i - 1] * 3 + 2;
        }
 
        // G[i]のセット
 
        for (int i = m-1; i >= 0; i--) {
            insertionSort(a, G[i]);
        }
 
        println("");
        println(m + "");
        for (int i = m-1; i > 0; i--) {
            print(G[i] + " ");
        }
        println(G[0] + "");
        println(cnt + "");
 
        for (int i = 0; i < n; i++) {
            println(a[i] + "");
        }
    }
 
    static void insertionSort(int[] a, int g) {
        int len = a.length;
 
        for (int i = g; i < len; i++) {
            int temp = a[i];
            int j = i - g;
            while (j >= 0 && a[j] > temp) {
                a[j + g] = a[j];
                j -= g;
                cnt++;
            }
            a[j + g] = temp;
        }
//        printlnArray(a);
    }
 
    static void println(String str) {
        System.out.println(str);
    }
 
    static void print(String str) {
        System.out.print(str);
    }
 
    private static void printlnArray(int[] a) {
        for (int i = 0; i < a.length - 1; i++) {
            System.out.print(a[i] + " ");
        }
        System.out.println(a[a.length - 1]);
    }
}


Measured memory_bytes: 299024
const main = function(input){
  var tasks = input.split(" ").map(i => parseInt(i));
  var min = 100*3;
  
  for(var i =0;i<3;i++){
    var pat1 = Math.abs(tasks[i]-tasks[(i-1)%3]) + Math.abs(tasks[(i-1)%3] - tasks[(i+1)%3]);
    var pat2 = Math.abs(tasks[i]-tasks[(i+1)%3]) + Math.abs(tasks[(i+1)%3] - tasks[(i-1)%3]);
    var smaller = Math.min(pat1,pat2);
    
    if(min>smaller) min = smaller;
  }
  console.log(min);
}


main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
N = int(input())
*A, = map(int, input().split())
ans = 0
k = 0
while k < N - 1 :
    i = N - 1
    while i > k :
        if A[i] < A[i-1] :
            A[i], A[i-1] = A[i-1], A[i]
            ans = ans + 1
        i = i - 1    
    k = k + 1
print(*A)
print(ans)


Measured memory_bytes: 5604
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.Comparator;
import java.util.ArrayList;

/**
 * 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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        MaxMinSums solver = new MaxMinSums();
        solver.solve(1, in, out);
        out.close();
    }

    static class MaxMinSums {
        public static int MOD = 1000000007;
        static long[] fac;
        static long[] finv;
        static long[] inv;

        static void comInit(int max) {
            fac = new long[max + 1];
            finv = new long[max + 1];
            inv = new long[max + 1];

            // 階乗
            fac[0] = fac[1] = 1;
            // 逆元の階乗
            finv[0] = finv[1] = 1;
            // 逆元
            inv[1] = 1;

            for (int i = 2; i <= max; i++) {
                fac[i] = fac[i - 1] * i % MOD;
                inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
                finv[i] = finv[i - 1] * inv[i] % MOD;
            }
        }

        static long com(int n, int k) {
            if (n < k) {
                return 0;
            }
            return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
        }

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            List<Long> list = new ArrayList<>();

            comInit(n);

            for (int i = 0; i < n; i++) {
                list.add(in.nextLong());
            }

            list.sort(Comparator.naturalOrder());

            long ans = 0;
            for (int i = 0; i < list.size(); i++) {
                ans -= com(n - i - 1, k - 1) * list.get(i);
                ans += com(i, k - 1) * list.get(i);
                ans %= MOD;
            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 65100
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    string S;
    cin >> S;

    if((int)S.size() == 1){
        cout << S << endl;
        return 0;
    }

    long long ans = 0;
    int com = 1 << ((int)S.size() - 1);
    for(int i = 0; i < com; i++){
        string s = "";
        for(int j = 0; j < (int)S.size() - 1; j++){
            s += S[j];
            if(i & (1 << j)){
                ans += stoll(s);
                s = "";
            }
        }
        s += S.back();
        ans += stoll(s);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n); for(ll i = 0; i < (ll)n; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ll n; cin >> n;
  vector<ll> v(n);
  rep(i, n)
    cin >> v.at(i);
  
  ll ans = 0;
  rep(i, n){
    for(ll j=i+1; j<n; j++)
      ans += v.at(i)*v.at(j);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3600
def solve(n):
    if n == 3:
        return [2, 5, 63]
    elif n == 4:
        return [2, 5, 20, 63]
    elif n == 5:
        return [2, 3, 4, 6, 9]

    ans = []
    for i in range(1, 30001):
        if i % 2 == 0 or i % 3 == 0:
            ans.append(i)
        if len(ans) == n:
            amari = n % 8
            if amari == 1 or amari == 6:
                j = i + 1
                while j % 6 != 0:
                    j += 1
                ans[4] = j
            elif amari == 2 or amari == 5:
                j = i + 1
                while j % 6 != 3:
                    j += 1
                ans[4] = j
            elif amari == 3 or amari == 4:
                j = i + 1
                while j % 6 != 0:
                    j += 1
                ans[5] = j
            break

    return ans


if __name__ == '__main__':
    N = int(input())
    ans = solve(N)
    print(' '.join(map(str, ans)))


Measured memory_bytes: 5084
#include "bits/stdc++.h"
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)


int main(){
	int r[1010];
	rep(i,1010)r[i]=i;
	for(int i=1;i<1010;i++)r[i] +=r[i-1];

	int n;
	while(cin>>n&&n){
		int c=0;
		for(int i=0;i<n;i++){
			for(int j=i+2;j<n;j++){
				if(r[j]-r[i]==n)c++;
			}
		}
		cout<<c<<endl;
	}
	
}

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

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;


int main(){
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m, 0);
  rep(i, m) cin >> b[i];
  int ans = 0;
  rep(i, n){
    int res = 0;
    rep(j, m){
      int a;
      cin >> a;
      res += a*b[j];
    }
    if(res + c > 0){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	int n;
	cin >> n;
	for (int x = 1; x <= n; x++) {
		int a;
		cin >> a;
		cout << "Case " << x << ":\n";
		for (int i = 0; i < 10; i++) {
			a *= a;
			int res = 0;
			a -= (a / 10000000) * 10000000;
			a -= (a / 1000000) * 1000000;
			res += (a / 100000) * 1000;
			a -= (a / 100000) * 100000;
			res += (a / 10000) * 100;
			a -= (a / 10000) * 10000;
			res += (a / 1000) * 10;
			a -= (a / 1000) * 1000;
			res += a / 100;
			cout << res << endl;
			a = res;
		}
	}
	return 0;
}

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



int main(){
	int a, b, c;
	cin >> a >> b >> c;

	int ans = 100000000;


	ans = min(ans, abs(b-a) + abs(c-b));
	ans = min(ans, abs(c-a) + abs(b-c));
	ans = min(ans, abs(a-b) + abs(c-a));
	ans = min(ans, abs(c-a) + abs(b-a));
	ans = min(ans, abs(c-b) + abs(a-c));
	ans = min(ans, abs(b-c) + abs(a-b));

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
#define int long long

signed main(){
    int n, d; cin >> n >> d;
    vector<int> x(n), y(n);
    rep(i,n) cin >> x[i] >> y[i];
    int cnt = 0;
    rep(i, n){
        if(d * d >= x[i] * x[i] + y[i] * y[i]) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 6432
#include <stdio.h>

int main()
{
    int x, y;
    scanf("%d %d", &x, &y);
    while (x != 0 || y != 0)
    {
        if (y > x)
            printf("%d %d\n", x, y);
        else
            printf("%d %d\n", y, x);
            scanf("%d %d", &x, &y);
    }

    return 0;
}


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

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#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;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

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


int main(){
  int a, b;
  double x;

  cin >> a >> b >> x;

  x /= a;

  double theta;

  if (a * b / 2.0 <= x) {
    x = a * b - x;
    theta = atan((x * 2 / a) / a);
  } else {
    theta = atan(b / (x * 2 / b));
  }

  double ans = theta / M_PI * 180;

  printf("%.10lf\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main(){
	fast;
	ll h,w;
	cin>>h>>w;
	char arr[h][w];
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			cin>>arr[i][j];
	for(int i=0;i<h;i++)
	{
				for(int j=0;j<w;j++)
			cout<<arr[i][j];
			cout<<endl;
					for(int j=0;j<w;j++)
			cout<<arr[i][j];
			cout<<endl;
	}
	return 0;
}



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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;



int main() {

	int n;
	cin >> n;
	ll sum = 0;
	VLL a(n);
	REP(i, n) {
		cin >> a[i];
		sum += a[i];
	}

	ll ans = INFL;

	ll cur = 0;

	REP(i, n) {
		cur += a[i];
		ans = min(ans, abs(sum - cur - cur));
	}
	cout << ans << endl;
	




	return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; ++i) {
        cin >> d.at(i);
    }
    sort(d.begin(), d.end());
    cout << d.at(n / 2) - d.at(n / 2 - 1) << endl;
    return 0;
}


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

#ifdef DEBUG
    #include "debug.h"
    #define DEB
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define DEB if (false)
    #define dump(...)
#endif


// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//////////////////

#define int long long
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
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; }

/*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)


/*
void solve(){
    int N;
    cin >> N;
//    N=475254;
    N--;
    vector<int> ans;
    if(N==0) ans.push_back(0);
    else{
        bool first=true;
        while(N>0){
            ans.push_back(N%26);
            N/=26;
        }
    }
    
    dump(ans);
}*/

void solve(){
    int N;
    cin >> N;
    vector<int> freq(123456,0);
    rep(i,N){
        int a;
        cin >> a;
        freq[a]++;
    }
    int sum = 0;
    rep(i,123456){
        sum += i * freq[i];
    }

    int Q;
    cin >> Q;
    while(Q--){
        int B, C;
        cin >> B >> C;
        freq[C] += freq[B];
        sum += freq[B] * (C-B);
        freq[B]=0;

        cout << sum << endl;
    }
}


signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 4320
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=2e5+5;
ll dp[N];
ll a[N];
ll solve(int i)
{
  if(i<=1)
return 0;
else if(dp[i]!=-1)
return dp[i];
return dp[i]=min(abs(a[i]-a[i-2])+solve(i-2),abs(a[i]-a[i-1])+solve(i-1));
}
int main()
{
  int n;
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i];
dp[0]=INT_MAX;
for(int i=2;i<=n;i++)
dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
cout<<dp[n]<<endl;
}

Measured memory_bytes: 1792
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n; cin >> n;
    vector<int> w(n), s(n), v(n);
    rep(i, n) {
        cin >> w[i] >> s[i] >> v[i];
    }
    vector<int> ids(n);
    iota(all(ids), 0);
    sort(all(ids), [&](int i, int j){ return w[i] + s[i] < w[j] + s[j]; });
    static int dp[1010][20010];
    rep(i, 1010) {
        rep(j, 20010) {
            dp[i][j] = 0;
        }
    }
    rep(i, n) {
        for(int j = 0; j <= 20000; ++ j) {
            chmax(dp[i + 1][j], dp[i][j]);
            if(j + w[ids[i]] < 20010 && j <= s[ids[i]]) chmax(dp[i + 1][j + w[ids[i]]], dp[i][j] + v[ids[i]]);
        }
    }
    int ans = 0;
    rep(j, 20010) {
        chmax(ans, dp[n][j]);
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 161580
d,n = map(int, input().split())
if d == 0:
  if n < 100:
    print(n)
  else:
    print(101)
elif d == 1:
  if n < 100:
    print(100 * n)
  else:
    print(10100)
else:
  if n < 100:
    print(10000 * n)
  else:
    print(1010000)
      
  

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

typedef long long ll;

int main()
{
	int n; cin >> n;
	vector<int> v(2 * n);
	for(int i = 0; i < 2 * n; i++)
		cin >> v[i];

	int ans = 0;
	sort(v.begin(), v.end());
	
	for(int i = 0; i < 2 * n; i += 2)
		ans += v[i];

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

Measured memory_bytes: 256
sx, sy, gx, gy = map(int,input().split())
dx = gx - sx
dy = gy - sy

ans = 'U'*dy + 'R'*dx
ans += 'D'*dy + 'L'*dx
ans += 'L' + 'U'*(dy+1) + 'R'*(dx+1) + 'D'
ans += 'R' + 'D'*(dy+1) + 'L'*(dx+1) + 'U'

print(ans)

Measured memory_bytes: 9124
<?php

$n = (int)fgets(STDIN);
$input = preg_split('/ /', trim(fgets(STDIN)));

$sum = 0;
$total_sum = 0;

for ($i = 0; $i < $n; $i++) {
    $sum += $input[$i];
}

for ($i = 0; $i < $n; $i++) {
    $num = $input[$i];
    $total_sum += $num * ($sum - $num);
}

echo $total_sum / 2;

Measured memory_bytes: 3956
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

#define LINF 1e18
#define INF 1e9 + 7

using namespace std;

int main() {
  int N;
  cin >> N;

  vector<int> dp(100005);
  for (int i = 0; i <= N; i++) {
    dp[i] = i;
  }

  for (int i = 1; i <= 100000; i++) {
    int t = 1;
    while (t <= i) {
      dp[i] = min(dp[i], dp[i - t] + 1);
      t *= 6;
    }
    int s = 1;
    while (s <= i) {
      dp[i] = min(dp[i], dp[i - s] + 1);
      s *= 9;
    }
  }
  cout << dp[N] << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
//#include "cpp/Solution.h"

using namespace std;


int main() {
    int N;
    int K;
    cin >> N >> K;
    vector<int>arr;

    for(int i = 0;i < N;i++){
        int in;
        cin >> in;
        arr.push_back(in);
    }

    sort(arr.begin(),arr.end());

    int sum= 0;
    for(int i = 0; i < K;i ++){
        sum += arr[i];
    }
    cout << sum;
    return 0;
}





Measured memory_bytes: 3600
A = int(input())
B = int(input())

if A == 1 and B == 2:
  print(3)
elif A == 1 and B == 3:
  print(2)
elif A == 2 and B == 3:
  print(1)
elif A == 2 and B == 1:
  print(3)
elif A == 3 and B == 1:
  print(2)
elif A == 3 and B == 2:
  print(1)


Measured memory_bytes: 3060
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

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

    void run() {

        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();

        int res = 100000;

        for (int i=0; i<s.length - t.length + 1; i++) {
            int cnt = 0;
            for (int j=0; j<t.length; j++) {
                if (s[i+j] != t[j]) cnt++;
            }
            res = Math.min(res, cnt);
        }

        System.out.print(res);

    }

}



Measured memory_bytes: 35640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int> > Matrix;

int main(){
    int n, x;
    cin >> n >> x;
    vector<int> m(n);
    int mon = x;
    rep(i, n) {
        cin >> m[i];
        mon -= m[i];
    }

    sort(ALL(m));
    int y = mon / m[0];
    int ans = n + y;
    cout << ans << endl;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

using System.Collections;

class Program
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        string S = Console.ReadLine();

        var charList = S.Distinct().ToArray();

        int ans = 0;

        for(int i = 0; i < S.Length - 1; i++)
        {
            string s1 = S.Substring(0, i);
            string s2 = S.Substring(i);

            int cnt = charList.Where(c => s1.Contains(c) && s2.Contains(c)).Count();
            ans = Math.Max(cnt, ans);
        }
        Console.WriteLine(ans);
    }
}


static class MathUtil
{
    public static T Max<T>(params T[] datas)
    {
        return datas.Max();
    }

    public static T Min<T>(params T[] datas)
    {
        return datas.Min();
    }

    public static IEnumerable<IEnumerable<int>> GetPermutation(int n)
    {
        if (n == 0)
        {
            yield return Single(0);
            yield break;
        }

        for (int i = 0; i <= n; i++)
        {
            foreach (var x in GetPermutation(n - 1))
            {
                yield return Single(i).Concat(x.Select(itm => itm < i ? itm : itm + 1));
            }
        }
    }

    private static IEnumerable<int> Single(int x)
    {
        yield return x;
    }

    public static IEnumerable<int> EnumeratePrimeNumbers()
    {
        List<int> primes = new List<int>() { 2 };
        yield return 2;

        for (int i = 3; i < int.MaxValue; i++)
        {
            bool isPrime = true;
            int Sqrt = (int)Math.Sqrt(i) + 1;

            foreach (var prime in primes)
            {
                if (prime > Sqrt)
                {
                    break;
                }
                if (i % prime == 0)
                {
                    isPrime = false;
                    break;
                }
            }

            if (isPrime)
            {
                primes.Add(i);
                yield return i;
            }
        }
    }
}


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

int main() {
  int N;
  cin >> N;
  if (N%1111==0){cout << "Yes" << endl;}
  else if((N%1110)<=9){cout << "Yes" << endl;}
  else if((N%1000)%111==0){cout << "Yes" << endl;}
  else {cout << "No" << endl;}
                 
}


Measured memory_bytes: 256
//What is the Bottommost?
#include<bits/stdc++.h>
using namespace std;

int main(){
  string s;
  while(cin>>s){
    int sum=0;
    for(int i=0; i<s.length(); i++)s[i]-='0';
    sum+=(s[0]+s[9]);
    sum+=(s[1]+s[8])*9;
    sum+=(s[2]+s[4]+s[5]+s[7])*6;
    sum+=(s[3]+s[6])*4;
    cout<<sum%10<<endl;
  }
  return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;

int main() {
    int n,m; cin >> n >> m;
    multimap<int,int> a;
    for(int i = 0;i < m;i++){
        int x; int y; cin >> x >> y;
        auto z = a.find(x);
        if(z == a.end()){
            a.insert(make_pair(x,y));
        }else{
            if(z->second != y){
                cout << -1;
                return 0;
            }
        }
    }
    string ans = "-1";
    for(int i = 0;i <= 999;i++){
        string s = to_string(i);
        if(s.length() == n){
            bool f = true;
            for(auto e:a){
                int num = s[e.first-1] - '0';
                if(num != e.second){
                    f = false;
                    break;
                }
            }
            if(f){
                ans = s;
                break;
            }
        }
    }
    cout << ans;
}



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <map>


using namespace std;

int a[100000];

int main() {
	int n;
	cin >> n;
	int a[100000];
	int ans=0;

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

	map<int, int> mp;
	for (int i = 0; i < n; i++)
	{
		mp[a[i]]++;
	}

	for (auto p: mp)
	{
		int x = p.first;
		int y = p.second;
		if (y >= x) {
			ans += y - x;
		}
		else {
			ans += y;
		}

	}
	cout << ans << endl;

}

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

#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdbl vector<double>
#define vstr vector<string>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	ll N;
	cin >> N;

	ll a[3*N];
	rep(i,3*N) cin >> a[i];

	priority_queue<ll,vector<ll>,greater<ll> > lq;
	ll lsm = 0;
	rep(i,N){
		lq.push(a[i]);
		lsm += a[i];
	} 

	priority_queue<ll> rq;
	ll rsm = 0;
	rep(i,N){
		rq.push(a[i+2*N]);
		rsm += a[i+2*N];
	} 

	ll ans[N+1] = {};
	ans[0] += lsm;
	ans[N] -= rsm;

	FOR(k,0,N){
		if(a[N+k] > lq.top()){
			lsm += a[N+k] - lq.top();
			lq.pop();
			lq.push(a[N+k]);
		}
		ans[k+1] += lsm;

		if(a[2*N-1-k] < rq.top()){
			rsm += a[2*N-1-k] - rq.top();
			rq.pop();
			rq.push(a[2*N-1-k]);
		}
		ans[N-1-k] -= rsm;
	}

	ll ma = -1e18;
	rep(i,N+1) ma = max(ma,ans[i]);
	
	cout << ma << endl;
}

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

using namespace std;
typedef long long ll;

ll N;
ll P[200000];

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> P[i];
    ll min_v = 1e10;
    ll c = 0;
    for(int i=0;i<N;i++){
        if(min_v <= P[i]) continue;
        min_v = P[i];
        c++;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 1792
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    s = [
        [-int(i) if i.isdigit() else i for i in input().split()] + [j]
        for j in range(1, n + 1)
    ]
    for _, _, i in sorted(s):
        print(i)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = pow(10, 9) + 7;

int main() {
    // source
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
    return 0;
}



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


Measured memory_bytes: 128
from itertools import chain

K = int(input())

L = 10
lunlun = [[] for _ in range(L+1)]

lunlun[1] = list(range(1,10))

for i in range(1,L):
    for x in lunlun[i]:
        r = x%10
        if r == 0:
            lunlun[i+1] += [x*10 + r, x*10 + r+1]
        elif r == 9:
            lunlun[i+1] += [x*10 + r-1, x*10 + r]
        else:
            lunlun[i+1] += [x*10 + r-1, x*10 + r, x*10 + r+1]

res = list(chain.from_iterable(lunlun))

print(res[K-1])

Measured memory_bytes: 92256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> pippi;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<61;
int iinf=1<<30;
double pi=3.14159265358979323846;
double pi2=pi/2.0;
double eps=1e-8;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
//#define endl "\n"
int dh[4]={1,0,-1,0};
int dw[4]={0,1,0,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<int,int,custom_hash>
ll gcd(ll a,ll b){
    if(a<0)a=-a;
    if(b<0)b=-b;
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    if(k<0)return 0;
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int d,t,s;cin>>d>>t>>s;
    if(s*t>=d)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3648
# AOJ 0079 Area of Polygon
# Python3 2018.6.17 bal4u

def calc_area(p):
	n, s = len(p), 0
	p.append(p[0])
	for i in range(n):
		s += (p[i].real-p[i+1].real)*(p[i].imag+p[i+1].imag)
	return abs(s)/2

p = []
while True:
	try: x, y = list(map(float, input().split(',')))
	except EOFError: break
	p.append(complex(x, y))
print(calc_area(p))


Measured memory_bytes: 5588
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <functional>
#include <iterator>
#include <string>
#include <assert.h>

using std::cin;
using std::cout;
using std::endl;
using std::vector;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = std::pair<int, int>;
using vpii = vector<pii>;
using trio = std::pair<int, pii>;
#define all(x) begin(x), end(x)

int main()
{
	int n;
	cin >> n;
	vi h(n + 1);
	vi cost(n + 1, 0);
	for (int i = 1; i <= n; ++i) cin >> h[i];
	cost[n - 1] = std::abs(h[n] - h[n - 1]);
	for (int i = n - 2; i > 0; --i)
	{
		cost[i] += std::min(std::abs(h[i + 1] - h[i]) + cost[i + 1], std::abs(h[i + 2] - h[i]) + cost[i + 2]);
	}
	cout << cost[1] << endl;
	return 0;
}

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

int main(){
  
  int N;
  cin >> N;
  
  int MAX=100000;
 
  int s[N];
  vector<int> vec(MAX+1,0);
  
  for(int i=0;i<N;i++){
    cin >> s[i];
    vec[s[i]] +=1;}

  int max1=0;
  
  
  for (int i=0;i<MAX-1;i++){
    if (vec[i]+vec[i+1]+vec[i+2] > max1) 
      max1=vec[i]+vec[i+1]+vec[i+2] ;}
  
  cout << max1;
  
}
    

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

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

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long N = scan.nextLong();
        Set<Long> divisors = new HashSet<>();
        for (long i = 1; i * i <= N - 1; i++) {
            if ((N - 1) % i != 0) {
                continue;
            }
            divisors.add(i);
            divisors.add((N - 1) / i);
        }
        divisors.remove(1L);
        Set<Long> set = new HashSet<>();
        for (long i = 1; i * i <= N; i++) {
            if (N % i != 0) {
                continue;
            }
            set.add(i);
            set.add(N / i);
        }
        set.remove(1L);
        for (long i : set) {
            long target = N;
            while (target % i == 0) {
                target /= i;
            }
            if ((target - 1) % i == 0) {
                divisors.add(i);
            }
        }
        System.out.println(divisors.size());
    }
}


Measured memory_bytes: 38752
/*


*/
#include <cstdio>
#include <algorithm>
#define mod 924844033
typedef long long LL;
const int N=4005;//2n

int ban[N],f[2][N][2],fac[N];

int main()
{
	int n,K,cnt=0; scanf("%d%d",&n,&K);
	for(int i=1; i<=K; ++i)
	{
		ban[++cnt]=1;
		for(int j=i+K; j<=n; j+=K) ban[++cnt]=0;
		ban[++cnt]=1;//就是两条链啊 
		for(int j=i+K; j<=n; j+=K) ban[++cnt]=0;
	}
	int p=0; f[p][0][0]=1;
	for(int i=0; i<cnt; ++i,p^=1)
		for(int j=0; j<=i; ++j)
		{
			f[p^1][j][0]=(f[p][j][0]+f[p][j][1])%mod;
			if(!ban[i+1]) f[p^1][j+1][1]=f[p][j][0];
			f[p][j][0]=f[p][j][1]=0;
		}
	fac[0]=1;
	for(int i=1; i<=n; ++i) fac[i]=1ll*fac[i-1]*i%mod;
	LL ans=0;
	for(int i=0; i<=n; ++i)
		ans+=i&1?mod-1ll*fac[n-i]*(f[p][i][0]+f[p][i][1])%mod:1ll*fac[n-i]*(f[p][i][0]+f[p][i][1])%mod;
	printf("%lld\n",ans%mod);

	return 0;
}

Measured memory_bytes: 256
n = int(input())

t = list(map(int,input().split()))

m = int(input())

px = [[] for i in range(m)]
for i in range(m):
    px[i] += list(map(int,input().split()))


for i in range(m):
    print(sum(t) - t[px[i][0]-1] + px[i][1])


Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  int coin=0;
  for(int i=0;i<2;i++){
    if(a>b){
      coin += a;
      a--;
    }
    else if(b>=a){
      coin += b;
      b--;
    }
  }
  cout << coin << endl;
  return 0;
}


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

using namespace std;

int main() {

	int n,m,x;
	cin >> n >> m >> x;

	int counter1 = 0;
	int counter2 = 0;
	vector<int> a(m,0);
	for (int j = 0; j < m; j++) {
		cin >> a[j];
	}

	for (int i = 0; i <= n; i++) {
		for (int j = 0; j < m; j++) {

			if (a[j] == i) {
				if (i < x) { counter1++; }
				else { counter2++; }
			}
		}
	}

	cout << min(counter1, counter2) << endl;

}

Measured memory_bytes: 256
from sys import stderr, setrecursionlimit, exit
from collections import defaultdict as dd
setrecursionlimit(2147483647)
def getInt():
    return int(input())
def getInts():
    return [int(i) for i in input().split()]
def getIntLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInt())
    return res
def getIntsLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInts())
    return res
def debug(*args, sep=" ", end="\n"):
    for item in args:
        stderr.write(str(item))
        stderr.write(sep)
    stderr.write(end)

n, k = getInts()
arr = dd(int)
for _ in range(n):
    a, b = getInts()
    arr[a] += b
arr_sorted = sorted(list(arr.items()),key=lambda x:x[0])
i = 0
for key, val in arr_sorted:
    i += val
    if i >= k:
        print(key)
        exit()

Measured memory_bytes: 15920
X, Y, A, B, C = [int(s) for s in input().split()]
p_list = [int(s) for s in input().split()]
q_list = [int(s) for s in input().split()]
r_list = [int(s) for s in input().split()]

p_list = list(reversed(sorted(p_list)))
p_list = p_list[:X]
# print(X, p_list)

q_list = list(reversed(sorted(q_list)))
q_list = q_list[:Y]
# print(Y, q_list)

r_list = list(reversed(sorted(r_list)))
# print(r_list)


p_i = -1
q_i = -1
r_i = 0

while True:
    if r_i == C:
        break

    if p_i + X >= 0 and q_i + Y >= 0:
        if p_list[p_i] <= q_list[q_i]:
            if p_list[p_i] < r_list[r_i]:
                p_list[p_i] = r_list[r_i]
                p_i -= 1
                r_i += 1
            else:
                break
        elif q_list[q_i] <= p_list[p_i]:
            if q_list[q_i] < r_list[r_i]:
                q_list[q_i] = r_list[r_i]
                q_i -= 1
                r_i += 1
            else:
                break
    elif p_i + X >= 0:
        if p_list[p_i] < r_list[r_i]:
            p_list[p_i] = r_list[r_i]
            p_i -= 1
            r_i += 1
        else:
            break
    elif q_i + Y >= 0:
        if q_list[q_i] < r_list[r_i]:
            q_list[q_i] = r_list[r_i]
            q_i -= 1
            r_i += 1
        else:
            break
    else:
        break

d = 0
d += sum(p_list)
d += sum(q_list)

print(d)

Measured memory_bytes: 23344
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        int[] a = nia(3);
        Arrays.sort(a);
        if (a[0] + a[1] == a[2]) out.println("Yes");
        else out.println("No");
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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

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

template <class T>
struct Kruskal {
  struct UnionFind {
    int N;
    vector<int> sz_tree, parent;
    UnionFind() {}
    UnionFind(int N) : N(N), sz_tree(N, 1), parent(N) {
      iota(parent.begin(), parent.end(), 0);
    }
    int root(int x) {
      return parent[x] == x ? x : parent[x] = root(parent[x]);
    }
    void merge(int x, int y) {
      if ((x = root(x)) == (y = root(y))) return;
      if (sz_tree[x] < sz_tree[y]) swap(x, y);
      sz_tree[x] += sz_tree[y];
      parent[y] = x;
    }
    bool same(int x, int y) {
      return root(x) == root(y);
    }
    int size(int x) {
      return sz_tree[root(x)];
    }
  };
  struct edge {
    int from, to; T cost;
    edge() {}
    edge(int f, int t, T c) : from(f), to(t), cost(c) {}
  };
 
  int N;
  vector<edge> es;
  vector<edge> use;
  Kruskal() {}
  Kruskal(int N) : N(N) {}
 
  void add_edge(int from, int to, T cost) {
    es.emplace_back(from, to, cost);
  }
  T mst() {
    T res = 0;
    UnionFind uf(N);
    sort(es.begin(), es.end(), [&](edge a, edge b) {
      return a.cost < b.cost;
    });
    for (auto &e : es) {
      if (uf.same(e.from, e.to)) continue;
      uf.merge(e.from, e.to);
      use.emplace_back(e);
      res += e.cost;
    }
    return res;
  }
};

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n, m;
  while (cin >> n >> m, n) {
    Kruskal<int> K(n);
    for (int i = 0; i < m; i++) {
      int s, t, c;
      cin >> s >> t >> c;
      s--, t--;
      K.add_edge(s, t, c);
      K.add_edge(t, s, c);
    }
    K.mst();
    cout << K.use[(n - 1) / 2].cost << endl;
  }

  return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

ll gcd(ll a, ll b) {
  return b == 0 ? a : gcd(b, a % b);
}

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  ll X = abs(A - C);
  ll Y = abs(B - D);
  cout << X + Y - gcd(X, Y) << endl;
  return 0;
}



Measured memory_bytes: 256
import itertools
N,M = map(int, input().strip().split(' '))
sw = [[0 for _ in range(M)] for __ in range(N)]
for m in range(M):
  col = list(map(int, input().strip().split(' ')))[1:]
  for i in col:
    sw[i-1][m] = 1
p = list(map(int, input().strip().split(' ')))

ok_count = 0
for c in itertools.product([0,1], repeat=N):
  lamp = [0 for _ in range(M)]
  for i in range(N):
    if c[i]:
      lamp = [l+s for l,s in zip(lamp, sw[i])]
  lamp = [l%2 for l in lamp]
  if lamp == p:
    ok_count += 1
print(ok_count)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	char i,j,k;
	string a="A",b="B",c="C";
	int A=1,B=0,C=0;
	while(cin>>i>>k>>j){
		if((i =='A' && j=='B')||(i=='B' && j=='A')) swap(A,B);
		if((i =='B' && j=='C')||(i=='C' && j=='B')) swap(B,C);
		if((i =='A' && j=='C')||(i=='C' && j=='A')) swap(A,C);
	}
	if(A==1) cout<<a<<endl;
	else if(B==1) cout<<b<<endl;
	else if(C==1) cout<<c<<endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
template <class X> void print(X x) { cout << x << endl; }
void print(vl x) {
    for(ll i : x) {
        cout << i << " ";
    }
    cout << endl;
}
const ll INF = (1LL << 61) - 1;
const ll MOD = 1000000007 /*998244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, n, t, r, k, w, l, ans, i, j, u, v, m;
ll codeforces = 1;
string S, T;
vl A, B;
vector<tuple<ll,ll,ll>> UD,RL,UL,RD,UR,LD;
void input() {
cin>>n;
rep(i,n){
    cin>>x>>y;
    char C;
    cin>>C;
    if(C=='U'){
        UD.pb({x,y,1});
        UL.pb({y-x,y+x,1});
        UR.pb({y+x,y-x,1});
    }
    if(C=='D'){
        UD.pb({x,y,-1});
        RD.pb({y-x,y+x,-1});
        LD.pb({y+x,y-x,-1});
    }
        if(C=='L'){
        RL.pb({y,x,-1});
        UL.pb({y-x,y+x,-1});
        LD.pb({y+x,y-x,1});
    }
        if(C=='R'){
        RL.pb({y,x,1});
        RD.pb({y-x,y+x,1});
        UR.pb({y+x,y-x,-1});
    }
}
}
void solve() { 
    sort(all(UD));
    sort(all(RL));
    sort(all(UL));
    sort(all(RD));
    sort(all(UR));
    sort(all(LD));
    //tate
    a=INF;
    d=UD.size();
    e=RL.size();
    f=UL.size();
    t=RD.size();
    k=UR.size();
    l=LD.size();
    rep(i,d-1){
        auto [x,y,z]=UD[i];
        auto [p,q,r]=UD[i+1];
        if(z==1&&r==-1&&x==p)a=min(a,(q-y)*5);
    }
        rep(i,e-1){
        auto [x,y,z]=RL[i];
        auto [p,q,r]=RL[i+1];
        if(z==1&&r==-1&&x==p)a=min(a,(q-y)*5);
    }
        rep(i,f-1){
        auto [x,y,z]=UL[i];
        auto [p,q,r]=UL[i+1];
        if(z==1&&r==-1&&x==p)a=min(a,(q-y)*5);
    }
        rep(i,t-1){
        auto [x,y,z]=RD[i];
        auto [p,q,r]=RD[i+1];
        if(z==1&&r==-1&&x==p)a=min(a,(q-y)*5);
    }
        rep(i,k-1){
        auto [x,y,z]=UR[i];
        auto [p,q,r]=UR[i+1];
        if(z==1&&r==-1&&x==p)a=min(a,(q-y)*5);
    }
        rep(i,l-1){
        auto [x,y,z]=LD[i];
        auto [p,q,r]=LD[i+1];
        if(z==1&&r==-1&&x==p)a=min(a,(q-y)*5);
    }
    if(a==INF)print("SAFE");
    else print(a);
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    while(codeforces--) {
        solve();
    }
}

Measured memory_bytes: 22848