akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;

int L[MAX/2+2],R[MAX/2+2];

llong merge(int A[],int n,int left,int mid,int right)
{
  int i,j,k;
  llong cnt=0;
  int n1 = mid - left;
  int n2 = right - mid;
  for(i=0;i<n1;i++) L[i]=A[left+i];
  for(i=0;i<n2;i++) R[i]= A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  i=j=0;
  for(k=left;k<right;k++)
  {
    if(L[i]<=R[j])
    {
      A[k]=L[i++];
    }
    else
    {
      A[k]=R[j++];
      cnt += n1-i;
    }
  }
  return cnt;
}

llong mergeSort (int A[],int n,int left,int right)
{
  int mid;
  llong v1,v2,v3;
  if(left+1<right)
  {
    mid = (left+right)/2;
    v1 = mergeSort(A,n,left,mid);
    v2 = mergeSort(A,n,mid,right);
    v3 = merge(A,n,left,mid,right);
    return v1+v2+v3;
  }
  else
  return 0;
}

int main()
{
  int A[MAX],n,i;

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

  llong ans = mergeSort(A,n,0,n);
  cout << ans << endl;

  return 0;
}



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

int main(){
  int s;
  cin >> s;
  cout << s%100%10 + s/10%10 + s/100 << endl; 
  //cout << atoi(s[0]) + atoi(s[1]) + atoi(s[2]) << endl;
  //↑なんか使い物にならない。ctoiはコンパイラの都合で使えないらしい。
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int H, W, h, w;
	cin >> H >> W >> h >> w;

	if(H%h==0&&W%w==0){
		cout << "No" << endl;
		return 0;
	}

	int x, s;
	if(H%h==0){
		x = W;
		s = w;
	} else {
		x = H;
		s = h;
	}

	vector<int> xs;
	for(int i=0; i<x; i++){
		if(i%s==0) xs.push_back((x+s-1)/s);
		else if(i%s==s-1) xs.push_back(-(x+2*s-1)/s);
		else xs.push_back(0);
	}

	cout << "Yes" << endl;
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			cout << (H%h==0?xs[j]:xs[i]) << (j==W-1?'\n':' ');
		}
	} 


	return 0;
}


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

