akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));

signed main(){
    const int INF = 1e9;
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    int h,n; cin >> h >> n;
    int dp[n+1][h+1];
    rep(i,n+1)rep(j,h+1) dp[i][j]=INF;
    dp[0][0]=0;
    
    rep(i,n){
        int a,b;
        cin >> a >> b;
        rep(j,h+1) dp[i+1][j]=dp[i][j];
        rep(j,h+1){
            int x=min(h,j+a);
            chmin(dp[i+1][x],dp[i+1][j]+b);
        }
    }
    cout << dp[n][h] << endl;
}




Measured memory_bytes: 42636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int[][] happy = new int[n][3];
            for (int i = 0; i < n; i++) {
                happy[i][0] = Integer.parseInt(in.next());
                happy[i][1] = Integer.parseInt(in.next());
                happy[i][2] = Integer.parseInt(in.next());
            }

            int[][] dp = new int[n + 1][3];

            // dp遷移式
            // i-1日目までで得られる幸福度の最大値
            // dp[i]=dp[i-1]+max(a[i],b[i],c[i])

            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < 3; ++j) {
                    for (int k = 0; k < 3; ++k) {
                        if (j == k) continue;
                        dp[i + 1][k] = Math.max(dp[i + 1][k], dp[i][j] + happy[i][k]);
                    }
                }
            }

            long ans = 0;
            for (int i = 0; i < 3; i++) {
                ans = Math.max(ans, dp[n][i]);
            }
            out.println(ans);

        }

    }
}



Measured memory_bytes: 67760
K=int(input())
List=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(List[K-1])

Measured memory_bytes: 2940
H, W = map(int, input().split())

lst =[['#'] * (W + 2)]
for _ in range(H):
    tmp = ['#'] + list(input()) + ['#']
    lst.append(tmp)

tmp = ['#'] * (W + 2)
lst.append(tmp)

for tmp in lst:
    print (*tmp, sep = '')

Measured memory_bytes: 4468
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    string S;
    cin >> S;
    int count = 0;
    vector<bool> C(N,false);
    int abcount = 0;
    for (int i = 0; i < N; i++)
    {
        if (S[i] == 'a' && count < A+B)
        {
            count++;
            C[i] = true;
        }
        else if(S[i] == 'b' && abcount < B && count < A+B){
            count++;
            abcount++;
            C[i] = true;
        }
    }
    for (int i = 0; i < N;i++)
    {
        if(C[i]){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 896
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        var s = Console.ReadLine();
        var t = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        //int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();

        var ans = "Yes";
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] != t[i])
            {
                ans = "No";
            }
        }

        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 25892
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>  //setprecision(桁)
using namespace std;
#define pb push_back
#define rep(i,n) for(int i = 0;i < n;i++)
#define INF 1e+9
#define ll long long int

struct edge {
    int to;
    double cost;
};

// <最短距離, 頂点の番号>
using P = pair<double, int>;

int V;
const int ci = 2e5+ 5;
vector<edge> G[ci];
double d[ci];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) { //cout << "On" << endl;
        P p = que.top();
        que.pop();
        int v = p.second; //cout << "v=" << v << endl;
        if (d[v] < p.first) continue;
        for (int i=0; i<G[v].size(); i++) {
            edge e = G[v][i]; //cout << "koo" << endl;
            if (d[e.to] > d[v] + e.cost) { //cout << e.cost << endl;
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main(){
    ll n; cin >> n;
    if(n == 1){cout << 0 << endl; return 0;}
    vector<ll> so;
    ll k;
    ll N = n;
    bool ok;
    for(ll i = 2; i*i <= n;i++){
        k = 0;
        ok = false;
        while(N % i == 0){
            N /= i;
            k++;
            ok = true;
        }
        if(ok) so.pb(k);
    }
  	if(N != 1) so.pb(1);
    ll ans = 0;
    if(so.size() == 0){cout << 1 << endl; return 0;}
    //rep(i,so.size()) cout << so[i] << endl;
    for(ll i = 0; i < so.size(); i++){
        for(ll j = 1; j < 100000;j++){
            if(j *(j+1) > 2 * so[i]) {
                ans += j - 1;
                break;
            }
        }
    }
  //cout << "------" << endl;
  //for(auto i : so) cout << i << endl;
    cout << ans << endl;
}


Measured memory_bytes: 8328
#include<cstdio>
#include<algorithm>
using namespace std;

const int MAXN=3e5+5;

int n;
pair<int,int> a[MAXN];

int main(){

    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i].first),a[i].second=i;
    sort(a+1,a+n+1);
    int cnt=0;
    for(int i=1;i<=n;i++)
        if((a[i].second&1)!=(i&1))
            cnt++;
    printf("%d",cnt/2);

    fclose(stdin);
    fclose(stdout);
}


Measured memory_bytes: 896
N = int(input())
H = list(map(int,input().split()))

L = [0] * N
L[0] = H[0]

count = 1
for i in range(1,N):
	L[i] = max(L[i-1],H[i])
	if L[i-1] <= H[i]:
		count += 1

print (count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using ll = long long;
using PAIR = pair<int, int>;
using Graph = vector<vector<int>>;
const ll INF = (1LL << 60);
const double pi=acos(-1.0);
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/**************************************/
/******** User-defined Function *******/

/**************************************/
/********** Main()  function **********/
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n,k; cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));

    int ng = -1;
    int ok = 1e9;

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        //答えをxとして全てのlogsはx以下にk回以内で切れるのか
        auto f = [&](int x){
            ll now = 0;
            rep(i,n){
                if(x==0){
                    return false;
                }
                now += (a[i]-1)/x;
            }
            //切れる場合はtrueを返す
            return now<=k;
        };
        if (f(mid)) ok = mid;
        else ng = mid;
    }

    cout << ok << endl;

    return 0;
}
/********  Main() Ends Here *************/


