akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  vector<int> hs(n);
  for(int i=0;i<n;i++) cin>>hs[i];
  reverse(hs.begin(),hs.end());
  int cnt=0,res=0;
  for(int i=1;i<n;i++){
    if(hs[i-1]<=hs[i]) cnt++;
    else cnt=0;
    chmax(res,cnt);
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int coins[] = {1, 5, 10, 50, 100, 500};

int main() {
  int m = 0;
  int n;
  while(cin >> m, m) {
    n = 0;
    m = 1000 - m;
    for (int i = 5; i >= 0; i--) {
      int t = m / coins[i];
      n += t;
      m -= t * coins[i];
    }
    cout << n << endl;
  }
}

Measured memory_bytes: 1160
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
typedef long long ll;
const int inf=1e9;
int main(){
  int r,g;cin>>r>>g;
  cout<<g*2-r<<endl;
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	// Code for C - Welcome to AtCoder
	var N, M int
	fmt.Scanf("%d %d", &N, &M)

	var p int
	var S string
	temp := make(map[int]int, N)
	ans := make(map[int]int, N)
	for i := 0; i < M; i++ {
		fmt.Scanf("%d %s", &p, &S)
		if S == "WA" {
			temp[p]++
		} else {
			if ans[p] == 0 {
				ans[p] = temp[p] + 1
			}
		}
	}

	var count int
	for _, v := range ans {
		count += v - 1
	}

	fmt.Println(len(ans), count)
}


Measured memory_bytes: 10128
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	if (n > k * 2) {

	}
	return fac[n] / (fac[k] * fac[n - k]);
}

ll dp[201010][2];
ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char c[10][10];
bool flag[10][10];
bool flag2[10][10];

//long longしか使わない
//素数は1より大きい
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(a.rbegin(), a.rend());
	ll ans = a[0];
	ll res = 1;
	for (ll i = 1;i < n;++i) {
		if (res == n - 1)break;
		ans += a[i];
		res++;
		if (res == n - 1)break;
		ans += a[i];
		res++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
#define Yes(X) puts ( (X) ? "Yes" : "No")
#define YES(X) puts ( (X) ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = (a); i < (b) ; i++)
#define rep(i, n) for ( int i = 0; i < (n) ; i++)
const int MOD = 1000000007;
typedef long long ll;
typedef unsigned  u;
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}
/* main */
int main() {
  int k, x;
  cin >> k >> x;
  int m = max(-1000000, x - k + 1);
  int n = min(1000000, x + k - 1);
  for(int i = m; i <= n; i++) cout << i << " ";
}



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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 	string s;
 	cin>>s;
 	int i,n=s.length();
 	for(i=0;i<n;i++)
 	if(s[i]=='?')
 	s[i]='D';
 	cout<<s<<endl;
 	/*int a[n];
 	memset(a,0,sizeof(a));
 	if(s[0]=='D')
 	a[0]=1;
 	int ans=0;
 	if(s[0]=='D')
 	ans=1;
 	for(i=1;i<n;i++)
 	{
 	  if(s[i]=='D')
	   {
	   	 	if(s[i-1]=='P')
	   	 	a[i]=a[i-1]+2;
	   	 	else
	   	 	a[i]=a[i-1]+1;
	   }
	   else if(s[i]=='P' && s[i-1]!='P')
	   a[i]=a[i-1];
	   ans=max(ans,a[i]);	
	}
	cout<<ans<<endl;*/
	return 0;
}



Measured memory_bytes: 3780
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque


def S(): return sys.stdin.readline().rstrip()


def I(): return int(sys.stdin.readline().rstrip())


def MI(): return map(int, sys.stdin.readline().rstrip().split())


def MS(): return map(str, sys.stdin.readline().rstrip().split())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def LS(): return list(sys.stdin.readline().rstrip().split())


# N = I()
# A = [LI() for _ in range(N)]


n, m = map(int, input().split())
a = [0] * m
b = [0] * m
box = [[] for i in range(n)]
s = deque()
ans = [-1] * (n - 1)
for i in range(m):
    a[i], b[i] = map(int, input().split())
    box[a[i] - 1].append(b[i])
    box[b[i] - 1].append(a[i])
for i in range(len(box[0])):
    s.append([1, box[0][i]])

while len(s) > 0:
    k = s.popleft()

    if ans[k[1] - 2] == -1 and k[1] - 2 != -1:
        ans[k[1] - 2] = k[0]

        for i in range(len(box[k[1] - 1])):
            s.append([k[1], box[k[1] - 1][i]])

print('Yes')
for i in range(len(ans)):
    print(ans[i])


Measured memory_bytes: 77912
N,M,X = map(int,input().split())
c_A = [list(map(int,input().split())) for i in range(N)]

total = 0
result = 10000000000000000
count = 0
flag = True

