akhauriyash/Code-Regression huggingface dataset:
/*input
3 3
...
.#.
...


*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
#define PI 3.14159265
#define endl '\n'
#define debug(x) cout << #x << " = " << x << endl;

template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
    int x = 1 % mod;
    while(b){
        if(b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

char arr[1001][1001];
int n, m;

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

  cin >> n >> m;
  vector <PII> vec;
  for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
          cin >> arr[i][j];
          if (arr[i][j] == '#') {
            vec.pb({i, j});
          }
      }
  }
  int ans = 0;
  int l = 0;
  while(1) {
    int s = vec.size();
    bool ok = false;
    if (l == s) {
      break;
    }
    for (; l < s; l++) {
      auto it = vec[l];
      int i = it.first;
      int j = it.second;
      if (i + 1 < n && arr[i + 1][j] == '.') {
        ok = true;
        arr[i + 1][j] = '#';
        vec.pb({i + 1, j});
      }
      if (j + 1 < m && arr[i][j + 1] == '.') {
        ok = true;
        arr[i][j + 1] = '#';
        vec.pb({i, j + 1});
      }
      if (i - 1 >= 0 && arr[i - 1][j] == '.') {
        ok = true;
        arr[i - 1][j] = '#';
        vec.pb({i - 1, j});
      }
      if (j - 1 >= 0 && arr[i][j - 1] == '.') {
        ok = true;
        arr[i][j - 1] = '#';
        vec.pb({i, j - 1});
      }
    }
    if (ok) {
      ans++;
    }
  }
  cout << ans << endl;
  
  
  return 0;
}


Measured memory_bytes: 11372
#include<iostream>
using namespace std;
int f[10000009];
int main(){
	int a;
	cin>>a;
	for(int i=1;i<=a;i++){
		for(int j=i;j<=a;j=j+i)
		f[j]++;
	}
	long long ans=0;
	for(int i=1;i<=a;i++){
		ans=ans+f[i]*i;
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 42248
#include <stdio.h>

int main(void){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a == 0){
        if(b == 1)
            printf("Close\n");
        else if(c==1)
            printf("Open\n");
        else
            printf("Close\n");
    }
    else if(b==0)
        printf("Close\n");
    else
        printf("Open\n");
    return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

int main(){
    while(1){
        int n,m;
        cin >> n >> m;
        if(n==0) break;

        vector<int> solvable(n), mustsolve(n);
        for(int i=0; i<m; i++){
            int s,k;
            cin >> s >> k;
            vector<int> c(k);
            for(int j=0; j<k; j++){
                cin >> c[j];
                c[j]--;
                solvable[c[j]] += s;
            }
            if(k==1){
                mustsolve[c[0]] += s;
            }
        }
        
        vector<pair<int,int> > a(n), b(n);
        for(int i=0; i<n; i++){
            a[i] = make_pair(solvable[i], i);
            b[i] = make_pair(mustsolve[i], i);
        }
        sort(a.begin(), a.end());
        sort(b.begin(), b.end());

        if(a[n-1].second != b[0].second){
            cout << a[n-1].first -b[0].first +1 << endl;
        }else{
            cout << max(a[n-1].first -b[1].first, a[n-2].first -b[0].first) +1 << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3204
using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        string[] s = new string[n];
        for (int i = 0; i < n; i++)
        {
            s[i] = sc.Next();
        }

        long[] cnt = new long[256];
        foreach (var str in s)
        {
            cnt[str[0]]++;
        }
        string march = "MARCH";
        long ans = 0;
        for (int i = 0; i < 5; i++)
        {
            for (int j = i+1; j < 5; j++)
            {
                for (int k = j+1; k < 5; k++)
                {
                    ans += cnt[march[i]] * cnt[march[j]] * cnt[march[k]];
                }
            }
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 35228
def solve(n, dt, T):
    total = dt
    prev = T[0]
    for t in T[1:]:
        if dt <= t - prev:
            total += dt
        else:
            total += t - prev
        prev = t
    return total

_n, _dt = map(int, input().split())
_T = list(map(int, input().split()))
print(solve(_n, _dt, _T))

Measured memory_bytes: 25200
using System;

namespace abc156A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int N = int.Parse(str[0]);
            int R = int.Parse(str[1]);
            int Ans;
            if (N >= 10)
            {
                Ans = R;
            }
            else
            {
                Ans = R + (100 * (10 - N));
            }
            Console.WriteLine(Ans);
        }
    }
}


Measured memory_bytes: 11092
N = int(input())
T = list(map(int, input().split()))
M = int(input())
px = [map(int, input().split()) for _ in range(M)]

for p, x in px:
    total = 0

    for i in range(N):
        if i + 1 == p:
            total += x
        else:
            total += T[i]

    print(total)

Measured memory_bytes: 3060
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    S, W = read_values()
    print("safe" if W < S else "unsafe")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9880
#include <stdio.h>

int main(void){
    int n;
    int l,r;
    int sum;
    
    scanf("%d", &n);
    sum = 0;
    for (int i=0; i<n; i++){
        scanf("%d%d", &l, &r);
        sum += r-l+1;
    }
    printf("%d\n", sum);
    
    return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
from collections import *

H, W = map(int, input().split())
a = [input()[:-1] for _ in range(H)]
f = [False]*W

for i in range(W):
    l = []
    
    for j in range(H):
        l.append(a[j][i])
    
    if l==['.']*H:
        f[i] = True

for i in range(H):
    if a[i]=='.'*W:
        continue
    
    ans = []
    
    for j in range(W):
        if not f[j]:
            ans.append(a[i][j])
    
    print(''.join(ans))

Measured memory_bytes: 38896
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define maxin(v) *max_element(v.begin(), v.end())
#define minin(v) *min_element(v.begin(), v.end())
#define sumall(vect) accumulate(vect.begin(), vect.end(), 0)
#define count(x, vect) count(vect.begin(), vect.end(), x)
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 100000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "------------------------------------\n"
#define min(a, b, c) min(a, min(b, c))
//#define max(a, b, c) max(a, max(b, c))
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp;
string str;
set<ll> s;
vll v;
string decToBinary(int n) 
{ 
    string s;
    for (int i = temp-1; i >= 0; i--) { 
        int k = n >> i; 
        if (k & 1) 
            s.pb('1'); 
        else
            s.pb('0'); 
    } 
    //cout<<s;
    //nl;
    return s;
} 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	temp=n;
	vector<pll> t[n+1];
	for(int i=0;i<n;i++)
	{
	    cin>>m;
	    while(m--)
	    {
	        cin>>a>>b;
	        t[i].pb({a,b});
	    }
	}
	int count1=0;
	int mx=0;
	for(int i=0;i<pow(2,n);i++)
	{
	    str=decToBinary(i);
	    count1=0;
	    int flag=1;
	    for(int i=0;i<n;i++)
	    {
	        if(str[i]=='0')
	        continue;
	        count1++;
	        for(auto x:t[i])
	        {
	            int per=x.fi;
	            if(str[per-1]!=x.se+'0')
	            {flag=0;
	            break;}
	        }
	    }
	    if(flag)
	    mx=max(mx,count1);
	}
	cout<<mx;
}

Measured memory_bytes: 512
/* ***********************************************
Author        :dasinlsb
Created Time  :2018/6/1 23:48:40
File Name     :C:\dasin\mine.cpp
************************************************ */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
const int N=2005;
int n,c[2*N],a[2*N],f[2*N][N][2],g[N][N],p[2][N];
inline void up(int&x,int y){if(x==-1||y<x)x=y;}
int main(){
  //freopen("C:/dasin/aa.in","r",stdin);
  //freopen("C:/dasin/mine.out","w",stdout);
  int i,j,k;char str[5];
  scanf("%d",&n);
  for(i=1;i<=2*n;++i){
    scanf("%s%d",str,a+i);
    c[i]=str[0]=='B';
    p[c[i]][a[i]]=i;
  }
  for(i=1;i<=2*n;++i){
    for(j=n;j;--j){
      for(k=0;k<2;++k){
        f[i][j][k]=f[i][j+1][k]+(p[k][j]<i);
      }
    }
  }
  memset(g,-1,sizeof(g));
  g[0][0]=0;
  for(i=0;i<=n;++i){
    for(j=0;j<=n;++j){
      if(i<n)up(g[i+1][j],g[i][j]+f[p[0][i+1]][i+1][0]+f[p[0][i+1]][j+1][1]);
      if(j<n)up(g[i][j+1],g[i][j]+f[p[1][j+1]][i+1][0]+f[p[1][j+1]][j+1][1]);
    }
  }
  printf("%d\n",g[n][n]);
  return 0;
}


