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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  ll x; cin >> x;
  ll ans = (x/(11))*2;
  x %= 11;
  if(0 < x && x <= 6) ++ans;
  else if(x > 6) ans += 2;
  cout << ans << endl;
}


Measured memory_bytes: 256
package main

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

type Reader struct {
	reader *bufio.Reader
}

func toInt(str string) int {
	num, _ := strconv.Atoi(str)
	return num
}

func (reader *Reader) result() int {
	line, _, _ := reader.reader.ReadLine()
	stringLine := string(line)
	slitted := strings.Split(stringLine, " ")
	result := (toInt(slitted[0]) + toInt(slitted[1])) - (toInt(slitted[2]) + toInt(slitted[3]))
	return result
}

func main() {
	reader := &Reader{}
	reader.reader = bufio.NewReader(os.Stdin)



	result := reader.result()

	if result > 0 {
		fmt.Println("Left")
	} else if result < 0 {
		fmt.Println("Right")
	} else {
		fmt.Println("Balanced")
	}
}


Measured memory_bytes: 640
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {
	
	int n, m;
	scanf("%d%d", &n, &m);
	printf("%d\n", n * m);

	Please AC;
}


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

int main() {
    ll N;cin >> N;
    ll a[N] = {};
    for (int i = 0;i < N;i++){
        cin >> a[i];
    }
    int res = 0;int num = 1;
    for (int i = 0;i < N;i++){
        if (a[i] != num) res++;
        else num++;
    }
    if (num == 1) cout << -1 << endl;
    else cout << res << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int b[2000000];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>b[i];
	for(int i=n;i>0;i-=2)
		cout<<b[i]<<" ";
	for(int i=(n%2!=0)+1;i<=n;i+=2)
		cout<<b[i]<<" ";
	cout<<endl;
	return 0;
} 

Measured memory_bytes: 2944
import queue as qu
def BFS(connectinons:list,N):
    bfs_connections=[[] for _ in range(N)]
    reverse_connections=[[] for _ in range(N)]


    for A,B,_ in connectinons:
        bfs_connections[A].append(B)
        reverse_connections[B].append(A)
    
    reachable= [False]*N
    rev_reachable=[False]*N

    q = qu.Queue()
    q.put(0)

    while not q.empty():
        node = q.get()
        if reachable[node]:
            continue
        reachable[node]=True

        for B in bfs_connections[node]:
            q.put(B)
    
    q = qu.Queue()
    q.put(N-1)

    while not q.empty():
        node = q.get()
        if rev_reachable[node]:
            continue
        rev_reachable[node]=True

        for B in reverse_connections[node]:
            q.put(B)

    use=set()
    for i in range(N):
        if reachable[i] and rev_reachable[i]:
            use.add(i)
        
    return [[a,b,c] for a,b,c in connectinons if a in use and b in use]









def b_ford(connections:list,N):
    inf=float('inf')
    cost =[inf]*N
    cost[0]=0
    newchanged = set()
    oldchanged = set()

    for i in range(N):
        oldchanged=newchanged
        newchanged= set()
        for A,B,C in connections:
            if cost[A]+C < cost[B]:
                newchanged.add(B)
                cost[B]=cost[A]+C
        
        if not newchanged:
            if cost[-1] > 0:
                print(0)
            else:
                print(-cost[-1])
            return
    print(-1)







def resolve():
    N,M,P = map(int,input().split())
    
    connections = []
    for i in range(M):
        A,B,C = map(int,input().split())
        
        connections.append([A-1,B-1,P-C])
    #print(connections)
    connections = BFS(connections,N)
    #print(connections)
    b_ford(connections,N)

resolve()

Measured memory_bytes: 92884
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m; cin >> n >> m;
  vector<int> food(m,0);
  for(int i = 0; i < n; i++){
    int k; cin >> k;
    for(int j = 0; j < k; j++){
      int a; cin >> a;
      a--;
      food.at(a)++;
    }
  }
  int cnt = 0;
  for(int i = 0; i < m; i++){
    if(food.at(i) == n) cnt++;
  }
  cout << cnt;
}

