akhauriyash/Code-Regression huggingface dataset:
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

n, p = map(int,input().split())
A = list(map(int,input().split()))

odd = 0
for a in A:
    if a%2:
        odd += 1

all_c = 0
for i in range(n+1):
    all_c += cmb(n, i)

odd_c = 0
for i in range(-(-odd//2)):
    #print(odd,"C",2*i+1)
    odd_c += cmb(odd, 2*i+1)
#print("奇数個の組", odd_c)

even_c = 0
for i in range(n-odd+1):
    even_c += cmb(n-odd, i)

if p == 1:
    print(odd_c*even_c)
else:
    print(all_c - odd_c*even_c)

Measured memory_bytes: 9268
fn input_one<T: std::str::FromStr> () -> Result<T, T::Err> {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).unwrap();
    n.trim().parse()
}

fn main() {
    let a = input_one().unwrap();
    let b = input_one().unwrap();
    println!("{}", match (a, b) {
        (1, 2) | (2, 1) => 3,
        (1, 3) | (3, 1) => 2,
        (2, 3) | (3, 2) => 1,
        _ => panic!(),
    });
}


Measured memory_bytes: 2036
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define mod 1000000007
#define pll pair<long long,long long>
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
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;
        
}
//find_by_order() ->  iterator to the k-th largest element (counting from zero)
//order_of_key() ->    the number  items in a set that are strictly smaller than our item aka index in set
int dp[2000];
int fun(int i,int n){
	if(i>n)return 0;
	if(i==n)return 1;
	if(dp[i]!=-1)return dp[i];
	int ans=0;
	for(int j=3;j<=2000;j++){
	    ans+=(fun(i+j,n)%mod);
	}
	return dp[i]=(ans%mod);
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    cout<<fun(0ll,n);
    return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n; cin>>n;
	int p=n%10;
	if(p==0||p==1||p==6||p==8) cout<<"pon";
	else if(p==3) cout<<"bon";
	else cout<<"hon";
	return 0;
}

Measured memory_bytes: 3632
"use strict";
function main(input) {
    const S = input.replace("\n", "");
    const W = ["Sunny", "Cloudy", "Rainy"];
    console.log(W[(W.indexOf(S) + 1) % 3]);
    return;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29444
import sys

def f(N, X, a, p):
  if N == 0:
    return 0 if X <= 0 else 1
  elif X <= 1 + a[N-1]:
    return f(N-1, X-1, a, p)
  else:
    return p[N-1] + 1 + f(N-1, X-2-a[N-1], a, p)

def main():
  input = sys.stdin.readline
  N, X = map(int, input().split())
  a, p = [1], [1]
  for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

  ans = f(N, X, a, p)
  print(ans)


if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
#include<stdio.h>

static const int MAX = 500;
static const int INFTY = (1<<21);

int main(){
  int n,i,j,e,total=0;
  int M[MAX][MAX];
  int u,v;
  int minv;
  int d[MAX];
  int p[MAX];
  int vis[MAX];

  scanf("%d", &n);

  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }

  for ( i = 0; i < n; i++ ) {
    d[i] = INFTY;
    p[i] = -1;
    vis[i] = 0;
  }

  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for ( i = 0; i < n; i++ ){
      if ( minv > d[i] && !vis[i] ){
        u = i;
        minv = d[i];
      }
    }
    if ( u == -1 ) break;
    vis[u] = 1;
    for ( v = 0; v < n; v++ ){
      if ( !vis[v] && M[u][v] != INFTY ){
        if ( d[v] > M[u][v] ){
          d[v] =  M[u][v];
          p[v] = u;
        }
      }
    }
  }

  total = 0;

  for ( i = 0; i < n; i++ ){
    if ( p[i] != -1 ) total += M[i][p[i]];
  }

  printf("%d\n",total);

  return 0;
}


Measured memory_bytes: 2112
// AGC021
// B - Holes

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 100;
constexpr double PI = atan(1) * 4;

