akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

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

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main()
{
	COMinit();
	int n , k ;
	cin >> n >> k ;
	k = min(n-1,k);
	ll ans = 0 ;
	for(int i = 0 ;  i <= k ; i++){
		ans += (COM(n,i)*COM(n-1,i)) % mod;
		ans %= mod;
	}
	cout << ans << endl;
}


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

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

  













Measured memory_bytes: 256
n, m = map(int, input().split())
F = [0]*(n+1)
for _ in range(m):
  a, b = map(int, input().split())
  F[a] += 1
  F[b] += 1
for i in F:
  if i%2:
    print("NO")
    exit()
print("YES")

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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  int count = 0;
  rep(i,n){
    if(s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G'){
      ++count;
    }
    else count = 0;
    ans = max(ans,count);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import collections


if __name__ == "__main__":
    N = int(input())
    v_list = list(map(int, input().split()))
    even_list = [v_list[i] for i in range(N) if i % 2 == 0]
    odd_list = [v_list[i] for i in range(N) if i % 2 != 0]

    even_counter = collections.Counter(even_list)
    odd_counter = collections.Counter(odd_list)

    even_common = even_counter.most_common()
    odd_common = odd_counter.most_common()

    even_max = even_common[0][0]
    odd_max = odd_common[0][0]

    if even_max != odd_max:
        print((N - even_common[0][1] - odd_common[0][1]))
    else:
        if len(even_common) > 1:
            even_second_replace = N - even_common[1][1] - odd_common[0][1]
        else:
            even_second_replace = N - odd_common[0][1]

        if len(odd_common) > 1:
            odd_second_replace = N - even_common[0][1] - odd_common[1][1]
        else:
            odd_second_replace = N - even_common[0][1]
        print(min(even_second_replace, odd_second_replace))

Measured memory_bytes: 21952
#include<stdio.h>
#include<string.h>
	char s[200010];
	int main(){
    scanf("%s",s);
    int len=strlen(s);
    int sum=0;
    for(int i=0;i<len;i++)sum+=s[i]-'0';
    if(sum%9==0){
        puts("Yes");
    }else{
        puts("No");
    }
}


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

int main() {
	string s;
	cin >> s;
	string t = "CODEFESTIVAL2016";

	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		ans += s[i] != t[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int i;
  int length;
  
  scanf("%d",&length);

  int A[length];

  for (i = 0 ; i < length ; i++){
    scanf("%d",&A[i]);
  }

  int flag = 1;
  int j;
  int tmp;
  int counter = 0;
  

  while (flag){
    flag = 0;
    for(j = length - 1 ; j > 0 ; j-- ){
      if( A[j] < A[j - 1] ){

	tmp = A[j];
	A[j] = A[j - 1];
	A[j - 1] = tmp;

	flag = 1;
	counter++;
      }
    }
  }


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

  printf("%d\n",counter);
  
  
  return 0;
}



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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1LL << 60;

//Write From this Line

int main()
{
	int n; 
	cin >>  n; 
	string s;
	cin >>  s;
	int ans = 1 ;
	int first = s[0] ;
	rep(i,n){
		if(first ==s[i]){
			//none
		} else {
			first = s[i] ;
			ans ++ ;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	int N;
	std::string A, B, C;
	in >> N >> A >> B >> C;

	int ans = 0;
	rep(i, N)
	{
		std::map<char, int>cnt;
		++cnt[A[i]];
		++cnt[B[i]];
		++cnt[C[i]];

		int num = 0;
		char c;
		for (auto j : cnt)
		{
			if (num < j.second)
			{
				num = j.second;
				c = j.first;
			}
		}

		if (A[i] != c) ++ans;
		if (B[i] != c) ++ans;
		if (C[i] != c) ++ans;
	}

	out << ans << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;
typedef std::vector<std::vector<int>> graph;

graph g(200);

// 0: 調べてない, 1,-1: 塗り分け後
int checked[200] = {};
bool isBipartite(const graph &g, int parent, int i, int c) {
  if (checked[i] != 0) {
    return checked[i] == c;
  }
  checked[i] = c;
  for (auto v : g[i]) {
    if (v == parent)
      continue;
    if (!isBipartite(g, i, v, -c)) {
      return false;
    }
  }
  return true;
}

int main() {
  int n;
  cin >> n;
  REP(i, n) {
    string s;
    cin >> s;
    REP(j, n) {
      if (s[j] == '1') {
        g[i].push_back(j);
        g[j].push_back(i);
      }
    }
  }

  if (!isBipartite(g, -1, 0, 1)) {
    cout << -1 << endl;
    return 0;
  }

  // d[u][v]はu=vならば0、辺(u,v)があればそのコスト、なければINFで初期化
  int d[n][n] = {};

  REP(i, n) {
    REP(j, n) { d[i][j] = 500; }
  }

  REP(i, n) {
    d[i][i] = 0;
    for (auto v : g[i]) {
      d[i][v] = 1;
      d[v][i] = 1;
    }
  }

  REP(k, n) {
    REP(i, n) {
      REP(j, n) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); }
    }
  }

  int ans = 0;
  REP(i, n) {
    REP(j, n) { ans = max(ans, d[i][j]); }
  }

  cout << ans + 1 << endl;
}


Measured memory_bytes: 640
D=int(input())
C=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(D)]
X=[0]*26
XX=[0]*26
P=[]
Y,Z=0,0
V,W=0,0
T,U=0,0
for i in range(D):
  for j in range(26):
    X[j]+=C[j]
    XX[j]+=X[j]
  Y,Z=-1,-10**20
  V,W=Y,Z
  T,U=V,W
  for j in range(26):
    if Y==-1:
      Y,Z=0,X[0]+S[i][0]
    if Z<X[j]+S[i][j]:
      T,U=V,W
      V,W=Y,Z
      Y,Z=j,X[j]+S[i][j]
    elif W<X[j]+S[i][j]:
      T,U=V,W
      V,W=j,X[j]+S[i][j]
    elif T<X[j]+S[i][j]:
      T,U=j,X[j]+S[i][j]
  XX[Y]-=X[Y]
  X[Y]=0
  P.append((Y,V,T))
SCORE=0
X=[0]*26
for i in range(D):
  SCORE+=S[i][P[i][0]]
  for j in range(26):
    X[j]+=C[j]
  X[P[i][0]]=0
  SCORE-=sum(X)
SCORE2=0
YY=[]
for i in range(D):
  for k in range(2):
    d,q=i,P[i][k+1]
    SCORE2=SCORE
    YY=XX[:]
    SCORE2-=S[d][P[d][0]]
    SCORE2+=S[d][q]
    for j in range(26):
      X[j]=0
    YY[P[d][0]],YY[q]=0,0
    for j in range(D):
      if j==d:
        Z=q
      else:
        Z=P[j][0]
      X[P[d][0]]+=C[P[d][0]]
      X[q]+=C[q]
      X[Z]=0
      YY[P[d][0]]+=X[P[d][0]]
      YY[q]+=X[q]
    if SCORE2-sum(YY)>SCORE-sum(XX):
      z=[P[i][k+1]]
      for l in range(3):
        if l!=k:
          z.append(P[i][l])
      P[i]=tuple(z)
      XX=YY[:]
      SCORE=SCORE2
for i in range(D):
  print(P[i][0]+1)

Measured memory_bytes: 69952
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x=min(x, y)
#define chmax(x,y) x=max(x, y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = (1<<21);
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

int main(){
	int n, c;
    cin >> n >> c;
  	vector<vector<int>> D(c, vector<int>(c));
    rep(i, c)rep(j, c) cin >> D[i][j];
    vector<vector<int>> C(3);
    rep(i, n)rep(j, n){
        int tmp;
        cin >> tmp;
        tmp--;
        int index = (i+j)%3;
        C[index].push_back(tmp);
    }
    vector<vector<ll>> cost(3, vector<ll>(c));
    rep(i, 3)rep(j, c)rep(index, C[i].size()){
        cost[i][j] += D[C[i][index]][j];
    }
    ll ans = INF;
    rep(i, c)rep(j, c)rep(k, c){
        if(i!=j and i!=k and j!=k){
            chmin(ans, cost[0][i] + cost[1][j] + cost[2][k]);
        }
    }

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

Measured memory_bytes: 1524
from itertools import product


def main():
    tmp = [0] * 4
    N, A, B, C = map(int, input().split())
    L = [int(input()) for _ in range(N)]
    ans = float("inf")
    for i in range(N):
        for j in range(N):
            for k in range(N):
                if i == j or j == k or k == i:
                    continue
                tmp = [0, A-L[i], B-L[j], C-L[k]]
                rem = [L[x] for x in range(N) if x not in (i, j, k)]
                for p in product([0, 1, 2, 3], repeat=len(rem)):
                    tmp2 = [x for x in tmp]
                    for pi in range(len(p)):
                        tmp2[p[pi]] -= rem[pi]
                    swaps = len(list(filter(lambda x: x != 0, p)))
                    ans = min(ans, sum(map(abs, tmp2[1:])) + 10 * swaps)
                ans = min(ans, sum(map(abs, tmp[1:])))
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 47452
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<list>
#include<queue>
#include<map>
using namespace std;
#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)
int INF=1e9;
const long long mod=1e9+7;
typedef long long ll;

int main(){
  int n; cin>>n;
  vector<ll>a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int q; cin>>q;
  vector<ll>k(q);
  for(int i=0;i<q;i++){
    cin>>k[i];
  }
  for(int i=0;i<q;i++){
    if(binary_search(a.begin(),a.end(),k[i])){
      cout<<1<<endl;
    }
    else{
      cout<<0<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 5148
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
long long g[205][205];
int index[205];
void floyd(int n)
{
    for(int k=1;k<=n;k++)
    {
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=n;j++)
            {
                g[i][j]=min(g[i][k]+g[k][j],g[i][j]);
            }
        }
    }
    return ;
}
int main()
{
    int n,m,r;
    cin>>n>>m>>r;
    for(int i=1;i<=r;i++)
        cin>>index[i];
    sort(index+1,index+1+r);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(i==j) g[i][j]=0;
            else g[i][j]=10000005;
        }
    }
    for(int i=1;i<=m;i++)
    {
        int x,y;
        long long z;
        scanf("%d %d %lld",&x,&y,&z);
        g[x][y]=min(z,g[x][y]);
        g[y][x]=min(z,g[y][x]);
    }
    floyd(n);
    long long ans=100000005;
    do
    {
        long long sum=0;
        for(int i=1;i<=r-1;i++)
        {
            //cout<<index[i]<<" "<<index[i+1]<<" "<<g[index[i]][index[i+1]]<<endl;
            sum+=g[index[i]][index[i+1]];
        }
        ans=min(ans,sum);
    }while(next_permutation(index+1,index+1+r));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){

  int a,b;
  cin >> a >> b;
  if ((a > 8) || (b > 8)){
    cout << ":(" << endl;
  }
  else {
    cout << "Yay!" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#define ri register int
typedef long long ll;
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	// no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} 
using io :: gi;
using io :: putc;
using io :: print;
const int N=1e6+5;
int n,tot,head[N],nxt[N<<1],adj[N<<1],f[N],deg[N];
inline void addedge(ri x,ri y){
	nxt[++tot]=head[x];
	adj[head[x]=tot]=y;
}
inline void dfs(ri x,ri fa){
	ri y,i,ch,flag;
	ch=flag=f[x]=0;
	for(i=head[x];i;i=nxt[i])
		if((y=adj[i])!=fa)
			dfs(y,x),
			++ch,
			flag+=(f[y]!=0),
			f[x]+=f[y];
	if(flag<ch-1) f[x]+=ch-1-flag;
}
int main(){
	ri i,x,y;
	gi(n);
	if(n==1) return puts("0"),0;
	for(i=1;i^n;++i) gi(x),gi(y),++x,++y,addedge(x,y),addedge(y,x),++deg[x],++deg[y];
	for(i=1;i<=n;++i)
		if(deg[i]>2) break;
	if(i>n) return puts("1"),0;
	dfs(i,0);
	printf("%d\n",f[i]);
	return 0;
}

Measured memory_bytes: 20864
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <assert.h>
#include <map>
#include <memory.h>
#include <queue>
#include <string.h>
#include <set>
#include <bitset>
using namespace std;

#define ll long long
#define N 100005
#define EDGE 200005

vector<int> adj[N];
int a[EDGE],b[EDGE],c[EDGE];

int dsu[EDGE],id[EDGE];

int f(int x) {
  if(dsu[x]==x) {
    return x;
  }
  return dsu[x] = f(dsu[x]);
}

void merge(int x,int y) {
  x = f(x),y = f(y);
  if(x!=y) {
    dsu[x] = y;
  }
}

bool isUsedEdge[EDGE];
int depth[N];

vector<int> reachableNodes[EDGE];

void bfs(int n) {
  for(int i=n;i;--i) depth[i] = -1;
  depth[1] = 0;
  queue<int> q; q.push(1);

  while(!q.empty()) {
    int node = q.front();q.pop();
    for(int i=0;i<adj[node].size();++i) {
      int eid = adj[node][i];
      eid = f(eid);
      if(isUsedEdge[eid]) {
        continue;
      }
      isUsedEdge[eid] = true;
      for(int j = 0;j<reachableNodes[eid].size();++j) {
        int nextNode = reachableNodes[eid][j];
        if( depth[nextNode] == -1) {
          depth[nextNode] = depth[node] + 1;
          q.push(nextNode);
        }
      }
    }
  }
}

void solve() {
  int n,m;scanf("%d %d ", &n,&m);
  vector<pair<int,int> > edge;
  for(int i=0;i<m;++i) {
    scanf("%d %d %d",&a[i],&b[i],&c[i]);
    adj[a[i]].push_back(i);
    adj[b[i]].push_back(i);
    edge.push_back(make_pair(c[i],i));
    dsu[i] = i;
  }
  for(int i=n;i;--i) {
    id[i] = -1;
  }

  sort(edge.begin(),edge.end());
  for(int i=0;i<m;) {
    int j;
    for(j= i;j<m;++j) {
      if(edge[j].first!=edge[i].first) {
        break;
      }
      int x = a[edge[j].second], y = b[edge[j].second];
      if(id[x]==-1) {
        id[x] = edge[j].second;
      }
      if(id[y]==-1) {
        id[y] = edge[j].second;
      }
      merge(id[x],edge[j].second);
      merge(id[y],edge[j].second);
    }

    for(j= i;j<m;++j) {
      if(edge[j].first!=edge[i].first) {
        break;
      }
      int x = a[edge[j].second], y = b[edge[j].second];
      id[x] = -1;
      id[y] = -1;
    }
    i = j;
  }
  for(int i=0;i<m;++i) {
    int eid = f(i);
    reachableNodes[eid].push_back(a[i]);
    reachableNodes[eid].push_back(b[i]);
  }
  bfs(n);
  printf("%d\n", depth[n]);
}

int main() {
  //freopen("input.txt","r",stdin);
  solve();
  return 0;
}


Measured memory_bytes: 23536
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ls x<<1
#define rs x<<1|1
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-6;
const ull hashp=1e7+19;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=2e5+100;
char s[maxn];
void solve()
{
    int a,b,c;scddd(a,b,c);
    if(a+b+c>=22)printf("bust");
    else printf("win");
}
int main(){
    //IOS;
    //freopen("D://data.txt","r",stdin);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


int main(){
    LL l,r;cin >> l >> r;
    LL ans = LINF;
    for (LL i = l; i < min(l+2019LL,r); i++) {
        for (LL j = l+1; j <= min(l+2019LL,r); j++) {
            ans=min(ans,((i%2019)*(j%2019))%2019);
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> cities(N);
  for (int i = 0; i < M; i++) {
    int input_1, input_2;
    cin >> input_1 >> input_2;
    cities.at(input_1 - 1)++;
    cities.at(input_2 - 1)++;
  }
  for (int j = 0; j < N; j++) 
    cout << cities.at(j) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int i;
  int arr[n+1];
    long long int sum=0,sum1=0;
  long int avg;
  long long int brr[100000];
  for(i=0;i<n;i++)
  {
    cin>>arr[i];
    sum=sum+arr[i];
  }
  int x;
  int k=0;
//  cout<<sum<<endl;
  //avg=ceil(sum/float(n));
  //cout<<avg<<endl;
  for(x=-100;x<=100;x++)
  {
    sum1=0;
  for(i=0;i<n;i++)
  {
    sum1=sum1+(arr[i]-x)*(arr[i]-x);
  //  cout<<sum1<<endl;
  }
  brr[k++]=sum1;
}
  sort(brr,brr+k);
  cout<<brr[0];
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int r;
		int g;
		int b;
		while(true) {
			r = sc.nextInt();
			g = sc.nextInt();
			b = sc.nextInt();
			if(r > 0 && r < 10 && g > 0 && g < 10 && b > 0 && b < 10) {
				break;
			}
		}
		String R = String.valueOf(r);
		String G = String.valueOf(g);
		String B = String.valueOf(b);
		String rgb = R + G + B;
		int changeRGB = Integer.parseInt(rgb);
		if(changeRGB % 4 == 0) {
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 23632
/*
Name: B
Author: ztj
Date: 2018-7-7
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s; cin>>s;
	int w; cin>>w;
	for(int i=0;i<s.size();i+=w) cout<<s[i];
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
primeset = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009}

def gcd(n,m):
    while n:
        m,n = n,m%n
    return m

N = int(input())
A = list(map(int,input().split()))

soinsu = set()
a,b = 0,0

def pariwise():
    global primeset,N,A,soinsu,a,b
    for i in range(N):
        a = A[i]
        b = set()
        for j in primeset:
            while a != 1 and a % j == 0:
                a //= j
                b.add(j)
        if a != 1:
            b.add(a)
        for j in b:
            if j in soinsu:
                return False
            soinsu.add(j)
    return True

def setwise():
    global primeset,N,A,soinsu,a,b
    a = A[0]
    for i in range(1,N):
        a = gcd(a,A[i])
    return (a == 1)

if pariwise():
    print('pairwise coprime')
elif setwise():
    print('setwise coprime')
else:
    print('not coprime')


Measured memory_bytes: 197148
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a[11],b[11];
  for(int i=0;i<10;i++){
    cin >> a[i];
  }
  for(int i=0;i<10;i++){
    cin >> b[i];
  }
  sort( a , a + 10 ,greater<int>());
  sort( b , b + 10 ,greater<int>());
  cout << a[0]+a[1]+a[2] << ' ' << b[0]+b[1]+b[2] << endl;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(long long i=1; i<x;i++)
typedef long long ll;

int main(){
	ll K;
  cin>>K;
  ll ans=0;
  
  auto gcd = [&](ll p, ll q){
    while(p%q!=0){
    	ll x = p%q;
      p=q;
      q=x;
    }
  	return q;
  };
  
  
  rep(a,K+1){
  	rep(b,K+1){
    	rep(c,K+1){
        
         ll ab=gcd(a,b);
          ans+=gcd(ab,c);

        
        }
    }
  }
  cout<<ans;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long A, B;
    cin >> A >> B;
    long long sol = 0;
    if (A % 2 == 1) {
        sol = sol ^ A++;
    }
    if (B % 2 == 0) {
        sol = sol ^ B--;
    }
    sol = sol ^ ((B - A + 1) / 2 % 2 == 1);
    cout << sol;
}

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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> p(N);
  for(int i = 0; i < N; i++) {
    cin >> p.at(i);
  }
  
  sort(p.begin(),p.end());
  int ans = 0;
  for(int j = 0; j < K; j++) {
    ans += p.at(j);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i, N) for (int i=0; i<(int)N; i++)
#define rep1(i, N) for (int i=1; i<(int)N; i++)

using namespace std;

int n, m;

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

  int p[m];
  string  s[m];
  set<int> st_ans;
  set<int> st_ans_all;

  int n_ans = 0;
  int n_pen = 0;
  rep(i, m) {
    cin >> p[i] >> s[i];
    if(s[i] == "AC") {
      st_ans_all.insert(p[i]);
    }

   }
  

  rep(i, m) {
    if (s[i] == "WA") {
      if (st_ans.find(p[i]) == st_ans.end() && 
          st_ans_all.find(p[i]) != st_ans_all.end()) {
        n_pen++;
      }
    }
    
    if(s[i] == "AC") {
      st_ans.insert(p[i]);
    }
  }
  
  cout << st_ans.size() << " " << n_pen;
   
}


Measured memory_bytes: 15488
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	long long n;

	std::cin >> n;

	if (n % 10 == 3) {
		std::cout << "bon" << std::endl;
	}
	else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) {
		std::cout << "pon" << std::endl;
	}
	else {
		std::cout << "hon" << std::endl;
	}

	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
bool isPalindrome(string str)
{

    int l = 0;
    int h = str.size() - 1;

    while (h > l)
    {
        if (str[l++] != str[h--])
        {

            return false;
        }
    }
    return true;
}
int main()
{
    string s;
    cin>>s;
    string st1;
    st1=s[0];
    for(int i=1; i<(s.size())/2; i++){
        st1+=s[i];

    }
    string st2;
    st2[0]= s[(s.size()/2)+2];
    int j=1;
    for(int i= (s.size()/2)+1; i<s.size(); i++){
        st2+=s[i];
    }
    if(isPalindrome(s)){
        if(isPalindrome(st1) and isPalindrome(st2)){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}


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

int n;
int a[100010];
int cou[100010];

int main()
{
	cin >> n;
	int kind = 0;
	int over = 0;

	for(int i = 0;i < n;i++)
	{
		cin >> a[i];
		cou[a[i]]++;
		if(cou[a[i]] == 1)
		{
			kind++;
		}
		else
		{
			over++;
		}
	}
	if(over % 2== 1)
	{
		kind--;
	}

	cout << kind << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long banme = Long.MIN_VALUE;
		long ans = 0L;
		for(int i = 0; i < N; i++) {
			long l = sc.nextLong();
			long a = sc.nextLong();
			if(l >= banme) {
				banme = l;
				ans = l + a;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 62628
import java.util.Scanner;

public class Main{

	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		String result = "No";
		int N100 = N/100;
		int N10 = (N-N100*100)/10;
		int N1 = (N-N100*100-N10*10);
		if(N100==7 || N10==7 || N1==7) {
			result="Yes";
		}
		scan.close();
		System.out.println(result);
	}
}

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

int main() {
    int i,x;
    i = 1;
    while (1) {
        cin >> x;
        if (x == 0) {
            break;
        }
        cout << "Case " << i << ": " << x << endl;
        ++i;
    }
    return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll ;
long double dp[3000][3000] ;

ll max(ll a , ll b)
{
  return (a > b) ? a: b;
}
ll min(ll a , ll b)
{
  return (a < b) ? a : b;
}
void memset(int *arr , int n , int value)
{
    for(int i= 0; i<n ; i++)
    {
        arr[i] = value;
    }
}

void probability(long double *arr , int n)
{
    dp[0][0] = 1.0 ;

    // filling base conditions
    for(int i =1 ; i<=n ; i++)
    {
        dp[i][0] = dp[i-1][0]*(1 - arr[i-1] );
    }

    for(int i= 1 ; i<=n ; i++)
    {
        for(int j=1 ; j<=n ; j++)
        {
            dp[i][j] = arr[i-1]*dp[i-1][j-1] + (1 - arr[i-1])*dp[i-1][j] ;
        }
    }
    long double ans = 0.0;
    for(int i=n/2+1 ; i<=n ; i++)
    {
        ans +=dp[n][i] ;
    }
    cout<<setprecision(10)<<ans<<endl;
}

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

    int n;
    cin>>n;
    long double *arr = new long double[n] ;
    for(int i= 0; i<n ; i++)
    {
        cin>>arr[i];
    }
    for(int i= 0; i<=n ; i++)
    {
        for(int j=0 ; j<=n ; j++)
        {
            dp[i][j] =0;
        }
    }
    probability(arr , n ) ;
    return 0;
}


Measured memory_bytes: 140928
#include<iostream>
#include<vector>
using namespace std;
//1-indexed
#include<vector>
template<typename T>
struct BIT{
	int n;
	vector<T>bit;
	BIT(int n_=0):n(n_),bit(n_+1){}
	T sum(int i)
	{
		T ans=0;
		for(;i>0;i-=i&-i)ans+=bit[i];
		return ans;
	}
	void add(int i,T a)
	{
		if(i==0)return;
		for(;i<=n;i+=i&-i)bit[i]+=a;
	}
	int lower_bound(T k)//k<=sum(ret)
	{
		if(k<=0)return 0;
		int ret=0,i=1;
		while((i<<1)<=n)i<<=1;
		for(;i;i>>=1)
			if(ret+i<=n&&bit[ret+i]<k)k-=bit[ret+=i];
		return ret+1;
	}
};
int N,Q;
string S;
main()
{
	cin>>N>>S>>Q;
	vector<BIT<int> >P(26,BIT<int>(N));
	for(int i=0;i<S.size();i++)
	{
		P[S[i]-'a'].add(i+1,1);
	}
	for(;Q--;)
	{
		int id;cin>>id;
		if(id==1)
		{
			int i;char c;cin>>i>>c;
			i--;
			P[S[i]-'a'].add(i+1,-1);
			S[i]=c;
			P[S[i]-'a'].add(i+1,1);
		}
		else
		{
			int l,r;cin>>l>>r;
			l--;
			int cnt=0;
			for(int i=0;i<26;i++)cnt+=P[i].sum(r)>P[i].sum(l);
			cout<<cnt<<endl;
		}
	}
}


Measured memory_bytes: 53764
#include<bits/stdc++.h>
using namespace std;
double cxu,cxl,cyu,cyl;
bool bx,by;
double uR,lR,uL,lL,uU,lU,uD,lD;
bool bR,bL,bU,bD;
typedef struct{double x,y; char d;}dat;
auto u = [](double& a,double b){a=max(a,b);};
auto l = [](double& a,double b){a=min(a,b);};
const double inf = 1e10;
int main(){
  dat D;
  int n;
  cin>>n;
  for(int i=0;i<n;++i){
    cin>>D.x>>D.y>>D.d;
    switch(D.d){
      case 'U':
      case 'D':
        if(bx)u(cxu,D.x),l(cxl,D.x);
        else cxu=cxl=D.x,bx=1;
        break;
      case 'L':
      case 'R':
        if(by)u(cyu,D.y),l(cyl,D.y);
        else cyu=cyl=D.y,by=1;
    }
    switch(D.d){
      case 'U':
        if(bU)u(uU,D.y),l(lU,D.y);
        else uU=lU=D.y,bU=1;
        break;
      case 'D':
        if(bD)u(uD,D.y),l(lD,D.y);
        else uD=lD=D.y,bD=1;
        break;
      case 'L':
        if(bL)u(uL,D.x),l(lL,D.x);
        else uL=lL=D.x,bL=1;
        break;
      case 'R':
        if(bR)u(uR,D.x),l(lR,D.x);
        else uR=lR=D.x,bR=1;
        break;
    }
  }
  auto xmax = [&](double t){return max({bL?uL-t:-inf,bR?uR+t:-inf,bx?cxu:-inf});};
  auto xmin = [&](double t){return min({bL?lL-t:inf,bR?lR+t:inf,bx?cxl:inf});};
  auto ymax = [&](double t){return max({bD?uD-t:-inf,bU?uU+t:-inf,by?cyu:-inf});};
  auto ymin = [&](double t){return min({bD?lD-t:inf,bU?lU+t:inf,by?cyl:inf});};
  auto f = [&](double t){u(t,-t);return (xmax(t)-xmin(t))*(ymax(t)-ymin(t));};
  printf("%.12f\n",min({f(lL-cxl),f((lL-lR)/2.0),f(cxl-lR),f(uL-cxu),f((uL-uR)/2.0),f(cxu-uR),f(lD-cyl),f((lD-lU)/2.0),f(cyl-lU),f(uD-cyu),f((uD-uU)/2.0),f(cyu-uU),f(0.0)}));
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int n,k;
	int ans = 0;
	cin >> n >> k;
	
	vector<int>v(n);

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

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

	for(int i = 0;i < k;i++){
		ans += v[i];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <algorithm>

#define ASCII_NUM 48

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

using namespace std;

int main(){
    int N;
    long ans=0;
    cin >> N;
    vector<string> str(N);
    unordered_map<string, int> mp;

    rep(i, N){
        cin >> str[i];
        sort(str[i].begin(),str[i].end());
    }

    rep(i, N){
        if (mp[str[i]] == 0)    mp[str[i]] = 1;
        else{
            ans += mp[str[i]]++;
        }
    }

    cout << ans << endl;

    return 0;
}



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

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

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;



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

    while (true) {
        int M, N;
        cin >> N >> M;

        if (M == 0 or N == 0) {
            break;
        }
        vector<int> C(M);
        FOR(i, 0, M) {
            cin >> C[i];
        }
        vector<int> X(N);
        FOR(i, 0, N) {
            cin >> X[i];
        }

        vector<vector<int>> dp(N + 1, vector<int>(256, INF));
        dp[0][128] = 0;

        FOR(i, 0, N) {
            FOR(j, 0, dp[0].size()) {
                if (dp[i][j] == INF) {
                    continue;
                }
                FOR(k, 0, M) {
                    int v = min(max(0, j + C[k]), 255);
                    int d = X[i] - v;
                    dp[i + 1][v] = min(dp[i + 1][v], dp[i][j] + d * d);
                }
            }
        }

        int ans = INF;
        FOR(i, 0, 256) {
            ans = min(ans, dp[N][i]);
        }
        print(ans);
    }
	return 0;
}


Measured memory_bytes: 23752
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using vi = vector<int>;
using vl = vector<int64_t>;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64_t INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

int countdigit(int n) {
  int cnt = 0;
  while (n > 0) {
    n /= 10;
    ++cnt;
  }
  return cnt;
}

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

  int n; cin >> n;
  int ans = 0;

  for (int i = 1; i <= n; ++i) {
    ans += (countdigit(i) & 1);
  }

  print(ans);

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    vector<int>an(5);
    for(int i = 0; i < 5; i++){
        cin >> an.at(i);
    }
    sort(an.begin(), an.end());
    int sum = 0;
    int memo = 9;
    bool up = false;
    for(int i = 0; i < 5; i++){
        if(an.at(i) % 10 != 0){
            up = true;
            memo = min(memo, an.at(i) % 10);
        }
        an.at(i) += 9;
        an.at(i) /= 10;
        an.at(i) *= 10;
        sum += an.at(i);
    }
    if(up){
        sum += memo;
        sum -= 10;
    }
    cout << sum << endl;
    solve();
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int cards[N + 1];
  for(int i = 0;i < N; i++){
    cin >> cards[i];
  }
  int long long cnt = 0;
  cards[N] = 0;
  for(int i = 0;i < N;i++){
    cnt += cards[i]/2;
    cards[i] %= 2;
    if(cards[i] % 2 > 0 && cards[i + 1] != 0){
      cnt++;
      cards[i]--;
      cards[i + 1]--;
    }
  }
  cout << cnt << endl;
  return 0;
}


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

int main(){
    /*
    vector<int> a(3);
    for(int i=0; i<3; ++i){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    cout << a[2]-a[0] << endl;
    */
   vector<int> a(3);
   for(int i=0; i<3; ++i){
       cin >> a[i];
   }
   sort(a.begin(), a.end());
   int sum=0;
   sum += a[2] - a[1] + a[1] - a[0];
   cout << sum << endl;
}


Measured memory_bytes: 3640
#include<cstdio>

int dp[200000];
int h[200000];

int abs(int x) {
    return x < 0 ? -x : x;
}

int main(void) {
    int n,k;
    scanf("%d",&n);
    k = 2;
    for(int i=0; i<n; i++)
        scanf("%d",&h[i]);

    for(int i=0; i<n; i++)
        dp[i] = 1e9;

    dp[0] = 0;
    for(int i=0; i<n; i++)
        for(int j=1; j<=k && i+j<n; j++)
            if(dp[i+j] > dp[i] + abs(h[i+j]-h[i]))
                dp[i+j] = dp[i] + abs(h[i+j] - h[i]);

    printf("%d\n", dp[n-1]);
}


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

int cookie(int a){
int temp=a;
    if(a%2==1){
        temp=a-1;
    }
    return  temp/2;
}

int main(){
    int a,b,k;
    cin >> a>>b>>k;
    for(int i=0;i<k;i++){
        if(i%2==0){
            a=cookie(a);
         //   cout<<a<<endl;
            b+=a;
//cout<<b<<endl;
        }else{
            b=cookie(b);
            a+=b;
        }
    }
    cout <<a<<" "<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  V<string> t(n); for (auto&& e : t) cin >> e;
  V<string> s;
  for (int i = 0; i < n; ++i) {
    if (i + 1 < n and count(begin(t[i]), end(t[i]), '.') + count(begin(t[i + 1]), end(t[i + 1]), '.') == 2 * m) continue;
    s.push_back(t[i]);
  }
  n = s.size();
  V<> idx;
  for (int j = 0; j < m; ++j) {
    bool b = j + 1 < m;
    if (b) {
      for (int i = 0; i < n; ++i) if (s[i][j] != '.' or s[i][j + 1] != '.') {
        b = false;
        break;
      }
    }
    if (b) continue;
    idx.push_back(j);
  }
  m = idx.size();
  for (auto&& e : s) {
    string t;
    for (int j : idx) t += e[j];
    e = t;
  }
  int res = 0;
  for (int _ = 0; _ < 26; ++_) {
    for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) if (s[i][j] == '.') {
      map<char, int> mp;
      for (int jj = j - 1; jj >= 0; --jj) if (s[i][jj] != '.') {
        ++mp[s[i][jj]];
        break;
      }
      for (int jj = j + 1; jj < m; ++jj) if (s[i][jj] != '.') {
        ++mp[s[i][jj]];
        break;
      }
      for (int ii = i - 1; ii >= 0; --ii) if (s[ii][j] != '.') {
        ++mp[s[ii][j]];
        break;
      }
      for (int ii = i + 1; ii < n; ++ii) if (s[ii][j] != '.') {
        ++mp[s[ii][j]];
        break;
      }
      set<char> se;
      for (const auto& e : mp) if (e.second >= 2) {
        se.insert(e.first);
      }
      for (int jj = j - 1; jj >= 0; --jj) if (se.count(s[i][jj])) {
        s[i][jj] = '.';
        ++res;
        break;
      }
      for (int jj = j + 1; jj < m; ++jj) if (se.count(s[i][jj])) {
        s[i][jj] = '.';
        ++res;
        break;
      }
      for (int ii = i - 1; ii >= 0; --ii) if (se.count(s[ii][j])) {
        s[ii][j] = '.';
        ++res;
        break;
      }
      for (int ii = i + 1; ii < n; ++ii) if (se.count(s[ii][j])) {
        s[ii][j] = '.';
        ++res;
        break;
      }
    }
  }
  cout << res << '\n';
}


Measured memory_bytes: 3380
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        F_LCS solver = new F_LCS();
        solver.solve(1, in, out);
        out.close();
    }

    static class F_LCS {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            String s = in.ns();
            String t = in.ns();
            int sn = s.length();
            int tn = t.length();
            int[][] dp = new int[sn + 1][tn + 1];
            int[][][] path = new int[sn + 1][tn + 1][2];
            for (int i = 0; i < sn; i++) {
                for (int j = 0; j < tn; j++) {
                    if (s.charAt(i) == t.charAt(j)) {
                        dp[i + 1][j + 1] = dp[i][j] + 1;
                        path[i + 1][j + 1][0] = i;
                        path[i + 1][j + 1][1] = j;
                    } else {
                        if (dp[i + 1][j] > dp[i][j + 1]) {
                            dp[i + 1][j + 1] = dp[i + 1][j];
                            path[i + 1][j + 1][0] = i + 1;
                            path[i + 1][j + 1][1] = j;
                        } else {
                            dp[i + 1][j + 1] = dp[i][j + 1];
                            path[i + 1][j + 1][0] = i;
                            path[i + 1][j + 1][1] = j + 1;
                        }
                    }
                }
            }
            int i = sn, j = tn;
            StringBuilder sb = new StringBuilder();
            while (i > 0 && j > 0) {
                if (s.charAt(i - 1) == t.charAt(j - 1)) {
                    sb.append(s.charAt(i - 1));
                }
                int ti = path[i][j][0];
                j = path[i][j][1];
                i = ti;
            }
            out.println(sb.reverse().toString());
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String ns() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 385740
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
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; }
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
static const double EPS = 1e-10;
static const double PI  = acos(-1.0);
static const ll MOD = 1000000007;
// static const ll MOD = 998244353;
static const int INF = 1 << 30;
// static const ll INF = 1LL << 62;
// --------------------------------------------------------


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);

    int H, W, D; cin >> H >> W >> D;
    VVI A(H, VI(W)); REP(i,H) REP(j,W) cin >> A[i][j];
    int Q; cin >> Q;

    VP B(H*W+1);
    REP(h,H) REP(w,W) {
        B[A[h][w]] = make_pair(h, w);
    }

    VI C(H*W+1,0);
    int h1, h2, w1, w2;
    FOR(i,1,H*W+1-(D-1)) {
        tie(h1, w1) = B[i];
        tie(h2, w2) = B[i + D];
        C[i + D] = C[i] + abs(h1 - h2) + abs(w1 - w2);
    }

    REP(_, Q) {
        int L, R; cin >> L >> R;
        cout << C[R] - C[L] << '\n';
    }

    return 0;
}


Measured memory_bytes: 4808
#include <stdio.h>

int main(void)
{
	char str[21];
	int i, j;

	scanf("%s", str);

	i = 0;
	while (str[i] != '\0'){
		i++;
	}

	for (j = i - 1; j >= 0; j--){
		printf("%c", str[j]);
	}
	printf("\n");

	return (0);
}

Measured memory_bytes: 2596
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}
		Arrays.sort(a);
		System.out.println(Math.abs(a[0] - a[n - 1]));
	}
}

Measured memory_bytes: 22740
/*
* problem:
* method:
* date:
*/
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#define LL long long
using namespace std;
vector<pair<LL,int> > v;
LL N,res;
int main() {
	LL i;
	cin>>N;
	for(i=2; i*i<=N; i++) {
		if(N%i==0) {
			v.push_back(make_pair(i,0));
			while(N%i==0) {
				v.back().second++;
				N/=i;
			}
		}
	}
	if(N>1) {
		v.push_back(make_pair(N,1));
	}
	res=0;
	for(pair<LL,int> &p : v) {
		int x=sqrt(p.second*2);
		if((x+1)*x>p.second*2) {
			x--;
		}
		res+=x;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 3640