akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
ll mod=1e9+7;
#define PI acos(-1)

int main(){
    int n,m;
    cin>>n>>m;
    int ans[n];
    int s[m], c[m];
    int flag[n]={};
    for(int i=0;i<n;i++) ans[i]=0;
    rep(i,m) {
        cin>>s[i]>>c[i];
    }
    rep(i,m){
        if(flag[s[i]-1]==0){
            ans[s[i]-1]=c[i];
            flag[s[i]-1]++;
        }
        else{
            if(ans[s[i]-1]==c[i]){
                ans[s[i]-1]=c[i];
                flag[s[i]-1]++;
            }
            else{
                cout<<-1<<endl;
                return 0;
            }
        }
    }
    if(n==1){
        cout<<ans[0]<<endl;
    }
    else if (n>1){
        if(ans[0]==0 && flag[0]!=0){
            cout<<-1<<endl;
            return 0;
        }
        if(ans[0]==0){
            ans[0]=1;
        }
        for(int i=0;i<n;i++){
            cout<<ans[i];
        }
        cout<<endl;
    }
    return 0;

}

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

int main(){
        int x1,x2,x3,x4;
        int y1,y2,y3,y4;


        cin >> x1>>y1>>x2>>y2;

        x3=x2-(y2-y1);
        y3=y2+(x2-x1);

        x4=x3-(x2-x1);
        y4=y3-(y2-y1);

        cout <<x3<<" "<<y3<<" "<<x4<<" "<<y4;


        return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int isATCG(char a)
{
	if(a=='A'||a=='T'||a=='C'||a=='G')
		return 1;
	else
		return 0;
}

int main()
{
	char n[100];
	gets(n);
	int x=0,y=0;
	int i;
	for(i=0;i<strlen(n);i++)
	{
		if(isATCG(n[i]))
		   {
			   int k;
			   for(k=i;;k++)
				   if(isATCG(n[k])==0)
					   break;
				y=k-i;
				if(y>x)
					x=y;
		   }
	}
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define F first
#define S second
#define REP(i, a, b, c) for(int i = a; i <= b; i+=c)
#define pb push_back
#define int long long int
#define MOD 1000000007
using namespace std;

/*class Graph {

  map<int, list<pair<int, int> > > l;

public:
  void addEdge(int x, int y, int cost) {
    l[x].pb(make_pair(y, cost));
    l[y].pb(make_pair(x, cost));
  }

  int dfs_helper(int n, int node, map<int, int> &vis, map<int, int> &count, int &ans) {
    //cout << node << " " ;
    vis[node] = 1;
    count[node] = 1;
    for (auto m : l[node]) {
      if (!vis[m.F]) {
        vis[m.F] = 1;
        count[node] += dfs_helper(m.F, vis, count, ans);
        ans += 2 * min(count[node], n - count[node]) * m.S.S;
      }
    }
    return count[node];
  }

  void dfs() {
    map<int, int> vis;
    map<int, int> count;
    int ans = 0;
    dfs_helper(0, vis, count, ans);
    cout << ans << endl;
  }

};*/

int dp[105][100005];

/*int solve(int wt[], int v[], int n, int w)
{
  if (n == 0 || w == 0)
    return 0;
  if (dp[n][w] != -1)
    return dp[n][w];
  int op1, op2;
  op1 = op2 = INT_MIN;
  if (w - wt[n] >= 0)
    op1 = v[n] + solve(wt, v, n - 1, w - wt[n]);
  op2 = solve(wt, v, n - 1, w);

  return dp[n][w] = max(op1, op2);
}*/

int solve(int wt[], int v[], int n, int w)
{
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++)
  {
    for (int j = 1; j <= w; j++)
    {
      int op1, op2;
      op1 = op2 = INT_MIN;
      if (j - wt[i] >= 0)
      {
        op1 = v[i] + dp[i - 1][j - wt[i]];
      }
      op2 = dp[i - 1][j];
      dp[i][j] = max(op1, op2);
    }
  }
  return dp[n][w];
}
int32_t main()
{
  ios :: sync_with_stdio(false); cin.tie(0);
  int t = 1;
  //cin >> t;
  for (int i9 = 1; i9 <= t; i9++)
  {
    /* Graph G;
     int n, x, y, cost;
     cin >> n;
     while (n--) {
       cin >> x >> y >> cost;
       G.addEdge(x, y, cost);
     }
     G.dfs();*/
    //freopen("ouputnew.txt", "w", stdout);
    //flclose(stdout);
    int N, W;
    cin >> N >> W;
    int wt[N + 5];
    int v[N + 5];
    for (int i = 1; i <= N; i++)
      cin >> wt[i] >> v[i];
    memset(dp, -1, sizeof(dp));
    cout << solve(wt, v, N, W);
  }
}



Measured memory_bytes: 85692
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long t = sc.nextInt();
        long n = sc.nextInt();
        long h = sc.nextInt();
        long k = sc.nextLong();
        if (k % 2 == 0) System.out.println(t - n);
        else System.out.println(n - t);

    }
}


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

