akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define pi 3.14159265358979323846264338
#define pb push_back
#define mp make_pair
#define inf 10000
using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;

ll divisor=998244353;

int main(){
	int n;
	cin>>n;
	string s[n];
	int a[4]={};
	string set[4]={"AC","WA","TLE","RE"};
	rep(i,n){
		cin>>s[i];
		rep(j,4){
			if(s[i]==set[j]){
				a[j]++;
				break;
			}
		}
	}
	cout<<"AC x "<<a[0]<<endl;
	cout<<"WA x "<<a[1]<<endl;
	cout<<"TLE x "<<a[2]<<endl;
	cout<<"RE x "<<a[3]<<endl;
}


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

int main(){
    long long n;
    long long a[87];
    cin>>n;
    a[0]=2;a[1]=1;
    for (int i=2;i<=n;i++)a[i]=a[i-1]+a[i-2];
    cout<<a[n]<<endl;
}

Measured memory_bytes: 3576
from collections import defaultdict
N=int(input())
A=list(map(int, input().split()))
D=defaultdict(int)
for a in A:
    D[a]+=1

SUM=sum(A)
Q=int(input())
for i in range(Q):
    b,c=map(int, input().split())
    preb=D[b]
    prec=D[c]
    SUM=SUM-preb*b+c*preb
    print(SUM)
    D[c]+=preb
    D[b]=0


Measured memory_bytes: 94308
#include <cstdio>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<fstream>

#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
using namespace std;

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
       
    ll i,j,k,x,y,z,p,q;
    ll n,m,tmp;
    string s[200000];
    string str;
    ll sum=0;
    ll strr[200005];
    cin>>i>>j;
    if(i==1){
        if(j==2){
            cout<<3<<endl;
        }else{
            cout<<2<<endl;
        }
    }
    if(i==2){
        if(j==1){
            cout<<3<<endl;
        }else{
            cout<<1<<endl;
        }
    }
    if(i==3){
        if(j==1){
            cout<<2<<endl;
        }else{
            cout<<1<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>

using namespace std;

int main(void){
    int n,a,b;

    cin >> n;

    if(n == 1){
        cout << "Hello World" << endl;
    }
    else{
        cin >> a >> b;
        cout << a + b << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, C0, C1, C2, C3, C4, i;
string s1, s2;
int main()
{
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> s1;
        if(s1=="AC")
            C0++;
        else if(s1=="WA")
            C1++;
        else if(s1=="TLE")
            C2++;
        else if(s1=="RE")
            C3++;
    }
    cout << "AC x "<<C0 << endl;
    cout << "WA x "<<C1 << endl;
    cout << "TLE x "<<C2 << endl;
    cout << "RE x "<<C3 << endl;
    return 0;
}


Measured memory_bytes: 3632
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    ll N; cin >> N;
    if (N == 0) {
        cout << 0 << endl; return 0;
    }
    if (N % 2) {
        cout << 0 << endl; return 0;
    }
    N /= 2;
    ll ans = 0;
    while (N > 0) {
        ans += N / 5;
        N/=5;
    }
    cout << ans << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



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

int a[200005];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n-k; i++)
    {
        if (a[i] >= a[i+k]) cout << "No";
        else cout << "Yes";
        cout << '\n';
    }
}

Measured memory_bytes: 4344
S = int(input())
mod = 10**9+7
if S<3:
    print(0)
    exit()
else:
    dp = [0]*(S+1)
    dp[3] = 1

for i in range(4,S+1):
    dp[i] = 1
    for j in range(i-2):
        dp[i] += dp[j]
    dp[i] %= mod
print(dp[S])

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

public static partial class Program
{
    public static void Main()
    {
        var whxy = CRL().ArrayInts();
        var w = whxy[0];
        var h = whxy[1];
        var x = whxy[2];
        var y = whxy[3];

        var menseki = (double) w * h / 2;

        var hukusuu = 0;
        if (x != 0 && y != 0)
        {
            if (w == x * 2 && h == y * 2)
            {
                hukusuu = 1;
            }
        }

        CWL($"{menseki} {hukusuu}");
    }
}

public static partial class Program
{
    //テンプレここから
    public static int Sigma(int n, int next = 1, int val = 0) => next > n ? val : Sigma(n, next + 1, val + next);
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);
    public static int GCD(int a, int b) => b == 0 ? a : GCD(b, a % b);
    public static long LCM(long a, long b) => a * b / GCD(a, b);
    public static int LCM(int a, int b) => a * b / GCD(a, b);
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static int ToInt(this double d) => (int) d;
    public static long ToLong(this double d) => (long) d;
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Diff(int a, int b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static readonly int[] Dx = {0, -1, 0, 1};
    public static readonly int[] Dy = {-1, 0, 1, 0};
    public const int Mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToLong();
    public static int ToInt(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray();
    public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray();
    public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray();
    public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray();
    public static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);
    public static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);

    public static string JoinToStr(this IEnumerable<int> array, string sep = "")
        => array.Select(x => x.ToString()).Join(sep);

    //テンプレここまで
}

