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

int main()
{
	int N, T = 0;
	cin >> N;
	vector<int> t(N);
	for (int i = 0; i < N; i++) {
		cin >> t[i];
		T += t[i];
	}
	vector<int> V(T + 1);
	for (int i = 0, j = 1; i < N; i++) {
		int v;
		cin >> v;
		for (int k = 0; k < t[i]; k++) {
			V[j++] = v;
		}
	}
	vector<vector<double>> dp(T + 1, vector<double>(101, -1e9));
	dp[0][0] = 0;
	for (int i = 1; i <= T; i++) {
		for (int j = 0; j <= V[i]; j++) {
			if (j >= 1) {
				dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + j - 0.5);
			}
			dp[i][j] = max(dp[i][j], dp[i - 1][j] + j + (j < V[i] ? 0.25 : 0.0));
			if (j < V[i]) {
				dp[i][j] = max(dp[i][j], dp[i - 1][j + 1] + j + 0.5);
			}
		}
	}
	cout << fixed << setprecision(3) << dp[T][0] << endl;
	return 0;
}


Measured memory_bytes: 16768
import java.util.Arrays;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		String W = keyboard.next();	
		
		int[] count = new int[W.length()];
		
		if(W.length() % 2 == 0) {
			for(int i =0; i < W.length(); i++) {
				for(int j=0; j < W.length(); j++) {
					if(W.charAt(i) != W.charAt(j)) {
						count[i]++;
					}
				}
			}
		
			int NG = 0;
			String kotae;
		
			for(int k=0; k < W.length(); k++) {
				if(count[k] % 2 == 1) {
					NG++;
				}
			}
			kotae = NG == 0 ? "Yes" : "No";
			System.out.print(kotae);
		
		}else {
			System.out.print("No");
		}
		
		keyboard.close();	
	}
}

Measured memory_bytes: 21716
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n;
  cin >> n;
  vll pref(n+2), suff(n+2), a(n+2);
  for(ll i = 1; i <= n; i++) cin >> a[i];
  ll gc = 0;
  for(ll i = 1; i <= n; i++) {
    gc = __gcd(a[i], gc);
    pref[i] = gc;
  }
  gc = 0;
  for(ll i = n; i >= 1; i--) {
    gc = __gcd(a[i], gc);
    suff[i] = gc;
  }
  ll ans = 0;
  for(ll i = 1; i <= n; i++) {
    ans = max(ans, __gcd(pref[i-1], suff[i+1]));
  }
  cout << ans << endl;
  return 0;
  
} //good night.

Measured memory_bytes: 2560
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int x, n;
    cin >> x >> n;
    set<int> s;
    for (int i = 0; i < n; i++) {
        int pi;
        cin >> pi;
        s.insert(pi);
    }

    int ans = 100000;
    for (int i = -1; i < 102; i++) {
        if (s.count(i) > 0) continue;

        if (abs(i - x) < abs(ans - x)) {
            ans = i;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3664
#include<stdio.h>
int main(){
  int a,b;
  int x;
  char op;

  while(1){
    scanf("%d%*c%c%d",&a,&op,&b);
    if(op == '?') break;
    
     
      if(op == '+') x=a+b;
      else if(op == '-') x=a-b;
      else if(op == '*') x=a*b;
      else if(op == '/') x=a/b;

      printf("%d\n",x);
   

  }

  return 0;
}

Measured memory_bytes: 600
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;
        static void Main(string[] args)
        {
            var NM = Sarray();
            N = NM[0];
            M = NM[1];
            a = new int[N].Select(_ => new List<long>()).ToArray();
            for (var i = 0; i < N - 1; ++i)
            {
                var t = Sarray();
                a[t[0] - 1].Add(t[1] - 1);
                a[t[1] - 1].Add(t[0] - 1);
            }
            dpnode = new int[N].Select(_ => 1L).ToArray();
            dpedge = new int[N].Select(_ => new List<long>()).ToArray();
            parent = new long[N];

            dfs(0, -1);
            dpa = new int[N].Select(_ => 1L).ToArray();
            ruil = new long[3 * N + 1];
            ruir = new long[3 * N + 1];

            dfs3(0, -1, 0, 0);
            for (var i = 0; i < N; ++i)
                WriteLine(dpnode[i]);
        }
        static List<long>[] a;
        static long N;
        static long M;
        static long[] dpnode;
        static long[] dpa;
        static List<long>[] dpedge;
        static long[] parent;
        static void dfs(long v, long p)
        {
            var cnt = 0;
            parent[v] = p;
            foreach (var n in a[v])
            {
                if (n == p)
                {
                    dpedge[v].Add(1);
                    continue;
                }
                cnt++;
                dfs(n, v);
                dpedge[v].Add((dpnode[n] + 1) % M);
                dpnode[v] = dpnode[v] * (dpnode[n] + 1) % M;
            }
        }
        static long[] ruil;
        static long[] ruir;
        static void dfs3(long v, long p, long pv, long s)//pv:親の情報
        {
            var num = a[v].Count;

            for (var i = 0; i < num; ++i)
                if (p == a[v][i])
                {
                    dpedge[v][i] = (pv + 1) % M;
                    break;
                }
            ruil[s] = 1;
            ruir[s] = 1;
            for (var i = 0; i < num; ++i)
            {
                ruil[s + i + 1] = ruil[s + i] * dpedge[v][i] % M;
                ruir[s + i + 1] = ruir[s + i] * dpedge[v][num - i - 1] % M;
            }
            dpnode[v] = ruil[s + num];
            for (var i = 0; i < num; ++i)
            {
                if (a[v][i] == p)
                    continue;
                dfs3(a[v][i], v, ruil[s + i] * ruir[s + num - i - 1], s + num + 1);
            }
        }
    }
}