#print(c_A)
for i in range(2 ** N):
    total = 0
    count = 0
    bit = [0]*N
    for j in range(N):
        state = [0] * M
        if (i >> j) & 1:
            bit[j] = 1
    
    #1の時全てのANを足し合わせる。合計金額を出す
    for k in range(N):
        if bit[k] == 1:
            #print(bit)
            for l in range(M):
                state[l] += c_A[k][l+1]
            total += c_A[k][0]
    #print(state)
    #print()
    #X以上じゃなければbreak
    for m in range(M):
        if state[m] < X:
            break
        else:
            count += 1
    #print(count)
    if count == M:
        flag = False
        result = min(total,result)
if flag == False:
    print(result)
else:
    print(-1)
    

Measured memory_bytes: 9224
n, k = [int(item) for item in input().split()]
ab = []
for i in range(n):
    a, b = [int(item) for item in input().split()]
    ab.append((a, b))
ab.sort(reverse=True)

candidate = [k]
for i in range(32):
    cand = 0
    if k & 1 << i:
        for j in range(i):
            cand += 1 << j
        for j in range(i + 1, 32):
            if k & 1 << j:
                cand += 1 << j
        candidate.append(cand)

ans = 0
for cand in candidate:
    ret = 0
    for a, b in ab:
        if cand | a == cand:
            ret += b
    ans = max(ans, ret)
print(ans)

Measured memory_bytes: 54744
#include<iostream>
#include<string>
#include<string.h>
#include<math.h>
#include<vector>
#include<algorithm>	

using namespace std; 

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

	string s;
	cin>>s;
	if(s[1]=='R'){
		cout<<"ABC";
	}
	else{
		cout<<"ARC";
	}
	
	return 0; 
} 


Measured memory_bytes: 3628
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main() {
    // 入力
    let (A, P) = get!(usize, usize);

    let ans = (3 * A + P) / 2;

    // 出力
    println!("{}", ans);
}


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

public class Main{
  public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      int n;
      n=Integer.parseInt(sc.next());

      if(100<=n && n<=111){
        System.out.println(111);
      }else if(111<n && n<=222){
        System.out.println(222);
      }else if(222<n && n<=333){
        System.out.println(333);
      }else if(333<n && n<=444){
        System.out.println(444);
      }else if(444<n && n<=555){
        System.out.println(555);
      }else if(555<n && n<=666){
        System.out.println(666);
      }else if(666<n && n<=777){
        System.out.println(777);
      }else if(777<n && n<=888){
        System.out.println(888);
      }else if(888<n){
        System.out.println(999);
      }
      
      }catch (Exception e) {
      System.out.println("out");
    }
  }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
 
#define vl vector<ll>
#define vi vector<int>
 
#define ff first
#define ss second
 
#define pb push_back
#define MOD 1000000007
//const int nax = 1e6+5;
#define inf 4e18
 
#define display(v) for(int i =0;i<v.size();++i)cout << v[i] << " "
#define all(v) v.begin(),v.end()
ll sqr(ll x){return x*x;}
inline ll add(ll a, ll b){ ll c = a + b; if(c >= MOD) c -= MOD; return c; }
inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
const int nax = 200*1000 + 10;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
    int n ; cin>>n;
    string str;
    cin>>str;
    int i  = 0 , j  = n-1;
    while(i<n && str[i] == 'R')++i;
    while(j>=0 && str[j] == 'W')--j;
    if(i>=j){
        cout << 0;
        return 0;
    }
    int ans = 0;
    while(i<j){
        swap(str[i] , str[j]);
        ans++;
        while(i<n && str[i] == 'R')++i;
        while(j>=0 && str[j] == 'W')--j;
    }
    for(int i = 0;i<n-1;++i){
        if(str[i] == 'W' && str[i+1] == 'R')ans++;
    }
    cout << ans;

   

  
    return 0;
}
    

// Химаншу


Measured memory_bytes: 3724
using System;
using System.Linq;

namespace D___Flipping_Signs
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var An = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            var DP = new long[N,2];
            DP[1,0] = An[0]+An[1];
            DP[1,1] = -An[0]-An[1];

            for(int i = 2 ; i < N ; i++)
            {
                DP[i,0] = Math.Max(DP[i-1,0],DP[i-1,1])+An[i];
                DP[i,1] = Math.Max(DP[i-1,0]-2*An[i-1]-An[i],DP[i-1,1]+2*An[i-1]-An[i]);
            }
        Console.WriteLine(Math.Max(DP[N-1,0],DP[N-1,1]));
        }
    }
}


Measured memory_bytes: 33500
# https://atcoder.jp/contests/abc084/tasks/abc084_c
n = int(input())

trains = []
for _ in range(n - 1):
    c, s, f = map(int, input().split())
    trains.append((c, s, f))