Measured memory_bytes: 78720
import heapq

n, m = [int(i) for i in input().split()]
inf = 10**10
path = [[0] * n for _ in range(n)]
Q = [[inf] * n for _ in range(n)]
ans = 0
pathnum = []

for i in range(m):
    a, b, c = map(lambda x: int(x)-1 ,input().split())    
    path[a][b] = path[b][a] = c+1
    pathnum.append((a,b))

for i in range(n):
    decided = [False for _ in range(n)]
    H = []
    Q[i][i] = 0
    heapq.heappush(H,(0,i))
    while False in decided:
        while True:
            k = heapq.heappop(H)
            k = k[1]
            if not decided[k]:
                decided[k] = True
                break
        for j in range(n):
            if path[k][j] == 0:
                continue
            if decided[j]:
                continue
            Q[i][j] = min(Q[i][k] + path[k][j], Q[i][j])
            heapq.heappush(H,(Q[i][j],j))

for i in pathnum:
    if Q[i[0]][i[1]] == inf:
        continue
    elif Q[i[0]][i[1]] != path[i[0]][i[1]]:
        ans += 1
print(ans)
    

Measured memory_bytes: 3572
## coding: UTF-8
from decimal import *
from itertools import permutations, combinations,combinations_with_replacement,product
import math