Measured memory_bytes: 4760
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
 #include <cmath>
using namespace std;


int main()
{	int a,b,c;
 cin>>a>>b>>c;
  int sum =0;
 sum = c - (a - b);
 if(sum<0){
  cout<<0;   
 }else{
 cout<<sum;
 }
}

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

int main(void) {
    int n, alice = 0, bob = 0;
    vector<int> cards;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        cards.push_back(a);
    }
    sort(cards.begin(), cards.end(), greater<int>());
    for (int i = 0; i < n; i++) {
        if (!(i % 2)) alice += cards[i];
        else bob += cards[i];
    }
    cout << alice - bob << endl;
}


Measured memory_bytes: 256
N,A,B = map(int,input().split());
lst = list(map(int,input().split()))

cost = 0
for i in range (1,N):
	if (lst[i]-lst[i-1])*A < B:
		cost+=((lst[i]-lst[i-1])*A)

	else:
		cost+=B 

print(cost)

Measured memory_bytes: 19944
import sys
# 再帰回数上弦を100000回に設定
sys.setrecursionlimit(100000)
# スタックサイズを無制限に設定
# resource.setrlimit(resource.RLIMIT_STACK, (-1, -1))

class UnionFind:
    """
    子ノードには自分の親ノードIDを記録。親ノードにはグループサイズの負値を記録。
    """

    def __init__(self, n):
        self.node = [-1] * n
    
    def unite(self, x, y):
        """
        xとyが属するグループを統合
        """
        # xとyの親ノードインデックスを取得
        _x, _y = self.find(x), self.find(y)
        # 一致していれば同じグループに属しているので処理終了。
        # Falseはなぞ。
        if _x == _y:
            return False
        # サイズが小さいグループを大きいグループに結合するので、
        # _y側の絶対値がかならず小さくなるように前処理。(_yを_xのグループへ統合)
        # 大きい方を小さい方へ結合してしまうとノードが深くなってしまうので、
        # 計算量を削減するためのテクニック。
        if abs(self.node[_x]) < abs(self.node[_y]):
             self.node[_x], self.node[_y] = self.node[_y], self.node[_x]
        # グループサイズ更新
        self.node[_x] += self.node[_y]
        # _yの親ノードを_xに更新
        self.node[_y] = _x
        return True

    def find(self, x):
        """
        xが属するグループの親ノードインデックスを検索。
        """
        _val = self.node[x]
        # 負なら親ノードとみなして、そのインデックスを返す。
        if _val < 0: 
            return x
        # グループの親ノードを再帰的に検索。
        # さらに、グループの親ノードIDを子ノードに記録しておくことで
        # 経路縮小を実現。
        self.node[x] = self.find(_val)
        return self.node[x]

    def same(self, x, y):
        """
        xとyが属するグループが同じかチェック。
        """
        return self.find(x) == self.find(y)

    def size(self, x):
        """
        xが属するグループの総サイズ取得
        """
        return abs(self.node[self.find(x)])
 
    def __str__(self):
        return str(self.node)

N, M, K = map(int, input().split())

uf = UnionFind(N)
friend = [0] * N
block = [[] for _ in range(N)]

for _ in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    uf.unite(a, b)
    friend[a], friend[b] = friend[a] + 1, friend[b] + 1

for _ in range(K):
    c, d = map(int, input().split())
    c, d = c - 1, d - 1
    block[c].append(d)
    block[d].append(c)