Measured memory_bytes: 58236
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef long long ll;
int n;
ll K;
#define Maxn 400010
ll a[Maxn],last[Maxn];
bool ap[Maxn];
ll to[Maxn],d[Maxn];
ll all[Maxn],cnt=0;
ll num[Maxn];
ll Ans[Maxn],len;
inline void solve(int ans){
	memset(ap,false,sizeof(ap));
	for(register int i=ans;i<=n;++i){
		if(!ap[a[i]])Ans[++len]=a[i],ap[a[i]]=true;
		else{
			while(ap[a[i]]){
				ap[Ans[len]]=false;
				len--;
			}
		}
	}
	for(register int i=1;i<=len;++i)printf("%d ",Ans[i]);
}
int main(){
	scanf("%d%lld",&n,&K);
	K=K*n;
	for(register int i=1;i<=n;++i){
		scanf("%lld",&a[i]);
		a[i+n]=a[i];
	}
	for(register int i=2*n;i>=1;--i){
		if(i<=n){
			if(last[a[i]]>n){
				to[i]=last[a[i]]-n+1;
				if(to[i]>n)to[i]=1;
			}else{
			    to[i]=last[a[i]]+1;
			    if(to[i]>n)to[i]=1;
			}
			d[i]=last[a[i]]-i+1;
		}
		last[a[i]]=i;
	}
	int node=1;
	while(!ap[node]){
		ap[node]=true;
		node=to[node];
	}
	int ans=0;
	ll sum=0;
	int at=1;
	while(at!=node){
		if(sum+d[at]>K){
			ans=at;
			break;
		}	
		sum+=d[at];
		at=to[at];
	}
	if(ans){
		if(sum<K)solve(ans);
		return 0;
	}
	num[0]=node;
	do{
		cnt++;
		all[cnt]=all[cnt-1]+d[at];
		at=to[at];
		num[cnt]=at;
	}while(at!=node);
	ll re=K-(K-sum)/all[cnt]*all[cnt]-sum;
	int l=0,r=cnt;
	while(l<r){
		int mid=(l+r)>>1;
		if(all[mid+1]<=re)l=mid+1;
		else r=mid;
	}
	ans=num[l];
	if(all[l]<re)solve(ans);
	return 0;
}

Measured memory_bytes: 23296
import heapq

T = int(input())
Ns = []
cases = []*T
for i in range(T):
    Ns.append(int(input()))
    cases.append([list(map(int, input().split())) for _ in range(Ns[-1])])

for i in range(T):
    answer = 0
    N = Ns[i]
    case = cases[i]
    
    sa = [case[j][2]-case[j][1] for j in range(N)]
    pluss = []
    minuss = []
    for j in range(N):
        if sa[j] >= 0:
            pluss.append([case[j][0],case[j][1],case[j][2],sa[j]])
        else:
            minuss.append([case[j][0],case[j][1],case[j][2],sa[j]])
    pluss = sorted(pluss)
    minuss = sorted(minuss,reverse = True)
    hq = []
    checking = 0
    for j in range(N-len(pluss),N):
        if checking < len(pluss):
            while j > pluss[checking][0]-1:
                heapq.heappush(hq, [-pluss[checking][3],pluss[checking][1],pluss[checking][2],pluss[checking][0]])
                checking+=1
                if checking >= len(pluss):
                    break
        if len(hq)>0:
            temp = heapq.heappop(hq)
            answer += temp[2]

    for j in range(checking,len(pluss)):
        heapq.heappush(hq, [-pluss[j][3],pluss[j][1],pluss[j][2],pluss[j][0]])
        
    for j in range(len(hq)):
        temp = heapq.heappop(hq)
        answer += temp[1]

    hq = []
    checking = 0
    for j in range(len(minuss)-1,-1,-1):
        if checking < len(minuss):
            while j <= minuss[checking][0]-1:
                heapq.heappush(hq, [minuss[checking][3],minuss[checking][1],minuss[checking][2],minuss[checking][0]])
                checking+=1
                if checking >= len(minuss):
                    break
        if len(hq)>0:
            temp = heapq.heappop(hq)
            answer += temp[1]

    for j in range(checking, len(minuss)):
                    heapq.heappush(hq, [minuss[j][3],minuss[j][1],minuss[j][2],minuss[j][0]])

    for j in range(len(hq)):
        temp = heapq.heappop(hq)
        answer += temp[2]
    print(answer)


Measured memory_bytes: 88488
#include "bits/stdc++.h"
using namespace std;
using lli = long long int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
  string s;
  cin >> s;

  int a,z;

  rep(i, s.size())
    if(s.at(i)=='Z') z = i;
  
  rep(i, s.size()) {
    if(s.at(i)=='A') {
      a = i;
      break;
    }
  }

  cout << z-a+1 << endl;
  return 0;
}


Measured memory_bytes: 640
# coding: utf-8
# Your code here!

import collections