N = int(input())
l = []
for i in range(N):
    l.append(input())


l = sorted(l)

last = ''
counter = 0
for i in range(N):
    if(l[i] != last):
        counter += 1
    last = l[i]

print(counter)

Measured memory_bytes: 26208
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

int inputValue() {
    int a;
    cin >> a;
    return a;
}

void inputArray(int *p, int a) {
    rep(i, a) { cin >> p[i]; }
}

void inputVector(vector<int> *p, int a) {
    rep(i, a) {
        int input;
        cin >> input;
        p->push_back(input);
    }
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

int main() {
    // source
    int n, m, X, Y;
    cin >> n >> m >> X >> Y;
    int x[n], y[m];
    rep(i, n) { cin >> x[i]; }
    rep(i, m) { cin >> y[i]; }

    sort(x, x + n);
    sort(y, y + m);

    if (x[n - 1] < y[0]) {
        repd(z, x[n - 1] + 1, y[0] + 1) {
            if (X < z && z <= Y) {
                cout << "No War" << endl;
                return 0;
            }
        }
    }
    cout << "War" << endl;
    return 0;
}


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

typedef long double lld;

#define REP(i,n) for(int i=0;i<n;i++)
#define EPS (1e-7)
#define INF (1e9 + 1)
#define PI (acos(-1))

int H, W;
string S[10010];
int m[2010][2010] = {};

int main()
{
	cin >> H >> W;
	REP(i, H) {
		cin >> S[i];
		S[i] += "#";
	}
	REP(j, W + 1) S[H] += "#";

	//nsは前回のシャープの場所覚える
	int ns;
	REP(i, H) {
		ns = -1;
		REP(j, W + 1) {
			if (S[i][j] == '#') {
				//それまでのとこに(j - ns) - 1を足す
				for (int k = ns + 1; k < j; k++) {
					m[i][k] += (j - ns) - 1;
				}
				ns = j;
			}
		}
	}

	REP(j, W) {
		ns = -1;
		REP(i, H + 1) {
			if (S[i][j] == '#') {
				//それまでのとこに(i - ns) - 1を足す
				for (int k = ns + 1; k < i; k++) {
					m[k][j] += (i - ns) - 1;
				}
				ns = i;
			}
		}
	}
/*
	REP(i, H) {
		REP(j, W) {
			cout << m[i][j] << " ";
		}
		cout << endl;
	}
*/
	int ans = 0;
	REP(i, H) {
		REP(j, W) {
			ans = max(ans, m[i][j]);
		}
	}
	cout << ans - 1 << endl;
}

Measured memory_bytes: 20096
#include <stdio.h>                      // use string s; getline(cin>>ws,s); where cin>>ws eats the white spaces.
#include <stdlib.h>                             // this above method is important when we need to string s ="hi my name is blah blah....\n"
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <iomanip>
#include <cmath>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include<math.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define ll long long
#define ld long double
#define inf 1000000007
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
#define ii pair<int,int>
#define iii pair<int,ii>
#define iiii pair<iii,int>
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define vv vector
#define endl "\n"
#define ld long double
using namespace std;

// 1944 324 54 9 18 3 6 1
int main(){
ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
int ans=0,l,r,d;
cin>>l>>r>>d;
for(int i=l;i<=r;i++)
{
    if(i%d==0)
        ans++;
}
cout<<ans;

}

Measured memory_bytes: 3624
import sys
def input(): return sys.stdin.readline().rstrip()
class UnionFind():
    def __init__(self, n):
        self.n=n
        self.parents=[-1]*n # 親(uf.find()で経路圧縮して根)の番号。根の場合は-(そのグループの要素数)
    def find(self,x):
        #グループの根を返す
        if self.parents[x]<0:return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]
    def unite(self,x,y):
        #要素x,yのグループを併合
        x,y=self.find(x),self.find(y)
        if x==y:return
        if self.parents[x]>self.parents[y]:#要素数の大きい方をxに
            x,y=y,x
        self.parents[x]+=self.parents[y]
        self.parents[y]=x #要素数が大きい方に併合
    def size(self,x):
        #xが属するグループの要素数
        return -self.parents[self.find(x)]
    def same(self,x,y):
        #xとyが同じグループ？
        return self.find(x)==self.find(y)
    def members(self,x):
        #xと同じグループに属する要素のリスト
        root=self.find(x)
        return [i for i in range(self.n) if self.find(i)==root]
        