for i in range(N):
    ans = uf.size(i) - friend[i] - 1
    for j in block[i]:
        if uf.same(i, j):
            ans -= 1
    print("{} ".format(ans), end="")
print("")

Measured memory_bytes: 50096
#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;}

typedef long long ll;
typedef long double R;
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 main() {
  ll n, a, b; cin >> n >> a >> b;
  int ans = 1;
  if(n == 1 && a != b) cout << 0 << endl;
  else if(a > b) cout << 0 << endl;
  else {
    if(n - 2 < 0) cout << 1 << endl;
    else {
      cout << (b-a)*(n-2)+1 << endl;
    }
  }


  return 0;
}

Measured memory_bytes: 256
import java.util.*;

/**
 * Created by Santa.
 */
public class Main {

    static long N;
    static int M;
    static int A;
    static long B;
    static long C;
    //    static int[][] map;
    static int min = 9999999;


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        N = scanner.nextInt();

        M = scanner.nextInt();

        System.out.println((N - 1) * (M - 1));

    }
}



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

ll n, ans=1, dp;
vector<ll> p(201001);

int main(){
  
  cin >> n;
  rep(i,n) cin >> p.at(i);
  
  for (ll i = 1; i < n; i++){
    
    if (i == 1) dp = p.at(0);
    else dp = min (p.at(i-1), dp);
    
      if(dp > p.at(i)) ans++;
    }
  
  cout << ans << endl;
  
  }

Measured memory_bytes: 1792
#TENKA1-C
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n=I()
S=S()
B=[0]*n
W=[0]*n
for i in range(n):
    if S[i]=="#":
        B[i]=1
    else:
        W[i]=1
for i in range(n-1):
    B[i+1]+=B[i]
    W[i+1]+=W[i]
B=[0]+B
W=[0]+W
ans=2*n
for i in range(n):
    tans=B[i+1]-B[0]+W[-1]-W[i+1]
    ans=min(ans,tans)
if B[-1]==n:
    ans=0
ans=min(W[-1],ans)
print(ans)

Measured memory_bytes: 22052
N,K = list(map(int,(input()).split()))
kubaru =[]
for n,k in enumerate(range(K)):
#  print(n,k)
  if n+1 != K:
    kubaru.append(1)
    N-=1
  else:
    kubaru.append(N)

print(max(kubaru)-min(kubaru))    


Measured memory_bytes: 2940
n = int(input())
a = list(map(int,input().split()))
t = [0]*(10**5+1)
s = 0
for i in range(n):
    t[a[i]] += 1
    s += a[i]
q = int(input())
for j in range(q):
    b,c = map(int,input().split())
    s += (c-b)*t[b]
    t[c] += t[b]
    t[b] *= 0
    print(s)

Measured memory_bytes: 84300
package main
 
import (
    "bufio"
    "bytes"
    "fmt"
    "io"
    "os"
    "strconv"
    "strings"
)
 
// M is large primary number
const M = 1046527
 
func main() {
    fmt.Println(answer(os.Stdin))
}
 
func answer(r io.Reader) string {
    H := make([]string, M)
    sc := bufio.NewScanner(r)
    sc.Scan()
    n, _ := strconv.Atoi(sc.Text())
 
    buf := bytes.Buffer{}
    for i := 0; i < n; i++ {
        sc.Scan()
        ss := strings.Fields(sc.Text())
        switch ss[0] {
        case "insert":
            insert(H, ss[1])
        case "find":
            if find(H, ss[1]) {
                buf.WriteString("yes\n")
            } else {
                buf.WriteString("no\n")
            }
        }
    }
    return strings.TrimRight(buf.String(), "\n")
}
 
func atoi(char byte) int {
    switch char {
    case 'A':
        return 1
    case 'C':
        return 2
    case 'G':
        return 3
    case 'T':
        return 4
    default:
        return 0
    }
}
 
func getKey(str string) int {
    sum, p := 0, 1
    for i := 0; i < len(str); i++ {
        sum += p * atoi(str[i])
        p *= 5
    }
    return sum
}
 
func h1(key int) int {
    return key % M
}
 
func h2(key int) int {
    return 1 + key%(M-1)
}
 
func find(H []string, str string) bool {
    key := getKey(str)
    h := 0
    for i := 0; ; i++ {
        h = (h1(key) + i*h2(key)) % M
        if H[h] == str {
            return true
        } else if len(H[h]) == 0 {
            return false
        }
    }
}
 
func insert(H []string, str string) []string {
    key := getKey(str)
    for i := 0; ; i++ {
        h := (h1(key) + i*h2(key)) % M
        if H[h] == str {
            return H
        } else if len(H[h]) == 0 {
            H[h] = str
            return H
        }
    }
}