ans = []
for i in range(n - 1):
    _c, start, _ = trains[i]
    t = start + _c
    for j in range(i + 1, n - 1):
        c, s, f = trains[j]
        if t > s:
            while t > s:
                s += f
            t += (s - t) + c
        else:
            t = s + c
    ans.append(t)
ans.append(0)
for a in ans:
    print(a)

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

int main(){

  int n,ans = 0;
  long long int a;
  cin >> n;
  while( n-- ){
    cin >> a;
    while( a%2 == 0 ){
      a /= 2;
      ans++;
    }
  }
  cout << ans << endl;

	return 0 ;
}


Measured memory_bytes: 384
use std::str::FromStr;
use std::io::*;

fn main() {
    let i = stdin();
    run(&mut i.lock(), &mut stdout());
}

fn run(i: &mut BufRead, o: &mut Write) {
    let n: usize = read(i);
    writeln!(o, "{}", n / 3).unwrap();
}

fn read_line(i: &mut BufRead) -> String {
    let mut line = String::new();
    i.read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn read<T: FromStr>(i: &mut BufRead) -> T {
    read_line(i).parse().ok().unwrap()
}


Measured memory_bytes: 4352
/// Created by ...Lusifer
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void solveTest(){
	int h,w;
	cin>>h>>w;
	string board[50];
	for(int i=0;i<h;i++) cin>>board[i];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(board[i][j]=='#') continue;
			int cnt=0;
			for(int d=0;d<8;d++){
				int ni = i+dy[d];
				int nj = j+dx[d];
				if(ni<0 || ni>=h) continue;
				if(nj<0 || nj>=w) continue;
				if(board[ni][nj]=='#') cnt++;
			}
			board[i][j] = char(cnt+'0');
		}
	}
	for(int i=0;i<h;i++){
		cout<<board[i]<<endl;
	}
	//cout<<endl<<"Time: "<<(float)clock()/CLOCKS_PER_SEC<<" seconds"<<endl;
	return ;
}
 
int main(){
	fastio();

	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	return 0;
}

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

int main(){
    
    // 1. 入力情報.
    char c[111];
    scanf("%s", c);
    
    // 2. 'C' の 出現位置(1回目).
    int atC = -1, l = strlen(c);
    rep(i, l){
        if(c[i] == 'C'){
            atC = i;
            break;
        }
    }
    
    // 3. 'F' の 出現位置(1回目 かつ 'C' より後ろ).
    int atF = -1;
    repx(i, atC + 1, l){
        if(c[i] == 'F'){
            atF = i;
            break;
        }
    }
    
    // 4. 出力.
    printf("%s\n", (atC != -1 && atF != -1) ? "Yes" : "No");
    return 0;
    
}

Measured memory_bytes: 256
while True:
    a = input()
    h, w = a.split(' ')
    h, w = int(h), int(w)
    
    if h == 0 and w == 0:
        break
    
    for i in range(h):
        str = ''
        for j in range(w):
            if (i + j) % 2 == 0:
                str += '#'
            else:
                str += '.'
        print(str)
    print()


Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
int n,a[N],tmp[N],tl;
int main()
{
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;++i) scanf("%d",&a[i]);
	while(n>1)
	{
		sort(a+1,a+n+1);
		for(i=2;i<=n;++i) a[i]%=a[1];
		tl=0;
		for(i=1;i<=n;++i)
			if(a[i])
				tmp[++tl]=a[i];
		for(i=1;i<=tl;++i) a[i]=tmp[i];
		n=tl;
	}
	printf("%d\n",a[1]);
	return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const int INF = 10000000;

int n;
int a[1000010];

int main(void){
    cin >> n;
    int mi = 0, mx = 0;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        if (a[i] < a[mi]) mi = i;
        if (a[i] > a[mx]) mx = i;
    }

    cout << 2 * n - 1 << endl;

    if (abs(a[mi]) >= abs(a[mx])){
        for (int i = 0; i < n; i++){
            cout << mi + 1 << ' ' << i + 1 << endl;
        }

        for (int i = n - 1; i > 0; i--){
            cout << i + 1 << ' ' << i << endl;
        }
    }
    else{
        for (int i = 0; i < n; i++){
            cout << mx + 1 << ' ' << i + 1 << endl;
        }

        for (int i = 0; i < n - 1; i++){
            cout << i + 1 << ' ' << i + 2 << endl;
        }
    }
    
    

}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const int MOD = 1000000007;

long long inverse(long long a)
{
    static vector<int> memo(300001, -1);
    if(memo[a] != -1)
        return memo[a];

    int b = MOD - 2;
    long long c = a;
    long long ret = 1;
    while(b > 0){
        if(b & 1){
            ret *= c;
            ret %= MOD;
        }
        c *= c;
        c %= MOD;
        b >>= 1;
    }

    return memo[a] = ret;
}

