akhauriyash/Code-Regression huggingface dataset:
#include <math.h>
#include <stdio.h>

int rel_l_l( double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3, double *x, double *y ) {
	double a, b, c, d;
	int rel;

	if ( x0 != x1 ) {
		a = ( y0 - y1 ) / ( x0 - x1 );
		b = ( x0 * y1 - x1 * y0 ) / ( x0 - x1 );
	}
	if ( x2 != x3 ) {
		c = ( y2 - y3 ) / ( x2 - x3 );
		d = ( x2 * y3 - x3 * y2 ) / ( x2 - x3 );
	}

	rel = 0;
	if ( x0 == x1 ) {
		*x = x0;
		if ( x2 == x3 )
			if ( x0 == x2 )
				rel = 2;
			else
				rel = 1;
		else {
			*y = c * *x + d;
			if ( y2 == y3 )
				rel = 3;
		}
	} else {
		if ( x2 == x3 ) {
			*x = x2;
			if ( y0 == y1 )
				rel = 3;
		} else
			if ( fabs( a - c ) < 1e-10 )
				if ( fabs( b - d ) < 1e-10 )
					rel = 2;
				else
					rel = 1;
			else {
				*x = ( -b + d ) / ( a - c );
				if ( fabs( a * c + 1.0 ) < 1e-10 )
					rel = 3;
			}
		*y = a * *x + b;
	}

	return rel;
}

int main( void ) {
	double xA, yA, xB, yB, xC, yC, xD, yD, x, y;
	
	while( scanf( "%lf %lf %lf %lf %lf %lf %lf %lf", &xA, &yA, &xB, &yB, &xC, &yC, &xD, &yD ) != EOF ) {
		int rel = rel_l_l( xA, yA, xB, yB, xC, yC, xD, yD, &x, &y );

		printf( "%s\n", rel == 3 ? "YES" : "NO" );
	}

	return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;
	printf("%d %d %d\n", Z, X, Y);
	return 0;
}


Measured memory_bytes: 256
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

'''
from numpy.linalg import solve

N =ii()
left = dp2(0, N, N)
for i in range(N-1):
    left[i][i] = left[i][i+1] = 0.5
left[N-1][N-1] = left[N-1][0] = 0.5

right = li()

for i in solve(left, right):
    print(int(i), end='')
    print(' ', end='')
'''

N = ii()
A = li()

ans = [0]*N

ans[0] = sum(A) - sum([A[i] for i in range(1, N, 2)])*2
for i in range(N-1):
    ans[i+1] = A[i]*2 - ans[i]

for i in range(N):
    print(ans[i], end='')
    print(' ', end='')

Measured memory_bytes: 14228
/******************************************
/@Author: LeafBelief
/@Date: 2020-04-04
/@Remark:    
/@FileName: popular
******************************************/
#include <bits/stdc++.h>
#define CSE(x,y) memset(x,y,sizeof(x))
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
#define FAST ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll , ll> pll;

const int maxn = 1111;
int n, m, vote[maxn];

int main()
{
    FAST;
    while(cin >> n >> m)
    {
        int ans = 0, all = 0;
        for(int i = 0;i < n; i++)
        {
            cin >> vote[i];
            all += vote[i];
        }
        for(int i = 0; i < n; i++)
        {
            if(vote[i] * 4 * m >= all)
                ans++;
        }
        if(ans >= m)
            cout << "Yes" << endl;
        else
        {
            cout << "No" << endl;
        }
        
    }
    return 0;
}

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

// using namespace std;
// typedef long long ll;

// #define rep(i, n) for (int i = 0; i < (n); i++)
// #define rep2(i, a, b) for (int i = (a); i < (b); ++i)
// #define all(a) (a).begin(), (a).end()
// #define all2(a, b) (a).begin(), (a).begin() + (b)
// #define debug(vari) cerr << #vari << " = " << (vari) << endl;

// int main()
// {
//     int N;
//     cin >> N;

//     vector<int> vec(N);
//     rep(i, N) cin >> vec[i];

//     bool flag = true;
//     rep(i, N)
//     {
//         if (vec[i] % 2 == 0)
//         {
//             if (vec[i] % 3 != 0 || vec[i] % 5 != 0)
//             {
//                 flag = false;
//             }
//         }
//     }

//     cout << (flag ? "APPROVED" : "DENIED") << endl;