Measured memory_bytes: 46192
n = gets.to_i
d = gets.split.map(&:to_i)
mount = Array.new(n, 0)
m1 = 0
d.each_with_index do |w, i|
  if i.even?
    m1 += w
  else
    m1 -= w
  end
end
mount[0] = m1
(n - 1).downto(1) do |i|
  mount[i] = if i == n - 1
               (d[i] - mount[0]/2)*2
             else
               (d[i] - mount[i + 1]/2)*2
             end
end

puts mount.join(' ')

Measured memory_bytes: 14084
rs = []
bs = []
24.times.map { p, t = gets.split; [t.to_f, p.to_i] }.each_slice(8).map(&:sort).each {|as| rs += as[0...2]; bs += as[2..-1] }
bs.sort!
rs += bs[0...2]
rs.each {|t, p| puts '%d %.2f' % [p, t] }

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

int cur=0;
int a=0;
int dp[100009];

int dfs(int u, vector<int> adj[]){
	if(dp[u] != -1)
		return dp[u];
		
	int cur=0;
	
	for(auto v : adj[u]){
		cur = max (cur, dfs(v, adj)+1);
	}
	
	return dp[u]=cur;
}

void solve(){
	int n, m;
	cin >> n >> m;
	vector<int> adj[n+1];
	int x, y;	
	while(m--) {
		cin >> x >> y;
		adj[x].push_back(y);		
	}
	int ans=0;
	memset(dp, -1, sizeof dp);
	
	for(int i=1; i<=n; i++){
		ans=max(ans, dfs(i, adj));
	}
	
	cout << ans << "\n";
}

int main(){
	solve();
}


Measured memory_bytes: 11396
#!/usr/bin/env python3.4
# -*- coding: utf-8 -*-
# abc042_a

# input
arr = input().split()
arr = map(int, arr)
haiku = [5, 7, 5]
# getans
for a in arr:
	if a in haiku:
		haiku.remove(a)
ans = 'YES' if not haiku else 'NO'
# output
print(ans)


Measured memory_bytes: 2940
m,d= map(int, input().split())

ans=0
for mon in range(1,m+1):
    for day in range(1,d+1):
        if day<22:
            continue
        d1,d2=str(day)
        d1,d2=int(d1),int(d2)
        if d1<2 or d2<2:
            continue
        if d1*d2==mon:
            ans+=1

print(ans)

Measured memory_bytes: 69712
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
    string s;
    cin >> s;
    s[3] = '8';
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <atcoder/dsu>

namespace ac = atcoder;