Measured memory_bytes: 3640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] cnt = new int[10][10];
        for(int i = 1; i < n + 1; ++i) {
            String si = String.valueOf(i);
            int head = (int)(si.charAt(0) - '0');
            int tail = (int)(si.charAt(si.length() - 1) - '0');
            ++cnt[head][tail];
        }
        
        long ans = 0L;
        for(int i = 0; i < 10; ++i) {
            for(int j = 0; j < 10; ++j) {
                ans += 1L * cnt[i][j] * cnt[j][i];
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 32724
#include <iostream>
#include <vector>
#include <algorithm>

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

    std::vector<long long> in(n);
    for (auto& work : in)
    {
        std::cin >> work;
        if (work == 0)
        {
            std::cout << "0";
            return 0;
        }
    }

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

    long long ans = 1;
    for (const auto& prod : in)
    {
        constexpr long long MAX = 1e18;
        if (MAX / ans < prod)
        {
            std::cout << "-1";
            return 0;
        }
        ans *= prod;
    }
    std::cout << ans;
}

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



int main(){
  string S; cin>>S;
  bool bad=false;
  for(int i=0;i<3;i++){
    if(S.at(i)==S.at(i+1))
      bad=true;
  }
  
  if(bad)
    cout<<"Bad"<<endl;
  else
    cout<<"Good"<<endl;
}

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

namespace ABC148A
{
	class Program
	{
		static void Main(string[] args)
		{
			int a, b,c;
			a = int.Parse(Console.ReadLine());
			b = int.Parse(Console.ReadLine());
			c = 6 - (a + b);
			Console.WriteLine(c);

			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <climits>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define fish        push_front
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Deque       std::deque
#define PQueue      std::priority_queue
#define Set         std::set
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B> A power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A, class B> A lcm   ( A x,  B y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A, class B> inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B> inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    signed call_of_Cthulhu( signed datum ) {

        String s, t;
        read s >> t;
        s = s + s;
        if ( s.find(t) == -1 ) {
            echo "No" fin;
        }
        else {
            echo "Yes" fin;
        }

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int gcd(int,int);

int main(){

  int x,y;

  scanf("%d %d",&x,&y);
  if(x<1 || y>1000000000) exit(1);
  printf("%d\n",gcd(x,y));
  
  return 0;
}

int gcd(int x,int y){

  int num;

  num = y ? gcd(y,x%y) : x;
  return num;
}



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

int main(){
  ll A,B,C;
  cin>>A>>B>>C;

  ll ans=0;
  while(1){
    if(A%2==1||B%2==1||C%2==1)break;

    if(A==B&&B==C){
      cout<<-1<<endl;
      return 0;
    }
    
    ans++;
    ll sum=A+B+C;
    A=(sum-A)/2;
    B=(sum-B)/2;
    C=(sum-C)/2;

    //    cout<<A<<' '<<B<<' '<<C<<endl;
  }
  cout<<ans<<endl;
  return 0;
}


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

typedef long lint;
typedef long long llint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }


int main(void) {
    int n, tmax;
    cin >> n >> tmax;

    vector<int> c(n);
    vector<int> t(n);
    for(int in=0;in<n;in++) {
        cin >> c.at(in) >> t.at(in);
    }

    int ans = 10000;
    for(int in=0;in<n;in++) {
        if(t.at(in)<=tmax) ans = min(ans, c.at(in));
    }

    if(ans==10000) cout << "TLE" << endl;
    else cout << ans << endl;

    return 0;
}


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

int main() {
  int K, T;
  cin >> K >> T;
  int a[110];
  for (int i = 0; i < T; i++) cin >> a[i];

  sort(a, a + T);
  int x = 0;
  for (int i = 0; i < T - 1; i++) x += a[i];

  if (a[T - 1] <= x + 1) cout << 0 << endl;
  else cout << a[T - 1] - (x + 1) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<vector>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}

void Yn(bool f)
{
  cout << (f ? "Yes" : "No") << endl;
}

void yn(bool f)
{
  cout << (f ? "yes" : "no") << endl;
}

void YN(bool f)
{
  cout << (f ? "YES" : "NO") << endl;
}
int n, k;
string s;

int main()
{
  cin >> n >> s >> k;
  string t;
  REP(i, n)
  {
    if(s[i] != s[k-1])
      t.push_back('*');
    else
    {
      t.push_back(s[i]);
    }
  }

  cout << t << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind, COM//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S;
ll MOD = 1000000007; ll ans = 1000000; ll INF = 9999999999999;
vl flag, color; vll path;
//***********//
ll A = 'a';
ll Z = 'z';
int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	ll p = 4;
	if (c - a - b < 0) {
		cout << "No" << endl;
		exit(0);
	}
	if (p * a * b >= (c - a - b) * (c - a - b)) {
		cout << "No";
	}
	else {
		cout << "Yes";
	}
}


Measured memory_bytes: 256
//
//  main.cpp
//  CppTest
//
//  Created by Ryu on 2017/02/08.
//  Copyright © 2017年 Ryu. All rights reserved.
//

#include <iostream>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    long n;
    cin >> n;
    
    long a[n];
    long b[n];
    
    for (int i = 0; i < n ; i++) {
        cin >> a[i] >> b[i];
    }
    
    
    
    long count = 0;
    for(int nowPlus = n - 1; nowPlus >= 0; nowPlus--){
        a[nowPlus] += count;
        if(a[nowPlus] % b[nowPlus] != 0){
            count += b[nowPlus] - (a[nowPlus] % b[nowPlus]);
        }
        /*
         printf("\n-----------------\n a = ");
         for (int i = 0; i < n; i++) {
         printf("%d ", a[i]);
         }
         printf(" count = %d\n", count);*/
    }
    
    cout << count;
    
    
    return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int graph[20][20];

ll comp[1<<16];
ll dp[1<<16][16];

const ll inf = 1LL << 40;

int main(void){
	int n,m;
	cin >> n >> m;

	rep(i,n)rep(j,n) graph[i][j]=-(i!=j);

	ll total = 0LL;
	rep(i,m){
		int a,b,c;
		cin >> a >> b >> c;
		a--,b--;
		graph[a][b] = graph[b][a]=c;
		total += c;
	}

	rep(mask,1<<n){
		comp[mask]=0;
		rep(i,n) if(mask&(1<<i)){
			rep(j,i) if(mask&(1<<j)){
				if(graph[i][j]==-1) continue;
				comp[mask]+=graph[i][j];
			}
		}
	}

	const int all = (1 << n) - 1;

	rep(i,all)rep(j,n) dp[i][j]=-inf;
	dp[1][0]=0;

	rep(mask,1,all)rep(i,n){
		if(dp[mask][i]==-inf) continue;
		if((mask&(1<<i))==0) continue;
		
		for(int amask = (~mask) & all; amask > 0 ; amask = (amask-1) & (~mask)){
			const int nmask = mask | amask;
			chmax(dp[nmask][i],dp[mask][i] + comp[amask | (1 << i)]);
		}

		rep(j,n){
			if(mask >> j & 1) continue;
			if(graph[i][j]==-1) continue;
			const int nmask = mask | (1 << j);
			chmax(dp[nmask][j], dp[mask][i] + graph[i][j]);
		}
	}

	const ll ans = total - dp[(1 << n) - 1][n-1];
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k;
  cin >> n >> k;
  
  int ans = k;
  if (n > 1) {
    for (int i = 2; i <= n; i++) {
      ans *= k-1;
    }
  }
  
  cout << ans << endl;
    
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();
    
    int n; cin >> n;
    VI a(n); cin >> a;

    int cnt = 0;
    FOR(i, 0, n)if (a[i] % 2 == 1)++cnt;
    cout << (cnt % 2 == 0 ? "YES\n" : "NO\n");
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
using P = pair<Int, Int>;
const Int B = 1LL<<52;
P add(P s,Int a,Int k){
  s.second+=a*k;
  return s;
}
Int check(P s,Int a,Int k){
  if(a>(B<<1)/k) return 1;
  if(a*k>=(B<<1)) return 1;
  if(s.second+a*k>=(B<<1)) return 1;
  return 0;
}
P add2(P s,Int a){
  s.second+=a;
  assert(s.second>=(B<<1));
  s.second>>=1;
  s.first++;
  return s;
}
signed main(){
  Int n;
  while(cin>>n,n){
    string b;
    cin>>b;
    Int a=1;
    for(Int i=0;i<(Int)b.size();i++)
      a=(a<<1)|(b[i]=='1');
    P s(0,a);
    while(n){
      if(!check(s,a,n)){
	s=add(s,a,n);
	n=0;
	break;
      }
      Int l=0,r=n;
      while(l+1<r){
	Int m=(l+r)>>1;
	if(check(s,a,m)) r=m;
	else l=m;
      }
      s=add(s,a,l);
      s=add2(s,a);
      n-=r;
      a>>=1;
    }
    bitset<12> x(s.first);
    bitset<52> y(s.second-B);
    cout<<x<<y<<endl;
  }
  return 0;
}



Measured memory_bytes: 3144
n, m = map(int, input().split())
c = list(map(int, input().split()))
dp = [float('inf')] * (n + 1)
dp[0] = 0
for i in range(n):
    for j in range(m):
        if i + c[j] <= n:
            dp[i + c[j]] = min(dp[i + c[j]], dp[i] + 1)
print(dp[n])



Measured memory_bytes: 7272
import random

class Dice():
    def __init__(self):
        self.face = [i for i in range(6)]
        self.memo = [i for i in range(6)]

    def setface(self,initface):
        for i in range(6):
            self.face[i] = initface[i]

    def roll(self,direction):
        for i in range(6):
            self.memo[i] = self.face[i]
        index = {'E':(3,1,0,5,4,2),'N':(1,5,2,3,0,4),'S':(4,0,2,3,5,1),'W':(2,1,5,0,4,3)}
        for i in range(6):
            self.face[i] = self.memo[index[direction][i]]

    def top(self):
        return self.face[0]

dice1 = Dice()
dice2 = Dice()
dice1.setface(list(map(int,input().split())))
dice2.setface(list(map(int,input().split())))

for i in range(10000):
    dice2.roll(['E','N','S','W'][random.randint(0,3)])
    for j in range(6):
        if dice1.face[j]!=dice2.face[j]:
            break
    else:
        print('Yes')
        break
else:
    print('No')


Measured memory_bytes: 8188
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
int main(){
	lli n;
	cin>>n;
	lli arr[n];
	for(lli i=0;i<n;i++)
	cin>>arr[i];
	lli dp[n];
	for(lli i=0;i<n;i++)
	dp[i]=INT_MAX;
	dp[0]=0;
	for(lli i=0;i<n;i++){
		if(i+1<n)
		dp[i+1]=min(dp[i+1],dp[i]+abs(arr[i]-arr[i+1]));
		if(i+2<n)
		dp[i+2]=min(dp[i+2],dp[i]+abs(arr[i]-arr[i+2]));
	}
	cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 1792
/*
https://atcoder.jp/contests/dp/tasks/dp_a
*/
#include<bits/stdc++.h>
using namespace std;

int main(){

    int n;  cin>>n;
    int height[n];
    int dp[n];

    for(int i=0;i<n;i++){
        cin>>height[i];
        dp[i] = 0;
    }

    dp[0] = 0;
    dp[1] = abs(height[1]-height[0]);

    for(int i=2;i<n;i++){
        dp[i] = min((abs(height[i]-height[i-1])+dp[i-1]), (abs(height[i]-height[i-2])+dp[i-2]));
    }

    cout<<dp[n-1]<<"\n";

return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
  int n;
  cin >> n;
  map<int,int> mp;
  rep(i,n){
    int a;
    cin >> a;
    mp[a-1] ++;
    mp[a] ++;
    mp[a+1] ++;
  }
  int ans = 1;
  for(auto i:mp) ans = max(ans,i.second);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 4736
// 解説PDFを実装
// 自力で実装したd.later1.cppより大幅に簡単化
//
// nを偶数として n ^ (n + 1)は必ず1になることを利用すると
// 0からNまでのxorのうち序盤はほとんど1になり大幅に簡単化
//
// この性質に気付けなくても、実験すればmod4で法則があることには
// 気付けたはず

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

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

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

// 0からnまでのXORを取った結果を返す
ll xor_to_n(ll n) {
    auto mod4 = n % 4;
    if (mod4 == 1) {
        return 1;
    } else if (mod4 == 3) {
        return 0;
    } else if (mod4 == 2) {
        return n ^ 1;
    } else {
        return n;
    }
}


int main(void)
{
    cin.sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;

    if (A == 0) {
        cout << xor_to_n(B) << endl;
    } else {
        cout << (xor_to_n(B) ^ xor_to_n(A - 1)) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np
input = sys.stdin.readline
n = int(input())

L = np.array(list(map(int, input().split())))

for i in range(n-1, 0, -1):
    if L[i]-L[i-1] ==-1:
        L[i-1] -=1

if np.all(L ==sorted(L)):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 23120
#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
#define INF 1e18

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, a[111111];
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	ll ans1 = -1;
	ll lo=1, hi = 1e17;
	ll mid;
	while(lo<=hi){
		mid = (lo+hi)/2;
		ll x = mid;
		for(int i = 0; i < n; i++){
			x-=(x%a[i]);
		}
		if(x<=1){
			lo=mid+1;
		}
		else{
			hi=mid-1;
			if(x==2){
				ans1=mid;
			}
		}
	}
	ll ans2=-1;
	lo=1, hi = 1e17;
	while(lo<=hi){
		mid = (lo+hi)/2;
		ll x = mid;
		for(int i = 0; i < n; i++){
			x-=(x%a[i]);
		}
		if(x>=3){
			hi=mid-1;
		}
		else{
			lo=mid+1;
			if(x==2){
				ans2=mid;
			}
		}
	}
	if(ans1==-1){
		cout << -1;
	}
	else{
		cout << ans1 << " " << ans2;	
	}
	
	return 0;
}


Measured memory_bytes: 1024
import itertools as it
import collections as col

import sys
sys.setrecursionlimit(10000)

class UnionFind:
    def __init__(self):
        '''\
Create an empty union find data structure.'''
        self.num_weights = {}
        self.parent_pointers = {}
        self.num_to_objects = {}
        self.objects_to_num = {}
        self.__repr__ = self.__str__
    def insert_objects(self, objects):
        '''\
Insert a sequence of objects into the structure.  All must be Python hashable.'''
        for object in objects:
            self.find(object);
    def find(self, object):
        '''\
Find the root of the set that an object is in.
If the object was not known, will make it known, and it becomes its own set.
Object must be Python hashable.'''
        if not object in self.objects_to_num:
            obj_num = len(self.objects_to_num)
            self.num_weights[obj_num] = 1
            self.objects_to_num[object] = obj_num
            self.num_to_objects[obj_num] = object
            self.parent_pointers[obj_num] = obj_num
            return object
        stk = [self.objects_to_num[object]]
        par = self.parent_pointers[stk[-1]]
        while par != stk[-1]:
            stk.append(par)
            par = self.parent_pointers[par]
        for i in stk:
            self.parent_pointers[i] = par
        return self.num_to_objects[par]
    def union(self, object1, object2):
        '''\
Combine the sets that contain the two objects given.
Both objects must be Python hashable.
If either or both objects are unknown, will make them known, and combine them.'''
        o1p = self.find(object1)
        o2p = self.find(object2)
        if o1p != o2p:
            on1 = self.objects_to_num[o1p]
            on2 = self.objects_to_num[o2p]
            w1 = self.num_weights[on1]
            w2 = self.num_weights[on2]
            if w1 < w2:
                o1p, o2p, on1, on2, w1, w2 = o2p, o1p, on2, on1, w2, w1
            self.num_weights[on1] = w1+w2
            del self.num_weights[on2]
            self.parent_pointers[on2] = on1
    def __str__(self):
        '''\
Included for testing purposes only.
All information needed from the union find data structure can be attained
using find.'''
        sets = {}
        for i in xrange(len(self.objects_to_num)):
            sets[i] = []
        for i in self.objects_to_num:
            sets[self.objects_to_num[self.find(i)]].append(i)
        out = []
        for i in sets.itervalues():
            if i:
                out.append(repr(i))
        return ', '.join(out)

def main():
    n,m = [int(x) for x in input().split()]
    p = [int(x)-1 for x in input().split()]
    g = [[int(x)-1 for x in input().split()] for _ in range(m)]
    uf = UnionFind()
    uf.insert_objects(p)
    for x,y in g:
        uf.union(x,y)

    count = 0
    for x,y in enumerate(p):
        if uf.find(x) == uf.find(y):
            count +=1
    print(count)


if __name__ == '__main__':
    main()

Measured memory_bytes: 113900
//Name: The Last Ant
//Level: 2
//Category: シミュレーション
//Note:

/**
 * 細いところにいるアリを管理して1秒ずつシミュレーションする。
 * 2匹のアリが衝突するとき、隣り合ったセルにいた場合は、1秒後にはすれ違っているので問題ない。
 * 1つ離れたマスにいた場合は、移動後に向きを反転する。
 *
 * 向きの反転を考えた場合でも、アリを区別しなければそのまますれ違ったのと同じなので、
 * 全てのアリが脱出するまでの時間は高々l秒である。
 * したがって、この愚直なシミュレーションで間に合う。
 *
 * オーダーは O(NL)。
 */
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool solve() {
    int N, L;
    if(!(cin >> N >> L)) return false;
    if(!N && !L) return false;

    vector<vector<pair<int,int>>> ants(L+1), buf(L+1);
    for(int i = 0; i < N; ++i) {
        char c;
        int x;
        cin >> c >> x;
        ants[x].emplace_back(i, c == 'L' ? -1 : 1);
    }

    int rem = N;
    int last = -1;
    int turn = 0;
    while(rem) {
        ++turn;
        for(int i = 0; i < L+1; ++i) {
            buf[i].clear();
        }
        for(int i = 0; i < L+1; ++i) {
            for(const auto &ant : ants[i]) {
                buf[i + ant.second].push_back(ant);
            }
        }
        for(int i = 0; i < L+1; ++i) {
            if(buf[i].size() == 2) {
                buf[i][0].second *= -1;
                buf[i][1].second *= -1;
            }
        }
        if(buf.back().size() > 0) {
            last = buf.back()[0].first;
            buf.back().clear();
            --rem;
        }
        if(buf[0].size() > 0) {
            last = buf[0][0].first;
            buf[0].clear();
            --rem;
        }
        ants.swap(buf);
    }
    cout << turn << ' ' << last+1 << endl;
    return true;
}

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

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1216
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    string s;
    int cnt = 0;
    cin >> s;
    rep(i,4)if(s[i] == '2')cnt++;
    cout << cnt << endl;
}

Measured memory_bytes: 256
//@source : 
//@create : 19:27:55 Saturday 27/06/2020
//@author : nghethuat102
//@status : 
#include <bits/stdc++.h>
using namespace std;

const long long MOD = 1e9 + 7;
const int N = 5000001;

vector<long long> fact(N);
vector<long long> invFact(N);

long long power(long long a, long long b) {
    long long ans = 1;
    while (b > 0) {
        if (b & 1) {
            ans = ans * a % MOD;
        }
        a = a * a % MOD;
        b >>= 1;
    }
    return ans; 
}

void build() {
    fact[0] = 1;
    invFact[0] = 1;
    for (int i = 1; i < N; ++i) {
        fact[i] = fact[i - 1] * i % MOD;
        invFact[i] = power(fact[i], MOD - 2) % MOD;
    }
}

long long ckn(int k, int n) {
    long long ans = fact[n] * invFact[n - k] % MOD;
    return ans * invFact[k] % MOD;
}

void solve() {
    int n, m;
    cin >> n >> m;
    long long all = fact[m] * invFact[m - n] % MOD;
    long long ans = all * all % MOD;
    for (int i = 1; i <= n; ++i) {
        long long tmp = ckn(i, n);
        int mm = m - i;
        int nn = n - i;
        tmp *= fact[mm];
        tmp %= MOD;
        tmp *= invFact[mm - nn];
        tmp %= MOD;
        tmp *= all;
        tmp %= MOD;
        if (i & 1) {
            ans = (ans + MOD - tmp) % MOD;
        } else {
            ans = (ans + tmp) % MOD;
        }
    }
    cout << ans << "\n";
}

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    build();
    int t = 1;
    while (t--) {
        solve();
    }
  //  cerr << fixed << setprecision(5) << double(clock()) * 1000 / CLOCKS_PER_SEC << " ms\n";
    return 0;
}

Measured memory_bytes: 81248
/// In The Name Of God

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

using namespace std;

int n;
int a[N], b[N];

vector <int> st;
ll ans;
int get(int l, int r) {
	return upper_bound(all(st), r) - lower_bound(all(st), l);
}
void solve(int k) {
	int m1 = (1 << k), m2 = m1 << 1;
	for (int i = 1; i <= n; i++) {
		st[i - 1] = a[i] & (m2 - 1);
	}
	sort(all(st));
	ll cnt = 0;
	for (int i = 1; i <= n; i++) {
		int cur = b[i] & (m2 - 1);
		cnt += get(m1 - cur, m2 - cur - 1);
		cnt += get(m1 + m2 - cur, m2 << 1);
	}
	if (cnt & 1) ans += m1;
}
int main() {
	#ifdef IOI2018
		freopen ("in.txt", "r", stdin);
	#endif
	Kazakhstan
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++) {
		cin >> b[i];
	}
	st.resize(n);
	for (int i = 0; i < 29; i++) {
		solve(i);
	}
	cout << ans;
	ioi
}


Measured memory_bytes: 2688
from itertools import combinations_with_replacement

n,m,q = map(int,input().split())
abcd = [list(map(int,input().split())) for _ in range(q)]

ans = 0
for a2 in combinations_with_replacement(range(1,m+1),n-1):
    A = [0,1] + list(a2)
    score = 0
    for a,b,c,d in abcd:
        if A[b] -A[a] == c:
            score += d
    ans = max(ans,score)
    
print(ans)

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

#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define mod 1000000007

int main()
{
	FASTIO
	string s;
	cin >> s;
	int n = s.size();
	
	ll dp[100005][13];
	memset(dp,0,sizeof(dp));
	dp[0][0] = 1;
	
	for(int i=0; i<n; i++)
	{
		int p;
		if(s[i] == '?') p = -1;
		else p = s[i]-'0';
		
		for(int j=0; j<10; j++)
		{
			if(p != -1 && j != p) continue;
			for(int k=0; k<13; k++)
			{
				dp[i+1][(k*10+j)%13] += dp[i][k];
			}
		}
		for(int j=0; j<13; j++) dp[i+1][j] %= mod;
	}
	cout << dp[n][5] << "\n";
	
	return 0;
}

Measured memory_bytes: 13864
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(998244353)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
int main()
{
 int n;
  cin>>n;
  vector<int>d(n);
  for(int i=0;i<n;i++)cin>>d[i];
  sort(all(d));
  ll l = d[n/2-1];
  ll r = d[n/2];
  cout<<r-l;
  
}

Measured memory_bytes: 3772
mod = 1000000007
H, W, A, B = map(int, raw_input().split())

factorial = [1]
for n in xrange(1, H+W):
    factorial.append(factorial[n-1]*n%mod)

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y/2)**2 % mod
    else            : return power(x, y/2)**2 * x % mod

inverseFactorial = [0] * (H+W)
inverseFactorial[H+W-1] = power(factorial[H+W-1], mod-2)
for n in xrange(H+W-2, -1, -1):
    inverseFactorial[n] = inverseFactorial[n+1] * (n+1) % mod

def combi(n, m):
    return factorial[n] * inverseFactorial[m] * inverseFactorial[n-m] % mod

sum = 0
for i in xrange(B+1, W+1):
    sum = (sum + combi(H-A-1+i-1, i-1) * combi(A-1+W-i, W-i)) % mod
print sum

Measured memory_bytes: 16900
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt(),
            B = sc.nextInt(),
            C = sc.nextInt();

        if (C - (A - B)< 0) {
            System.out.println(0);
        } else {
            System.out.println(C - (A - B ));
        }
    }
}

Measured memory_bytes: 22604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
ll mod=998244353,c[200005];
ll qpow(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1) res=res*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return res%mod;
}
int main(){
    ll n,m,k,ans=0;
    cin>>n>>m>>k;
    ll up=1,down=n-1;
    c[0]=1;
    for(ll i=1;i<=n-1;i++){
        c[i]=(c[i-1]%mod*down%mod*qpow(up,mod-2)%mod)%mod;
        down--;up++;
    }
    for(ll i=0;i<=k;i++){
        ans=(ans%mod+c[i]*m%mod*qpow(m-1,n-1-i)%mod)%mod;
    }
    cout<<ans<<endl;
}

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

int main()
{
	int x, a, b;

	cin >> x >> a >> b;

	if (abs(a - x) > abs(b - x))
		cout << "B" << endl;
	else
		cout << "A" << endl;

	return 0;
}

Measured memory_bytes: 256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() { 
  string s;
  int n;
  cin>>n>>s;
  string abc="ABC";
  int cnt=0;
  bool flag;
  rep(i,n){
      flag=1;
      if(s[i]==abc[0]){
          rep(j,3){
              if(s[i+j]!=abc[j]) flag=0;
          }
      }else{
          flag=0;
      }
      if(flag) cnt++;
  }
  cout<<cnt<<endl;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
 
	public static void main(String[] args) {
    	Scanner scan = new Scanner(System.in);
    	int n = scan.nextInt();
    	int[] multi = new int[60000];
    	
    	for(int x=1;x<100;x++) {
    		for(int y=1;y<100;y++) {
    			for(int z=1;z<100;z++) {
    				int t = (x*x+y*y+z*z+x*y+y*z+z*x); 
    					multi[t]++;
   						
    			}
    		}
    	}
    	for(int i=1;i<=n;i++) {
    		System.out.println(multi[i]);
    	}
   	}
     
}

Measured memory_bytes: 39156
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

#[allow(non_snake_case)]
fn main() {
    input! {
        A:usize,
        B:usize,
        H:usize,
        M:usize,
    }
    let at = (H as f64 + M as f64 / 60.0) / 12.0 * 2.0 * std::f64::consts::PI;
    let ax = (A as f64) * at.sin();
    let ay = (A as f64) * at.cos();
    let bt = M as f64 / 60.0 * 2.0 * std::f64::consts::PI;
    let bx = (B as f64) * bt.sin();
    let by = (B as f64) * bt.cos();
    let ans = ((ax - bx) * (ax - bx) + (ay - by) * (ay - by)).sqrt();
    println!("{}", ans);
}


Measured memory_bytes: 2868
package main

import (
	"fmt"
	"math"
)

func main(){
	var a float64
	var b, c int
	var save int
	fmt.Scanf("%g", &a)
	a_dash := int(a)
	b = int(math.Ceil(math.Sqrt(a)))
	for i:=b; i > 0 ; i--{
		if a_dash % i == 0 {
			c = a_dash / i
			save = c + i - 2
			break
		}
	}
	fmt.Print(save)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD=1e9+7;
int gcd(int a,int b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
int prime(int a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(int i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int pow(int x,int y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
int main(){
  int N,a;
  cin>>N;
  unordered_map<int,int> mp;
  vector<int> vec(N);
  vector<int> tf(1000001);
  for(int i=1;i<=1000000;i++){
    tf.at(i)=prime(i);
  }
  for(int h=0;h<N;h++){
    //間に合わなかったら素数判定結果を前処理で10^6まで計算しておけば計算量を10^7台まで落とせる
    cin>>a;
    vec.at(h)=a;
    int A=a;
    if(a==2){
      mp[2]=max(mp[2],1);
    }
    if(a==3){
      mp[3]=max(mp[3],1);
    }
    for(int i=2;i*i<=A;i++){
      if(tf.at(i)==1){
        int j=0;
        while(a%i==0){
          a/=i;
          j++;
        }
        mp[i]=max(mp[i],j);
      }
      if(a==1){break;}
    }
    if(a!=1){mp[a]=max(mp[a],1);}
  }
  int ans=0;
  unordered_map<int,int> mpcopy=mp;
  for(int i=0;i<N;i++){
    ll rock=1;
    int a=vec.at(i);
    int A=a;
    if(a==2){
      mp[2]=max(mp[2],1);
    }
    if(a==3){
      mp[3]=max(mp[3],1);
    }
    for(int i=2;i*i<=A;i++){
      if(tf.at(i)==1){
        while(a%i==0){
          a/=i;
          mp[i]--;
        }
      }
      if(a==1){break;}
    }
    if(a!=1){mp[a]--;}
    for(auto itr=mp.begin();itr!=mp.end();itr++){
      rock*=pow(itr->first,itr->second);
      rock%=MOD;
    }
    ans+=rock;
    ans%=MOD;
    mp=mpcopy;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 7840
#include"bits/stdc++.h"

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
	string s;
	cin >> s;
	int n = s.size();
	int res = 0;
	REP(i, n) {
		if (i % 2 == 0)res += (s[i] == '1' ? 0 : 1);
		else res += (s[i] == '1' ? 1 : 0);
	}
	cout << min(res, n - res) << endl;
	return 0;
}


Measured memory_bytes: 512