int main(){
    
    int ans = 1145141919;
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int>A(N + 1, 0);
    for(int i=0; i<N; i++)cin >> A[i];
    for(int i=0; i<N; i++){
        vector<int>tmp, tmp2;
        for(int j=0; j<=N;j++){
            if(A[j] < A[i]){
                if(tmp2.size() >= K){
                    sort(tmp2.begin(), tmp2.end());
                    for(int k=0; k+K-1<tmp2.size(); k++){
                        tmp.push_back(tmp2[k]);
                    }
                }
                tmp2.clear();
            }
            else tmp2.push_back(A[j]);
        }
        if(tmp.size()<Q)continue;
        sort(tmp.begin(), tmp.end());
        ans = min(ans, abs(tmp[Q-1] - tmp[0]));
    }
    cout << ans << endl;
    return 0;
}


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

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


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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; }



int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;

    vector<bool> dp(1e6+10, true);
    int ans = 0;
    set<int> st;
    set<int> bl;
    for(int i = 0; i < n; i++) {
        int a; cin >> a;
        if(st.count(a) == 0) st.insert(a);
        else bl.insert(a);
    }

    for(int a : st){
        if(dp[a]){
            if(bl.count(a) == 0) ans++;
            int tmp = a;
            while(tmp < 1e6+10){
                dp[tmp] = false;
                tmp+=a;
            }
        } 
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 13036
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define mod 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifndef ONLINE_JUDGE    
    freopen("input.txt", "r", stdin);     
    freopen("output.txt", "w", stdout);
#endif
string s;
string t;
cin>>s>>t;
int n = s.size();int m = t.size();
int dp[n+5][m+5];
memset(dp,0,sizeof(dp));
// initialisation



for(int i = 1;i<=n;i++){
	for(int j = 1;j<=m;j++){
		if(s[i-1]==t[j-1])
			dp[i][j] = 1 + dp[i-1][j-1];
		else
			dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
	}
}
// priniting
string ans = "";
int i = n;int j = m;
while(i>0 && j>0){
		if(s[i-1] == t[j-1]){
			ans = s[i-1]+ans;
			i--;
			j--;
		}
		else{
			if(dp[i-1][j]>dp[i][j-1])
				i--;
			else{
				j--;
			}

		}
	}
cout<<ans;









#ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#endif

return 0;
}

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

const int maxn = 2e5 + 100;

const long long inf = 1e9;
struct line
{
    long long a,b;
    line()
    {
        a = -0;
        b = -0;
    }
    line(long long a, long long b) : a(a), b(b){}
    long long get(long long x)
    {
        return a*x + b;
    }
};

struct lichao_tree
{
    struct node
    {
        node *l, *r;
        line x;
        node(line x) : x(x)
        {
            l = r = NULL;
        }
    };

    vector<line>vl;
    int sz = 0;
    node * root;
    void update(node *&v, long long l, long long r, line x)
    {
        if(v == nullptr)
        {
            v = new node(x);
            return;
        }
        long long mid = (l+r) >> 1;
        bool m = bool(x.get(mid) < v->x.get(mid));
        bool le = bool(x.get(l) < v->x.get(l));

        if(m)
            swap(x, v->x);
        if(l == r)
            return;
        if(m != le)
            update(v->l,l,mid,x);
        else
            update(v->r,mid+1,r,x);
    }
    long long query(node *&v, long long k, long long l , long long r)
    {
        if(v == nullptr)
            return 1e18;
        if(l == r)
            return v->x.get(l);
        
        long long mid = (l+r) >> 1;

        if(k <= mid)
            return min(v->x.get(k), query(v->l,k,l,mid));
        else
            return min(v->x.get(k), query(v->r,k,mid+1,r));
    }
    long long query(long long p) 
    {
        return query(root,p,-inf,inf);
    }

    void update(line x)
    {
        sz++;
        vl.push_back(x);
        update(root,-inf,inf,x);
    }
    
    void clear() 
    {
        root = nullptr;
    }
};

long long h[maxn];
long long dp[maxn];

int main()
{
    lichao_tree l;
    l.clear();
    int n;
    long long c;
    scanf("%d %lld",&n,&c);
    for(int i = 0; i < n ; i++)
        scanf("%lld",&h[i]);
    //l.update(line(0,0));
    dp[0] = 0;
    l.update(line(-2*h[0], dp[0] + h[0]*h[0]));
    for(int i = 1; i < n ; i++)
    {
        dp[i] = l.query(h[i]) + c + (h[i] * h[i]);
        l.update(line(-2*h[i], dp[i] + h[i] * h[i]));
    }
    printf("%lld\n",dp[n-1]);
    return 0;
}

Measured memory_bytes: 16748
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.tie(0);
    ll n;
    cin>>n;
    rep3(i,1,n){
        rep3(j,i+1,n+1){
            ll temp=abs(i-j);
            ll cnt=0;
            while(temp%2==0){
                cnt++;
                temp/=2;
            }
            cout<<cnt+1<<" ";
        }
        cout<<endl;
    }
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 2002;
const int mo = 1e9 + 7;