n = int(input())
c = collections.Counter([input() for i in range(n)])
m = max(c.values())
k = list(c.keys())
v = list(c.values())
data = []
for i in range(len(c)):
    if v[i] == m:
        data.append(k[i])
        

data.sort()

[print(i) for i in data]

Measured memory_bytes: 109008
#include <stdio.h>

int main(){
  char s[110];
  int flag=0;
  scanf("%s",s);
  
  for(int i=0;i<=100;i+=2){
    if(s[i]-'L'==0){
      printf("No");
      flag=1;
      break;
    }
  }
  for(int i=1;i<=100;i+=2){
    if(flag==1){
      break;
    }
    if(s[i]-'R'==0){
      printf("No");
      flag=1;
      break;
    }
  }
  if(flag==0){
    printf("Yes");
  }
  return 0;
}

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

int N;
 
signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    int M = -1;
    int ans = -1;
    for (int i=1; i<=N; i++) {
        int t = i;
        int cnt = 0;
        while (t%2==0) {
            t /= 2;
            cnt++;
        }
        if (cnt>M) {
            M = cnt;
            ans = i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <iomanip>
#include <bitset>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    int a, b, c;
    cin >> a >> b >> c;
    int x, y;
    cin >> x >> y;
    c = min(2 * c, a + b);
    cout << min(min(x, y) * c + (x > y ? (x - y) * a : (y - x) * b), max(x, y) * c) << '\n';
}


Measured memory_bytes: 256
n = int(input())
l = n // 100
r = n % 100
yymm = 1 <= r <= 12
mmyy = 1 <= l <= 12
if yymm:
    print('AMBIGUOUS' if mmyy else 'YYMM')
else:
    print('MMYY' if mmyy else 'NA')


Measured memory_bytes: 2940
#include <iostream>
#include <queue>

using namespace std;

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

	queue<int> que[1001];

	for (int i = 0; i < q; i++) {
		int s, t;
		cin >> s >> t;
		switch (s) {
		case 0:
			int v;
			cin >> v;
			que[t].push(v);
			// push
			break;
		case 1:
			// top
			if (!que[t].empty()) {
				cout << que[t].front() << endl;
			}
			break;
		case 2:
			// pop
			if (!que[t].empty()) {
				que[t].pop();
			}
			break;
		}
	}
}



Measured memory_bytes: 4384
N,M = map(int,list(input().split()))
i_list = [0]*M
for i in range(N):
    s = list(input().split())
    for j in range(int(s[0])):
        i_list[int(s[j+1])-1] += 1
     #   print(i_list)
counter = 0
for i in range(M):
    if i_list[i] == N:
        counter += 1   
    
print(counter)


Measured memory_bytes: 9120
#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() {
  string s;
  cin >> s;
  // 桁dp
  int n = s.size();
  vector<vector<ll> > dp(
      n + 1, vector<ll>(13, 0));  // dp[k]: 13で割ったあまりがKのパターン数

  int mod = 1000000007;
  dp[0][0] = 1;
  const int N = 13;
  for (int i = 0; i < n; i++) {
    char c = s[i];
    vector<ll> next(13);
    if (c == '?') {
      rep(k, 10) rep(j, 13) {
        dp[i + 1][((j * 10) + k) % 13] += dp[i][j];
        dp[i + 1][((j * 10) + k) % 13] %= mod;
      }
    } else {
      int k = c - '0';
      rep(j, 13) {
        dp[i + 1][((j * 10) + k) % 13] += dp[i][j];
        dp[i + 1][((j * 10) + k) % 13] %= mod;
      }
    }
  }
  cout << dp[n][5] << endl;
  return 0;
}

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

int main(){
  int n; cin >> n;
  ll v = 0, e = 0;
  for(int i = 0; i < n-1; i++){
    ll a, b; cin >> a >> b;
    if(a > b) swap(a, b);
    e += a * (n-b+1);
  }
  for(ll i = 1; i <= n; i++){
    v += i * (n-i+1);
  }
  cout << v - e << endl;
}

Measured memory_bytes: 3612
#include <stdio.h>
#define N 101
#define WHITE 0
#define GRAY  1
#define BLACK 2

int t=0;
int d[N],f[N];
int D[N][N],n;
int v;
int color[N];

void dfs(void);
void visit(int );
 

int main(){
  int i,j;
  int u,k,v;

  scanf("%d",&n);

   //入力
 for(i=1;i<=n;i++){
    scanf("%d%d",&u,&k);
    for(j=1;j<=k;j++){
      scanf("%d",&v);
      D[i][v]=BLACK;
    }
 }
 //
 /*
    for(j=0;j<n;j++)
     color[j]= WHITE;
     t=0;
     
     for(u=0;u<n;u++){
       if(color[u] == WHITE)dfs(u);
     }
 */  
dfs();
 
 //出力
 for(i=1;i<=n;i++){
   printf("%d %d %d\n",i,d[i],f[i]);
 }
  
  return 0;
}

void dfs(void){// int G
//for each vertex u in V
  int i;
  int u;
  
   for(u=1;u<=n;u++){
  color[u] = WHITE;
   }
   
   t =0;
    for(u=1;u<=n;u++){
 if(color[u] == WHITE)
   visit(u);
    }
}

