akhauriyash/Code-Regression huggingface dataset:
import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
import torch.nn.parallel
import torch.optim
import torch.utils.data
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda


@triton.jit
def triton_per_fused_mse_loss_mul_0(in_out_ptr0, in_ptr0, in_ptr1, xnumel,
    rnumel):
    XBLOCK: tl.constexpr = 1
    RBLOCK: tl.constexpr = 256
    xoffset = tl.program_id(0) * XBLOCK
    tl.full([1], xoffset, tl.int32)
    tl.full([RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[:]
    tl.full([RBLOCK], True, tl.int1)
    r0 = rindex
    tmp0 = tl.load(in_ptr0 + r0, None)
    tmp1 = tl.load(in_ptr1 + r0, None)
    tmp2 = tmp0 - tmp1
    tmp3 = tmp2 * tmp2
    tmp4 = tl.broadcast_to(tmp3, [RBLOCK])
    tmp6 = triton_helpers.promote_to_tensor(tl.sum(tmp4, 0))
    tmp7 = 256.0
    tmp8 = tmp6 / tmp7
    tmp9 = 1.0
    tmp10 = tmp8 * tmp9
    tl.debug_barrier()
    tl.store(in_out_ptr0 + tl.full([1], 0, tl.int32), tmp10, None)


def call(args):
    arg0_1, arg1_1 = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg1_1, (4, 4, 4, 4), (64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((), (), torch.float32)
        buf1 = buf0
        del buf0
        get_raw_stream(0)
        triton_per_fused_mse_loss_mul_0[grid(1)](buf1, arg1_1, arg0_1, 1, 
            256, num_warps=2, num_stages=1)
        del arg0_1
        del arg1_1
    return buf1,


class MSELossNew(nn.Module):

    def __init__(self, ratio=1, size_average=None, reduce=None, reduction=
        'mean'):
        super(MSELossNew, self).__init__()
        self.ratio = ratio
        self.size_average = size_average
        self.reduce = reduce
        self.reduction = reduction

    def forward(self, input_0, input_1):
        arg0_1 = input_0
        arg1_1 = input_1
        output = call([arg0_1, arg1_1])
        return output[0]


Measured latency_ms: 0.022953
import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor


@triton.jit
def triton_poi_fused_renorm_0(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x1 = xindex // 4
    tmp0 = tl.load(in_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + 4 * x1, xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr0 + (1 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr0 + (2 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp9 = tl.load(in_ptr0 + (3 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp2 = tmp1 * tmp1
    tmp4 = tmp3 * tmp3
    tmp5 = tmp2 + tmp4
    tmp7 = tmp6 * tmp6
    tmp8 = tmp5 + tmp7
    tmp10 = tmp9 * tmp9
    tmp11 = tmp8 + tmp10
    tmp12 = libdevice.sqrt(tmp11)
    tmp13 = 1.0
    tmp14 = tmp12 > tmp13
    tmp15 = 1e-07
    tmp16 = tmp12 + tmp15
    tmp17 = tl.full([1], 1, tl.int32)
    tmp18 = tmp17 / tmp16
    tmp19 = tmp18 * tmp13
    tmp20 = tl.where(tmp14, tmp19, tmp13)
    tmp21 = tmp0 * tmp20
    tl.store(out_ptr0 + x2, tmp21, xmask)


def call(args):
    primals_1, primals_2, primals_3 = args
    args.clear()
    assert_size_stride(primals_1, (4, 4), (4, 1))
    assert_size_stride(primals_2, (4,), (1,))
    assert_size_stride(primals_3, (4, 4, 4, 4), (64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_renorm_0[grid(16)](primals_1, buf0, 16, XBLOCK=16,
            num_warps=1, num_stages=1)
        buf1 = empty_strided_cuda((64, 4), (4, 1), torch.float32)
        extern_kernels.addmm(primals_2, reinterpret_tensor(primals_3, (64, 
            4), (4, 1), 0), reinterpret_tensor(buf0, (4, 4), (1, 4), 0),
            alpha=1, beta=1, out=buf1)
        del primals_2
        buf2 = torch.ops.aten.set_.source_Tensor(primals_1, buf0)
        assert_size_stride(buf2, (4, 4), (4, 1))
        del primals_1
    return reinterpret_tensor(buf1, (4, 4, 4, 4), (64, 16, 4, 1), 0
        ), reinterpret_tensor(primals_3, (64, 4), (4, 1), 0)


class LinearWithConstraintNew(nn.Linear):

    def __init__(self, *args, max_norm=1, **kwargs):
        self.max_norm = max_norm
        super(LinearWithConstraintNew, self).__init__(*args, **kwargs)

    def forward(self, input_0):
        primals_1 = self.weight
        primals_2 = self.bias
        primals_3 = input_0
        output = call([primals_1, primals_2, primals_3])
        return output[0]


Measured latency_ms: 0.026845
import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.utils.data
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda


@triton.jit
def triton_poi_fused_mul_0(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + 0)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK])
    tmp2 = tl.load(in_ptr1 + x0, xmask)
    tmp3 = tmp1 * tmp2
    tl.store(out_ptr0 + x0, tmp3, xmask)


def call(args):
    primals_1, primals_2 = args
    args.clear()
    assert_size_stride(primals_1, (1,), (1,))
    assert_size_stride(primals_2, (4, 4, 4, 4), (64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_mul_0[grid(256)](primals_1, primals_2, buf0, 256,
            XBLOCK=128, num_warps=4, num_stages=1)
        del primals_1
    return buf0, primals_2


class alphaNew(nn.Module):

    def __init__(self, alpha_val=0):
        super(alphaNew, self).__init__()
        self.alpha = nn.Parameter(torch.Tensor([alpha_val]))
        self.alpha.requires_grad = True

    def forward(self, input_0):
        primals_1 = self.alpha
        primals_2 = input_0
        output = call([primals_1, primals_2])
        return output[0]


Measured latency_ms: 0.015067
import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda


@triton.jit
def triton_poi_fused_add_mul_0(in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x0 = xindex % 16
    x2 = xindex // 64
    tmp0 = tl.load(in_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr1 + 0)
    tmp2 = tl.broadcast_to(tmp1, [XBLOCK])
    tmp3 = tl.load(in_ptr2 + (x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp4 = tmp2 * tmp3
    tmp5 = tmp0 + tmp4
    tl.store(out_ptr0 + x3, tmp5, xmask)


def call(args):
    primals_1, primals_2 = args
    args.clear()
    assert_size_stride(primals_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(primals_2, (1,), (1,))
    buf0 = empty_strided_cuda((4, 1, 4, 4), (16, 16, 4, 1), torch.float32)
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf1 = torch.ops.aten.normal_functional.default(buf0)
        del buf0
        buf2 = buf1
        del buf1
        buf3 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_add_mul_0[grid(256)](primals_1, primals_2, buf2,
            buf3, 256, XBLOCK=128, num_warps=4, num_stages=1)
        del primals_1
        del primals_2
    return buf3, buf2


class NoiseInjectionNew(nn.Module):

    def __init__(self):
        super().__init__()
        self.weight = nn.Parameter(torch.zeros(1))

    def forward(self, input_0):
        primals_2 = self.weight
        primals_1 = input_0
        output = call([primals_1, primals_2])
        return output[0]


Measured latency_ms: 0.013831
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int A, B, C;
	cin >> A >> B >> C;
	if(max(max(A, B), C) == A){
		cout << 10 * A + B + C << endl;
	}
	else if(max(max(A, B), C) == B){
		cout << 10 * B + A + C << endl;
	}
	else{
		cout << 10 * C + A + B << endl;
	}
	return 0;
}

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

void solver() {
  long long x;
  cin >> x;

  long ans = 0;
  long mo = 100;
  while(mo < x) {
    mo = mo * 1.01;
    ans++;
  }
  cout << ans << "\n";
}

int main() {
  solver();
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
ll s[5000],e[5000],c[5000],v[2500],v1[2500];	ll n,m,p;
ll ans[2500];
ll ans2[2500];

int main() {
	cin>>n>>m>>p;
	for(ll i=0;i<m;i++){
		cin>>s[i]>>e[i]>>c[i];
		s[i]--;e[i]--;
		c[i]*=-1;
		c[i]+=p;
	}
	for(ll i=0;i<2500;i++){
		v[i]=INF;
		ans[i]=INF;
		ans2[i]=INF;
	}
	v[0]=0;
	ans[0]=0;
	ans2[n-1]=0;
	for(ll i=0;i<n+100;i++){
		for(ll j=0;j<m;j++){
		ll now=s[j];
		ll next=e[j];
		v[next]=min(v[next],v[now]+c[j]);
		ans[next]=min(ans[next],ans[now]);
		ans2[now]=min(ans2[now],ans2[next]);
		}
	}
	for(ll i=0;i<n;i++){
		v1[i]=v[i];
	}
	for(ll i=0;i<1;i++){
		for(ll j=0;j<m;j++){
		ll now=s[j];
		ll next=e[j];
		v[next]=min(v[next],v[now]+c[j]);
		}
	}
	for(ll i=0;i<n;i++){
		if(v[i]<v1[i]&&ans[i]==0&&ans2[i]==0){
			cout << -1;
			return 0;
		}
	}
	if(v[n-1]>0){
		cout << 0;
	}
	else{
	cout << abs(v[n-1]);
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 384
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=1e5+5;
char s[N];int sum[N],n,las;
int main(){
	scanf("%s",s+1),n=strlen(s+1);
	las=0;
	fp(i,1,n){
		if(s[i]=='L'&&s[i-1]=='R')las=i,++sum[i];
		if(s[i]=='L'&&s[i-1]=='L')++sum[las-((i-las)&1)];
	}
	las=0;
	fd(i,n,1){
		if(s[i]=='R'&&s[i+1]=='L')las=i,++sum[i];
		if(s[i]=='R'&&s[i+1]=='R')++sum[las+((las-i)&1)];
	}
	fp(i,1,n)printf("%d%c",sum[i]," \n"[i==n]);
	return 0;
}

Measured memory_bytes: 896
N = int(input())
B = list(map(int, input().split()))
M = 0
for i in range(N):
  if B[i] > i+1:
    M = -1
if M != -1:
  L = []
  for j in range(N):
    s = 0
    for k in range(len(B)):
      if B[k] == k+1:
        s = k
    L.insert(0, s+1)
    del B[s]
  for m in range(N):
    print(L[m])
else:
  print(M)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

const int MOD = 998244353;

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

  long sum = 0;
  vector<int> a(n);

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

  vector<vector<long>> dp(n+1, vector<long>(sum+1, 0));
  vector<vector<long>> dp2(n+1, vector<long>(sum+1, 0));

  dp[0][0] = 1;
  dp2[0][0] = 1;
  for (int i = 0; i < n; i++) {
    long ai = a[i];
    for (long j = 0; (j + ai) <= sum; j++) {
      // 新しいやつを赤にする場合
      dp[i+1][j+ai] += dp[i][j];
      dp[i+1][j+ai] %= MOD;
      // 新しいやつを緑または青にする場合
      dp[i+1][j] += 2 * dp[i][j];
      dp[i+1][j] %= MOD;

      dp2[i+1][j+ai] += dp2[i][j];
      dp2[i+1][j+ai] %= MOD;
      // 新しいやつを緑にする場合
      dp2[i+1][j] += dp2[i][j];
      dp2[i+1][j] %= MOD;
    }
  }

  long dp_sum = 0;
  for (long i = sum / 2 + 1; i <= sum; i++) {
    dp_sum += dp[n][i];
    dp_sum %= MOD;
  }
  
  long dp2_sum = 0;
  if (sum % 2 == 0) {
    dp_sum += dp[n][sum / 2];
    dp_sum %= MOD;
    dp2_sum += dp2[n][sum / 2];
    dp2_sum %= MOD;
  }

  long power_result = 1;
  for (int i = 0; i < n; i++) {
    power_result *= 3;
    power_result %= MOD;
  }

  long result;
  result = power_result - 3 * dp_sum + 3 * dp2_sum;
  result %= MOD;

  if (result < 0) {
    result += MOD;
  }

  cout << result << endl;

  return 0;
}

Measured memory_bytes: 423744
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef struct edge{
  edge(int a, int b):to(a),cost(b){};
  int to, cost;
}edge;
typedef struct state{
  state(int a, int b):v(a),cost(b){};
  int v, cost;
  bool operator<(const state s)const{return cost < s.cost;}
  bool operator>(const state s)const{return cost > s.cost;}
}state;

int dijkstra(vector<vector<edge> > &g, int start, int goal){
  priority_queue<state, vector<state>, greater<state> > que;
  que.push(state(start, 0));
  vector<int> ans(g.size(), 1e9);
  ans[start] = 0;
  while(not que.empty()){
    int v = que.top().v;
    int c = que.top().cost;
    que.pop();
    for (int i = 0; i < g[v].size(); i++) {
      int nv = g[v][i].to;
      if(ans[nv] > c + g[v][i].cost){
        ans[nv] = c + g[v][i].cost;
        que.push(state(nv, ans[nv]));
      }
    }
  }
  return ans[goal];
}

int main(){
  int n, m;
  std::cin >> n >> m;
  vector<vector<edge> > g(n);
  for (int i = 0; i < m; i++) {
    int a, b, c, d;
    scanf("%d,%d,%d,%d", &a, &b, &c, &d);
    a--, b--;
    g[a].push_back(edge(b, c));
    g[b].push_back(edge(a, d));
  }
  int start, goal, v, p;
  scanf("%d,%d,%d,%d", &start, &goal, &v, &p);
  start--, goal--;
  std::cout << v - p - (dijkstra(g, start, goal) + dijkstra(g, goal, start)) << std::endl;
  
  return 0;
}

Measured memory_bytes: 3160
package main

import (
	"fmt"
	"time"
)

const (
	yyyymmdd = "2006/01/02"
)

func main() {
	// solveA
	{
		// var dateS, resA string
		// _, _ = fmt.Scan(&dateS)
		// resA = solveA(dateS)
		// fmt.Println(resA)
	}

	//solveB
	{
		var n int
		fmt.Scan(&n)
		a := make([]float64, n)
		b := make([]string, n)

		for i := 0; i < n; i++ {
			fmt.Scan(&a[i])
			fmt.Scan(&b[i])
		}
		total := 0.0
		for index := 0; index < n; index++ {
			if b[index] == "JPY" {
				total += a[index]
			} else if b[index] == "BTC" {
				total += a[index] * 380000.0
			}
		}
		//res := solveB(a, b)
		fmt.Println(total)
	}
}

func solveA(dateS string) string {

	t1, _ := time.Parse(yyyymmdd, dateS)
	t2, _ := time.Parse(yyyymmdd, "2019/04/30")

	if t1.Unix() <= t2.Unix() {
		return "Heisei"
	} else {
		return "TBD"
	}
}

func solveB(a []float64, b []string) float64 {

	total := 0.0
	for index := 0; index < len(a); index++ {
		if b[index] == "JPY" {
			total += a[index]
		} else if b[index] == "BTC" {
			total += a[index] * 380000.0
		}
	}
	return total
}


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

#define col first
#define cn second

typedef pair<int, int> PR;

pair<int, int> puyo[10000+10] , tmp;

int sum;


int chek(int , /*PR[10000 + 10],*/ int ,int,int);


int main()
{
	int n;
	int pn=0;

	int a;

	int i;

	int sa=0;

	while (cin >> n, n != 0)
	{
		sa = 0;
		sum = n;
		pn = 0;

		cin >> a;
		puyo[pn].col = a;
		puyo[pn].cn = 1;


		for (i = 1; i < n; i++)
		{
			cin >> a;

			if (puyo[pn].col == a)
			{
				puyo[pn].cn++;
			}
			else
			{
				pn++;
				puyo[pn].col = a;
				puyo[pn].cn = 1;
			}
		}

		pn++;

		for (i = 1; i < pn - 1; i++)
		{

			if (puyo[i].cn == 3)
			{
				if (puyo[i + 1].col == puyo[i - 1].col && puyo[i + 1].cn + puyo[i - 1].cn >= 5)
				{
					//tmp = puyo[i + 1];
					//puyo[i + 1].cn--;

					sa = 3 + puyo[i + 1].cn + puyo[i - 1].cn;

					sum = min(sum, n - chek(pn, i - 2, i + 2, sa));
					//puyo[i + 1] = tmp;
				}
			}

			if( puyo[i+1].cn==1 && puyo[i].col == puyo[i+2].col )
			{
				if (puyo[i].cn + puyo[i + 2].cn >= 3)
				{
					//puyo[i + 1].cn--;
					sa = 1 + puyo[i].cn + puyo[i + 2].cn;

					sum = min(sum, n - chek(pn, i - 1, i + 3, sa));
					
				}
			}

			if (puyo[i - 1].cn == 1 && puyo[i].col == puyo[i - 2].col)
			{
				if (puyo[i].cn + puyo[i - 2].cn >= 3)
				{
					//puyo[i - 1].cn--;
					sa = 1 + puyo[i].cn + puyo[i - 2].cn;

					sum = min(sum, n - chek(pn, i - 3, i + 1, sa));
				}
			}
		}
		cout << sum << endl;
	}
	return 0;
}


int chek(int pn/*, PR tp[10000 + 10]*/, int go, int ba , int sa)
{
	if (puyo[go].col == puyo[ba].col && puyo[go].cn + puyo[ba].cn >= 4)
	{
		sa += puyo[go].cn + puyo[ba].cn;

		if (go - 1 >= 0 && ba < pn)
		{
			return chek(pn, go - 1, ba + 1, sa);
		}

	}

	return sa;
}

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

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

    if(s[0]==s[1]&&s[1]==s[2]){puts("No");} 
    else{puts("Yes");}
}

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

int main(){
    int n; cin >> n; bool flg = true;
    for (auto i = 0; i < n; i++) {
        int a; cin >> a;
        if(a % 2 == 0) flg &= true;
        else flg &= false;
    }

    cout << ((flg) ? "second" : "first") << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>

typedef long double ld;
typedef long long ll;

using namespace std;

#define MAXN (1 << 20)

int n, m;
vector<int> a[MAXN];
int h[MAXN];
int g[MAXN];

int main() {
	cin >> n >> m;
	memset(g, 0, sizeof(g));
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
	}

	for (int i = 0; i < m; i++) {
		int v1, v2;
		cin >> v1 >> v2;
		a[v1].push_back(v2);
		a[v2].push_back(v1);
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < a[i].size(); j++) {
			if (h[a[i][j]] >= h[i]) {
				g[i] = 1;
			}
		}
	}

	int ret = 0;
	for (int i = 1; i <= n; i++) {
		ret += 1 - g[i];
	}

	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 35468
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
int main(){
    long long i,j,n,q,ans=0,a[100010]={},b[100010]={},c[100010]={},d[100010]={};
    scanf("%lld",&n);
    for(i=0; i<n; i++){
        scanf("%lld",&a[i]);
        d[a[i]]++;
        ans+=a[i];
    }
    scanf("%lld",&q);
    for(i=0; i<q; i++){
        scanf("%lld %lld",&b[i],&c[i]);
        ans+=(c[i]-b[i])*d[b[i]];
        printf("%lld\n",ans);
        d[c[i]]+=d[b[i]];
        d[b[i]]=0;
    }
    return 0;
}

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

int N, M;
vector<int> s, c;

bool ok(string str) {
    if (str.size() != N) return false;
    for (int i = 0; i < M; ++i) if (str[s[i]] != (char)(c[i] + '0')) return false;
    return true;
}

string solve() {
    for (int i = 0; i <= 999; ++i) {
        stringstream iss; iss << i;
        string str = iss.str();
        if (ok(str)) return str;
    }
    return "-1";
}

int main() {
    cin >> N >> M;
    s.resize(M); c.resize(M);
    for (int i = 0; i < M; ++i) cin >> s[i] >> c[i], --s[i];
    cout << solve() << endl;
}

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

using namespace std;

int c[13] , n , m , a[13][13] , S , col[13];

int main()
{
    int x;
    cin >> n >> m >> S;
    for(int i = 1 ; i <= n ; i++)
    {
        cin >> c[i];
        int p = 0;
        for(int j = 1 ; j <= m ; j++)
        {
            cin >> x;
            a[i][j] = x;
            p = max(p , x);
        }
    }
    int ansmn = 1e9;
    for(int i = 0 ; i < (1 << n) ; i++)
    {
        int s = 0 , sum = 0;
        for(int j = 0 ; j < n ; j++)
            if(i & (1 << j))
            {
                sum += c[j + 1];
                for(int k = 1 ; k <= m ; k++)
                    col[k] += a[j + 1][k];
            }
        bool ok = true;
        for(int k = 1 ; k <= m ; k++)
            ok &= (col[k] >= S);
        if(ok)
            ansmn = min(ansmn , sum);
        for(int k = 1 ; k <= m ; k++)
            col[k] = 0;
    }
    if(ansmn == 1e9)
        cout << "-1\n";
    else cout << ansmn << "\n";
    return 0;
}


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

const int MAXN = 200010;
const int mod = 1000000007;
typedef long long LL;
void reduce(int & x) { x += x >> 31 & mod; }
int mul(int a, int b) { return (LL) a * b % mod; }
int pow(int a, int b, int res = 1) {
	for (; b; b >>= 1, a = mul(a, a)) if (b & 1) res = mul(res, a);
	return res;
}
int head[MAXN], nxt[MAXN], n, hav[MAXN];
typedef std::vector<int> VI;
typedef VI::iterator it;
VI dp[MAXN][3];
void dfs(int u, int dep = 0) {
	++hav[dep]; int ma = 0;
	for (int i = head[u]; i; i = nxt[i]) {
		dfs(i, dep + 1);
		if (dp[i][0].size() > dp[u][0].size())
			for (int j = 0; j != 3; ++j)
				dp[u][j].swap(dp[i][j]);
		const int S = dp[i][0].size(); ma = std::max(ma, S);
		const int R = dp[u][0].size();
		for (int j = 0; j != S; ++j) {
			static int a[3]; a[0] = a[1] = a[2] = 0;
			for (int k = 0; k != 3; ++k)
			for (int l = 0; l != 3; ++l)
			reduce(a[std::min(k + l, 2)] += mul(dp[u][k][R - j - 1], dp[i][l][S - j - 1]) - mod);
			for (int k = 0; k != 3; ++k) dp[u][k][R - j - 1] = a[k];
		}
	}
	const int R = dp[u][0].size();
	for (int j = 0; j != ma; ++j) {
		reduce(dp[u][0][R - j - 1] += dp[u][2][R - j - 1] - mod);
		dp[u][2][R - j - 1] = 0;
	}
	dp[u][0].push_back(1);
	dp[u][1].push_back(1);
	dp[u][2].push_back(0);
}

int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1, t; i <= n; ++i)
		std::cin >> t, nxt[i] = head[t], head[t] = i;
	VI res = (dfs(0), dp[0][1]); int ans = 0;
	const int R = res.size();
	for (int i = 0; i != R; ++i)
		reduce(ans += pow(2, n + 1 - hav[i], res[R - i - 1]) - mod);
	std::cout << ans << std::endl;
	return 0;
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (b - a == c - b)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

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

int main(){
	string s; cin >> s;
	int ans = 114514;
	for(int i = 0; i < 26; ++i){
		char a = 'a' + i;
		string c; c += a;
		string anss;
		for(int j = 0; j < s.size(); ++j){
			anss += c;
		}
		string subs = s;
		int count = 0;
		while(1){
			if(anss == subs){
				if(ans > count){
					ans = count;
				}
				break;
			}
			for(int j = 0; j < s.size() - 1; ++j){
				if(subs[j + 1] == a && subs[j] != a){
					subs[j] = a;
				}
			}
			++count;
			subs.pop_back();
			anss.pop_back();
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque
H, W = map(int, input().split())
si, sj = map(int, input().split())
gi, gj = map(int, input().split())
si, sj, gi, gj = si-1+2, sj-1+2, gi-1+2, gj-1+2
X = [[1] * (W + 4)] * 2 + [[1] * 2 + [1 if a == "#" else 0for a in input()] + [1] * 2 for _ in range(H)] + [[1] * (W + 4)] * 2
H += 4
W += 4

Y = [(-1, 0), (0, -1), (0, 0), (0, 1), (1, 0)]
Z = [(-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-1, -2), (-1, -1), (-1, 1), (-1, 2), (0, -2), (0, 2), (1, -2), (1, -1), (1, 1), (1, 2), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2)]

def BFS():
    Q = deque([(si, sj)])
    D = [-1] * (H * W)
    D[si*W + sj] = 0
    while Q:
        i, j = Q.popleft()
        x = i * W + j
        for di, dj in Y:
            ni, nj = i+di, j+dj
            y = ni * W + nj
            if X[ni][nj] == 0:
                if D[y] == -1 or D[y] > D[x]:
                    D[y] = D[x]
                    Q.appendleft((ni, nj))
        for di, dj in Z:
            ni, nj = i+di, j+dj
            y = ni * W + nj
            if X[ni][nj] == 0:
                if D[y] == -1:
                    D[y] = D[x] + 1
                    Q.append((ni, nj))
    return D[gi * W + gj]

print(BFS())

Measured memory_bytes: 98148
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int gcd(int a, int b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	ll l, r;
	cin >> l >> r;
	if((r - l) > 1e4){
		cout << 0 << endl;
		return 0;
	}
	ll ans = 1e18;
	for(ll i = l; i < r; i++)
		for(ll j = i + 1; j <= r; j++) ans = min(ans, ((i * j) % 2019));
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define rep2(i,s,t) for(int i = s; i <= t; ++i)
#define rev(i,n) for(int i = n-1; i >= 0; --i)
#define rev1(i,n) for(int i = n; i > 0; --i)
#define rev2(i,s,t) for(int i = s; i >= t; --i)
#define F first
#define S second
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
using vii = vector<vi>;
typedef long long ll;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};


int main()
{
  int n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];

  vector<mint> sum(n+1);
  sum[0].x = 0;
  rep(i,n) sum[i+1] = (mint)a[i] + sum[i];

  mint res;
  rep(i,n) {
    res += (mint)a[i] * (sum[n] - sum[i+1]);
  }
  cout << res.x << "\n";
  
  return 0;
}


Measured memory_bytes: 6428
import sys
from pprint import pprint

def solve(n, a, b, c):
    ans = 0
    pre = -1
    for a_i in a:
        # print(a_i)
        ans += b[a_i-1]
        if pre + 1 == a_i:
            ans += c[pre-1]
        pre = a_i

    print(ans)

if __name__ == '__main__':
  n = int(sys.stdin.readline().strip())
  a = list(map(int, sys.stdin.readline().strip().split(" ")))
  b = list(map(int, sys.stdin.readline().strip().split(" ")))
  c = list(map(int, sys.stdin.readline().strip().split(" ")))
  # pprint(a)
  # pprint(b)
  # pprint(c)
  solve(n, a, b, c)

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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)

#define ll long long

#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));

int main(){
	int N,M;
  cin >> N >> M;
  froop1(1,10001){
   if(floor(i * 0.08) == N){
     if(floor(i * 0.10) == M){
       cout << i << endl;
       return 0;
     }
   }
  }
  cout << -1 << endl;
return 0;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
char str[1000005];
int main()
{
  scanf("%s",&str);
  int leng=strlen(str);
  int ans=0,i=0;
 for(;;)
    {
      if(str[i]=='J')
	{
	  int a=0,b=0,c=0;
	  while(str[i]=='J' && i<leng)
	    {
	      i++; a++;
	    }
	  while(str[i]=='O' && i<leng)
	    {
	      i++;
	      b++;
	    }

	  while(str[i]=='I' && i<leng)
	    {
	      i++;
	      c++;
	    }
	  if(b<=a && b<=c)
	    {
	      ans=max(ans,b);
	    }
		if(i==leng) break;
	}else{
	    i++;
            if(i==leng) break;
	}

    }

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

Measured memory_bytes: 1948
#include<stdio.h>

int main(){
    int n;
    scanf("%d", &n);
    char s[10001];
    int a[10001];
    scanf("%s", s);
    int x = 0;
    while(s[x] != '\0'){
        a[x] = s[x] - 'A' + n;
        if(a[x] >= 26){
            a[x] -= 26;
        }
        x++;
    }
    char ans[10001];
    for(int i=0; i<x; i++){
        ans[i] = 'A' + a[i];
    }
    ans[x] = '\0';
    printf("%s", ans);

    return 0;
}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int mod = 998244353;
struct modulo {
	int w;
	operator int&() { return w; }
	
	modulo() {}
	modulo(int w) { this->w = w; fix(); }
	void inline fix() { w %= mod; if (w < 0) w += mod; }
	modulo inline fix(int w) const { w %= mod; if (w < 0) w += mod; return w; }
	
	modulo& operator += (modulo b) { if ((w += b.w) >= mod) w -= mod; return *this; }
	modulo& operator -= (modulo b) { if ((w -= b.w) < 0) w -= mod; return *this; }
	modulo& operator *= (modulo b) { w = (num) w * b.w % mod; return *this; }
	modulo& operator /= (modulo b) { w = (num) w * b.inv() % mod; return *this; }
	modulo inline operator + (modulo b) { modulo r = *this; r += b; return r; }
	modulo inline operator - (modulo b) { modulo r = *this; r -= b; return r; }
	modulo inline operator * (modulo b) { modulo r = *this; r *= b; return r; }
	modulo inline operator / (modulo b) { modulo r = *this; r /= b; return r; }
	
	modulo inline inv() const {
		int a = w, m = mod, u = 0, v = 1, t;
		for (; a != 0; t = m / a, m -= t * a, swap(a, m), u -= t * v, swap(u, v));
		return fix(u);
	}
	
	modulo inline pow(int p) const {
		if (!w)  return 0;
		modulo a = *this, r = 1;
		for (; p > 0; a *= a, p >>= 1) if (p & 1) r *= a;
		return r;
	}
};
typedef modulo rem;

const int nsz = int(2e5);
rem n, m, k, inv[nsz + 5], fac[nsz + 5], ifc[nsz + 5], ans;

void inline init() {
	inv[1] = 1;
	circ (i, 2, n) {
		inv[i] = rem(-mod / i) * inv[mod % i];
	}
	fac[0] = ifc[0] = 1;
	cont (i, n) {
		fac[i] = fac[i - 1] * rem(i);
		ifc[i] = ifc[i - 1] * inv[i];
	}
}

rem inline C(int n, int m) { return fac[n] * ifc[m] * ifc[n - m]; }

rem inline f(int n, int k) { return C(n - 1, k) * m * (m - rem(1)).pow(n - k - 1); }

int main() {
	scanf("%d%d%d", &n, &m, &k);
	if (m == 1) {
		printf("%d\n", k == n - rem(1));
		return 0;
	}
	init();
	circ (i, 0, int(k)) {
		ans += f(n, i);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 6096
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
ll add(ll x,ll y)
{
return (x%hell+y%hell)%hell;
}
ll mul(ll x,ll y)
{
return ((x%hell)*(y%hell))%hell;
}
ll sub(ll x,ll y)
{
return (x-y+hell)%hell;
}
#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
   //cin>>t;
    for(int ok=1;ok<=t;ok++)
    {
      ll ans=0;
        ll n,d;
        cin>>n>>d;
        for(int i=1;i<=n;i++)
        {
          ll x,y;
            cin>>x>>y;

          ll o=(x*x+y*y);
          if(o<=d*d)
            ans++;
        }
        cout<<ans;
     
    }
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<stack>
#include<string>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < (n) ; ++i )
int main(){
  int n;
  cin >> n;
  while( n-- ){
    int cnt = 0;
    string str;
    stack<int> st;
    cin >> str;
    rep(i,str.size()) st.push(str[i]-'0');
    while(st.size() != 1){
      cnt++;
      int a = st.top(); st.pop();
      int b = st.top(); st.pop();
      int sum = a+b;
      if(sum>9) cnt++,sum = sum % 10 + 1;
      st.push(sum);
    }
    cout << (!(cnt%2) ? "Audrey" : "Fabre" ) << " wins." << endl;
  }
}

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

#define all(x) (x).begin(),(x).end()
#define endl '\n'
//#define int long long

bool isPal(string str) {
        string temp = str;
        reverse(all(temp));
        return temp == str;
}

signed main() { //[J][O][L][S][K][E][Y]
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        string str; cin >> str;
        int n = str.length();
        string a = str.substr(0, (n - 1) / 2);
        string b = str.substr((n + 3) / 2 - 1);
        cout << (isPal(str) && isPal(a) && isPal(b) ? "Yes" : "No");
        return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void Do(int N){
  int i, c, max;
  int H, h;
  scanf("%d", &H);
  c = max = 0;
  for(i = 1;i < N;i++){
    scanf("%d", &h);
    if(h <= H) c++;
    else c = 0;
    if(max < c) max = c;
    H = h;
  }
  printf("%d\n", max);
}   

int main(void){
  int N;
  scanf("%d", &N);
  Do(N);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
int main(void){
	int n,s[1000],i;
	double ex1,ex2,b;
	while(scanf("%d",&n),n){
                ex1=ex2=0;
		for(i=0;i<n;i++){
			scanf("%d",&s[i]);
			ex1+=s[i]*s[i];
			ex2+=s[i];
		}
		b=sqrt((ex1/n)-pow(ex2/n,2));
		printf("%.8f\n",b);
	}
	return 0;
}


Measured memory_bytes: 2112
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define REEP(i, N) for(ll i = N - 1; i >= 0; --i)
#define FOR(i,m,n) for(ll i = m; i < n; ++i)
#define RFOR(i,m,n) for(ll i = n - 1; i >= m; --i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define PB push_back
#define KIRIAGE(a, b) a += (b - a % b) % b // a を b の倍数値まで増やす
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;} // a / b 以上の最小整数
#define sp(n) setprecision(n)
#define INF 1000000000
#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
int dx8[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	int N, M;
	cin>>N>>M;
	vector<P> hito(N);
	vector<P> point(M);
	REP(i, N) cin>>hito[i].first>>hito[i].second;
	REP(i, M) cin>>point[i].first>>point[i].second;
	REP(i, N) {
		ll ans = -1;
		ll score = INF;
		REP(j, M) {
			if(abs(hito[i].first - point[j].first) + abs(hito[i].second - point[j].second) < score) {
				ans = j;
				score = abs(hito[i].first - point[j].first) + abs(hito[i].second - point[j].second);
			}

		}
		cout << ++ans << endl;
	}
}



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

using namespace std;

int main() {
    int N;
    cin >> N;
    int a[N+1];
    for(int i = 1; i<N+1; i++){
        cin >> a[i];
    }
    int count = 0;
    for(int i = 1; i<N+1; i++){
        if(i == a[a[i]]){
            count++;
        }
    }
    cout << count/2;

}

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

int main(){
    using namespace std;
    using tuplis = array<int, 3>;
    const int sq = 512;
    
    int n, q;
    cin >> n >> q;
    vector<int> c(n);
    for(int& i : c){
        cin >> i;
        i--;
    }
    vector<tuplis> query(q);
    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        l--;
        query[i] = {l, r, i};
    }
    sort(query.begin(), query.end(), [&](const tuplis& a, const tuplis& b){ if(a[0] / sq == b[0] / sq) return a[1] < b[1]; return a[0] < b[0]; });
    vector<int> ans(q);
    vector<int> cnt(n);
    int types = 0, L = 0, R = 0;
    for(auto [l, r, i] : query){
        while(L < l){
            cnt[c[L]]--;
            types -= !cnt[c[L]];
            L++;
        }
        while(L > l){
            L--;
            types += !cnt[c[L]];
            cnt[c[L]]++;
        }
        while(R > r){
            R--;
            cnt[c[R]]--;
            types -= !cnt[c[R]];
        }
        while(R < r){
            types += !cnt[c[R]];
            cnt[c[R]]++;
            R++;
        }
        ans[i] = types;
    }
    for(int i : ans) cout << i << ' ';
}

Measured memory_bytes: 15468
#include <stdio.h>


int main(){
	int a;
	int b;
	int c;
	scanf("%d %d %d", &a, &b, &c);

	int x[3] = {a, b, c};
	int i = 0;
	int j = 0;
	for (i = 0; i < 3; i++){
		for (j = 0; j < 2; j++){
			if (x[j]>x[j+1]){
				int temp = x[j + 1];
				x[j + 1] = x[j];
				x[j] = temp;
			}
		}
	}
	printf("%d %d %d\n", x[0], x[1], x[2]);

	return 0;
}


Measured memory_bytes: 2096
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,-1,0,1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
    if(a>b){
        a = b; return true;
    }
    else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
    if(a<b){
        a = b; return true;
    }
    else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
    cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
const ll mod = 1e9 + 7;
//const int mod = 998244353;

int a[1<<26];

int main(){
    string s; cin >> s;
    int n = s.size();
    rep(i,1<<26) a[i] = inf;
    a[0] = 0;
    int now = 0;
    int dp;
    rep(i,n){
        now ^= (1<<(s[i]-'a'));
        dp = inf;
        rep(j,26){
            int nxt = now ^ (1<<j);
            if(a[nxt] != inf){
                chmin(dp, a[nxt] + 1);
            }
        }
        if(a[now] != inf){
            chmin(dp, a[now] + 1);
            chmin(a[now], dp);
        }else{
            a[now] = dp;
        }
    }
    cout << dp << "\n";
}

Measured memory_bytes: 265900
#include<cstdio>
#include<vector>
using namespace std;
const int MAXN = 200000;
const int MOD = 998244353;
inline int add(int x, int y) {return (x + y)%MOD;}
inline int mul(int x, int y) {return 1LL*x*y%MOD;}
inline int sub(int x, int y) {return add(x,MOD-y);}
int pw2[MAXN + 5];
char X[MAXN + 5], Y[MAXN + 5];
int N;
int func(int x) {
	int ret = 1;
	for(int i=0;i<x;i++)
		if( X[i] - '0' ) ret = add(ret, pw2[x-i-1]);
	for(int i=0;i<N;i++)
		Y[i] = X[i % x]^((i/x)&1);
	for(int i=0;i<N;i++)
		if( X[i] < Y[i] ) {
			ret = sub(ret, 1);
			break;
		}
		else if( X[i] > Y[i] ) break;
	return ret;	
}
vector<int>v, v2;
int main() {
	int ans = 0; pw2[0] = 1;
	scanf("%d%s", &N, X);
	for(int i=1;i<=N;i++) pw2[i] = mul(2, pw2[i-1]);
	for(int i=1;i<=N;i++)
		if( N % i == 0 && (N / i) % 2 == 1 ) {
			int p = func(i);
			for(int j=0;j<v.size();j++)
				if( i % v2[j] == 0 ) p = sub(p, v[j]);
			v.push_back(p); v2.push_back(i);
			ans = add(ans, mul(p, mul(2, i)));
		}
	printf("%d\n", ans);
}

Measured memory_bytes: 1408
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <string>
#include <cassert>

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define PI acos(-1.0)

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef vector <ll> vll;

int n;
ll arr[100000];

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%lld", arr + i);
	sort(arr, arr + n);
	ll first = -1;
	for (int i = n - 1; i > 0; i--) {
		if (arr[i] == arr[i - 1]) {
			if (first == -1)
				first = arr[i], i--;
			else {
				cout << first * arr[i] << endl;
			 	return 0;
			}
		}			
	}		
	cout << 0 << endl;
	return 0;
}


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

int main() {
  int K, S;
  scanf("%d%d", &K, &S);

  int ans = 0;
  for (int X = 0; X <= K; X++) {
    for (int Y = 0; Y <= K; Y++) {
      int Z = S - (X + Y);
      if (0 <= Z && Z <= K) ans++;
    }
  }
  
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF 2e9
#define EPS 1e-9
#define int long long
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<int, int, hash<int>> ht; // while using, comment #define int long long  */

void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
using namespace std;
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("in5.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int T=1;
    // cin >> T;
    FOR1(tt, T){
        // cout << "Case #" << tt << ": ";
        string s; cin >> s;
        string t; cin >> t;
        int n = s.length();
        int m = t.length();
        int mini = INF;
        for(int i = 0; i + m < n + 1; i++){
            int curr = 0;
            for(int j = 0; j < m; j++){
                if(t[j] != s[i+j]) curr++;
            }
            mini = min(mini, curr);
        }
        cout << mini;
        cout << '\n';
    }
    return 0;
}


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

int n;
vector<int> a;
vector<int> v, w;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<n; ++i){
		int t;
		cin >> t;
		a.push_back(t);
	}
	for(int i=0; i<n; ++i){
		if(i % 2 == 0) v.push_back(a[i]);
		else w.push_back(a[i]);
	}
	if(n % 2 == 0){
		for(int i=0; i<w.size(); ++i)
			cout << w[w.size()-i-1] << " ";
		for(int i=0; i<v.size(); ++i)
			cout << v[i] << (i == v.size()-1 ? "\n": " ");
	}else{
		for(int i=0; i<v.size(); ++i)
			cout << v[v.size()-i-1] << (n == 1 ? "\n" : " ");
		for(int i=0; i<w.size(); ++i)
			cout << w[i] << (i == w.size()-1 ? "\n": " ");
	}
}

Measured memory_bytes: 4212
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <fstream>
#include <cmath>

using namespace std;
#define SWAP(x,y,t) (t=x,x=y,y=t)
int main(void)
{
	int n;
	int temp;
	int res = 0;
	map <int,int> count;
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> temp;
		count[temp - 1]++;
		count[temp]++;
		count[temp + 1]++;
	}
	
	for (auto it : count)
	{
		res = max(res,it.second);
	}
	
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 4736