def main():
    n,m,k=map(int,input().split())
    AB=[tuple(map(int,input().split())) for i in range(m)]
    CD=[tuple(map(int,input().split())) for i in range(k)]
    un=UnionFind(n)
    friend=[[] for _ in range(n)]
    for a,b in AB:
        un.unite(a-1,b-1)
        friend[a-1].append(b-1)
        friend[b-1].append(a-1)
    blockc=[0]*n
    for c,d in CD:
        if un.same(c-1,d-1):
            blockc[c-1]+=1
            blockc[d-1]+=1
    for i in range(n):
        print(un.size(i)-1-blockc[i]-len(friend[i]))
 
if __name__=='__main__':
    main()

Measured memory_bytes: 54544
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//




int main() {

    string s;
    cin >> s;
    int len = s.size();
    bool flag = true;
    for (int i = 0; i < len; ++i) {
        if (s[i] != s[len-1-i]) flag = false;
    }
    for (int i = 0; i < (len - 1) / 2; ++i) {
        if (s[i] != s[len/2-1-i]) flag = false;
        if (s[len/2+1+i] != s[len-1-i]) flag = false;
    }

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    

    return 0;
}






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

using namespace std;

int main()
{
    int N;
    vector<int> A;
    vector<int> B;
    vector<int> C;

    cin >> N;

    A.resize(N);
    B.resize(N);
    C.resize(N);

    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> B[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> C[i];
    }

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    long long ans = 0;

    for (int i = 0; i < N; i++)
    {

        auto a = lower_bound(A.begin(), A.end(), B[i]);
        auto b = upper_bound(C.begin(), C.end(), B[i]);
        ans += (a - A.begin()) * (C.end() - b);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	lli a, b, h;
	cin >> a >> b >> h;

	COUT((a + b) * h / 2);

	return 0;
}

Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

using P = pair<int, int>;

int factorial(int n) {
    if (n == 0) return 1;
    return n * factorial(n - 1);
}

int main(int argc, const char * argv[]) {
    int N;
    cin >> N;

    vector<P> pts(N);
    vector<int> indices(N);
    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        pts[i] = make_pair(x, y);
        indices[i] = i;
    }

    vector<vector<double>> dist(N, vector<double>(N));
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            double dx = pts[i].first - pts[j].first;
            double dy = pts[i].second - pts[j].second;
            double d = sqrt(dx * dx + dy * dy);
            dist[i][j] = d;
            dist[j][i] = d;
        }
    }

    double total = 0.0;
    do {
        for (int i = 0; i < N - 1; i++) {
            total += dist[indices[i]][indices[i+1]];
        }
    } while(next_permutation(indices.begin(), indices.end()));

    cout << fixed << setprecision(10) << total / factorial(N) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
#define N 250000

const ll MOD=998244353;

main(){
    int n;cin>>n;
    int x;cin>>x;
    if(x==1||n*2-1==x)cout<<"No";
    else{
        cout<<"Yes\n";
        if(n==2){cout<<"1\n2\n3\n";return 0;}
        if(x<n){
            deque<int> dq{x+2,1,x,x+1};
            rep2(i,2,n*2-1){
                if(abs(i-x-1)<=1)continue;
                if(dq.size()<n+1)dq.push_front(i);
                else dq.pb(i);
            }
            for(auto e:dq)cout<<e<<endl;
        }
        else if(x>n){
            deque<int> dq{x-2,n*2-1,x,x-1};
            rep2(i,1,n*2-2){
                if(abs(i-x+1)<=1)continue;
                if(dq.size()<n+1)dq.push_front(i);
                else dq.pb(i);
            }
            for(auto e:dq)cout<<e<<endl;
        }
        else{
            rep2(i,1,n*2-1)cout<<i<<endl;
        }
        // rep2(i,1,n*2-1)cout<<dq[i]<<endl;
    }
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    string s;
    cin >> s;
    int ans=1000;
    int count=0;
    int y=0;
    for(char x='a';x<='z';x++){
        count=0;
        y=-1;
        rep(i,s.size()){
            if(s.at(i)==x){
                count=max(i-y-1,count);
                y=i;
            }else if(i==s.size()-1){
                count=max(i-y,count);
            }
        }
        ans=min(ans,count);
    }
    cout << ans << endl;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)

