akhauriyash/Code-Regression huggingface dataset:
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using static System.Math;
using static System.Console;

class E { static void Main() => new J(); }
class J
{
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		var I = G();
		int V = I[0], E = I[1], D = 10;
		var es = new List<int>[V];
		for (var u = 0; u < V; u++) es[u] = new List<int> { u };
		for (var e = 0; e < E; e++)
		{
			I = G();
			int a = I[0] - 1, b = I[1] - 1;
			es[a].Add(b);
			es[b].Add(a);
		}
		var Q = F();
		var col = new int[Q + 1];
		var dp = new int[V, D + 1];
		for (var q = 0; q < Q; q++)
		{
			I = G();
			col[q + 1] = I[2];
			int u = I[0] - 1, d = I[1];
			dp[u, d] = Max(dp[u, d], q + 1);
		}
		for (var d = D; d > 0; d--) for (var u = 0; u < V; u++) foreach (var v in es[u]) dp[v, d - 1] = Max(dp[v, d - 1], dp[u, d]);
		for (var u = 0; u < V; u++) WriteLine(col[dp[u, 0]]);
		Out.Flush();
	}
}

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

typedef long long ll;
const int MAX = 1e5 + 5;

int sum[2 * MAX];

ll f(int X, vector<int>& V) {
    ll cnt = 0;
    for (int i = 0; i < V.size(); ++i) {
        int index = X - V[i];
        if (index < 0) index = 0;
        cnt += sum[index];
    }
    return cnt;
}

int main(void){
    int N;
    ll M;
    cin >> N >> M;
    
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    
    sort(A.begin(), A.end());
    
    int now = N - 1;
    bool ok = true;
    for (int i = 2 * MAX - 2; i >= 0; --i) {
        if (ok && i == A[now]) {
            sum[i] = sum[i + 1] + 1;
            now--;
            while (0 <= now && A[now] == A[now + 1]) {
                sum[i]++;
                now--;
            }
            if (now < 0) ok = false;
        } else {
            sum[i] = sum[i + 1];
        }
    }
    
    int l = 0, r = 2 * MAX;
    while (r - l > 1) {
        int mid = (l + r) / 2;
        if (f(mid, A) < M) {
            r = mid;
        } else {
            l = mid;
        }
    }
    
    vector<ll> sum2(N + 1);
    for (int i = 0; i < N; ++i) {
        sum2[i + 1] = sum2[i] + A[N - 1 - i];
    }
    
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        int index = lower_bound(A.begin(), A.end(), r - A[i]) - A.begin();
        index = N - index;
        ans += sum2[index] + (ll)A[i] * index;
    }
    
    M -= f(r, A);
    
    ans += (ll)l * M;
    
    cout << ans << endl;
}