long long comb(int n, int m)
{
    static vector<long long> a(300001, -1), b(300001, -1);
    if(a[1] == -1){
        a[1] = b[1] = 1;
        for(int i=2; i<=300000; ++i){
            a[i] = a[i-1] * i;
            a[i] %= MOD;
            b[i] = b[i-1] * inverse(i);
            b[i] %= MOD;
        }
    }

    if(m < 0 || m > n)
        return 0;
    if(m == 0 || m == n)
        return 1;

    return ((a[n] * b[m]) % MOD * b[n-m]) % MOD;
}

vector<long long> solve(int len, int n)
{
    vector<long long> ret(n+1);
    ret[0] = 1;
    long long tmp = 1;
    for(int i=1; i<=n; ++i){
        ret[i] = comb(len+2*i, i) - comb(len+2*i, i-1);
        ret[i] += MOD;
        ret[i] %= MOD;
    }

    return ret;
}

int main()
{
    int w, h, n; // ゴールのx座標、y座標、寄り道回数
    cin >> w >> h >> n;

    vector<long long> s = solve(w, n);
    vector<long long> t = solve(h, n);

    long long ret = 0;
    for(int i=0; i<=n; ++i){
        ret += (s[n-i] * t[i]) % MOD * comb(w+h+2*n, h+2*i);
        ret %= MOD;
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 6812
use std::io::{BufRead, Write, stdin, stdout};


fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut s = String::new();
    input.read_line(&mut s).unwrap();
    let mut split = s.split_whitespace();
    let n: i64 = split.next().unwrap().parse().unwrap();
    let mut ab = Vec::<(i64, i64)>::new();
    for _ in 0..n {
        let mut s = String::new();
        input.read_line(&mut s).unwrap();
        let mut split = s.split_whitespace();
        let a: i64 = split.next().unwrap().parse().unwrap();
        let b: i64 = split.next().unwrap().parse().unwrap();
        ab.push((a, b));
    }
    writeln!(output,
             "{}",
             ab.iter().rev().fold(0, |acc, &(a, b)| {
        acc + b -
        match (a + acc) % b {
            0 => b,
            _ => (a + acc) % b,
        }
    }))
        .unwrap();
}

fn main() {
    let stdin = stdin();
    solve(stdin.lock(), stdout());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v = Vec::<u8>::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }
    #[test]
    fn case1() {
        test("3\n3 5\n2 7\n9 4\n", "7\n");
    }
    #[test]
    fn case2() {
        test("7\n3 1\n4 1\n5 9\n2 6\n5 3\n5 8\n9 7\n", "22\n");
    }
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first < y.first;});
#define FRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first > y.first;});
#define SSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second < y.second;});
#define SRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second > y.second;});
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define $(x) {cout << #x << " = " << (x) << endl;}


int main() {
    LL N;
    cin >> N;
    vector<double> p(N + 1);
    FOR(i, 1, N + 1) cin >> p[i];

    vector<vector<double>> dp(N + 1, vector<double>(N + 1));   // dp[i][j] = prob. of #H = j with first i coins
    dp[0][0] = 1;
    FOR(i, 1, N + 1) {
        FOR(j, 0, i + 1) {
            dp[i][j] = (j == 0 ? 0.0 : dp[i - 1][j - 1] * p[i]) + dp[i - 1][j] * (1 - p[i]);
        }
    }
    double ans = 0.0;
    FOR(j, N / 2 + 1, N + 1) ans += dp[N][j];
    cout << setprecision(10) << ans << endl;
	
    return 0;
}


Measured memory_bytes: 70784
r, c =map(int, input().split())
data = []
for i in range(r):
    row = list(map(int, input().split()))
    row.append(sum(row))
    data.append(row)

list1 = []
for j in range(c+1):
    temp = 0
    for k in range(r):
        temp += data[k][j]
    list1.append(temp)

for l in data:
    print(*l)
print(*list1)

Measured memory_bytes: 8324
// Problem : D - String Formation
// Contest : AtCoder - AtCoder Beginner Contest 158
// URL : https://atcoder.jp/contests/abc158/tasks/abc158_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#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;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    string s,t="";
    int q;
    cin>>s>>q;
    int p = 0;
    while(q--){
        int x;
        cin>>x;
        if(x == 1) p ^= 1;
        else{
            int y;
            char c;
            cin>>y>>c;
            y--;
            if(p^y) s.pb(c);
            else t.pb(c);
        }
    }
    if(p) reverse(all(s)), cout<<s+t<<endl;
    else reverse(all(t)), cout<<t+s<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 4068
while True:
    a, op, b = input().split()
    
    if op == '?':
        break
    
    a = int(a)
    b = int(b)
    
    if op == '+':
        print(a + b)
    if op == '-':
        print(a - b)
    if op == '*':
        print(a * b)
    if op == '/':
        print(a // b)


Measured memory_bytes: 5596
N,M=[int(i) for i in input().split()]
ab=[[int(j) for j in input().split()] for i in range(N)]

res=0
ab.sort()
for a,b in ab:
    if b<M:
        M-=b
        res+=a*b
    else:
        res+=a*M
        break
print(res)


Measured memory_bytes: 21608
A, B = gets.split(" ").map(&:to_i)
A, B = B, A if A < B

def f(t)
    if t % 2 == 1
        return ((t / 2) + 1) % 2
    else
        return t^((t / 2) % 2)
    end
end

puts f(A)^f(B - 1)

Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

int main() {
    string s, t;
    cin >> s;
    cin >> t;

    for(int i = s.size() - t.size(); i >= 0; i--){
        string tmp = s.substr(i, t.size());
        bool flag = true;
        REP(j, t.size()){
            if (!(tmp[j] == '?' || tmp[j] == t[j])) flag = false;
        }
        if (!flag) continue;
        REP(j, s.size()){
            if (i <= j && j < i + t.size()) cout << t[j - i];
            else if(s[j] == '?') cout << 'a';
            else cout << s[j];
        }
        cout << endl;
        return 0;
    }
    cout << "UNRESTORABLE" << endl;

    return 0;
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    ll n,k;
    cin >> n >> k;
    ll ans = 0;
    if(k==0)
    {
        cout << n*n << endl;
        return 0;
    }
    for (int b = k+1; b < n+1; b++)
    {
        ll syou = n/b;
        ll amari = n%b;
        ll kosu = b-k;
        ll temp = syou*kosu;
        if((amari-k)>=0) temp+= amari-k+1;
        ans += temp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, w = map(int, input().split(' '))
items = [[]] * n
for i in range(n):
  weight, val = map(int, input().split(' '))
  items[i] = [weight, val]

# print(n, w)
# print(items)
MAX_V = 100100

#dp = [[10**9 for i in range(MAX_V)]] * (n+1) # 同じ配列を参照してしまう
dp = [[0]] * (n+1)
for i in range(n+1):
  dp[i] = [10**10 for num in range(MAX_V)]
# print(len(dp), len(dp[0]), dp[0][0])

dp[0][0] = 0

for i in range(n):
  weight , val = items[i]
  for sum_v in range(MAX_V):
    # i番目のアイテムを選択する
    if sum_v - val >= 0:
      dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v - val] + weight)
    # i番目のアイテムを選択しない
    dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v])