using namespace std;
typedef long long ll;
ll tax[50005];
int main()
{
    rep1(i,50000) tax[i]=-1;
    rep1(i,50000)
    {
        if(int(i*1.08)>50000) break;
        tax[int(i*1.08)]=i;
    }
    ll n;
    while(cin>>n)
    {
        if(tax[n]==-1) cout<<":(\n";
        else cout<<tax[n]<<"\n";
    }

}


Measured memory_bytes: 640
a, b, c = map(int, input().split())
d = 0 + abs(b - a) + abs(c - b)
e = 0 + abs(c - a) + abs(b - c)
f = 0 + abs(a - b) + abs(c - a)
g = 0 + abs(c - b) + abs(a - c)
h = 0 + abs(a - c) + abs(b - a)
i = 0 + abs(b - c) + abs(a - b)
print(min(d, e, f, g, h, i))

Measured memory_bytes: 38384
#include<map>
#include<vector>
#include<iostream>
#include<algorithm>
#include<numeric>
#include <string.h>
#include <unordered_map>
#include <set>
#include <math.h>

using namespace std;

typedef long long ll;

string s;

int fact(int i) {
    if (i <= 1) {
        return 1;
    }
    return i * fact(i - 1);
}

void solve() {
    int n;
    cin >> n;
    double len = 0;
    vector<int> x(n), y(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j) {
                continue;
            }
            len += hypot(x[i] - x[j], y[i] - y[j]);
        }
    }
    cout << fixed;
    cout.precision(10);
    cout << len / n;
}


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}





Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int rCnt = sc.nextInt();
		int dCnt = sc.nextInt();
		int minR = 100000;
		int minD = 100000;
		int m = sc.nextInt();
		int[] rList = new int[rCnt];
		int[] dList = new int[dCnt];
		for(int i=0;i<rCnt;i++) {
			rList[i] = sc.nextInt();
			if(rList[i]<minR){
				minR = rList[i];
			}
		}
		for(int i=0;i<dCnt;i++) {
			dList[i]=sc.nextInt();
			if(dList[i]<minD){
				minD = dList[i];
			}
		}
		int minC = minR+minD;
		for(int i=0;i<m;i++) {
			int cost = rList[sc.nextInt()-1]+dList[sc.nextInt()-1]-sc.nextInt();
			if(cost<minC){
				minC = cost;
			}			
		}
		
		System.out.println(minC);
		
	}
	

}