int N;
pii xy[MAX_N];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> xy[i].first >> xy[i].second;
    }

    for (int i = 0; i < N; i++) {
        vector<double> slopes;
        for (int j = 0; j < N; j++) {
            if (i == j) {
                continue;
            }
            int dx = xy[j].first - xy[i].first;
            int dy = xy[j].second - xy[i].second;
            slopes.push_back(atan2(dy, dx));
        }
        sort(slopes.begin(), slopes.end());
        slopes.push_back(slopes[0] + 2 * PI);

        double ans = 0.0;
        for (int i = 0; i < N; i++) {
            if (slopes[i + 1] - slopes[i] >= PI) {
                ans = (slopes[i + 1] - slopes[i] - PI) / (2 * PI);
                break;
            }
        }
        cout << fixed << setprecision(8) << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 384
import sys, copy
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    n = I()
    A = []
    for _ in range(n):
        SN = LSS()
        A.append((SN[0], int(SN[1])))

    A_org = copy.deepcopy(A)

    def partition(A, p, r):
        x = A[r][1]
        i = p-1
        for j in range(p, r):
            if A[j][1]<=x:
                i += 1
                A[i], A[j] = A[j], A[i]
        A[i+1], A[r] = A[r], A[i+1]
        return i+1

    def quickSort(A, p, r):
        if p<r:
            q = partition(A, p, r)
            quickSort(A, p, q-1)
            quickSort(A, q+1, r)

    def is_stable(A, A_org):
        # 数字をkey、スート列をvalueに持つ辞書を使って比較

        d_A = {}
        for i in A:
            if i[1] in d_A:
                d_A[i[1]].append(i[0])
            else:
                d_A[i[1]] = [i[0]]
        d_A_org = {}
        for i in A_org:
            if i[1] in d_A_org:
                d_A_org[i[1]].append(i[0])
            else:
                d_A_org[i[1]] = [i[0]]

        if d_A == d_A_org:
            return 'Stable'
        else:
            return 'Not stable'

    quickSort(A, 0, n-1)
    print(is_stable(A, A_org))
    for s, n in A:
        print(s, n)

if __name__ == '__main__':
    resolve()



Measured memory_bytes: 25456
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <cstdio>
using namespace std;

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
/* ここからが本編 */
/* */
/* 入力開始！ */
/* 入力終了！ */
int main(void)
{
   int n;
   double a,b,c,d,e,f;
   double x,y;
   while(cin >> a) {
      cin >> b >> c >> d >> e >> f;
      y = (a*f-d*c)/(a*e-b*d);
      x = (c - b*y)/a;
      printf("%.3f %.3f\n",x,y);
   }

   return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, d; cin >> n >> d;
	vector<vector<int> > a;
	for(int i = 0; i < n; i++){
		vector<int> r(d);
		for(int j = 0; j < d; j++) cin >> r[j];
		a.push_back(r);
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){
			int sum = 0;
			for(int k = 0; k < d; k++) sum += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
			int sq = sqrt(sum);
			if(sq * sq == sum) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
x = gets.chomp.to_i

as = (0..a).map { |n| n * 500 }.select { |n| n <= x }
bs = (0..b).map { |n| n * 100 }.select { |n| n <= x }
cs = (0..c).map { |n| n * 50 }.select { |n| n <= x }

all_comb = as.product(bs).product(cs).map(&:flatten)
print "#{all_comb.count { |arr| arr.reduce(:+) == x }}\n"

Measured memory_bytes: 29308
#include <cstdio>
#include <cstring>
#define MAXN 200010

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

int calc(){
	int last=1;
	a[n+1]=a[n];
	for(int i=2;i<=n+1;i++)
		if(a[i]==a[i-1]){
			if(a[last]==a[i]){
				for(int j=last+1;j<i-1;j++)
					a[j]=a[i];
			}else{
				for(int j=last+1;j<i-1;j++)
					if(j-last<i-1-j) 
						a[j]=a[last];
					else 
						a[j]=a[i];
			}
			last=i;
		}
	return a[(n+1)/2];
}

int main(){
	scanf("%d",&n);
	n=n*2-1;
	for(int i=1;i<=n;i++)
		scanf("%d",b+i);
	int l=1,r=n;
	while(l<r){
		int mid=(l+r)>>1;
		for(int i=1;i<=n;i++)
			a[i]=(b[i]<=mid?1:0);
		if(calc()==1) r=mid;
		else l=mid+1;
	}
	printf("%d\n",l);
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main()
 {
  int a;
  int b=1;
  while(1)
  {
   cin>>a;
   if(a==0)break;
   else 
   {
    cout<<"Case "<<b<<": "<<a<<endl;;
    b++;
   }
  }
 }



//Case 1: 3


Measured memory_bytes: 3136
fun main(args:Array<String>) {
    val key = "keyence"
    val target = readLine()!!
    if(key == target) {
        println("YES")
        return
    }
    for(i in (0 until target.length - 1)) {
        for(j in (i + 1 until target.length)) {
            val str1 = target.substring(0..i)
            val str2 = target.substring(j)
            if(str1 + str2 == key) {
                println("YES")
                return
            }
        }
    }
    println("NO")
}


Measured memory_bytes: 35700
n = int(input())
s = input()
x, y, a = 0, 0, 0

for char in s:
    if char == '(': x += 1
    else: y += 1
    a = min(a, x-y)
    b = x-y

ans = '('*(-a) + s + ')'*(b-a)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
 
int main() {
  	int c5 = 0, c7 = 0;
  
  	int a;
  
  	for (int i = 0; i < 3; i++) {
        cin >> a;

        if (a == 5) {
            c5++;
        } else if (a == 7) {
            c7++;
        }
    }
 
  	if (c5 == 2 && c7 == 1) {
      	cout << "YES" << endl;
    } else {
      	cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

string s;
int main()
{
	cin >> s;
	if (s[0] == s[1] && s[1] == s[2]) cout << "Yes" << endl;
	else if (s[1] == s[2] && s[2] == s[3])cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int m = sc.nextInt();
			if(m == 0) break;
			int[] a = new int[m+1];
			int[] b = new int[m+1];
			for(int i=1;i<=m;i++) {
				a[i] = sc.nextInt();
				b[i] = sc.nextInt();
			}
			int g = sc.nextInt();
			int[] n = new int[g];
			for(int i=0;i<g;i++) {
				n[i] = sc.nextInt();
			}
			int[][] dp = new int[m+1][1001];  // dp[i][j] = i以下の整数を用いてjを作るときの組み合わせ数
			dp[0][0] = 1;
			for(int i=1;i<=m;i++) {
				for(int j=0;j<=1000;j++) {
					for(int k=0;k<=b[i];k++) {
						if(j - k*a[i] < 0) break;
						dp[i][j] += dp[i-1][j - k*a[i]];
					}
				}
			}
			for(int i=0;i<g;i++) {
				System.out.println(dp[m][n[i]]);
			}
		}
	}
}
		



Measured memory_bytes: 27612
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  vector<int> vec(3);
  cin>>vec[0]>>vec[1]>>vec[2];

  sort(vec.begin(),vec.end());
  
  if(vec[0]==vec[1]&&vec[1]==5&&vec[2]==7){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 3516
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << endl;
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << endl;
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  ll A_max=0;
  rep(i, 0, N){
    cin >> A[i];
    if(A_max < A[i]){
      A_max = A[i];
    }
  }

  ll A_middle=0;
  ll A_middle_num=A_max;
  rep(i, 0, N){
    if(A[i] == A_max){
      continue;
    }
    if(A_middle_num > abs((A_max/2)-A[i])){
      A_middle_num = abs((A_max/2)-A[i]);
      A_middle = A[i];
    }
  }

  cout << A_max << " " << A_middle << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


void solve(long long N){
    cout<<"ABC"<<N<<endl;
}

int main(){
    int a,b;
    cin>>a>>b;
    if(a>b)cout<<a-1<<endl;
    else cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

n = int(input())

d = defaultdict(int)
for _ in range(n):
    d[input()] += 1

ans = sorted(sorted(d.items()), key=lambda x:x[1], reverse=True)
max_v = ans[0][1]
for s, v in ans:
    if v < max_v:
        break
    print(s)

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

int main(){
  int t;
  cin >> t;
  for (int i=0; i<t; i++) {
    int n, k;
    cin >> n >> k;
    int x[n], gap[n-1];
    for (int j=0; j<n; j++) cin >> x[j];
    for (int j=0; j<n-1; j++) gap[j] = x[j+1] - x[j];
    sort(&gap[0],&gap[n-1]);
    int sum=0;
    if ((n-1)-(k-1)>0) {
      for (int j=0; j<(n-1)-(k-1); j++) sum += gap[j];
    }
    cout << sum << endl;
  }
  return 0;
}

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

int main() {

	int n, a, b;
	cin >> n >> a >> b;
	int one = 0, two = 0, three = 0;
	int ans = 0;
	rep(i, n){
		int p;
		cin >> p;
		if(p <= a){
			one++;
		}
		else if(p <= b){
			two++;
		}
		else{
			three++;
		}
		ans = min({one, two, three});
	}

	cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
using namespace std;
#define ll long long
#define vel vector<ll>
#define vvel vector<vel>
#define vvvel vector<vvel>
#define veb vector<bool>
#define pin pair<ll,ll>
#define mkp make_pair
#define mot pair<D,D>//time,dist
#define path pair<ll,int>//cost,to
#define int long long
using namespace std;
vvel ta_min(0);
vvel ta_max(0);
int leth = 1024 * 512;
int p = 1000000007;
vel par;
vel dis;
int n;
void mmax(ll &a, ll b) { a = max(a, b); }
void mmin(ll &a, ll b) { a = min(a, b); }
pin root(int ser) {
	if (par[ser] == -1) {return mkp(ser,0);}
	pin x=root(par[ser]);
	x.second += dis[ser];
	par[ser] = x.first;
	dis[ser] = x.second;
	return x;
}
void uni(int a, int b,int d) {
	pin p1 = root(a);
	pin p2 = root(b);
	int a1 = p1.first;
	int b1 = p2.first;
	if (a1 != b1) {
		par[b1] = a1;
		dis[b1] = d + dis[a] - dis[b];
	}
}
bool issame(int x, int y) {
	return root(x).first == root(y).first;
}
void ref(int &x) { x = x % p; x = (x + p) % p; }
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);//return a^n%p
	x *= x; ref(x);
	if (n % 2 == 1) { x *= a; }
	ref(x);
	return x;
}
void nim(int x, int k) {
	while (1) {
		int x; int k; cin >> x >> k;
		vel gr(x + 1);
		gr[0] = 0;
		for (int i = 1; i <= x; i++) {
			vel ko(x + 1, 0);
			for (int j = 1; j <= i / k; j++) { ko[gr[i - j]]++; }
			int ind = 0;
			while (ko[ind] != 0) { ind++; }
			gr[i] = ind;
		}
		for (int i = 1; i <= x; i++) { cout << gr[i] << " "; }
	}
}
signed main() {
	int n, k; cin >> n >> k;
	int ans = 0;
	for (int b = k + 1; b <= n; b++) {
		int qn = n - k; if (k == 0) { qn--; }
		ans += (qn / b)*(b - k);
		int re = qn % b;
		ans += min(re + 1, b - k);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    i32 a, b;
    std::cin >> a >> b;
    std::cout << a * b << '\n';
}


Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var p = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int count = 0;
        for (int i = 0; i < n - 2; i++)
        {
            var three = p.Skip(i).Take(3).ToArray();
            if (three[1] != three.Max() && three[1] != three.Min())
            {
                count++;
            }
        }

        Console.WriteLine(count);
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void){
  int N;
  cin >> N;
  
  vector<string>name(N);
  for(int i=0;i<N;i++){
    cin >> name[i];
  }
  
  long m = 0;
  long a = 0;
  long r = 0;
  long c = 0;
  long h = 0;
  
  for(int i=0;i<N;i++){
    if(name[i][0] == 'M')
      m++;
    if(name[i][0] == 'A')
      a++;
    if(name[i][0] == 'R')
      r++;
    if(name[i][0] == 'C')
      c++;
    if(name[i][0] == 'H')
      h++;
  }
  
  cout << m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h << endl;
  
  return 0;
}


Measured memory_bytes: 6144
n = int(input())
def bi(ball, i, x, y):
    # print(i, len(x), len(y))
    if i != 10:
        x2, y2 = x + [ball[i]], y + [ball[i]]
        bi(ball, i + 1, x2, y)
        bi(ball, i + 1, x, y2)
    else:
        nx = x[:]
        ny = y[:]
        x.sort(), y.sort()
        if nx == x and ny == y:
            global ans
            ans = 'YES'
            # print(nx, ny)

for i in range(n):
    ans = 'NO'
    ball = list(map(int, input().split()))
    bi(ball, 0, [], [])
    print(ans)


Measured memory_bytes: 5600
N,K = map(int,input().split(" "))
cdn = list(map(int,input().split(" ")))
n = N - K + 1
neko = 0
ans = []
i = 0
while i < n:
  if abs(cdn[i]) >= abs(cdn[i+K-1]):
    neko = abs(cdn[i+K-1]) + cdn[i+K-1] - cdn[i]
    ans.append(neko)
  else:
     neko = abs(cdn[i]) + cdn[i+K-1] - cdn[i]
     ans.append(neko)
  i = i + 1
ans.sort()
print(ans[0])

Measured memory_bytes: 14224
#ifndef ONPC
  #define _FORTIFY_SOURCE 0
  #pragma GCC optimize("Ofast")
  #pragma GCC optimize("no-stack-protector")
  #pragma GCC optimize("unroll-loops")
  #pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
  #pragma GCC optimize("fast-math")
#endif

#include <bits/stdc++.h>

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
//#define int long long
const int INF = 1e9;

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int x, y, a, b, c;
    priority_queue<pair<ll, int>> q;
    cin >> x >> y >> a >> b >> c;
    ll v;
    for (int i = 0; i < a; i++){
      cin >> v;
      q.push(mp(v, 1));
    }
    for (int i = 0; i < b; i++){
      cin >> v;
      q.push(mp(v, 2));
    }
    for (int i = 0; i < c; i++){
      cin >> v;
      q.push(mp(v, 0));
    }

    ll sum = 0LL;
    int cl = 0;
    while (!q.empty()){
      auto t = q.top();
      q.pop();
      if (t.ss == 1 && x > 0){
        x--;
        sum += t.ff;
      }
      if (t.ss == 2 && y > 0){
        y--;
        sum += t.ff;
      }
      if (t.ss == 0){
        cl++;
        sum += t.ff;
      }
      if (cl >= x + y) break;
    }

    cout << sum << '\n';

    return 0;
}


Measured memory_bytes: 10604
#include<bits/stdc++.h>
using namespace std;
char s[100001];
int main(){
    int a,b;
    cin>>a>>b;
    for(int i=1;i<=a+b+1;i++){
        cin>>s[i];
    }
    for(int i=1;i<=a+b+1;i++){
        if(s[i]<48 && i!=a+1 || s[i]>58 && i!=a+1){
            cout<<"No";
            return 0;
        }
        if(i==a+1 && s[i]!='-'){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}

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

int lcs(string X,string Y){
	int x=X.size(),y=Y.size();
	X = ' '+X;
	Y= ' '+Y;
	int c[1000+10][1000+10];
	for(int i=0;i<1010;i++){
		c[i][0]=0;
		c[0][i]=0;
	}
	for(int i=1;i<=x;i++){
		for(int j=1;j<=y;j++){
			if(X[i]==Y[j]){
				c[i][j]=c[i-1][j-1]+1;
			}
			else{
				c[i][j]=max(c[i][j-1],c[i-1][j]);
			}
		}
	}
	return c[x][y];
}

int main() {
	int n;
	string s1,s2;
	cin>>n;
	for(int i=0;i<n;i++){
	cin>>s1>>s2;
	cout<< lcs(s1,s2)<<endl;
	}
	return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const int int_inf = 100000000;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int h, w;
    cin >> h >> w;

    vector<vector<int>> dist(h, vector<int>(w, int_inf));

    char grid[h][w];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> grid[i][j];
        }
    }

    if (grid[0][0] == '#') dist[0][0] = 1;
    else dist[0][0] = 0;
    
    queue<pair<int, int>> que;
    que.push(make_pair(0, 0));

    while (!que.empty()) {
        auto now = que.front();
        que.pop();
        int now_x, now_y, next_x, next_y, cost;
        now_x = now.first;
        now_y = now.second;

        for (int i = 0; i < 2; i++) {
            next_x = now_x + dx[i];
            next_y = now_y + dy[i];
            if (next_x < 0 or next_x >= h or next_y < 0 or next_y >= w) continue;
            cost = dist[now_x][now_y];
            if (grid[now_x][now_y] == '.' and grid[next_x][next_y] == '#') cost++;
            if (cost < dist[next_x][next_y]) {
                dist[next_x][next_y] = cost;
                que.emplace(make_pair(next_x, next_y));
            }
        }
    }
    /*
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << dist[i][j] << " ";
        }
        cout << endl;
    }*/
    cout << dist[h-1][w-1] << '\n';
    
    return 0;
}

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

const char c[2][2] = {'R', 'Y',
                      'G', 'B'};

int n, m, d;

int main(){

    cin >> n >> m >> d;

    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){

            int x = i+j;
            int y = i-j + 500;

            x = (x/d) % 2;
            y = (y/d) % 2;

            cout << c[x][y];

        }
        cout << "\n";
    }

    return 0;

}

Measured memory_bytes: 512
def main():
    N, T = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(N)]

    dp = [-1] * (T + 3000)
    dp[0] = 0
    for a, b in sorted(AB):
        for j in range(T - 1, -1, -1):
            if dp[j] == -1:
                continue
            if dp[j] + b > dp[j + a]:
                dp[j + a] = dp[j] + b
    print(max(dp))


main()


Measured memory_bytes: 3932
#include <stdio.h>
#define MIN -1000000000
int heapsize=0,A[2000000001];
void maxHeapify(int );
void insert(int );
void helpIncreaseKey(int ,int );
int heapExtractMax(int );


int main(void){
  int key;
  char command[7];
  while(1){
    scanf("%s",command);
    if(command[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }
    else if(command[0]=='e'){
      if(command[1]=='n')
        break;
      else if(command[1]=='x')
        printf("%d\n",helpExtractMax());
    }
  }
  
  return 0;
}

int helpExtractMax(int element){
  int max;
  if(heapsize<1)
    return ;
  max=A[1];
  A[1]=A[heapsize];
  heapsize--;
  maxHeapify(1);
  return max;
}

void helpIncreaseKey(int element,int key){
  int temp;
  if(key < A[element])return ;
  A[element]=key;
  while(element>1 && A[element/2] < A[element]){
    //compare parent's key with child's key
    temp=A[element];
    A[element]=A[element/2];
    A[element/2]=temp;
    element/=2;
  }
}

void insert(int key){
  heapsize++;
  A[heapsize]=MIN;
  //set key to A[heapsize]
  helpIncreaseKey(heapsize,key);
}
void maxHeapify(int parent){
  int left,right,maxnode,temp;
  left=2*parent;
  right=left+1;

  if(left<=heapsize && A[left] > A[parent])
    maxnode=left;
  else
    maxnode=parent;
  if(right<=heapsize && A[right] > A[maxnode])
    maxnode=right;

  if(maxnode!=parent){
    //need to swap node
    temp=A[maxnode];
    A[maxnode]=A[parent];
    A[parent]=temp;

    if(maxnode*2<=heapsize)
      //there is child of maxnode
      maxHeapify(maxnode);
  }
}


Measured memory_bytes: 5704
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

//           k人, l個
long long dp[500][500];

long long A[500];
long long B[500];

long long N, C;

long long modpow(long long ori, long long po){
	long long res = 1;
	while(po > 0){
		if(po&1){
			res *= ori;
			res %= DIV;
		}
		ori *= ori;
		ori %= DIV;
		po >>= 1;
	}
	return res;
}


long long memo[500][500];

int main(){
	cin >> N >> C;

	for(int i = 0; i < N; i++){
		cin >> A[i];
	}

	for(int i = 0; i < 500; i++){
		for(int j = 1; j < 500; j++){
			memo[i][j] = memo[i][j-1] + modpow(j, i);
			memo[i][j] %= DIV;
		}
	}
	//for(int i = 0; i < 10; i++){
	//	for(int j = 0; j < 10; j++){
	//		cout << "memo" << i << "," << j << "=" << memo[i][j] << endl;
	//	}
	//}

	for(int i = 0; i < N; i++){
		cin >> B[i];
	}
	for(int i = 0; i <= C; i++){
		dp[0][i] = 0;
		for(int j = A[0]; j <= B[0]; j++){
			dp[0][i] += modpow(j, i);;
			dp[0][i] %= DIV;
		}
	}

	for(int i = 1; i < N; i++){
		for(int j = 0; j <= C; j++){
			for(int k = 0; k <= j; k++){

				dp[i][j] += dp[i-1][k]*(memo[j-k][B[i]] - memo[j-k][A[i]-1]);
				dp[i][j] %= DIV;

				//for(int l = A[i]; l <= B[i]; l++){
				//	dp[i][j] += dp[i-1][k]*modpow(l, (j-k));
				//	dp[i][j] %= DIV;
				//}
			}
		}
	}


	//for(int i = 0; i <= N; i++){
	//	for(int j = 0; j <= C; j++){
	//		cout << "i=" << i << "j=" << j << ":" << dp[i][j] << endl;
	//	}
	//}
	
	cout << dp[N-1][C] << endl;
}

Measured memory_bytes: 3712
import java.io.*;
import java.util.*;
class Main
{
  public static void main(String args[])throws Exception
  {
    Scanner Sc=new Scanner(System.in);
    int a=Sc.nextInt();
    String s=Sc.next();
    if(a>=3200)
      System.out.println(s);
    else
      System.out.println("red");
  }
}

Measured memory_bytes: 21844
#include <stdio.h>

int main (){

  int year = 0, month = 0, day = 0;

  scanf("%d / %d / %d",&year, &month, &day);

  if( year <= 2018 ){
    printf("Heisei");
  }
  else if( year >= 2020){
    printf("TBD");
  }
  else{

    if( month <= 4 ){
      printf("Heisei");
    }
    else if( month >= 5 ){
      printf("TBD");
    }
  }
 return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'

typedef long long int ll;
typedef pair<int, int> P;

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

  int a, b;
  cin >> a >> b;

  if (a == 1) a += 13;
  if (b == 1) b += 13;

  if (a == b) {
    cout << "Draw" << endl;
  } else if (a > b) {
    cout << "Alice" << endl;
  } else {
    cout << "Bob" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
n = input()

s = list(n)
if n[0] == '1':
    s[0] = '9'
elif n[0] == '9':
    s[0] = '1'
if n[1] == '1':
    s[1] = '9'
elif n[1] == '9':
    s[1] = '1'
if n[2] == '1':
    s[2] = '9'
elif n[2] == '9':
    s[2] = '1'
str_changed = "".join(s)
print(str_changed)

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

int main() {
  int c[3][3];
  for (int i=0 ; i<3 ; i++) {
    for (int j=0 ; j<3 ; j++) {
      cin >> c[i][j];
    }
  }
  int a[3];
  for (int i=0 ; i<3 ; i++) a[i] = c[i][0];
  int b2 = c[0][1] - a[0], b3 = c[0][2] - a[0];
  for (int i=0 ; i<3 ; i++) {
    if (b2 != c[i][1] - a[i] || b3 != c[i][2] - a[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int w[33];
vector<ll> a, b;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	map<int, ll> mp;
	rep(i, n) mp[s[i] - 'a']++;
	ll ans = 0;
	rep(i, n) {
		int d = s[i] - 'a';
		mp[d]--;
		ll tmp = 1;
		rep(j, 26) {
			if (j == d) continue;
			(tmp *= (mp[j] + 1)) %= mod;
		}
		(ans += tmp) %= mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
n = int(input())
s = [list(input()) for i in range(n)]
a,b,c = 0,0,0
t = 0
for i in range(n):
        for j in range(len(s[i])-1):
                if s[i][j] =="A" and s[i][j+1] == "B":
                        c += 1
                else:
                        continue
        if s[i][0] == "B":
                b += 1
        if s[i][-1] == "A":
                a += 1
        if s[i][0] == "B" and s[i][-1] == "A":
                t += 1
 
if a > b:
        d = b
else:
        d = a

if  t == b and a == t:
        d -= 1
if  t == 0 and a == 0 and b ==0:
        d += 1

print(d + c)

Measured memory_bytes: 4596
n = int(input())
T = [int(input()) for _ in range(n)]

def gdc(a,b):
    while b:
        a,b = b,a%b
    return a

def lcm(a,b):
    return a*b//gdc(a,b)

temp = T[0]
for i in range(n-1):
    temp = lcm(temp,T[i+1])
print(temp)

Measured memory_bytes: 3064
// abc058_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    vector<int> A(3);
    REP(i, 3) cin >> A[i];
    sort(ALL(A));

    if (A[2] - A[1] == A[1] - A[0]){
        print("YES");
    } else {
        print("NO");
    }


    return 0;
}


Measured memory_bytes: 256
n = int(input())
xy = [[]] * n
cnt = 0

for i in range(n):
    xy[i] = [list(map(int, input().split())) for j in range(int(input()))]

bit = '0' + str(n) + 'b'
for k in range(2**n):
  cnt_current = 0
  flg = True
  katei = format(k, bit)
  
  for l in range(len(xy)):
    if flg == False:
      break
    if katei[l] == '0':
      continue
    else:
      for m in range(len(xy[l])):
        if int(xy[l][m][1]) != int(katei[xy[l][m][0]-1]):
          flg = False
          break
  if flg == True:
    cnt_current = katei.count('1')
  if cnt_current > cnt:
    cnt = cnt_current
    
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  string s; cin >> s;
  int r=0,b=0;
  rep(i,s.size()){
    if(s.at(i)=='0') r++;
    else b++;
  }
  cout << min(r,b)*2 <<endl;
}


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

public class Main {	

	private static void solve(){
		//Implement solution here.
		int N = ni();
		int[] A = na(N);
		Arrays.sort(A);
		long result = 0;
		ArrayDeque<Integer> q = new ArrayDeque<Integer>();
		q.add(A[N - 1]);
		for(int i = N - 2; i >= 0 ; i--) {
			result += q.poll();
			q.addLast(A[i]);
			q.addLast(A[i]);
//			System.out.println(q);
//			System.out.println(result);
		}
		System.out.println(result);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 58044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  ll N,Q;
  cin >> N >> Q;
  vector<vector<ll>> t(N);
  ll a,b;
  rep(i,N-1){
    cin >> a >> b;
    a--; b--;
    t[a].pb(b);
    t[b].pb(a);
  }
  vector<ll> ans(N,0);

  ll p,x;
  rep(i,Q){
    cin >> p >> x;
    p--;
    ans[p] += x;
  }
  vector<bool> chk(N,false);
  chk[0] = true;
  queue<ll> q;
  q.push(0);
  while(!q.empty()){
    ll now = q.front(); q.pop();
    rep(i,(int)t[now].size()){
      if(chk[t[now][i]]) continue;
      chk[t[now][i]] = true;
      q.push(t[now][i]);
      ans[t[now][i]] += ans[now];
    }
  }

  rep(i,N){
    if(i!=0) cout << " ";
    cout << ans[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 17904
/*
1 bubbleSort(A, N) // N 個の要素を含む 0-オリジンの配列 A
2   flag = 1 // 逆の隣接要素が存在する
3   while flag
4     flag = 0
5     for j が N-1 から 1 まで
6       if A[j] < A[j-1]
7         A[j] と A[j-1] を交換
8         flag = 1
*/
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

void print_vec(vector<int> &A){
    for(int i=0;i<A.size();i++){
        cout << A.at(i);
        if(i == A.size()-1){
            cout << endl;
        }else{
            cout << ' ';
        }
    }
}

void bubbleSort(vector<int> &A,int &cnt){
    bool flag = 1;
    for(int i=0; flag; i++){
        flag = 0;
        for(int j = A.size()-1; j>= i+1; j--){
            if(A.at(j) < A.at(j-1)){
                swap(A.at(j),A.at(j-1));
                cnt++;
                flag = 1;
            }
        }
    }
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A.at(i);
    int cnt = 0;
    bubbleSort(A,cnt);
    print_vec(A);
    cout << cnt << endl;
}   


Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

int main() {
    long long N;
    cin >> N;
    long long ans=0;
    for (long long i=1; i<sqrt(N); i++) {
        if ((N-i)%i==0) {
            //cout << i << endl;
            if(N%((N-i)/i)!=0){
                ans+=(N-i)/i;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>
using namespace std;

int main(){
  int n,m;
  cin>>n>>m;
  int b[m],a[n][m];

  for(int i = 0; i<n; i++){
    for(int j = 0; j<m; j++){
      cin>>a[i][j];
    }
  }
  for(int i = 0; i<m; i++){
    cin>>b[i];
  }

  int sum;
  for(int i = 0; i<n; i++){
    sum=0;
    for(int j =0; j<m; j++){
      sum += a[i][j] * b[j];
    }
    cout<<sum<<endl;
  }
  
}

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

const int N = 88;
const int M = 6400;
int n, m, A[N][N], B[N][N];
std::bitset<M * 2 + 1> dp[N][N];

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			scanf("%d", A[i] + j);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			scanf("%d", B[i] + j);
	dp[0][1].set(M);
	dp[1][0].set(M);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++) {
			int d = std::abs(A[i][j] - B[i][j]);
			dp[i][j] |= (dp[i - 1][j] << d) | (dp[i - 1][j] >> d);
			dp[i][j] |= (dp[i][j - 1] << d) | (dp[i][j - 1] >> d);
		}
	int ans = 1e9;
	for (int i = 0; i <= 2 * M; i++)
		if (dp[n][m].test(i))
			ans = std::min(ans, std::abs(i - M));
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  int div = 0;
  scanf("%d",&n);
  int temp = n;
  while(n)
  {
    div += n%10;
    n = n/10;
  }
  if(temp%div == 0)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
#include <chrono>
#include <random>
#include <ctime>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.14159265358979323846;
const ll MOD = 998244353;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	srand(time(0));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	map<ll, ll> s;
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		s[x]++;
		ans += x;
	}
	int q;
	cin >> q;
	while (q--) {
		ll b, c;
		cin >> b >> c;
		ans -= b * s[b];
		ans += c * s[b];
		s[c] += s[b];
		s[b] = 0;
		cout << ans << "\n";
	}
}

Measured memory_bytes: 9444
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

long long const MOD = 1000000007LL;

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

    int keta = 0;

    int num = n;
    while (num) {
        ++keta;
        num /= 10;
    }
 
    int res = 0;
    if (keta == 1) res = n;
    if (keta >= 2) res += 9 - 0;
    if (keta == 3) res += n - 99;
    if (keta >= 4) res += 999 - 99;
    if (keta == 5) res += n - 9999;
    if (keta == 6) res += 99999 - 9999;

    cout << res << endl;
}


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

int main() {
  ll N; 
  cin >> N;
  vector<ll> A(N), D(N);
  ll t = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    t += A.at(i);
  }
  ll u = N * (N+1) / 2;
  
  if (t % u != 0) 
    return cout << "NO" << '\n', 0;
  
  ll m = t / u;
  
  for (int i = 0; i < N-1; i++) 
  	D.at(i) = A.at(i + 1) - A.at(i);
  
  D.at(N-1) = A.at(0) - A.at(N-1);
  
  for (int i = 0; i < N; i++) {
    ll y = m - D.at(i);
    if (y < 0 || y % N != 0)
      return cout << "NO" << '\n', 0;
  }
  
  cout << "YES" << '\n';
  return 0;
}

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

int main(){
  vector<int> p(5);
  for ( int i = 0; i < 5; i++) cin >> p.at(i);  
  int k;
  cin >> k;
  
  bool flg = false;
  for(int i = 0; i < 5 ; i++){
    for(int j = 1 + i; j < 5 - i;j++){
      if ( (p.at(j) - p.at(i) ) > k){
        flg = true;
      }
    }
  }
  
  if(flg) cout << ":(" << endl;
  else cout << "Yay!" << endl;    
 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
 
int main() {
  int d,n;
  cin >> d >> n;
  int s = 1; for (int i = 0; i < d; i++) s *= 100;
  if(n <= 99){
    cout << s * n << endl;
  }
  else{
    cout << s * 101 << endl;
  } 
  return 0;
}

Measured memory_bytes: 256
# ABC082C - Good Sequence (ARC087C)
from collections import Counter


def main():
    N, *A = map(int, open(0).read().split())
    C = Counter(A)
    ans = sum(j if i > j else j - i for i, j in C.items())
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 18728
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,z;
    char ca,cb,cc;
    cin>>n;
    long double ans=0;
    rep(i,n){
        long double ac;
        cin>>ac>>str;
        if(str[0]=='J')ans+=ac;
        else{
            ans+=ac*380000;
        }
    }
cout<<ans<<endl;

    

    return 0;
}


Measured memory_bytes: 3816