void visit(int u){
  int i;
  int v;
  color[u] = GRAY;
   d[u] = ++t;
 //for each v in Adj[u]
   
   for(v=1;v<=n;v++){
 if(color[v] == WHITE && D[u][v] == BLACK) visit(v);
   }
color[u] = BLACK;
 f[u] = ++t; //visit終了
}





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

#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))

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

template <class T> inline T biton(T n, T pos) { return n | ((T)1 << pos); }
template <class T> inline T bitoff(T n, T pos) { return n & ~((T)1 << pos); }
template <class T> inline T ison(T n, T pos) { return (bool)(n & ((T)1 << pos)); }
template <class T> inline T gcd(T a, T b) { while (b) { a = a%b; swap(a, b); } return a; }
template <class T> inline T bigmod(T p, T e, T m) { T ret = 1; for (; e > 0; e >>= 1) { if (e & 1) ret = (ret * p) % m; p = (p * p) % m; } return (T)ret; }



void solve() {
	long long n, m;
	cin >> n >> m;

	long long lm = 0;
	long long rmx = 0;

	for (int i = 1; i <= m; i++) {
		long long l, r;
		cin >> l >> r;

		if (lm == 0) {
			lm = l;
			rmx = r;
		}
		else {
			lm = max(lm, l);
			rmx = min(r, rmx);
		}
	}

	long long res = min(n, (rmx - lm + 1));

	cout <<max(0ll,res) << endl;
}