Measured memory_bytes: 149788
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <map>
using namespace std;
#define MAXN 3
#define MAXM 120000
#define FI first
#define SE second
const int INF =1000000007;
char dice[6][MAXN][MAXN];
int ans=0,now[6];
int ty[6][3][3];
const int rcmp[6][4]={{0,2,5,2},{0,2,4,0},{1,3,5,2},{1,3,4,0},{4,5,0,2},{4,5,2,0}};
const int ccmp[6][4]={{0,2,1,2},{0,2,3,0},{1,3,2,2},{1,3,0,0},{4,5,1,2},{4,5,3,0}};
const int from[4][6]={{4,1,5,3,2,0},{0,4,2,5,3,1},{5,1,4,3,0,2},{0,5,2,4,1,3}};
void dfs(int dep)
{
    if(dep>=ans)    return ;
    int flag=0;
    for(int k=0;k<6;++k)
        if((rcmp[k][0]==now[0]&&rcmp[k][1]==now[2]||rcmp[k][0]==now[2]&&rcmp[k][1]==now[0])&&rcmp[k][2]==now[5])
        {
            int a=rcmp[k][0],c=rcmp[k][3];
            for(int i=0;i<3;++i)
                flag|=ty[a][c][i];
        }
    for(int k=0;k<6;++k)
        if((ccmp[k][0]==now[0]&&ccmp[k][1]==now[2]||ccmp[k][0]==now[2]&&ccmp[k][1]==now[0])&&ccmp[k][2]==now[5])
        {
            int a=ccmp[k][0],c=ccmp[k][3];
            for(int i=0;i<3;++i)
                flag|=ty[a][i][c];
        }
    if(flag==3)
    {
        ans=min(ans,dep);
        return ;
    }
    int tnow[6];
    memcpy(tnow,now,sizeof(now));
    for(int i=0;i<4;++i)
    {
        for(int j=0;j<6;++j)    now[j]=tnow[from[i][j]];
        dfs(dep+1);
    }
}
int main()
{
    //freopen("J:\\Mydocument\\Code\\input.txt","r",stdin);
    char tmp[4];
    while(1)
    {
        for(int i=0;i<6;++i)
            for(int j=0;j<3;++j)
            {
                scanf("%s",tmp);
                for(int k=0;k<3;++k)    dice[i][j][k]=tmp[k];
            }
        if(dice[0][0][0]=='#')   break;
        ans=4;
        for(int i=0;i<2;++i)
            for(int j=0;j<3;++j)
                for(int k=0;k<3;++k)
                    ty[i][j][k]=(dice[i][j][k]=='*')+(dice[i+2][j][2-k]=='*')*2;
        for(int j=0;j<3;++j)
            for(int k=0;k<3;++k)
                ty[4][j][k]=(dice[4][j][k]=='*')+(dice[5][2-j][k]=='*')*2;
        for(int i=0;i<6;++i)    now[i]=i;
        dfs(0);
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1136
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	while(cin>>n,n){
		vector<int>in(n);
		rep(i,in.size())cin>>in[i];
		int sum=32;
		int co=0;
		while(sum>=0){
			sum-=(sum-1)%5;
			if(sum<0)sum=0;
			cout<<sum<<endl;
			if(!sum)break;
			sum-=in[co%n];
			if(sum<0)sum=0;
			cout<<sum<<endl;
			if(!sum)break;
			co++;
		}
	}
}

Measured memory_bytes: 1188
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

bool dp[10001];

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  fill(dp, dp + 10001, false);
  dp[0] = true;
  for(int i = 0; i < n; i++){
    int s;
    cin >> s;
    for(int j = 10000; j >= 0; j--){
      if(dp[j] && j + s <= 10000)dp[j + s] = true;
    }
  }
  int res = 0;
  for(int i = 0; i < 10001; i++){
    if(i % 10 == 0)continue;
    if(dp[i])res = i;
  }
  cout << res << endl;
	return 0;
}


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

int main(){
  int x; cin >> x;
  bool dp[100010];
  for (int i = 0; i <= x; i++){
    dp[i] = false;
  }
  dp[0] = true;
  int a[] = {100, 101, 102, 103, 104, 105};
  for (int i = 1; i <= x; i++){
    for (int j = 0; j < 6; j++){
      if (i - a[j] >= 0 && dp[i-a[j]]) dp[i] = true;
    }
  }
  cout << (dp[x] ? 1 : 0) << endl;
  return 0;
}

Measured memory_bytes: 384
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t N, K;
    std::cin >> N >> K;
    std::unordered_map<int64_t, int64_t> num;
    for (int64_t i = 0; i < N; i++)
    {
        int64_t ball;
        std::cin >> ball;
        num[ball - 1]++;
    }

    if ((int64_t)num.size() <= K)
    {
        std::cout << 0 << std::endl;
        return;
    }

    std::vector<int64_t> num_vec;
    for (auto v : num) num_vec.push_back(v.second);

    std::sort(num_vec.begin(), num_vec.end());

    int64_t val = num.size();
    int64_t ans = 0;
    for (auto v : num_vec)
    {
        ans += v;
        val--;
        if (val <= K) break;
    }

    std::cout << ans << std::endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}