int n, blue, red, c[maxn][maxn];

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> blue;
	red = n - blue;

	int lim = min(blue, red + 1), maxv = max(blue - 1, red + 1);

	for (int i = 0; i <= maxv; ++i) {
		c[i][0] = c[i][i] = 1;
		for (int j = 1; j < i && j <= lim; ++j) {
			c[i][j] = (c[i-1][j] + c[i-1][j-1]) % mo;
		}
	}

	for (int i = 1; i <= lim; ++i) {
		long long cur = (long long)c[red+1][i] * c[blue-1][i-1] % mo;
		cout << cur << endl;
	}

	for (int i = lim+1; i <= blue; ++i)
		cout << 0 << endl;
	

	return 0;
}

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

const double p=3.14159265359;

int main(){
  double a,b,h,m;
  cin >> a >> b >> h >> m;
  double tyo=(double)m*6.0;
  double tansin=((double)h*60.0+(double)m)*360.0/(12.0*60.0);
  double kaku=abs((double)tyo-(double)tansin);
  if(kaku>180){
    kaku=kaku-180;
    kaku=180-kaku;
  }
  double ans=a*a+b*b-2*(a*b*cos(kaku*(p/180.0)));
  ans=sqrt(ans);
  printf("%.10lf\n",ans);
  //cout << kaku << endl;
  //printf("%lf\n",cos(kaku*(p/180)));
  return 0;
}


Measured memory_bytes: 4216
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var n int
	fmt.Scan(&n)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	b := make([]int, n)
	for i := range b {
		sc.Scan()
		b[i], _ = strconv.Atoi(sc.Text())
		b[i] -= i + 1
	}

	sort.Ints(b)
	m := b[n/2]

	ans := 0
	for _, v := range b {
		ans += abs(v - m)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5120
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <functional>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
using namespace std;
// #define int long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = (((1<<30)-1)<<1)+1;
const int nINF = 1<<31;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;

/////////////////////////////////////////////////////////////////////

typedef uint16_t bitmask;

const int N = 20, K = 1 << 16;
int n, a[N][N];
ll dp[K], score[K];

ll rec(bitmask cur) {
	ll& memo = dp[cur];
	if(memo != -1) return memo;
	// DEBUG(cur);
	ll res = 0;
	for(bitmask i = cur; i; i = (i-1) & cur) {
		res = max(res, score[i] + rec(cur & ~i));
	}
	return memo = res;
}

signed main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    memset(dp, -1, sizeof(dp));
    cin >> n;
    REP(i, n) REP(j, n) cin >> a[i][j];
    int tot = 1 << n;
    REP(i, tot) {
    	vector<int> have;
		REP(j, n) if(i & (1 << j)) have.push_back(j);
		REP(j, have.size()) FOR(k, j+1, have.size()-1) score[i] += a[have[j]][have[k]];
    }
    // REP(i, tot) cout << score[i] << endl;
    cout << rec(tot - 1) << endl;

    return 0;
}

// Easy things to check:
// - LONG LONGS (WA)
// - const int N is correct (WA, RTE)
// - .size()-k underflow (WA, RTE, TLE)
// - small n edge cases (WA)

// Rare mistakes made in the past:
// - division by 0 (WA)
// - integer division (WA)
// - setprecision (WA)
// - INF not big enough using ll (WA)
// - setting min to 0 instead of -INF (WA)
// - outputting debug (WA)
// - allocating too much memory (locRTE, MLE)
// - stack size (locRTE)


Measured memory_bytes: 1280
#include<stdio.h>