ans = 0
for sum_v in range(MAX_V):
  if dp[n][sum_v] <= w:
    # print(sum_v, dp[n][sum_v])
    ans = sum_v
# for i in range(n+1):
#  print(dp[i])
print(ans)

Measured memory_bytes: 173704
#include<stdio.h>
#include <iomanip>
#include <iostream>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include <random>
#include <chrono>

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
int main() {
	int n;
	double sum=0;
	double tmp;
	cin >> n;
	
	rep(i, n) {
		cin >> tmp;
		sum += 1 / tmp;
	}
	cout << setprecision(30)<< 1 / sum;

}

Measured memory_bytes: 256
n = gets.split
a = n[0].to_i
b = n[1].to_i
k = n[2].to_i

numbers = [a,b]
max = numbers.max {|a2, b2| a2.to_i <=> b2.to_i }
result = []

max.downto(1).each do |i|
  if((a/i) * i == a)
    if((b/i) * i == b)
      result.push(i)
    end
  end
end

p result[k-1]


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define ct(string) cout << string << endl

int main() {
    int x, k;
    cin >> k >> x;
    bool first = true;
    if (x-k+1 >= (-1000000)) {
        cout << x-k+1; first = false;
        for (int i=1; i<k; i++) {
            cout << " " << x-k+i+1;
        }
    } else {
        if (!first) {cout << " "; first = false;}
        cout << (-1000000);
        for (int i=(-1000001); i<x+1; i++) {
            cout << " " << i;
        }
    }
    if (k < 2) {cout << endl; return 0;}
    if (x+k-1 <= 1000000) {
        if (!first) {cout << " "; first = false;}
        cout << x+1;
        for (int i=2; i<k; i++) {
            cout << " " << x+i;
        }
    } else {
        if (!first) cout << " ";
        cout << x+1;
        for (int i=x+2; i<1000001; i++) {
            cout << " " << i;
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef vector<lint> vlint;
#define rep(i,n) for(lint i = 0;i < n;i++)
#define all(x) x.begin(),x.end()
#define clr(a) memset(a,0,sizeof(a))
lint maxi(lint a[],lint s){
    lint r = 0,max = 0;
    
    for(lint i = 1;i < s;i++){
        if(max < a[i]){
            max = a[i];
            r = i;
        }
    }
    return r;
}
lint emaxi(lint a[],lint s,lint e){
    lint max = 0;
    
    for(lint i = 1;i < s;i++){
        if(i == e)
            continue;
        if(max < a[i]){
            max = a[i];
        }
    }
    return max;
}
int main(void){
    lint n;
    cin >> n;
    lint* v1 = new lint[n/2];
    lint* v2 = new lint[n/2];
    rep(i,n/2){
        cin >> v1[i];
        cin >> v2[i];
    }

    lint a[100001] = {},b[100001] = {};
    rep(i,n/2){
        a[v1[i]]++;
        b[v2[i]]++;
    }
    
    bool one = true;
    lint xa = v1[0];
    rep(i,n/2){
        if(xa != v1[i] || xa != v2[i]){
            one = false;
            break;
        }
    }
    if(one){
        cout << n/2;
        return 0;
    }
    
    lint x = maxi(a,100001);
    lint y = maxi(b,100001);
    lint cntx = 0,cnty = 0;
    rep(i,n/2){
        if(x != v1[i])
            cntx++;
        if(y != v2[i])
            cnty++;
    }
    if(x == y){
        lint tx = n/2-emaxi(a,100001,x),ty = n/2-emaxi(b,100001,y);
        //cout << x << " " << y << "|" << tx << " " << ty << "|" << cntx << " " << cnty << endl;
        if(tx < ty)
            cntx = tx;
        else
            cnty = ty;
    }
    cout << cntx+cnty;
    return 0;
}
/*
ループ for(lint i = 0;i < N;i++)
ソート sort(a,a+N);
*/

Measured memory_bytes: 2560
import java.io.IOException;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author wijebandara
 */
public class Main {
    public static void main(String[] args) {
        try {
            java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
            
            String s =in.readLine();
            StringTokenizer st;
            while (s!=null) {
                st =new StringTokenizer(s);
                double a = Integer.parseInt(st.nextToken());
                double b = Integer.parseInt(st.nextToken());
                double c = Integer.parseInt(st.nextToken());
                double d = Integer.parseInt(st.nextToken());
                double e = Integer.parseInt(st.nextToken());
                double f = Integer.parseInt(st.nextToken());
                
                double y = (c*d-a*f)/(b*d-e*a);
                double x = (c*e-b*f)/(e*a-b*d);
                if(x==0.0)
                {
                    x=0.0;
                }
                if(y==0.0)
                {
                    y=0.0;
                }
                System.out.printf("%.3f %.3f\n",x,y);
                s =in.readLine();
            }
        } catch (Exception ex) {
            System.exit(0);
        }
        
    }
}

Measured memory_bytes: 17096
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

int main() {
  string s;
  cin >> s;
  if (s[0] == 'S') {
    if (s[1] == 'U') cout << 7 << endl;
    else cout << 1 << endl;
  }
  else if (s[0] == 'M') cout << 6 << endl;
  else if (s[0] == 'T') {
    if (s[1] == 'U') cout << 5 << endl;
    else cout << 3 << endl;
  }
  else if (s[0] == 'W') cout << 4 << endl;
  else cout << 2 << endl;


  
  return 0;
}

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

/*                          
---------------------------------------------------------------
Aditya Kumar mishra
---------------------------------------------------------------
*/

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define len(s) s.length()
#define forp(i, a, b) for (int i = a; i <= b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define ren(i, n) for (int i = n - 1; i >= 0; i--)
#define forn(i, a, b) for (int i = a; i >= b; i--)
#define on cout << endl
#define o2(a, b) cout << a << " " << b
#define os cout << " "
#define all(v) v.begin(), v.end()
#define mem(n, m) memset(n, m, sizeof(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define sii set<int>
#define us unordered_set<int>
#define um unordered_map<int, int>
#define sll set<long long>
#define vii vector<int>
#define vll vector<long long>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ret return 0
#define present(s, x) (s.find(x) != s.end())
#define cpresent(s, x) (find(all(s), x) != s.end())
#define ford(container, it) for (__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fors(container, it, a, b) for (__typeof(container.begin()) it = a; it != b; it++)

#define boost ios_base::sync_with_stdio(0)
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100001
#define SIZ 1000001
#define SIZE 200001

typedef long long ll;
typedef long double ldo;
typedef double db;
using namespace std;
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)

void c_p_c()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int main()
{
    c_p_c();
    ll a[101];
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int cnt = 0;
    if (n <= 2)
    {
        cout << 0 << endl;
    }
    else
    {

        for (int i = 0; i < n; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                for (int k = j + 1; k < n; k++)
                {
                    if ((a[i] != a[j] && a[j] != a[k] && a[k] != a[i]))
                    {
                        if (
                            a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[k] + a[j] > a[i])
                        {
                            cnt++;
                        }
                    }
                }
            }
        }
        cout << cnt << endl;
    }

    return 0;
}

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

int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  if((a==b && b!=c ) || (b==c && c!=a) || (c==a && a!=b))
  {
    cout << "Yes" << endl;
  }
  else 
  {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	ll a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22)
		cout<<"bust"<<endl;
	else
		cout<<"win"<<endl;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin


def input():
    return stdin.readline()[:-1]


def intput():
    return int(input())


def sinput():
    return input().split()


def intsput():
    return map(int, sinput())


# Code

n = intput()

a = list(intsput())

rgb = [0, 0, 0]

ans = 1
for i in range(n):
    x = a[i]
    cnt = 0
    placed = False
    for j in range(3):
        if rgb[j] == x:
            if not placed:
                rgb[j] += 1
                placed = True
            cnt += 1
        
    ans *= cnt
    ans %= 10 ** 9 + 7

print(ans)


Measured memory_bytes: 53356
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define IO std::ios::sync_with_stdio(false)
#define ll long long
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define INF 0x3f3f3f3f

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

int s,w;
signed main() {
  IO;
  cin >> s >> w;
  if(w >= s) cout << "unsafe" << '\n';
  else cout << "safe" << '\n';
  return 0;
}

Measured memory_bytes: 3668
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
 
#define sz(x) (int)(x.size())
#define fr(i,a,b) for(int i=a;i<b;++i)
#define fdr(i,a,b) for(int i=b-1;i>=a;--i)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
///////////////////////
 
ll const INF = 1e18;
 
void solve(){
	ll q, h, s, d;
	ll n;
	cin >> q >> h >> s >> d;
	cin >> n;
	n *= 4LL;
	h = min(h, 2 * q);
	s = min(s, 2 * h);
	d = min(d, s * 2);
	ll ans = 0;
	ans += (n / 8) * d;
	n %= 8;
	ans += (n / 4) * s;
	n %= 4;
	ans += (n / 2) * h;
	n %= 2;
	ans += (n / 1) * q;
	
	cout << ans << endl;
}
 
int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
 
	solve();
 
 
 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+9;
string st ;
int arr[N],frq[N];
ll t,a,b,c,m,n;
int main(){
    scanf("%d%d",&n,&m);

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

	int count=0;

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

		if(arr[i]>=ceil(c/(4.0*(double)m)))
			count++;

	}

	if(count>=m)
		cout<<"Yes";
	else
		cout<<"No";
        }





