akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, m;
  cin >> n >> m;
  vector <ll> v(n);
  rep(i, n) cin >> v.at(i);
  vector <ll> tmp = {1};
  set <ll> s;
  s.insert(1);
  ll f = 1;
  while (!s.count(v.at(f-1))) {
    tmp.push_back(v.at(f-1));
    s.insert(v.at(f-1));
    f = v.at(f-1);
  }
  ll rem;
  rep(i, tmp.size()) {
    if (tmp.at(i) == v.at(f-1)) rem = i;
  }
  ll loc;
  if ((m+1-rem)%(tmp.size()-rem)) {
    loc = (m+1-rem)%(tmp.size()-rem) - 1;
  } else {
    loc = tmp.size()-rem-1;
  }
  if (m+1 <= rem) {
    cout << tmp.at(m) << endl;
  } else {
    cout << tmp.at(rem+loc) << endl;
  }
}

Measured memory_bytes: 15340
// IDE used VSCode with gcc plug-in
/*
Event: Codeforces Global Round 7
Author: miitbh1
*/
#include <map>
#include <set>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cstdlib>
#include <climits>
#include <iomanip>
#include <iostream>
#include <algorithm>


#define rep(i, n) for(int i=0; i<n; i++)
#define repA(i, a, n) for(int i=a; i<n; i++)
#define repD(i, a, n) for(int i=a; i>=n; i--)
#define trav(it, ctr) for(auto it=ctr.begin(); it!=ctr.end(); it++)
#define p(x) cout<<x<<"\n"
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pp(x, y) cout<<x<<" "<<y<<"\n"
#define btc __builtin_popcount
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef priority_queue<int> pq;
typedef pair<int, int> ii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
using ll=long long int;
int N=100001, M=1e9+7;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    double v, a, b, c, s;
    cin>>s;
    a=s/3.0;
    b=(s-a)/2.0;
    v=a;
    v+=b;
    c=s;
    c-=v;
    a*=b;
    a*=c;
    cout<<fixed<<setprecision(10);
    p(a);
    return 0;
}

Measured memory_bytes: 256
def f1():
    frame = 1
    total = 0
    i = 0
    while frame < 10:
        if score[i] == 10:
            total += (score[i] + score[i+1] + score[i+2])
            i += 1
        elif score[i] + score[i+1] == 10:
            total += (score[i] + score[i+1] + score[i+2])
            i += 2
        else:
            total += (score[i] + score[i+1])
            i += 2
        frame += 1
    else:
        total += sum(score[i:])
        res.append([sn,total])

def f2():
    for k, v in sorted(sorted(res), key=lambda x:x[1], reverse=True):
        print k, v

while True:
    n = input()
    if n == 0: break
    res = []
    for i in range(n):
        L = map(int, raw_input().split())
        sn = L[0]
        score = L[1:]
        f1()
    else:
        f2()

