akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define N 100
#define M 1000

int main(void){
  int i,num,j,numj,k;
  int n;
  char event[10];
  int point[M],runner[4];
  int outcount;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    point[i]=0;
    outcount=0;
    for(j=0;j<4;j++){
      runner[j]=0;
    }
    for(;;){
      scanf("%s",&event);
      if(event[0]=='O'){
        outcount++;
        if(outcount>=3)
          break;
      }else if(event[0]=='H' &&
          event[1]=='I'){
        for(k=3;k>=1;k--){
          runner[k]=runner[k-1];
        }
        runner[0]=1;
        if(runner[3]==1){
          point[i]++;
          runner[3]=0;
        }
      }else if(event[0]=='H' &&
          event[1]=='O'){
        for(k=0;k<3;k++){
          if(runner[k]==1)
            point[i]++;
          runner[k]=0;
        }
        point[i]++;
      }
    }
  }
  num=i;
  for(i=0;i<num;i++){
    printf("%d\n",point[i]);
  }
  return 0;
}

Measured memory_bytes: 0
c=[list(map(int,input().split())) for _ in range(3)]
if (c[0][0]-c[1][0])==(c[0][1]-c[1][1])==(c[0][2]-c[1][2]) and\
    (c[0][0]-c[2][0])==(c[0][1]-c[2][1])==(c[0][2]-c[2][2]) and\
    (c[0][0]-c[0][1])==(c[1][0]-c[1][1])==(c[2][0]-c[2][1]) and\
    (c[0][0]-c[0][2])==(c[1][0]-c[1][2])==(c[2][0]-c[2][2]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3188
n, q = map(int,input().split())
s = input()
li = [0]*(n+1)
for i in range(n):
  li[i+1] = li[i] + (1 if s[i:i+2]=='AC' else 0)
#print(li)
for i in range(q):
  l, r = map(int,input().split())
  print(li[r-1]-li[l-1])

Measured memory_bytes: 7748
#include<bits/stdc++.h>
using namespace std;
 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ll long long
#define nl '\n'
#define in() ( { int a ; scanf("%d",&a); a; } )
 
const int N = 3e5 + 9;
const int mod = 1e9 + 7;
//int dx[]={1,0,-1,0,1,-1,-1,1};
//int dy[]={0,1,0,-1,1,1,-1,-1};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    double b;
    ll a, c;
    cin >> a >> b;
    c = b*100;
    unsigned ll ans;
    ans = (a*c)/100;
    cout << ans << endl;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  string s; cin >> s;
  ll ans = 0;
  ll b = 0;
  REP(i, s.size()){
    if(s[i] == 'B') b++;
    else ans += b;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
int mod(ll a){
    int c=a%1000000007;
    if(c>=0)return c;
    else return c+1000000007;
}
typedef pair<int,int> i_i;


int main(){
    char s[100];cin>>s;
    s[3]='8';
    cout<<s;
    
    return 0;
}

Measured memory_bytes: 764
#include<stdio.h>

int rc[1000][1000];

int main(void)
{

  int r,c;
  int i,j;

  scanf("%d %d",&r,&c);

  for(i = 0; i < r; i++)
    {
      for(j = 0; j < c; j++)
	{
	  scanf("%d",&rc[i][j]);
	}
    }

  for(i = 0; i < r; i++)
    {
      for(j = 0; j < c; j++)
	{
	  rc[i][c] += rc[i][j];
	  rc[r][j] += rc[i][j];
	  rc[r][c] += rc[i][j];
	}
    }

  for(i = 0; i <= r; i++)
    {
      for(j = 0; j <= c; j++)
	{
	  printf("%d",rc[i][j]);
	  j == c ? putchar('\n'):putchar(' ');
	}
    }

	  return 0;
}

Measured memory_bytes: 992
first = -1
second = -1
third = -1
for i in xrange(10):
  height = int(raw_input())
  if first < height:
    third = second
    second = first
    first = height
  else:
    if second < height:
      third = second
      second = height
    else:
      if third < height:
        third = height

print first
print second
print third


      

Measured memory_bytes: 4208
r[9],t,o;main(n){char s[9];scanf("%d",&n);while(n){scanf("%s",s);if(s[1]==73){r[3]&&t++,r[3]=0;if(r[2])r[3]=1,r[2]=0;if(r[1])r[2]=1;r[1]=1;}else if(s[1]==85){o++;if(o>2)printf("%d\n",t),n--,r[3]=r[2]=r[1]=o=t=0;}else{r[3]&&t++,r[3]=0;r[2]&&t++,r[2]=0;r[1]&&t++,r[1]=0;t++;}}exit(0);}

Measured memory_bytes: 0
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
    int r, g, b, r_rem, g_rem, n, count = 0, ball[3];
    cin >> ball[0];
    cin >> ball[1];
    cin >> ball[2];
    cin >> n;
    sort(ball, ball + 3, greater<int>());
    r = n / ball[0];
    r_rem = n % ball[0];
    for(int i = r; i >= 0; i--)
    {
        if(r_rem == 0) 
        {
            count += 1;
            r_rem += ball[0];
            continue;
        }
        g = r_rem / ball[1];
        g_rem = r_rem % ball[1];
        for(int j = g; j >= 0; j--)
        {
            if((g_rem == 0) || (g_rem % ball[2] == 0))
            {
                count += 1;
                g_rem += ball[1];
                continue;
            }
            g_rem += ball[1];
        }
        r_rem += ball[0];
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iterator>
#include<set>
#include<sstream>
#define rep(i,n) for(i=0;i<n;i++);
#define endl "\n"
#define ll long long
#define N 200050
using namespace std;
 
int main()
{
    long long int d,i,n,m,p=0,q=0,r=0,s=0,l;
 
    int j,k,x;
 
    cin>>n>>x;
 
if((n-x)==0)
  cout<<"Yes";
else
  cout<<"No";
 
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n,p,x,cnt;
	cin>>n>>p;
	if(n==1)
	{
		cout<<p<<endl;
		return 0;
	}
	if(n>40)
	{
		cout<<1<<endl;
		return 0;
	}
	for(int i=sqrt(p);i>=1;i--)
	{
		x=p;
		cnt=0;
		while(x%i==0)
		{
			cnt++;
			if(cnt==n)
			{
				cout<<i<<endl;
				return 0;
			}
			x/=i;
		}
	}
 } 

Measured memory_bytes: 256
#include <stdio.h>
//#define DEBUG


typedef struct dice{
	int TOP ;
	int FRONT ;
	int RIGHT ;
	int LEFT ;
	int BACK ;
	int BOTTOM ;
}DICE;

void showdice(DICE *);				//???????¢?????????????????????¨??¢??°

void dicescan(DICE *);			//??????????????°???????¨???\????????¢??°

void rotateN(DICE *);			//N?????¢??¢??° TOP???BACk???
void rotateS(DICE *);			//S?????¢??¢??° TOP???FRONT???
void rotateE(DICE *);			//E?????¢??¢??° TOP???RIGHT???
void rotateW(DICE *);			//W?????¢??¢??° TOP???LEFT???

int main(void){

	DICE testdice = {1,2,3,4,5,6};
	char command[101] = {};
	int i = 0 ;

	dicescan(&testdice);

	scanf("%s",command);

	/*???????????£??????????????????*/
	for( i = 0 ; ( command[i] != '\0' ) && ( i < 102 ) ; i++){
		switch(command[i]){
		case 'N':
			rotateN(&testdice);
			break;
		case 'S':
			rotateS(&testdice);
			break;
		case 'E':
			rotateE(&testdice);
			break;
		case 'W':
			rotateW(&testdice);
			break;
		default:
			printf("error\n");
			break;
		}
#ifdef DEBUG
		showdice(&testdice);
#endif
	}//????????????????????????????????§

	/*???????????????*/
	printf("%d\n",testdice.TOP);

	return 0;
}

void rotateN(DICE *rotate){
	int tmp = 0;

	tmp = rotate -> BACK ;
	rotate -> BACK = rotate -> TOP ;
	rotate -> TOP = rotate -> FRONT ;
	rotate -> FRONT = rotate -> BOTTOM ;
	rotate -> BOTTOM = tmp ;
}
void rotateS(DICE *rotate){
	int tmp = 0;

	tmp = rotate -> BACK ;
	rotate -> BACK = rotate -> BOTTOM ;
	rotate -> BOTTOM = rotate -> FRONT ;
	rotate -> FRONT = rotate -> TOP ;
	rotate -> TOP = tmp ;
}
void rotateE(DICE *rotate){
	int tmp = 0;

	tmp = rotate -> TOP ;
	rotate -> TOP = rotate -> LEFT ;
	rotate -> LEFT = rotate -> BOTTOM ;
	rotate -> BOTTOM = rotate -> RIGHT ;
	rotate -> RIGHT  = tmp ;
}
void rotateW(DICE *rotate){
	int tmp = 0;

	tmp = rotate -> TOP ;
	rotate -> TOP = rotate -> RIGHT ;
	rotate -> RIGHT = rotate -> BOTTOM ;
	rotate -> BOTTOM = rotate -> LEFT ;
	rotate -> LEFT  = tmp ;
}

void showdice(DICE *show){
	printf("?????¢???%d\n",show -> TOP);
	printf("?????¢???%d\n",show -> FRONT);
	printf("?????¢???%d\n",show -> RIGHT);
	printf("?????¢???%d\n",show -> LEFT);
	printf("?????¢???%d\n",show -> BACK);
	printf("?????¢???%d\n",show -> BOTTOM);
}

void dicescan(DICE *scan){
	scanf("%d",&scan -> TOP);
	scanf("%d",&scan -> FRONT);
	scanf("%d",&scan -> RIGHT);
	scanf("%d",&scan -> LEFT);
	scanf("%d",&scan -> BACK);
	scanf("%d",&scan -> BOTTOM);
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#define SIZE 10
using namespace std;

class State{
public:
  int data[SIZE][SIZE];
  int put[SIZE][SIZE];
  State() {
    fill((int*)put, (int*)put+SIZE*SIZE, 0);
  }
  void puts(int x, int y) {
    static int d[5][2] = {{0,-1},{1,0},{0,1},{-1,0},{0,0}};
    put[y][x] = 1;
    for(int k = 0; k < 5; k++) {
      int nx = x + d[k][0];
      int ny = y + d[k][1];
      if(nx < 0 || nx >= SIZE) continue;
      if(ny < 0 || ny >= SIZE) continue;
      data[ny][nx] = -(data[ny][nx] - 1);
    }
  }
  bool isAll0() {
    for(int i = 0; i < SIZE; i++) {
      for(int j = 0; j < SIZE; j++) {
	if(data[i][j] != 0) return false;
      }
    }
    return true;
  }
  void show() {
    for(int i = 0; i < SIZE; i++) {
      for(int j = 0; j < SIZE; j++) {
	if(j != 0) cout << ' ';
	cout << put[i][j];
      }
      cout << endl;
    }
  }
};

bool rec(State s, int x, int y) {
  static int d[5][2] = {{0,-1},{1,0},{0,1},{-1,0},{0,0}};
  if(s.isAll0()) {
    s.show();
    return true;
  }

  for(int i = y; i < SIZE; i++) {
    int j;
    if(i == y) j = x;
    else       j = 0;
    for(; j < SIZE; j++) {
      bool flag = false;
      /*for(int k = 0; k < 5; k++) {
	int nx = j + d[k][0];
	int ny = i + d[k][1];
	if(nx < 0 || nx >= SIZE) continue;
	if(ny < 0 || ny >= SIZE) continue;
	if(s.data[ny][nx] == 1) {
	  flag = true;
	  break;
	}
	}*/
      flag = true;
      if(flag) {
	if(i > 0 && s.data[i-1][j] == 0) continue;
	State tmp = s;
	tmp.puts(j, i);
	int nx, ny;
	nx = j + 1;
	ny = i;
	if(nx >= SIZE) {
	  nx = 0;
	  ny++;
	}
	if(rec(tmp, nx, ny)) {
	  return true;
	}
	if(i > 0 && s.data[i-1][j] == 1) return false;
      }
    }
  }
  return false;
}

main() {
  int n;
  cin >> n;
  for(int t = 0; t < n; t++) {
    State s;
    for(int i = 0; i < SIZE; i++) {
      for(int j = 0; j < SIZE; j++) {
	cin >> s.data[i][j];
      }
    }
    rec(s, 0, 0);
  }
}

Measured memory_bytes: 1000
#include <iostream>
    #include <string>
    #include <set>  
    #include <algorithm>
    #include <vector>
    #include <cmath>
    #include <queue>
    #include <deque>
    #include <cstring>
    #include <cstdio>
    #include <map>
    #include <numeric>
	#include <cassert>
    #include <iomanip>
    #include <sstream> 
    #include <cstdlib>
using namespace std;
string s;
int main()
{
	cin>>s;
	int len=s.length();
	int cnt=1;
	for(int i=1;i<len;i++)
		if(s[i]!=s[i-1])cnt++;
	cout<<cnt-1<<endl;
	return 0;
}

Measured memory_bytes: 512
// Copyright 2017 Parallelc
#include <bits/stdc++.h>
using namespace std;  // NOLINT

using LL = int64_t;
const int INF = 0x3f3f3f3f;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    vector<vector<LL>> c(n + 1);
    for (auto& i : c) i.resize(n + 1);
    for (int i = 0; i <= n; i++) {
        c[i][0] = 1;
        for (int j = 1; j < i; j++) {
            c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
        }
        c[i][i] = 1;
    }
    vector<LL> s(n);
    for (auto& i : s) cin >> i;
    sort(s.rbegin(), s.rend());
    cout << fixed << setprecision(6) << (long double)accumulate(s.begin(), s.begin() + a, 0LL) / (long double)a << endl;
    int sum = count(s.begin() + a, s.end(), s[a - 1]);
    if (s[0] == s[a - 1]) {
        sum += a;
        LL ans = 0;
        for (int i = a; i <= min(b, sum); i++) {
            ans += c[sum][i];
        }
        cout << ans << endl;
    } else {
        int p = count(s.begin(), s.begin() + a, s[a - 1]);
        cout << c[sum + p][p] << endl;
    }
}

Measured memory_bytes: 256
A,B,C = map(int,input().split())

oddcnt = 0
sub = [A,B,C]
sub2 = [i - min(sub) for i in sub]
sub2 = sorted(sub2)[1:3]
# print(sub2)
for i in sub2:
    if i%2 != 0:
        oddcnt += 1

if oddcnt == 0:
    print((sub2[1]+(sub2[1]-sub2[0]))//2)
elif oddcnt == 1:
    if sub2[0]%2 ==0:
        print((sub2[1]+(sub2[1]-sub2[0]))//2)
    else:
        print((sub2[1]+(sub2[1]-sub2[0]+1))//2+1)
else:
    print((sub2[1]+(sub2[1]-sub2[0]+1))//2+1)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <map>
#include <functional>
using namespace std;

int main() {
	int ans = 0;
	int A, B;
	int num[4];
	cin >> A >> B;
	for (int i = A; i <= B; i++) {
		num[0] = i / 10000;
		num[1] = (i / 1000) % 10;
		num[2] = (i % 100) / 10;
		num[3] = i % 10;
		if (num[0] == num[3] && num[1] == num[2]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define X first;
#define Y second;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 2e5 + 10;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 1e9+7;


vector<int> v[maxN];
void addedge(int x,int y)
{
	v[x].push_back(y);
	v[y].push_back(x);
}
pii g[maxN];
//ll getsum(int x,int n)
//{
//	int sum = (2+n-x)*(n-x)/2;
//	return sum;
//}
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		if(x>y)
			swap(x,y);
		g[i] = pii(x,y);
	}
	ll ans = 0;
	for(int L=1;L<=n;L++)
	{
		ans += (ll)(n-L+1)*L; 
	}
	for(int i=1;i<n;i++)
	{
		int x = g[i].X;
		int y = g[i].Y
		ans -= (ll)x * (n-y+1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9884
from sys import stdin

import collections

def main():

    input = stdin.readline

    A = int(input())
    S = []

    for _ in range(A):
        S.append(input()[:-1])

    c = collections.Counter(S)

    maxnum = c.most_common()[0][1]

    S_ans = []
    for value,key in c.most_common():
        if(key == maxnum):
            S_ans.append(value)
        else:
            break

    print('\n'.join(sorted(S_ans)))


if __name__ == "__main__":
    main()

Measured memory_bytes: 45032
import math

def isPrime(n):
    if n == 1:
        return False
    elif n == 2:
        return True
    elif n % 2 == 0:
        return False

    for i in range(3, int(math.sqrt(n))+1, 2):
        if n % i == 0:
            return False
    else:
        return True

n = int(input())

numbers = []
for i in range(n):
  numbers.append(int(input()))

sum = 0
for i in numbers:
    if isPrime(i):
        sum += 1

print (sum)



Measured memory_bytes: 6004
#include <bits/stdc++.h>
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define befv(V) ((V)[(sz(V)-2)])
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAXN = 100005;

vector<int> G[MAXN];
multiset<int> PQ;

int ud[MAXN];
int A[MAXN];

ll Ans;
int N, M;

int uf(int i) { return i == ud[i] ? i : (ud[i] = uf(ud[i])); }
void uf(int a, int b) { ud[uf(b)] = uf(a); }

int main() {
	ios::sync_with_stdio(false);
	iota(ud, ud+MAXN, 0);

	cin >> N >> M;
	for(int i = 1; i <= N; i++) cin >> A[i];
	if(M+1 == N) {
		puts("0");
		return 0;
	}
	for(int i = 1, a, b; i <= M; i++) {
		cin >> a >> b; a++; b++;
		uf(a, b);
	}

	if(N < 2 * (N-M-1)) {
		puts("Impossible");
		return 0;
	}

	for(int i = 1; i <= N; i++)
		G[uf(i)].eb(A[i]);
	for(int i = 1; i <= N; i++) sorv(G[i]);
	for(int i = 1; i <= N; i++) PQ.insert(A[i]);
	for(int i = 1; i <= N; i++) if(i == uf(i)) {
		int t = G[i][0];
		Ans += t;
		PQ.erase(PQ.find(t));
	}

	for(int t = 0; t < 2*(N-M-1) - (N-M); t++) {
		Ans += *PQ.begin();
		PQ.erase(PQ.begin());
	}

	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 9856
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class Bisect:
    def __init__(self, func):
        self.__func = func

    def bisect_left(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if self.__func(mid) < x:
                lo = mid+1
            else:
                hi = mid
        return lo

    def bisect_right(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if x < self.__func(mid):
                hi = mid
            else:
                lo = mid+1
        return lo

@mt
def slv(N, M, V, P, A):
    A.sort(reverse=True)
    def f(i):
        if i < P:
            return 0

        if V - P <= 0:
            if A[i] + M >= A[P-1]:
                return 0
            else:
                return 1
        else:
            am = A[i] + M
            r = V - P
            B = []
            for j in range(P-1, N):
                if j != i:
                    B.append(A[j])
                j += 1
            heapq.heapify(B)
            C = []
            rm = M * r
            while B:
                b = heapq.heappop(B)
                d  = am - b
                if d > 0:
                    if d > M:
                        d = M
                    if d <= rm:
                        rm -= d
                        C.append(b+d)
                    else:
                        C.append(b+rm)
                        rm = 0
                else:
                    C.append(b)
            return 0 if max(C) <= am and rm == 0 else 1

    b = Bisect(f)
    i = b.bisect_right(0.5, lo=0, hi=N)
    return i


def main():
    N, M, V, P = read_int_n()
    A = read_int_n()
    print(slv(N, M, V, P, A))

    # N = 10**5
    # M = random.randint(0, 10**9)
    # V = random.randint(1, N-1)
    # P = random.randint(1, N-1)
    # A = [random.randint(0, 10**9) for _ in range(N)]
    # print(slv(N, M, V, P, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 121688
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int p[110],n,sum;

int main(){
 scanf("%d",&n);
 for(int i = 0 ; i < n ; i++) scanf("%d",p+i),sum+=p[i],p[i] = p[i]%10==0?0:p[i];
 sort(p,p+n);
 if( sum % 10 == 0 ){
  for(int j = 0 ; j < n ; j++){
   sum-=p[j];
   if(sum%10) break;
  }
  if(sum%10==0)sum = 0; 
 }
 printf("%d\n",sum);
 return 0;
}

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

signed main () {
	int n, k;
	cin >> n >> k;
	if (k * 2 > (n - 1) * (n - 2))
		cout << "-1\n";
	else {
		vector < pair < int, int > > edges;
		for (int i = 2; i <= n; ++i)
			edges.push_back(make_pair(1, i));
		int cur = ((n - 1) * (n - 2)) / 2;
		vector < set < int > > can(n + 1);
		for (int i = 2; i <= n; ++i) {
			for (int j = i + 1; j <= n; ++j) 
				can[i].insert(j);
		}
		int i = 2;
		while (cur > k) {
			if (can[i].empty())
				++i;
			edges.push_back(make_pair(i, *can[i].begin()));
			can[i].erase(can[i].begin());
			--cur;
		}
		cout << edges.size() << '\n';
		for (int j = 0; j < int(edges.size()); ++j)
			cout << edges[j].first << ' ' << edges[j].second << '\n';
	}
}


Measured memory_bytes: 512
#include<stdio.h>
int main(){
	int a,b,c=0;
	scanf("%d %d",&a,&b);
	for(int i=0;i<=a;i++){
	for(int j=0;j<=a;j++){
		if(b-i-j<=a&&b-i-j>=0){
			c++;
		}
	}
	}
	printf("%d",c);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e5+1;
int main()
{
    FASTINOUT;
    int x,in1=0,in2=0,cnt=0;
    cin>>x;
    vector<int> a(x),b(x),c(x);
    for (int i=0;i<x;i++){
        cin>>a[i];
        c[i]=a[i];
    }
    for (int i=0;i<x;i++)
    cin>>b[i];
    sort(c.begin(),c.end());
    do{
        cnt++;
        if (c==a){
            in1=cnt;
        }
        if (b==c)
            in2=cnt;
    }while (next_permutation(c.begin(),c.end()));
    cout<<abs(in1-in2)<<endl;
    return 0;
}


Measured memory_bytes: 256
n, m = map(int,input().split())
a = [0]
b = [0]
c = [0]*(m+1)
for i in range(1, m+1):
    tab = list(map(int, input().split()))
    a.append(tab.pop(0))
    b.append(tab)
    tc1 = list(map(int, input().split()))
    tc2 = 0
    for j in tc1:
        tc2 |= 1<<(j-1)
    c[i] = tc2
INF = 10**9
dp = [[0] + [INF] * (2**n-1) for i in range(m+1)]
for i in range(1, m+1):
    for j in range(2**n):
        dp[i][j] = min(dp[i][j], dp[i-1][j])
        nj = j | c[i]
        dp[i][nj] = min(dp[i][nj], dp[i-1][nj], dp[i-1][j] + a[i])

print(-1) if dp[m][2**n-1] == INF else print(dp[m][2**n-1])

Measured memory_bytes: 112848
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,arr[33]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin >> n;
    cout << arr[n]<< endl;
    return 0;

}


Measured memory_bytes: 256
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
N = int(input())
s = input()
t = input()
X = True
Y = False
MOD = 10**9+7
if s[0] == t[0]:
    i = 1
    ans = 3
    prev = X
else:
    i = 2
    ans = 6
    prev = Y
while i < N:
    if s[i] == t[i]:
        if prev:
            ans = (ans*2) % MOD
        else:
            ans = ans % MOD
        i += 1
        prev = X
    else:
        if prev:
            ans = (ans*2) % MOD
        else:
            ans = (ans*3) % MOD
        i += 2
        prev = Y
print(ans)


Measured memory_bytes: 3064
s=input()
n=len(s)
arr1=[]
arr2=[]
for i in range(n):
  if s[i]!='x':
    arr1.append(s[i])
    arr2.append(i)
if len(arr1)==0:
  print(0)
  exit()
for i in range(len(arr1)):
  if arr1[i]!=arr1[len(arr1)-i-1]:
    print(-1)
    exit()
arr2=[0]+arr2+[n-1]
arr3=[]
for i in range(len(arr2)-1):
  arr3.append(arr2[i+1]-arr2[i])
ans=0
for i in range(len(arr3)//2):
  ans+=max(arr3[i],arr3[len(arr3)-i-1])-min(arr3[i],arr3[len(arr3)-i-1])
print(ans)
#print(arr3)

Measured memory_bytes: 9504
n = int(input())
a = list(map(int,input().split()))
avg = sum(a)/len(a)

min = abs(avg-max(a))+1
index=0
for i in range(len(a)):
    x=abs(a[i]-avg)
    if x < min:
        min = x
        index=i
print(index)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int a[100];

int main()
{
	int K, T, ans = 0, pre = -1;

	cin >> K >> T;
	rep(i, T) cin >> a[i];

	rep(day, K) {
		int max_idx = -1;
		int max_val = 0;

		rep(i, T) {
			if (i == pre) continue;
			if (a[i] > max_val) {
				max_idx = i;
				max_val = a[i];
			}
		}

		if (max_idx == -1) {
			ans = a[pre];
			break;
		}
		else {
			a[max_idx]--;
			pre = max_idx;
		}
	}

	cout << ans << endl;

	return 0;
}


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

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

int main(void){
    const string odd = "RUD", even = "LUD";
    string s;
    bool flg = true;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    REP(i, s.length()) {
        if (i % 2 == 0 && odd.find(s[i]) != string::npos) {
            continue;
        } else if (i % 2 == 1 && even.find(s[i]) != string::npos) {
            continue;
        } else {
            flg = false;
        }
    }

    cout << (flg? "Yes" : "No") << "\n";
    return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  int n;
  cin >> n;
  int ans = 1;
  int tmp = 0;
  while(tmp < n){
    tmp += ans;
    ans++;
  }
  cout << ans-1 << endl;
}

Measured memory_bytes: 256
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
edge = []
for i in range(N):
    edge.append([])
    if i != 0:
        edge[i].append(i - 1)
    if i != N-1:
        edge[i].append(i + 1)
edge[X].append(Y)
edge[Y].append(X)

answer = [0] * (N - 1)
for i in range(N):
    queue = []
    for e in edge[i]:
        queue.append(e)
    counter = 0
    d = [N + 10] * N
    d[i] = 0
    # i is start
    while counter < len(queue):
        node = queue[counter]
        min_dist = N + 10
        for e in edge[node]:
            if d[e] < min_dist:
                min_dist = d[e]
            if d[e] == N + 10:
                queue.append(e)
        d[node] = min_dist + 1
        counter += 1
    for i in d:
        answer[i] += 1
for a in answer[1:]:
    print(a//2)
print('0')

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

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

const ll mod=1000000007;
//head

pair<ll,ll> normalize(ll a, ll b) {
    pll sardines;
    if(a == b && a == 0) {
        sardines = mp(a,b);
    } else if(a == 0 && b != 0) {
        sardines = mp(0ll,1ll);
    } else if(a != 0 && b == 0) {
        sardines = mp(1ll,0ll); 
    } else if(a < 0 && b < 0) {
        a *= -1;
        b *= -1;
        sardines = mp(a/__gcd(a,b), b/__gcd(a,b));
    } else if(a > 0 && b > 0) {
        ll gcd = __gcd(a,b);
        sardines = mp(a/gcd,b/gcd);
    } else {
        ll gcd = __gcd(abs(a),abs(b));
        sardines = mp(-1*abs(a)/gcd, abs(b)/gcd);
    }
    return sardines;
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int n;
    cin >> n;
    map<pair<ll,ll>, int> cnt;
    vector<pair<ll,ll>> sardines(n); 
    for(int i = 0; i < n; i++) {
        ll a, b;
        cin >> a >> b;
        pair<ll,ll> norm = normalize(a,b);
        if(cnt.count(norm) == 0) {
            cnt[norm] = 1;
        } else {
            cnt[norm]++;
        }
        //cout << norm.first << " " << norm.second << endl;
    }
    /*trav(p, cnt) {
        cout << p.first.first << " " << p.first.second << endl;
    }*/
    ll ans = 1;
    const int nax = 2e5+2;
    ll pow[nax];
    pow[0] = 1;
    set<pair<ll,ll>> counter;
    for(int i = 1; i < nax; i++) pow[i] = (pow[i-1]*2) % mod;
    
    trav(p, cnt) {
        assert(ans >= 0);
        pair<ll,ll> s1 = p.first;
        if(s1.first == 0 && s1.second == 0) continue;
        pair<ll,ll> recip = normalize(-1*s1.second, s1.first);
        if(cnt.count(recip) != 0) {
            ans *= (pow[p.second] + pow[cnt[recip]] - 1) % mod;
            ans %= mod;
        } else {
            ans *= (pow[p.second]);
            ans %= mod;
        }
        cnt.erase(recip);
    }
    ans -= 1;
    if(cnt.count(mp(0ll,0ll)) != 0)
        ans += cnt[mp(0ll,0ll)];
    ans %= mod;
    if(ans < 0) ans += mod;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 20336
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,s=0;
  cin >> a >> b;
  for (int i=a; i<b+1; i++) {
    if (i/10000==i%10 && i/1000-i/10000*10==i/10-i/100*10) {
      s++;
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 3600
from collections import deque
h,w = (int(i) for i in input().split())
maze = [input() for _ in range(h)]
visited = [[False]*w for _ in range(h)]
  
def solve2(i,j):
  d = [(1,0),(0,1),(-1,0),(0,-1)]
  queue = deque([(i,j)])
  b,c = 0,0
  while queue:
    (x,y) = queue.popleft()
    if maze[x][y] =='#':b+=1
    else:c += 1
    visited[x][y] = True
    
    for dx,dy in d:
      nx,ny = x+dx,y+dy
      #print(nx,ny)
      if nx <= -1 or nx >= h or ny <= -1 or ny >= w:
        continue
      if visited[nx][ny]:
        continue
      #print(maze[nx][ny],maze[x][y])
      if maze[nx][ny] != maze[x][y]:
       visited[nx][ny] = True
       queue.append([nx,ny])
        
 # print(b,c)
  return b*c

ans = 0
for i in range(h):
  for j in range(w):
    if not visited[i][j]:
     ans += solve2(i,j)
print(ans)

Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define     PI                       acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void GO(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const int N=200000+5,mod=1e9+7;
int a[N],pre[N];
int main(){
    GO();

    int T;
    T=1;
    while(T--){
         int n;
         cin>>n;

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

         for(int i=0;i<n;i++){
             pre[i]=max((i?pre[i-1]:0),a[i]);
         }
         ll ans=0;
         for(int i=n-1;i>0;i--){
            ans+= max(0,pre[i-1]-a[i]);
         }
         cout<<ans<<"\n";
    }

}




























































































































































































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

int main(){
int N,A,B;
  cin>>N>>A>>B;
 
 int ans=0;
 for(int i=1; i<=N; i++){
   int sum=0;
   int num=i;
   for(int j=0; j<5; j++){
    sum+=num%10;
    num/=10;
   }
   if(A<=sum && sum<=B){ans+=i;}
 }
  
  cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

char c;
char v[] = {'a', 'i', 'u', 'e', 'o'};

int main(void)
{
	cin >> c;
	for(int i = 0; i < 5; i++) if(c == v[i]){
		cout << "vowel" << endl;
		return 0;
	}
	cout << "consonant" << endl;
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;
const int mod = 1e9 + 7;

int main(){
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){
   int a,b;
   cin>>a>>b;
   int ans=-1;

   for(int i=1;i<=1250;i++){
      int c=i*0.08;
      int d=i*0.10;
      if(c==a && d==b){
          ans=i;
          break;
      }
   }
   cout<<ans;

   
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    int a[n];
    for (int &i : a) cin >> i;
    int T;
    cin >> T;
    while (T--) {
        int x;
        cin >> x;
        int b, e;
        cin >> b >> e;
        if (x==0) cout << *min_element(a + b, a + e) << endl;
        else cout << *max_element(a + b, a + e) << endl;
    }
}


Measured memory_bytes: 3104
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#endif

#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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


MY_NAMESPACE(testbed)
ll gcd(ll a, ll b)
{
	if (a < b)
		swap(a, b);
	if (a % b == 0)
		return b;
	return gcd(b, a % b);
}

ll modpow(ll base, ll exponent, ll mod)
{
	ll retval = 1;
	while (exponent > 0)
	{
		if (exponent % 2)
			retval = (retval * base) % mod;
		exponent /= 2;
		base = (base * base) % mod;
	}
	return retval;
}

class HashPair
{
public:
	static size_t m_hash_pair_random;

	template<class T1, class T2>
	size_t operator()(const pair<T1, T2>& p) const {

		auto hash1 = hash<T1>{}(p.first);
		auto hash2 = hash<T2>{}(p.second);

		size_t seed = 0;
		seed ^= hash1 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
		seed ^= hash2 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
		seed ^= m_hash_pair_random + 0x9e3779b9 + (seed << 6) + (seed >> 2);
		return seed;
	}
};

size_t HashPair::m_hash_pair_random = (size_t)random_device()();

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

	ll modval = 1000000007;

	int n;
	cin >> n;
	//map<pll, int> cnt;
	unordered_map<pll, int, HashPair> cnt;
	for (int i = 0; i < n; i++)
	{
		ll a, b;
		cin >> a >> b;
		if (a != 0 && b != 0)
		{
			if (a < 0)
			{
				a *= -1;
				b *= -1;
			}
			ll g = gcd(abs(a), abs(b));
			cnt[{a / g, b / g}]++;
		}
		else if (a == 0 && b == 0)
			cnt[{0, 0}]++;
		else if (a == 0)
			cnt[{0, 1}]++;
		else  // b == 0
			cnt[{1, 0}]++;
	}

	ll num00 = cnt[{0, 0}];
	cnt.erase(make_pair(0, 0));

	ll num = 1;
	while (!cnt.empty())
	{
		auto this_item = cnt.begin();
		pll this_pair = this_item->first;
		pll anti_pair = { this_pair.second, -this_pair.first };
		if (anti_pair.first < 0)
			anti_pair = { -this_pair.second, this_pair.first };
		else if (anti_pair.first == 0)
			anti_pair = { 0, 1 };
		if (cnt.find(anti_pair) == cnt.end())
			cnt[anti_pair] = 0;
		auto anti_item = cnt.find(anti_pair);

		num = num * (modpow(2, this_item->second, modval) - 1 + modpow(2, anti_item->second, modval) - 1 + 1) % modval;
		cnt.erase(this_item);
		cnt.erase(anti_item);
	}
	ll retval = (num00 + (num - 1) + modval) % modval;  // -1 for nothing chosen case
	cout << retval << "\n";

	return 0;
}
MY_NAMESPACE_

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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int mx = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        mx = max(mx, a[i]);
    }
    double c = mx / 2.0;
    double min_d = 1000000100.0;
    int m = 0;
    for (const auto x : a) {
        if (x == mx) {
            continue;
        }
        if (min_d > abs(c - x)) {
            min_d = abs(c - x);
            m = x;
        } 
    }
    cout << mx << " " << m << endl;
}


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

int main(){
    unsigned long long a,b,c,d;
    cin >> a >> b >> c >> d;
    unsigned long long count = 0;
    unsigned long long i;
    unsigned long long koubai;
    unsigned long long r;
    unsigned long long A = max(c,d);
    unsigned long long B = min(c,d);
    r = A % B;
    while(r !=0){
        A = B;
        B = r;
        r = A%B;
    }
    koubai = (c*d)/B;
    unsigned long long Kamijou =  b-a;
    unsigned long long Keisuke =  ((b / c) - ((a-1) / c)) + ((b / d) - ((a-1) /d)) - ((b / koubai) - ((a-1) / koubai));
    cout << Kamijou - Keisuke + 1 << endl; 
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var n = int.Parse(_[0]);
            var m = int.Parse(_[1]);
            var c = int.Parse(_[2]);
            var b = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

            var count = 0;
            for(var i = 0; i < n; i++){
                var a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
                var t = Enumerable.Range(0, m).Select(j => a[j] * b[j]).Sum() + c;
                count += t > 0 ? 1 : 0;
            }

            Console.WriteLine(count);
        }
    }
}


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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  int r,g; cin>>r>>g;
  print(2*g-r);

  return 0;
}

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

void bfs(vector<string > &vec,vector< vector<ll> > &visited,ll a,ll b,ll count,ll h,ll w){
	queue<pair<ll,ll> >  q;
	q.push({a,b});
	visited[a][b]=1;
	while(!q.empty()){
		pair<ll,ll> pp=q.front();
//		cout<<pp.first<<" "<<pp.second<<endl;
		ll a=pp.first,b=pp.second;
		q.pop();
		if(a-1>=0&&b>=0&&a-1<h&&b<w&&visited[a-1][b]==0&&vec[a-1][b]=='.'){
			q.push({a-1,b});
			visited[a-1][b]=visited[a][b]+1;
//			cout<<"a";
		}
		if(a+1>=0&&b>=0&&a+1<h&&b<w&&visited[a+1][b]==0&&vec[a+1][b]=='.'){
			q.push({a+1,b});
			visited[a+1][b]=visited[a][b]+1;
//			cout<<"b";
		}
		if(a>=0&&b-1>=0&&a<h&&b-1<w&&visited[a][b-1]==0&&vec[a][b-1]=='.'){
			q.push({a,b-1});
			visited[a][b-1]=visited[a][b]+1;
//			cout<<"c";
		}
		if(a>=0&&b+1>=0&&a<h&&b+1<w&&visited[a][b+1]==0&&vec[a][b+1]=='.'){
			q.push({a,b+1});
			visited[a][b+1]=visited[a][b]+1;
//			cout<<"d";
		}
//		cout<<endl;
	}
	
}

int main()
{
	ll h,w;
	cin>>h>>w;
	vector<string > vec;
	for(ll i=1;i<=h;i++){
		string s;
		cin>>s;
		vec.push_back(s);
	}
	
	
	ll ans=0;
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			if(vec[i][j]=='.'){
				vector< vector<ll> > visited(h,vector<ll> (w,0));
				ll count=1;
				bfs(vec,visited,i,j,count,h,w);
//				cout<<i<<" "<<j<<"   pp"<<endl;
				for(ll k=0;k<h;k++){
					for(ll l=0;l<w;l++){
						count=max(count,visited[k][l]-1);
//						cout<<visited[k][l]-1<<" ";
					}
//					cout<<endl;
				}//cout<<endl;
				ans=max(ans,count);
			}
		}
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/aising2020/tasks/aising2020_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N;
  cin >> N;

  VL res(N + 1);

  rep1(x, 100) rep1(y, 100) rep1(z, 100) {
    ll val = x * x + y * y + z * z + x * y + y * z + z * x;
    unless(val <= N) continue;
    res[val]++;
  }

  rep1(i, N) cout << res[i] << "\n";
}


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

typedef signed long long ll;
const int MX = 1e3 + 5;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    ((b - a) == (c - b)) ? printf("YES\n") : printf("NO\n");
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    long long N;
    cin >> N;
    vector<long long> A(N);
    priority_queue<long long> que;
    REP(i, N) {
        cin >> A[i];
        que.push(A[i]);
    }

    REP(i, N) {
        if(que.top() != A[i]) {
            cout << que.top() << endl;
        } else {
            long long t = que.top();
            que.pop();
            cout << que.top() << endl;
            que.push(t);
        }
    }
    return 0;
}


Measured memory_bytes: 4848
# -*- coding: utf-8 -*-
K,X=map(int,input().split())
a=X-(K-1)
b=X+(K-1)
ans=[]
if a<-1000000:
    a=-1000000
if b>1000000:
    b=1000000
for i in range(a,b+1):
    ans.append(str(i))
print(" ".join(ans))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[10],b[10],i,sum=0,j,c[10],k=0;
    for(i=0;i<5;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]<1||a[i]>123)
        {
            scanf("%d",&a[i]);
        }
    }
    for(i=0;i<5;i++)
    {
        b[i]=a[i]%10;
        sum=sum+a[i];
        if(b[i]!=0)
            c[k++]=b[i];
    }
    sort(c,c+k);
    for(j=1;j<k;j++)
    {
        sum=sum+(10-c[j]);
    }
    printf("%d\n",sum);
    return 0;
}


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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;

  string s, t;
  cin >> s >> t;

  string ans = s+t;
  for ( int i = 0; i < (int)s.size(); i++ ) {
    bool f = true;    
    for ( int j = i; j < s.size(); j++ ) {
      if ( j-i >= (int)t.size() || s[j] != t[j-i] ) {	
	f = false;
	break;	
      }
    }

    if ( f ) {
      ans = s;
      for ( int j = s.size()-i; j < (int)t.size(); j++ ) {
	ans += t[j];	
      }
      break;     
    }
  }

  cout << ans.size() << endl;  
  
  return 0;
}


Measured memory_bytes: 256