//     return 0;
// }

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

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

    vector<int> v(n, 0);
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        v[a - 1]++;
        v[b - 1]++;
    }

    rep(i, n)
    {
        cout << v[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int n, m, q;
int a[100], b[100], c[100], d[100];
int s[20], ans;
void dfs(int cur, int lst) {
	if (cur > n) {
		int cnt = 0;
		for (int i = 1; i <= q; i++) {
			if (s[b[i]] - s[a[i]] == c[i]) {
				cnt += d[i];
			}
		}
		ans = max(ans, cnt);
		return;
	}
	for (int i = lst; i <= m; i++) {
		s[cur] = i;
		dfs(cur + 1, i);
	}
}
int main() {
	cin >> n >> m >> q;
	for (int i = 1; i <= q; i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
	dfs(1, 1);
	cout << ans;
	return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };


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

	vector<string>ans;
	int sz = s.length();
	int r = min(K, sz);
	for (int i = 1; i <= r; i++) {
		for (int j = 0; j + i <= s.size(); j++) {
			string temp = "";
			for (int k = j; k <= j + i - 1; k++) {
				temp += s[k];
			}
			ans.pb(temp);
		}
	}

	sort(all(ans));
	ans.erase(unique(all(ans)),ans.end());
	cout << ans[K - 1] << endl;
	return 0;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(aa) (aa).begin(), (aa).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
typedef pair<pill,int> PA;
//ll MOD;
ll MOD = 1000000007;
// ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	ll weight;
};
int M,N;
vi gr[214514];
int num[214514];
string str;
int ans[214514]={0};
int main(){
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	cin>>str;
	if(str=="hi"||str=="hihi"||str=="hihihi"||str=="hihihihi"||str=="hihihihihi")cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


int main(){
    int N;
    cin >> N;
    vector<int> a;
    rep(i, 3 * N){
        int n;
        cin >> n;
        a.push_back(n); 
    }
    sort(all(a));
    ll ans = 0;
    for(int i = 0; i < 3 * N; i++){
        if(i < N) continue; 
        if((i - N) % 2 == 0)ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,m,ans=0,now=0,a,b;
  cin >> n >> m;
  vector<P> p(m);
  for(int i=0; i<m; i++) {
    cin >> a >> b;
    p[i]=make_pair(b,a);
  }
  sort(p.begin(),p.end());
  for(int i=0; i<m; i++) {
    if(now<=p[i].second) {
      ans++;
      now=p[i].first;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
from math import ceil, log2

def getNums(As, N):
    dp = list(range(16))
    nums = [0] * N
    for i in reversed(range(N - 1)):
        dx = ceil( log2( As[i] / As[i+1] ) / 2 )
        if dx <= 0:
            dp0 = dp[0]
            dp = [dp0] * (-dx) + dp[:16+dx]
        else:
            dp15 = dp[15]
            k = N - 1 - i
            dp = dp[dx:] + list(range(dp15 + k, dp15 + k * dx + 1, k))
        dp = [dpx + x for x, dpx in enumerate(dp)]
        nums[i] = dp[0]
    return nums

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

numPstvs = getNums(As, N)
numNgtvs = getNums(As[::-1], N)[::-1]

ans = min([2 * p + 2 * m + i for i, (p, m) in enumerate(zip(numPstvs + [0], [0] + numNgtvs))])
print(ans)


Measured memory_bytes: 41692
#include <cstdio>
#include <cstring>

#include <algorithm>

using namespace std;

typedef long long i64;

#define NMAX 100000

static int n;
static i64 A[NMAX + 10], S[NMAX + 10];

inline i64 eval() {
    i64 r = 0;
    for (int i = 1; i < n; i++) r += abs(S[i] - S[i + 1]);
    return r;
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%lld", A + i);
    sort(A + 1, A + n + 1);
    for (int i = 1, j = n, t = 1; i <= j; i++, j--) {
        S[t++] = A[i];
        if (i < j) S[t++] = A[j];
    }

    i64 ans = 0;
    if (n & 1) {
        swap(S[1], S[n - 2]);
        ans = eval();
        i64 l = S[n];
        memmove(S + 2, S + 1, sizeof(i64) * (n - 1));
        S[1] = l;
    } else swap(S[1], S[n - 1]);
    ans = max(ans, eval());
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 100 + 10;
const int CAP = 1e5 + 10;
int n,cap;
int v[N], w[N];
ll dp[N][CAP];
ll run(int idx, int cur) {
    if(dp[idx][cur] != -1) return dp[idx][cur];
    ll res = 0;
    if(idx == n or cur == 0) res = 0;
    else if(w[idx] > cur) res = run(idx + 1, cur);
    else res = max(
        run(idx + 1, cur),
        run(idx + 1, cur - w[idx]) + v[idx]
    );
    return dp[idx][cur] = res;
}
ll run() {
    for(int i = 1; i <= n; ++i) {
        for(int k = 1; k <= cap; ++k) {
            if(w[i - 1] > k) dp[i][k] = dp[i - 1][k];
            else dp[i][k] = max(
                dp[i - 1][k],
                dp[i - 1][k - w[i - 1]] + v[i - 1]
            );
        }
    }
    return dp[n][cap];
}
int main() {
    scanf("%d %d", &n, &cap);
    for(int i = 0; i < n; ++i) scanf("%d %d", &w[i], &v[i]);
    // memset(dp, -1, sizeof dp);
    ll ans = run();
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=100005;
int n,q,a[N],ans;
signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		a[x]++;
		ans+=x;
	}
	cin>>q;
	while(q--)
	{
		int b,c;
		cin>>b>>c;
		ans+=(c-b)*a[b];
		a[c]+=a[b];
		a[b]=0;
		cout<<ans<<endl;
	}
	return 0;
}

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

int main()
{

    int a , b , c;

    cin >> a >> b >> c;

    if((a+b+c)>=22)
    {
        cout << "bust" << endl;
    }
    else
    {
        cout << "win" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long
#define mod (1000000007)
using pi=pair<int,int>;
#define mp make_pair
#define x first
#define y second
main(){
  int h,w;
  cin>>h>>w;
  vector<vector<int>> a(h,vector<int>(w));
  vector<pair<pi,pi>> res;
  for(auto& v:a)for(auto& i:v)cin>>i;
  for(int i=0;i<h;++i){
    for(int j=(i%2?w-1:0);(i%2?j>=0:j<w);j+=(i%2?-1:1)){
      bool f=(i%2&&!j)||(i%2==0&&j==w-1);
      if(f&&i==h-1)continue;
      int& next=f?a[i+1][j]:a[i][j+1-(i%2)*2];
      if(a[i][j]%2)a[i][j]--,next++,res.emplace_back(mp(i+1,j+1),mp((f?i+1:i)+1,(f?j:j+1-(i%2)*2)+1));
    }
  }
  cout<<res.size()<<"\n";
  for(auto pp:res)printf("%ld %ld %ld %ld\n",pp.x.x,pp.x.y,pp.y.x,pp.y.y);
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    
    set<int>s;
    for(int i = 0; i < k; ++i)
    {
        int temp;
        cin >> temp;
        s.insert(temp);
    }
    
    for(int j = n; j <= INT_MAX; ++j)
    {
        int t = j;
        while(t)
        {
            if(s.count(t % 10) == 1)
            {
                break;
            }
            t /= 10;
        }
        
        if(t == 0)
        {
            cout << j << endl;
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

    int n, k;
    cin >> n >> k;

    vector<int> p(n);
    REP(i, n) cin >> p[i];

    vector<double> ex(n);
    REP(i,n ) ex[i] = (p[i] + 1) / 2.0;

    double maxi = 0.0;
    double sum = 0.0;
    queue<double> q;
    REP(i, n) {
        sum += ex[i];
        q.push(ex[i]);
        if (q.size() > k) {
            sum -= q.front();
            q.pop();
        }
        if (q.size() == k)
            maxi = max(maxi, sum);
    }

    printf("%.10f\n", maxi);
    return 0;
}


Measured memory_bytes: 4224
/*
 *
 * hsl2363 solve this problem.   He is so good at programming
 * hsl2363 can get ans in O(N), I only come up with an idea in O(N^2). He is so good at algorithm competition.
 * hsl2363 T2 dd me
 *
 */

#include <bits/stdc++.h>

#define ll long long
#define rep(i, a, b) for(int i = a; i <= b; ++i)

using namespace std;

#define N 3005

int n, a[N], ans[N], tot;
bool vis[N], can[N];
vector<int> G[N];
class Node {
    public:
        int val, id;

        bool operator < (const Node A) const {
            return val < A.val;
        }
} b[N];

bool dfs(int x, int from) {
    int len = G[x].size() - 1;
    rep (i, 0, len) {
        if (a[G[x][i]] >= a[x] || G[x][i] == from || !can[G[x][i]]) continue;
        if (!dfs(G[x][i], x)) return true;
    }
    return false;
}

int main() {
    scanf ("%d", &n);
    rep (i, 1, n) scanf ("%d", &a[i]), b[i].id = i, b[i].val = a[i];
    int u, v;
    rep (i, 1, n - 1) {
        scanf ("%d%d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    sort(b + 1, b + n + 1);
    rep (i, 1, n) {
        can[b[i].id] = 1;
        if (dfs(b[i].id, b[i].id)) ans[++tot] = b[i].id;
    }
    sort(ans + 1, ans + tot + 1);
    rep (i, 1, tot) printf("%d ", ans[i]);
    return 0;
}

Measured memory_bytes: 512
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var s string
	if sc.Scan() {
		s = sc.Text()
	}
	split := strings.Split(s, " ")
	a, _ := strconv.Atoi(split[0])
	b, _ := strconv.Atoi(split[1])
	c, _ := strconv.Atoi(split[2])
	d, _ := strconv.Atoi(split[3])

	max := a * c
	if a*d > max {
		max = a * d
	}
	if b*c > max {
		max = b * c
	}
	if b*d > max {
		max = b * d
	}

	fmt.Printf(strconv.Itoa(max))
}


Measured memory_bytes: 1740
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
using namespace std;

struct edge {
	int u, v; edge() {}
	edge(int _u, int _v) :
		u(_u), v(_v) {}
};

struct node { vector<edge> edges; };

struct graph {
	vector<node> nodes; int n;
	graph(int _n) : n(_n) { nodes.resize(n); }

	void add_edge(int u, int v) {
		nodes[u].edges.emplace_back(u, v);
		nodes[v].edges.emplace_back(v, u);
	}

	int bfs(int u, vector<bool> &visited) {
		queue<int> q; q.push(u);
		visited[u] = true; int res = 0;
		while (!q.empty()) {
			int cur = q.front(); q.pop(); res++;
			for (edge &e : nodes[cur].edges) {
				if (visited[e.v]) { continue; }
				q.push(e.v); visited[e.v] = true;
			}
		}
		return res;
	}
};

int main() {
	int n, m; cin >> n >> m; graph g(n);
	for (int i = 0; i < m; i++) {
		int u, v; cin >> u >> v;
		u--; v--; g.add_edge(u, v);
	}
	vector<bool> vis(n, false); int res = 0;
	for (int i = 0; i < n; i++) if (!vis[i])
		res = max(res, g.bfs(i, vis));
	cout << res << '\n';
	cin.ignore(2); return 0;
}

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

int main(){
  string S;
  cin >> S;
  set<char> s;
  for(int i=0;i<S.size();i++){
    s.insert(S.at(i));
  }
  if(s.size()==S.size()){
    cout << "yes" << endl;
  }else{
    cout << "no" << endl;
  }
  return 0;
}


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

using namespace std;

int main(){

  string name;
  int p,a,b,c,d,e,f,s,m;
  int n;

  cin >> n;
  while(n){

    vector<pair<double,string> > food(n);

    for(int i=0;i<n;i++){
      cin >> name;
      cin >> p >> a >> b >> c >> d >> e >> f >> s >> m;

      double rieki = (double)(f*m*s-p)/((a+b+c)+(d+e)*m);

      food[i].first = rieki;
      food[i].second = name;      
    }

    sort(food.begin(),food.end());
    reverse(food.begin(),food.end());

    vector<string> vc;
    
    for(int i=1;i<n;i++){
      if(food[i].first==food[i-1].first){
	vc.push_back(food[i-1].second);
      }else{
	vc.push_back(food[i-1].second);
	sort(vc.begin(),vc.end());
	for(int j=0;j<vc.size();j++){
	  cout << vc[j] << endl;
	}
	vc.clear();
      }
    }
    if(food[n-1].first==food[n-2].first){
      vc.push_back(food[n-1].second);
      sort(vc.begin(),vc.end());
      for(int i=0;i<vc.size();i++)cout << vc[i] << endl;
    }else{
      sort(vc.begin(),vc.end());
      for(int i=0;i<vc.size();i++)cout << vc[i] << endl;
      cout << food[n-1].second << endl;
    }
    cout <<  "#" << endl;
    cin >> n;
  }
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

inline bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
inline bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
    int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
    return x * fh;
}

int main () {
	long long n = read(), k = read();
	long long ans = 0;
	if (k == 0) return printf ("%lld\n", n * n), 0;
	For (i, 1, n) {
		ans += n / i * max((i - k), 0ll);
		if (n % i) ans += max(n % i - k + 1, 0ll);
	}
	printf ("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define CMD 16

typedef struct node_t{
  long key;
  struct node_t *prev;
  struct node_t *next;
} node; 

node *head, *tail;

int insert(node *add){
  if (!add)
    return -1;
  else if (!head)
    // when add a first node
    head = tail = add;
  else {
    head->prev = add;
    add->next = head;
    head = add;
  }
  return 0;
}

node *search(long searchKey){
  node *tmp = head;
  while (tmp) {
    if (tmp->key == searchKey)
      return tmp;
    tmp = tmp->next;
  }
  return NULL;
}

int delete(long deleteKey){
  node *del;
  if (!(del = search(deleteKey)))
    return -1;
  else {
    if (del == head) {
      head = head->next;
      if (head)
    	head->prev = NULL;
      else
	// list is empty
    	head = tail = NULL;
    }
    else if (del == tail) {
      tail = tail->prev;
      tail->next = NULL;
    }
    else {
      // delete node is middle in the list
      del->prev->next = del->next;
      del->next->prev = del->prev;
    }
    free(del);
    return 0;
  }
  return 1;
}

int deleteFirst(){
  if (head == tail && tail == NULL)
    return -1;
  else {
    head = head->next;
    if (head)
      head->prev = NULL;
    else
      // list is empty
      head = tail = NULL;
    return 0;
  }
}

int deleteLast(){
  if (head == tail && tail == NULL)
    return -1;
  else {
    tail = tail->prev;
    if (tail)
      tail->next = NULL;
    else
      // list is empty
      head = tail = NULL;
    return 0;
  }
}

int main(void){
  long n, i, key;
  char command[CMD] = {0};
  char ins[] = "insert", del[] = "delete";
  char delF[] = "deleteFirst", delL[] = "deleteLast";
  node *tmp;
  scanf("%ld", &n);
  for (i = 0; i < n; i++) {
    scanf("%s %ld", command, &key);
    if (!(strcmp(command, ins))) {
      tmp = (node *)malloc(sizeof(node));
      tmp->key = key;
      tmp->next = NULL;
      tmp->prev = NULL;
      insert(tmp);
    }
    else if(!(strcmp(command, del)))
      delete(key);
    else if(!(strcmp(command, delF)))
      deleteFirst();
    else if(!(strcmp(command, delL)))
      deleteLast();
    else
      puts("Not available command!");
  }
  
  // output
  char *sp = "";
  for (tmp = head; tmp != NULL; tmp = tmp->next) {
    printf("%s%ld", sp, tmp->key);
    sp = " ";
  }
  puts("");
  return 0;
}

Measured memory_bytes: 34992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int N;
vector<int> x, y;
vector<char> d;

int main() {
  cin >> N;
  x.resize(N), y.resize(N), d.resize(N);

  rep(i, N) cin >> x[i] >> y[i] >> d[i];

  map<char, double> xMax, xMin, yMax, yMin;
  const vector<char> dirs = {'U', 'D', 'R', 'L'};
  for (auto dir : dirs) {
    xMax[dir] = -1e10;
    xMin[dir] = 1e10;
    yMax[dir] = -1e10;
    yMin[dir] = 1e10;
  }

  rep(i, N) {
    xMax[d[i]] = max(xMax[d[i]], (double)x[i]);
    xMin[d[i]] = min(xMin[d[i]], (double)x[i]);
    yMax[d[i]] = max(yMax[d[i]], (double)y[i]);
    yMin[d[i]] = min(yMin[d[i]], (double)y[i]);
  }

  function<double(double)> dx = [&](double t) {
    return max({xMax['R'] + t, xMax['L'] - t, xMax['U'], xMax['D']}) -
           min({xMin['R'] + t, xMin['L'] - t, xMin['U'], xMin['D']});
  };
  function<double(double)> dy = [&](double t) {
    return max({yMax['U'] + t, yMax['D'] - t, yMax['L'], yMax['R']}) -
           min({yMin['U'] + t, yMin['D'] - t, yMin['L'], yMin['R']});
  };

  auto s = [&](double t) { return dx(t) * dy(t); };

  vector<double> T;
  const double eps = 1e-11;
  vector<vector<double>> rs({
      {xMax['R'], xMax['L'], max(xMax['U'], xMax['D'])},
      {xMin['R'], xMin['L'], min(xMin['U'], xMin['D'])},
      {yMax['U'], yMax['D'], max(yMax['R'], yMax['L'])},
      {yMin['U'], yMin['D'], min(yMin['R'], yMin['L'])},
  });

  T.push_back(0);
  for (auto r : rs) rep(i, 3) rep(j, 3) {
      double t = r[i] - r[j];
      if (i == j || t < 0) continue;
      if (i != 2 && j != 2) t /= 2;
      T.push_back(t);
    };

  // auto search = [&](function<bool(double)> f) {
  //   double l = 0.0, r = 1e10;
  //   while (r - l > eps) {
  //     double m = (l + r) / 2;
  //     if (f(m)) {
  //       l = m;
  //     } else {
  //       r = m;
  //     }
  //   }
  //   return l;
  // };
  // T.push_back(search([&](double m) { return dx(m + eps / 2) - dx(m) < 0; }));
  // T.push_back(
  //     search([&](double m) { return dx(m + eps / 2) - dx(m) < eps / 2; }));
  // T.push_back(search([&](double m) { return dy(m + eps / 2) - dy(m) < 0; }));
  // T.push_back(
  //     search([&](double m) { return dy(m + eps / 2) - dy(m) < eps / 2; }));

  double ans = 1e17;
  for (double t : T) ans = min(ans, s(t));

  printf("%.10lf\n", ans);

  return 0;
}


Measured memory_bytes: 1152
<?php
//error_reporting(0);
//$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
list($N,$K) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$a = array_map('intval',explode(" ",trim(fgets(STDIN))));

printf("%d\n",min($N%$K,abs(($N%$K)-$K)));


Measured memory_bytes: 4856
import java.sql.Time;
import java.util.*;
import java.util.stream.DoubleStream;

public class Main {

    private static class Pair {
        char a;
        int b;

        Pair(char a, int b) {
            this.a = a;
            this.b = b;
        }

        Pair(Pair p) {
            a = p.a;
            b = p.b;
        }

        Pair() {
        }
    }

    static Scanner sc;

    private static boolean check(ArrayList<ArrayList<Pair>> split) {
        for (int i = 0; i < 3; ++i) {
            ArrayList<Pair> s = split.get(i);
            char c = s.get(0).a;

            for (int j = 1; j < 3; ++j) {
                if (c != s.get(j).a) {
                    return false;
                }
            }

            int sum = s.get(0).b + s.get(1).b + s.get(2).b;

            for (int j = 0; j < 3; ++j) {
                int diff = s.get(j).b * 3 - sum;
                if (diff != 0 && diff != 3 && diff != -3) {
                    return false;
                }
            }
        }

        return true;
    }

    private static boolean create(int idx, Pair[] arr, ArrayList<ArrayList<Pair>> split) {
        if (idx == 9) {
            return check(split);
        }

        for (int i = 0; i < 3; ++i) {
            ArrayList<Pair> s = split.get(i);
            if (s.size() == 3)
                continue;
            s.add(arr[idx]);

            if (create(idx + 1, arr, split))
                return true;

            s.remove(s.size() - 1);
        }

        return false;
    }

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

        int n = sc.nextInt();
        for (int l = 0; l < n; ++l) {
            Pair[] arr = new Pair[9];

            for (int i = 0; i < 9; ++i) {
                arr[i] = new Pair('a', sc.nextInt());
            }

            for (int i = 0; i < 9; ++i) {
                arr[i].a = sc.next().charAt(0);
            }

            ArrayList<ArrayList<Pair>> a = new ArrayList<ArrayList<Pair>>();
            for (int i = 0; i < 3; ++i) {
                a.add(i, new ArrayList<Pair>(0));
            }

            System.out.println(create(0, arr, a) ? 1 : 0);

        }
    }
}


Measured memory_bytes: 33404
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
const int MOD = 998244353;

ll A[200010];
int main()
{
	int N; cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	ll ans = INF, cnt = 0;
	int turn = 1;
	ll num = 0;
	for (int i = 0; i < N; i++) {
		num += A[i];
		if (num * turn <= 0) {
			cnt += abs(num - turn);
			num = turn;
		}
		turn *= -1;
	}
	ans = min(ans, cnt);
	//cout << ans << endl;
	num = 0; cnt = 0;
	turn = -1;
	for (int i = 0; i < N; i++) {
		num += A[i];
		if (num * turn <= 0) {
			cnt += abs(num - turn);
			num = turn;
		}
		turn *= -1;
	}
	cout << min(ans, cnt) << endl;
}


Measured memory_bytes: 1024
# PROBLEM C
a, b, c = sorted([int(arg) for arg in input().split()])
moves = 0
while b < c:
    a += 1
    b += 1
    moves += 1
while a < b:
    a += 2
    moves += 1
while b < a:
    b += 1
    c += 1
    moves += 1

print(moves)

Measured memory_bytes: 3060
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt(), M = sc.nextInt();
        int[] H = new int [N];
        for (int i=0; i<N; i++) {
        	H[i] = sc.nextInt();
        }
        int[] array = new int [N];
        for (int i=0; i<M; i++) {
            int a = sc.nextInt()-1, b = sc.nextInt()-1;
            array[a] = Math.max(array[a],H[b]);
            array[b] = Math.max(array[b],H[a]);
        }
        int ans = 0;
        for (int i=0; i<N; i++) {
            ans += (H[i] > array[i])?1: 0;
        }
        sc.close();
        System.out.println(ans);
	}
}

Measured memory_bytes: 59692
#include <iostream>

using namespace std;

void print(int *p, int n)
{
    cout << p[0];
    for (int i = 1; i < n; i++) cout << " " << p[i];
    cout << endl;
}

int selectionsort(int *p, int n)
{
    int minj, j, v;
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        minj = i;
        for (j = i; j < n; j++) if (p[j] < p[minj]) minj = j;
        if (minj != i)
        {
            v = p[i];
            p[i] = p[minj];
            p[minj] = v;
            count++;
        }
    }
    return count;
}

int main(void)
{
    int A[100];
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];
    int count = selectionsort(A, N);
    print(A, N);
    cout << count << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define INF 1000000000

#define MP make_pair<int>

// http://www.slideshare.net/iwiwi/ss-3578491

int dat[1<<19];
struct rmq{
  int n;
  rmq(){}
  void init(int _n){
    n = 1;
    while(n<_n) n<<=1;
    REP(i,n-1)dat[i] = INF;
  }
  void update(int i,int x){
    i += n-1;
    dat[i] = x;
    while(i>0){
      i = (i-1)/2;
      dat[i] = min(dat[i*2+1],dat[i*2+2]);
    }
  }
  int _min(int a,int b,int k,int l,int r){
    if(r<=a||b<=l)return INF;
    if(a<=l&&r<=b){
      return dat[k];
    }else{
      int vl = _min(a,b,k*2+1,l,(l+r)/2);
      int vr = _min(a,b,k*2+2,(l+r)/2,r);
      return min(vl,vr);
    }
  }
  int qmin(int a,int b){
    return _min(a,b,0,0,n);
  }
};

vi lst[200010];
rmq Q;
int result;
int cnt = 0;

int main(){
  int _n;
  cin>>_n;
  int n = 1;
  while(n<_n) n<<=1;
  REP(i,_n) cin>>dat[i+n-1];

  // ??§??§
  set<int> S;
  REP(i,_n) S.insert(dat[i+n-1]);
  set<int>::iterator iter = S.begin();
  int x = 1;
  map<int,int> mp;
  while(iter != S.end()){
    mp[*iter] = x++;
    ++iter;
  }
  REP(i,_n) dat[i+n-1] = mp[dat[i+n-1]];
  S.clear();

  // value list
  REP(i,_n) lst[dat[i+n-1]].push_back(i);
  // REP(i,200010) reverse(ALL(lst[i]));

  // RMQ
  Q.init(_n);
  REP(i,_n) Q.update(i,dat[i+n-1]);

  result = 0;
  stack< pair<pii,int> > st;
  st.push(make_pair(MP(0,_n),0));
  while(!st.empty()){
    pair<pii,int> pp = st.top(); st.pop();
    int l = pp.first.first;
    int r = pp.first.second;
    int lastval = pp.second;
    if(l>=r)continue;
    int minval = Q.qmin(l,r);
    int pos = *lst[minval].rbegin(); lst[minval].pop_back();
    if(minval != lastval) ++result;
    lastval = minval;
    st.push(make_pair(MP(l,pos),lastval));
    st.push(make_pair(MP(pos+1,r),lastval));
  }
  cout<<result<<endl;
  return 0;
}

Measured memory_bytes: 26588
n = int(input())
S = input()

E = [0] * n
W = [0] * n

for i in range(0, n):
    if i < n - 1:
        if S[i] == "W":
            E[i+1] = E[i] + 1
        else:
            E[i+1] = E[i]
        if S[n-i-1] == "E":
            W[n-i-2] = W[n-i-1] + 1
        else:
            W[n-i-2] = W[n-i-1]
min_so_far = n
for i in range(n):
    c = E[i]+ W[i]
    if min_so_far > c:
        min_so_far = c
print (min_so_far)

Measured memory_bytes: 76092
#include "bits/stdc++.h"
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr_inv(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define rep(i,n) repr(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
#define PI 3.1415926535
using namespace std;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n;

	long long ans;

	string s1, s2;

	cin>>n>>s1>>s2;

	vector<bool> flag;

	rep(i, n){
		if(s1[i]==s2[i]){
			flag.push_back(true);
		}else{
			flag.push_back(false);
			i++;
		}
	}
	if(flag[0]){
		ans=3;
	} else{
		ans=6;
	}
	repr(i, 1, (int)flag.size()){
		if(flag[i-1]&&flag[i]){
			ans*=2;
		} else if(flag[i-1]&&!flag[i]){
			ans*=2;
		} else if(!flag[i-1]&&!flag[i]){
			ans*=3;
		}
		if(ans>MOD) ans=ans%MOD;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.math.*;
class Main{
    static int[] prime, map, check;
    static int n, x, sum;
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try {
	    prime = new int[1000001];
	    sieve();
	    while(true){
		String[] st = sc.readLine().split(" ");
		n = Integer.valueOf(st[0]);
		x = Integer.valueOf(st[1]);
		if(n==0 && x==0)
		    break;
		map = new int[n];
		for(int i=0; i<n; i++)
		    map[i] = Integer.valueOf(sc.readLine());
		check = new int[x+1];
		sum = 0;
		solve();
		String out = "NA";
		for(int i=x; i>=0; i--)
		    if(check[i]==1 && prime[i]==0){
			out = String.valueOf(i);		
			break;
		    }
		System.out.println(out);
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
    static void solve(){
	check[0] = 1;
	for(int i=0; i<=x; i++)
	    if(check[i]==1)
		for(int j=0; j<n; j++)
		    if(i+map[j]<=x)
			check[i+map[j]] = 1;
    }
    static void sieve(){
	prime[0] = 1; prime[1] = 1;
	for(int i=2; i<1000; i++)
	    if(prime[i]==0)
		for(int j=i*i; j<1000000; j+=i)
		    prime[j] = 1;
    }
}

Measured memory_bytes: 23000
// Author: Amey Bhavsar
// IDE: Geany/Ubuntu
// Platform: ---

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;

#define bpc __builtin_popcount
#define bpcl __builtin_popcountll
#define bpr __builtin_parity
#define bprl __builtin_parityll
#define ctz __builtin_ctz
#define ctzl __builtin_ctzll
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define repD(i,a,b) for(auto i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second


// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal
// traversal function to avoid long template definition
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define uint32 int64_t

ll gcd(ll a, ll b) {
	if (a%b == 0) return b;
	return gcd(b,a%b);
}
int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	ll k;
	cin >> k;
	ll s = 0;
	rep(i,1LL,k+1) {
	rep(j,1LL,k+1) {
	rep(l,1LL,k+1) {
		s += gcd(gcd(i,j),l);
	}}}
	
	cout << s << "\n";
		
	
		
	return 0;
}


Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll XS,YS,XT,YT;
int N;
double X[5050],Y[5050],R[5050];
double D[5050];



void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>X[0]>>Y[0]>>X[1]>>Y[1];
	R[0]=R[1]=0;
	cin>>N;
	FOR(i,N) {
		cin>>X[i+2]>>Y[i+2]>>R[i+2];
	}
	N+=2;
	for(i=1;i<N;i++) D[i]=1e15;
	
	priority_queue<pair<double,int>> P;
	P.push({0,0});
	
	while(P.size()) {
		double cost=-P.top().first;
		int cur=P.top().second;
		P.pop();
		if(cost!=D[cur]) continue;
		
		FOR(i,N) if(i!=cur) {
			double d=hypot(X[i]-X[cur],Y[i]-Y[cur])-R[i]-R[cur];
			if(d<0) d=0;
			if(D[i]>D[cur]+d) {
				D[i]=D[cur]+d;
				P.push({-D[i],i});
			}
		}
	}
	
	
	_P("%.12lf\n",D[1]);
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 4592
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
   
   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       int A = sc.nextInt();
       int B = sc.nextInt();
        

        System.out.println(A <=8 && B<= 8? "Yay!":":(");
        
    }
}


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

typedef long long ll;
const int MOD = 1e9 + 7;

const int Nmax = 2e5 + 10;
int f[Nmax], c[Nmax];

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

bool merge(int x, int y) {
	int rx = find(x), ry = find(y);
	if (rx == ry)
		return false;
	f[ry] = rx;
	c[rx] += c[ry];
	return true;
}

int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; ++i) {
		f[i] = i;
		c[i] = 1;
	}
	for (int i = 0; i < m; ++i) {
		int x, y;
		cin >> x >> y;
		--x, --y;
		merge(x, y);
	}
	int res = 0;
	for (int i = 0; i < n; ++i)
		if (find(i) == i)
			res = max(res, c[i]);
	cout << res << '\n';
	return 0;
}

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

typedef long long ll;

using namespace std;

string solve(int n, string s) {
    
    if(s.size()<=n)
        return s;
    
    s=s.substr(0,n)+"...";
    return s;
}

int main() {
    
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    string s;
    int n;
    cin>>n>>s;
    cout<<solve(n, s);
}


Measured memory_bytes: 3616
#include<stdio.h>

int main(void){
    int n,k,x;
    int y=0;
    int sam=0;
    int str[1000];

    scanf("%d %d", &n, &k);
    for(int i=1; i<=n; i++){
        scanf("%d", &str[i-1]);
    }

    for(int i=1; i<=k; i++){
    x = str[y];
    for(int i=1; i<n; i++){
        if(str[i] <= x){
            x = str[i];
            y = i;
        }
    }
    sam = sam + x;
    str[y] = 1000;
    x=0;
    y=0;
    }

    printf("%d",sam);

    return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <cmath>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long int ll;

int main() {
  string S, T, U;
  int A, B;
  cin >> S >> T >> A >> B >> U;
  if (S == U) A--;
  else B--;
  cout << A << " " << B << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n=0,m,a,b,c,d,e;
	long double z,w;
	string str,str2,str3;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>str;
	if(str[0]=='9'||str[1]=='9'){
		cout<<"Yes";
	}else{cout<<"No";}
	








	cout<<endl;
} 


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define M 2000001
#define k 10001

int main(){
  int *A, *B;
  int C[k];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(int) * n + 1);
  B = malloc(sizeof(int) * n + 1);

  for ( i = 0; i <= k; i++ ) C[i] = 0;

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

  for ( i = 1; i <= k; i++ ) C[i] = C[i] + C[i - 1];

  for ( j = 1; j <= n; j++ ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 16272
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
    long long int i, j, k, n, ans=0, po=0, x[5];
    char a;
    scanf("%lld", &n);
    printf("%lld", n+n*n+n*n*n);
    
}

Measured memory_bytes: 1688
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int n = sc.nextInt();
        for(int i = 1; i < 10; i++){
            if(n%i==0 && n/i<10) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 23764
def min_num_part_sum(a,A):
    N=len(a)
    inf=float('inf')
    dp=[inf for i in range(A+1)]
    dp[0]=0
    for i in range(N):
        for j in range(A+1):
            if a[i]<=j:
                dp[j]=min(dp[j-a[i]]+1,dp[j])
            else:
                dp[j]=dp[j]
    return dp[A]

can_pay=[1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049]

n=int(input())

print(min_num_part_sum(can_pay,n))

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

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

int main(void){

    string str;
    cin >> str;

    if(str == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;

    return 0;
}

Measured memory_bytes: 3628
//https://vjudge.net/contest/342760#problem/A
/*
* Author : MaxSally
*/
/********   All Required Header Files ********/
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i <= k ; ++i)
#define rrep(i, j, k) for (int i = j; i >= k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
#define inf (int) (1e9 + 7)
#define epsi 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define read(type) readInt<type>()
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define left tuyiuoi
#define right fgjhk
#define ss second
#define ff first
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) rep(i, l, r) cout << a[i] << " "; cout << endl
#define Flag(n) cout << "here " << n << endl
const double pi=acos(-1.0);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

const int N = 100005;
int n, a[N];

int main(){
    io;
    //freopen("input.txt", "r", stdin);
    cin >> n;
    int totalSum = 0;
    rep(i, 1, n){
        cin >> a[i];
        totalSum ^= a[i];
    }
    cout << (totalSum == 0? "Yes": "No");

    return 0;
}



Measured memory_bytes: 768
#include<stdio.h>
int main()
{
  int k,s;
  scanf("%d%d",&k,&s);
  
  int count=0;
  
  for(int x=0;x<=k;x++){
    for(int y=0;y<=k;y++){
      int z=s-x-y;
      if(z>=0&&z<=k)count+=1;
    }
  }
  
  printf("%d",count);
  
  return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

int main(){
    string s, t;
    cin >> s >> t;
    vector<int> start(26, -1);
    vector<int> goal(26, -1);

    for(int i = 0; i < s.size(); i++){
        int a = s[i] - 'a';
        int b = t[i] - 'a';

        if(start[a] != -1 || goal[b] != -1){
            if(start[a] != b || goal[b] != a){
                cout << "No" << endl;
                return 0;
            }
        }

        start[a] = b;
        goal[b] = a;
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
map<string,ll>mp;
map<ll,ll>mpp;

int main(){

     double n,m,k,s=0,t;

     cin>>n;
     ll i,j=100;

    double tt=100.0;

    for(i=1;;i++){

        tt=j+j*.01;
        j=tt;
        if(j>=n)break;
    }
    cout<<i<<endl;

}


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

using ll = long long;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define rep(i,n) for_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

int n, x;

int main(){
	cin.tie(0);
	
	while(cin>>n>>x,n||x) {
	    int c = 0;
	    for_(i, 1, n+1) {
	        for_(j, i+1, n+1) {
	            if(x-i-j>j && x-i-j<=n)c++;
	        }
	    }
	    cout<<c<<endl;
	}
	
	return 0;
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
    ll x=0,w=0;char ch=getchar();
    while(!isdigit(ch))w|=ch=='-',ch=getchar();
    while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    return w?-x:x;
}
int a[1000000],b[1000000];
int main()
{
    int n=read();int m=0;
    reg int i,gs,j;
    for(i=1;i<=n;++i)a[i]=read();
    for(i=n;i>=1;--i)
    {
        gs=0;
        for(j=2;j*i<=n;++j)
            gs+=b[j*i];
        gs%=2;
        if(a[i])
        {
            if(gs==0)b[i]=1;
        }
        else
        {
            if(gs)b[i]=1;
        }
    }
    for(i=1;i<=n;++i)m+=b[i];
    cout<<m<<"\n";
    for(i=1;i<=n;++i)
        if(b[i])cout<<i<<" ";cout<<"\n";
    return 0;
}

Measured memory_bytes: 5760