void solve() {
    int n, q;
    std::cin >> n >> q;

    ac::dsu dsu(n);
    while (q--) {
        int t, u, v;
        std::cin >> t >> u >> v;

        switch (t) {
            case 0:
                dsu.merge(u, v);
                break;
            case 1:
                std::cout << dsu.same(u, v) << "\n";
                break;
        }
    }
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3968
n = int(input())
a = list(int(x) for x in input().split())

flag = 1
cnt = 0

while flag == 1:
    for i in range(n):
        if a[i] % 2 == 0:
            a[i] = int(a[i]/2)
        else:
            flag = 0
            break
    cnt += 1

print(cnt-1)

Measured memory_bytes: 3060
N=int(input())
List=[input() for i in range(N)]
a=0
b=0
c=0
d=0
for i in range(0,N):
    if List[i]=="AC":
        a+=1
    elif List[i]=="WA":
        b+=1
    elif List[i]=="TLE":
        c+=1
    else:
        d+=1
print("AC"+" x "+str(a))
print("WA"+" x "+str(b))
print("TLE"+" x "+str(c))
print("RE"+" x "+str(d))

Measured memory_bytes: 16324
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 3e6 + 6;
const int MOD = 1e9 + 7;
int fat[MAX];

inline int add(int a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
    return a;
}

inline int sub(int a, int b) {
    a -= b;
    if (0 > a) a += MOD;
    return a;
}

inline int mult(int a, int b) {
    return (1LL * a * b) % MOD;
}

int f_exp(int x, int e) {
    if (e <= 0) return 1;
    if (e & 1) return mult(x, f_exp(x, e - 1));
    return f_exp(mult(x, x), e / 2);
}

inline int inv(int x) {
    return f_exp(x, MOD - 2);
}

inline int comb(int n, int k) {
    if (k > n) return 0;
    return mult(fat[n], mult(inv(fat[n - k]), inv(fat[k])));
}

void preprocess() {
    fat[0] = 1;
    fori (i, 1, MAX) {
        fat[i] = mult(fat[i - 1], i);
    }
}

void solve() {
    preprocess();
    int k;
    cin >> k;
    string s;
    cin >> s;
    int n = s.size();
    int t = n + k;
    int ans = 0;
    fori (i, n, t + 1) {
        int b = i - 1;
        int c = comb(b, n - 1);
        int f = t - i;
        int p = mult(f_exp(26, f), f_exp(25, t - f - n));
        ans = add(ans, mult(c, p));
    }
    cout << ans << endl;
}

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



Measured memory_bytes: 15976
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define sz(x) ((int) x.size())
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;


int main() {sws;

    int n;
    cin >> n;
    vi h(n);

    fo(i, n) cin >> h[i];

    vi dp(n);

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

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

    cout << dp.back() << endl;

    return 0;
}

Measured memory_bytes: 3964
k,a,b=map(int,input().split())
if a>=b-2 or a>=k+1:
    print(k+1);exit()
#とりあえずビスケットをA枚まで増やす
bis=a
t=k-(a-1)#残り行動可能回数
#2回行動することによりビスケットはB-A枚増える
bis+=(t//2)*(b-a)
t-=(t//2)*2
#行動回数が1回残っていれば最後にビスケットを1枚増やす
bis+=t
print(bis)

Measured memory_bytes: 3060
fun main(args: Array<String>) {
    val X = readLine()!!.toInt()

    val l = mutableListOf(1)
    for (p in 1 until 33) for (q in 2 until 10) {
        val d = Math.pow(p.toDouble(), q.toDouble()).toInt()
        if (d <= X) l.add(d)
    }

    println(l.distinct().sorted().reversed().first())
}


Measured memory_bytes: 36252
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) (int)((a).size())
typedef long long ll;
typedef pair<int,int> PI;

int main(int argc, char *argv[])
{
  string ex;
  cin >> ex;
  int m;
  cin >> m;
  int n = ex.size();

  ll nor = 0;
  ll gre = ex[0] - '0';

  for(int i = 1; i <n;++i){
    char op = ex[i];
    ++i;
    if(op=='*') gre *= ex[i]-'0';
    else gre += ex[i] - '0';
  }

  for(int i = 0; i < n; ++i){
    ll nu = ex[i] - '0';
    while(i+1 < n && ex[i+1] == '*'){
      i+=2;
      nu *= ex[i] - '0';
    }
    nor += nu;
    ++i;
  }

  if(nor == gre && nor==m) cout << 'U' << endl;
  if(nor ==m && gre != m) cout << 'M' << endl;
  if(nor !=m && gre == m) cout << 'L' << endl;
  if(nor !=m && gre != m) cout << 'I' << endl;  
  //cout << nor << " " << gre << endl;
  
  
  return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
#define pb           push_back
#define pf           push_front
#define in           insert
#define ff           first
#define ss           second
#define int          long long
#define rep(i,x,m)   for(int i=x;i<m;i++)
#define MOD          1000000007
#define endl         "\n"
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define vi           vector<int>
#define pi           pair<int,int>
#define sz(x)       (int)x.size()
#define pq           priority_queue<int>
#define fix(y)       fixed<<setprecision(y)
#define print(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
#define FIO         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}
vi v;
int ok=0;
map<int,int>m1;
 void primeFactors(int n)  
{  
    // Print the number of 2s that divide n  
  set<int>s;
    while (n % 2 == 0)  
    {  
        s.in(2);
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i *i<= n; i = i + 2)  
    {  
         
        while (n % i == 0)  
        {  
            s.in(i);
            n = n/i;  
        }  
    }  
  
     
    if (n > 2)  
        s.in(n);
      for(auto x:s)
      {
        m1[x]++;
        if(m1[x]>=2)
        {
          ok=1;
        }
      }

}  
void solve()
{
     int n;
     cin>>n;
     int a[n];
     rep(i,0,n)
     cin>>a[i];
     sort(a,a+n);
    rep(i,0,n)
    {
      primeFactors(a[i]);
      if(ok)
        break;
    }
    if(ok==0)
    {
      cout<<"pairwise coprime";return;
    }
    int g;
    rep(i,0,n)
    {
      if(i==0)
      {
        g=a[i];continue;
      }
      g=__gcd(g,a[i]);
    }
    if(g==1)
    {
      cout<<"setwise coprime";return;
    }
    cout<<"not coprime";



}

signed main()
{
        FIO
          
        
        int t=1;
        //cin>>t;
        
        while(t--)
        solve();
        cerr<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;

        return 0;
}

Measured memory_bytes: 11556
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (N, M) = read!(usize, usize);
    let mut g = vec![vec![]; N];

    for ei in 0..M {
        let (a, b, c) = read!(usize, usize, i64);
        let (a, b) = (a - 1, b - 1);
        g[a].push((b, c, ei));
        g[b].push((a, c, ei));
    }

    let mut retain = vec![false; M];

    for u in 0..N {
        let mut q = BinaryHeap::new();
        const INF: i64 = 1 << 60;

        let mut dist = vec![INF; N];
        dist[u] = 0;
        q.push((u, 0));

        while let Some((u, d)) = q.pop() {
            for &(v, c, _) in &g[u] {
                let d = d + c;
                if dist[v] > d {
                    dist[v] = d;
                    q.push((v, d));
                }
            }
        }

        for v in 0..N {
            if v == u {
                continue;
            }

            for &(w, c, ei) in &g[v] {
                if dist[w] + c == dist[v] {
                    // 少なくとも1つの最短経路に含まれているので削除しない。
                    retain[ei] = true;
                }
            }
        }
    }

    let count = M - (0..M).filter(|&i| retain[i]).count();

    println!("{}", count)
}


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

#define ll long long
#define tc                int T;cin>>T;while(T--)
const int INF =1e9+5;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n, c, b ; cin >> n;
  	vector<int> a(n);
	for (int& e : a)cin >> e;
	vector<int> dp(n, INF);
	dp[0] = 0;
	for (int i = 0; i < n; ++i) {
		for (int e : {i + 1, i + 2}) {
			if (e < n)
					dp[e] = min(dp[e],dp[i] + abs(a[e] - a[i]));
		}
	}
	cout << dp[n - 1] << '\n';
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int x;
  vector<int>a;
  for(int i=0;i<10;i++){
    cin>>x;
    a.push_back(x);
  }
  sort(a.begin(),a.end()); 
  cout<<a[9]<<endl;
  cout<<a[8]<<endl;
  cout<<a[7]<<endl;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define f(i,a,b) for(int i=a;i<=b;++i)
using namespace std;
int M=998244353,N,K,a,s[303],d[303][303][303]={1};
int main(){
    string S;cin>>S>>K;K=min((int)S.size(),K);
    for(auto c:S)c=='0'?++N:++s[N];
    f(i,0,N) f(j,0,K) f(k,0,j) f(l,-min(k,s[i]),K-j) (d[i+1][j+max(l,0)][k+l]+=d[i][j][k])%=M;
    f(i,0,K) (a+=d[N+1][i][0])%=M;
    cout<<a;
}

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

using namespace std;
vector <int> a , b , c;


int main(){
	int N , A , B , C;
	cin>>N;
	for (int i=0;i<N;i++)
	{
		cin>>A>>B>>C;
		a.push_back(A);
		b.push_back(B);
		c.push_back(C);
	}
	
	for (int i=1;i<N;i++)
	{
		a[i]+=max(c[i-1],b[i-1]);
		b[i]+=max(c[i-1],a[i-1]);
		c[i]+=max(b[i-1],a[i-1]);
	}
	
	cout<<max(a[N-1],max(b[N-1],c[N-1]));
	
	return 0;
}


Measured memory_bytes: 1644
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  double N; cin >> N;
  vector<double> v(N);
  rep(i,N) cin >> v[i];
  double heikin=0;
  rep(i,N) heikin+=v[i]/N;
  vector<double> res(N);
  rep(i,N) res[i]=abs(v[i]-heikin);
  int ans=0;
  double cnt=INF;
  rep(i,N){
    if(res[i]<cnt){
      cnt=res[i];
      ans=i;
    }
  }
  cout << ans << endl;

  
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll INM = 114514;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
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; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	bool ok  = false;
	bool tmp = true;
	for (int i = 1; i < n; i++) {
		if (a[i] < a[i - 1]) tmp = false;
	}
	if (tmp) {
		dump("YES");
		return 0;
	}
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			vector<ll> tmp = a;
			swap(tmp[i], tmp[j]);
			bool c = true;
			for (int i = 1; i < n; i++) {
				if (tmp[i] < tmp[i - 1]) c = false;
			}
			ok |= c;
		}
	}
	dump(ok ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 256
/*input
13
ABCDEFGHIJKLMNOPQRSTUVWXYZ
*/
#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;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long ll;
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=100000000;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b,ll MOD){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int main(){
    int n;
    string a;
    cin>>n>>a;
    REP(i,a.length()){
        int cur=a[i]-'A';
        cur+=n;
        cur%=26;
        cout<<char('A'+cur);
    }
}

Measured memory_bytes: 256
# Aizu Problem 0065: Trading
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


first = {}
while True:
    inp = input().strip()
    if len(inp) == 0:
        break
    no, day = [int(_) for _ in inp.split(',')]
    first[no] = first.get(no, 0) + 1

both = {}
while True:
    try:
        no, day = [int(_) for _ in input().split(',')]
    except EOFError:
        break
    if no in both:
        both[no] += 1
    elif no in first:
        both[no] = first[no] + 1

for no in sorted(both.keys()):
    print(no, both[no])

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

int main() {
  int n;
  while (cin >> n, n) {
    vector<int> a(n);
    int sum = 0;
    REP(i,n) cin >> a[i], sum += a[i];
    int ans = 0;
    REP(i,n) ans += (a[i] * n <= sum);
    cout << ans << endl;
  }
}


Measured memory_bytes: 3088
# -*- coding: utf-8 -*-
import sys

#tmp= int(input())
tmp = input().split()
W,H,x,y,r = list(map(lambda a: int(a), tmp))


if(x<r):
    print("No")
    sys.exit()
if(x>W-r):
    print("No")
    sys.exit()
if(y<r):
    print("No")
    sys.exit()
if(y>H-r):
    print("No")
    sys.exit()
print("Yes")



Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll l, r;
    cin >> l >> r;
    ll md = 2019;

    ll a = l % md, b = r % md;

    ll ans = INF;
    if (r - l >= md-1) ans = 0;
    else if (a >= b) ans = 0;
    else {
        rep(i, a, b+1) rep(j, a, b+1) {
            if (i >= j) continue;
            chmin(ans, i*j % md);
        }
    }
    cout << ans << endl;
}

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