int main()
{

	ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(10); cout.tie(nullptr); cin.tie(nullptr);

	int t = 1;
	while (t--) {

		solve();
	}


	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define EB(x) emplace_back(x)
#define DEBUG(x) cout << (#x) << ": " << (x) << endl
#define DEBUG_VEC(v)            \
    cerr << #v << ": ";         \
    REP(__i, (v).size())        \
    cerr << ((v)[__i]) << ", "; \
    cerr << endl

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

vi xs;

int main()
{
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    xs.resize(N + 2);
    REP(i, M)
    {
        int l, r;
        cin >> l >> r;
        xs[l] += 1;
        xs[r + 1] -= 1;
    }
    partial_sum(xs.begin(), xs.end(), xs.begin());

    int res = 0;
    for (auto &x : xs)
        if (x == M)
            res++;

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N;
    N = 1000 - N % 1000;
    if (N == 1000)
        N = 0;
    cout << N << endl;
}

Measured memory_bytes: 3632
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    a[i]-=(i+1)
median=-1
a.sort()
if n%2==0:
    median=(a[n//2]+a[n//2-1])//2
else:
    median=a[n//2]
def comp(x):
    su=0
    for i in a:
        su+=abs(i-x)
    return su
print(min(comp(median),comp(median+1)))





Measured memory_bytes: 25200
# Problem C - Average Length

from itertools import permutations
import math

# input
N = int(input())
point_list = []
for i in range(N):
    x, y = map(int, input().split())
    point_list.append([x, y])

# initialization
pattern_list = []
moto = [i for i in range(1, N+1)]
distance = 0
patterns = list(permutations(moto))

# count
for p in patterns:
    for i in range(len(p)-1):
        point_1 = point_list[p[i]-1]
        point_2 = point_list[p[i+1]-1]
        tmp = math.sqrt((point_1[0]-point_2[0])**2 + (point_1[1]-point_2[1])**2)
        distance += tmp
distance = distance / len(patterns)

# output
print(distance)


Measured memory_bytes: 46572
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    std::string s;
    std::cin >> s;
    std::cout << "ABC" + s << std::endl;
    return 0;
}

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

int main(void){
    // Your code here!
    char enki;
    cin >> enki;
    
    if (enki == 'A'){
        cout << 'T' << endl;
    } else if(enki == 'T'){
        cout << 'A' << endl;
    } else if(enki == 'G'){
        cout << 'C' << endl;
    } else{
        cout << 'G' << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
using namespace std;
void solve(){
    string s;
    int l, r, ans = 0, n;
    cin >> n >> s;
    l = 0;
    r = n - 1;
    while(l < r){
        while(s[l] == 'R' && l < r)l++;
        while(s[r] == 'W' && l < r)r--;
        if(l < r && s[l] == 'W' && s[r] == 'R'){
            ans++;
            swap(s[l], s[r]);
            l++;
            r--;
        }
    }
    cout << ans << endl;
}
main(){
    ios_base::sync_with_stdio(0);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 3780
#include<iostream>
using namespace std;
int main()
{
	int sya=100000;
	int i;
	int n,a;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		sya *= 1.05;
		if (sya % 1000 > 0)
		{
			a = sya % 1000;
			sya = sya - a + 1000;
		}
	}
	cout << sya << endl;
	return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 998244353
#define pb push_back
ll dp[1001][9001];
ll vec[1001];
ll cost[1001];
ll n,m;
ll total;

ll solve(int idx , int temp) {
    if(idx == m) {
        if(temp == total) return 0;
        return INT_MAX-2;
    }

    if(dp[idx][temp]!=-1) return dp[idx][temp];

    ll a = solve(idx+1,temp | vec[idx]) + cost[idx];
    ll b = solve(idx+1,temp);

    int ans = min(a,b);
    dp[idx][temp] = ans;

    return ans;
}

int main() {

    int t = 1;
    //cin>>t;
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    while(t--) {

        cin>>n>>m;

        for(int i=0;i<n;i++) total |= (1<<i);

        memset(dp,-1,sizeof(dp));

        int s,x;

        for(int i=0;i<m;i++) {
            cin>>cost[i]>>s;
            for(int j=0;j<s;j++) cin>>x,vec[i] |= (1<<(x-1));
        }


        ll ans = solve(0,0);
        if(ans == INT_MAX-2) ans = -1;
        cout<<ans<<"\n";
    }

}




Measured memory_bytes: 70656
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define int                 long long
#define FF(i,a,b)           for(int i=a;i<b;i++)
#define BF(i,a,b)           for(int i=a;i>=b;i--)
#define vi                  vector<int>
#define MAP                 map<int,int>
#define pb                  push_back
#define MP                  make_pair
#define F                   first
#define S                   second
#define pi                  pair<int,int>
#define all(v)              v.begin(),v.end()
#define PIE                 3.1415926535897932384626433832795
#define FastIO              ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
//#define ordered_set         tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
/*

    order_of_key (k) : Number of items strictly smaller than k .
    find_by_order(k) : K-th element in a set (counting from zero).

*/
/**************************************************************************************/
                       /*Global Variables*/
const int mod = 1e9+7;
const int N = 2e5+10;
const int inf = 3e18;

/**************************************************************************************/
template <typename A>istream& operator>>(istream& input,vector<A>& x) {for(auto& i:x)input>>i;return input;}
template<typename A>ostream& operator<<(ostream& output,vector<A>& x) {for(auto& i:x)output<<i<<' ';return output;}
int add(int a, int b){return (a%mod + b%mod + mod)%mod;}
int sub(int a, int b){return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b){return ((a%mod)*(b%mod) + mod)%mod;}
int Power(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b&1)res*=a;
        a*=a;
        b>>=1;
    }
    return res;
}
int dp[101][(int)2e5+1];
signed main()
{
    FastIO;
    int T=1;
    //cin>>T;
    while(T--)
    {
        int n,w;
        cin>>n>>w;
        vi wt(n),val(n);
        FF(i,0,n)
        {
            cin>>wt[i]>>val[i];
        }
        FF(i,1,n+1)
        {
            FF(j,1,w+1)
            {
                if(wt[i-1]<=j)
                {
                    dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
                }
                else
                {
                    dp[i][j]=dp[i-1][j];
                }
            }
        }
        cout<<dp[n][w]<<"\n";
        
        
    }

}
/*
|| Do what you can with all you have,wherever you are. ||

|| Knowing is not enough, we must apply. Wishing is not enough, we must do. ||

|| A goal is a dream with deadline. ||

|| Whether you think you can or you think you can't, you're right. ||

|| A year from now you may wish you had started today ||
*/



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

int main() {

    int N;
    cin >> N;

    vector<ll> A(2e5);
    vector<ll> B(2e5);
    vector<ll> C(2e5);
    bool zero = false;
    rep(i, N) {
        cin >> A[i];
        if (A[i] == 0) zero = true;
        B[i] = A[i] / 1000000000;
        C[i] = A[i] % 1000000000;
    }

    if (zero) {
        cout << 0 << endl;
        return 0;
    }

    ll a = 0;
    ll b = 0;
    ll c = 1;
    rep(i, N) {
        a = b*B[i];
        b = b*C[i] + c*B[i];
        c = c*C[i];
        b += (c / 1000000000);
        c %= 1000000000;
        a += (b / 1000000000);
        b %= 1000000000;
        if (a > 0) {
            if (b > 0 || c > 0) {
                cout << -1 << endl;
                return 0;
            }
        }
    }

    if (a > 0) {
        cout << 1000000000000000000 << endl;
    }
    else if (b > 0) {
        cout << b;
        cout << setfill('0') << right << setw(9) << c;
        cout << endl;
    }
    else {
        cout << c;
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 8012
import numpy as np


def solve(H, A, B):
    A_max = A.max()
    dp = np.zeros(H + A_max + 1, dtype=np.int64)
    for i in range(A_max + 1, H + A_max + 1):
        dp[i] = np.min(dp[i - A] + B)
    return dp[-1]


H, N, *AB = map(int, open(0).read().split())
A = np.array(AB[::2], dtype=np.int64)
B = np.array(AB[1::2], dtype=np.int64)
print(solve(H, A, B))


Measured memory_bytes: 27364
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
const double eps=1e-6;
const int inf=1e9;
const int mod=1e9+7;
const int maxn=5e5+10;
int n;
int a[55],x;
ll dp[55][55][2510];
int main(){
    ios::sync_with_stdio(false);
    //cout<<(1ll<<26)<<endl;
    cin>>n>>x;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    dp[0][0][0]=1;
    for(int i=1;i<=n;i++){
    	for(int j=0;j<=n;j++){
    		for(int k=0;k<=n*x;k++){
    			dp[i][j][k]+=dp[i-1][j][k];
    			if(k>=a[i]&&j>=1) dp[i][j][k]+=dp[i-1][j-1][k-a[i]];
    		}
    	}
    }
    ll ans=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=n*x;j++){
			if(j/i==x&&j%i==0){
				ans+=dp[n][i][j];
			}
		}
	}
    cout<<ans<<endl;
    return 0;
}
//x+y-a*c1==a*c2;
//y=a*(cnt+j)-ret;
//a*(cnt+j)>=ret/a-cnt
//cnt+j<n-cnt
//x+y=k*a

Measured memory_bytes: 54528
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

int main(){
	ll n,m,ans=0;
	cin>>n>>m;
	m/=2;
	if(n>=m)ans+=m;
	else{
		m-=n;
		ans+=(n+m/2);
	}
	cout<<ans<<endl;
	
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, int b, int _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;

  int cnt = 0;
  rep(i, sz(s)) {
    if (s.substr(i, 3) == "ABC") cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define mp make_pair
 
const int MOD = 1000000007;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   
    int n;
    cin>>n;
    int a[3][n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[0][i]>>a[1][i]>>a[2][i];
    }

    int dp[n+1][3];
    dp[1][0]=a[0][1];
    dp[1][1]=a[1][1];
    dp[1][2]=a[2][1];

    for(int i=2;i<=n;i++)
    {
        for(int j=0;j<3;j++)
        {
            dp[i][j]=0;
            for(int k=0;k<3;k++)
            {
                if(j==k)
                    continue;
                dp[i][j]=max(dp[i-1][k]+a[j][i],dp[i][j]);
            }
        }
    }

    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));

    return 0;
} 

Measured memory_bytes: 4992
i = 0
while True:
    
    n = int(input())
    if n == 0:
        break

    x = 0
    b = -1
    c = 1001
    for i in range(n):
        a = int(input())
        x += a
        b = max(b, a)
        c = min(a, c)
        y = (x-b-c)//(n-2)
        
    i += 1

    print(y)


Measured memory_bytes: 5596
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
    int r, D;    
    long long x;
    cin >> r >> D >> x;
    for(int i=1; i<=10; i++){
        x = r*x - D;
        cout << x << '\n';
    }
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<stdlib.h>

typedef struct node{
  int key, priority;
  struct node *left;
  struct node *right;
}node;


node * Delete(node **,int);
node * _delete(node **,int);

int find(node *p,int x){

  while(p != NULL){
    if(p->key == x) return 1;
    else if(p->key > x) p = p->left;
    else p = p->right;
  }
	
  return 0;
	
}

void inorder(node *p){

  if(p->left != NULL) inorder(p->left);
	
  printf(" %d", p->key);
	
  if(p->right != NULL) inorder(p->right);
	 
  return;
	
}

void preorder(node *p){
	
  printf(" %d", p->key);
	
  if(p->left != NULL) preorder(p->left);
	
  if(p->right != NULL) preorder(p->right);
	
  return;
	
}

void print(node *p){

  inorder(p);
  printf("\n");
	
  preorder(p);
  printf("\n");
	
  return;
	
}

node * makenode(int x,int y){
  node *new = malloc(sizeof(node));
  new->key = x;
  new->priority = y;
  new->left = NULL;
  new->right = NULL;
  return new;
}

node *rightRotate(node *p){
  node *q = p->left;
  p->left = q->right;
  q->right = p;
  return q;
}

node *leftRotate(node *p){
  node *q = p->right;
  p->right = q->left;
  q->left = p;
  return q;
}


node* insert(node **t, int key, int priority){
  node *new;
	
  if((*t) == NULL)
    return new = makenode(key,priority);
  if ((*t)->key == key)
    return *t;
	
  if(key < (*t)->key){
    (*t)->left = insert(&(*t)->left, key, priority);
    if((*t)->priority < (*t)->left->priority)
      (*t) = rightRotate((*t));
  }
  else {
    (*t)->right = insert(&(*t)->right, key, priority);
    if((*t)->priority < (*t)->right->priority)
      (*t) = leftRotate((*t));
  }
	
  return *t;
}


node * Delete(node **t, int key){
  if((*t) == NULL)
    return NULL;
		
  if(key < (*t)->key)
    (*t)->left = Delete(&((*t)->left),key);
		
  else if(key > (*t)->key)
    (*t)->right = Delete(&((*t)->right),key);
		
  else return _delete(t,key);
	
  return *t;
}

node * _delete(node **t,int key){
  if((*t)->left == NULL && (*t)->right == NULL)
    return NULL;
  else if((*t)->left == NULL)
    (*t) = leftRotate(*t);
  else if((*t)->right == NULL)
    (*t) = rightRotate(*t);
  else {
    if((*t)->left->priority > (*t)->right->priority)
      (*t) = rightRotate(*t);
    else
      (*t) = leftRotate(*t);
  }
  return Delete(t,key);
}


int main(){
  int i, n, x, y;
  char com[8];
  node *root = NULL;
	
  scanf("%d", &n);
	
  for(i = 0 ; i < n ; i++){
    scanf("%s", com);
		
    switch(com[0]){
		
    case 'i':scanf("%d %d", &x, &y);
      root = insert(&root, x, y);
      break;
			
    case 'd':scanf("%d", &x);
      root = Delete(&root, x);
      break;
			
			
    case 'f':scanf("%d", &x);
      if(find(root,x)) printf("yes\n");
      else printf("no\n");
      break;

    case 'p':print(root);
      break;
    }	
  }
	
  return 0;	
}


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

int a[5][5][15], n, b, f, r, v, _;

main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> b >> f >> r >> v;
		a[b][f][r] += v;
	}
	for (int i = 1; i < 5; i++) {
		if (i - 1) cout << "####################" << endl;
		for (int j = 1; j < 4; j++) {
			for (int k = 1; k < 11; k++) {
				cout << " " << a[i][j][k];
			}
			cout << endl;
		}
	}
}



Measured memory_bytes: 3088
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define x first
#define y second

template<typename T0,typename T1>inline void check_min(T0 a,T1 &b){if(a<b)b=a;}
template<typename T0,typename T1>inline void check_max(T0 a,T1 &b){if(a>b)b=a;}

typedef long long ll;
typedef std::pair<ll,ll> pii;

const int N=201000,M=2010000;

int n;

namespace naoyuguo_chu_nan_ti_chao_feng_wo
{
	inline int dis(int x,int y){return std::abs(x)+std::abs(y);}

	bool initialize()
	{
		scanf("%d",&n);
		ll ti,x,y,lx=0,ly=0,lt=0;

		for(int i=1,d,e;i<=n;i++)
		{
			scanf("%lld%lld%lld",&ti,&x,&y);
			d=ti-lt,e=dis(x-lx,y-ly);

			if(d<e)return 0;
			if((d-e)&1)return 0;
			lt=ti,lx=x,ly=y;
		}
		return 1;
	}
	void solve()
	{
		if(!initialize())printf("No\n");
		else printf("Yes\n");

	}
}

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


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

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;

  int ans = 1e9;

  for (int i = 0; i <= 100000; i++) {
    ans = min(ans, i * C * 2 + max(0, X - i) * A + max(0, Y - i) * B);
  }

  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N;
    cin >> N;
    ll ans = 1;
    vector<ll> A(N);
    Rep (i, N) {
        cin >> A[i];
    }

    sort(A.begin(), A.end());
    if (A[0] == 0) {
        cout << 0 << "\n";
        return 0;
    }
    Rep (i, N) {
        if (ans > 1000000000000000000 / A[i]) {
            cout << -1 << "\n";
            return 0;
        }
        ans *= A[i];
    }

    if (ans > 1000000000000000000) {
        cout << -1 << "\n";
        return 0;
    }

    cout << (ll)ans << endl;
}