int main(){

	int m[100];
	int f[100];
	int r[100];
	int a[100];
	int b[100];
	int j=0;
	int i=0;
	int ans[100];

	while(1){
		scanf("%d %d %d", &m[i], &f[i], &r[i]);
		if (m[i] == -1 && f[i] == -1 && r[i] == -1)break;
		i++;
	}
	while (1){
		if (m[j] == -1 && f[j] == -1)break;
		
		ans[j] = m[j] + f[j];
		
		if (m[j] == -1 || f[j] == -1)printf("F\n");
		else if (ans[j] >= 80)printf("A\n");
		else if (65 <= ans[j]&&ans[j] < 80)printf("B\n");
		else if (50 <= ans[j] && ans[j] < 65)printf("C\n");
		else if (30 <= ans[j] && ans[j] < 50){
			if (r[j] >= 50)printf("C\n");
			else printf("D\n");
		}
		else if(ans[j] < 30)
			printf("F\n");
		j++;
	}

	return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n, x, y;
    cin >> n >> x >> y;
    --x; --y;
    vector<int> ans(n);
    rep(sv,n) {
        vector<int> dist(n, 1e8);
        queue<int> q;
        auto push = [&](int v, int d) {
            if ( dist[v] != 1e8 ) return;
            dist[v] = d;
            q.push(v);
        };
        push(sv, 0);
        while(!q.empty()) {
            int v = q.front();
            q.pop();
            int d = dist[v];
            if (v-1 >= 0) push(v-1, d+1);
            if (v+1 < n) push(v+1, d+1);
            if (v == x) push(y, d+1);
            if (v == y) push(x, d+1);
        }
        rep(i, n) ans[dist[i]]++;
    }
    rep(i,n) ans[i] /= 2;
    for (int i = 1; i <= n-1; ++i) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string S,T;cin>>S>>T;
    long long ans=100000;
    for(long long i=0;i<S.size()-T.size()+1;i++){
        string tmpS=S.substr(i,T.size());
        long long tmp=0;
        for(long long j=0;j<T.size();j++){
            if(tmpS[j]!=T[j]){
                tmp++;
            }
        }
        if(tmp<ans){
            ans=tmp;
        }
    }
    cout<< ans <<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x;
    cin>>x;
    int tmp,result;
    if(x==1){
        cout<<x<<endl;
        return 0;
    }
    for(int i=2;i<x;i++)for(int j=2;j<x;j++){
        tmp=pow(i,j);
        if(x<tmp){
            break;
        }
        result=max(tmp,result);
    }
    cout<<result<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Scanner;

public class Main {
	static int n, dx, dy;
	static int[] cx, cy;
	static double[] cdis;
	static int[] cgot;
	static Boolean flag;
	
	// a <= bと同じ
	private static Boolean bigger(double a, double b)
	{
		return a <= b;
	}
	
	private static void check(double hx, double hy, double day, int num)
	{
		int i;
		double move;
		
		for(i = 0;i < n;i++)
		{
			move = distance(hx, hy, cx[i], cy[i]);
			if(cgot[i] == 1) continue;
			if(bigger(cdis[i], day + move)) return;
		}
		
		for(i = 0;i < n;i++)
		{
			if(cgot[i] == 1) continue;
			
			move = distance(hx, hy, cx[i], cy[i]);
			if(num == 1)
			{
				flag = true;
				return;
			}
			
			cgot[i] = 1;
			check(cx[i], cy[i], day + move, num - 1);
			if(flag) return;
			cgot[i] = 0;
		}
	}
	
	private static double distance(double ax, double ay, double bx, double by)
	{
		double dx = ax - bx;
		double dy = ay - by;
		return Math.sqrt(dx * dx + dy * dy);
	}
	
	public static void main(String[] args)
	{
		
		Scanner sca = new Scanner(System.in);
		
		while(true)
		{
			int hx, hy;
			
			n = sca.nextInt();
			hx = sca.nextInt();
			hy = sca.nextInt();
			dx = sca.nextInt();
			dy = sca.nextInt();
			
			if(n == 0) break;
			
			cx = new int[n];
			cy = new int[n];
			cdis = new double[n];
			cgot = new int[n];
			
			int i;
			for(i = 0;i < n;i++)
			{
				cx[i] = sca.nextInt();
				cy[i] = sca.nextInt();
				cdis[i] = distance(cx[i], cy[i], dx, dy);
				cgot[i] = 0;
			}
			
			flag = false;
			check(hx, hy, 0, n);
			if(flag)
				System.out.println("YES");
			else
				System.out.println("NO");
		}
	}
}

Measured memory_bytes: 25268
#include<stdio.h>
#include<stdlib.h>
void partition(int *A,int p,int r);
int main(){
  int n,*S,q,*T,i,N,count=0;
  scanf("%d\n",&n);
  S=(int *)malloc(n*sizeof(int));
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  partition(S,0,n-1);
  return 0;
}
void partition(int *A,int p,int r){
  int x,i,j,swap,k;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      swap=A[i];
      A[i]=A[j];
      A[j]=swap;
    }
  }
  
  /*printf("[%d] ",A[r]);
  for(k=r+1;k<i+1;k++){
    printf("%d ",A[k]);
  }
  printf("%d\n",A[i+1]);*/
  swap=A[i+1];
  A[i+1]=A[r];
  A[r]=swap;
  for(k=0;k<i+1;k++){
    printf("%d ",A[k]);
  }
  printf("[%d] ",A[i+1]);
for(k=i+2;k<r;k++){
    printf("%d ",A[k]);
  }
 printf("%d\n",A[r]);
}



Measured memory_bytes: 2100
#include<stdio.h>
#include<math.h>

int main(){
  int n,m,x;
  int a[100];
  scanf("%d%d%d",&n,&m,&x);
  for(int i=0;i<m;i++){
    scanf("%d",&a[i]);
  }

  int num0=0,num1=0;
  int flg =0;
  for(int i=0;;){
    if(a[i]<x){
      i++;
      num0++;
      flg++;
    }
    else break;
  }
  for(int i=flg;i<m;){
    if(a[i]>x){
      i++;
      num1++;
    }
    else break;
  }
  int num = 0;
  if(num0<=num1)num=num0;
  else num=num1;
  printf("%d\n",num);
  return 0;
}

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