/**
5
2 3
10 10
2 4
7 4
9 3



*/




/**
  int power1(int b, int p){               //O(p)
    if(!p)  return 1;
    return b*power1(b, p-1);
  }
  int power2(int b, int p){               //O(Log(p))
    if(!p)  return 1;
    int ret = power2(b, p/2);
    return (p&1 ? ret*ret*b : ret*ret);
  }
   int mul(int a, int b, int m){
      return (a%m * b%m) % m;
  }

*/


/**
void seive()
{
    bitset<N>iscomp;
    iscomp[0]=iscomp[1]=1;
    for(long long i=2; i<=N; ++i)
    {
        if(!iscomp[i])
        {
            a.push_back(i);
            for(long long j=i*i; j<=N; j+=i)
                iscomp[j]=1;
        }
    }
}
3
abc
abc
*/


Measured memory_bytes: 256
<?php

$w = array(512, 256, 128, 64, 32, 16, 8, 4, 2, 1);
while (TRUE) {
    fscanf(STDIN, '%d', $n);
    if (feof(STDIN)) {
        break;
    }

    $list = array();
    foreach ($w as $v) {
        if ($n >= $v) {
            $list[] = $v;
            $n -= $v;
        }
    }
    $list = array_reverse($list);
    echo implode(' ', $list);
    echo PHP_EOL;
}



