akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

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

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	x := r.nextInt()

loop:
	for xi := 2; ; xi++ {

		n := xi * x
		a := make([]bool, n+1)
		for i := 2; i*i <= n; i++ {
			if !a[i] {
				for j := i; j < n; j++ {
					if i*j > n {
						break
					}
					a[i*j] = true
				}
			}
		}

		for i := x; i <= n; i++ {
			if !a[i] {
				fmt.Fprintln(stdout, i)
				break loop
			}
		}
	}
}


Measured memory_bytes: 768
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        s: Chars,
    }

    let mut count = 0;
    // let mut prev_colour = s[0];
    for i in 0..s.len() - 1 {
        if s[i] != s[i + 1] {
            count += 1;
            // prev_colour = s[i + 1];
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 2564
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vll a(n);
    REP(i,n) cin >> a[i];
    if(n%2==0){
        vll cnt(n);
        REP(i,n){
            if(a[i]%2==0){
                cout << 0 << endl;
                return 0;
            }
            cnt[a[i]]++;
            if(cnt[a[i]]>2){
                cout << 0 << endl;
                return 0;
            }
        }
    }else{
        vll cnt(n);
        REP(i,n){
            if(a[i]%2==1){
                cout << 0 << endl;
                return 0;
            }
            cnt[a[i]]++;
            if((a[i]==0&&cnt[0]>1)||cnt[a[i]]>2){
                cout << 0 << endl;
                return 0;
            }
        }
    }
    ll ans = 1;
    ll t = n/2;
    REP(i,t){
        ans*=2;
        ans%=mod;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4740
#include <stdio.h>
int main(){
  int sum=1,n,h[20],f=1;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&h[i]);
  }
  for(int i=n-1;0<i;i--){
    for(int s=i-1;0<=s;s--){
    if(h[i]<h[s]){
      f=-1;
    }
    }
    if(0<f){
    sum++;
    }
    f=1;
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-

import collections
import math


class Vector2(collections.namedtuple("Vector2", ["x",  "y"])):

    def __add__(self, other):
        return Vector2(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return Vector2(self.x - other.x, self.y - other.y)

    def __mul__(self, scalar):
        return Vector2(self.x * scalar, self.y * scalar)

    def __neg__(self):
        return Vector2(-self.x, -self.y)

    def __pos__(self):
        return Vector2(+self.x, +self.y)

    def __abs__(self):  # norm
        return math.sqrt(float(self.x * self.x + self.y * self.y))

    def __truediv__(self, scalar):
        return Vector2(self.x / scalar, self.y / scalar)

    def abs2(self):
        return float(self.x * self.x + self.y * self.y)

    def dot(self, other):  # dot product
        return self.x * other.x + self.y * other.y

    def cross(self, other):  # cross product
        return self.x * other.y - self.y * other.x


def getDistanceSP(segment, point):
    p = point
    p1, p2 = segment
    if (p2 - p1).dot(p - p1) < 0:
        return abs(p - p1)
    if (p1 - p2).dot(p - p2) < 0:
        return abs(p - p2)
    return abs((p2 - p1).cross(p - p1)) / abs(p2 - p1)


def getDistance(s1, s2):
    a, b = s1
    c, d = s2
    if intersect(s1, s2):  # intersect
        return 0
    return min(getDistanceSP(s1, c), getDistanceSP(s1, d), getDistanceSP(s2, a), getDistanceSP(s2, b))


def ccw(p0, p1, p2):
    a = p1 - p0
    b = p2 - p0
    if a.cross(b) > 0:
        return 1  # COUNTER_CLOCKWISE
    elif a.cross(b) < 0:
        return -1  # CLOCKWISE
    elif a.dot(b) < 0:
        return 2  # ONLINE_BACK
    elif abs(a) < abs(b):
        return -2  # ONLINE_FRONT
    else:
        return 0  # ON_SEGMENT


def intersect(s1, s2):
    a, b = s1
    c, d = s2
    return ccw(a, b, c) * ccw(a, b, d) <= 0 and ccw(c, d, a) * ccw(c, d, b) <= 0


def project(l, p):
    p1, p2 = l
    base = p2 - p1
    hypo = p - p1
    return p1 + base * (hypo.dot(base) / abs(base)**2)


class Circle():
    def __init__(self, c, r):
        self.c = c
        self.r = r


def getCrossPoints(c, l):
    pr = project(l, c.c)
    p1, p2 = l
    e = (p2 - p1) / abs(p2 - p1)
    base = math.sqrt(c.r * c.r - (pr - c.c).abs2())
    return [pr + e * base, pr - e * base]


def polar(r, a):
    return Vector2(r * math.cos(a), r * math.sin(a))


def getCrossPointsCircle(c1, c2):
    base = c2.c - c1.c
    d = abs(base)
    a = math.acos((c1.r**2 + d**2 - c2.r**2) / (2 * c1.r * d))
    t = math.atan2(base.y, base.x)
    return [c1.c + polar(c1.r, t + a), c1.c + polar(c1.r, t - a)]


if __name__ == '__main__':

    a, b, r = map(int, input().split())
    c1 = Circle(Vector2(a, b), r)
    a, b, r = map(int, input().split())
    c2 = Circle(Vector2(a, b), r)

    ans = getCrossPointsCircle(c1, c2)
    ans = sorted(ans, key=lambda x: (x.x, x.y))

    print("{:.8f} {:.8f} {:.8f} {:.8f}".format(
        ans[0].x, ans[0].y, ans[1].x, ans[1].y))



Measured memory_bytes: 6204
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);



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

	int N, d, x;
	cin >> N >> d >> x;
	vector<double>pb(N);
	double ans = 0;
	REP(i, 1, N) pb[i] = pb[i - 1] + 0.5 / (i + 1);
	rep(i, N) {
		ans += 0.5 * (d + i * 2 * x);
		ans += 0.5 * (d + i * 2 * x + x);
		ans += 0.5 * (pb[i] + pb[N - 1 - i]) * (d + d + i * 4 * x + x);
	}
	cout << setprecision(20) << ans << endl;


	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
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++)

int main() {
    string s;
    cin >> s;
    cin >> s;
    char c = s[0];
    cin >> s;

    cout << 'A' << c << 'C';

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;


int main(){
  string s; cin>>s;
  int c0=0;
  int c1=0;
  rep(i,s.size()){
    if(s[i]=='0')
    c0++;
    else
    c1++;
  }
  int ans=2*min(c1,c0);
  cout<<ans<<endl;

  return 0;
}


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

typedef pair<long, long> P;

int binary_search(vector<P> &tmp, long long x, long long y_up, long long y_down){
    int ok = (int)tmp.size();
    int ng = -1;
    while (abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;
        if (tmp[mid].first >= x) ok = mid;
        else ng = mid;
    }
    int ok2 = (int)tmp.size();
    int ng2 = -1;
    while (abs(ok2 - ng2) > 1){
        int mid = (ok2 + ng2) / 2;
        if (tmp[mid].first >= x + 1) ok2 = mid;
        else ng2 = mid;
    }
    int ok3 = ok2;
    int ng3 = ng;
    while (abs(ok3 - ng3) > 1){
        int mid = (ok3 + ng3) / 2;
        if (tmp[mid].second >= y_up) ok3 = mid;
        else ng3 = mid;
    }
    int ok4 = ok2;
    int ng4 = ng;
    while (abs(ok4 - ng4) > 1){
        int mid = (ok4 + ng4) / 2;
        if (tmp[mid].second >= y_down + 1) ok4 = mid;
        else ng4 = mid;
    }
    return ng4 - ng3;
}

int main(){
    long long h, w, n;
    cin >> h >> w >> n;

    vector<P> tmp(n);
    for (int i = 0; i < n; i++) cin >> tmp[i].first >> tmp[i].second;
    sort(tmp.begin(), tmp.end());

    vector<long long> ans(10, 0);
    for (int elm = 0; elm < n; elm++){
        long long x = tmp[elm].first;
        long long y = tmp[elm].second;
        for (int i = - 2; i < 1; i++){
            for (int j = -2; j < 1; j++){
                if (x + i <= 0 || h < x + i || y + j <= 0 || w < y + j) continue;
                if (x + i + 2 <= 0 || h < x + i + 2 || y + j + 2 <= 0 || w < y + j + 2) continue;
                int ss = 0;
                ss += binary_search(tmp, x + i, y + j, y + j + 2);
                ss += binary_search(tmp, x + i + 1, y + j, y + j + 2);
                ss += binary_search(tmp, x + i + 2, y + j, y + j + 2);
                ans[ss]++;
            }
        }
    }

    long long tt = 0;
    for (int i = 1; i < 10; i++){
        ans[i] /= i;
        tt += ans[i];
    }

    ans[0] = (h - 2) * (w - 2) - tt;
    for (int i = 0; i < 10; i++) cout << ans[i] << endl;
}

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

int main(){
 rep(i,365){
	cout<<i%26 + 1<<endl;
 }
 return 0;
}

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

int main(){
    int a[3][3];
    int n;
    rep(i,3){rep(j,3)cin >> a[i][j];}
    cin >> n;
    int b[n];
    rep(i,n)cin >>b[i];
    rep(i,3){
        rep(j,3){
            rep(k,n){
            if(a[i][j]==b[k])a[i][j]=0;
            }
        }
    }
    if(a[0][0]+a[0][1]+a[0][2]==0|a[1][0]+a[1][1]+a[1][2]==0|a[2][0]+a[2][1]+a[2][2]==0|a[0][0]+a[1][0]+a[2][0]==0|a[0][1]+a[1][1]+a[2][1]==0|a[0][2]+a[1][2]+a[2][2]==0|a[0][0]+a[1][1]+a[2][2]==0|a[0][2]+a[1][1]+a[2][0]==0
       ){
        cout<<"Yes"<<endl;
    }else{
        cout <<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for x in range(n)]
cd = [list(map(int, input().split())) for x in range(m)]
for i in ab:
    atemp = 1000000000
    ans = 0
    for f in range(len(cd)):
        temp = abs(i[0] - cd[f][0]) + abs(i[1] - cd[f][1])
        if atemp > temp:
            atemp = temp
            ans = f + 1
    print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;
//#define int long long
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>vec[i];
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int kurai(int x00, int y00) {
	int z00 = (x00 % jousu(10, y00)) / jousu(10, y00 - 1);
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}



int main() {
	int a, b;
	cin >> a >> b;
	if (max((a - b),(a+b)) % 2 == 1) {
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}
	cout << (a + b) / 2 << endl;
}



Measured memory_bytes: 256
/*
2015??´11???29??\(??\)
?????????:Hikichi Mari
??????URL:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0103&lang=jp
*/

#include<stdio.h>
#include <string.h>

int main(){

  int inning_num;
  char inning_data[7]; //????????§"HOMERUN"?????????????????\????????????????????§???????????????
  int i,j;
  int runner[3] = {0,0,0}; //3??????,runner???????????¨??????1,???????????????0??¨??????
  int sum = 0;
  int out_count = 0;

  scanf( "%d",&inning_num );

  for( i=0;i<inning_num;i++ ){

  for( j=0;j<3;j++ ){
    runner[j] = 0;
  }
  out_count = 0;

    while( out_count<3 ){

      scanf( "%s",inning_data );

      //HIT?????¨???
      if( strcmp(inning_data,"HIT") == 0){

        //3??? ??? ??????
        if( runner[2] == 1 ){
          sum++;
          runner[2] = 0;
        }

        //2??? ??? 3???
        if( runner[1] == 1 ){
          runner[1] = 0;
          runner[2] = 1;
        }

        //1??? ??? 2???
        if( runner[0] == 1 ){
          runner[0] == 0;
          runner[1] = 1;
        }

        //???????????? ??? 1???
        runner[0] = 1;

      }

      //HOMERUN?????¨???
      else if( strcmp(inning_data,"HOMERUN") == 0 ){
        sum++;
        for( j=0;j<3;j++ ){
          if( runner[j] == 1 ){
            sum++;
            //???????????????????????????0?????????
            runner[j] = 0;
          }
        }
      }

      //OUT?????¨???
      else{
        out_count++;
      }

    }

    printf("%d\n",sum);
    //sum????????????
    sum = 0;

  }

  return 0;

}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define endl "\n"
#define ciosup cin.tie(0);ios::sync_with_stdio(false);
#define eb emplace_back
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

struct edge{
    int to, cost;
};
vector<edge> G[100'000];
int n;
int memo[100'000];

void dfs(int i,int c, int be){
    if (memo[i] != -1) return;
    memo[i] = c;
    for (auto ne : G[i])
    {
        if (ne.to != be){
            if (ne.cost % 2 == 0){
                dfs(ne.to, c, i);
            }
            else
            {
                dfs(ne.to, !c, i);
            }
        }
    }
}

int main()
{
    cin >> n;
    REP(i,n){
        int u, v, w;
        cin >> u >> v >> w;
        edge e;
        e.cost = w;
        e.to = v-1;
        G[u - 1].eb(e);
        e.to = u-1;
        G[v - 1].eb(e);
        memo[i] = -1;
    }
    dfs(0, 1, -1);
    REP(i,n){
        cout << memo[i] << endl;
    }
}

Measured memory_bytes: 8320
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
using LL = long long;
using ULL = unsigned long long;
#define NUM 1000000007

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    if (s < t)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 384
#include<iostream>
#include<string>

using namespace std;

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

    int n, a, b,aa,bb;
    string s;
    cin >> n >> a >> b>>s;
    aa = a; bb = b;
    for(int i = 0; i < n; ++i) {
        if(aa + bb <= 0) {
            cout << "No" << endl;
            continue;
        }
        if(s.at(i) == 'a') {
            --aa;
            cout << "Yes" << endl;
        }
        else if(s.at(i) == 'b') {
            if(bb > 0) {
                --bb;
                cout << "Yes" << endl;
            }
            else cout << "No" << endl;
        }
        else
            cout << "No" << endl;
    
    }
}

Measured memory_bytes: 848
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = II()
    print(n**3)
    return

#B
def B():
    n = II()
    a = LI()
    b = LI()
    c = LI()
    ans = 0
    for i in range(n):
        ans += b[a[i] - 1] + (c[a[i] - 1] if i != n - 1 and a[i] + 1 == a[i + 1] else 0)
    print(ans)
    return

#C
def C():
    n = II()
    b = LI()
    ans = b[0]
    for i in range(n-1):
        if b[i] >= b[i + 1]:
            ans += b[i + 1]
        else:
            ans += b[i]
    print(ans)
    return

#D
def D():
    n, k = LI()
    s = S()
    a = []
    for i in range(n):
        if i == n - 1:
            a.append(s[i])
        elif s[i] != s[i + 1]:
            a.append(s[i])
    print(min(n - 1, n - len(a) + 2 * k))
    return

#E
def E():
    return

#F
def F():
    return


#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 38640
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

R = INT()
print(R * 2 * pi)


Measured memory_bytes: 10040
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=1001;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	int ans[102]={};
	ans[A]++;
	ans[C]++;
	ans[B+1]--;
	ans[D+1]--;
	int sec=0;
	for(int i=1;i<101;i++)
		ans[i]+=ans[i-1];
	for(int i=0;i<101;i++){
		if(ans[i]==2)
			sec++;
	}
	if(!sec)
		cout << sec << endl;
	else
		cout<<sec-1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    while(cin>>a>>b)
    {
        string s;
        cin>>s;
        int x=0,y=0;
        for(int i=0;i<s.size();i++)
        {
            if(s[i]=='-')
                y=i;
            else if(s[i]>='0' && s[i]<='9')
                x++;
        }
        if(y==a && x==a+b)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

int main(){
    string s; cin>>s;
    string s1,s2;
    rep(i,(int)s.size()){
        if(i%2==0){
            s1+='0';
            s2+='1';
        }else{
            s1+='1';
            s2+='0';
        }
    }
    ll s1cnt=0;
    ll s2cnt=0;
    rep(i,(int)s.size()){
        if(s1[i]==s[i]) s1cnt++;
        if(s2[i]==s[i]) s2cnt++;
    }
    cout<<min(s1cnt,s2cnt)<<endl;

}

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

using namespace std;

typedef long long ll;

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

	int n, r;
	cin >> n >> r;

	if(n >= 10){
		cout << r << endl;
	}else{
		cout << r + 100 * (10 - n) << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

#include <inttypes.h>
using namespace std;

class union_find_tree
{
private:
	int32_t N;
	vector<int32_t> parents, rank, node_cnt;

public:
	// n要素で初期化
	void init(int32_t n)
	{
		parents.resize(n);
		for (int32_t i = 0; i < n; i++)
			parents[i] = i;
		rank.resize(n, 0);
		node_cnt.resize(n, 1);
		N = n;
	}

	// 木の根を求める
	int32_t find(int32_t x)
	{
		if (parents[x] == x) {
			return x;
		} else {
			parents[x] = find(parents[x]);
			return parents[x];
		}
	}

	// xとyの属する集合を併合
	void unite(int32_t x, int32_t y)
	{
		x = find(x);
		y = find(y);
		if (x == y)
			return;

		if (rank[x] < rank[y]) {
			parents[x] = y;
			node_cnt[y] += node_cnt[x];
		} else {
			parents[y] = x;
			node_cnt[x] += node_cnt[y];
			if (rank[x] == rank[y])
				rank[x]++;
		}
	}

	// xとyが同じ集合に属するか否か
	bool same(int32_t x, int32_t y)
	{
		return find(x) == find(y);
	}

	// 親を取得
	int32_t get_parent(int32_t x)
	{
		return parents[x];
	}

	// ルートかどうか
	bool is_root(int32_t x)
	{
		return parents[x] == x;
	}

	// グループの総数
	int32_t number_of_groups()
	{
		int32_t cnt = 0;
		for (int32_t i = 0; i < N; i++)
			if (is_root(i))
				cnt++;
		return cnt;
	}

	// グループ内のノードの数
	int32_t group_size(int32_t x)
	{
		return node_cnt[find(x)];
	}
};

int main()
{
	int32_t N, K, L;
	scanf("%d%d%d", &N, &K, &L);

	union_find_tree uft_road;
	uft_road.init(N);
	for (int32_t i = 0; i < K; i++) {
		int32_t p, q;
		scanf("%d%d", &p, &q);
		p--;
		q--;
		uft_road.unite(p, q);
	}

	union_find_tree uft_train;
	uft_train.init(N);
	for (int32_t i = 0; i < L; i++) {
		int32_t p, q;
		scanf("%d%d", &p, &q);
		p--;
		q--;
		uft_train.unite(p, q);
	}

	int64_t ar_br[200000];
	map<int64_t, int32_t> ar_br_cnt;
	for (int32_t i = 0; i < N; i++) {
		ar_br[i] = (((int64_t)uft_road.find(i)) << 32) | uft_train.find(i);
		ar_br_cnt[ar_br[i]]++;
	}
	for (int32_t i = 0; i < N; i++)
		printf("%d ", ar_br_cnt[ar_br[i]]);
	printf("\n");

	return 0;
}

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

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

int main(void) {
  int N; cin >> N;
  int R = 0, B = 0;
  REP(int, i, N) {
    char c; cin >> c;
    if (c == 'R') R++;
    if (c == 'B') B++;
  }
  if (R > B) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

int main(void){
    int x,n;
    cin >> x >> n;
    vector<int> v(102,1);
    for(int i = 0;i < n;i++){
          int a;
          cin >> a;
          v[a] = 0;
    }
    int ans = 0;
    int t = 102;
    for(int i = 0;i < 102;i++){
          if(v[i]){
              if(t > abs(x - i)){
                    t = abs(x - i);
                    ans = i;
              }  
          }
    }
    cout << ans << endl;
}


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

int main()
{
    int n;
    cin>>n;
    int h[n+1];
    for(int i=1;i<=n;i++)
        cin>>h[i];
    long long cost[n+1];
    cost[n] = 0;
    cost[n-1] = abs(h[n-1]-h[n]);

    for(int i=n-2;i>=1;i--)
    {
        cost[i] = min(abs(h[i]-h[i+1])+cost[i+1],abs(h[i]-h[i+2])+cost[i+2]);
    }
    cout<<cost[1];
    return 0;
}


Measured memory_bytes: 1408
import Foundation

var s : String = readLine()!

var i = 0
var j = 1
var count = 0
var resultA = 0
var resultB = 0

for num in s.characters{
    //正しい場合
    if (num == "0" && count%2 == 0){
        
    }else if(num == "1" && count%2 == 1){
        
    }else{//正しく無い場合
        resultA = resultA + 1
    }
    count = count + 1
}

count = 0
for num in s.characters{
    //正しい場合
    if (num == "1" && count%2 == 0){
        
    }else if(num == "0" && count%2 == 1){
        
    }else{//正しく無い場合
        resultB = resultB + 1
    }
    count = count + 1
}


if(resultA < resultB){
    print(resultA)
}else{
    print(resultB)
}


Measured memory_bytes: 7268
using System;

namespace ABC126A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string[] ss = Console.ReadLine().Split(' ');
            a = int.Parse(ss[0]);
            b = int.Parse(ss[1]);
            
            string s = Console.ReadLine();
            if (s.Substring(b - 1, 1) == "A")
                Console.WriteLine(s.Substring(0, b - 1) + "a" + s.Substring(b, a - b));
            else if (s.Substring(b - 1, 1) == "B")
                Console.WriteLine(s.Substring(0, b - 1) + "b" + s.Substring(b, a - b));
            else
                Console.WriteLine(s.Substring(0, b - 1) + "c" + s.Substring(b, a - b));
            Console.ReadKey();
            
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+5;
//int a[N];
int freq[N];

int main()

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

    int n, k, q, x;

    cin >> n >> k >> q;

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

        cin >> x;
        freq[x]++;
    }

    for (int i = 1; i <= n; i++) {

        if (freq[i]+k <= q) cout << "No\n";
        else cout << "Yes\n";
    }

    return 0;
}


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

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



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

    /////////////////////
    // Write code below /
    /////////////////////
    int A,B,T;

    cin>>A>>B>>T;

    cout<<T/A*B<<endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
M = [[] for _ in range(N)]
for i in range(N):
    A = int(input())
    for j in range(A):
        x, y = map(int, input().split())
        M[i].append([x, str(y)])

ans = 0
for i in range(2 ** N):
    S = format(i, 'b').zfill(N)
    flag = True
    for j in range(N):
        if S[j] == '1':
            for x, y in M[j]:
                if S[x - 1] != y:
                    flag = False
    if flag:
        ans = max(ans, S.count('1'))
print(ans)

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

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            List<Int64> px=new List<long>();
            var each = spr(RL()).Select(x => c2i(x)).ToList();
            var num = each.Last();
            var X = each.First();
            var ret=true;
            if (num > 0)
            {
                px = spr(RL()).Select(x => c2i(x)).ToList();
                px.Sort();
            }
            if (px.Count(x=>x==X) == 0)
            {
                Console.WriteLine(X);
                Console.ReadLine();
                return;
            }
            var index= px.FindIndex(x => x == X);
            long move = 1;
            long retindex=0;
            while (move<=100)
            {
                if (!px.Any(x=>x==(X - move)))
                {
                    retindex = X - move;
                    break;
                }
                if (!px.Any(x => x == (X + move)))
                {
                    retindex = X + move;
                    break;
                }
                move++;

            }
            Console.WriteLine(retindex);
            Console.ReadLine();

        }

        static string RL() { return Console.ReadLine().Trim(); }
        static IEnumerable<string> spr(string s) { return s.Split(' '); }
        static Int64 c2i(string c) { return Int64.Parse(c); }
        //static double c2d(string c) { return double.Parse(c); }
        static string bool2ret(bool b) { return b ? "Yes" : "No"; }
    }
}

Measured memory_bytes: 28344
from collections import Counter 
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

cs = Counter(s)
ct = Counter(t)
ans = 0
for k, v in cs.items():
    if k in ct.keys():
        ans = max(ans, v-ct[k])
    else:
        ans = max(ans, v)

print(ans)

Measured memory_bytes: 38640
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double EPS = 1e-10;


int main(void) {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  ll num = 0;
  map<int, int> m;
  rep(i, N) {
    m[A[i]]++;
  }
  for (auto itr = m.begin(); itr != m.end(); ++itr) {
    num += (ll) itr->second * (itr->second - 1) / 2;
  }

  ll before, after;
  rep(i, N) {
    ll val = m[A[i]];
    before = val * (val - 1) / 2;
    after = (val - 1) * (val - 2) / 2;
    cout << num + after - before << endl;
  }
  
  return 0;
}

Measured memory_bytes: 9988
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

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

    LL ans = 0;
    for (LL sz = 1; sz <= n; sz++) {
        ans += sz*(n-sz+1);
    }

    for (int i = 1; i < n; i++) {
        LL u, v;
        cin >> u >> v;
        if (u > v) swap(u, v);
        ans -= u*(n-v+1);
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3636
# coding: utf-8
# Your code here!

class Player:
    
    id = 0
    score = 0
    def __init__(self, id, score):
        self.id = id
        self.score = score
        
    def __lt__(self, other):
        if self.score == other.score:
            return self.id < other.id
        else:
            return self.score > other.score


while True:
    N = int(input())
    if N == 0:
        break
    
    players = []
    
    for l in range(N):
        line = [int(i) for i in input().split()]
        line.append(0)
        line.append(0)
        score = 0
        round = 0
        i = 1
        while round < 10:
            if round < 9:
                if line[i] < 10:
                    if line[i] + line[i+1] < 10:
                        score += line[i] + line[i+1]
                    else:
                        score += line[i] + line[i+1] + line[i+2]
                    i += 2
                    round += 1
                else:
                    score += line[i] + line[i+1] + line[i+2]
                    i += 1
                    round += 1
            else:
                score += line[i] + line[i+1] + line[i+2]
                round += 1
        
        players.append(Player(line[0], score))
    
    players.sort()
    
    for i in range(N):
        print(players[i].id, players[i].score)
        
        


Measured memory_bytes: 5632
n = gets.to_i
k = gets.to_i
balls_x = gets.split(' ').map{|x| x.to_i} 
results = 0

balls_x.each{|x|
  if x <= (k-x)
    results += 2*x
  else
    results += 2*(k-x)
  end
}

puts "#{results}"

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

int main(){
	int n;
	string s;
	int max = 0;
	int tmp = 0;
	cin >> n >> s;
	for(auto c: s){
		if(c == 'I') tmp++;
		else tmp--;
		if(tmp > max) max = tmp;
	}
	cout << max;
	return 0;
}



Measured memory_bytes: 256
a,b,c,d = map(int, input().split())

cnt = 0
while a > 0 and c > 0:
    if cnt % 2 == 0:
        c -= b
    else:
        a -= d
    cnt += 1
if cnt %2 == 1:
    print("Yes")
else:
    print("No")

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

signed main(void)
{
	string s;
	int k, cnt;
	set<string> st;

	cin >> s >> k;
	for(int j = 1; j <= k; j++)
	{
		rep(i, s.size())
		{
			string t = s.substr(i, j);
			st.insert(t);
		}
	}
	cnt = 0;
	for(auto v : st)
	{
		cnt++;
		if (cnt == k)
		{
			cout << v << endl; 
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M; cin >> N >> M;
  int AC=0;
  int WA=0;
  
  //バケット
  vector<int> bucAC(N);
  vector<int> bucWA(N);
  vector<bool> jud(N);
  for (int i=0; i<N; i++)  bucAC[i]=0;
  for (int i=0; i<N; i++)  bucWA[i]=0;
  for (int i=0; i<N; i++)  jud[i]=false;
  
  for (int i=0; i<M; i++){ //M回下記の処理
    int p;
    string S;    
    cin >> p >> S;
    if (jud[p-1]==true) continue;
    if (S=="AC"){
      bucAC[p-1]++;
      jud[p-1]=true; //問題pのACフラグ
      WA += bucWA[p-1];
    }
    else if (S=="WA"){
      bucWA[p-1]++;
    }
  }
  
  for (int i=0; i<N; i++){
    if (bucAC[i]>0) AC++;
  }
  
  cout << AC << " "  << WA << endl;
  
}

Measured memory_bytes: 1024
#include<iostream>
#include<utility>
#include<vector>
//二項係数nCrをdivisorで割った余りを求めるクラス
class combination_mod
{
private:
	std::vector<long long>factorial_mod;
	long long divisor;
public:
	combination_mod(long long div, long long sup_n) :divisor(div), factorial_mod(std::vector<long long>(sup_n + 1))
	{
		//階乗をdivisorで割ったあまりを計算する
		if (factorial_mod[0] != 1)
		{
			factorial_mod[0] = 1;
			for (long long i = 1; i < sup_n; i++)
			{
				factorial_mod[i] = factorial_mod[i - 1] * i % divisor;
			}
		}
	}
	long long operator()(long long n, long long r)
	{
		//分母、分子
		long long numerator = factorial_mod[n];
		long long denominator = factorial_mod[r] * factorial_mod[n - r] % divisor;//積はdivisorを超えているかもしれないからもう一回剰余算する

		/*
		 * nCr ≡ (n! % p) * ((n-r)! r! % p)^(p-2) (mod p) (但しpは素数)
		 *
		 * 証明:
		 * nCrを変形して
		 * nCr * (n-r)! * r! = n!
		 * 任意の整数は自分自身と合同だから
		 * nCr * (n-r)! * r! ≡ n! (mod p)
		 * 両辺に(n-r)!とr!のモジュラ逆数をかけて
		 * nCr ≡ n! * ((n-r)!)^(-1) * (r!)^(-1) (mod p)
		 * ---------------------------------------------------------------
		 * 補題1:
		 * pが素数のとき
		 * a^(p-1) ≡ 1 (mod p) (ただしaとpは互いに素)
		 * が成立する(フェルマーの小定理)。
		 * 上式を変形して
		 * a * a^(p-2) ≡ 1 (mod p)
		 * 即ちa^(p-2)がaのモジュラ逆数である。
		 * ---------------------------------------------------------------
		 * pは十分大きい素数だから(n-r)!とr!はそれぞれpと互いに素
		 * よって補題1より
		 * ((n-r)!)^(-1) = ((n-r)!)^(p-2)
		 * (r!)^(-1) = (r!)^(p-2)
		 * よって
		 * nCr ≡ n! * ((n-r)!)^(p-2) * (r!)^(p-2) (mod p)
		 *     =  n! * ((n-r)! * (r!))^(p-2)
		 * ---------------------------------------------------------------
		 * 補題2:
		 * a ≡ b1 * b2 * b3...(mod c)
		 * のとき
		 * a ≡ (b1 % c) * (b2 % c) * (b3 % c)...(mod c)
		 * ---------------------------------------------------------------
		 * 補題2より
		 * nCr ≡ (n! % p) * ((n-r)! r! % p)^(p-2) (mod p)
		 * Q.E.D.
		 */

		 //power = denominator^(divisor - 2)を計算する
		long long index = divisor - 2, power = 1;
		while (index > 0)
		{
			if (index & 1 == 1)
			{
				power *= denominator;
				power %= divisor;
			}
			denominator *= denominator;
			denominator %= divisor;
			index >>= 1;
		}
		return numerator * power % divisor;
	}
};
int main()
{
	const long long divisor = 998244353;
	const long long sup_n = 333333;
	combination_mod cm(divisor, sup_n);
	long long n, a, b, k;
	std::cin >> n >> a >> b >> k;
	std::vector<std::pair<long, long>>pairs;
	pairs.reserve(n);
	for (long long x = 0; x <= n; x++)
	{
		if ((k - a * x) % b == 0)
		{
			long long y = (k - a * x) / b;
			if (0 <= y && y <= n)
			{
				pairs.push_back(std::make_pair(x, y));
			}
		}
	}
	long long ans = 0;
	for (auto i : pairs)
	{
		ans += cm(n, i.first) * cm(n, i.second) % divisor;
		ans %= divisor;
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
int kvalue[3000];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a[4];
    for(auto & x : a)
        cin >> x;
    sort(a,a+4);
    string s = "";
    for(auto x : a)
        s += (x+'0');
    if(s == "1479")
    {
        cout << "YES\n";
    }
    else
        cout << "NO\n";



return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
#include <set>


int main(void) {
	int n, m; std::cin >> n >> m;
	if (n == m) {
		std::cout << "Yes\n";
	}
	else {
		std::cout << "No\n";
	}
}



Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define N_PRIME 1000000007
#define ll int64_t


int main(void){
    ll N;
    ll t,a;
    ll left,right;
    
    left = 1;
    right = 1;
    
    cin >> N;
    
    for(int i = 0 ; i < N ; i++ ){
        cin >> t >> a;
        
        ll l = left / t  + (left%t == 0 ? 0 : 1 ) ;
        ll r = right / a + (right%a == 0 ? 0 : 1 );
        /*
        cout << l << endl;
        cout << r << endl;
        cout << "LLL"<< endl;
        */
        ll m = max(l,r);
        
        left = m * t;
        right = m * a;
        /*
        cout << left << endl;
        cout << right << endl;
        cout << "L555LL"<< endl;
        */
    }
    
    cout << left + right << endl;
    
    return 0;
}

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

int main() {
  int a,b,k;
  cin >> k >> a >> b;
  for(int i=a;i<=b;i++){
    if(i%k==0){ cout << "OK" << endl; return 0;}
  }
  cout << "NG" << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define vite ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tst int T; cin>>T; while(T--)
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define ll long long int
#define vt vector
#define pb push_back
int main()
{
    vite;
    string s;
    cin>>s;
    if(s[0]==s[1]&&s[0]=='?')
    {
        s[0] = 'P';
        s[1] = 'D';
    }
    for (ll i = 0; i < s.length();i++)
    {
        if(s[i]=='?')
            s[i] = 'D';
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static const ll INF = 1<<21;
static const ll MOD = 1e9 + 7;

bool pairCompare(const pair<int, int>& firstElof, const pair<int, int>& secondElof) {
    return firstElof.first > secondElof.first;
}

int main(void) {
    int N, K;
    string S;
    cin >> N >> K;
    cin >> S;

    S.at(K-1) += 32;

    cout << S << endl;

    return (0);
}


Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String[] argv){
		divisor();
	}
	static Scanner scan = new Scanner(System.in);
	public static void yard(){
		int a = scan.nextInt(), b = scan.nextInt();
		int area = (a-1)*(b-1);
		System.out.println(area);
	}
	//input: 1<=n<=200
	//n以下の奇数の内，約数をちょうど８個持つものの数を出力
	//①2*4, 2*2*2の３通り．
	public static void divisor(){
		int n = scan.nextInt();
		int count = 0;
		int[] prime = {3,5,7,11,13,17,19,23,29,31};//200以下の際に候補になりえる素数．
		
		//②指数が1と3のパターン
		if(n>=135){//a*3^3のパターン
			count++;
			if(n>=189)
				count++;
		}
		
		//③のパターン．全探索する．
		for(int i=0;i<prime.length;i++){
			for(int j=i+1;j<prime.length;j++){
				for(int k=j+1;k<prime.length;k++){
					if(prime[i]*prime[j]*prime[k]<=n)
						count++;
				}
			}
		}
		System.out.println(count);
	}
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string str; int q; cin>>str>>q;
	for(int i=0;i<q;++i){
		string com; int a,b; cin>>com>>a>>b;
		if(com=="replace"s){
			string nw; cin>>nw;
			for(int j=a,k=0;j<=b;++j,++k){
				str.at(j)=nw.at(k);
			}
		}else if(com=="reverse"s){
			for(int j=a,k=b;j<k;++j,--k){
				char tmp=str.at(j);
				str.at(j)=str.at(k);
				str.at(k)=tmp;
			}
		}else for(int j=a;j<=b;++j){
			cout<<str.at(j);
			if((j==b))cout<<"\n"s;
		}
	}
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, const vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int n, ma, mb;
vi a, b, c;
int dp[44][444][444];

int solve(int p, int wa, int wb)
{
	if (dp[p][wa][wb] >= 0) return dp[p][wa][wb];
	if (p == n)
	{
		if (wa > 0 && wb > 0 && wa * mb == wb * ma) return 0;
		else return 1e9;
	}
	int res = min(solve(p + 1, wa, wb), solve(p + 1, wa + a[p], wb + b[p]) + c[p]);
	return dp[p][wa][wb] = res;
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	cin >> n >> ma >> mb;
	MS(dp, -1);
	REP(i, n)
	{
		int x, y, z;
		cin >> x >> y >> z;
		a.push_back(x);
		b.push_back(y);
		c.push_back(z);
	}
	int res = solve(0, 0, 0);
	if (res >= 1e9) res = -1;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 34176
n=int(input())
li=list(map(int,input().split()))
li.sort()
if li[0]==0:
  print(0)
else:
  ans=1
  for i in li:
    ans*=i
    if ans>1000000000000000000:
        print(-1)
        exit()
    else:
        continue
  print(ans)

Measured memory_bytes: 21580
n, p = list(map(int, input().split()))
if(n == 1):
  print(p)
elif(p == 1):
  print(1)
elif(n > 64):
  print(1)
else:
  ans = 1
  tmp = 2
  while(tmp**n <= p):
    if((p%(tmp**n)) == 0): ans = tmp
    tmp+=1
  print(ans)

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

int main( int argc, char *argv[] )
{
int i;
int N;
char S[ 110 ];
char C;
int iMax;
int iPos;

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

	cin >> N;
	cin >> S;

	iMax = 0;
	iPos = 0;
	for( i = 0; i < N; i++ )
	{
		C = S[ i ];
		if( C == 'I' )
		{
			iPos++;
			if( iMax < iPos ) iMax = iPos;
		}
		else
			iPos--;
	}

	cout << iMax << endl;

	return 0;
}




Measured memory_bytes: 256
import std.stdio;

void main() {
	long n, a, b;

	readf(" %s %s %s", &n, &a, &b);

	long balls = (n / (a + b)) * a;

	long mod = n % (a + b);
	if (mod > a) {
		balls += a;
	} else {
		balls += mod;
	}

	writeln(balls);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    vl v(n);rep(i,n)cin >> v[i];v.pb(0);
    ll ans=0;
    rep(i,n){
        ans+=v[i]/2;v[i]%=2;
        if(v[i]&&v[i+1])ans++,v[i+1]--;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 4828