int main() {
  string s;
  cin >> s;
  int i;
  for (i = 0; i < s.length(); i++) {
    if (i % 2 == 0) {
      cout << s.at(i);
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<cmath>
#include<cstdio>
#include<set>
#include<map>
#include<iomanip>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++) 
#define lint long long
#define all(x) (x).begin(), (x).end()


int main(){
    int A,B; cin>>A>>B;
    if(B%A==0) cout<<(A+B)<<endl;
    else cout<<(B-A)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
  for ( ; ; ) {
    int h, w ;
    std::cin >> h >> w ;

    if ( h == 0 && w == 0 )
      return 0 ;

    for ( int i = 0 ; i < h ; ++i ) {
      for ( int j = 0 ; j < w ; ++j ) {
        if ( i == 0 || i == h - 1 || j == 0 || j == w - 1 )
          std::cout << "#" ;
        else
          std::cout << "." ;
      }
      std::cout << std::endl ;
    }
    std::cout << std::endl ;
  }

  return 0 ;
}

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
int main(){
  int num,n,c,i,k;
  char s[5];
  int data[4][14]={0};
  char mark[]="SHCD";
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%s",s);
    scanf("%d",&n);
    if(strcmp(s,"S")==0)c=0;
    else if(strcmp(s,"H")==0)c=1;
    else if(strcmp(s,"C")==0)c=2;
    else c=3;
    data[c][n]++;
  }
  for(i=0;i<4;i++){
    for(k=1;k<14;k++){
      if(!data[i][k])printf("%c %d\n",mark[i],k);
    }
  }
  return 0;
}

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

int main(void){
    int n;
    cin >> n;
    map<vector<int>, int> mp;

    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        vector<int> charnum(26,0);
        for(int i=0;i<10;i++){
            charnum[s[i]-'a']++;
        }
        mp[charnum]++;
    }

    ll ans = 0;
    for(auto p: mp){
        ll k = p.second;
        k *= k-1;
        ans += k/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 18944
#include <bits/stdc++.h>
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<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//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 SQ(a) ((a)*(a))
#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())
#define LB lower_bound
#define UB upper_bound

//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);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

LL Gcd(LL a, LL b) {
  if (a < b) {
    return Gcd(b,a);
  }
  if (b == 0) {
    return a;
  }
  else {
    return Gcd(b,a%b);
  }
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}


//-------------------------------------------

int main() {
  
  LL N, ans=INF;
  cin >> N;
  
  for(LL i = 1; i*i <= N; i++){
    if(N%i == 0){
      chmin(ans, (LL)SZ(toString(N/i)) );
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 384
W, B = map(int, input().split())

WHITE = "."
BLACK = "#"

base_row = (B // 50 + 1) * 2
GRID = [[WHITE if row < base_row else BLACK for _ in range(100)] for row in range(100)]

for i in range(B - 1):
    GRID[2 * (i // 50)][(i % 50) * 2] = BLACK

for i in range(W - 1):
    GRID[2 * (i // 50) + base_row + 1][(i % 50) * 2] = WHITE

print("100 100")
for row in GRID:
    for c in row:
        print(c, end='')
    print()


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    ll r;
    cin >> r;
    printf("%lld\n", 3 * r * r);

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

a.sort()
abs_a = [abs(x) for x in a]
minus = []

for x in a:
    if x < 0:
        minus.append(x)

tmp = sum(abs_a)

if len(minus) % 2 == 0:
    print(tmp)
else:
    print(tmp - min(abs_a)*2)

Measured memory_bytes: 19976
#include<stdio.h>
#include<iostream>
#include<climits>
using namespace std;
#define SIZE 100

class ExtendedLightsOut{
 public:
  char M[SIZE], P[SIZE], A[SIZE];
  bool solved;
  int min_value;

  bool check(){
    for ( int i = 0; i < SIZE; i++ ) if ( M[i] == '1' ) return false;
    return true;
  }

  void flipM( int pos ){ M[pos] = ( M[pos] == '0' ) ? '1' : '0'; }
  void flipP( int pos ){ P[pos] = ( P[pos] == '0' ) ? '1' : '0'; }

  void press( int pos ){
    int x, y, nx, ny;
    x = pos / 10;
    y = pos % 10;

    flipM( pos );
    flipP( pos );

    nx = x + 1;
    ny = y;
    if ( 0 <= nx && 0 <= ny && nx < 10 && ny < 10 ) flipM( nx*10 + ny );

    nx = x;
    ny = y + 1;
    if ( 0 <= nx && 0 <= ny && nx < 10 && ny < 10 ) flipM( nx*10 + ny );

    nx = x - 1;
    ny = y;
    if ( 0 <= nx && 0 <= ny && nx < 10 && ny < 10 ) flipM( nx*10 + ny );

    nx = x;
    ny = y - 1;
    if ( 0 <= nx && 0 <= ny && nx < 10 && ny < 10 ) flipM( nx*10 + ny );

  }

  bool recursive( int pos ){
    if ( pos == SIZE ) return check();

    if ( pos < 10 ){
      if ( recursive( pos + 1 ) ) return true;
      press( pos );
      if ( recursive( pos + 1 ) ) return true;
      press( pos );
    } else {
      int p = pos - 20;
      if ( p > 0 && M[p] == '1' ) return false;
      int v = pos - 10;
      if ( M[v] == '1' ) {
	press( pos );
	if ( recursive( pos + 1 ) ) return true;
	press( pos );
      } else {
	if ( recursive( pos + 1 ) ) return true;
      }
    }
    return false;
  }

  void print(){
    for ( int i = 0; i < 10; i++ ){
      for ( int j = 0; j < 10; j++ ){
	if ( j ) printf(" ");
	printf("%c", P[i*10+j] );
      }
      printf("\n");
    }
  }

  void work(){
    for ( int i = 0; i < SIZE; i++ ){
	P[i] = '0';
    }
    solved = false;
    min_value = INT_MAX;
    if ( recursive( 0 ) ){
      print();
    }else{
      cout << "NO SOLUTION" << endl;
    }
  }

  void read(){
    for ( int i = 0; i < SIZE; i++ ){
      cin >> M[i];
    }
  }
};

main(){
  ExtendedLightsOut ELO;
  int tcase;
  cin >> tcase;
  for ( int i = 1; i <= tcase; i++ ){
    ELO.read();
    ELO.work();
  }
}

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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	string S;
	cin >>S;
	int N=S.size();
	int k=(N-1)/2;
	char C=S.at(k);
	while ((k<N-1)&&(C==S.at(k+1))&&(C==S.at(N-k-2)))
		k++;
	cout <<k+1 <<endl;
	return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  rep(i, n) cin >> a[i];
  vector<long long> subSum(n);
  rep(i, n) {
    if(i == 0) subSum[i] = a[i];
    else subSum[i] = subSum[i-1] + a[i];
  }
  long long total = subSum[n-1];
  double half = (double)total / 2;
  auto it = upper_bound(subSum.begin(), subSum.end(), half);
  long long ans_1 = LLONG_MAX;
  long long ans_2 = LLONG_MAX;
  if(it != subSum.begin()) ans_1 = (half - *prev(it)) * 2;
  int dist = distance(subSum.begin(), it) + 1;
  long long limit = *it - dist;
  if((*it-half)*2<=limit) ans_2 = (*it-half) * 2;
  cout << min(ans_1, ans_2) << endl;
}

Measured memory_bytes: 3456
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

#define PI 3.14159265358979323846264338327950L

ll res;

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

    ll X,K,D;
    cin >> X >> K >> D;
    X = abs(X);

    ll straight = min(K, X / D);
    K -= straight;
    X -= straight * D;

    if (K % 2 == 0){
        cout << X << endl;
    } else {
        cout << D - X << endl;
    }
    return 0;
}

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

int combination(int m, int n, int a, int x) {
    if (a <= 1) {
        if (m <= x && x <= n) {
            return 1;
        } else {
            return 0;
        }
    }
 
    int c = 0;
    for (int i = m; (i <= n) && (i <= x); i++) {
        c = c + combination( i+1, n, a-1, x-i);
    }
    return c;
}



int main() {
    int n, x;
   
    while (1) {
        cin >> n >> x;
         
        if (n == 0 && x == 0) {
            return 0;
        } else {
            cout << combination( 1, n, 3, x) << endl;
        }
    }   
}

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

int two_max(int a, int b) {
	return a > b ? a : b;
}

int vector_max(vector<int> v) {
	int m = v.at(0);
	for (int i = 0; i < v.size(); i++) {
		m = two_max(m, v.at(i));
	}
	return m;
}

int main() {
	int K, N;
	cin >> K >> N;

	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
	}

	vector<int> B(N);
	for (int i = 0; i < N - 1; i++) {
		B.at(i) = A.at(i + 1) - A.at(i);
	}
	B.at(N - 1) = K - (A.at(N - 1) - A.at(0));

	cout << K-vector_max(B) << endl;
}

Measured memory_bytes: 2560
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N, M;
    scan(N, M);
    auto S = sread();
    DList!long route;
    long x = N;
    outer: while (true)
    {
        if (x - M <= 0)
        {
            route.insertFront(x);
            route.array.map!(text).join(' ').writeln();
            return;
        }
        foreach_reverse (m; 1 .. M + 1)
        {
            if (S[x - m] == '0')
            {
                x = x - m;
                route.insertFront(m);
                continue outer;
            }
        }
        writeln(-1);
        return;
    }
}


Measured memory_bytes: 8572
import java.util.Scanner

object Main extends App {
  def readALine(c:Int, ac:List[Int]):List[Int] =
    if (c > 0) readALine(c-1, sc.nextInt::ac) else ac.reverse
  def readLines(r:Int, c:Int, ac:List[List[Int]]):List[List[Int]] =
    if (r > 0) readLines(r-1, c, readALine(c, Nil)::ac) else ac.reverse
  val sc = new Scanner(System.in)
  val a, b = sc.nextInt

  val area = a*b
  val peri = 2*(a+b) 
  
  println(s"$area $peri")

}


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

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

    int b[n + 2] = {};
    int w[n + 2] = {};

    for (int i = 0; i < n; i++) {
        if (s[i] == '#') {
            b[i + 1] = b[i] + 1;
            w[i + 1] = w[i];
        } else {
            b[i + 1] = b[i];
            w[i + 1] = w[i] + 1;
        }
    }
    b[n + 1] = b[n];
    w[n + 1] = w[n];

    // for (int i = 0; i < n + 2; i++) {
    //     cout << b[i] << " ";
    // }
    // cout << endl;

    // for (int i = 0; i < n + 2; i++) {
    //     cout << w[i] << " ";
    // }
    // cout << endl;

    int ans = 2 * 1e5;
    for (int i = 0; i < n + 2; i++) {
        ans = min(ans, b[i] + (w[n + 1] - w[i]));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2180
# Fast IO (only use in integer input)

# TLE

import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

def main():

    N = int(input())
    Resident = []
    for i in range(N):
        x,y,p = map(int,input().split())
        Resident.append((x,y,p))

    minCost = [float("inf")] * (N+1)

    preCalRange = 1 << N

    horizontalLineDistance = []
    verticalLineDistance = []

    for i in range(preCalRange):
        railRoad = bin(i)[2:]
        railRoad = '0' * (N - len(railRoad)) + railRoad
        horizontalLineDistance.append([])
        verticalLineDistance.append([])
        for j in range(N):
            horizontalLineDistance[i].append(min(abs(Resident[j][0]),abs(Resident[j][1])))
            verticalLineDistance[i].append(min(abs(Resident[j][0]),abs(Resident[j][1])))
            for k in range(N):
                if railRoad[k] == '1' and abs(Resident[j][0] - Resident[k][0]) < horizontalLineDistance[i][j]:
                    horizontalLineDistance[i][j] = abs(Resident[j][0] - Resident[k][0])
                if railRoad[k] == '1' and abs(Resident[j][1] - Resident[k][1]) < verticalLineDistance[i][j]:
                    verticalLineDistance[i][j] = abs(Resident[j][1] - Resident[k][1])

    power2 = [1]
    for i in range(N):
        power2.append(power2[-1] * 2)
    loopCount = power2[N]
    for i in range(loopCount):
        numNewRailroad = bin(i)[2:].count('1')
        j = i
        while j >= 0:
            j &= i
            goodList1 = horizontalLineDistance[j]
            goodList2 = verticalLineDistance[i - j]
            cost = 0
            for k in range(N):
                cost += Resident[k][2] * min(goodList1[k], goodList2[k])
            if minCost[numNewRailroad] > cost:
                minCost[numNewRailroad] = cost
            j -= 1
    for elem in minCost:
        print(elem)

main()

Measured memory_bytes: 90488
let calc (n: int) =
    // 端数切り捨てで考えると該当する数 x は n \leq x * 1.08 < n + 1 をみたす
    let orig = (n |> float) / 1.08 |> ceil |> int
    if ((orig |> float) * 1.08) |> int = n then (orig |> string) else ":("

//let input = [| 432; 1079; 1001 |]
//for i in input do calc i |> printfn "%s"
// expected 400; :(; 927

[<EntryPoint>]
let main argv =
    let n = stdin.ReadLine() |> int
    calc n |> printfn "%s"
    0


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

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

int main()
{
    string ss;
    cin >> ss;
    map<char,ll> m;
    for(ll i = 0; i < ss.size(); i++) m[ss[i]]=1;
    for(char i='a'; i <='z';  i++)
    {

        if(m[i]==0)
        {

            cout << i;
            return 0;
        }
    }
    cout << "None";
}


Measured memory_bytes: 512
A = int(input())
B = int(input())
C = int(input())
X = int(input())

result = 0
for i in range(0, A+1):
    for j in range(0, B+1):
        for k in range(0, C+1):
            coins = 500 * i + 100 * j + 50 * k
            if coins == X:
                result += 1

print(result)

Measured memory_bytes: 9196
#include <iostream>

using namespace std;
using ll = long long;

ll gcd(ll a, ll b) {
    if(a == b || b == 0) return a;
    else return gcd(b , a % b);
}

int main() {
    int N; cin >> N;
    ll A[100000] = {};

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

    ll eucrid = A[0];
    for(int i = 0; i < N; i++) {
        if(eucrid > A[i]) {
            eucrid = gcd(eucrid, A[i]);
        } else {
            eucrid = gcd(A[i], eucrid);
        }
    }

    cout << eucrid << endl;
}


Measured memory_bytes: 1400
import math
import queue
R,C = list(map(int,input().split(" ")))


gx=C -1
gy=R - 1
mass = [input() for _ in range(R)]
tejun =[ [-1 for i in range(C)] for j in range(R)]
xy = [(1,0),(0,1),(-1,0),(0,-1)]
q = queue.Queue()
q.put((0,0))
tejun[0][0] = 0
while True:
    if q.empty():
        break
    x,y = q.get()
    if x == gx and y == gy:
        break
    for go in xy:
        xmove,ymove = go
        if 0<=x + xmove < C and 0<=y + ymove < R and mass[y + ymove][x+xmove] != "#":
           if tejun[y + ymove ][x + xmove ] == -1:
               tejun[y + ymove][x + xmove]  = tejun[y][x] + 1
               q.put((x + xmove,y + ymove))
if tejun[gy][gx] == -1:
    print(-1)
    exit()

sharp = 0
for temp in mass:
    sharp+= temp.count("#")
ans = R*C -(sharp + (tejun[gy][gx] + 1))
print(ans)

Measured memory_bytes: 3952
# coding: utf-8
# Your code here!
# coding: utf-8
import sys
sys.setrecursionlimit(200000000)


# my functions here!

#入力

def pin(type=int):
    return map(type,input().rstrip().split())

def resolve():
    K,S=pin()
    ans=0
    for x in range(K+1):
        for y in range(K+1):
            if S-(x+y)>=0 and S-(x+y)<=K:
                ans+=1
    print(ans)
    
"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 2"""
        output = """6"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """5 15"""
        output = """1"""
        self.assertIO(input, output)
if __name__=="__main__":resolve()

Measured memory_bytes: 5608
N,M = map(int,input().split())
pro = [0 for i in range(N+1)]
ac,wa = 0,0
for i in range(M):
    p,s = input().split()
    p = int(p)
    if s == 'AC':
        if pro[p] != -1:
            ac += 1
            wa += pro[p]
            pro[p] = -1
    else:
        if pro[p] != -1:
            pro[p] += 1
print(ac,wa)


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

const ll INF = LLONG_MAX/3;

ll dp[50][410][410];

int main(){
	ll N, Ma, Mb;
	cin >> N >> Ma >> Mb;
	vector<ll> a(N), b(N), c(N);
	REP(i, N) cin >> a[i] >> b[i] >> c[i];

	REP(i, 40)REP(j, 401)REP(k, 401) dp[i][j][k] = INF;
	dp[0][0][0] = 0;
	dp[0][a[0]][b[0]] = c[0];
	REP(i, N)REP(j, 401)REP(k, 401){
		if(dp[i][j][k]>=INF) continue;
		dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
		if(j+a[i+1]>400||k+b[i+1]>400) continue;
		dp[i+1][j+a[i+1]][k+b[i+1]] = min(dp[i+1][j+a[i+1]][k+b[i+1]], dp[i][j][k]+c[i+1]);
	}

	/*
	REP(i, 10){
		REP(j, 10){
			cout << dp[N-1][i][j] << " ";
		}
		cout << endl;
	}
	*/

	ll res = INF;
	REP(i, 401)REP(j, 401){
		if(i==0||j==0) continue;
		if(i*Mb==j*Ma) res = min(res, dp[N-1][i][j]);
	}
	if(res==INF){
		cout << -1 << endl;
	}else{
		cout << res << endl;
	}
    return 0;
}

Measured memory_bytes: 55552
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

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

    ll x, k, d;
    cin >> x >> k >> d;

    ll curr = x;

    ll req = abs(x) - 0;
    req /= d;

    ll t = min(k, req);
    k -= t;

    if (x < 0)
        x += d * t;
    else
        x -= d * t;

    if (k % 2 == 0)
    {
        cout << abs(x) << endl;
    }
    else
    {
        cout << min(abs(x - d), abs(x + d)) << endl;
    }
}

Measured memory_bytes: 3644
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
#include<string.h>
#include <cmath>
#include <iomanip>
using namespace std;
#define inf 1000000007
#define int long long
#define rep(i,j,n) for(int i=j;i<n;++i)
typedef pair<int,int>  P;
string alph("abcdefghijklmnopqrstuvwxyz");
struct edge{int from,to,cost;};
vector<edge> G;
double pi = 3.141592653589793;
P sg[10];
int a[55],b[55];
int n,m;
int d[16][16];
int dp[1<<16][16];
int  solve(int s,int v){
    if(dp[s][v]>=0)return dp[s][v];
    if(s==(1<<n)-1&&v==0)return dp[s][v]=0;
    int res=inf;
    rep(u,0,n){
        if(!(s>>u&1)){
            res=min(res,solve(s|1<<u,u)+d[v][u]);
        }
    }
    return dp[s][v]=res;
}

signed main(){
cin>>n>>m;
    rep(i,0,n)rep(j,0,n)d[i][j]=inf;
    rep(i,0,m){
        int a,b,c;cin>>a>>b>>c;
        d[a][b]=c;
    }
    memset(dp,-1,sizeof(dp));
    int h=solve(0,0);
    if(h==inf)cout<<-1<<endl;
    else cout<<h<<endl;
    return 0;
}


Measured memory_bytes: 11408
#include <iostream>
using namespace std;
main () {
	int r, g, b, result;
	cin>>r>>g>>b;
	result = (r*100) + (g*10) + b;
	if (result % 4 == 0)
	{
		cout<<"YES"<<endl;
	} else {
		cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <ctime>

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>

using namespace std;

// defines
#define rep(i, N) for (i=0;i<(N);i++)
#define sqr(x) (x) * (x)
#define all(v) (v.begin(), v.end())
#define pb push_back
#define random (rand() << 16 ^ rand())

// Typedefs
typedef pair<int, int> ii;

// constants
const int64_t inf = 1e18+7;
const int64_t mod = 1e9+7;

const int MAXN = 1001;

int64_t dp[MAXN][MAXN][8];
int s[MAXN][MAXN];

int64_t *V[3];

int main() {
	int N, M;
	int i, j, k, l;

	cin >> N >> M;

	rep(i, N+1) rep(j, M+1) rep(l, 8) dp[i][j][l] = -inf;
	rep(i, N+1) rep(l, 8) dp[i][0][l] = 0LL;
	rep(k, 3) V[k] = new int64_t[N];
	rep(i, N) cin >> V[0][i] >> V[1][i] >> V[2][i];

	for (i=1;i<=N; i++) {
		for (j=1; j<=M; j++) {
			for (l=0; l<8; l++) {
				int64_t here = dp[i-1][j-1][l];

				for (k=0;k<3;k++) {
					if (l & (1<<k)) here += V[k][i-1];
					else here -= V[k][i-1];
				}

				dp[i][j][l] = max(dp[i-1][j][l], here);
			}
		}
	}

	int64_t ans = -inf;
	for (l=0;l<8;l++) {
		ans = max(ans, dp[N][M][l]);
	}

	cout << ans << endl;

	return 0;
}


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

int N;

int main(){
    cin>>N;
    int d[N];
    for(int i=0;i<N;i++){
        cin>>d[i];
    }
    int sum=0;
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            sum+=d[i]*d[j];
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    H,W = (int(_) for _ in input().split())
    ans = []
    ans.append('#'*(W+2))
    for i in range(H):
        a = input().rstrip()
        a = '#' + a + '#'
        ans.append(a)
    ans.append('#'*(W+2))
    print('\n'.join(ans))
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN 2*int(1e5)+5
#define endl '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<ll, ll> pii;
const ll mod = 1e9+7;

ll dp[1005][10005];

int n;
vector<pii> vet;

ll solve(ll i, ll h) {
	if(h <= 0) return 0;
	if(i == n) return LINF;
	ll &ans = dp[i][h];
	if(ans != LINF) return ans;
	return ans = min(solve(i+1, h), solve(i, h-vet[i].f)+vet[i].s);
}

int main(){
	int h;
	cin >> h >> n;
	vet.resize(n);
	for(pii &i : vet)
		cin >> i.f >> i.s;
	for(int i = 0; i < 1005; i++)
		for(int j = 0; j < 10005; j++)
			dp[i][j] = LINF;
			
	cout << solve(0, h) << endl;

}


Measured memory_bytes: 79360
def split(word): 
    return [char for char in word]  
n=int(input())
a=list(map(int,input().split()))
blist=[]
for i in range(20):
  blist.append(0)
ans=0
finalbad=0
for i in range(n):
  s='{0:08b}'.format(a[i])
  maxclash=0
  for j in range(20-len(s),20):
    if s[j-(20-len(s))]=='1':
      if blist[j]>maxclash:
        maxclash=blist[j]
      blist[j]=i+1
  if maxclash>finalbad:
    finalbad=maxclash
  ans+=i+1-finalbad
print(ans)
  

Measured memory_bytes: 25684
object Main extends App {
    val sc = new java.util.Scanner(System.in)

    val a,b = sc.nextLong

    println(lcm(a,b))
    
    def gcd(x:Long,y:Long):Long = if (y > 0) gcd(y,x%y) else x
    def lcm(x:Long,y:Long):Long = x/gcd(x,y) * y
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li a[200200];
li b[200200];
li n;

inline bool chk(li x) {
    rep(i, 2 * n + 1) {
        if (a[i] >= x)b[i] = 1;
        else b[i] = 0;
    }
    //dump(b, 2 * n + 1);
    li ll, rr;
    li dll, drr;

    for (li l = n; l >= 1; --l) {
        if (b[l] == b[l - 1]) {
            ll = b[l];
            dll = n - l;
            break;
        }
    }
    for (li r = n; r <= 2 * n - 1; ++r) {
        if (b[r] == b[r + 1]) {
            rr = b[r];
            drr = r - n;
            break;
        }
    }
    //p4(dll, ll, drr, rr);
    if (dll < drr) {
        return ll == 1;
    } else {
        return rr == 1;
    }
}


int main() {
    cin >> n;
    rep(i, n * 2 - 1) {cin >> a[i + 1];}
    a[0] = a[1];
    a[2 * n] = a[2 * n - 1];

    li l = 0, r = n * 2;
    while (l + 1 < r) {
        li mid = (l + r) / 2;
        //p3(l, r, mid);
        if (chk(mid)) {
            l = mid;
        } else {
            r = mid;
        }
    }
    cout << l << endl;

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define INF (int)1e8
#define EPS 1e-9

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

int main() {
  int N, x;
  cin >> N >> x;
  vi a(N);
  rep(i, N) cin >> a[i];

  int res = 0;
  sort(all(a));
  rep(i, N) {
    if (x <= 0) break;
    x -= a[i];
    res++;
  }
  if (x != 0) res--;
  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

//===
template<typename Monoid, typename OP = function<Monoid(Monoid, Monoid)> >
struct SegmentTree {
    //    using OP = function<Monoid(Monoid, Monoid)>;
    
    vector<Monoid> tree;
    int size;
    const OP merge_monoid; // bin' operation
    const Monoid e; // neutral element
                                           
    SegmentTree(int nmemb, const Monoid &e, const OP &f):
        size(nmemb), merge_monoid(f), e(e)
    {
        tree.assign(size << 1, e);
    }

    inline void update(int k, Monoid dat) {
        k += size;
        tree[k] = dat;
        
        while(k > 1) {
            k >>= 1;
            tree[k] = merge_monoid(tree[(k << 1)], tree[(k << 1) | 1]);
        }
    }

    // [l, r)
    inline Monoid fold(int l, int r) {
        l += size; //points leaf
        r += size;

        Monoid lv = e;
        Monoid rv = e;
        while (l < r) {
            if (l & 1) lv = merge_monoid(lv, tree[l++]);
            if (r & 1) rv = merge_monoid(tree[--r], rv);

            l >>= 1;
            r >>= 1;
        }

        return merge_monoid(lv, rv);
    };

    inline Monoid operator[] (const int k) const {
        return tree[k + size];
    };
};
//===

SegmentTree<llong> sum(3005, 0,
                           [](auto l, auto r){return l + r;});
llong n;
llong l[2005];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> l[i];
        sum.update(l[i], sum[l[i]] + 1);
    }

    llong ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            llong a = l[i];
            llong b = l[j];
            sum.update(a, sum[a] - 1);
            sum.update(b, sum[b] - 1);

            llong l = max({0ll, a - b, b - a});
            llong r = a + b;

            ans += sum.fold(l + 1, r);
            
            sum.update(a, sum[a] + 1);
            sum.update(b, sum[b] + 1);
        }
    }

    ans /= 3;
    cout << ans << endl;

    return 0;
}


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

#define phb push_back

using namespace std;

typedef vector< int > Row;
typedef vector< Row > Matrix;

int N, M, A, B, C, T;
int S[50], res[50];

void read();
void soups_on();
Matrix mul(Matrix &, Matrix &);

int main() {
  while (cin >> N >> M >> A >> B >> C >> T, N)
    read(), soups_on();

  return 0;
}

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

void soups_on() {
  Matrix base, mtrx;

  mtrx = base = Matrix(N, Row(N, 0));
  for (int i = 0; i < N; ++i)
    mtrx[i][i] = 1;

  for (int i = 0; i < N; ++i) {
    if (i > 0) base[i][i - 1] = A;
    base[i][i] = B;
    if (i + 1 < N) base[i][i + 1] = C;
  }

  for (int q = 30; q >= 0; --q) {
    mtrx = mul(mtrx, mtrx);
    if (T & 1 << q)
      mtrx = mul(mtrx, base);
  }

  fill(&res[0], &res[N], 0);
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < N; ++j)
      res[i] += mtrx[i][j] * S[j], res[i] %= M;

  for (int i = 0; i < N; ++i) {
    if (i > 0) cout << " ";
    cout << res[i];
  }

  cout << "\n";
}

Matrix mul(Matrix &ma, Matrix &mb) {
  Matrix mr(N, Row(N, 0));
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < N; ++j)
      for (int k = 0; k < N; ++k)
        mr[i][j] += ma[i][k] * mb[k][j], mr[i][j] %= M;
  return mr;
}

Measured memory_bytes: 1264
S = input()
#revS = S[::-1]
ls = len(S)
cur_num = 0
cur_r = 0
r = [0]*ls
ans = 0
for i in range(ls):
    if i == 0:
        r[i] = (int(S[ls-i-1])*pow(10,i,2019))%2019
    else:
        r[i] = r[i-1] + (int(S[ls-i-1])*pow(10,i,2019))%2019
        r[i] %= 2019
#print(r)
from collections import Counter
c = Counter(r)

#print(c)
ans = 0
c[0] += 1
for k,v in c.items():
    # if k == 0:
    #     pass
    if v >= 2:
        ans += v*(v-1)//2
print(ans)

Measured memory_bytes: 70340
N = int(input())
a = [int(e) for e in input().split()]

mul4 = len([e for e in a if e % 4 == 0])
mul2 = len([e for e in a if e % 2 == 0])

if mul4 >= N // 2 or mul2 == N or mul2 - mul4 >= N - mul4 * 2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14252
a=[[[0]*10 for _ in range(3)] for _ in range(4)]
for _ in range(int(input())):
 b,f,r,v=map(int,input().split())
 a[b-1][f-1][r-1]+=v
for i in range(4):
 for j in range(3):
  print(' ',end='')
  print(*a[i][j])
 if i!=3:print('#'*20)

Measured memory_bytes: 5620
module don_t_be_late;

import std.stdio;

void main(string[] args)
{
    float d, t, s;
    readf("%f %f %f\n", &d, &t, &s);
    if (d / s <= t)
    {
        writeln("Yes");
    }
    else
    {
        writeln("No");
    }
}


Measured memory_bytes: 2800
#include <iostream>
using namespace std;
int a(int x,int y){
	int s=1;
	for(int i=0;i<y;i++)
	{
		s*=x;
	}
	return s;
}
int main()
{
	int x;
	cin>>x;
	int s=1;
	for(int i=2;i*i<=x;i++)
	{
		int q=2;
		while(a(i,q)<=x)
		{
			q++;
		}
		s=max(s,a(i,q-1));
	}
	cout<<s;
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define LL long long

LL F[3005],C[3005];
int n,s;
int A[3005];
int mo = 998244353;

int main(){
	
	scanf("%d%d",&n,&s);
	for ( int i = 1; i <= n; i++ ) scanf("%d",&A[i]);
	
	LL ans = 0;
	for ( int i = 1; i <= n; i++ ){
		
		for ( int j = s- A[i]; j >= 0; j-- ){
			F[j+A[i]] += F[j];
			F[j+A[i]] %= mo;
		}
		
		F[A[i]] += i;
		F[A[i]] %= mo;
		
		LL lo = F[s];
		ans = ( ans + lo) % mo;
//		cout << C[s] << " " << F[s] << " " << ans << " " << diff << endl;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
//%std
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out = 0, fh = 1;
	char jp = getchar();
	while ((jp > '9' || jp < '0') && jp != '-')
		jp = getchar();
	if (jp == '-')
		fh = -1, jp = getchar();
	while (jp >= '0' && jp <= '9')
		out = out * 10 + jp - '0', jp = getchar();
	return out * fh;
}
const int N = 2e5 + 10;
int t[N];
int main()
{
	int n = read();
	for (int i = 1; i < n; ++i)
		t[read()]++;
	for (int i = 1; i <= n; ++i)
		printf("%d\n", t[i]);
	return 0;
}


Measured memory_bytes: 4476
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main() {
  int64_t N, M, K;
  cin >> N >> M >> K;

  vector<int64_t> a(N + 1, 0), b(M + 1, 0);
  rep(i, N) { cin >> a[i + 1]; }
  rep(i, M) { cin >> b[i + 1]; }

  rep(i, N) { a[i + 1] += a[i]; }
  rep(i, M) { b[i + 1] += b[i]; }

  int result = 0;
  irep(i, N) {
    if (K >= a[i]) {
      int j = upper_bound(b.begin(), b.end(), K - a[i]) - b.begin() - 1;
      result = max(result, (int)i + j);
    }
  }
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 6044
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    vector<int> v;
    int tmp;
    REP(i, 5) {
        cin >> tmp;
        v.push_back(tmp);
    }

    int res = 100001;
    do {
        int tot = 0;
        REP(i, 5) {
            if (tot % 10 != 0) {
                tot += 10 - (tot % 10);
            }
            tot += v[i];
        }
        res = min(res, tot);
    } while (next_permutation(v.begin(), v.end()));

    cout << res << endl;

    return 0;
}

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

manzokudo = sum(B)
i1 = 0
i2 = 0
for idx, i in enumerate(A):
  if idx == 0:
    i1 = i
  else:
    i2 = i1
    i1 = i
    if i1 - i2 == 1:
      manzokudo += C[i2 - 1]
print(manzokudo)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <limits.h>
using namespace std;
int main()
{
	int k, n, s, t, i = 0, j, maxV = INT_MIN, A[30] = {};
	while (cin >> k) {
		if (0 == k)break;
		A[i++] = k;
		if (maxV < k)
			maxV = k;
	}
	s = maxV + 1;
	vector<long> vP(s, 0);
	int c = 0;
	for (k = 2; k < s; ++k){
		if (vP[k] == 0)
			vP[k] = ++c;
		else if (vP[k] == -1)
			vP[k] = c;
		t = (s - 1) / k;
		for (j = 2; j <= t; ++j)
			vP[j * k] = -1;
	}
	for (j = 0; j < i; ++j)
		cout << vP[A[j]] << "\n";
	return 0;
}

Measured memory_bytes: 8984
Scanf.scanf "%d" (fun n ->
    let a = Array.init n (fun _ -> Scanf.scanf " %f" (fun f -> f)) in
    let m = Array.fold_left ( *.) 1. a in
    let g = Array.fold_left (fun acc v -> acc +. m /. v) 0. a in
    Printf.printf "%.6f\n" @@ m /. g
)

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

int main() {
	string s;cin >> s;
	
	while(s.size()>=2){
		s= s.substr(0,s.size()-2);
		int hsize=s.size()/2;
		string suba = s.substr(0,hsize);
		string subb = s.substr(hsize,hsize);
		if(suba==subb){
			break;
		} 
	}
	cout << s.size() << endl;
	return 0;
}

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

int main() {
  ll N;
  ll k = 0;
  ll sum = 2000000000000;
  cin >> N;
  while ((k+1) * (k+1) <= N) {
    k++;
  }
  
  for (int i = 0; i < k; i++) {
    if (N % (i+1) == 0) {
      sum = min(sum, i+1 + N / (i+1) - 2);
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

def main():
    n,m,x=L()
    understand=[0]*m
    book=[[0]*m for i in range(n)]
    price=[]*m
    for i in range(n):
        tmp=L()
        price.append(tmp[0])
        for j in range(m):
            book[i][j]=tmp[j+1]
    ans=1e+12
    for bit in range(1<<n):
        sum=0
        understand=[0]*m
        for i in range(n):
            if bit&(1<<i):
                sum+=price[i]
                for j in range(m):
                    understand[j]+=book[i][j]
        flag=True
        for i in range(m):
            if understand[i]<x:
                flag=False
        if flag:
            ans=min(ans,sum)
    if ans==1e+12:
        ans=-1
    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9268
import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as C

x ? (a,b) = if x then a else b

main = do
 n <- getLine
 putStr $ (solve n)?("Yes","No")

solve :: String -> Bool
solve [] = True
solve [a] = False
solve s@(a:b:x)
 | take 2 s == "hi" = solve x
 | otherwise = False


Measured memory_bytes: 380
import numpy as np
from collections import Counter


def solve(string):
    n, *a = map(int, string.split())
    table = np.array([True] * (10**6 + 1))
    ma = max(a)
    for _a in a:
        if table[_a]:
            table[2*_a:ma + 1:_a]=False
    i = np.array([k for k,v in Counter(a).items() if v==1],dtype=np.int)
    return str(table[i].sum())


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 57628
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] H = new int[n];
        int[] dp = new int[3];
        Arrays.setAll(H, i -> Integer.parseInt(sc.next()));
        dp[1] = Math.abs(H[1] - H[0]);
        for(int i = 2; i < n; i++) {
            dp[i % 3] = Math.min(dp[(i-1) % 3] + Math.abs(H[i] - H[i-1]),
                            dp[(i-2) % 3] + Math.abs(H[i] - H[i-2]));
        }
        System.out.println(dp[(n-1) % 3]);
    }
}


Measured memory_bytes: 47104
#include<bits/stdc++.h>
#define N 100005
using namespace std;
char s[N];
int a[N];
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	int ans=n;s[0]='0';
	for(int i=1;i<=n;i++)
	{
		if(s[i]!=s[i-1])
		{
			ans=min(ans,max(i-1,n-i+1));
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll wa,wb,sa,sb,lim,sum;
  cin >> wa >> wb >> sa >> sb >> lim >> sum;
  vec w,s;
  for(ll i=0;i*wa*100<=sum;i++) {
    for(ll j=0;(i*wa+j*wb)*100<=sum;j++) {
      if(i==0&&j==0) continue;
      w.push_back(i*wa+j*wb);
    }
  }
  for(ll i=0;i*sa<=sum;i++) {
    for(ll j=0;i*sa+j*sb<=sum;j++) {
      s.push_back(i*sa+j*sb);
    }
  }
  sort(w.begin(),w.end());
  sort(s.begin(),s.end());
  ll as=0,aw=w[0];
  for(ll i=0;i<w.size();i++) {
    for(ll j=0;j<s.size();j++) {
      if(w[i]*lim<s[j]||w[i]*100+s[j]>sum) break;
      if(as*w[i]<s[j]*aw) {
        as=s[j];
        aw=w[i];
      }
    }
  }
  cout << aw*100+as << " " << as << endl;
}

Measured memory_bytes: 2420