Measured memory_bytes: 9260
#include<iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  int a = N / 1000;
  int b = (N - 1000*a)/100;
  int c = (N - 1000*a - 100 * b)/10;
  int d = (N-1000*a - 100*b - 10*c);
  int count = 0;
  if(a == 2) count++;
  if(b == 2) count++;
  if(c == 2) count++;
  if(d == 2) count++;
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;


public class Main {

    static final int MOD = 1_000_000_007;
    public static long addMod(long a, long b){
    	long tmp = (a+b)%MOD;
    	return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long subMod(long a, long b){
    	return addMod(a,-b);
    }
    public static long multMod(long a, long b){
    	long tmp = (a*b)%MOD;
    	return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long powerMod(long a, long x){ //calculate a^x
        if(x<0)return 0;
        if(x==0)return 1;
        if(x%2==0) {
        	long half = powerMod(a,x/2);
        	return multMod(half,half);
        }
        return (a*powerMod(a,x-1)) % MOD;
    }
    public static long inverseMod(long a){
        return powerMod(a,MOD-2);
    }
    public static long divMod(long a, long b){
    	return multMod(a, inverseMod(b));
    }
    public static long[] makeFactorialArray(int size){
        long[] array = new long[size];
        array[0]=1;
        for(int i=1;i<size;i++){
        	array[i]=multMod(array[i-1],i);
        }
        return array;
    }
    public static long[] makeInversedArray(long[] original){
        long[] array = new long[original.length];
        for(int i=0;i<original.length;i++){
        	array[i] = inverseMod(original[i]);
        }
        return array;
    }
    public static long combination(int n, int r, long[] fact, long[] factInv){
        return multMod(fact[n], multMod(factInv[r],factInv[n-r]));
    }

    public static void main(String[] args) {
        long[] fact = makeFactorialArray(200001);
        long[] factInv = makeInversedArray(fact);
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(fact[N]);
    }
}


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

string s[10] = {
    "",
    ".,!? ",
    "abc",
    "def",
    "ghi",
    "jkl",
    "mno",
    "pqrs",
    "tuv",
    "wxyz"
};

char p(int n, int times) {
    return s[n][(times - 1) % (int)s[n].size()];
}

int main() {
    int N;
    cin >> N;
    string msg;
    while (N --) {
        cin >> msg;
        string t = "";
        for (int i=0; i<(int)msg.size(); ++i) {
            if (msg[i] == '0') {
                if (t != "") {
                    cout << p(t[0] - '0', t.size());
                    t = "";
                }
            } else {
                t += msg[i];
            }
        }
        cout << endl;
    }
    return 0;
}

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

int main() {
    int N;
    cin >> N;
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
      vec.at(i) = a;
  }
  sort(vec.begin(), vec.end());
  
  int A = 0;
  int B = 0;
  
  if(N % 2 == 0){
    int i =0;
    int C = 0;
  while (i < N / 2) {
    A += vec.at(N-i-1-C);

    B += vec.at(N-i-2-C);
    
    C++;
    i++;
  }
  
  }

    else if(N % 2 != 0){
    int i =0;
    int C = 0;
  while (i < N / 2) {
    A += vec.at(N-i-1-C);

    B += vec.at(N-i-2-C);
    
    C++;
    i++;
  }
      A +=vec.at(0);
  
    }
  
  cout << A - B << endl;
  
}


Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int f(int n) {
    return n * n;
}

int main(void) {
    int n;
    while (cin >> n) {
        int ans = 0;
        for (int i = 0; i * n < 600; i++) {
            ans += f(i*n) * n;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam))
  #-swank (set-dispatch-macro-character #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((x (read))
         (a (read)))
    (println (if (< x a) 0 10))))