Measured memory_bytes: 2176
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
	ll N;
	cin >> N;
	ll countzero=0;
	vector<vll> vv;
	bool flg;
	for(int i=0; i<N; i++){
		vll a(2,1);
		cin >> a[0];
		if(a[0]==0){
			countzero++;
		}else{
			flg=true;
			for(int j=0; j<vv.size(); j++){
				if(a[0]==vv[j][0]){
					vv[j][1]++;
					flg=false;
				}
			}
			if(flg){
				vv.push_back(a);
			}
			if(vv.size()>3){
				break;
			}
		}
	}

	bool ok=false;
	if(vv.size()==0){
		cout << "Yes" << endl;
		return 0;
	}
	if(N%3!=0){
		cout << "No" << endl;
		return 0;
	}
	if(countzero==N/3){
		if(vv.size()==1){
			if(vv[0][1]==N*2/3){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}else{
		if(vv.size()==3){
			if(vv[0][1]==N/3 && vv[1][1]==N/3 && vv[2][1]==N/3){
				if(vv[0][0]==(ll)(vv[1][0]^vv[2][0])){
					ok=true;
				}
			}
		}
	}

	if(ok){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;


int main(int argc, char const *argv[]) {
  ll n, k, c;std::cin >> n >> k >> c;
  string s;std::cin >> s;
  vll L(n+1, 0), R(n+1, 0);
  for(int i=1;i<=n;i++){
    L[i] = L[i-1];
    if(s[n-i]=='x') continue;
    if(i>=c+1) L[i] = max(L[i], (L[i-c-1] + 1));
    else L[i] = max(L[i], (ll)1);
  }

  if(c==0){
    if(L[n]==k){
      for(int i=0;i<n;i++) if(s[i]=='o') std::cout << i+1 << '\n';
      return 0;
    }else{
      std::cout << '\n';
      return 0;
    }
  }
  for(int i=1;i<=n;i++){
    R[i] = R[i-1];
    if(s[i-1]=='x') continue;
    if(i>=c+1) R[i] = max(R[i], (R[i-c-1] + 1));
    else R[i] = max(R[i], (ll)1);
  }
  multiset<vll> mp;
  for(int i=0;;i++){
    ll r = n-i-1, l = i-c+1;
    //std::cout << max((ll)0, l) << " " << min(n, max(r, (ll)0)) << '\n';
    ll cos = L[min(n, max(r, (ll)0))]+R[max((ll)0, l)];
    mp.insert(vll{i-c+1, -1, cos});
    mp.insert(vll{i+1, 1, cos});
    if(l==n) break;
  }
  vll ans(n);
  vll e;
  auto itr = mp.begin();
  multiset<ll> t;

  for(int i=0;i<n;i++){
    while(mp.size()&&itr!=mp.end()&&(*itr)[0]<=i){
      //std::cout << (*itr)[0] << " " <<(*itr)[1] << " " << (*itr)[2] << '\n';
      if((*itr)[1]==-1) t.insert((*itr)[2]);
      else{
        auto op = t.find((*itr)[2]);
        t.erase(op);
      }
      itr++;
    }
    ans[i] = (*(--t.end()));
    if(s[i]=='o' && ans[i]<k&&L[n]>=k) e.push_back(i+1);
  }

  for(auto E:e) std::cout << E << '\n';
  if(e.size()==0) std::cout << '\n';
  return 0;
}


Measured memory_bytes: 42876
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

bool IsPrime(int num) {
    if(num<2) return false;
    else if(num==2) return true;
    else if(num%2==0) return false;

    double sqrtNum = sqrt(num);
    for(int i=3; i<=sqrtNum; i+=2) {
        if(num%i==0) {
            return false;
        }
    }
    return true;
}

int main() {
    ll X;
    bool ok=false;

    cin >> X;

    while(ok==false){
        ok = IsPrime(X);
        if(ok == false) {
            X++;
        }
    }

    cout << X << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define Int long long
using namespace std;

const int MAXN=500005;
const long MOD=(long)(1e9+7);
vector<int> adj[MAXN];
vector<pair<int,int>> G[MAXN];

Int N,M,K;
Int B,C,H,W;
Int X,Y,Z;
vector<Int> A;

Int ceilS(Int x,Int y){
    return (x+y-1)/y;
}
using D=long double;

Int perform(Int x){
    return (x*(x+1))/2LL;
}

int main()
{
     cin>>N;
     A.resize(N);
     
     for(auto &x:A) cin>>x;
     Int ans=0;
     for(int i=1;i+1<N;++i){
         vector<Int> inner;
         for(int j=i-1;j<=i+1;++j) inner.pb(A[j]);
         sort(inner.begin(),inner.end());
         ans+=(inner[1]==A[i]);
     }
     cout<<ans<<"\n";
     
}


Measured memory_bytes: 27084
#include <bits/stdc++.h>
using namespace std;
int main(){
  int r,d,moto;
  cin >> r >> d >> moto;
  int x[100];
  x[0] = moto;
  for(int i=1;i<11;i++){
    x[i] = x[i-1]*r-d;
    cout << x[i] << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template

int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n,r; cin>>n>>r;
    if(n>=10) cout<<r<<newl;
    else cout<< r + (100 * (10-n))<<newl;
}



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

using namespace std;

const int N = 4e3 + 4, inf = 1e9 + 7;
struct BIT {
  int n;
  int bit[N][N];
  BIT() : n(N-2) {
    memset(bit, 0, sizeof bit);
  }
  int get(int x, int y) {
    ++x, ++y;
    int yy = y, ret = 0;
    for (; x; x -= x&-x)
      for (y = yy; y <= n; y += y&-y)
        ret += bit[x][y];
    return ret;
  }
  void upd(int x, int y, int v) {
    ++x, ++y;
    int yy = y;
    for (; x <= n; x += x&-x)
      for (y = yy; y; y -= y&-y)
        bit[x][y] += v;    
  }
};

BIT fen[2];
int a[N];
int c[N];
int pos[2][N];
int dp[N][N];

void upd(int & var, int val) {
  if (var > val) var = val;
}

int main() {
  int n;
  scanf("%d", &n);
  fen[0].n = fen[1].n = 2 * n + 2;
  for (int i = 0; i < n * 2; ++i) {
    char col;
    scanf(" %c %d", &col, a+i); --a[i];
    c[i] = col == 'B';
    pos[c[i]][a[i]] = i;
    fen[c[i]].upd(i, a[i], +1);
  }
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= n; ++j)
      dp[i][j] = inf;
  dp[0][0] = 0;
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) {
      if (i < n) {
        int cost = fen[0].get(pos[0][i], i)-1+fen[1].get(pos[0][i], j);
        upd(dp[i+1][j], dp[i][j] + cost);
      }
      if (j < n) {
        int cost = fen[1].get(pos[1][j], j)-1+fen[0].get(pos[1][j], i);
        upd(dp[i][j+1], dp[i][j] + cost);
      }
    }
  }
  printf("%d\n", dp[n][n]);
  return 0;
}

Measured memory_bytes: 158976
def Lucky_PIN():
	n=int(input())
	s=input()
	ans=0
	for i in range(1000):
		p='{:03d}'.format(i)
		n1=s.find(p[0])
		if n1!=-1:
			n2=s[n1+1:].find(p[1])
			if n2!=-1:
				n3=s[n1+n2+2:].find(p[2])
				if n3!=-1:
					ans+=1
	print(ans)
if __name__=='__main__':
	Lucky_PIN()

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B;
  for (int i = 0; i < N; i++) cin >> A.at(i);

  B = A;
  sort(B.rbegin(), B.rend());

  for (int i = 0; i < N; i++) {
    if (A.at(i) == B.at(0)) cout << B.at(1) << "\n";
    else cout << B.at(0) << "\n";
  }
}

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

int main(){
	int n, d;
	while(cin >> n >> d && (n || d)){
		vector<int> si[100];
		int max_potential = -1;
		for(int i = 0; i < n; i++){
			int m;
			cin >> m;
			for(int j = 0; j < m; j++){
				int cap;
				cin >> cap;
				if(si[i].empty()) si[i].push_back(cap);
				else si[i].push_back(cap + si[i][si[i].size()-1]);
			}
			if(!si[i].empty() && max_potential < si[i][si[i].size()-1]) max_potential = si[i][si[i].size()-1];
		}
		bool update = true;
		while(update){ 
			update = false;
			for(int i = 0; i < n; i++){
				max_potential = 0;
				if(si[i].empty()) continue;
				for(int j = 0; j < n; j++){
					if(j != i && !si[j].empty()) max_potential = max(max_potential, si[j][si[j].size()-1]);
				}
				while(!si[i].empty() && ((si[i].size() == 1 && d >= max_potential)
					 || (si[i].size() > 1 && si[i][si[i].size() - 2] + d >= max_potential))){
					int c = si[i][si[i].size()-1];
					si[i].pop_back();
					update = true;
				}
			}
		}
		bool f = true;
		for(int i = 0; i < n; i++){
			if(!si[i].empty()) f = false;
		}
		if(f) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 940
N, M = map(int, input().split())
corret_list = [False] * (N+1)
wa_number = [0] * (N+1)
true_ans = 0
penalty = 0
for _ in range(M):
    P, S = input().split()
    P = int(P)
    if S == 'AC':
        if not corret_list[P]:
            true_ans += 1
            corret_list[P] = True
            continue
        else:
            continue
    else:
        if not corret_list[P]:
            wa_number[P] += 1
            continue
for i in range(len(corret_list)):
    if corret_list[i]:
        penalty += wa_number[i]
print(true_ans, penalty)

Measured memory_bytes: 10412
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int block = 0;
    int brokenBlock = 0;
    boolean isSatisfied = false;
    for (int i = 0; i < a; i++) {
      int b = sc.nextInt();
      if (b == block + 1) {
        isSatisfied = true;
        block++;
      } else {
        brokenBlock++;
      }
    }
    if (isSatisfied) {
      System.out.println(brokenBlock);
    } else {
      System.out.println(-1);
    }
  }
}


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

int main() {
  int N, K, l;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    int j;
    cin >> j;
    if (j * 2 < (K - j) * 2) {
      l += j * 2;
    }
    else {
      l += (K - j) * 2;
    }
  }
  cout << l << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    vector<int> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    sort(x.begin(), x.end());
    
    int r = 1 << 30;
    int j0 = x.front();
    int j1 = x.back();
    for (int j = j0; j <= j1; j++) {
        int t = 0;
        for (int i = 0; i < n; i++) {
            t += (x[i] - j) * (x[i] - j);
        }
        r = min(r, t);
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;

int main(){
    int a, b;
    cin>>a>>b;
    if(a%2==1 && b%2==1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
e=0
dic={}
for i in range(N):
 d=0
 B=int(N/(N-i))
 if B==1 and A[N-i-1]==1:
   dic[N-i]=1
   e+=1
 elif B>1:
  for k in range(1,B+1):
   if (k+1)*(N-i) in dic:
    d+=1
  if (d+A[N-i-1])%2==1:
   dic[N-i]=0
   e+=1
if dic=={}:
 print(0)
else:
 print(e)
 b = dic.keys()
 z=[str(a) for a in b]
 z=' '.join(z)
 print(z)


Measured memory_bytes: 23540
#include <iostream>
#include <vector>
using namespace std;
void creatVec(vector<string> &vec, size_t size, size_t &AC, size_t &WA, size_t &TLE, size_t &RE);
void check(const string &s, size_t &AC, size_t &WA, size_t &TLE, size_t &RE);
void printer(const string &s, size_t n);
int main() {
    size_t n{}, countAC{}, countWA{}, countTLE{}, countRE{};
    cin >> n;
    vector<string> words {};
    creatVec(words, n, countAC, countWA, countTLE, countRE);
    printer("AC", countAC);
    printer("WA", countWA);
    printer("TLE", countTLE);
    printer("RE", countRE);
    return 0;
}
void creatVec(vector<string> &vec, size_t size, size_t &AC, size_t &WA, size_t &TLE, size_t &RE) {
    for (size_t i{}; i < size; i++) {
        string in{};
        cin >> in;
        check(in, AC, WA, TLE, RE);
        vec.push_back(in);
    }
}
void check(const string &s, size_t &AC, size_t &WA, size_t &TLE, size_t &RE) {
    if (s == "AC") AC++;
    else if (s == "WA") WA++;
    else if (s == "TLE") TLE++;
    else if (s == "RE") RE++;
}
void printer(const string &s, size_t n) {cout << s << " x " << n << endl;}

Measured memory_bytes: 7468
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  int a;
  int kaisu = 0;
  int kaisu0 = 0;
  cin >> n;

for(int i=0;i<n;i++){
  cin >> a;
  while(a%2 == 0){
    kaisu0++;
    a=a/2;
  }
  if(i==0||(kaisu0<kaisu))
    kaisu=kaisu0;
  kaisu0=0;
}
cout << kaisu;
}

Measured memory_bytes: 256
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


enum INF = 10L^^18;

int N;
long[][] A;

void main() {
  try {
    for (; ; ) {
      N = readInt();
      A = new long[][](N, N);
      foreach (u; 0 .. N) foreach (v; 0 .. N) {
        if (u != v) {
          A[u][v] = readLong();
        }
      }
      
      auto sumL = new long[][N];
      auto sumR = new long[][N];
      foreach (u; 0 .. N) {
        sumL[u] = new long[u + 1];
        sumR[u] = new long[u + 1];
        foreach (v; 0 .. u) {
          sumL[u][v + 1] = sumL[u][v] + A[u][v];
          sumR[u][v + 1] = sumR[u][v] + A[v][u];
        }
      }
      
      auto dp = new long[][](1, 1);
      dp[0][0] = 0;
      foreach (u; 1 .. N) {
        auto dpNext = new long[][](u + 1, u + 1);
        foreach (a; 0 .. u + 1) foreach (b; a .. u + 1) {
          dpNext[a][b] = INF;
        }
        foreach (a; 0 .. u) foreach (b; a .. u) {
          // -0
          chmin(dpNext[a][b], dp[a][b] + sumL[u][a] + (sumR[u][u] - sumR[u][b]));
          // -1
          chmin(dpNext[b][u], dp[a][b] + sumL[u][b]);
        }
        dp = dpNext;
      }
      long ans = INF;
      foreach (a; 0 .. N) foreach (b; a .. N) {
        chmin(ans, dp[a][b]);
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 36476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << N); ++bit)

int main()
{
    ll R;
    cin >> R;
    cout << (R < 1200 ? "ABC" : R < 2800 ? "ARC" : "AGC") << 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(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  int ans = 0;
  int c = 0;
  int prev = v[0];
  rep(i,n-1) {
    if (prev >= v[i + 1]) c++;
    else {
      ans = max(c, ans);
      c = 0;
    }
    prev = v[i + 1];
  }
  cout << max(c, ans) << endl;
}

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

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

using namespace std;

const int N = 1e2 + 5;
int n, x[N];

int calc(int p) {
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    ans += (x[i] - p) * (x[i] - p);
  return ans;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int avg = 0;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> x[i];
    avg += x[i];
  }
  avg /= n;
  cout << min(calc(avg), calc(avg + 1));
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b)cout<<c<<endl;
  else if(b==c)cout<<a<<endl;
  else cout<<b<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimization ("O2")
#pragma GCC target("popcnt")
#pragma GCC target ("avx2")
using namespace std;
vector<vector<vector<vector<int>>>> dp;
vector<int> v;

int ans(int curr , int used , int last , int all){
    if(curr+1 == v.size()){
        return 0;
    }
    if(dp[curr][used][last][all] != -1){
        return dp[curr][used][last][all];
    }
    int ret = 0;
    if(all){
        return dp[curr][used][last][all] = ans(curr+1,0,0,0);
    }
    if(used){
        if(!last){
            if(v[curr] > 1){
                ret = v[curr]-1+ans(curr+1,1,0,0);
            }
        }
        if(v[curr] > 1 && curr+1 < v.size()){
            ret = max({ret,v[curr+1]+ans(curr+1,1,1,1),v[curr+1]-1+ans(curr+1,1,1,0)});
        }
    }else{
        ret = v[curr]+ans(curr+1,1,0,0);
        if(curr+1 < v.size()){
            ret = max({ret,v[curr+1]+ans(curr+1,1,1,1),v[curr+1]-1+ans(curr+1,1,1,0)});
        }
    }
    ret = max(ret,ans(curr+1,0,0,0));
    return dp[curr][used][last][all] = ret;
}

int solve(string f){
    v.clear();
    if(f.back() == '0'){
        f.pop_back();
    }
    int cnt = 0;
    bool ok = true;
    for(char i : f){
        if(i == '1'){
            cnt += 1;
        }else{
            ok = false;
            v.push_back(cnt);
            cnt = 0;
        }
    }
    v.push_back(cnt);
    if(ok){
        return 0;
    }
    int siz = v.size();
    dp.assign(siz,vector<vector<vector<int>>>(2,vector<vector<int>>(2,vector<int>(2,-1))));
    return ans(0,0,0,0);
}

int main(){
    int n,ans=0;
    string s;
    cin >> n >> s;
    string f = "";
    for(int i = 0 ; i < n ; i += 1){
        if((f.size() == 0 || f.back() == '0') && s[i] == '0'){
            ans += solve(f);
            f = "";
            continue;
        }
        f += s[i];
    }
    if(f.size()){
        ans += solve(f);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1928
fn main() {
    let nab = read_vec::<usize>();
    let train = nab[0] * nab[1];
    let taxi = nab[2];
    if train < taxi {
        println!("{}", train);
    } else {
        println!("{}", taxi);
    }
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 4352
N = int(input())
A = list(map(int, input().split()))
ans = abs(A[0])
ans += sum([abs(A[i]-A[i-1]) for i in range(1, N)])
ans += abs(A[-1])

for i in range(N):
    if i == 0:
        if (0 <= A[i] <= A[i+1]) or (A[i+1] <= A[i] <= 0):
            tmp = ans 
        else:
            tmp = ans - abs(A[0]) - abs(A[0]-A[1]) + abs(A[1])
        print(tmp)
    elif i == N-1:
        if (0 <= A[i] <= A[i-1]) or (A[i-1] <= A[i] <= 0):
            tmp = ans
        else:
            tmp = ans - abs(A[i]-A[i-1]) - abs(A[i]) + abs(A[i-1])
        print(tmp)
    else:
        if (A[i-1] <= A[i] <= A[i+1]) or (A[i-1] >= A[i] >= A[i+1]):
            print(ans)
        else:
            tmp = ans - abs(A[i]-A[i-1]) - abs(A[i]-A[i+1]) + abs(A[i+1]-A[i-1])
            print(tmp)

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

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

using namespace std;

int p[100000];
int q[100000];
int r[100000];

int main() {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  REP(i, A) cin >> p[i];
  REP(i, B) cin >> q[i];
  REP(i, C) cin >> r[i];

  sort(p, p + A);
  sort(q, q + B);
  sort(r, r + C);

  int ai = A - X;
  int bi = B - Y;
  int ci = C;
  while (true) {
    if (ci == 0) {
      break;
    }
    bool a = ai < A && p[ai] < r[ci - 1];
    bool b = bi < B && q[bi] < r[ci - 1];
    if (!a && !b) {
      break;
    }
    if (a && (!b || p[ai] < q[bi])) {
      ++ai;
    } else {
      ++bi;
    }
    --ci;
  }

  long long ans = 0;
  for (int i = ai; i < A; ++i) {
    ans += p[i];
  }
  for (int i = bi; i < B; ++i) {
    ans += q[i];
  }
  for (int i = ci; i < C; ++i) {
    ans += r[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  ll m = 1e6, ans = 0;
  vl cnt(m + 1, 0);
  rep(i, n) {
    if(cnt[a[i]] > 0) {
      cnt[a[i]] = 2;
      continue;
    }
    for(int j = a[i]; j <= m; j += a[i]) cnt[j]++;
  }
  rep(i, n) if(cnt[a[i]] < 2) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 12764
#include <stdio.h>
int main(void){
    int W, H, x, y, r;
    
    scanf("%d %d %d %d %d\n", &W, &H, &x, &y, &r);
    
  
    if ((x - r >= 0 && x + r <= W) && (y - r >= 0 && y + r <= H)) {
        printf("Yes\n");
    
    } else {
        printf("No\n");
    }
    
    return 0;

    
}



Measured memory_bytes: 2100
n = gets.chomp.to_i
d, x = gets.chomp.split(' ').map(&:to_i)

arr = []
(1..n).each do |i|
  arr[i-1] = gets.chomp.to_i
end

arr.each do |i|
  eaten = (d-1)/i + 1
  x += eaten
end

p x


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

int main(void) {
    int N;cin>>N;
    map<int, int> mp;
    for (int i = 2; i <= N; i++) {
        int A;cin>>A;
        if (mp.find(A) != mp.end()) mp[A] += 1;
        else mp[A] = 1;   
    }
    for (int i = 1; i <= N; i++) {
        if (mp.find(i) != mp.end()) cout << mp[i] << endl;
        else cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 12540
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Contest
{
    class Program
    {
        static int Main(string[] args)
        {
            new Program().Process();

            return 0;
        }

        private CommonInput cin;

        private void Process()
        {
            this.cin = new CommonInput();

            int a, b, c;

            a = cin.GetInt();
            b = cin.GetInt();
            c = cin.GetInt();

            Console.WriteLine("{0}", a < b && b < c ? "Yes" : "No");
        }
    }

    public class CommonInput
    {
        public CommonInput()
        {
            this._s = new string[0];
            this._i = 0;
        }

        private string[] _s;
        private int _i;
        private char[] _sep = { ' ' };

        public string GetLine()
        {
            if (this._i < this._s.Length)
                return this._s[this._i++];

            string line;
            this._i = 0;
            do
            {
                line = Console.ReadLine();
            } while (line == "");

            this._s = line.Split(this._sep, StringSplitOptions.RemoveEmptyEntries);

            return this._s[this._i++];
        }

        public int GetInt()
        {
            return int.Parse(this.GetLine());
        }

        public long GetLong()
        {
            return long.Parse(this.GetLine());
        }

        public double GetDouble()
        {
            return double.Parse(this.GetLine());
        }
    }
}

Measured memory_bytes: 5376
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
bool dfs(vector<int> &v, int pos, int sum)
{
    if(sum == 0) return true;
    if(pos >= v.size()) return false;
    if(dfs(v, pos + 1, sum - v[pos])) return true;
    if(dfs(v, pos + 1, sum)) return true;
    return false;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    int q; cin >> q;
    for(int i = 0; i < q; i++)
    {
        int x; cin >> x;
        cout << (dfs(v, 0, x) ? "yes" : "no") << endl;
    }
    return 0;
}




Measured memory_bytes: 3136
import numpy as np
def f(n, x):
    mean =  np.mean(x)
    s1 = sum((x-np.floor(mean))**2)
    s2 = sum((x-np.ceil(mean))**2)
    print(int(min(s1, s2)))

n = int(input())
x = list(map(int, input().split()))
f(n, x)


Measured memory_bytes: 12412
fun main(args: Array<String>) {

    val (N, W) = readLine()!!.split(" ").map(String::toInt)
    val WV = Array(N) { readLine()!!.split(" ").map(String::toInt) }
    val w = WV.map { it[0] }
    val v = WV.map { it[1] }


    val m = Array(N + 1) { BooleanArray(W + 1) }
    val memo = Array(N + 1) { LongArray(W + 1) }
    fun resolve(index: Int, weight: Int): Long {

        if (m[index][weight]) {
            return memo[index][weight]
        }
        val result = when {
            index == N -> {
                0
            }
            weight < w[index] -> {
                resolve(index + 1, weight)
            }
            else -> {
                Math.max(
                    resolve(index + 1, weight - w[index]) + v[index],
                    resolve(index + 1, weight)
                )
            }
        }
        memo[index][weight] = result
        m[index][weight] = true
        return result
    }

    resolve(0, W).let(::println)
}


Measured memory_bytes: 157736
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
int main() {
    ios;
ll  k,x;
  cin>>k>>x;
 if(k*500>=x)cout<<"Yes";
 else
  cout<<"No";
 
    
}

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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int32_t GCD(int32_t a, int32_t b){return b ? GCD(b, a%b) : a;}
int64_t GCD(int64_t a, int64_t b){return b ? GCD(b, a%b) : a;}
int32_t LCM(int32_t a, int32_t b){return a * b / GCD(a, b);}
int64_t LCM(int64_t a, int64_t b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7; //10^9
constexpr int64_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/



//#define int int64_t
signed main()
{
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0, i_len = (int)n; i < i_len; ++i) cin >> a[i];

	int x2 = 0;//2x=a_5-a_4+a_3-a_2+a_1
	for(int i = 0; i < n; ++i)
	{
		if(i&1) x2 -= a[i];
		else x2 += a[i];
	}
	vector<int> ans(n);
	ans[0] = x2/2;//X_1(first mountain) = x

	//editorialのX_i+1 = 2A_i-X_iではない
	//Xを決め打ちして(上で求めた),x_2とかを出している
	for(int i = 0; i < n-1; ++i)
	{
		//ans[1](x_2)~ans[n-1](x_n)まで計算
		ans[i+1] = a[i] - ans[i];//x_2 = A_1-X_1, x_3=A_2-(A_1+X_1==x_2)
	}
	//2xにしていく
	for(int i = 0; i < n; ++i){
		ans[i] *= 2;//欲しいのは2xなので2xにする
	}
	for(int i = 0; i < n; ++i){
		cout << ans[i] << '\n';
	}
}

Measured memory_bytes: 2176
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>

#include <iostream>

//AtCoder 星には四種類の塩基 A, C, G, T が存在し、A と T、C と G がそれぞれ対になります。
int main()
{
	std::string s;
    std::cin >> s;
  
	std::string out;
  switch(s[0])
  {
    case 'A':
      out = "T";
      break;
    case 'C':
      out = "G";
      break;
    case 'G':
      out = "C";
      break;
    case 'T':
      out = "A";
      break;
  }
    
  std::cout << out << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 1e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  int A,B;
  cin >> A >> B;
  cout << (A-1) * (B-1) << endl; 
}


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

int main(int argc, char const *argv[]) {
  int n;
  string s;
  int cnt = 0;
  cin >> n;
  cin >> s;

  for (size_t i = 0; i < n; i++) {
    if (s[i] == '.') cnt++;
  }
  int ans = cnt;

  for (size_t i = 0; i < n; i++) {
    if (s[i] == '.')
      cnt--;
    else if (s[i] == '#')
      cnt++;
    ans = min(ans, cnt);
  }

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

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

int main(){
    int n,d,x;
    cin >> n >> d >> x;
    vector<int> a(n);
    for (int i=0; i < n; i++){
        cin >> a[i];
    }
    int eaten = 0;
    for (int i = 0; i < n; i++){
        eaten += 1 + (d-1)/a[i];
    }
    cout << x + eaten << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<long long int> vint;
typedef vector<vector<long long int>> vvint;
typedef vector<string> vstr;
typedef long long int llint;

llint gcd(llint x, llint y) {
	while (y != 0) {
		if (x > y) {
			llint r = x % y;
			x = y;
			y = r;
		}
		else {
			llint r = y % x;
			y = r;
		}
	}
	return x;
}

int main(void) {
	int n;
	cin >> n;
	cout << n * 32 << endl;
}



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
ll max(ll a, ll b){
    return a > b? a: b;
}
const ll INF = 1e18L+7;
int main() {
    int n, W;
    ll tv = 0;
    cin >> n >> W;
    vector<ll> wt(n), val(n);
    for(int i = 0; i < n; i++) { 
        cin >> wt[i] >> val[i];
        tv += val[i];
    }

    vector< ll> dp(tv+1, INF);
    // dp[i] = min total weight of items with total val  i  
    dp[0] = 0;
    for(int i = 0; i < n; i++) {
        for(int v = tv; v >= val[i]; v--) {
                dp[v] = min(dp[v], wt[i] + dp[v-val[i]]);
        }
    }
    ll ans = 0;
    for(int i = 0; i <= tv; i++){
        if(dp[i] <= W)
            ans = max(i, ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
// Because I am lazy
// Template Start
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define en end()
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define REP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define REPI(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define REPITER(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds

#define eps 1e-6
#define pi 3.141592653589793

using namespace std;

template<class T> inline T gcd(T a, T b) { while(b) b ^= a ^= b ^= a %= b; return a; }
template<class T> inline T mod(T x) { if(x < 0) return -x; else return x; }

typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII > PPII;
typedef vector< PII > VPII;
typedef vector< PPII > VPPI;

const int MOD = 1e9 + 7;
const int INF = 1e9;
// Template End
int main(int argc, char* argv[])
{
    if(argc == 2 or argc == 3) freopen(argv[1], "r", stdin);
    if(argc == 3) freopen(argv[2], "w", stdout);
    int a, b;
    cin >> a >> b;
    cout << (a+b) % 24 << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    let mut nums = buf.split_whitespace().map(|n| i32::from_str(n).unwrap());
    let (A, B) = (nums.next().unwrap(), nums.next().unwrap());

    let ans = if A < 10 && B < 10 { A * B } else { -1 };

    println!("{}", ans);
}


Measured memory_bytes: 2156
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std ;
#define int                 long long
#define ull                 unsigned long long int
#define ld                  long double
#define vi                  vector<int>
#define vii                 vector<pair<int,int>>
#define vvi                 vector<vector<int>>
#define pii                 pair<int,int>
#define prec(x)             fixed<<setprecision(15)<<x
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define rev(x)              reverse(x.begin(),x.end())
#define mset(a,b)           memset(a,b,sizeof(a))
#define mcpy(a,b)           memcpy(a,b,sizeof(a))
#define fo0(i,n)            for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n)            for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b)           for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)            for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)            for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define mk(arr,n,type)  	type *arr=new type[n];
#define dbg(x) cerr << #x << " is " << x << endl;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
clock_t beg = clock();
const int inf=1e18;const int mod=1e9+7;const int N=2e5+9;
const double pi = 3.1415926535897932384626433;
void FILE_IO(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}

void JH(){
    int d=0,e=0,f=0,g=0,p=0,w=0,flag=0,ans=0,res=0,cnt=0,sum=0;double f1=0.0,f2=0.0,f3=0.0;
    string s;
    int n;cin>>n;
    while(n>0){
    	n-=1;
    	int r=n%26;
    	n/=26;
    	s.push_back(char('a'+r));
    }
    reverse(all(s));
    cout<<s;
}

int32_t main()
{
    FILE_IO();FAST_IO;int t=1;
    // cin>>t;
    while(t--){JH();}cerr<<(double)(clock()-beg)/1000<<"s ";
}

Measured memory_bytes: 3852
#include "bits/stdc++.h"
using namespace std;
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define nl cout<<"\n"
#define endl "\n"
#define ll long long
#define ld long double
#define all(c) (c).begin(),(c).end()
#define trav(a,x) for(auto a = x.begin() ; a != x.end() ; a++)
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define f first
#define s second

inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b) {if(b==0) return a; a%=b;return gcd(b,a);}
ll power(ll x, ll y){if(y == 0) return 1; ll a = power(x,y/2);if (y % 2 == 0) return a * a; else return x * a * a; }
ll powermod(ll x, ll ex , ll md) {ll ans = 1ll;while (ex > 0) {if (ex & 1ll) ans = (ans * x) % md; ex >>= 1ll;x = (x * x) % md;}return ans;}

const ll inf = 1e18 + 9;
const ll mod = 1e9 + 7;
const ld PI = acos(-1);
const ld eps = 1e-9;

const ll N = 1e5 + 1;

void solve(){
    string s , t;
    cin >> s;
    cin >> t;
    ll ct = 0;
    ll len = s.size();
    for(ll i =0 ; i < len ; i++) ct += (s[i] != t[i]);
    cout << ct << endl;
}
int main(){
    IOS;
    cout << fixed << setprecision(20);
    ll NTC=1;
    // cin>>NTC;
    ll PTC=0;
    while(PTC++<NTC){
        // cout<<"Case #"<<PTC<<":"<<' ';
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 3916
import sys

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))


n=int(input())
d=LI()

ans=0
for i in range(n):
    for j in range(i+1,n):  
        ans+=d[i] * d[j]
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 1000000007
#define int long long
#define ll long long
#define EPS 0.00000000000001
#define ld long double
#define PI 3.14159265358979323846
#define inf 200000000
#define N 1000000
// #define double long double
vector<int> g[N];
int dp[N];
int taken[N];
int in[N];
int n;
int get_node(int a,int b)
{
    if(a > b)
        swap(a,b);
    return a * n + b;
}

int32_t main()
{
    IOS;
   
    memset(in,0,sizeof(in));
    memset(dp,0,sizeof(dp));
    memset(taken,0,sizeof(taken));
    cin >> n;
    int cnt = (n * (n - 1)) / 2;
    for(int i = 0;i < n;i++)
    {
        int prev = -1;
        for(int j = 0;j < n - 1;j++)
        {
            int a;
            cin >> a;
            a--;
            if(prev != -1)
            {
                g[get_node(i,prev)].push_back(get_node(i,a));
                in[get_node(i,a)]++;
            }
            prev = a;
        }
    }
    queue<int> q;
    for(int i = 0;i < n;i++)
    {
        for(int k = i + 1;k < n;k++)
        {
            if(in[get_node(i,k)] == 0)
            {
                q.push(get_node(i,k));
                // cerr << i << " " << k << endl;
                dp[get_node(i,k)] = 1;
            }
        }
    }
    int ans = 1;
    while(!q.empty())
    {
        cnt--;
        int d = q.front();
        q.pop();
        
        
        for(auto it : g[d])
        {
            in[it]--;
            if(in[it] == 0)
            {
                dp[it] = max(dp[d] + 1,dp[it]);
                ans = max(ans,dp[it]);
                q.push(it);
            }
        }
    }
    if(cnt == 0)
    {
        cout << ans;
    }
    else
        cout << "-1";

}   
 
 


Measured memory_bytes: 62720
#include <stdio.h>

int main()
{

  int i,j,count = 0,N,A[100],minj,swap,flag;

  scanf("%d",&N);
  for(i  = 0 ; i < N ; i++)scanf("%d",&A[i]);
  
  for(i = 0 ; i<N ; i++)
    {
      flag = 0;
      minj = i;
      for(j= i ; j <N ; j++)
	{
	  if( A[j] < A[minj] )
	    {
	      minj = j;
	      flag = 1;
	    }
	}
      if(flag == 1)
	{
	  count++ ;
	  swap = A[i];
	  A[i] = A[minj];
	  A[minj] = swap;
	}
    }

  for(i = 0 ; i < N ; i++)
    {
      if(i == N - 1)
	{
	  printf("%d\n%d\n" , A[i] , count);
	  break;
	}
      printf("%d ",A[i]);
    }

}



Measured memory_bytes: 2072
S = input()
r = 1
arr = [0]

for c in S[::-1]:
  arr.append((arr[-1] + int(c) * r) % 2019)
  r *= 10
  r %= 2019
from collections import Counter
ctr = Counter(arr)
ans = 0
for v in ctr.values():
  ans += v*(v-1)//2
print(ans)

Measured memory_bytes: 16648
#include <iostream>
#include <map>

using namespace std;

int main()
{
    int n;

    while (cin >> n, n) {
        int ans = 0;

        for (int a = 0; a * a <= n; a++) {
            for (int b = a; b * b <= n; b++) {
                if (a * a + b * b > n)
                    break;
                for (int c = b; c * c <= n; c++) {
                    if (a * a + b * b + c * c > n)
                        break;
                    for (int d = c; d * d <= n; d++) {
                        if (a * a + b * b + c * c + d * d == n) 
                            ans++;
                        else if (a * a + b * b + c * c + d * d > n)
                            break;
                    }
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1160