Measured memory_bytes: 4280
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)
        {
            var N = c2i(RL());
            var Li = RL2IE().ToList();
            var cnt = 0;
            Li.Sort();
            var lst=new List<string>();

            for (int i = (int)N-1; i >= 2; i--)
            {
                for (int j = i - 1; j >= 1; j--)
                {
                    if (Li[i] != Li[j])
                    {
                        for (int k = j - 1; k >= 0; k--)
                        {
                            if (Li[k] != Li[j])
                            {
                                if (Li[i] < Li[j] + Li[k])
                                {

                                    cnt++;
                                }
                                else break;
                            }
                        }
                    }
                }


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

        }

        static IEnumerable<int> RL2IE() { return spr(RL()).Select(x => (int)c2i(x)); }
        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: 28284
#include <iostream>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <cstring>
using namespace std;
const int maxn=200005;
set<int>s;
int main()
{
    int a,b,k;
    cin>>a>>b>>k;
    int cnt1=1;
    int cnt2=1;
    for(int i=a;cnt1<=k;i++)
    {
        s.insert(i);
        cnt1++;
        if(i>=b)
            break;
    }

    for(int i=b;cnt2<=k;i--)
    {

        s.insert(i);
        cnt2++;
        if(i<=a)
            break;
    }

    set<int>::iterator iter=s.begin();

    while(iter!=s.end())
    {
        cout<<*iter<<endl;;
        iter++;
    }
}



Measured memory_bytes: 768
N = int(input())


def dfs(cur, use, cnt):
    if cur > N:
        return
    if use == 0b111:
        cnt.append(1)
    dfs(cur*10 + 7, use | 0b001, cnt)
    dfs(cur*10 + 5, use | 0b010, cnt)
    dfs(cur*10 + 3, use | 0b100, cnt)


res = []
dfs(0, 0, res)
print(sum(res))


Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main() {
  int n;
  cin>>n;
  int m=100000;
  for(int i=0;i<n;i++){
    m*=1.05;
    if((m%1000)!=0) {
       m/=1000;
       m*=1000;
       m+=1000;
    }
  }
  cout<<m<<endl;
  return 0;
}



Measured memory_bytes: 3036
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""

def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

inf = 10 ** 18
mod = 10 ** 9 + 7

_INPUT = """\
codeforces
atcoder
"""

def main(*, input=input):
    sr = lambda: input()
    ir = lambda: int(sr())
    lr = lambda: list(map(int, sr().split()))

    s = sr()
    t = sr()
    n = len(s)
    len_t = len(t)
    ans = len_t
    for i in range(n-len_t+1):
        tmp = 0
        for j,c in enumerate(t):
            if s[i+j] != c:
                tmp+=1
        ans = min(ans,tmp)
    print(ans)


if __name__ == "__main__":
    import io, sys

    # sys.stdin = io.StringIO(_INPUT)

    main()

Measured memory_bytes: 78556
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
int n;
double v;
priority_queue<double> q;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		cin>>v;
		q.push(-v);
	}
	while(q.size() != 1)
	{
		double a1 = q.top();
		a1 = -a1;
		q.pop();
		double a2 = q.top();
		a2 = -a2;
		q.pop();
		double aa = (a1 + a2) / 2;
		q.push(-aa);
	}
	double ans = -q.top();
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
from itertools import combinations as comb

l, r = map(int, input().split())

min = 2018
if r-l >= 2018:
    print(0)
else:
    range_list = [i for i in range(l, r + 1)]
    comb_list = list(comb([i for i in range(r - l + 1)], 2))
    for comb in comb_list:
        if range_list[comb[0]]*range_list[comb[1]]%2019 < min:
            min = range_list[comb[0]]*range_list[comb[1]]%2019
    print(min)

Measured memory_bytes: 129324
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int n, k;
  double expect[200005];
  
  cin >> n >> k;
  for(int i = 0; i < n; i++){
    int data;
    cin >> data;
    expect[i] = (data + 1) / 2.0;
  }

  //左からk個のサイコロの期待値を計算する
  double sum = 0;
  for(int i = 0; i < k; i++){
    sum += expect[i];
  }
  //左のサイコロを引き、右のサイコロを足しながらiを進める
  double maxim = sum;
  for(int i = 0; i < n - k; i++){
    sum = sum - expect[i] + expect[i + k];
    maxim = max(maxim, sum);
  }

  printf("%lf\n", maxim);
  return(0);
}

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

struct Node{
  int key;
  Node *right,*left,*parent;
};

Node *root, *NIL;

Node * treeMinimum(Node *x){
  while( x->left != NIL) x = x->left;
  return x;
}

Node * find(Node *u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

Node * treeSuccessor(Node *x){
  if(x->right != NIL)return treeMinimum(x->right);
  Node *y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node *z){
  Node *y;
  Node *x;

  if(z->left == NIL || z->right == NIL)y = z;
  else y = treeSuccessor(z);

  if(y->left != NIL){
    x = y->left;
  }else{
    x = y->right;
  }

  if(x != NIL){
    x->parent = y->parent;
  }

  if(y->parent == NIL){
    root = x;
  }else{
    if(y == y->parent->left){
      y->parent->left = x;
    }else{
      y->parent->right = x;
    }
  }

  if(y != z){
    z->key = y->key;
  }

  free(y);
}

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node*)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }

  z->parent = y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key < y->key){
      y->left = z;
    }else{
      y->right = z;
    }
  }
}

void inorder(Node *u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  string com;

  scanf("%d\n", &n);

  for(i = 0; i < n;i++){
    cin >> com;
    if(com[0] == 'f'){
      scanf("%d",&x);
      Node *t = find(root,x);
      if(t != NIL)printf("yes\n");
      else printf("no\n");
    }else if( com == "insert"){
      scanf("%d", &x);
      insert(x);
    }else if( com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }else if( com == "delete"){
      scanf("%d", &x);
      treeDelete(find(root,x));
    }
  }

  return 0;
}



Measured memory_bytes: 22048
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);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 VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};
 