std::vector <int> a;

int main () {
  int n; std::cin >> n;
  a.resize (n);
  for (int i = 0; i < n; ++i)
    std::cin >> a[i];
  int sum = 0;
  for (int i = 0; i < n; ++i)
    sum = sum + a[i];
  sum = round (1.0 * sum / n);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    ans = ans + (a[i] - sum) * (a[i] - sum);
  }
  std::cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
// #Sazaの1日1AC
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;
const long long INF=9e18;
const double PI=3.14159265358979323846;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vP=vector<pair<long long, long long>>;
//ショートカット
#define rep(i,n) for(long long i = 0; i < n; i++)
#define rep2(i,k,n) for(long long i = k; i < n; i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mkp make_pair
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define chin(x) char x;cin>>x;
#define sin(s) string s;cin>>s;
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

#define max(a,b) max((ll)a,(ll)b)
#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//繰り返し二乗法
long long repeat_squaring(long long x, long long n){
  if(n==0) return 1;
  else if(n%2==0){
    long long t=repeat_squaring(x,n/2);
    return t*t%mod;
  }
  else
    return x*repeat_squaring(x,n-1);
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//構造体

//Union-Find木
struct UnionFind{
  //メンバ変数 
  vector<long long>par; //par[i]:=頂点iの親
  vector<long long>s; //s[i]:=頂点iが属する集合の個数(iが根のとき)
  
  //コンストラクタ
  UnionFind(long long N):par(N),s(N){
    for(long long i=0;i<N;i++){
      par[i]=i; //最初はすべてが根として初期化
      s[i]=1;
    }
  }
  //メンバ関数
  //root(i):=頂点iの根
  long long root(long long i){
    if(par[i]==i) return i;
    par[i]=root(par[i]); //経路圧縮
    return root(par[i]); //再帰
  }
  //size[i]:=iが属する集合の個数
  long long size(long long i){
    return s[root(i)];
  }
  //same(x,y) xとyが同じ根を持つか(同じ集合に含まれるか)
  bool same(long long x, long long y){
    return root(x)==root(y);
  }
  //unite(x,y) xの根をyの根に繋げる(集合を合併)
  void unite(long long x, long long y){
    if(!same(x,y)){
      long long rx=root(x);
      long long ry=root(y);
      par[rx]=par[ry];
      s[ry]=s[rx]+s[ry];
    }
  }
};

/////////////////⊂('ω'⊂ )))Σ≡GO!/////////////////
int dp[3005][3005][5];

//メイン関数
int main(){
  //doubleの桁数
  
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  ll res = - INF;

  res = max(res, a * c);
  res = max(res, a * d);
  res = max(res, b * c);
  res = max(res, b * d);
  cout << res << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <iomanip>
#include <bits/stdc++.h>
#include <fstream>
#include <map>
using namespace std;
typedef long long ll;
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
  int n,x;
  ll ans=0;
  cin >> n;
  rep(i,n){
    cin >> x;
    ans += x-1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
use std::io;
use std::cmp;

fn main() {
    let mut abc = String::new();
    io::stdin().read_line(&mut abc).unwrap();
    let mut abc = abc.split_whitespace();
    let a: u32 = abc.next().unwrap().parse().unwrap();
    let b: u32 = abc.next().unwrap().parse().unwrap();
    let c: u32 = abc.next().unwrap().parse().unwrap();

    if a == b && b == c {
        println!("0");
    } else {
        let max = cmp::max(cmp::max(a, b), c);
        let tri_max = max * 3;
        let sum = a + b + c;

        let diff = tri_max - sum;
        let times = if diff % 2 == 0 { diff / 2 } else { (diff + 3) / 2 };
        println!("{}", times);
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  int ans = n / 2;
  if(n % 2 == 1) ans++;
  cout << ans << endl;
  return 0;
}

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

using namespace std;

using ll = long long;
const int MOD = 2019;

ll counts[MOD];
ll ncounts[MOD];

int main() {
    string S;
    cin >> S;
    ll ans = 0;
    ll curr = 0;
    counts[0] = 1;
    for (char c : S) {
        curr = curr * 10 + c - '0';
        ans += counts[curr % MOD];
        counts[curr % MOD]++;
        for (int i = 0; i < MOD; i++) {
            ncounts[i * 10 % 2019] = counts[i];
        }
        memcpy(counts, ncounts, sizeof(counts));
        curr %= MOD;
    }
    cout << ans << endl;
}


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

char s[100005];

int alphabet[26];
char alphabet2[55];

int main() {

	int K;

	scanf("%s",s);
	scanf("%d",&K);

	int len = strlen(s);

	int i;

	for (i = 25; i >= 0; i--) {
		alphabet[i] = 26 - i;
	}

	for (i = 0; i < len; i++) {
		if (s[i] == 'a') { continue; }
		if (alphabet[s[i] - 'a'] <= K) { K -= alphabet[s[i] - 'a']; s[i] = 'a'; }
	}
	if (K > 0) {
		for (i = 0; i < 26; i++) {
			alphabet2[i] = 'a' + i;
		}
		for (i = 26; i < 52; i++) {
			alphabet2[i] = 'a' + i;
		}

		s[len - 1] = alphabet2[(s[len - 1] - 'a') + (K % 26)];
	}
	printf("%s\n",s);
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
import java.awt.image.BandedSampleModel;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {


    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        String t=sc.next();
        int ans=0;
        for(int i=0;i<s.length();i++)
        {
            if(!(s.charAt(i)+"").equals(t.charAt(i)+""))
            {
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 56412
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    int cnt = 0;

    String pat = scan.next();

    while (true) {

      String str = scan.next();

      if (str.equals("END_OF_TEXT")) {
        break;
      }

      if (str.equalsIgnoreCase(pat)) {
        cnt++;
      }

    }

    System.out.println(cnt);

  }

}


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

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<string> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int ans = 1;
  for (int i = 0; i < n; ++i) {
    queue<int> q;
    q.push(i);
    vector<int> vis(n);
    vis[i] = 1;
    int k = 1;
    while (!q.empty()) {
      int cur = q.front();
      q.pop();
      k = vis[cur];
      for (int j = 0; j < n; ++j) {
        if (a[cur][j] - '0') {
          if (!vis[j]) {
            vis[j] = vis[cur] + 1;
            q.push(j);
          } else if (j != cur && vis[j] % 2 == vis[cur] % 2) {
            cout << -1 << endl;
            return 0;
          }
        }
      }
    }
    ans = max(ans, k);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string.h>

int main()
{
    int N, H[20];
    scanf("%d", &N);
    for (int i = 0; i < N; ++i) scanf("%d", &H[i]);
    int ans = 1;
    int highest = H[0];
    for (int i = 1; i < N; ++i)
    {
        if (H[i] >= highest)
        {
            ++ans;
            highest = H[i];
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);

  string s; cin >> s;
  int n = SZ(s);
  bool ok = true;
  for(int i=0;i<n/2;++i) {
    ok &= s[i] == s[n-i-1];
  }
  for(int i=0;i<n/2/2;++i) {
    ok &= s[i] == s[n/2-i-1];
  }
  cout << (ok ? "Yes" : "No") << endl;

}


Measured memory_bytes: 256
X = list(map(int,list(input())))

for i in range(2**3+1):
  ans =[X[0]]
  for j in range(3):
    d = X[j+1]*(-1)**((i >>j)&1)
    ans.append(d)
  if sum(ans) == 7:
    for i,a in enumerate(ans):
      if a>=0 and i>0:
        print("+",end="")
      print(a,end="")
    print("=7")
    exit()

Measured memory_bytes: 9060