Measured memory_bytes: 14476
#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>;
 
 const ll MX =1e18;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a.at(i);
    ll ans=1;

    //ソートしとくと0判定が楽
    sort(a.begin(),a.end());
    // rep(i,n) cout<<a.at(i)<<endl;

    rep(i,n){
        //aの要素に0があったら即座に0出力して終わり．
        if(a.at(i)==0){
            cout<<0<<endl;
            return 0;
        }
        //1e18を超えたら-1を出力して終わり．
        if(MX/ans>=a.at(i)){//この条件だと次a(i)を数かける前に終われる．
            ans *= a.at(i);  
        }
        else{
            cout<<-1<<endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4052
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto s = readln.chomp;
  foreach (e; s) {
    if (e == '1') {
      write('9');
    } else if (e == '9') {
      write('1');
    } else {
      write(e);
    }
  }
  writeln("");
}


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

int main(){
int K;
cin >> K;
vector<int> v={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};
cout << v.at(K-1) << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	n := readi()
	p := make([]int, n)
	for i := 0; i < n; i++ {
		p[i] = readi()
	}
	q := make([]int, n)
	for i := 0; i < n; i++ {
		q[i] = readi()
	}

	cp := make([]int, len(p))
	copy(cp, p)
	perms := make([]string, 0)
	for _, perm := range permutations(cp) {
		s := strings.Trim(strings.Join(strings.Fields(fmt.Sprint(perm)), ""), "[]")
		perms = append(perms, s)
	}
	sort.Strings(perms)

	ps := strings.Trim(strings.Join(strings.Fields(fmt.Sprint(p)), ""), "[]")
	qs := strings.Trim(strings.Join(strings.Fields(fmt.Sprint(q)), ""), "[]")

	a := -1
	b := -1
	i := 0
	for {
		if perms[i] == ps {
			a = i
		}
		if perms[i] == qs {
			b = i
		}
		if a != -1 && b != -1 {
			break
		}
		i++
	}
	fmt.Println(abs(a - b))
}

/*-------------------utilities-------------------*/

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

// 最大公約数
func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

// 最小公倍数
func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func comb(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func permutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7

	COMB_MAX = 510000
)

var (
	readString func() string
)

var (
	fac  = [COMB_MAX]int{}
	finv = [COMB_MAX]int{}
	inv  = [COMB_MAX]int{}
)

func init() {
	readString = newReadString(os.Stdin)
}

func combInit() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i := 2; i < COMB_MAX; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		finv[i] = finv[i-1] * inv[i] % MOD
	}
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


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