int main(){
    string s;
    cin >> s;
    if(s.at(0) != s.at(1) || s.at(1) != s.at(2)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	scanf("%d",&N);
    int l = 0, r = N-1;
    printf("%d\n",0);
    fflush(stdout);
	string q;
	cin>>q;
	if(q=="Vacant")
			return 0;
    while (l != r) {
        int m = (l + r + 1) / 2;
        printf("%d\n", m);
        fflush(stdout);
		string s;
		cin>>s;
		if(s=="Vacant")
			return 0;
        else if ((q==s && m%2) || (q!=s && !(m%2)) )
            r = m-1;
        else
            l = m;
    }
}


Measured memory_bytes: 852
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

const long long MOD = 4294967291LL;
const long long INF = 1e18;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long mult_mod(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

long double dp[305][305][305];
int freq[5];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

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

    // dp[i,j,k,l,m...] expected number

    // we can compress this down to dp[i][j][k] (1s, 2s, 3s), 0s can be deduced

    int n; cin >> n;

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

    int a = freq[1], b = freq[2], c = freq[3];

    for(int k = 0; k <= c; ++k){
        for(int j = 0; j <= b + c; ++j){
            for(int i = 0; i <= n; ++i){
                long double left = i + j + k;
                if(i > 0)
                    dp[i][j][k] += dp[i - 1][j][k] * i;
                if(j > 0)
                    dp[i][j][k] += dp[i + 1][j - 1][k] * j;
                if(k > 0)
                    dp[i][j][k] += dp[i][j + 1][k - 1] * k;
                if(left > 0)
                    dp[i][j][k] = (dp[i][j][k] + n) / left;
            }
        }
    }

    cout << setprecision(10) << fixed << dp[a][b][c];

    return 0;
}


Measured memory_bytes: 438528
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    /* 変数宣言 */
    final double H;
    final double A;

    AtCoder(FastScanner sc) {
        H = sc.nextDouble();
        A = sc.nextDouble();
    }

    void solve(PrintWriter out) {
        out.println((int)Math.ceil(H/A));
    }
}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
// ll fact(ll n){ll s=1; for(ll i=1;i<=n;i++)s*=i; return s;}
// ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
// // vll factor(ll n){
// //     vll ans;
// //     if(n>0)ans.pb(1);if(n==2)ans.pb(2);
// //     for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
// //     return ans;
// // }
// ll nCr(ll n, ll r) 
// { 
//     return fact(n) / (fact(r) * fact(n - r)); 
// } 
// void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
// {
 
//     par[k]=p;
//     dis[k]=dis[p]+1;
//     for(ll i=0;i<v[k].sz;i++){
//         if(v[k][i]!=p){
//             dfs(v,v[k][i],par,dis,k);
//         }
//     }
// }
// bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second<b.second);} 