#-swank(main)


;; For Test
#+swank
(defun io-equal (in-string out-string &optional (func #'main))
  "Passes IN-STRING to *STANDARD-INPUT*, executes FUNC, and checks the string
output to *STANDARD-OUTPUT* is equal to OUT-STRING."
  (labels ((ensure-last-lf (s)
             (if (and (> (length s) 0)
                      (eql (char s (- (length s) 1)) #\Linefeed))
                 s
                 (uiop:strcat s uiop:+lf+))))
    (equal (ensure-last-lf out-string)
           (with-output-to-string (out)
             (let ((*standard-output* out))
               (with-input-from-string (*standard-input* (ensure-last-lf in-string))
                 (funcall func)))))))

#+swank
(defun get-clipbrd ()
  (with-output-to-string (out)
    (run-program "C:/msys64/usr/bin/cat.exe" '("/dev/clipboard") :output out)))

#+swank (defparameter *this-pathname* (uiop:current-lisp-file-pathname))
#+swank (defparameter *dat-pathname* (uiop:merge-pathnames* "test.dat" *this-pathname*))

#+swank
(defun run (&optional thing (out *standard-output*))
  (let ((*standard-output* out))
    (etypecase thing
      (null ; Runs #'MAIN with the string on clipboard
       (with-input-from-string (*standard-input* (delete #\Return (get-clipbrd)))
         (main)))
      (string
       (with-input-from-string (*standard-input* (delete #\Return thing))
         (main)))
      (symbol (5am:run! thing))
      (pathname ; Runs #'MAIN with the string in a text file
       (with-open-file (*standard-input* thing)
         (main))))))

#+swank
(defun gen-dat ()
  (uiop:with-output-file (out *dat-pathname* :if-exists :supersede)
    (format out "")))

#+swank
(defun bench (&optional (out (make-broadcast-stream)))
  (time (run *dat-pathname* out)))


Measured memory_bytes: 14560