int main(void){
	string S;
	int counter[3],min=INF,max=-INF;
	cin>>S;

	REP(i,3) counter[i]=0;
	REP(i,(int)S.length()){
		switch(S[i]){
			case 'a':
				counter[0]++;
				break;
			case 'b':
				counter[1]++;
				break;
			case 'c':
				counter[2]++;
				break;
		}
	}
  REP(i,3){
		chmin(min,counter[i]);
		chmax(max,counter[i]);
	}

	if(abs(min-max)<=1) puts("YES");
	else puts("NO");

	return 0;
}


Measured memory_bytes: 512
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

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


Measured memory_bytes: 72872
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<algorithm>
using namespace std;
int a[200500];
long long s[200500],x[200500];
int main()
{
	int n,i,j;
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	for (i=1;i<=n;i++) s[i]=s[i-1]+a[i];
	for (i=1;i<=n;i++) x[i]=x[i-1]^a[i];
	int l=1,r=1;
	long long ans=0;
	while (r<=n)
	{
		while (s[r]-s[l-1]!=(x[r]^x[l-1])) l++;
		ans+=r-l+1;
		r++;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 4096
fn main() {
    let (n, m): (usize, usize) = (read::<usize>(), read::<usize>());
    let mut a = vec![];
    let mut s = 0;
    for i in 0..n {
        let v: usize = read();
        a.push(v);
        s += v;
    }
    a.sort_by(|x, y| y.cmp(x));
    let lim: f64 = s as f64 / (4.0 * m as f64);
    for i in 0..m {
        if (a[i] as f64) < lim {
            println!("{}", "No");
            exit(0);
        }
    }
    println!("{}", "Yes");
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


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

int main(){
    int n,l;
    cin >> n >> l;
    
    vector<vector<char>> s(n,vector<char>(l));
    
    rep(i,n){
        rep(j,l) cin >> s[i][j];
    }
    
    sort(s.begin(),s.end());
    
    rep(i,n){
        rep(j,l){
            cout << s[i][j];
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
std::vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
#define size_t ll
int n,a,b,c,d,ck=0;
string s;
bool can=false;
int main(){
  cin >> n >> a >> b >> c >> d >> s;
  if(c < d){
    can = true;
  }else{
    for (size_t i = b-1; i < d; i++) {
      if(s[i-1] == '.' && s[i] == '.' && s[i+1] == '.'){
        can = true;
      }
    }
  }
  for (size_t i = a; i < (c>d ? c:d); i++) {
    if(s[i] == '#')ck++;
    else ck = 0;
    if(ck >= 2){
      can = false;
    }
  }
  cout << (can ? "Yes":"No") << endl;
}


Measured memory_bytes: 640
// #define _GLIBCXX_DEBUG

#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <string>
#include <vector>
#include <chrono>
#include <cmath>

#define int long long

using namespace std;


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

  if (s[1] == 'B') {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }

  return 0;
}


Measured memory_bytes: 3596
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C: Special Trains
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 500;

/* typedef */

/* global variables */

int ts[MAX_N];

/* subroutines */

/* main */

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

  int t = 0;
  for (int i = 0; i < n - 1; i++) {
    int ci, si, fi;
    scanf("%d%d%d", &ci, &si, &fi);

    for (int j = 0; j <= i; j++)
      ts[j] = (ts[j] <= si ? si : (ts[j] + fi - 1) / fi * fi) + ci;
  }

  for (int i = 0; i < n; i++)
    printf("%d\n", ts[i]);
  return 0;
}


Measured memory_bytes: 256
import sys

N = int(sys.stdin.readline().rstrip())
A = list(map(int, sys.stdin.readline().rstrip().split()))

if A.count(0) > 0:
    print(0)
else:
    x = 1
    for a in A:
        x *= a
        if x > 1000000000000000000:
            print(-1)
            sys.exit()
    print(x)


Measured memory_bytes: 21656
#include <stdio.h>

int main(void)
{
	int i=1,input=1;

	while (input!=0)
	{
		scanf("%d", &input);
		if (input != 0)
		{
			printf("Case %d: %d\n",i, input);
			i++;
		
		}
	}
	return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define mp  make_pair
#define SIZE 200005
vll tree[SIZE];
ll arr[SIZE];
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ll N,Q;
	cin>>N>>Q;
	for(ll i=1;i<N;++i){
		ll u,v;
		cin>>u>>v;
		tree[u].pb(v);
	}
	while(Q--){
		ll node,value;
		cin>>node>>value;
		arr[node]+=value;
	}
	for(ll i=1;i<=N;++i){
		vll :: iterator itr;
		for(itr=tree[i].begin();itr!=tree[i].end();++itr){
			arr[*itr]+=arr[i];
		}
	}
	for(int i=1;i<=N;++i){
		cout<<arr[i]<<endl;
	}
}

Measured memory_bytes: 14848
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=s;i<t;i++)
typedef long long ll;
const ll mod=998244353;
int cnt[8];
char s[333333];
int main()
{
    int n;scanf("%d",&n);
    scanf("%s",s+1);
    rep(i,1,3*n+1)
    {
        if(s[i]=='R')s[i]=1;
        else if(s[i]=='G')s[i]=0;
        else s[i]=2;
    }
    ll res=1;int nownum=n;
    rep(i,1,3*n+1)
    {
        if(cnt[7-(1<<s[i])])res=res*cnt[7-(1<<s[i])]%mod,cnt[7-(1<<s[i])]--;
        else if(cnt[1<<((s[i]+1)%3)])res=res*cnt[1<<((s[i]+1)%3)]%mod,cnt[1<<((s[i]+1)%3)]--,
                    cnt[(1<<((s[i]+1)%3))+(1<<s[i])]++;
        else if(cnt[1<<((s[i]+2)%3)])
            res=res*cnt[1<<((s[i]+2)%3)]%mod,cnt[1<<((s[i]+2)%3)]--,
                    cnt[(1<<((s[i]+2)%3))+(1<<s[i])]++;
        else res=res*nownum%mod,nownum--,cnt[(1<<s[i])]++;
    }
    printf("%lld\n",res);
}

Measured memory_bytes: 512
import java.util.*;
import java.io.*;

class Main {

	void solve() {

		int a = inint(), b = inint();
		out.println(a%b==0 ? 0 : 1);
		
	}
	
	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);
	
	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}
	
	public int inint() {
		return in.nextInt();
	}
	
	public String instr() {
		return in.next();
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}
	
	public char[] incharar() {
		return in.next().toCharArray();
	}
	
}

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

int main(){
    string s, t; cin >> s >> t;
    int f = 0;
    for(int i = s.size() - 1;i >= 0; i--){
        if(f == 1){
            break;
        }
        int j;
        for(j = 0; j < t.size(); j++){
            if(s[i - j] == t[t.size() - 1 - j] || s[i - j] == '?'){
                continue;
            }else{
                break;
            }
        }
        if(j == t.size()){
            f = 1;
            for(j = 0; j < t.size(); j++){
                s[i-j] = t[t.size() - 1 - j];
            }
        }
    }
    if(f == 0){
        cout << "UNRESTORABLE" << endl; 
    }else{
        for(int i = 0; i < s.size(); i++){
            if(s[i] == '?'){
                s[i] = 'a';
            }
        }
        cout << s << endl;
    }
}

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

using namespace std;
typedef long long ll;

int A, B, Q;
ll s[100000], t[100000];

ll solve(ll a) {
	ll ans = 1e18;
	if (lower_bound(s, s + A, a) != s) {

		//左の神社
		ll tmp = 0;
		ll pos = *(lower_bound(s, s + A, a) - 1);
		tmp += (a - *(lower_bound(s, s + A, a) - 1));

		if (lower_bound(t, t + B, pos) != t) {
			tmp = min(tmp + abs(*lower_bound(t, t + B, pos) - pos),
				tmp + abs(*(lower_bound(t, t + B, pos) - 1) - pos));
		}
		else {
			tmp += abs(*lower_bound(t, t + B, pos) - pos);
		}
			ans = min(ans, tmp);
	}

	if (lower_bound(t, t + B, a) != t) {

		//左の寺
		ll tmp = 0;
		ll pos = *(lower_bound(t, t + B, a) - 1);
		tmp += (a - *(lower_bound(t, t + B, a) - 1));

		if (lower_bound(s, s + A, pos) != t) {
			tmp = min(tmp + abs(*lower_bound(s, s + A, pos) - pos),
				tmp + abs(*(lower_bound(s, s + A, pos) - 1) - pos));
		}
		else {
			tmp += abs(*lower_bound(s, s + A, pos) - pos);
		}
		ans = min(ans, tmp);
	}
	//右の神社
	ll tmp = 0;
	ll pos = *lower_bound(s, s + A, a);
	tmp += abs(*lower_bound(s, s + A, a) - a);
	if (lower_bound(t, t + B, pos) != t) {
		tmp = min(tmp + abs(*lower_bound(t, t + B, pos) - pos),
			tmp + abs(*(lower_bound(t, t + B, pos) - 1) - pos));
	}
	else {
		tmp += abs(*lower_bound(t, t + B, pos) - pos);
	}
	ans = min(ans, tmp);

	tmp = 0, pos = 0;

	//右の寺
	pos = *lower_bound(t, t + B, a);
	tmp += abs(*lower_bound(t, t + B, a) - a);
	if (lower_bound(s, s + A, pos) != t) {
		tmp = min(tmp + abs(*lower_bound(s, s + A, pos) - pos),
			tmp + abs(*(lower_bound(s, s + A, pos) - 1) - pos));
	}
	else {
		tmp += abs(*lower_bound(s, s + A, pos) - pos);
	}
	ans = min(ans, tmp);

	return ans;

}

int main() {
	cin >> A >> B >> Q;
	for (int i = 0; i < A; i++)cin >> s[i];
	for (int i = 0; i < B; i++)cin >> t[i];

	for (int i = 0; i < Q; i++) {
		ll tmp;
		cin >> tmp;
		cout << solve(tmp) << endl;
	}

	return 0;
}

Measured memory_bytes: 2816
n, x = map(int, input().split())
list_L = list(map(int, input().split()))

list_L_hane = [0] + list_L
for i in range(1, len(list_L_hane)):
    list_L_hane[i] = list_L_hane[i] + list_L_hane[i - 1]

score = 0
for i in list_L_hane:
    if i <= x:
        score += 1
    else:
        break

print(score)

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

const long long MOD = (1e9)+7;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	long long res = 1, curr = 0;
	cin >> n;
	for(int i = 0, x; i < n; i++, curr++) {
		cin >> x;
		if(x <= 2*curr) res = (res*(curr+1))%MOD, curr--;
	}
	while(curr) res = (res*curr--)%MOD;
	cout << res;
}