void solve()
{
	ll n,m,sum=0;
	cin>>n>>m;
	ll a[m];
	for(ll i=0;i<m;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	if(sum>n)
	{
		cout<<-1;
	}
	else
	{
		cout<<n-sum;
	}
       return;
}

int main()
{
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3676
package main

import "fmt"

func getMin(a, b int) (min int){
  if a < b{
    min = a
  }else{
    min = b
  }
  return
}

func main(){
  var a, b, c, d int
  fmt.Scan(&a, &b, &c, &d)
  fmt.Println(getMin(a,b) + getMin(c,d))
}
  

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

int main() {
  lint n, p;
  cin >> n >> p;
  map<lint, lint> mp;
  lint x = p, y = 2l, cnt = 0ll;
  while (y * y <= x) {
    cnt = 0;
    while (x % y == 0) {
      cnt++;
      x /= y;
    }
    if (cnt > 0ll) {
      mp[y] = cnt;
    }
    y++;
  }
  if (x > 1ll) mp[x] = 1ll;

  //   for (auto&& w : mp) cout << w.first << " " << w.second << endl;
  //   cout << endl;

  lint ans = 1ll;
  for (auto&& w : mp) {
    if (w.second / n > 0) {
      int num = w.second / n;
      while (num--) {
        ans *= w.first;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC047A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

            if ((a + b) == c || (b + c) == a || (a + c) == b)
            {
                Console.WriteLine("Yes");
            }            

            else
            {
                Console.WriteLine("No");
            }

            Console.ReadKey();
        }
    }
}

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

int main() {
	int b,f,r,v;
	int a[4+1][3+1][10+1] = {0};// 1indexed
	int n;
	
	cin >> n;
	for ( int i = 0; i < n; i++ ) {
		cin >> b >> f >> r >> v;
		a[b][f][r] += v;
	}
	for ( int b = 1;b <= 4; b++ ) {
		if ( b > 1 ) cout << "####################\n";
		for ( int f = 1; f <= 3; f++ ) {
			for ( int r = 1; r <= 10; r++ ) {
				cout << " " << a[b][f][r];
			}
			cout << endl;
		}   
	}
	return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#define MOD 1000000007

using namespace std;
typedef struct real_t {
    long long P;
    long long Q;
} real;
real mul(real a, real b) {
    real out;
    out.P = (a.P * b.P) % MOD;
    out.Q = (a.Q * b.Q) % MOD;
    return out;
}
real add(real a, real b) {
    real out;
    out.P = (a.P * b.Q) % MOD + (a.Q * b.P) % MOD;
    out.Q = (a.Q * b.Q) % MOD;
    out.P %= MOD;
    return out;
}
real mul(real a, long long c) {
    real out;
    out.P = (a.P * c) % MOD;
    out.Q = a.Q;
    return out;
}

long long modinv(long long a, long long b)
{
    long long b0 = b, t, q;
    long long x0 = 0, x1 = 1;
    if (b == 1) return 1;
    while (a > 1) {
        q = a / b;
        t = b, b = a % b, a = t;
        t = x0, x0 = x1 - q * x0, x1 = t;
    }
    if (x1 < 0) x1 += b0;
    return x1;
}

int main() {
    int N, A, B, C;
    cin >> N >> A >> B >> C;
    real X;
    real stepSize;
    stepSize.P = 100;
    stepSize.Q = 100 - C;
    real Pa[200000], Pb[200000];

    Pa[0].P = 1;
    Pa[0].Q = 1;
    Pb[0].P = 1;
    Pb[0].Q = 1;
    Pa[1].P = A;
    Pa[1].Q = A+B;
    Pb[1].P = B;
    Pb[1].Q = A+B;

    for (int i=2; i<2*N; i++) {
        Pa[i] = mul(Pa[i-1], Pa[1]);
        Pb[i] = mul(Pb[i-1], Pb[1]);
    }

    X.P = 0;
    X.Q = 1;
    real combination = {1, 1};
    real all = {0, 1};
    for (long long i=N; i<2*N; i++) {
        real AIplusBI = add(Pa[2*N-i], Pb[2*N-i]);
        real AImulBI = mul(Pa[i-N], Pb[i-N]);
        real local = mul(mul(AIplusBI, combination), AImulBI);
        all = add(all, local);
        X = add(mul(mul(stepSize, i), local), X);
        //cerr << local.P << " " <<local.Q << endl;
        real sub = {i, i-N+1};
        combination = mul(combination, sub);
    }
    real allinv;
    allinv.P = all.Q;
    allinv.Q = all.P;
    X = mul(X, allinv);
    cout << ((X.P * modinv(X.Q, MOD)) % MOD) << endl;
    
    return 0;
}



Measured memory_bytes: 6528
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC126B
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            string head = s.Substring(0, 2);
            string tail = s.Substring(2, 2);

            int h = 0;
            int.TryParse(head,out h);//headを数値に置き換える　出力はh
            int t = 0;
            int.TryParse(tail, out t);//tailを数値に置き換える　出力はt

            if (t==0)
            {
                if (h==0)
                {
                    Console.WriteLine("NA");
                }
                else if (h>=1&&h<=12)
                {
                    Console.WriteLine("MMYY");
                }
                else
                {
                    Console.WriteLine("NA");
                }
            }
            if (t>=1&&t<=12)
            {
                if (h>12||h==0)
                {
                    Console.WriteLine("YYMM");
                }
                else
                {
                    Console.WriteLine("AMBIGUOUS");
                }
            }
            if (t>=13)
            {
                if (h==0)
                {
                    Console.WriteLine("NA");
                }
                else if (h>=1&&h<=12)
                {
                    Console.WriteLine("MMYY");
                }
                else
                {
                    Console.WriteLine("NA");
                }
            }
        }
    }
}


Measured memory_bytes: 11092
#include<cstdio>
#define pritnf printf
#define scnaf scanf
#define retrun return
#define sizoef sizeof
#define inl inline
#define br break
#define con continue
#define mst(a,b) memset(a,b,sizeof(a))
#define fora(x,a,b) for(re nti (x)=(a);(x)<=(b);++(x))
#define forb(x,a,b) for(re nit (x)=(a);(x)>=(b);--(x))
#define re register
#define stt struct
#define infa (0x3f3f3f3f)
#define infb (0x7fffffff)
#define infd (0x7f)
#define abss(x) ((x)>(0)?(x):(-1)*(x))
#define maxx(a,b) ((a)>(b)?(a):(b))
#define minn(a,b) ((a)<(b)?(a):(b))
#define pf(_) ((_)*(_))
#define in(a) freopen("D:/""/in"a".in","r",stdin)
#define out(a) freopen("D:/""/out"a".out","w",stdout)
typedef long long ll;
typedef int itn,nti,tin,tni,nit;
using namespace std;
const nit maxa=10004;
const nit maxb=1e2;
const nit maxc=5;
#include<iostream>

string x;
tni p=0,s;
char ans[maxa]="";

tni main()
{
	cin>>x;
	s=x.size();
	//
	fora(i,0,s-1)
	{
		if(x[i]=='0')
		{
			ans[++p]='0';
		}
		else if(x[i]=='1')
		{
			ans[++p]='1';
		}
		else if(x[i]=='B')
		{
			if(p>0)
			{
				--p;
			}
		}
	}
	//
	fora(i,1,p)
	{
		pritnf("%c",ans[i]);
	}
	pritnf("\n");
	return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B
import           Data.Char
import           Data.List

main :: IO ()
main = do
    [_, k] <- readInts
    xs <- readInts
    print $ solve k xs

readInts :: IO [Int]
readInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine

solve :: Int -> [Int] -> Int
solve k xs = minimum $ map cost $ zip (drop (k-1) xs) xs

cost :: (Int, Int) -> Int
cost (x, y)
    | x <= 0    = -y
    | y >= 0    = x
    | x + y < 0 = 2 * x - y
    | otherwise = x - 2 * y

Measured memory_bytes: 8572
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define LL long long
using namespace std;
LL n,a,b,c,d;
int main(){
	scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	for(int i(0);i<=n-1;i++){
		if(((n-1-i)*c-i*d)<=b-a and b-a<=((n-1-i))*d-i*c){
			printf("YES");
			return 0;
		}
	}
	printf("NO");
	return 0;
}

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

int main(){
	int s;
	int m;
	int h;
    cin>>s;
    h=s/3600;
    m=(s-3600*h)/60;
    s=s-60*m-3600*h;
    cout<<h<<":"<<m<<":"<<s<<endl;
    return 0;
}
    
    
    
    
  
   



	
	
	
	




Measured memory_bytes: 3084
#include<cstdio>
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;

int main(void) {
	int N;
	scanf("%d", &N);
	map<int, int> m;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int A;
		scanf("%d", &A);
		if (m[A] == 1) {
			m[A] = 0;
			ans--;
		} else {
			m[A] = 1;
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 8388
import sys
N, M = (int(x) for x in input().split())
AB = []
for i in range(N):
    AB_before = input().split()
    AB.append([int(x) for x in AB_before])

AB.sort(key=lambda x : x[0], reverse=False)  #1個目の要素で昇順並び替え

count = 0
total = 0

for i in range(N):
    if count < M - AB[i][1]:
        total += AB[i][0] * AB[i][1]
        count += AB[i][1]
    elif count < M:
        total += AB[i][0] * (M - count)
        print(total)
        sys.exit()


Measured memory_bytes: 22820
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int N;
  int a[110];
  int res=0;
  cin >> N;
  rep(i,N) cin >> a[i];

  rep(i,N){
    if(a[i]%2==0){
      if(a[i]%3!=0 && a[i]%5!=0){
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }

  cout << "APPROVED" << endl;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()

int main() {
	int n;
	cin >> n;
	bool flag = false;
	FOR(i, 1, 9) {
		FOR(j, 1, 9) {
			if (i*j == n) {
				flag = true;
			}
		}
	}
	if (flag) {
		ps(Yes);
	}
	else {
		ps(No);
	}
	return(0);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void) {
	long long a,b,c,x,y;
	cin >> a >> b >> c >> x >> y;
	long long half=min(x,y);
	long long ans=0;
	ans+=a+b<=c*2?(a+b)*half:c*2*half;
	ans+=a<=c*2?a*(x-half):c*2*(x-half);
	ans+=b<=c*2?b*(y-half):c*2*(y-half);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(a) (a).begin(),(a).end()
#define SIZE(a) (int)((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

typedef pair<int,int> P;
struct edge {
  int to, cap, rev;
};

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

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " ";
  }
  return s;
}

void add_edge(vector< vector<edge> >& G, int from, int to, int cap) {
  G[from].push_back((edge){ to, cap, SIZE(G[to])   });
  G[to].push_back((edge){ from, 0, SIZE(G[from])-1 });
}

int dfs(vector< vector<edge> >& G, vector<bool>& used, int v, int t, int flow)
{
  if (v == t) {
    return flow;
  }
  used[v] = true;

  for(int i = 0; i < G[v].size(); ++i) {
    edge& e = G[v][i];
    if (used[e.to] || e.cap == 0) {
      continue;
    }
    int d = dfs(G, used, e.to, t, min(e.cap, flow));
    if (d > 0) {
      e.cap -= d;
      G[e.to][e.rev].cap += d;
      return d;
    }
  }

  return 0;
}

int max_flow(vector< vector<edge> >& G, int s, int t)
{
  int flow = 0;
  vector<bool> used(G.size());
  for (;;) {
    fill(used.begin(), used.end(), false);
    int f = dfs(G, used, s, t, INF);
    if (f == 0) {
      return flow;
    }
    flow += f;
  }
}


signed main()
{
  int N; cin >> N;
  vector< vector<edge> > G(N+2, vector<edge>());

  int sum = 0;
  rep(i, 0, N) {
    int a; cin >> a;
    if (a < 0) {
      add_edge(G, 0, i+1, -a);
    } else {
      add_edge(G, i+1, N+1, a);
      sum += a;
    }
  }

  rep(i, 1, N+1) {
    for(int j=2; i*j <= N; ++j) {
      add_edge(G, i, i*j, INF);
    }
  }

  cout << sum - max_flow(G, 0, N+1) << endl;

  return 0;
}


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

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }

int main(){
  char c;
  cin >> c;
  cout << char(c + 1) << endl;
}


Measured memory_bytes: 256
using System;
using static System.Console;
public class Hello{
    public static void Main(){
//        string[] a = ReadLine().Split(' ');
//        int x = int.Parse(a[0]);
//        int y = int.Parse(a[1]);
//        int z = int.Parse(a[2]);
        string b = ReadLine();
        int count = 0;
        if(b[0] == 'o'){ count++; }
        if(b[1] == 'o'){ count++; }
        if(b[2] == 'o'){ count++; }
        WriteLine(700+(100*count));
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define nw	 endl
#define mod 1000000007
 
 
int main(void)
{
	CIN;
	ll  tc,l,k=0,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	ll arr[2],a[2];
	cin>>arr[0]>>arr[1]>>a[0]>>a[1];
	//sort(arr,arr+2);
	//sort(a,a+2);
	cout<<max({arr[0]*a[0],arr[1]*a[1],arr[0]*a[1],arr[1]*a[0]})<<nw;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <iostream>

using namespace std;
typedef long long ll;

struct TREE{
    ll h;
    vector<pair<int,ll> > way;
    bool kaku;
    
    TREE (){
        kaku=false;
    }
    
}tree[100000];

int main(){
    int n,m,a,b;
    ll x,t;
    priority_queue<pair<ll,int> > pq;
    
    scanf("%d%d%lld",&n,&m,&x);
    
    for(int i=0;i<n;i++){
        scanf("%lld",&tree[i].h);
    }
    
    for(int i=0;i<m;i++){
        scanf("%d%d%lld",&a,&b,&t);
        
        tree[a-1].way.push_back(make_pair(b-1,t));
        tree[b-1].way.push_back(make_pair(a-1,t));
    }
    
    for(int i=0;i<tree[0].way.size();i++){
        if(tree[0].way[i].second<=x && x<=tree[tree[0].way[i].first].h+tree[0].way[i].second)
            pq.push(make_pair(-tree[0].way[i].second,tree[0].way[i].first));
        
        else if(x>tree[tree[0].way[i].first].h+tree[0].way[i].second)
            pq.push(make_pair(-x+tree[tree[0].way[i].first].h,tree[0].way[i].first));
            
        else if(tree[0].h>=tree[0].way[i].second)
            pq.push(make_pair(x-tree[0].way[i].second*2,tree[0].way[i].first));
    }
    tree[0].kaku=true;
    
    while (!pq.empty()) {
        pair<ll,int> p=pq.top();
        pq.pop();
        
        if(tree[p.second].kaku) continue;
        //cerr << p.second << ":" << -p.first << endl;
        tree[p.second].kaku=true;
        
        if(p.second==n-1){
            if(-p.first>=x)
                printf("%lld\n",-p.first+tree[n-1].h);
            else
                printf("%lld\n",tree[n-1].h-x-(p.first*2));
            return 0;
        }
        
        if(-p.first>=x){
            for(int i=0;i<tree[p.second].way.size();i++){
                if(tree[p.second].way[i].second<=tree[p.second].h)
                    pq.push(make_pair(p.first-tree[p.second].way[i].second*2,tree[p.second].way[i].first));
            }
        }else{
            for(int i=0;i<tree[p.second].way.size();i++){
                if(tree[p.second].way[i].second<=x+p.first && x+p.first<=tree[tree[p.second].way[i].first].h+tree[p.second].way[i].second)
                    pq.push(make_pair(-tree[p.second].way[i].second+p.first,tree[p.second].way[i].first));
                
                else if(x+p.first>tree[tree[p.second].way[i].first].h+tree[p.second].way[i].second)
                    pq.push(make_pair(-x-p.first+tree[tree[p.second].way[i].first].h+p.first,
                                      tree[p.second].way[i].first));
                
                else if(tree[p.second].h>=tree[p.second].way[i].second)
                    pq.push(make_pair(x+p.first-tree[p.second].way[i].second*2+p.first,
                                      tree[p.second].way[i].first));
            }
        }
    }
    
    puts("-1");
    
    return 0;
}

Measured memory_bytes: 30296
n = int(input())

chars = list(input())

if n == 0:
    print(0)
elif n == 1:
    print(1)
else:
    slime_num = 1
    idx_0 = 0
    idx_1 = 1
    
    while idx_1 < n:
        if chars[idx_0] != chars[idx_1]:
            slime_num += 1
        idx_1 += 1
        idx_0 += 1
    
    print(slime_num)

Measured memory_bytes: 4084
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>
#define PI 3.141592653589793

int b[105][105];
int h, w;
char c[105][105];
vector<Pii> v[100000];

void dfs(int x, int y, int val) {
    if (b[x][y] != -1) return ;
    b[x][y] = val;
    v[val].emplace_back(x, y);
    int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
    for (int i = 0; i < 2; i++) {
        int nx = dx[i] + x, ny = dy[i] + y;
        if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
        if (b[nx][ny] == -1 && c[x][y] == c[nx][ny]) dfs(nx, ny, val);
    }
}

int main() {
    cin >> h >> w;
    for (int i = 0; i < h; i++) cin >> c[i];


    for (int i =0 ; i < h; i++) {
        for (int j = 0; j < w; j++) b[i][j] = -1;
    }
    //b[0][0] = 0;
    dfs(0, 0, 0);

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

    for (int i = 0; i < 10000; i++) {
        for (auto j : v[i]) {
            if (j == Pii(h-1, w-1)) break;
            for (int k  =0; k < 2; k++) {
                int nx = dx[k] + j.first, ny = dy[k] + j.second;
                if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
                dfs(nx, ny, i + 1);
            }
        }
    }
    cout << (b[h-1][w-1] + 1 + (c[0][0] == '#')) / 2 << endl;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) cerr << b[i][j];
        cerr << endl;
    }
}

Measured memory_bytes: 2816