Measured memory_bytes: 3988
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict

# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial
# from pprint import pprint

INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)

# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))

N, M = [int(x) for x in input().split()]
AB = []
for _ in range(M):
    a, b = [int(x) for x in input().split()]
    AB.append((a - 1, b - 2))

AB.sort(key=lambda x: (-x[0], x[1]))

cnt = 0
i = 0
while i < len(AB):
    cut = AB[i][0]
    while i < len(AB) and AB[i][1] >= cut:
        i += 1
    cnt += 1

print(cnt)


Measured memory_bytes: 28404
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int n,ans=1;
    long a[100000],sum[100000];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%ld",&a[i]);
    }
    sort(a,a+n);
    sum[0]=a[0];
    for(int i=1;i<n;i++){
        sum[i]=sum[i-1]+a[i];
    }
    for(int i=n-1;i>=1;i--){
        if(sum[i-1]*2<a[i]){
            break;
        }
        ans++;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 1664
#include <cstdio>

using namespace std;

char s[100001];
char t[100001];
int a[100000];

int main() {
    int n, i, j, k;
    
    scanf("%d", &n);
    scanf("%s", s);
    
    for (i = 0; i < 2; i++) {
        for (j = 0; j < 2; j++) {
            if (i == 0) {
                a[0] = 0;
            } else {
                a[0] = 1;
            }
            
            if (j == 0) {
                a[1] = 0;
            } else {
                a[1] = 1;
            }
            
            for (k = 2; k < n; k++) {
                if (s[k - 1] == 'o') {
                    if (a[k - 1] == 0) {
                        a[k] = a[k - 2];
                    } else {
                        a[k] = 1 - a[k - 2];
                    }
                } else {
                    if (a[k - 1] == 0) {
                        a[k] = 1 - a[k - 2];
                    } else {
                        a[k] = a[k - 2];
                    }
                }
            }
            
            if (s[n - 1] == 'o') {
                if (a[n - 1] == 0) {
                    if (a[n - 2] != a[0]) continue;
                } else {
                    if (a[n - 2] == a[0]) continue;
                }
            } else {
                if (a[n - 1] == 0) {
                    if (a[n - 2] == a[0]) continue;
                } else {
                    if (a[n - 2] != a[0]) continue;
                }
            }
            
            if (s[0] == 'o') {
                if (a[0] == 0) {
                    if (a[n - 1] != a[1]) continue;
                } else {
                    if (a[n - 1] == a[1]) continue;
                }
            } else {
                if (a[0] == 0) {
                    if (a[n - 1] == a[1]) continue;
                } else {
                    if (a[n - 1] != a[1]) continue;
                }
            }
            
            for (k = 0; k < n; k++) {
                if (a[k] == 0) {
                    t[k] = 'S';
                } else {
                    t[k] = 'W';
                }
            }
            
            printf("%s\n", t);
            
            return 0;
        }
    }
    
    puts("-1");
    
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
using namespace std;
int main(void){
int a,l,o;
cin>>a>>l>>o;
if((a==0&&l==0&&o==0)||(a==1&&l==0&&o==0)||(a==0&&l==1&&o==0)){
  cout<<"Close"<<endl;  
}
if((a==1&&l==1&&o==0)||(a==0&&l==0&&o==1)){
  cout<<"Open"<<endl;  
}


}



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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (int)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

vll binary_convert(ll n){
    vll s;
    ll size = 0;

    while(n / (ll)(pow(2,size)) > 0)size++;
    rep(i,size + 1){
        s.pb(n / (ll)(pow(2,i)));
        n %= (ll)(pow(2,i));
    }

    return s;
}

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

    ll ans = 0;
    rep(i,n){
        if(a[i] != b[i] && a[i] != c[i] && b[i] != c[i])ans += 2;
        else if((a[i] != b[i] && a[i] == c[i]) || (a[i] != c[i] && a[i] == b[i]) || (b[i] == c[i] && b[i] != a[i]))ans++;
    }

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

Measured memory_bytes: 256
///============================================================================
/// Name        : Faisal.cpp
/// Author      : Faisal Ahmed
/// Version     :
/// Copyright   : Your copyright notice
/// Description : C++, Ansi-style
///============================================================================

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

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

	int a, p;

	cin >> a >> p;

	int d = a * 3 + p;
	d /= 2;

	cout << d << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

void trace(int *a, int N){
	int i;
	for(i=0; i<N-1; i++){
		std::printf("%d ", a[i]);
	}
	std::printf("%d\n", a[N-1]);
}

void bubbleSort(int *a, int N){
	int i,j,minj,x,count;
	count = 0;
	for (i=0;i<N; i++){
		minj = i;
		for (j=i; j<N; j++){
			if (a[minj] > a[j]){
				minj = j;
			}
		}
		if (i!=minj){
			x = a[i];
			a[i] = a[minj];
			a[minj] = x;
			count ++;
		}
	}
	trace(a, N);
	std::printf("%d\n", count);
}

int main(){
	int N,i;
	int *a;
	std::scanf("%d", &N);
	a = new int[N];
	for (i=0; i<N; i++){
		std::scanf("%d", &a[i]);
	}
	bubbleSort(a, N);
	return 0;
}

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

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

#define REP(i, n) for(int i = 0; i<n; i++)
#define REPR(i, n) for(int i = n; n>=0; i--)
#define FOR(i, m, n) for(int i = m, i < n; i++)

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    /*example standard input and output(cout << "\n")
	int x;
	cin >> x;
	cout << x * x * x << "\n";
    */

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


   printf("%d", (a-1)*(b-1));


    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >=0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
 
typedef long long ll;
#define INF 1e9
 
 
int main(){
   string s, s2;
   cin >> s;
   s2 = s;
   int cnt = 0, ans = 1e9;
   bool flag = true;
   REP(i, s.length()){
      s2 = s;
      cnt = 0;
      REPR(j, s2.length()-1){
         flag = true;
         REP(k, j){
            if(s2[k+1] == s[i]){
               s2[k] = s[i];
            }
            if(s2[k] != s[i]){
               flag = false;
            }
         }
         cnt++;
         if(flag){
            break;
         }
      }
      ans = min(cnt, ans);
   }
   char pre = s[0];
   REP(i, s.length()){
      if(pre != s[i]){
         cout << ans << endl;
         return 0;
      }
   }
   cout << 0 << endl;
   return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
board = []
for _ in range(H):
    board.append(input())

def count(x, y):
    result = 0
    for my in range(-1, 2):
        for mx in range(-1, 2):
            tx = x + mx
            ty = y + my
            if 0 <= tx < W and 0 <= ty < H:
                if board[ty][tx] == "#":
                    result += 1

    return result

output = []

for y, b in enumerate(board):
    line = ""
    for x, c in enumerate(b):
        if c == ".":
            num = count(x, y)
            line += str(num)
        else:
            line += c
    output.append(line)

for o in output:
    print(o)

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		long n = Long.parseLong(br.readLine());
		long total = 0;
		for (int i = 1; i <= Math.sqrt(n); i++) {
		    if (n % i == 0) {
		        long m = n / i - 1;
		        if (m > i) {
		            total += m;
		        }
		    }
		}
		System.out.println(total);
    }
}



Measured memory_bytes: 21588
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("avx")

// timus 219263UI
//    (><)

#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <ctime>
#include <queue>
#include <vector>
#include <sstream>
#include <iomanip>
#include <cstdlib>
#include <stdio.h>
#include <assert.h>  
#include <string.h>
#include <algorithm>
#include <unordered_map>

using namespace std;

typedef long long ll;

#define y1 needtrainharder
#define f first
#define s second
#define gg exit(0)
#define sz() size()
#define pb emplace_back
#define mp make_pair
#define skip continue
#define all(x) x.begin(), x.end()
#define alln(x, y) x, x + y
#define boost ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define file(s) if(fopen(task".in", "r"))freopen(s".in","r",stdin),freopen(s".out","w",stdout);
#define task "sorting"

const int inf = 1e9 + 5;  
const ll infll = 1e18 + 5ll;  
const long double eps = 1e-15;
const int maxn = 1e5 + 100;
const int maxlog = 21;
const int P = 97;
const int mod = 1e9 + 7;

int n, a[maxn], ans;

int main(){
  boost; 
  // srand(time(NULL));
  file(task);  

  cin >> n;
  n <<= 1;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  sort(alln(a + 1, n));
  for (int i = 2; i <= n; i += 2) {
    ans += min(a[i - 1], a[i]);
  }
  cout << ans;
  return 0; 
}
/*




*/

Measured memory_bytes: 256