Measured memory_bytes: 13396
a = int(input())
b = int(input())
c = int(input())
d = int(input())
ans = 0

for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i + 100*j + 50*k == d:
        ans += 1

print(ans)

Measured memory_bytes: 3060
'use strict';
(function(stdin) {
  var inputs = stdin.toString().trim().split('\n');

  (function(x) {
    // ????????????????????????
    console.log(Math.pow(x, 3));
  })(parseInt(inputs[0], 10)); // ??°?????????

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15824
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int n; cin >> n;
  int ans = 0, max = 0;
  rep(i, n) {
    int a, b; cin >> a >> b;
    if (a > max) {
      max = a;
      ans = a + b;
    }
  }
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

int main(){
    int X;
    cin >> X;
    if(X == 7 or X == 5 or X == 3)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

}





    

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;
using Complex = complex<double>;
const double PI = acos(-1);

ll mod(ll a, int m) {
    return ((a % m) + m) % m;
}

int main() {
    int N;
    cin >> N;
    vector<int> x(N), s(N);
    for (int i = 0; i < N; ++i)
        cin >> x[i];

    vector<ll> inv(N);
    inv[1] = 1;
    for (int i = 2; i < N; ++i)
        inv[i] = mod(-(MOD / i) * inv[MOD % i], MOD);

    ll fac = 1;
    for (int i = 2; i < N; ++i)
        (fac *= i) %= MOD;

    for (int i = N - 2; i >= 0; --i) {
        s[i] = s[i + 1] + (x[i + 1] - x[i]);
        s[i] %= MOD;
    }

    ll ans = 0;
    for (int i = 0; i < N - 1; ++i) {
        ll c = (fac * inv[i + 1]) % MOD;
        ans += (s[i] * c) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_D&lang=jp
 */

import java.util.*;

class Lake {
	int rpos, lpos, area;
	Lake(int lpos, int rpos, int areaOfChilds) {
		this.rpos = rpos;
		this.lpos = lpos;
		this.area = rpos - lpos - 1 + areaOfChilds;
	}
	void print() {
		System.out.println("lpos:" + lpos + ", rpos:" + rpos + ", area:" + area);
	}
}
public class Main {

	void printArray(int[] a) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + " ");
		}
		System.out.println();
	}

	void update(LinkedList<Lake> lakes, int l, int r) {
		LinkedList<Lake> childs = new LinkedList<Lake>();
		int areaOfChilds = 0;
		int i = 0, idx = -1;
		for (Lake lake : lakes) {
			if (l < lake.lpos && lake.rpos < r) {
				childs.addLast(lake);
				areaOfChilds += lake.area;
				if (idx == -1) idx = i;
			} else if (idx == -1 && r <= lake.lpos) {
				idx = i;
			}
			i++;
		}
		lakes.removeAll(childs);
		lakes.add((idx == -1 ? lakes.size() : idx), new Lake(l, r, areaOfChilds));
	}

	void debugPrint(LinkedList<Lake> lakes) {
		for (Lake lake : lakes) {
			lake.print();
		}
		System.out.println();
	}

	void solve(int[] a, int level, int cap, LinkedList<Lake> lakes) {
		//System.out.println("solve: " + level + ", " + cap);
		do {
			//System.out.println("solve: " + level + ", " + cap);
		for (int i = 0; i < a.length;) {
			int l = -1, r = -1;
			if (a[i] == level && i+1 < a.length && a[i+1] == (level-1)) {
				l = i;
				for (i += 2; i < a.length; i++) {
					if (a[i] == level && a[i-1] == (level-1)) {
						r = i;
						break;
					}
				}
				if (r != -1) {
					update(lakes, l, r);
				}
			}
			if (r == -1) i++;
		}
		} while (cap > level++);
		//System.out.println(level);
		//debugPrint(lakes);
		//if (cap <= level) return;
		//solve(a, level+1, cap, lakes);
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		char[] chars = line.toCharArray();
		int[] heights = new int[chars.length + 1];
		heights[0] = 0;  // 基準にする
		int bottom = 0;
		int top = 0;
		for (int i = 1; i < heights.length; i++) {
			int diff = 0;
			switch (chars[i-1]) {
			case '\\':
				diff = -1;
				break;
			case '/':
				diff = +1;
				break;
			case '_':
				diff = 0;
				break;
			}
			heights[i] = heights[i-1] + diff;
			bottom = Math.min(heights[i], bottom);
			top = Math.max(heights[i], top);
		}
		//printArray(heights);
		LinkedList<Lake> lakes = new LinkedList<Lake>();
		solve(heights, bottom+1, top, lakes);

		int sum = 0;
		for (Lake lake : lakes) {
			sum += lake.area;
		}

		System.out.println(sum);
		System.out.print(lakes.size());
		for (Lake lake : lakes) {
			System.out.print(" " + lake.area);
		}
		System.out.println();
	}

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

}



Measured memory_bytes: 34508
#include <bits/stdc++.h>
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;
template <typename... Args> void dbg(Args &&... args) {
  using expander = int[];
  (void)expander{
      0,
      (static_cast<void>(void(cout << std::forward<Args>(args) << " ")), 0)...};
  cout << endl;
}
void gen() {
  exit(0);
}

const int N = (int)1e5 + 7;
int n, q;
char s[N];
int tot[N] = {0};

void input() {
  scanf("%d %d", &n, &q);
  scanf("%s", s);
}

void solve() {
  for (int i = 1; i < n; i++) {
    if (s[i - 1] == 'A' && s[i] == 'C') {
      tot[i] += 1;
    }
    tot[i] += tot[i - 1];
  }

  forn(t, 0, q) {
    int l, r;
    scanf("%d %d", &l, &r);
    int left = l == 1 ? 0 : tot[l - 2];
    if (l > 1 && s[l - 1] == 'C' && s[l - 2] == 'A') {
      left++;
    }
    int count = tot[r - 1] - left;
    printf("%d\n", count);
  }
}

void clean() {
  scanf(" ");
}

int main() {
#ifdef DEBUG
  freopen("input", "r", stdin);
  // freopen("output", "w", stdout);
  // gen();
  while (!feof(stdin)) {
#endif
    input();
    solve();
#ifdef DEBUG
    clean();
  }
#endif
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    ll N, K; cin >> N >> K;
    vll A(N), F(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    for(int i=0; i<N; i++){
        cin >> F[i];
    }
    sort(A.begin(),A.end());
    sort(F.begin(),F.end(),greater<ll>());
    bool a=false, b=false;
    ll min = 0; ll max = 1000000000001; ll mid = (max+min)/2;

    ll k; ll mid2;
    ll t = 0;
    while(a==true&&b==true||a==false&&b==false){
        k = 0;

        for(int i=0; i<N; i++){
            if(F[i]*A[i]>mid){
                k += (F[i]*A[i]-mid)/F[i];
                if((F[i]*A[i]-mid)%F[i] != 0){
                    k++;
                }
            }
        }
        if(k <= K){
            a = true;
        }else{
            a = false;
        }

        k = 0;
        mid2 = mid+1;

        for(int i=0; i<N; i++){
            if(F[i]*A[i]>mid2){
                k += (F[i]*A[i]-mid2)/F[i];
                if((F[i]*A[i]-mid2)%F[i] != 0){
                    k++;
                }
            }
        }
        if(k <= K){
            b = true;
        }else{
            b = false;
        }

        if(a==true&&b==true){
            max = mid;
            mid = (mid+min)/2;
        }
        else if(a==false&&b==false){    
            min = mid2;
            mid = (mid+max)/2;
        }

        if(min == mid&&mid == max){
            t = 1;
            break;
        }
    }
    if(t == 0){
    cout << mid2;
    }else{
        cout << mid;
    }
}

Measured memory_bytes: 3328
sx, sy, tx, ty = map(int, input().split())
dx, dy = tx - sx, ty - sy

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

Measured memory_bytes: 3060
#include <stdio.h>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    long long int q,h,s,d,n,num=0;
    cin>>q>>h>>s>>d>>n;
    long long int m[4];
	 m[0]=q*8,m[1]=h*4,m[2]=s*2,m[3]=d;
	long long int l[4];
	 l[0]=q*8,l[1]=h*4,l[2]=s*2,l[3]=d;
	sort(l,l+4);
	if (l[0]==m[3])
	{
	    num=l[0]*(n/2);
	    if ((n%2)!=0)
	        num=num+l[1]/2;
	}
	else
	{
	    num=l[0]/2*n;
	}
	cout<<num<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long unsigned int ll;

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

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


int main() {

  int a, b, c;
  cin >> a >> b >> c;

  int maxa = max(a*10+b+c, max(b*10+a+c, 10*c+a+b));

  cout << maxa << endl;

  return 0;
}


Measured memory_bytes: 256
/*Priyansh Agarwal*/
#include<bits/stdc++.h>
#include<algorithm>
#include<unordered_map>
#include<vector>
#include<unordered_set>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define nline "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define debug(x) cout << #x << " " << x <<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef priority_queue<int, vector<int>, function<bool(int, int)>> pq_func;
/*---------------------------------------------------------------------------------------------------------------------------*/
int gcd(int a, int b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll expo(ll a, ll b, ll mod) {ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
vector<int> sieve(int n) {int*arr = new int[n + 1](); vector<int> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
void extendgcd(ll a, ll b, ll*v) {if (b == 0) {v[0] = 1; v[1] = 0; v[2] = a; return ;} extendgcd(b, a % b, v); ll x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;} //pass an arry of size 3
ll mminv(ll a, ll b) {ll arr[3]; extendgcd(a, b, arr); return arr[0];} //for non prime b
ll mminvprime(ll a, ll b) {return expo(a, b - 2, b);}
bool revsort(ll a, ll b) {return a > b;}
void swap(int &x, int &y) {int temp = x; x = y; y = temp;}
/*--------------------------------------------------------------------------------------------------------------------------*/
int main()
{
	fastio();
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
	freopen("Error.txt", "w", stderr);
#endif
	unordered_set<string> us;
	int n;
	cin >> n;
	while (n--)
	{
		string p;
		cin >> p;
		us.insert(p);
	}
	cout << us.size() << endl;
	return 0;
}

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

const int maxn = 1e5+10;
char s[maxn];

int main(){
	scanf("%s",s);
	int len = strlen(s);

	int cnt=0;
	for(int i=0; i<len-1; i++){
		while(s[i]==s[i+1]) i++;
		cnt++;
	}
	if(s[len-2]!=s[len-1]) cnt++;
	printf("%d\n",cnt-1);
}

Measured memory_bytes: 384
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}

int main(){
  long ii,jj,kk;
  vector<int> a;
  int n,minj,cnt,tmp;
  cnt = 0;
  
  cin >> n;

  a.resize(n);

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

  for(ii=0;ii<n;ii++){
    minj = ii;

    for(jj=ii;jj<n;jj++){
      if(a[jj] < a[minj]){
        minj = jj;
      }
    }
    
    if(minj != ii){
      tmp = a[ii];
      a[ii] = a[minj];
      a[minj] = tmp;

      cnt++;
    }
    
  }

  vector<int>::iterator it;
  it = a.begin();

  while(it != a.end()){
    cout << *it ;
    it++;
    if(it != a.end()){
      cout << " ";
    }
  }
  cout << endl;

  cout << cnt <<endl;
  return 0;
}



Measured memory_bytes: 3080
from itertools import accumulate
from math import log2

n, k = map(int, input().split())
a = list(map(int, input().split()))

for j in range(k):
    a01 = [0] * (n + 1)
    for i, ai in enumerate(a):
        l, r = max(0, i - ai), min(i + ai + 1, n)
        a01[l] += 1
        a01[r] -= 1
    a = list(accumulate(a01))
    if all(ai == n for ai in a[:-1]):
        break
print(*a[:-1])


Measured memory_bytes: 188344
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr = ds.begin(); itr != ds.end(); ++itr)
#define mp make_pair
#define INF 2000000000
#define INFL 2000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;

int main() {
	int N;
	cin >> N;
	vi a(N);
	int m = 0;
	rep(i, N) {
		cin >> a[i];
		m = max(m, a[i]);
	}
	rep(i, m + 1) {
		int d = max(m - i, i);
		bool flag = true;
		rep(j, a.size()) {
			if (a[j] == d) {
				a.erase(a.begin() + j);
				flag = false;
				break;
			}
		}
		if (flag) {
			cout << "Impossible" << endl;
			return 0;
		}
	}
	rep(i, a.size()) {
		if (a[i] <= (m + 1) / 2) {
			cout << "Impossible" << endl;
			return 0;
		}
	}

	cout << "Possible" << endl;

	return 0;
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const M = parseInt(arg[0].split(" ")[1]);
    
    const ab = arg.slice(1, M + 1).map(n=>n.split(" ").map(l=>parseInt(l)));
    
    // 区間の終端でソート
    ab.sort((a,b)=>a[1] - b[1]);
    
    let answer = 0;
    let endTime = 0;
    
    // 貪欲
    for(let i=0; i<M; i++) {
        if(ab[i][0] >= endTime) {
            endTime = ab[i][1];
            answer++;
        }
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 56604
# zentansaku
S = input()
T = input()
Ns = len(S)
Nt = len(T)

cand = []

N = max(0, Ns - Nt + 1)
for i in range(N):
    for j in range(Nt):
        s = S[i + j]
        t = T[j]
        if s == t or s == "?":
            continue
        else:
            break
    else:
        pre = S[:i].replace("?", "a")
        suf = S[i+j+1:].replace("?", "a")
        cand.append(pre + T + suf)

if not cand:
    print("UNRESTORABLE")
else:
    cand.sort()
    print(cand[0])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FASTIO ios::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, n) for(int (i) = 0; (i) < (int)(n); ++(i))
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())

int main() {
	FASTIO;
	ll a, b, c, d, ans = -1000000000000000000;
	cin >> a >> b >> c >> d;
	vector<ll> v;
	v.eb(a*c);
	v.eb(a*d);
	v.eb(b*c);
	v.eb(b*d);
	for(auto i : v){
	    ans = max(ans, i);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  bool n = false;
  bool w = false;
  bool s = false;
  bool e = false;
  for (int i = 0; i < S.size(); i++){
    if (S[i] == 'N') n = true;
    if (S[i] == 'W') w = true;
    if (S[i] == 'S') s = true;
    if (S[i] == 'E') e = true;
  }
  if ((n ^ s) || (w ^ e)){
    cout << "No";
  } else {
    cout << "Yes";
  }
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;
list<long long int> Prime(int M) {
	list<long long int>P;
	P.push_back(2);
	P.push_back(3);
	for (int i = 5; i <= M; i += 6) {
		bool flag = true;
		for (auto j : P) {
			if (i%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i);
		flag = true;
		for (auto j : P) {
			if ((i + 2) % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i + 2);
	}
	return P;
}

long long int N, M, K, Q, W, H;
long long int ans;



int main() {
	ios::sync_with_stdio(false);
	int num[3];
	for (int i = 0; i < 3; i++)cin >> num[i];
	sort(num, num + 3);
	if (num[0] + num[1] == num[2])cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,M;
	cin >> N >> M;
	if(N > M)swap(N,M);
	if(N == 1){
		if(M==1)printf("1\n");else
			printf("%d\n",M-2);
	}else
		printf("%lld\n",(N-2LL)*(M-2LL));
	return 0;
}


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

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

  vector<int> a(N);

  for(int i = 0; i < N; i++){
    cin >> a.at(i);
  }

  int sum = 0;
  for(int i = 0; i < N; i++){
    sum += a.at(i);
  }

  vector<int> b(N - 1);

  for(int i = 0; i < N - 1; i++){
    int s = 0;
    for(int j = 0; j <= i; j++){
      s += a.at(j);
    }
    b.at(i) = 2 * s - sum;
    if(b.at(i) < 0){
      b.at(i) = -b.at(i);
    }
  }

  sort(b.begin(), b.end());
  
  cout << b.at(0) << endl;

}

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

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    long long A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    int ans = INT32_MAX;
    
    for (int i = 0; i <= 2*max(X, Y); i+=2) {
        int x = i/2, y = i/2;
        int cost = C * i;
        if (X > x) cost += A * (X - x);
        if (Y > y) cost += B * (Y - y);
        ans = min(ans, cost);
    }

    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3656
n, m = map(int, input().split())

x = list(map(int, input().split()))
x.sort()

distance = []

for i in range(len(x) - 1):
    tmp = x[i + 1] - x[i]
    distance.append(tmp)

distance.sort()
if n >= m:
    print(0)
else:
    for i in range(n - 1):
        distance.pop()

    print(sum(distance))


Measured memory_bytes: 13960
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define mp make_pair
#define ll long long
#define ld double
#define ull unsigned long long
#define PI pair < int, int > 

const int N = 123;
const int M = 123;
const ld Pi = acos(-1);
const ll Inf = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const int Sz = 501;
const int MOD = 1e9 + 7;

void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
int mult(int a, int b) {
  return 1ll * a * b % mod;
}
int sum(int a, int b) {
  add(a, b);
  return a;
}

int n, m, dp[N][N], cnt[N];
char a[N][N];
queue < pair < int, int > > q;

void solve() { 
  cin >> n >> m;
  for (int i = 1;i <= n;i++) {
    for (int j = 1;j <= m;j++) {
      cin >> a[i][j];
      dp[i][j] = inf;
      if (a[i][j] == '.') continue;
      int dist = i + j - 1;
      cnt[dist]++;
    }
  }
  for (int i = 1;i <= n + m - 1;i++) {
    //cout << "i = " << i << " cnt = " << cnt[i] << endl;
    if (cnt[i] != 1) {
      cout << "Impossible\n";
      return;
    }
  }
  q.push({1, 1});
  dp[1][1] = 1;
  while(q.size()) {
    int x = q.front().f;
    int y = q.front().s;
    q.pop();
    if (x < n && a[x + 1][y] == '#' && dp[x + 1][y] > dp[x][y] + 1) {
      dp[x + 1][y] = dp[x][y] + 1;
      q.push({x + 1, y});
    }
    if (y < m && a[x][y + 1] == '#' && dp[x][y + 1] > dp[x][y] + 1) {
      dp[x][y + 1] = dp[x][y] + 1;
      q.push({x, y + 1});
    }
  }
  if (dp[n][m] == inf) cout << "Impossible\n";
  else cout << "Possible\n";
}
  
int main() {
  #ifdef wws
   freopen("in", "r", stdin);
   // freopen("in", "w", stdout);
  #endif 
  ios_base::sync_with_stdio(0);
  int tt = 1; 
  while(tt--) solve();
  return 0;
}

Measured memory_bytes: 256
S = input()

n = len(S)
i = 0
last = ''
k = 0
while True:
    if i >= n:
        break
    if i == n-2 and S[i] == S[i+1]:
        i += 1
    if last == S[i]:
        last = S[i:i+2]
        i += 1
    else:
        last = S[i]
    k += 1
    i += 1
print(k)


Measured memory_bytes: 41308
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

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

    void run() {

        int h1 = sc.nextInt();
        int m1 = sc.nextInt();
        int h2 = sc.nextInt();
        int m2 = sc.nextInt();
        int k = sc.nextInt();

        int diff = (h2-h1) * 60 + (m2-m1);

        System.out.println(diff-k);

    }
}

Measured memory_bytes: 35724
import java.util.*;

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

        int N = sc.nextInt();
        int candy = 0;

        for(int i=1; i<=N; i++){
            candy += i;
        }
        
        System.out.println(candy);
    }
}

Measured memory_bytes: 21204
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
const int MR=1e6+10;
typedef long long LL;

int main() {
	int K,A,B;
	cin>>K>>A>>B;
	if((A+K-1)/K<=B/K){
		printf("OK\n");
	}
	else printf("NG\n");
    return 0;
}

Measured memory_bytes: 3636
# 入力の取得(文字列)
s = input()

# 処理
result = 0
# ビット全探索(「2のn乗」数分ループ)
# len-1する理由：桁数 = パターン数ではないため。パターン数は数は2の「桁数-1」乗。
# 例：3桁(123)の場合 = 検証パターンは2の2乗。(1 「+」 2 「+」  3)。
for i in range(1 << len(s)-1):
    # -dev- bit = bin(i)
    left_digit = 0

    # パターン桁数分ループ(len(s)-1)
    # 12+3(123の「01」)の場合:i=0～4)
    for j in range(len(s)-1):
        # 値が１の桁が存在する場合
        if i & 1 << j:
            # 12+3(123の「01」)の場合:12を加算する式はint(s[0:2])。だからint(s[0:i(=1)+1] を実装
            result += int(s[left_digit:j + 1])
            # -dev- print("ループ中")
            # -dev- print(int(s[left_digit:j + 1]))
            # 12+3(123の「01」)の場合:12を加算後、left_digitは2になる。だから「j + 1」を代入する。
            left_digit = j + 1

    # 12+3(123の「01」)の場合:ループ終了時、3が加算されていない。だから「int(s[left_digit:])」を加算する。
    result += int(s[left_digit:])
    # -dev- print("ループ終了時")
    # -dev- print(int(s[left_digit:]))
# 結果出力
# -dev- print("最終結果")
print(result)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int n;
int ar[200005];
int ar1[200005];
int32_t main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>ar[i];
		ar1[i]=ar[i];
	}
	sort(ar+1,ar+n+1);
	int m1 = ar[n/2];
	int m2 = ar[n/2+1];
	if(m1==m2){
		for(int i=1;i<=n;i++){
			cout<<m1<<"\n";
		}
		return 0;
	}
	for(int i=1;i<=n;i++){
		if(ar1[i]>m1){
			cout<<m1;
		}
		else {
			cout<<m2;
		}
		cout<<"\n";
	}
}


Measured memory_bytes: 5376
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <tuple>
#include<map>

using namespace std;
int main() {
	int A, B;
	char op;
	cin >> A >> op >> B;

	if (op == '+') {
		cout << A + B << endl;
	}
	else {
		cout << A - B << endl;
	}

}

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

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

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

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

bool chk(ll n)
{
    map<char,ll> C;
    string s = to_string(n);
    REP(i,0,SZ(s)) ++C[s[i]];
    if(C['3']*C['5']*C['7'] > 0) return true;
    else return false;
}

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

    vec A;
    ll k = 0;
    A.pb(3);
    A.pb(5);
    A.pb(7);
    while(true) {
        A.pb(A[k]*10+3);
        A.pb(A[k]*10+5);
        A.pb(A[k]*10+7);
        ++k;
        if(A.back() > 1000000000LL) break;
    }

    ll cnt = 0;
    REP(i,0,SZ(A)) {
        if(A[i] > N) break;
        if(chk(A[i])) ++cnt; 
    }
    PR(cnt);

    return 0;
}