int main(){
  string a,b;
  cin >> a >> b;
    
  if(a.at(0)==b.at(2) and a.at(1)==b.at(1) and a.at(2)==b.at(0)){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

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

int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    string S;
    cin >> S;

    int tukaninzu = 0;
    int kaigaininzu = 0;

    for (int i = 0; i < N; i++)
    {
        char chr = S[i];
        if (chr == 'a')
        {
            if (tukaninzu < A + B)
            {
                cout << "Yes" << endl;
                tukaninzu++;
            }
            else
            {
                cout << "No" << endl;
            }
        }
        else if (chr == 'b')
        {
            if (tukaninzu < A + B && kaigaininzu < B)
            {
                cout << "Yes" << endl;
                tukaninzu++;
                kaigaininzu++;
            }
            else
            {
                cout << "No" << endl;
            }
        }
        else
        {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define maxn 100005
int main(){__
	int n;
	cin >> n;
	map<int,int> c;
	lli ans = 0ll;
	for(int i=0; i < n; i++){
		int x;
		cin >> x;
		ans+=x;
		c[x]++;
	}
	int q;
	cin >> q;
	while(q--){
		int a,b;
		cin >> a >> b;
		if(c.find(a) != c.end()){
			int xx = c[a];
			ans-= lli(a) * lli(xx);
			ans+= lli(b) * lli(xx);
			c.erase(c.find(a));
			c[b]+=xx;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 6580
#include <bits/stdc++.h>
using namespace std;
#define NUM_MAX 2147483647
#define N_MAX (1 << 17)
int n;
int dat[2*N_MAX-1];

void init(int n_) {
    n = 1;
    while(n < n_) n *= 2;
    for(int i=0; i < 2 * n - 1; ++i) dat[i] = NUM_MAX;
}

void update(int k, int a) {
    k += n - 1;
    dat[k] = a;
    while(k > 0) {
        k = (k - 1) / 2;
        dat[k] = min(dat[2 * k + 1], dat[2 * k + 2]);
    }
}

int query(int a, int b, int k, int l, int r) {
    if(r <= a || l >= b) return NUM_MAX;

    if(a <= l && r <= b) return dat[k];
    else {
        int vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        int vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
}

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

    for(int i=0; i<q; ++i) {
        int c,x,y;
        cin >> c >> x >> y;
        if(c == 0) update(x, y);
        else cout << query(x, y + 1, 0, 0, n) << endl;
    }
    return 0;
}


Measured memory_bytes: 4124
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int n = sc.nextInt();

      if(n%2!=0){
        System.out.print(n*2);
        System.exit(0);
      }
        System.out.print(n);

      }

  }


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

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

int N,M,K;
int C[101010];

template<int um> class UF {
	public:
	vector<int> par,rank,cnt;
	UF() {par=rank=vector<int>(um,0); cnt=vector<int>(um,1); for(int i=0;i<um;i++) par[i]=i;}
	void reinit() {int i; FOR(i,um) rank[i]=0,cnt[i]=1,par[i]=i;}
	int operator[](int x) {return (par[x]==x)?(x):(par[x] = operator[](par[x]));}
	int count(int x) { return cnt[operator[](x)];}
	int operator()(int x,int y) {
		if((x=operator[](x))==(y=operator[](y))) return x;
		cnt[y]=cnt[x]=cnt[x]+cnt[y];
		if(rank[x]>rank[y]) return par[x]=y;
		rank[x]+=rank[x]==rank[y]; return par[y]=x;
	}
};
UF<101010> uf;
int prec[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	int a=1,b=1;
	cin>>N>>M>>K;
	MINUS(prec);
	FOR(i,N) {
		cin>>C[i];
		if(C[i]) {
			if(prec[C[i]]>=0) uf(prec[C[i]],i);
			prec[C[i]]=i;
		}
	}
	
	
	priority_queue<pair<int,pair<int,int>>> PQ;
	FOR(i,M) {
		cin>>x>>y>>j;
		PQ.push({-j,{x-1,y-1}});
	}
	
	ll ret=0;
	K--;
	while(PQ.size()&&K) {
		auto e=PQ.top();
		PQ.pop();
		if(uf[e.second.first]!=uf[e.second.second]) {
			K--;
			uf(e.second.first,e.second.second);
			ret+=-e.first;
		}
	}
	if(K) cout<<-1<<endl;
	else cout<<ret<<endl;
}


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


Measured memory_bytes: 3960
#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;
int main()
{
  int N,K;
  cin >> N >> K;
  vector<int> l(N + 10, 0);
  for (int i=0; i < N; i++) {
    cin >> l.at(i);
  }
  int s = 0;
  sort(l.begin(), l.end(), greater<int>());
  for (int i=0; i < K; i++) {
    s += l.at(i);
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll n,q;
    cin>>n>>q;
    V vec(n);
    rep(i,n)cin>>vec[i];
    V last(n+1,-1);
    vector<pair<P,ll>> query(q);
    map<P,ll> mp; 
    rep(i,q){
        cin>>query[i].F.S>>query[i].F.F;
        query[i].F.S--;
        query[i].F.F--;
        query[i].S=i;
    }
    sort(all(query));
    BinaryIndexedTree<ll> tree(n);
    ll nowR=0;
    V res(q);
    rep(index,q){
       // cout<<endl;
        rep3(i,nowR,query[index].F.F+1){
            if(last[vec[i]]==-1){
                last[vec[i]]=i;
                tree.add(i,1);
               // cout<<"ADD "<<i<<" "<<vec[i]<<endl;
            }else{
                tree.add(last[vec[i]],-1);
                tree.add(i,1);
              //  cout<<"ERASE"<<last[vec[i]]<<endl;
                last[vec[i]]=i;
            //    cout<<"ADD"<<i<<endl;
                
            }
        }
        
        nowR=query[index].F.F+1;
        ll tempres;
        if(query[index].F.S==0){
            tempres=tree.sum(query[index].F.F);
        }else{
            tempres=tree.sum(query[index].F.F)-tree.sum(query[index].F.S-1);
        }
        res[query[index].S]=tempres;
    }
    for(auto i:res){
        cout<<i<<endl;
    }
}


Measured memory_bytes: 31140
#include <queue>
#include <stack>
#include <iostream>
#include <string>
using namespace std;
int main(){
  stack<char> qu;
  stack<char> qu2;
  string n;
  cin >> n;
  int i=0;
  for(int j=0;j<n.size();j++){
    
    if(n[j] == '0' || n[j] == '1'){
      qu.push(n[j]);
    }else if(n[j] == 'B'){
      if(!qu.empty()){
        qu.pop();
      }
    }
  }
  while (!qu.empty()) {
    qu2.push(qu.top());
    qu.pop();
  }
  while (!qu2.empty()) {
    cout << qu2.top();
    qu2.pop();
  }
  cout << endl;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,k;
  int array[200005];
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>array[i];
  }
  
  for(int i=0;i<n-k;i++){
    if(array[i+k]>array[i]){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
  return(0);
}

Measured memory_bytes: 4400