akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
 
// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
 
/*
--------------------------------------------
 
	type
 
--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;
 
/*
--------------------------------------------
 
	container
 
--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
 
/*
--------------------------------------------
 
	repetition
 
--------------------------------------------
*/
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPS(i,n) for(int i=0; i<(n); i++)
#define REPinit(a,n) for(int i=a; i<(n); i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)
 
//algorithm
//#define SORT(c) sort((c).begin(),(c).end())
 
/*
--------------------------------------------
 
	constant
 
--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
/*
 
	Optimizer
 
*/
//#pragma GCC optimize("Ofast")


/*
 
	Utility Algorithm
 
*/
template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}

LL euclideanAlgorithm(LL a, LL b) {
    LL a_tmp = a;
    LL b_tmp = b;

    if (a_tmp > b_tmp) {
        swapAlgorithm<LL>(a_tmp, b_tmp);
    }

    LL r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

LL getLCM(LL a, LL b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

/*
  Code
*/

double eauclidDistance(pair<double, double>& x1, pair<double, double>& x2) {
  return sqrt((x1.first - x2.first) * (x1.first - x2.first) + (x1.second - x2.second) * (x1.second - x2.second));
}

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

const ULL MOD = 1000000007;

ULL modadd(ULL a, ULL b) {
  return ((a+b)%MOD);
}

ULL modmul(ULL a, ULL b) {
  return (((a%MOD)*(b%MOD))%MOD);
}

ULL modsub(ULL a, ULL b) {
  ULL val = (a%MOD) - (b%MOD);
  ULL res = val % MOD;
  if (res < 0) res += MOD;
  return res;
}

int main(int argc, char const *argv[])
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int R,G,B,N;
  cin >> R >> G >> B >> N;

  int ans = 0;
  for (int i = 0; i <= N; i++)
  {
    for (int j = 0; j <= N; j++)
    {
      // cout << "DEBUG : " << (N - (i * R) - (j * G)) << endl;
      if((N - (i * R) - (j * G)) % B == 0 && (N - (i * R) - (j * G)) >= 0) ans++;
    }    
  }

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


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


const int MAX = 1001;
char area[MAX][MAX];
char bak[MAX][MAX];
int dst[MAX][MAX];
int mx, my;
vector<pair<int, int>> kouho;


int adj(int x, int m) {

	if (x < 0) return 0;
	if (x >= m) return m - 1;

	return x;
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {



	int n, m, pw, fc, sx, sy, stp, nxt;
	queue < pair<int, int>> q;
	pw = nxt = 1;
	stp = 0;
	cin >> my >> mx >> fc;


	rep(i, my) {
		cin >> area[i];

		rep(j, mx) {
			dst[i][j] = -1;

			if (area[i][j] == 'S') {
				sx = j;
				sy = i;
			}
		}
	}


	int dx[] = { 1,0,-1,0 };
	int dy[] = { 0,1,0,-1 };
	q.push(make_pair(sx, sy));
	dst[sy][sx] = 0;

	while (!q.empty())
	{
		auto pr = q.front();q.pop();
		int x, y, nx, ny;
		x = pr.first;
		y = pr.second;

		rep(i, 4) {

			nx = adj(x + dx[i], mx);
			ny = adj(y + dy[i], my);

			if (area[ny][nx] == 'X') continue;

			if (dst[ny][nx] == -1) {
				if (ctoi(area[ny][nx]) == nxt) {
					stp += dst[y][x] + 1;
					nxt += 1;

					rep(i, my) {
						rep(j, mx) {
							dst[i][j] = -1;
						}
					}
					dst[ny][nx] = 0;
					queue < pair<int, int>> dd;
					q = dd;
					q.push(make_pair(nx, ny));
					break;
				}
				else
				{
					dst[ny][nx] = dst[y][x] + 1;
					q.push(make_pair(nx, ny));
				}
			}
		}
	}

	cout << stp << endl;
}





Measured memory_bytes: 8052
#include <stdio.h>

int main() {
	int a,i,k,m;
	int data[100] = {0};
	int output[100] = {0};
	while(scanf("%d", &a) != EOF) {
		if (a != 0) {
			for (k = 0; k < 100; k++) {
				if (data[k] == 0) {
					data[k] = a;
					break;
				}
			}
		}
		else {
			for (k = 0; k < 100; k++) {
				if (data[k] == 0) {
					for (m = 0; m < 100; m++) {
						if (output[m] == 0) {
							output[m] = data[k - 1];
							break;
						}
					}
					data[k - 1] = 0;
					break;
				}
			}
		}
	}
	for (i = 0; i < 100; i++) {
		if (output[i] != 0) {
			printf("%d\n", output[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
    string s;
    vector<int> hoge(3);
    cin>>s;
    for(int i=0; i<s.length(); i++){
        if(s[i]=='a'){
            hoge.at(0)++;
        }else if(s[i]=='b'){
            hoge.at(1)++;
        }else{
            hoge.at(2)++;
        }
    }
    
        if(abs(hoge.at(0)-hoge.at(1))<2&&abs(hoge.at(0)-hoge.at(2))<2&&abs(hoge.at(1)-hoge.at(2))<2){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define int long long
//#define _GLIBCXX_DEBUG

signed main() {
  int N, K; cin >> N >> K;
  vector<int> A(N);
  rep(i, N) {
    cin >> A[i];
    A[i]--;
  }
  vector<int> B(N, -1);

  B[0] = 0;
  
  int now = 0;
  int n = 0;
  while(B[A[now]] == -1) {
    now = A[now];
    n++;
    B[now] = n;
    if(n == K) {
      cout << now+1 << endl;
      return 0;
    }
  }
  now = A[now];
  n++;
  B[now] = n;
  if(n == K) {
    cout << now+1 << endl;
    return 0;
  }
  int k = n-B[A[now]]+1;
  n = K-(K-n)%k;
  while(true) {
    if(n == K) {
      cout << now+1 << endl;
      return 0;
    }
    now = A[now];
    n++;
    B[now] = n;
    
  }
  

}

Measured memory_bytes: 6424
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <stdlib.h>
using namespace std;

int main (void) {
  int H,W;
  cin >> H >> W;
  int c[H+2][W+2]={0};
  string s;
  for (int i=1; i<=H; i++) {
    cin >> s;
    for (int j=1; j<=W; j++) {
      if (s[j-1] == '#') {
        c[i][j]=20;
        for (int k=-1;k<=1;k++){
          for (int l=-1;l<=1;l++){
            c[k+i][l+j]=int(c[k+i][l+j])+1;
          }
        }
      }
    }
  }
  for (int i=1; i<=H; i++) {
    for (int j=1; j<=W; j++) {
      if (int(c[i][j]) >= 20) {
        c[i][j]=35;
        printf("%c", c[i][j]);
        continue;
      }
    cout << c[i][j]; 
    }
  cout << endl;
  }
}

Measured memory_bytes: 256
//09
#include<iostream>
#include<cstdlib>

using namespace std;

int main(){
  int n,k;
  cin>>n>>k;
  int c[500][500];
  for(int i=0;i<k;i++){
    for(int j=0;j<n/2;j++){
      cin>>c[i][j];
    }
  }
  int b[1000];
 loop:
  for(int i=0;i<n;i++){
    b[i]=rand()/(RAND_MAX/2+1);
  }
  for(int i=0;i<k;i++){
    int nb=0;
    for(int j=0;j<n/2;j++){
      nb+=b[c[i][j]-1];
    }
    if(nb<n/8||n*3/8<nb)goto loop;
  }
  for(int i=0;i<n;i++){
    cout<<b[i];
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 2144
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int n = sc.nextInt();
		int[] p = new int[n];
		for(int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
		}
		Arrays.sort(p);
		int ans = -1;
		int sub = 100;
		if(n==0) ans = x;
		else if(x<p[0]) ans=x;
		else if(x>p[n-1]) ans=x;
		else {
			if(x==p[0]) ans=x-1;
			else if(p[n-1]==x&&p[n-1]-p[n-2]<=1) ans=x+1;
			else {
				for(int i = 0; i < n-1; i++) {
					int left = p[i];
					int right = p[i+1];
					if(right>x&&left<x) ans = x;
					else if(left>=x&&sub>left+1-x) {
							if(right-left>1) {
								ans=left+1;
								sub = ans-x;
							}
							
						}
						else if(left>=x&&sub<left+1-x) {
							break;
						}
						else if(right<=x&&sub>x-(right-1)) {
							if(right-left>1) {
								ans=right-1;
								sub = x-ans;
							}
							
						}
						else if(right<=x&&sub<x-(right-1)) {
							break;
						}
				}
			}
		}
		if(ans==-1) {
			if(Math.abs((p[0]-1)-x)<=Math.abs((p[n-1]+1)-x)) {
				ans = p[0]-1;
			}
			else ans =p[n-1]+1;
		}
		System.out.println(ans);
	 }
}

Measured memory_bytes: 35864
#include <iostream>

using namespace std;

int main()
{  int a , b ;
   
   cin >> a >> b ;
   if( a > b ) {
       cout << "a > b" << endl;
   }
   else if( a < b ){
       cout << "a < b" << endl;
   }
   else if( a = b ){
       cout << "a == b" << endl; 
   }
   return 0;
}

 


Measured memory_bytes: 3016
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
	int a[3];
	rep (i, 3) cin >> a[i];

	sort(a, a + 3);

	int cnt = 0;
	while (a[0] < a[2] - 1) {
		a[0] += 2;
		cnt++;
	}
	while (a[1] < a[2] - 1) {
		a[1] += 2;
		cnt++;
	}

	sort(a, a + 3);

	if (a[0] == a[1] && a[0] == a[2]) {}
	else {
		if (a[0] == a[1] && a[0] != a[2]) {
			cnt++;
		}
		if (a[0] != a[1] && a[1] == a[2]) {
			cnt+=2;
		}
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define FT() int t; scanf("%d",&t); while(t--)
#define pb push_back
#define nl printf("\n")
#define fi(i,start,end) for(int i=start; i < (int)end ; ++i)
#define ip(n)   scanf("%d",&n)
#define mz(a)   memset(a,0,sizeof(a))
#define inpArr(A,n) fi(i,0,n)   ip(A[i]);
#define print(a)  for(auto i : a)   cout<<i<<" "; nl;
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
ll max(ll a,ll b) { return a>b?a:b;}
ll min(ll a,ll b) { return a<b?a:b;}

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    
    int n;
    cin>>n;
    string x;
    cin>>x;
    
    ll smb = 0,sma = 0;
    ll pb = 1,pa=1;
    int c =0;
    ll dpb[n],dpa[n];
    mz(dpa);
    mz(dpb);
    for(int i=n-1;i>=0;--i)
    {  
      c+=(x[i]=='1');
    }
    for(int i=n-1;i>=0;--i)
    {
      if(x[i]=='1')
      {
        smb+=pb;
        sma+=pa;
        if(c>1)
          smb%=(c-1);
        sma%=(c+1);
      }
      if(c>1)
        dpb[i] = pb%(c-1);
      dpa[i] = pa%(c+1);
      
      pa*=2;
      pa%=(c+1);
      if(c>1)
        {pb*=2;pb%=(c-1);}
    }
    if(c!=1)
    for(int i = 0;i<n;i++)
    {
      if(x[i] == '0')
      {
        ll smt = sma + dpa[i];
        smt%=(c+1);
        int count = 1;
        while(smt!=0)
        {
          ll temp = smt;
          int cc = 0;
          while(temp)
          { cc+=(temp&1);
            temp>>=1;
          }
          if(cc==0)
            break;
          smt = smt%cc;
          count++;
        }
        cout<<count<<"\n";
      }
      else if(x[i]=='1')
      { 
        ll smt = smb - dpb[i];
        if(smt<0)
          smt += (c-1);
        else
          smt%=(c-1);
        int count = 1;
        while(smt>0)
        {
          ll temp = smt;
          int cc = 0;
          while(temp)
          { cc+=(temp&1);
            temp>>=1;
          }
          if(cc==0)
            break;
          smt = smt%cc;
          count++;
        }
        cout<<count<<"\n";
      }
    }
    
    else
    {
      for(int i=0;i<n;i++)
      {
        if(x[i] == '1')
          cout<<"0\n";
        else
        {
          if(i==n-1)
            cout<<"2\n";
          else
            cout<<"1\n";
        }
      }
    }
    

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
    #endif
    
    return 0;
}


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

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

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

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<endl

int n,m;
int a[252521], b[252521];

ll bcnt[252521];
ll bcsum[252521];
ll bmsum[252521];

int main(){
	scanf("%d%d",&n,&m);
	REP(i,n)scanf("%d",a+i);
	REP(i,m)scanf("%d",b+i);
	REP(i,m)bcnt[b[i]]++;
	REP(i,252500)bcsum[i+1] = bcnt[i] + bcsum[i];
	REP(i,252500)bmsum[i+1] = bcnt[i]*i + bmsum[i];
	ll ans = 0;
	const int C = 200;
	REP(i,n){
		int v = a[i];
		ll lst = 0;
		FOR(k,0,C){
			ll lb = (v / (k+1)) + 1;
			ll ub = k==0 ? 252125 : (v / k);
			lst = lb;
			ll cnt = bcsum[ub+1] - bcsum[lb];
			ll sum = bmsum[ub+1] - bmsum[lb];
			ans += v * cnt;
			ans -= k * sum;
		}
		FOR(bb,1,lst){
			ans += bcnt[bb] * (v % bb);
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 10256
// D - Lucky PIN
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define all(x) (x).begin(),(x).end()
#define ubound(x,c) upper_bound(all(x),(c))-(x).begin()

int main(){
	int N; string S; cin>>N>>S;
	vector<int> ix[10];
	rp(i, 0, N) ix[S[i]-'0'].push_back(i);
	int ans = 0;
	rp(a, 0, 10){
		int p = ubound(ix[a], -1); if(p >= ix[a].size()) continue;
		rp(b, 0, 10){
			int q = ubound(ix[b], ix[a][p]); if(q >= ix[b].size()) continue;
			rp(c, 0, 10) if(ubound(ix[c], ix[b][q]) < ix[c].size()) ans++;
		}
	}
	cout<< ans <<endl;
}

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

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

  vector<int> W(N), E(N);
  int sum_w = 0, sum_e = 0;
  rep(i, N) {
    if (S[i] == 'W')
      sum_w++;
    else
      sum_e++;
    W[i] = sum_w;
    E[i] = sum_e;
  }

  int ans = 1e9;
  rep(i, N) {
    int w_w = W[i];
    if (S[i] == 'W')
      w_w--;
    int e_e = E.back() - E[i];
    ans = min(ans, w_w + e_e);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3076
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    S = ii(str)
    ans = 0
    for i in range(1 << len(S) - 1):
        output = ""
        for j in range(len(S)):
            output += S[j]
            if ((i >> j) & 1) == 1:
                output += "+"
        ans += eval(output)
    return ans


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int main()
{
	int H, W;
	char a[101][101];
	cin >> H >> W;
	REP(i, 0, H) {
		REP(j, 0, W) {
			cin >> a[i][j];
		}
	}

	REP(i, 0, H + 2) {
		REP(j, 0, W + 2) {
			if (i == 0 || j == 0 || i == H + 1 || j == W + 1) cout << "#";
			else cout << a[i - 1][j - 1];
		}
		cout << endl;
	}

	return 0;
}

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

using namespace std;

#define pb push_back
#define eps 1e-9
#define PI acos(-1.0)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
const int INF = 1e9 + 5;

bool prime(ll x)
{
    if(x == 2)
        return true;
    for(int i = 2 ; i * i <= x ; i++)
        if(x % i == 0)
            return false;
    return true;
}
void self_max(ll &a, ll b)
{
    a = max(a, b);
}
bool cmp(int a, int b)
{
    return a > b;
}
int a[int(1e5 + 5)];
int main()
{

    ios_base::sync_with_stdio (0);
    cin.tie(0);

    int n, w;
    cin >> n >> w;
    std::vector<ll> dp(w + 5);
    for (int item = 0; item < n; ++item)
    {
        int wt, val;
        cin >> wt >> val;
        for (int wt_alrdy = w - wt; wt_alrdy >= 0; --wt_alrdy)
        {
            self_max(dp[wt_alrdy + wt], dp[wt_alrdy] + val);
        }

    }
    ll ans = 0;
    for (int i = 0; i <= w; ++i)
    {
        self_max(ans, dp[i]);
    }
    cout << ans;
    return 0;
}


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

int main() {
    string S;
    cin >> S;
    int N = S.length();
    int ans = 0;
    
    for (int i = 0; i < N/2; i++) {
        if (S[i] != S[N-1-i]) ans++;
    }
    cout << ans << endl;
}

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


int main(){
    string str("abcdefghijklmnopqrstuvwxyz");
    char C;
    cin >> C;
    
    int buf;
    // cout << str[2] << endl;
    for(int i=0; i<26; i++){
        if(C == str[i]){
            buf = i;
        }
    }
    
    cout << str[buf+1] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int W,H,j=0;
  int n = 0;
  int hantei;
  int d[10000][2];
  while(j == 0){ 
    scanf("%d %d",&H,&W);
    if(W == 0 && H == 0){ 
      j = 1;
    }else{
      d[n][0] = H;
      d[n][1] = W;
      n++;
    }   
  }
  for(int i = 0;i < n;i++){ //???????????????????????°??????
    for(int q = 0;q < d[i][0];q++){
      if(q%2 == 0){ 
        hantei = 1;
      }else{
        hantei = 0;
      }   
      for(j = 0;j < d[i][1];j++){
        if((hantei == 1 && j%2 == 0) ||(hantei == 0 && j%2 == 1)){
          printf("#");
        }else{
          printf(".");
        }   
      }   
      printf("\n");
    }   
    printf("\n");
  }
}

Measured memory_bytes: 2604
#include <bits/stdc++.h> 
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

const ll v = 3001;
ll dp[v][v];

ll length(string& s,string& t,ll i,ll j)
{
   // memset(dp,-1,sizeof(dp));
    //Base case
    if(i>=s.size() || j>=t.size())
    return 0;

    //Lookup
    if(dp[i][j] != -1)
    return dp[i][j];

    //Rec case
    if(s[i] == t[j])
    return dp[i][j] = 1 + length(s,t,i+1,j+1);

    else
    return dp[i][j] = max(length(s,t,i+1,j), length(s,t,i,j+1));
}

int main()
{
   fast_io;
    string s,t;
    cin>>s>>t;
     memset(dp,-1,sizeof(dp));

    //cout<<length(s,t,0,0)<<endl;
  ll len = length(s,t,0,0);
  ll i=0,j=0;

   string ans = " ";
   while(len)
   {
       if(s[i] == t[j])
       {
           ans.pb(s[i]);
           i++;
           j++;
           len--;
       }
       else
       {
           if(dp[i][j+1] > dp[i+1][j])
           j++;
           else
           i++;
       }
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 74388
#include<bits/stdc++.h>
using namespace std;
int arr[5];
int main()
{
    int x,y;
    int maxi = 0;
    cin >> x >> y;
    arr[x]++;
    arr[y]++;
    cin >> x >> y;
    arr[x]++;
    arr[y]++;
    cin >> x >> y;
    arr[x]++;
    arr[y]++;
    for(int i = 1; i<= 4;i++)
    {
        maxi = max(maxi,arr[i]);
    }
    if(maxi <= 2)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

signed main() {
    int x,a;
    cin>>x>>a;
    cout<<((x<a)?0:10)<<endl;

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

Measured memory_bytes: 256
from collections import defaultdict

def solve(n, m):
  H = [int(input()) for i in range(n)]
  W = [int(input()) for i in range(m)]

  D_h = defaultdict(int)
  D_w = defaultdict(int)

  cum_h = [0]
  cum_w = [0]

  for h in H:
    cum_h.append(cum_h[-1] + h)

  for w in W:
    cum_w.append(cum_w[-1] + w)

  for i in range(n + 1):
    for j in range(i + 1, n + 1):
      D_h[cum_h[j] - cum_h[i]] += 1

  for i in range(m + 1):
    for j in range(i + 1, m + 1):
      D_w[cum_w[j] - cum_w[i]] += 1

  ans = 0

  for k, v in D_h.items():
    ans += v * D_w[k]

  print(ans)
  
while True:
  n, m = [int(i) for i in input().split()]
  if (n, m) == (0, 0):
    break
  solve(n, m)


Measured memory_bytes: 75296
import java.util.Scanner;

public class Main {

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

        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
        int c = Integer.parseInt(scan.next());

        scan.close();

        System.out.println(c + " " + a + " " + b);
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mod 1000000007
// #define mod 998244353
using namespace std;

ll xs, ys, xt, yt, x[1000], y[1000], r[1000];
double dp[1002];
vector<pair<int, double>> neig[1002];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> xs >> ys >> xt >> yt;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> x[i] >> y[i] >> r[i];
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			ll dist2 = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
			if (dist2 > (r[i] + r[j]) * (r[i] + r[j]))
			{
				neig[i].pb({j, sqrt(dist2) - (r[i] + r[j])});
				neig[j].pb({i, sqrt(dist2) - (r[i] + r[j])});
			}
			else
			{
				neig[i].pb({j, 0});
				neig[j].pb({i, 0});
			}
		}
	}
	for (int i = 0; i < n; i++)
	{
		ll dist2 = (x[i] - xs) * (x[i] - xs) + (y[i] - ys) * (y[i] - ys);
		if (dist2 > r[i] * r[i])
		{
			neig[n].pb({i, sqrt(dist2) - r[i]});
			neig[i].pb({n, sqrt(dist2) - r[i]});
			// cout << sqrt(dist2) - r[i] << endl;
		}
		else
		{
			neig[n].pb({i, 0});
			neig[i].pb({n, 0});
		}
	}
	for (int i = 0; i < n; i++)
	{
		ll dist2 = (x[i] - xt) * (x[i] - xt) + (y[i] - yt) * (y[i] - yt);
		if (dist2 > r[i] * r[i])
		{
			neig[n + 1].pb({i, sqrt(dist2) - r[i]});
			neig[i].pb({n + 1, sqrt(dist2) - r[i]});
			// cout << sqrt(dist2) - r[i] << endl;
		}
		else
		{
			neig[n + 1].pb({i, 0});
			neig[i].pb({n + 1, 0});
		}
	}
	neig[n].pb({n + 1, sqrt((xs - xt) * (xs - xt) + (ys - yt) * (ys - yt))});
	neig[n + 1].pb({n, sqrt((xs - xt) * (xs - xt) + (ys - yt) * (ys - yt))});
	for (int i = 0; i <= n + 1; i++)
	{
		dp[i] = 1000000000000000000;
	}
	dp[n] = 0;
	set<pair<double, int>> s;
	s.insert({0, n});
	while (s.begin() != s.end())
	{
		pair<double, int> p = *s.begin();
		s.erase(s.begin());
		int u = p.second;
		double dist = p.first;
		for (auto p : neig[u])
		{
			int v = p.first;
			if (dp[v] > dist + p.second)
			{
				s.erase({dp[v], v});
				dp[v] = dist + p.second;
				s.insert({dp[v], v});
			}
		}
	}
	cout << setprecision(40) << dp[n + 1] << endl;
	return 0;
}

Measured memory_bytes: 19888
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(15);
    int n, k, q;
    cin >> n >> k >> q;
    vi cor(n+1, 0);
    for (int i = 0; i < q; i++){
        int nxt;
        cin >> nxt;
        cor[nxt]++;
    }
    for (int i = 1; i <= n; i++){
        if (q - cor[i] >= k){
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(NULL);
#define REP(i,a,n) for(int i=a;i<b;++i)
#define REPN(i,a,b) for(int i=a;i<=b;++i)

int main() 
{ 
  FASTIO;
    int n,m;
    cin>>n>>m;
    cout<<n*(n-1)/2 + +m*(m-1)/2<<"\n";
  
    return 0; 
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a;
int main()
{
    //freopen("vidu.inp","r",stdin);
    //freopen("vidu.out","w",stdout);
  cin>>a;
  bool kt=false;
  for (int x=0 ; x<=a/4 ; x++)
  {
    int y= (a-4*x)/7;
    if (4*x + 7*y == a)  {kt=true;break;}
  }
   if (kt) cout<<"Yes";
  else cout<<"No";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl "\n";
#define pair pair<ll,ll> 
ll MAX=LLONG_MAX;
ll MIN=LLONG_MIN;
const int siz=200001;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll i,j,k,l,m,n,o,p,q,r,s,t,x,a[siz+10]={0},prefix[siz+10]={0},dp[siz+10]={0};
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        if(i-2>=0)
        prefix[i]=prefix[i-2]+a[i];
        else 
        prefix[i]=a[i];
    }
    dp[1]=0;
    for(i=2;i<=n;i++)
    {
        if(i%2==1)
        dp[i]=max(dp[i-1],dp[i-2]+a[i]);
        else 
        dp[i]=max(prefix[i-1],dp[i-2]+a[i]);
    }
    cout<<dp[n]<<endl;
    return 0;
}  
    


Measured memory_bytes: 8324
#include <iostream>
#include <cmath>
#include <algorithm>

using ll = unsigned long long int;

constexpr ll MOD = (ll)1e9 + 7;

int n, m;

int main() {

	std::cin >> n >> m;

	ll ans = 1;

	if (n == m) {

		for (int i = 1; i <= n; ++i) {
			ans *= i;
			ans %= MOD;
		}
		ans = ans*ans;
		ans *= 2;
		ans %= MOD;
	}
	else if (std::abs(n - m) == 1) {

		ll tmp = 1;

		for (int i = 1; i <= std::max(n, m); ++i) {
			ans *= i;
			if (i != std::max(n, m)) {
				tmp *= i;
				tmp %= MOD;
			}
			ans %= MOD;
		}
		ans = ans*tmp;
		ans %= MOD;
	}
	else
		ans = 0;

	std::cout << ans << std::endl;

	return 0;
}

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

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    ll base = X * A + Y * B;
    int min_needs = min(X, Y);
    int x_diff = X - min_needs;
    int y_diff = Y - min_needs;
    ll pair = C * 2 * min_needs;
    int min_a = min(A, C * 2);
    int min_b = min(B, C * 2);
    ll remain_a = min_a * x_diff;
    ll remain_b = min_b * y_diff;

    cout << min(base, pair + remain_a + remain_b) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int W;
	int H;
	int x;
	int y;
	int r;
	
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	
	if ((x <= (W - r)) && (x >= r) && (y <= (H - r)) && (y >= r))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	
	return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

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

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; cin>>n;
  vector<vi> a(n, vi(3));
  rep(i,n) cin>>a[i][0]>>a[i][1]>>a[i][2];
  
  int dp[n+1][3];
  rep(i,n+1) rep(j,3) dp[i][j]=0;
  rep(i,3) dp[0][i]=a[0][i];
  for(int i=1; i<n; i++){
    for(int j=0; j<3; j++){
      for(int k=0; k<3; k++){
        if(j==k) continue;
        chmax(dp[i][j], dp[i-1][k]+a[i][j]);
      }
    }
  }
  int ans=0;
  rep(i,3) chmax(ans,dp[n-1][i]);
  cout<<ans<<endl;
}

Measured memory_bytes: 6912
#include <cstdio>
#include <algorithm>
#define mod 924844033
typedef long long LL;
const int N=4005;//2n
 
int ban[N],f[2][N][2],fac[N];
 
int main()
{
    int n,K,cnt=0; scanf("%d%d",&n,&K);
    for(int i=1; i<=K; ++i)
    {
        ban[++cnt]=1;
        for(int j=i+K; j<=n; j+=K) ban[++cnt]=0;
        ban[++cnt]=1;//就是两条链啊 
        for(int j=i+K; j<=n; j+=K) ban[++cnt]=0;
    }
    int p=0; f[p][0][0]=1;
    for(int i=0; i<cnt; ++i,p^=1)
        for(int j=0; j<=i; ++j)
        {
            f[p^1][j][0]=(f[p][j][0]+f[p][j][1])%mod;
            if(!ban[i+1]) f[p^1][j+1][1]=f[p][j][0];
            f[p][j][0]=f[p][j][1]=0;
        }
    fac[0]=1;
    for(int i=1; i<=n; ++i) fac[i]=1ll*fac[i-1]*i%mod;
    LL ans=0;
    for(int i=0; i<=n; ++i)
        ans+=i&1?mod-1ll*fac[n-i]*(f[p][i][0]+f[p][i][1])%mod:1ll*fac[n-i]*(f[p][i][0]+f[p][i][1])%mod;
    printf("%lld\n",ans%mod);
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
#define pb push_back
#define mp make_pair
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
 
const int inf = int(1e9);
const int mod = 1e9 + 7;
const int N = 1e6 + 555;
const long double PI = acos(-1.0);

map<string, ll> x;
void solve()
{	
	int n;
	cin >> n;
	set<string> st;
	for(int i = 0; i < n; ++i){
		string s;
		cin >> s;
		sort(all(s));
		x[s]++;
		st.insert(s);
	}
	ll sum = 0;
	for(auto it : st){
		sum += x[it] * (x[it] - 1) / 2;
	}
	cout << sum;
}

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


Measured memory_bytes: 20608
#include <bits/stdc++.h>
#define rep(i, s, n) for(int i = s; i < n; i++)
#define rrep(i, s, n) for(int i = s; i > (s)-(n); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


  int n;
  cin >> n;

  int t, x, y;
  int ct, cx, cy;
  ct = 0;
  cx = 0;
  cy = 0;
  rep(i, 0, n) {
    cin >> t >> x >> y;
    if (((x-cx) + (y-cy) - (t-ct))%2 == 0 && ((x-cx) + (y-cy) - (t-ct)) <= 0) {
      ct = t;
      cx = x;
      cy = y;
    } else {
      pr("No");
      return 0;
    }
  }
  pr("Yes");


  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define reps(i,n) for(int i=1;i<=(int)n;i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define MOD 1000000007
#define itn int
#define enld endl
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

vector<pair<long long, long long>> prime_factorize(long long N) {
    vector<pair<long long, long long>> res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main(){
    string s; cin >> s;
    rep(i,SZ(s)){
        if(s[i] == '?') s[i] = 'D';
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3760
import numpy as np

a,b,h,m = map(int, input().split())
minutes = h*60 + m
ome1 = minutes % 60 *6
ome2 = (minutes%1800) * 0.5
# print(ome1,ome2)
rad = (ome2 - ome1) * np.pi/180
x = a**2+b**2-2*a*b*(np.cos(rad))
print(x**0.5)


Measured memory_bytes: 27220
#include <bits/stdc++.h>
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define TRAV(i, a) for(auto & i : (a))
#define SZ(x) ((int)(x).size())
#define PR std::pair
#define MP std::make_pair
#define X first
#define Y second
typedef long long ll;
typedef std::pair<int, int> PII;
typedef std::vector<int> VI;

int main(){
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(0);
  int n;
  std::cin >> n;
  int m;
  std::cin >> m;
  std::vector<VI> g(n);
  FOR(i, m){
    int a, b;
    std::cin >> a >> b;
    a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  std::queue<int> que;
  que.push(0);
  VI prev(n, -1);
  prev[0] = 0;
  while(SZ(que)){
    int cur =que.front();
    que.pop();
    TRAV(ch, g[cur]){
      if(prev[ch] == -1){
        prev[ch] = cur;
        que.push(ch);
      }
    }
  }

  std::cout << "Yes\n";
  REP(i, 1, n) std::cout << prev[i]+1 << "\n";

	return 0;
}

Measured memory_bytes: 10320
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxk=100010;
int k,dl[maxk<<4],f[maxk],id;
bool vis[maxk];
struct edge
{
	int t,w;
	edge *next;
}*con[maxk];
void ins(int x,int y,int w)
{
	edge *p=new edge;
	p->t=y;
	p->w=w;
	p->next=con[x];
	con[x]=p;
}
void spfa()
{
	int head=1,tail=1;
	memset(f,0x3f,sizeof(f));
	dl[1]=1;vis[1]=1;f[1]=0;
	for(int v=1;head<=tail;vis[v]=0,v=dl[++head])
		for(edge *p=con[v];p;p=p->next)
			if(f[p->t]>f[v]+p->w)
			{
				//cout<<v<<' '<<p->t<<' '<<f[v]<<endl;
				f[p->t]=f[v]+p->w;
				if(!vis[p->t]) vis[p->t]=1,dl[++tail]=p->t;
			}
}

int main()
{
	scanf("%d",&k);
	for(int i=1;i<k;i++)
		ins(i,i*10%k,0),ins(i,(i+1)%k,1);
	spfa();	
	printf("%d",f[0]+1);
}

Measured memory_bytes: 10624
#include <iostream>
#include<string>
#include<vector>
using namespace std;
int calCost(vector<int>& nums, int i){
	int ans = 0;
	for (auto& elem : nums){
		ans += (elem - i)*(elem - i);
	}
	return ans;
}
int main()
{
	int N, t, max = -100, min = 100, minCost = 2147483647;
	vector<int> nums;
	cin >> N;
	for (int i = 0; i < N; ++i){
		cin >> t;
		nums.push_back(t);
		if (t>max){ max = t; }
		if (t < min){ min = t; }
	}


	for (int i = min; i <= max; ++i){
		int cost = calCost(nums, i);
		if (cost < minCost){
			minCost = cost;
		}
		else{ break; }
	}
	cout << minCost << endl;
	cin >> t;
	return 0;
}


Measured memory_bytes: 256
mod=10**9+7
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a,b=mi()
dp=[0]*(b+1)
for i in range(a):
  x,y=mi()
  for i in range(b-x,-1,-1):
      dp[i+x]=max(dp[i]+y,dp[i+x])
print(max(dp))

Measured memory_bytes: 74928
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n; cin >> n;
  while(n>0) {
    int a = n%10;
    if (a==7) { COUT("Yes"); return 0; }
    n/=10;
  }
  COUT("No");
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define db double
#define pb push_back
#define wrln cout<<'\n';
#define pii pair<int,int>
using namespace std;
const int H=1e9+7;
const int N=1e5+100;

ll a,b,c,d,n,f[N];

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


    cin>>n;
    for (int i=3; i<=n; i++)
    {
        f[i]=1;
        for (int j=i-3; j>0; j--)
        {
            f[i]=(f[i]+f[j]) % H;
        }
    }
    cout<<f[n];
}


Measured memory_bytes: 3648
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

struct Pt{
	double x,y;
	Pt(){}
	Pt(double x,double y):x(x),y(y){}
	Pt operator+(const Pt&a)const{return Pt(x+a.x,y+a.y);}
	Pt operator-(const Pt&a)const{return Pt(x-a.x,y-a.y);}
	Pt operator*(const Pt&a)const{return Pt(x*a.x-y*a.y,x*a.y+y*a.x);}
	Pt operator*(const double&k)const{return Pt(x*k,y*k);}
	Pt operator/(const double&k)const{return Pt(x/k,y/k);}
	double abs2()const{return x*x+y*y;}
	double dot(const Pt&a)const{return x*a.x+y*a.y;}
};

Pt proj(Pt a,Pt b){return a*a.dot(b)/a.abs2();}
Pt prep(Pt a,Pt b,Pt c){return a+proj(b-a,c-a);}
Pt refl(Pt a,Pt b,Pt c){return prep(a,b,c)*2-c;}

int main() {
	Pt a,b,c;
	for(;~scanf("%lf,%lf,%lf,%lf,%lf,%lf",&(a.x),&(a.y),&(b.x),&(b.y),&(c.x),&(c.y));){
		Pt r=refl(a,b,c);
		printf("%.10f %.10f\n",r.x,r.y);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	int n,a=0,b=0,c=0,d=0;
	cin>>n;
	while(n--){
		cin>>s;
		if(s=="AC")a++;
		else if(s=="WA")b++;
		else if(s=="RE")c++;
		else d++;
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d",a,b,d,c);
}

Measured memory_bytes: 3720
n, *l = map(int, open(0).read().split())

max = 0
total = 0
for i in range(0, n):
    if l[i] > max:
        total += max
        max = l[i]
    else:
        total += l[i]

if max >= total:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 2940
var
  a,b:array[-100000..100000]of longint;
  i,n,k:longint;
  ans:qword;
Function min(x,y:longint):longint;
begin
  if x<y then exit(x) else exit(y);
end;
begin
  readln(n,k);
  for i:=1 to n do read(a[i]);
  ans:=maxlongint;
  for i:=1 to n-k+1 do
    begin
	  if a[i]<=0 then
	    begin
		  if a[i+k-1]<=0 then
		    ans:=min(ans,-a[i]) else
		  begin
		    ans:=min(ans,abs(a[i]-0)*2+abs(a[i+k-1]-0));
		    ans:=min(ans,abs(a[i]-0)+abs(a[i+k-1]-0)*2);
		  end;
		end else
		begin
		  ans:=min(ans,a[i+k-1]);
		end; 
	end;
  write(ans);
end.
    
  

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int k;
  cin >> k;
  while (k) {
    k--;
    if (a >= b) {
      b *= 2;
    } else if (b >= c) {
      c *= 2;
    } else {
      break;
    }
  }
  if (a < b && b < c)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
using namespace std;
typedef unsigned long long ll;

int main(void)
{
    int N, W;
    cin >> N >> W;

    int w[N];
    ll v[N];
    for(int i = 0; i < N; i++)
        cin >> w[i] >> v[i];

    ll dp[W+1][N+1];
    for(int i = 0; i <= N; i++)
    {
        for(int m = 0; m <= W; m++)
        {
            if(i == 0 || m == 0)
                dp[m][i] = 0;
            else if(w[i-1] <= m)
                dp[m][i] = max(dp[m - w[i-1]][i-1] + v[i-1], dp[m][i-1]);
            else
                dp[m][i] = dp[m][i-1];
        }
    }

    cout << dp[W][N] << endl;

    return 0;
}


Measured memory_bytes: 79104
import sys
 
 
list_line = sys.stdin.readlines()
 
for index, element in enumerate(list_line):
    list_line[index] = element.rstrip('\n')
 
for element in list_line:
    x_y_list = element.split(" ")
    x = int(x_y_list[0])
    y = int(x_y_list[1])
    if x == 0 and y == 0:
        sys.exit()
    if x > y:
        print(str(y) + " " + str(x))
    else:
        print(element)

Measured memory_bytes: 7932
n,m,l = [int(x) for x in input().split()]
       
a = [[0 for j in range(m)] for i in range(n)] #n行,m列
b = [[0 for k in range(l)] for j in range(m)]


for i in range(n):
    a[i] = [int(x) for x in input().split()]
    
for j in range(m):
    b[j] = [int(x) for x in input().split()]

c = [[0 for j in range(l)] for i in range(n)]
for i in range(n):
    for j in range(l):
        s = 0
        for k in range(m):
            s += a[i][k] * b[k][j]

        c[i][j] = s
        
for i in range(n):
    print(" ".join([str(x) for x in c[i]]))


Measured memory_bytes: 6872
/* ***********************************************
Author        :yang12138
Created Time  :2018年06月23日 星期六 20时07分34秒
File Name     :B.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)
 
 
ll get(ll n){
	ll ans=0;
	while(n){
		ans+=n%10;
		n/=10;
	}
	return ans;
}
 
const int N=1e6+10;
double f[N];
 
bool check(ll a,ll b){
	return a*get(b)<=b*get(a);
}
 
const ll INF=1e15+1e13;
int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    
	vector<ll>ans;
	ll s=1;
	for(ll i=1;i<=INF && s<=INF;i*=10LL,s+=i){
		while(1){
			bool flag=1;
			for(int j=1;j<=10;j++){
				if(!check(s,s+j*i)){
					flag=0;
					break;
				}
			}
			if(!flag) break;
			ans.push_back(s);
			s+=i; 
		}
		s-=i;
	}

	ll k;
	cin>>k;


	for(int i=0;i<(int)ans.size() && i<k;i++){
		cout<<ans[i]<<endl;
	}
 
    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define rep(i, j) FOR(i, 0, j, 1)
#define rrep(i, j) RFOR(i, j, 0, 1)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define endl "\n"
#define MOD 1000000007
#define DEB(x) cout<<"##"<<x<<"##"<<endl;
void solve()
{ 
	ll a;
	string s;
	cin>>a>>s;
	ll x,y;
	x=s[0]-'0';
	y=(s[2]-'0')*10+s[3]-'0';
	cout<<x*a+(y*a)/100;
} 
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	int tt=1;
	//cin>>tt;
	while(tt--)
	solve(); 	
	return 0;
}


Measured memory_bytes: 3624
#!/usr/bin/env python
"""AtCoder Beginner Contest 168: B - 
https://atcoder.jp/contests/abc168/tasks/abc168_b
"""

__author__ = 'bugttle <bugttle@gmail.com>'


def main():
    K = int(input())
    S = input()

    if len(S) <= K:
        print(S)
    else:
        print("{}...".format(S[0:K]))

if __name__ == '__main__':
    main()


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

const long long INF = 1LL << 60;

int main() {
	long long N, A, B;
	cin >> N >> A >> B;
	vector<long long> h(N);
	for (int i = 0; i < N; i++) cin >> h[i];

	long long max_h = 0;
	for (int i = 0; i < N; i++) max_h = max(max_h, h[i]);

	long long top = (max_h - 1) / B + 1;
	long long bottom = 0;
	long long middle = (top + bottom) / 2;

	long long ans = INF;
	long long cnt_one;
	while (top >= bottom) {
		cnt_one = 0;
		for (int i = 0; i < N; i++) {
			if (h[i] - middle*B - 1 >= 0) {
				cnt_one += (h[i] - middle*B - 1)/ (A - B) + 1;
			}
		}
		ans = min(ans, max(cnt_one, middle));

		if (cnt_one >= middle)
			bottom = middle + 1;
		else
			top = middle - 1;
		middle = (top + bottom) / 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	double a,b;
	int c[2][4]={0};
	while(cin >> a >> b){
		c[0][a>=1.1?0:a>=0.6?1:a>=0.2?2:3]++;
		c[1][b>=1.1?0:b>=0.6?1:b>=0.2?2:3]++;
	}
	rep(i,4)
		cout << c[0][i] << " " << c[1][i] << endl;
}

Measured memory_bytes: 0