Measured memory_bytes: 256
n=int(input())
p=list(map(int,input().split()))
l=len(p)
#print(l)
count=0
for i in range(l-2):
  if p[i]<p[i+1]<p[i+2] or p[i]>p[i+1]>p[i+2]:
    count+=1
  i+=1
  
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll, ll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rev(a) reverse(all(a))
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll mod=1e9+7;
int main() {
    ll n;
    cin >> n ;
    if(n%2==0) cout << n/2 << endl;
    else cout << (n+1)/2 << endl;
    
	return 0;
}

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif

signed main() {
    
    int x, a, b;
    cin >> x >> a >> b;
    
    if(a>=b) cout <<"delicious" << endl;
    else if(-a+b<=x) cout <<"safe" << endl;
    else cout <<"dangerous" << endl;

    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

vector<ii> adj[200111];
ll ans[200011];

void dfs(int u)
{
	for(ii x:adj[u])
	{
		int v=x.fi; ll w=x.se;
		if(ans[v]<-ll(1e17))
		{
			ans[v] = ans[u] + w;
			dfs(v);
		}
		else
		{
			if(ans[v] != ans[u] + w)
			{
				cout<<"No\n"; exit(0);
			}
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,m; cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int l,r,d; cin>>l>>r>>d; l--; r--;
		adj[l].pb(mp(r,d));
		adj[r].pb(mp(l,-d));
	}
	for(int i=0;i<n;i++) ans[i]=-ll(1e18);
	for(int i=0;i<n;i++)
	{
		if(ans[i]<-ll(1e17))
		{
			ans[i]=0;
			dfs(i);
		}
	}
	cout<<"Yes\n";
}


Measured memory_bytes: 18816
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
using namespace std;
int main(){
    int n;
    cin >> n;
    int x;
    cin >> x;
    int pre=x;
    int count=0;
    bool h=false;
    for(int i=1;i<n;i++){
        int y;
        cin >> y;
        if(h){
            h=false;
            if(y!=pre){
                pre=y;
            }
            continue;
        }
        if(y==pre){
            count++;
            h=true;
        }else{
            pre=y;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
ll X;

void solve()
{
    ll now = 100;
    cin >> X;
    for (int i = 1;; ++i)
    {
        now += now * 0.01;
        if(now>=X)
            return printf("%d\n", i), void();
    }
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 3696
#include <stdio.h>
#include <string.h>

int main(void){
    char p[100];
    char s[100];
    char catp[200];

    scanf("%s%s", p, s);
    strcpy(catp, p);
    strcat(catp, p);
    printf("%s", strstr(catp, s) ? "Yes" : "No");
    puts("");
    return 0;
}



Measured memory_bytes: 2080
K,A,B = input().split()
K = int(K)
A = int(A)
B = int(B)
bi = 1

if(B-A<=2):
    bi+=K
else:
    bi=A
    #print(bi)
    K1=K-(A-1)
    #print(K-(A-1))
    bi+=((K1)//2)*(B-A)
    #print(((K1)//2)*(B-A))
    bi+=((K1)%2)
    #print(((K1)%2))
print(bi)

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

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

int main(){

  ll w,h;cin>>h>>w;
  char map[h][w];
  ll sum=h*w;
  ll mi[h][w];
  rep(i,0,h)rep(j,0,w){
    cin>>map[i][j];
    if(map[i][j]=='#')sum--;
    mi[i][j]=INF;
  }
  sum-=2;

  queue<P>q;
  q.push(P(0,0));
  mi[0][0]=0;

  while(!q.empty()){
    P p=q.front();q.pop();

    ll y=p.first,x=p.second;

    if(y==h-1&&x==w-1)continue;

    rep(i,0,4){
      ll ny=y+dy[i],nx=x+dx[i];

      if(IN(0,h,ny)&&IN(0,w,nx)&&map[ny][nx]=='.'&&mi[y][x]+1<mi[ny][nx]){
        q.push(P(ny,nx));
        chmin(mi[ny][nx],mi[y][x]+1);
      }
    }
  }

  if(mi[h-1][w-1]==INF)out(-1);
  else out(sum-mi[h-1][w-1]+1);

  return 0;
}


Measured memory_bytes: 256
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int a,b,c;
int main(){
	cin>>a>>b>>c;
	if(a==b&&b!=c||a==c&&b!=c||b==c&&a!=b)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int head=0,tail=0;

typedef struct{
  char name[11];
  int time;
}Q;
void inq(Q);
Q deq();
Q queue[100000];

int main(){
  int n,q,i,sumtime=0;
  Q queue,comp;
  scanf("%d%d",&n,&q);
  for(i=0;i<n;i++){
    scanf("%s %d",queue.name,&queue.time);
    inq(queue);
  }
  i=0;
  while(i<n){
    comp=deq();
    if(comp.time>q){
      sumtime+=q;
      comp.time-=q;
      inq(comp);
    }else{
      sumtime+=comp.time;
      printf("%s %d\n",comp.name,sumtime);
      i++;
    }
  }
  return 0;
}

void inq(Q q){
  if(tail+1==100000)tail=0;
  tail++;
  queue[tail-1]=q;
}
Q deq(){
  if(head+1==100000)head=0;
  head++;
  return queue[head-1];
}



Measured memory_bytes: 3264
fun main(args: Array<String>) {
    val n = readInputLine().toInt()
    val k = readInputLine().toInt()
    
    var num = 1
    
    for (i in 1..n) {
        if (num + k < num + num) {
            num += k
        } else {
            num += num
        }
    }
    
    println(num)
}
 
fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 29848
#include <iostream>
#include <list>
#include <algorithm>
#include <map>
#include <math.h>
#include <set>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <queue>
#include <vector>
#include <cstdlib>
#include <stack>
#include <ctime>
#define lld long long int
#define rep(i,start,end) for(lld i = start;i<end;i++)
#define newline cout << endl
#define fastio ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define in insert
#define mp make_pair
#define se second
#define fi first
#define starttime chrono::time_point<chrono::system_clock> start, end; start = chrono::system_clock::now()
#define showtime end = chrono::system_clock::now();  chrono::duration<double> elapsed_seconds = end - start; time_t end_time = chrono::system_clock::to_time_t(end); cout << "elapsed time: " << elapsed_seconds.count() << "s\n"
#define INF 1e16+1
#define MOD (lld)(1e9+7)
#define mh make heap
#define ph push_heap
#define poph pop_heap
#define openf   freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);
using namespace std;
lld add(long long a, long long b){return ((a%MOD)+(b%MOD))%MOD;}

lld mul(long long a, long long b){return ((a%MOD)*(b%MOD))%MOD;}
lld modInverse(lld a){   lld m = MOD,m0 = m, y = 0, x = 1;  if (m == 1) return 0;   while (a > 1) {  lld q = a / m, t = m;  m = a % m, a = t, t = y;          y = x - q * y, x = t;   } if (x < 0)  x += m0; return x; } 
lld gcd(lld a, lld b){if (b == 0) return a; return gcd(b, a % b);}
void MAIN();
int get(){lld t;cin>>t; return t;}
int log(string name){cout<<name<<endl; return 0;}
void test(int t) { while(t--){MAIN();} }
#define all(v) (v).begin(),(v).end()

void MAIN(){    

    string s;  
    cin >> s;
    string t;
    t = s;
    reverse(all(t));
    if(t==s)
    {
        string p = s.substr(0,s.size()/2);
       //cout << p << endl;
        reverse(all(p));
        if(s.substr(0,s.size()/2)==p)
        {
            p = s.substr(s.size()/2+1,s.size());
           // cout << p;
            reverse(all(p));
            if(s.substr(s.size()/2+1,s.size())==p)
                {
                    cout <<"Yes";
                    return;
                }
        }
    }
    cout <<"No";
    
   
}





int main(){ 
    fastio;
    test(1);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    if(s.at(0)==s.at(1)||s.at(1)==s.at(2)||s.at(0)==s.at(2))
    cout<<"No"<<endl;
    else
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 3628
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    if n == 25:
        print("Christmas")
    elif n == 24:
        print("Christmas Eve")
    elif n == 23:
        print("Christmas Eve Eve")
    elif n == 22:
        print("Christmas Eve Eve Eve")
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 61944
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args){
  Scanner scan = new Scanner(System.in);
   
  int a = scan.nextInt();
  int b = scan.nextInt();
  int c = scan.nextInt();
  scan.close();
  int p = (a + b);
  int q = (a + c);
  int r = (b + c);
  int min;
  	min = Math.min(p,q);
  	min = Math.min(min,r);
  	System.out.println(min);
  }
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N,M;
    cin >> N >> M;
    vector<pair<int,int> > vec(N);
    rep(i,N){
        cin >> vec[i].first >> vec[i].second;
    }
    sort(all(vec));
    priority_queue<int> pque;
    rep(i,100005){
        pque.push(0);
    }
    int count = 0;
    int ans = 0;
    for (int i = 1; i <= M; i++){
        while(true){
            if (count >= N){
                break;
            }
            else if (vec[count].first != i){
                break;
            }
            else{
                pque.push(vec[count].second);
                count++;
            }
        }
        ans += pque.top();
        pque.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 2168
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


#隣接リスト 1-index
def make_adjlist_nond(n, edges):
    res = [[] for _ in range(n+1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
        res[edge[1]].append(edge[0])
    return res


def main():
    N, M = NMI()
    F = [NLI() for _ in range(M)]
    tree = make_adjlist_nond(N, F)

    ans = 0
    seen = [0] * (N + 1)
    for start in range(1, N+1):
        que = deque()
        que.append(start)

        seen[start] = 1
        fri_cnt = 1
        while que:
            now = que.popleft()

            for goto in tree[now]:
                if seen[goto]:
                    continue
                seen[goto] = 1
                fri_cnt += 1
                que.append(goto)
        ans = max(fri_cnt, ans)
    print(ans)





if __name__ == "__main__":
    main()

Measured memory_bytes: 132700
fun main(args: Array<String>) {
    val (n, a, b) = readLine()!!.split(" ").map { it.toLong() }
    val sum = a + b
    val count : Long = n/sum
    val amari = a - (n - count*sum)
    if(amari > 0L) println(a*count + n - count*sum)
    else println(a*count + a)
}

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

int32_t main()
{

    int n,a,cnt=0;
    cin>>n;

    vector<int> v;

    for(int i=1; i<=n; i++){
       cin>>a;
       v.push_back(a);
       if(i%2 !=0 and a%2!=0) cnt++;
    }

    cout<<cnt<<endl;

    return 0;
}



Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

#define MAX_N 100005
int N,M;
map<  int, map<int , vector<int> >  > G;
map<int, map<int,bool> > visited;
int d[MAX_N];

vector<int> v;

void dfs(int pos,int ID){
  if(visited[pos][ID])return;
  visited[pos][ID]=true;
  v.push_back(pos);
  for(int i=0;i<(int)G[pos][ID].size();i++){
    dfs(G[pos][ID][i],ID);
  }
}

int main(){
  scanf("%d %d",&N,&M);
  for(int i=0;i<=N;i++)d[i]=1e8;
  
  for(int i=0;i<M;i++){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    G[a][c].push_back( b );
    G[b][c].push_back( a );
  }


  priority_queue< P , vector<P> , greater<P> > Q;
  Q.push(P(0,1));
  d[1]=0;
  while(!Q.empty()){
    P p=Q.top();Q.pop();
    int pos=p.second;
    int cost=p.first;
    if(d[pos]<cost)continue;
    map<int, vector<int> > &g=G[pos];
    for( auto &e : g ){
      if( visited[pos][e.first] )continue;
      v.clear();
      dfs(pos,e.first);
      for(int i=0;i<(int)v.size();i++){
        int to=v[i];
        if( d[to] > cost+1 ){
          d[to]=cost+1;
          Q.push(P(cost+1,to));
        }
      }
    }
  }

  if(d[N]==1e8)cout<<-1<<endl;
  else cout<<d[N]<<endl;
  
  return 0;
}


Measured memory_bytes: 82168
///
// File:  b.go
// Author: ymiyamoto
//
// Created on Sat May 12 19:14:32 2018
//
package main

import (
	"fmt"
)

var N int
var arr []int

func main() {
	fmt.Scan(&N)

	arr = make([]int, N+1)
	for i := 1; i <= N; i++ {
		var p int
		fmt.Scan(&p)
		arr[p] = i
	}

	for i := 1; i <= N; i++ {
		if i != 1 {
			fmt.Print(" ")
		}
		fmt.Print(i * N)
	}
	fmt.Println()

	for i := 1; i <= N; i++ {
		if i != 1 {
			fmt.Print(" ")
		}
		fmt.Print(N*(N-i) + arr[i])
	}
	fmt.Println()
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m, a, b, ans = 0;
    cin >> n >> m;
    vector<int> G[n];
    for (int i = 0; i < m; i++)
    {
        cin >> a >> b;
        G[a - 1].push_back(b - 1);
        G[b - 1].push_back(a - 1);
    }
    int un_vis = n;
    vector<bool> vis(n, false);
    stack<pair<int, bool>> s;
    s.push({0, false});
    bool debug = false;
    int tp;
    while (!s.empty())
    {
        tp = s.top().first;
        if (debug)
            cout << "Top: " << tp << endl;
        if (vis[tp])
        {
            while (!s.empty() and vis[s.top().first])
            {
                if (debug)
                    cout << "Pop1: " << s.top().first << " ";
                vis[s.top().first] = false;
                un_vis++;
                s.pop();
            }
            if (debug)
                cout << endl;

            if (s.empty())
                break;
            tp = s.top().first;
            if (debug)
                cout << "New Top: " << tp << endl;
        }

        vis[tp] = true;
        un_vis--;
        for (int i = 0; i < G[tp].size(); i++)
        {
            if (!vis[G[tp][i]])
            {
                if (debug)
                    cout << "Push: " << G[tp][i] << " ";
                s.push({G[tp][i], false});
            }
        }
        if (debug)
            cout << endl;

        if (un_vis == 0)
        {
            ans++;
            while (!s.empty() and vis[s.top().first])
            {
                if (debug)
                    cout << "Pop: " << s.top().first << " ";
                vis[s.top().first] = false;
                un_vis++;
                s.pop();
            }
            if (debug)
                cout << endl;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/perl

$line = 0;
while(<>) {
    chomp;
    if ($line == 0) {
        $n = $_;
    } else {
        @a = split /\s+/, $_;
    }
    $line++;
}

foreach (@a) {
    if ($_ != 0) {
        $e{$_ - 1}++;
    }
    $e{$_}++;
    $e{$_ + 1}++;
}

$max = 0;
foreach (keys %e) {
    if($max < $e{$_}) {
        $max = $e{$_};
    }
}
print "$max\n";


Measured memory_bytes: 27596
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::unordered_set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  ui a,b; cin >> a >> b;
  cout << (a - 1)*(b - 1) << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
a,b,c,x,y = [int(i) for i in input().split()]
if a>2*c and b>2*c:
        m = max(x,y)*2*c
elif a>2*c:
        if x>=y:
            m = x*2*c
        else:
            m=x*2*c+(y-x)*b
elif b>2*c:
        if y>=x:
            m=y*2*c
        else:
            m=y*2*c +(x-y)*a
elif a+b>2*c:
    if x>=y:
        d=a
    else:
        d=b
    m = min(x,y)*2*c+(max(x,y)-min(x,y))*d
else:
    m = x*a + y*b
print(m)

Measured memory_bytes: 3064