/*



*/

Measured memory_bytes: 3764
m, d = map(int, input().split())
ans = 0
for i in range(1, m+1):
    for j in range(1, d+1):
        d1, d10 = j % 10, int(j/10) % 10
        if d1 >= 2 and d10 >= 2 and d1 * d10 == i: ans += 1
print(ans)

Measured memory_bytes: 3060
N,T = gets.split(/\s/).map(&:to_i)
t = gets.split(/\s/).map(&:to_i)
s = 0
tt = t[0]

for i in 1..N-1
	if (t[i] - tt) < T
		s = s + t[i]-tt
	else
		s = s + T
	end
	tt = t[i]
end
puts s + T


Measured memory_bytes: 16004
a, v = map(int, input().split())
b, w = map(int, input().split())
T = int(input())
 
k = b - a
flag = False
 
if k >= 0:
    l = T*v - T*w 
    if (k <= l):
        flag = True
 
if k < 0:
    k = a - b
    l = T*v - T*w
    if (k <= l):
        flag = True
 
 
if (flag == True):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 9188
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            String t = in.next();
            int tot = 0;
            for (int i = 0; i < s.length(); ++i) {
                if (s.charAt(i) != t.charAt(i)) tot++;
            }
            out.println(tot);
        }

    }
}



Measured memory_bytes: 33056
#include <iostream>
#define INF 999999999

