akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;

int main(){
    
    string S;cin>>S;
    int x,y;cin>>x>>y;
    vector<int> A,B;
    int cnt=0,sumA=0,sumB=0;
    bool now=true;
    if(S[S.size()-1]!='T') S+="T";
    for(int i=0;i<S.size();i++){
        if(S[i]=='F') cnt++;
        else if(S[i]=='T'&&now){
            A.push_back(cnt);
            sumA+=cnt;
            cnt=0;
            now=false;
        }else if(S[i]=='T'&&!now){
            B.push_back(cnt);
            sumB+=cnt;
            cnt=0;
            now=true;
        }
    }
    if(abs(x)%2!=sumA%2||abs(y)%2!=sumB%2) cout<<"No"<<endl;
    else{
        int ansA,ansB;
        ansA=(sumA+x)/2;
        ansB=(sumB+y)/2;
    vector<bool> dp1(S.size()*2+5,false),dp2(S.size()*2,false);
    for(int i=0;i<A.size();i++){
        if(i==0) dp1[A[0]]=true;
        else{
            for(int j=S.size()+2;j>=A[0];j--){
                if(dp1[j]==true) dp1[j+A[i]]=true;
            }
        }
    }
        dp2[0]=true;
    for(int i=0;i<B.size();i++){
        for(int j=S.size()+2;j>=0;j--){
            if(dp2[j]==true) dp2[j+B[i]]=true;
        }
    }
        if(ansA<A[0]||ansB<0) cout<<"No"<<endl;
    else if(dp1[ansA]&&dp2[ansB]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;


int main(int argc, const char * argv[]) {

    int n, m, count =0;
    
    cin >> n >> m;
    
    int ans = n;
    
    int a[m];
    
    for(int i=0; i<m; i++) {
        cin >> a[i];
        count = count + a[i];
    }
    
    ans = n - count;
    
    if(ans >= 0) cout << ans << endl;
    else cout << -1 << endl;
    
    
    
    return 0;
    
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#define fio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define dsc [](int a,int b)->bool {return a>b;}
#define pb push_back
#define test int t; cin>>t;
#define MOD 1000000007LL
#define all(x) (x).begin(),(x).end()

using namespace std;

ll nxt() { ll x; cin>>x; return x; }

int main()
{
    #ifndef ONLINE_JUDGE
        fio
    #endif
    IOS

    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max({a*c,a*d,b*c,b*d})<<endl;

    return 0;
}


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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j, k) for (int i = j; i < k; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 60);

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    string s;

    cin >> n >> s;
    vi vr(n + 1, 0), vg(n + 1, 0), vb(n + 1);
    for (int i = n - 1; i >= 0; i--) {
        vr[i] = vr[i + 1] + (s[i] == 'R');
        vg[i] = vg[i + 1] + (s[i] == 'G');
        vb[i] = vb[i + 1] + (s[i] == 'B');
        // cout << vr[i] << " " << vg[i] << " " << vb[i] << endl;
    }

    int ans = 0;
    rep(i, 0, n) {
        rep(j, i + 1, n) {
            if (s[j] == s[i] or j == n - 1) continue;
            if (s[i] == 'R' and s[j] == 'G')
                ans += vb[j + 1];
            else if (s[i] == 'R' and s[j] == 'B')
                ans += vg[j + 1];
            else if (s[i] == 'B' and s[j] == 'G')
                ans += vr[j + 1];
            else if (s[i] == 'B' and s[j] == 'R')
                ans += vg[j + 1];
            else if (s[i] == 'G' and s[j] == 'R')
                ans += vb[j + 1];
            else if (s[i] == 'G' and s[j] == 'B')
                ans += vr[j + 1];
            // debug2(s[i], s[j]);
            // debug(ans);
            if (j + (j - i) < n and (s[2 * j - i] != s[i] and s[2 * j - i] != s[j])) ans--;
            // break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3744
#include<stdio.h>
#include <limits.h>
int gcd(long int p,long int q){
long int r; r=p%q;
while(r>0){p=q;q=r;r=p%q;}
return q;}

int main(){
long int A,a,b,c;
scanf("%ld %ld",&a,&b);
c=a*b;
A=c/gcd(a,b);
printf("%ld", A);
return 0;}

Measured memory_bytes: 128
from collections import deque
import sys


INF = float('inf')


def I(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))


class Graph:
    def __init__(self, n, is_directed=False):
        self.graph = [[] for _ in range(n)]
        self.is_directed = is_directed

    def add_edge(self, u, v):
        """頂点uから頂点vに辺を作る
        無向グラフの場合、uからvの方向の辺のみを記録する
        """
        self.graph[u].append(v)
        if not self.is_directed:
            self.graph[v].append(u)

    def bfs(self, start):
        """幅優先探索を行い始点から各頂点までの距離の配列を返す
        """
        distances = [INF] * len(self.graph)
        queue = deque([start])
        distances[start] = 0
        ans = [0] * len(self.graph)

        while queue:
            now = queue.popleft()
            for to in self.graph[now]:
                if distances[to] != INF:
                    continue
                queue.append(to)
                # 現在の頂点に隣接する頂点の道標を現在の頂点に向ける
                ans[to] = now
                distances[to] = distances[now] + 1
        return distances, ans


def main():
    n, m = LI()
    g = Graph(n)
    for _ in range(m):
        a, b = LI()
        a, b = a - 1, b - 1
        g.add_edge(a, b)

    bfs_res, ans = g.bfs(0)
    for d in bfs_res:
        if d == INF:
            print('No')
            return

    print('Yes')
    print(*map(lambda x: x + 1, ans[1:]), sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 39448
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using Data=pair<int,int>;
#define mod 1000000007 
long mmax(long a,long b,long c){
  if(a<b){
    return max(b,c);
  }else{
    return max(a,c);
  }
}

long mmin(long a,long b,long c){
  if(a<b){
    return min(a,c);
  }else{
    return min(b,c);
  }
}

long long modinv(long long a) {
    long long b = mod, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}

long long moddevide(long long a,long long b){return (a*modinv(b))%mod;}

long long modncr(long long n,long long r){
  long long i,plus=1;
  for(i=0;i<r;i++){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

long long euclidean_gcd(long long a, long long b) {
  if(a < b) return euclidean_gcd(b, a);
  long long r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

typedef struct unionfind{
  vector<int> par;
  unionfind(int N) :par(N){
    for(int i=0;i<N;i++)par[i]=i;
  }
  int root(int x){
    if(par[x]==x)return x;
    return par[x]=root(par[x]);
  }
  void unite(int x,int y){
    int px=root(x);
    int py=root(y);
    if(px!=py){
      par[px]=py;
    }
  }
  bool parcheck(int x,int y){
    int px=root(x);
    int py=root(y);
    return px==py;
  }
};

int main(){
  int i,N,K,L,a,b;
  cin>>N>>K>>L;
  unionfind road(N),train(N);

  for(i=0;i<K;i++){
    cin>>a>>b;
    road.unite(a-1,b-1);
  }
  for(i=0;i<L;i++){
    cin>>a>>b;
    train.unite(a-1,b-1);
  }
  map<Data,int> m;
  vector<Data> ans(N);
  for(i=0;i<N;i++){
    ans[i].first=road.root(i);
    ans[i].second=train.root(i);
    m[ans[i]]++;
  }
   for(i=0;i<N;i++){
    cout << m[ans[i]];
    cout <<" ";
  }
  return 0;
}

Measured memory_bytes: 15104
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int k;
  cin >> k;
  ll cnt = 9;
  queue<ll> que;
  
  vector<ll> seq;
  reps(i, 1, 10) {
    seq.push_back(i);
    que.push(i);
  }
  while(!que.empty()) {
    ll cv = que.front();
    que.pop();
    ll st = max(cv % 10 - 1, (ll)0);
    ll mx = min(cv % 10 + 1, (ll)9);
    for(ll i = st; i <= mx; i++) {
      ll v = cv*10 + i;
      seq.push_back(v);
      que.push(v);
    }
    if (seq.size() - 1 >= k) {
      cout << seq.at(k-1) << endl;
      return 0;
    }   
  }
  cout << seq.size() << endl;
  return 0;
}

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

class Program
{
    void Run()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int k = sc.NextInt();
        Console.WriteLine(k == 1 ? 0 : n - k);
    }

    static void Main(string[] args)
    {
        new Program().Run();
    }

    static long Gcd(long a, long b)

    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 13140
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

typedef string::const_iterator State;
string s;

// mmemewwemeww
void cat(State &begin) {
    if(*begin=='m') {
        begin++;
        cat(begin);
        if(*begin=='e') {
            begin++;
            cat(begin);
            if(*begin=='w') begin++;
        }
    }

}

int main() {
    cin>>s;
    s+="$";
    State begin=s.begin();
    cat(begin);

    string ans;
    if(*begin=='$') ans="Cat";
    else ans="Rabbit";
    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;
const ll mod=1e9+7;
const ll N=5e5+1;
const ll INF=1e10;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int n;
	cin>>n;
	if(n%1000==0) cout<<0;
	else cout<<1000-n%1000;
}


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

int main() {
    string Sa, Sb, Sc;
    cin >> Sa >> Sb >> Sc;
    vector<string> Ss = {Sa, Sb, Sc};
    vector<vector<char>> S = {{}, {}, {}};
    for (int i = 0; i < 3; i++){
        for (int j = Ss[i].length() - 1; j >= 0; j--){
            S[i].push_back(Ss[i][j]);
        }
    }
    vector<char> c = {'A', 'B', 'C'};
    int tmp = 0;
    char x;
    while (S[tmp].size() > 0){
        x = S[tmp][S[tmp].size() - 1];
        S[tmp].pop_back();
        if (x == 'a'){
            tmp = 0;
        }
        else if (x == 'b') {
            tmp = 1;
        }
        else {
            tmp = 2;
        }
    }
    cout << c[tmp] << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

 int main(){
     int a,p,applePie;
     double ap;
     0 <= a <= 100;
     0 <= p <= 100; 
     scanf("%d %d", &a, &p);
     p = a * 3 + p;
     ap = p / 2;
     applePie = ap;
     printf("%d", applePie);
     return 0;
 }

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通

int N;
vector<int> A;
bool F = true;
int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		A.push_back(a);
	}
	for (int i = 0; i < A.size(); i++) {
		if (A[i] % 2 == 0) {
			if (A[i] % 3 != 0 && A[i] % 5 != 0) {
				F = false;
			}
		}
	}

	if (F) cout << "APPROVED";
	else cout << "DENIED";

	return 0;
}

Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, a = list(map(int, readline().split()))
    x = list(map(int, readline().split()))
    for i in range(n):
        x[i] -= a
    ls = [0] * 5010
    ls[2500] = 1
    for v in x:
        if v == 0:
            for i in range(5010):
                ls[i+v] += ls[i]
        elif v > 0:
            for i in range(5009 - v, -1, -1):
                ls[i+v] += ls[i]
        elif v < 0:
            for i in range(5009 + v):
                ls[i+v] += ls[i]
    print(ls[2500] - 1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 39152
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect


class Scanner():
    def int():
        return int(sys.stdin.readline().rstrip())

    def string():
        return sys.stdin.readline().rstrip()

    def map_int():
        return [int(x) for x in Scanner.string().split()]

    def string_list(n):
        return [input() for i in range(n)]

    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    def roundUp(a, b):
        return -(-a // b)

    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    def toLowerMultiple(a, x):
        return (a // x) * x

    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7


def main():
    # sys.stdin = open("sample.txt")
    N, M = Scanner.map_int()
    if N == M == 1:
        print(1)
    elif N == 1:
        print(M-2)
    elif M == 1:
        print(N-2)
    else:
        print((N-2) * (M-2))

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 38512
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

using namespace std;
using ll = long long;

int main()
{
	vector<int> v(3);
	for (int i = 0; i < 3; i++)
		cin >> v[i];
	sort(v.begin(), v.end());
	cout << v[0] * v[1] / 2 << endl;
}



Measured memory_bytes: 256
n  = int(input())
xs = [0]
ys = [0]
zs = [0]
p  = None
c  = 0

xs.extend([int(x) for x in input().split()])
ys.extend([int(x) for x in input().split()])
zs.extend([int(x) for x in input().split()])

for i in range(1, n + 1):
	a  = xs[i]
	c += ys[a]
	if a - 1 == p:
		c += zs[p]
	p = a
	
print(c)


Measured memory_bytes: 3064
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	H, W := sc.nextInt(), sc.nextInt()
	if H%3 == 0 || W%3 == 0 {
		fmt.Println(0)
		return
	}
	ans := divide(H, W)
	ans2 := divide(W, H)
	fmt.Println(min(ans, ans2))
}

func divide(h, w int) int {
	var dividePoint, rec1, rec2, rec3 int
	if h%3 == 1 {
		dividePoint = h / 3
	} else {
		dividePoint = h/3 + 1
	}
	rec1 = w * dividePoint
	rec2, rec3 = divideToTwo(h-dividePoint, w)
	ans := max(rec1, rec2, rec3) - min(rec1, rec2, rec3)
	rec2, rec3 = divideToTwo(w, h-dividePoint)
	ans2 := max(rec1, rec2, rec3) - min(rec1, rec2, rec3)
	return min(ans, ans2)
}

func divideToTwo(h, w int) (int, int) {
	total := h * w
	rec := h * (w / 2)
	return rec, total - rec
}


Measured memory_bytes: 640
N = int(input())
inputs = list(map(int, input().split()))
#print(inputs)
total = 1
flag = 0
if 0 in inputs:
    print('0')
else:
    for i in range(len(inputs)):
        total = total * inputs[i]
        if total > 10 ** 18:
            print('-1')
            flag = 1
            break
    if flag == 0:
        print(total)

Measured memory_bytes: 84496
a1 = input().split()
a2 = input().split()
a3 = input().split()
A = [a1, a2, a3]
N = input()
N = int(N)

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

ans = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

for b in B:
  for i in range(3):
    for j in range(3):
      if int(A[i][j]) == b:
        ans[i][j] = 1

flag = False
if sum(ans[0]) == 3 or sum(ans[1]) == 3 or sum(ans[2]) == 3:
	flag = True
if (ans[0][0] + ans[1][0] + ans[2][0]) == 3:
	flag = True
if (ans[0][1] + ans[1][1] + ans[2][1]) == 3:
	flag = True
if (ans[0][2] + ans[1][2] + ans[2][2]) == 3:
	flag = True
if (ans[0][0] + ans[1][1] + ans[2][2]) == 3:
	flag = True
if (ans[0][2] + ans[1][1] + ans[2][0]) == 3:
	flag = True

if flag:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
    int a, b, c;
    scanf("%d %d %d" ,&a ,&b ,&c);
    if(a-b<c){
        printf("%d\n",c-a+b);
    }
    else{
        printf("0\n");
    }
    return 0;
    
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include <string.h>
using namespace std;
int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		int ans=1,temp;
		int saikoro[6]={1,2,3,4,5,6};
		string dir;
		for(int i=0;i<n;i++){
			cin>>dir;
			if(dir=="North"){
				temp=saikoro[0];
				saikoro[0]=saikoro[1];
				saikoro[1]=saikoro[5];
				saikoro[5]=saikoro[4];
				saikoro[4]=temp;
			}
			if(dir=="East"){
				temp=saikoro[0];
				saikoro[0]=saikoro[3];
				saikoro[3]=saikoro[5];
				saikoro[5]=saikoro[2];
				saikoro[2]=temp;
			}
			if(dir=="South"){
				temp=saikoro[0];
				saikoro[0]=saikoro[4];
				saikoro[4]=saikoro[5];
				saikoro[5]=saikoro[1];
				saikoro[1]=temp;
			}
			if(dir=="West"){
				temp=saikoro[0];
				saikoro[0]=saikoro[2];
				saikoro[2]=saikoro[5];
				saikoro[5]=saikoro[3];
				saikoro[3]=temp;
			}
			if(dir=="Right"){
				temp=saikoro[1];
				saikoro[1]=saikoro[2];
				saikoro[2]=saikoro[4];
				saikoro[4]=saikoro[3];
				saikoro[3]=temp;
			}
			if(dir=="Left"){
				temp=saikoro[1];
				saikoro[1]=saikoro[3];
				saikoro[3]=saikoro[4];
				saikoro[4]=saikoro[2];
				saikoro[2]=temp;
			}
			ans+=saikoro[0];
		}
		cout<<ans<<endl;
	}
	
	return 0;
	
}

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

int main() {
  int a[] = { 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 };
  int k;
  cin >> k;
  cout << a[k - 1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N,K; cin>>N>>K;
	string S; cin>>S; S+='@';
	vector<ii> v;
	string s;
	int cur=1;
	for (int i=1; i<=N; i++) {
		if(S[i]==S[i-1]) cur++;
		else {
			v.push_back({i-cur,i-1}); s+=S[i-1];
			cur=1;
		}
	}
	int left=0, right=0, ret=0;
	cur=K;
	while(1) {
		if(s[right]=='0') cur--;
		if(right==v.size()-1) break;
		if(s[right+1]=='0' && cur==0) break;
		right++;
	}
	ret=max(ret,v[right].second-v[left].first+1);

	while(right!=v.size()-1) {
		while(1) {
			if(s[left]=='0') {
				cur++; left++; break;
			}
			left++;
		}
		while(1) {
			if(s[right]=='0') cur--;
			if(right==v.size()-1) break;
			if(s[right+1]=='0' && cur==0) break;
			right++;
		}
		ret=max(ret,v[right].second-v[left].first+1);
	}
	cout<<ret<<"\n";
	return 0;
}

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

const int INF = 10000000;

int main() {
	int n;
	while(cin >> n, n) {
		int tab[16][16];
		int m = 0;
		for(int i = 0; i < 16; i++) {
			for(int j = 0; j < 16; j++)
				tab[i][j] = INF;
			tab[i][i] = 0;
		}
		for(int i = 0; i < n; i++) {
			int a, b, c;
			cin >> a >> b >> c;
			tab[a][b] = tab[b][a] = c;
			m = max(m, max(a, b));
		}
		m++;
		for(int i = 0; i < 16; i++) {
			for(int j = 0; j < 16; j++) {
				for(int k = 0; k < 16; k++) {
					tab[j][k] = min(tab[j][k], tab[j][i] + tab[i][k]);
				}
			}
		}

		/*
		for(int i = 0; i < 16; i++) {
			for(int j = 0; j < 16; j++) {
				cout << tab[i][j] << " ";
			}
			cout << endl;
		}
		*/

		pair<int,int> ans(INF,-1);
		for(int i = 0; i < m; i++) {
			pair<int,int> tmp(0,i);
			for(int j = 0; j < m; j++) {
				tmp.first += tab[i][j];
			}
			ans = min(ans, tmp);
		}
		cout << ans.second << " " << ans.first << endl;
	}
}

Measured memory_bytes: 1156
N=int(input())
A=list(map(int, input().split()))
a=0
for i in range(N):
  if A[i]%2==0:
    if A[i]%3!=0 and A[i]%5!=0:
      a=1
if a==1:
  print("DENIED")
else:
  print("APPROVED")
      

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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i,n){
    cin >> p.at(i);
  }
  int cnt=0;
  for(int i=1; i<n-1; i++){
    if((p.at(i-1) <= p.at(i) && p.at(i) <= p.at(i+1)) ||
      (p.at(i-1) >= p.at(i) && p.at(i) >= p.at(i+1))) cnt++;
  }
  cout << cnt << endl;
  
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    vector<int> used(b, 0);
    int base = a % b;
    int now = base;
    bool ans = false;
    while (true)
    {
        ans |= now == c;
        if (used[now])
            break;
        else
            used[now] = 1;
        now = (now + base) % b;
    }
    if (ans)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int t,p,q,i,n,x,f =0;
        cin>>n;
        for(i=0;i<n;i++)
        {
            cin>>x;
            if(x%2==0 && x%3 != 0 && x%5!=0)f=1;
        }
    if(f==0)
        cout<<"APPROVED"<<endl;
    else
        cout<<"DENIED"<<endl;
    return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int main() {
    int a, b;
    int ret_a = 0, ret_b = 0, cnt = 0;
    while(~scanf("%d,%d", &a, &b)) {
        ret_a += a * b;
        ret_b += b;
        cnt++;
    }

    cout << ret_a << endl;
    cout << round((double)ret_b / cnt) << endl;
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
using namespace std;

#define INF 1145141919

struct L {
  int left, mid, right;
  L() : left(-1), mid(-1), right(-1) {}
  L(int l, int m, int r) : left(l), mid(m), right(r) {}
};

int N, M;
int D[100010], P[100010];

int G;
L E[200010];

long long cost(int x) {
  if (E[x].left == -1) return E[x].mid;
  long long a = cost(E[x].left), b = cost(E[x].mid), c = cost(E[x].right);
  return a + b + c - max(a, max(b, c));
}

bool solve(int x) {
  for (int i=0; i<G; i++) {
    if (E[i].left == -1) E[i].mid = 1;
  }
  for (int i=0; i<M; i++) {
    if (D[i] >= x) E[P[i]-1].mid = 0;
    else           E[P[i]-1].mid = INF;
  }

  int K = 0;
  for (int i=0; i<N-M; i++) K += D[i+M] >= x;
  return cost(G-1) <= K;
}

int main() {
  cin >> N >> M;
  for (int i=0; i<M; i++) cin >> D[i] >> P[i];
  for (int i=0; i<N-M; i++) cin >> D[i+M];

  queue<int> q;
  for (int i=0; i<N; i++) {
    q.push(i);
    E[i] = L(-1, -1, -1);
  }

  G = N;
  while (q.size() >= 3) {
    int a = q.front(); q.pop();
    int b = q.front(); q.pop();
    int c = q.front(); q.pop();
    E[G] = L(a, b, c);
    q.push(G);
    G += 1;
  }

  int lo = -1, hi = INF;
  while (hi != lo) {
    int mid = (lo + hi) / 2;
    if (solve(mid)) {
      if (solve(mid+1)) lo = mid + 1;
      else {
        hi = mid;
        break;
      }
    }
    else hi = mid - 1;
  }
  cout << hi << "\n";
  return 0;
}

Measured memory_bytes: 6308
/*
    Created by Ezio112
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define inf ll(10e16)
#define mod ll(10e8+7)
#define ff first
#define ss second
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    ll t;
    //cin>>t;
    t=1;
    while(t--)
    {
        ll n,k;
        cin>>n>>k;
        vector<ll> ar(n+1);
        for(ll i=1;i<=n;++i)
            cin>>ar[i];

        unordered_map<ll,ll> appeared;

        ll start=1,jumps=1,loop_size=1;

        while(k--)
        {
            appeared[start]=jumps++;
            start=ar[start];
            if(appeared.count(start))
            {
                loop_size=jumps-appeared[start];
                break;
            }
        }
        k%=loop_size;
        while(k--)
        {
            start=ar[start];
        }
        cout<<start;
    }
    return 0;
}


Measured memory_bytes: 11916
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;

int main(){
  string s;
  cin>>s;
  if(s[s.length()-1]=='s'){
    cout<<s<<"es"<<endl;
  }else{
    cout<<s<<'s'<<endl;
  }
  return 0;

}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 0x3f3f3f3f;
const ll LINF = 1ll << 55;
const ll MOD = 1e9 + 7;
const ll MAXN = 400 + 5;
const ll MAXK = 1e5 + 10;

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

template<typename T>
ostream& operator<< (ostream& out, vector<T>& vec) {
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        out << *it << " ";
    }
    return out;
}

template<typename T>
istream& operator>> (istream& in, vector<T>& vec) {
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        in >> *it;
    }
    return in;
}

int main() {
    ll A, B, X;
    cin >> A >> B >> X;
    if (A > X || A + B < X) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }
    return 0;
}

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

// バケット法のmap ver.

int main() {
  int N;
  cin >> N;
  
  map<int, bool> table;
  int key;
  for (int i = 0; i < N; i++) {
    cin >> key;
    table[key] = 1;
  }
  
  cout << table.size() << endl;
}


Measured memory_bytes: 3540
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

struct UnionFind(T)
{
	void init(T n) { par = new T[](n); foreach (i; 0..n) par[i] = i; cnt = new T[](n); fill(cnt, 1); }
	T root(T i) { return par[i] == i ? i : (par[i] = root(par[i])); }
	bool same(T i, T j) { return root(i) == root(j); }
	void unite(T i, T j) { i = root(i); j = root(j); if (i == j) return; par[i] = j; cnt[j] += cnt[i]; }
	T size(T i) { return cnt[root(i)]; }
	T[] par, cnt;
}

void main()
{
	auto N = RD;
	auto M = RD;

	UnionFind!long uf;
	uf.init(N);
	foreach (i; 0..M)
	{
		auto A = RD-1;
		auto B = RD-1;
		uf.unite(A, B);
	}

	long ans;
	foreach (i; 0..N)
	{
		ans.chmax(uf.size(i));
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}


Measured memory_bytes: 16256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n;
	ll l;
	cin >> n;
	cin >> l;
	vector<ll> s,t;
	s.pb(l);
	for(int i = 0; i < n - 1; i++) {
		cin >> l;
		if (i % 2 == 0){
			t.pb(l);
		}
		else{
			s.pb(l);
		}
	}

	if (n % 2 == 0){
		for(int i = t.size() - 1; i >= 0; i--) {
			cout << t[i] << ' ';
		}
		for(int i = 0; i < s.size(); i++) {
			cout << s[i] << ' ';
		}
	}
	else{
		for(int i = s.size() - 1; i >= 0; i--) {
			cout << s[i] << ' ';
		}
		for(int i = 0; i < t.size(); i++) {
			cout << t[i] << ' ';
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3948
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
using pii =pair<int,int>;
template <class T> bool chmin(T &a,T &b){if(a>b){ b^=a;a^=b;b^=a;return 1;}return 0;}
template <class T> bool chmax(T &a,T &b){if(a<b){ b^=a;a^=b;b^=a;return 1;}return 0;}

ll n,q;
vector<vector<ll>>paths;
vector<ll>sc;

void dfs(int v, int p) {
    sc.at(v) += sc.at(p);
    for (int e : paths.at(v)) if (p != e) dfs(e, v);
}

void input(){
    cin>>n>>q;
    ll a,b;
    sc.resize(n+1,0);
    paths.resize(n+1);
    rep(i,n-1){
        cin>>a>>b;
        paths[a].push_back(b);
        paths[b].push_back(a);
    }

    int x,p;
    rep(i,q){
        cin>>p>>x;
        sc[p]+=x;
    }
}
void src(){
    dfs(1,0);
    repi(j,1,n+1){cout<<sc[j]<<" ";}
    return;
}

int main(int argc,char* argv[]){
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 24320
#include <iostream>

using namespace std;

int N;
int main()
{

	cin >> N;

	double n = N / 1.08;

	int a = n;


	for (int i = a;; i++) {
		int b = i * 1.08;

		if (b == N) {
			cout << i << endl;
			break;
		}
		if (b > N) {
			cout << ":(" << endl;
			break;
		}

	}


	return 0;


}


Measured memory_bytes: 256
import math
import collections

def factorizec(n):
    fct = []
    b = 2
    e = 0
    while b * b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e > 0:
            fct.append((b, e))
        b += 1
        e = 0
    if n > 1:
        fct.append((n, 1))
    return fct

n = int(input())
mod = 10 ** 9 + 7
f = factorizec(math.factorial(n))
ans = 1
for i in f:
    ans *= i[1] + 1
print(ans % mod)

Measured memory_bytes: 3564
#include <iostream>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

bool is_prime(int n) {
  for (int p = 2; p * p <= n; p++) {
    if (n % p == 0) {
      return false;
    }
  }

  return true;
}

vector<pair<int, int>> factorize(int n) {
  vector<pair<int, int>> result;
  for (int p = 2; p * p <= n; p++) {
    if (is_prime(p)) {
      int cnt = 0;
      while (n % p == 0) {
        n /= p;
        cnt++;
      }
      if (cnt > 0) {
        result.push_back(make_pair(p, cnt));
      }
    }
  }
  if (n != 1) {
    result.push_back(make_pair(n, 1));
  }
  return move(result);
}

int main() {
  int n;
  cin >> n;
  vector<int> e(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    auto factor = factorize(i);
    for (const auto f : factor) {
      int p, j;
      tie(p, j) = f;
      e[p] += j;
    }
  }

  const int64_t MOD = 1e9 + 7;
  int64_t result = 1;
  for (int i = 1; i <= n; i++) {
    result *= e[i] + 1;
    result %= MOD;
  }
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int n; R(n);
    VI a(n);
    REP(i,n)R(a[i]);
    sort(ALL(a));
    int an1=a.back(),an2=-1;
    int ma=-1;
    REP(i,n){
        if(min(a[i],an1-a[i])>ma){
            ma=min(a[i],an1-a[i]);
            an2=a[i];
        }
    }
    W(an1,an2);
    return 0;
}


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

int main(void){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b;
    cin >> a >> b;
    int ans = 0;
    if(a>b){
        ans += a;
        a--;
    }else{
        ans += b;
        b--;
    }
    if(a>b){
        ans += a;
    }else{
        ans += b;
    }
    cout << ans;


    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <bitset>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10



int main() {
	int L; cin >> L;
	double x = L / 3.0;
	cout << fixed << setprecision(10) << x * x * x << endl;



	return 0;
}


Measured memory_bytes: 256
n, p = map(int,input().split())
src = list(map(int, input().split()))
even_count = 0 #偶数
odd_count = 0 #奇数
for s in src:
    if s%2 == 0:
        even_count += 1
    else:
        odd_count += 1
if p == 1 and odd_count == 0:
    print(0)
elif odd_count == 0:
    print(2**even_count)
else:
    print(2**even_count*2**(odd_count-1))

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

using namespace std;
using ll = long long;
using pll = pair <ll, ll>;

const ll mod = 1e9 + 7;

ll P[303030], D[303030];
ll n, h, ans;

void f(ll p, ll s, ll e)
{
	if(s == e)return;

	vector <ll> V;
	ll m, i, x, y, t, v;

	m = s + e >> 1;
	f(p << 1, s, m);
	f(p << 1 | 1, m + 1, e);

	for(i = s; i <= m; i ++){
		for(x = i + n - 1, t = 1; x != p; x >>= 1){
			t = t * x % mod;
		}
		for(y = P[i] + n - 1; y; y >>= 1){
			t = t * y % mod;
			D[y] += t; if(D[y] >= mod) D[y] -= mod;
			V.push_back(y);
		}
	}

	for(i = m + 1; i <= e; i ++){
		for(x = i + n - 1, t = p; x != p; x >>= 1){
			t = t * x % mod;
		}
		for(y = P[i] + n - 1, v = 0; y; y >>= 1){
			v = v * y % mod;
			ans = (ans + (D[y] - v) * t) % mod;
			v = D[y]; t = t * y % mod;
		}
	}

	for(ll &t: V) D[t] = 0;
}

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

	ll i;

	cin >> h; n = 1 << h - 1;

	for(i = 1; i <= n; i ++){
		cin >> P[i];
	}

	f(1, 1, n);

	cout << (ans + mod) % mod << "\n";

	return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{
    int N, W;
    cin >> N >> W;
    int w[100] = {};
    int v[100] = {};
    for (int i = 0; i<N;i++){
        cin >>w[i]>>v[i];
    }
    ll dp[2][100001] = {};
    dp[0][w[0]] = v[0];
    for (int i=1;i<N;i++){
        for(int j=0;j<W+1;j++){
            if(j >= w[i]){ 
                dp[1][j] = max(dp[0][j],dp[0][j-w[i]]+v[i]);
            }else{
                dp[1][j] = dp[0][j];
            }
        }
        for(int j=0;j<W+1;j++){
            dp[0][j] = dp[1][j];
        }
    }
    ll ans = 0;
    for (int j=0;j<W+1;j++){
        ans = max(ans, dp[0][j]);
    }
    cout << ans <<endl;

    // system("pause");
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >> n;
  rep(i,n+1){
    int tc=i*1.08;
    if(tc==n){
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
    

}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
    	//?¨??????\??????????????????????????§????????????
		Scanner scanner = new Scanner(System.in);
    	while(true){
    		int x = scanner.nextInt();
    		int y = scanner.nextInt();
    		//x ??? 0 ?????¨?????\???????????????
    		if(x == 0 && y == 0) break;
    		//x<y?????´???
    		if(x < y ){
    			System.out.println(x+" "+y);
    		}
    		else{
    			System.out.println(y+" "+x);
    		}
    	}
    }
}	

Measured memory_bytes: 34416
a, b, c, x, y = map(int, input().split())
ans = 999999999999999
for i in range(10 ** 5+1):
  	# maxの部分はx-iまたはy-iが負になったときに0を返すために用いてる
    ans = min(ans, i * 2*c + max(0, x-i) * a + max(0, y-i)*b)
print(ans)


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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    int n, w[1000], a[1000], mi=1e6;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> w[i];
        a[i]=w[i];
        mi=min(mi, w[i]);
    }
    sort(a, a+n);
    int idx[100001];
    for(int i=0;i<n;i++) idx[w[i]]=i;

    ll cost = 0;
    ll ccost, cnt;
    for(int i=0;i<n;i++){
        if(a[i]==w[i]) continue;
        int j=idx[a[i]];
        int s=w[j];
        ccost = 0;
        cnt = 0;
        while(true){
            int k=idx[a[j]];
            ccost += w[k];
            cnt++;
            w[j]=w[k];
            w[k]=s;
            j=k;
            if(w[k]==a[k]) break;
        }
        cost += min(ccost + cnt*a[i], ccost + (a[i]+mi)*2 + cnt*mi);
    }
    std::cout << cost << endl;
    
    return 0;
}


Measured memory_bytes: 3172
/**
 *   created: 16 November 2019  10:01:14
**/
#include<bits/stdc++.h>
using namespace std;

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

#define int long long
#define PB push_back
#define PPB pop_back
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rrep(i,a,b) for(int i = (int)(a-1); i>=(int)(b); i--)
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================

int32_t main()
{
	optimizeIO();
	int tt=1;
	//cin>>tt;
	while(tt--){
		int n;
		cin>>n;
		vector<int> v(n);
		rep(i,0,n)
			cin>>v[i];
		sort(all(v));
		int res =0;
		rep(i,0,n){
			rep(j,i+1,n){
				int a = v[i], b = v[j];
				int temp = lower_bound(all(v), a+b) - upper_bound(all(v), abs(a-b));
				// trace1(temp);
				if(v[i]>abs(a-b) && v[i]<a+b)
					temp--;
				if(v[j]>abs(a-b) && v[j]<a+b)
					temp--;
				// trace3(a,b,temp);
				res += max((ll)0,temp);
			}
		}
		cout<<res/3;	
	}
	return 0;
}


Measured memory_bytes: 384
H, W = gets.split.map(&:to_i)
As = H.times.map{gets.split.map(&:to_i)}
Bs = H.times.map{gets.split.map(&:to_i)}

ds = (0 ... H).map{|i| (0 ... W).map{|j| (As[i][j] - Bs[i][j]).abs} + [0]} + [[0] * (W + 1)]
mx = ds.flatten.max * (H + W)
dp = Array.new(H){Array.new(W, 0)}
dp[0][0] |= 1 << (mx + ds[0][0])
dp[0][0] |= 1 << (mx - ds[0][0])
H.times do |i|
  W.times do |j|
    if i > 0
      dp[i][j] |= dp[i - 1][j] << ds[i][j]
      dp[i][j] |= dp[i - 1][j] >> ds[i][j]
    end
    if j > 0
      dp[i][j] |= dp[i][j - 1] << ds[i][j]
      dp[i][j] |= dp[i][j - 1] >> ds[i][j]
    end
  end
end
ans = dp.last.last
puts (0 .. mx).find{|x| ans[mx + x] == 1 || ans[mx - x] == 1}

Measured memory_bytes: 51196
n= int(input())
a = list(map(int,input().split()))
mc = 0
mi = 999999999
hasz=False
for i in range(n):
    if a[i]==0:hasz=True
    else:
        if a[i]<0:
            mc+=1
            a[i]*=-1
        mi = min(mi,a[i])
if hasz or mc%2==0:print(sum(a))
else:print(sum(a)-mi*2)

Measured memory_bytes: 14412