using namespace std;

int main(void){

  int e;
  while( cin >> e , e ){

    int ans = INF;
    for( int a = 0 ; a*a*a <= e ; a++ ){
      for( int b = 0 ; b*b + a*a*a <= e ; b++ ){
	ans = min( ans , e - a*a*a - b*b + b + a ); 
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<LL>
#define VVL vector<vector<LL>>
#define VVVL vector<vector<vector<LL>>>
#define VB vector<bool>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

template<class T> T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> void print(T x) { std::cout << x << std::endl; }

const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy = { 0, -1, 0, 1 }, dx = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）

using namespace std;

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

    while (true) {
        int N, M;
        cin >> N >> M;
        if (N == 0 and M == 0) { break; }

        vector<int> C(M), X(N + 1);
        X[0] = 128;
        FOR(i, 0, M) {
            cin >> C[i];
        }
        FOR(i, 0, N) {
            cin >> X[i + 1];
        }

        VVL dp(N + 2, VL(256, LONG_LONG_MAX));
        dp[0][128] = 0;

        FOR(i, 0, X.size() - 1) {
            int x = X[i + 1];

            FOR(j, 0, dp[0].size()) {
                if (dp[i][j] == LONG_LONG_MAX) { continue; }
                FOE(c, C) {
                    int v = min(max(0, j + c), 255);
                    dp[i + 1][v] = min(dp[i + 1][v], dp[i][j] + (x - v) * (x - v));
                }
            }
        }
        LL ans = LLONG_MAX;
        FOR(j, 0, dp[0].size()) {
            ans = min(ans, dp[N][j]);
        }
        print(ans);
    }
    return 0;
}


Measured memory_bytes: 43836
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    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;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  vll A(n);
  ll count=0;
  bl b=false;
  ll ans=0;
  
  FOR(i,0,n){
    ci(A[i])
  if(A[i]==0){
    b=true;
  }
  else if(A[i]<0){
    count++;
  }
  }
  
  FOR(i,0,n){
    A[i]=abs(A[i]);
    ans+=A[i];
  }
  
  SORT(A);
  
  if(b||count%2==0){
    co(ans)
  }
  else{
    co(ans-A[0]-A[0])
  }
}

Measured memory_bytes: 1024
maxa=0
N=int(input())
L=list(map(int,input().split()))
c=[0]*100000
for i in L:
  c[i]+=1
for i in range(1,99999):
  s=c[i]+c[i-1]+c[i+1]
  maxa=max(maxa,s)
print(maxa)

Measured memory_bytes: 20688
local mfl = math.floor

local function comp(a, b)
  return a < b
end

local function lower_bound(ary, x)
  local num = #ary
  if num == 0 then return 1 end
  if not comp(ary[1], x) then return 1 end
  if comp(ary[num], x) then return num + 1 end
  local min, max = 1, num
  while 1 < max - min do
    local mid = mfl((min + max) / 2)
    if comp(ary[mid], x) then
      min = mid
    else
      max = mid
    end
  end
  return max
end

local n, k = io.read("*n", "*n")
local a = {}
local poslist = {}
for i = 1, n do
  a[i] = io.read("*n")
  if not poslist[a[i]] then
    poslist[a[i]] = {}
  end
  table.insert(poslist[a[i]], i)
end

local rep = 1
local curpos = 1
while true do
  local pary = poslist[a[curpos]]
  local nxt = lower_bound(pary, curpos + 1)
  local np = 0
  if #pary < nxt then
    rep = rep + 1
    curpos = pary[1] + 1
  else
    curpos = pary[nxt] + 1
  end
  if n < curpos then
    break
  end
end
k = k % rep
if k == 0 then
  print("")
else
  rep = 1
  curpos = 1
  while true do
    if k == rep then break end
    local pary = poslist[a[curpos]]
    local nxt = lower_bound(pary, curpos + 1)
    local np = 0
    if #pary < nxt then
      rep = rep + 1
      curpos = pary[1] + 1
    else
      curpos = pary[nxt] + 1
    end
  end
  local ans = {}
  while true do
    local pary = poslist[a[curpos]]
    local nxt = lower_bound(pary, curpos + 1)
    if #pary < nxt then
      table.insert(ans, a[curpos])
      curpos = curpos + 1
    else
      curpos = pary[nxt] + 1
    end
    if n < curpos then break end
  end
  print(table.concat(ans, " "))
end


Measured memory_bytes: 36152
#include <stdio.h>

int A[1000];
int max,min;
int a,t,maxcnt,mincnt=0;
int sum,avg=0;
int result[1000];

//int w,h,x,y,r;

int main(void) {
  while(1){
    if(scanf("%d",&a) && a!=0){
      for(int i=0;i<a;i++){
        scanf("%d",&A[i]);
    }
    max=A[0];
    min=A[0];
      for(int i=1;i<a;i++){
        if(A[i]>max){
          max=A[i];
          maxcnt=i;
        }
        else if(A[i]<min){
          min=A[i];
          mincnt=i;
        }
      }
      A[maxcnt]=0;
      A[mincnt]=0;
      for(int i=0;i<a;i++){
        sum = sum + A[i];
      }
      avg=sum/(a-2);
      result[t] = avg;
      t++;
      max=0;
      min=0;
      maxcnt=0;
      mincnt=0;
      sum=0;
      avg=0;
    }
    else break;;
}

for(int i=0;i<t;i++){
printf("%d\n",result[i]);
}


    return 0;
  }



Measured memory_bytes: 2044
#include <stdio.h>

int main(void )
{
    int i , count=0;
    char a[4];

    for( i=0 ; i<4 ; i++)
        scanf("%c" , &a[i]);

    for(i=0 ; i<4 ; i++){
        if(a[i]=='+')
            count++;
        else
            count--;
    }

    printf("%d" , count);
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
#define mod 1000000007
#define pub(a) push_back(a)
#define mp(a,b) make_pair(a,b)




int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s,t;
    cin>>s>>t;
    ll c=0;
    for(ll i =0;i<s.length();i++){
        if(s[i]!=t[i]){
            c++;
        }
    }
    cout<<c;

    return 0;
}


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

int main()
{
	int i,max;
	cin >> i;
	int* v = new int[i];
	int* c = new int[i];
	max = 0;
	for (int j = 0; j < i; j++)
	{
		cin >> v[j];
	}
	for (int k = 0; k < i; k++)
	{
		cin >> c[k];
		if (v[k] - c[k] > 0) max += v[k] - c[k];
	}
	cout << max;
		return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define li long int
#define ld long double
using namespace std;

int main()
{
    string s,t;
    cin>>s>>t;
    int n=s.size();
    int m=t.size();
    int ans=INT_MAX;;
    for(int i=0;i<n-m+1;i++)
    {
        int k=i;
        int c=0;
        for(int j=0;j<m;j++)
        {
            if(s[k]!=t[j])
            {
                c++;
            }
            k++;
        }
        ans=min(ans,c);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3536
from collections import Counter

n=int(input())
s=[input() for i in range(n)]
c=Counter(s)
c_v=sorted(c.values(),reverse=True)

m=c_v[0]

ans=[]
for k,v in c.items():
 if v==m:
  ans.append(k)
ans.sort()
for i in ans:
 print(i)

Measured memory_bytes: 35564