akhauriyash/Code-Regression huggingface dataset:
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 count = 0;
        int max = 0;
        for (int i = 0 ; i < N ; i++) {
            H[i] = sc.nextInt();
            if (max < H[i]) max = H[i];
        }
        int[][] HN = new int[max][N];
        for (int i = 0; i < max; i++) {
            for (int j = 0; j < N ; j++) {
                if (0 < H[j]) {
                    HN[i][j] = 1;
                    H[j]--;
                } else HN[i][j] = 0;
            }
        }
        for (int[] line : HN) {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < line.length; i++) {
                if (i == 0 && line[0] != 0) sb.append(line[i]);
                else if (0 < i && line[i] != line[i-1]) sb.append(line[i]);
                else continue;
            }
            count += sb.toString().split("0").length;
        }
        System.out.println(count);
    }
}

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

const ll m = 1000000007;

int main(){
    int k;
    cin >> k;
    string ans = "";
    rep(i, k){
        ans += "ACL";
    }
    cout << ans << endl;
}

Measured memory_bytes: 3544
A = Array.new(3) { gets.split.map(&:to_i) }
N = gets.to_i
B = readlines.map(&:to_i)

res = A.flatten.map {|n| B.include?(n) }.each_slice(3).to_a
ans = 'No'
ans = 'Yes' if res.any? {|a| a.all? }
ans = 'Yes' if res.transpose.any? {|a| a.all? }
ans = 'Yes' if res[0][0] && res[1][1] && res[2][2]
ans = 'Yes' if res[0][2] && res[1][1] && res[2][0]
puts ans

Measured memory_bytes: 1788
import java.util.*;

class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                sc.nextLine();
                String[] list = new String[52];
                for(int i = 0; i < 26; i++){
                        list[i] = f(i, 0, "that");
                        list[26+i] = f(i, 0, "this");
                }   
                while(n-- > 0){ 
                        String s = sc.nextLine();
                        String[] _s = s.split(" ");
                        int a = 0;
                        int b = 0;
                        l1:for(String tmp: _s){
                                if(tmp.length() == 4){ 
                                        for(int i = 0; i < 52; i++){
                                                for(int j = 0; j < 26; j++){
                                                        if(tmp.equals(f(1,j,list[i]))){
                                                                a = i%26;
                                                                b = j;
                                                                break l1; 
                                                        }   
                                                }   
                                        }   
                                }   
                        }   
                        System.out.println(_f(a,b,s));
                }   
                sc.close();
        }   
        static String f(int a, int b, String s){
                String tmp = ""; 
                for(int i = 0; i < s.length(); i++){
                        tmp += fb(b, fa(a, s.charAt(i)));
                }   
                return tmp;
        }   
        static char fa(int a, char c){
                return (char)((c-'a')*a%26+'a');
        }   
        static char fb(int b, char c){
                return (char)(((c-'a')+b+26)%26+'a');
        }   
        static String _f(int a, int b, String s){ 
                String tmp = ""; 
                for(int i = 0; i < s.length(); i++){
                        char c = s.charAt(i);
                        if(c != ' '){
                                c = fb(-b, c); 
                                char _c = 'a';
                                while(fa(a, _c)!=c){
                                        _c++;
                                }   
                                c = _c; 
                        }   
                        tmp += String.valueOf(c);
                }   
                return tmp;
        }   
}

Measured memory_bytes: 0
/*
    ##############################
    #  Author: Pratyush Gaurav   #
    #  College: NIT ROURKELA     #
    ##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

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

void solve() {
    string s;
    cin >> s;
    lli pos = 0, ans = 0;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == 'W') {
            ans += i - pos;
            pos += 1;
        }
    }
    cout << ans << endl;
}

int main()
{
    IOS;
    lli t = 1;
    //cin >> t;

    while(t--)
        solve();
    return 0;
}


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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
long double a, b ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>a>>b ;
	return cout<<fixed<<setprecision(0)<<floor(a*b)<<"\n" , 0 ;
}		

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

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

  int mat[100][100];
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      mat[i][j]=0;

  for(int i=0;i<n;i++){
    int u, k;
    cin >> u >> k;
    for(int i=0;i<k;i++){
      int v;
      cin >> v;
      mat[u-1][v-1]=1;
    }
  }

  for(int i=0;i<n;i++){
    cout << mat[i][0];
    for(int j=1;j<n;j++)
      cout << ' ' << mat[i][j];
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3112
use std::vec::Vec;
use std::cmp;
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let (n, m) = {
      let v: Vec<usize> = read_vec();
      (v[0], v[1])
    };

    let mut a: Vec<u64> = read_vec();
    a.sort_by(|a, b| b.cmp(&a));
    let mut dp: Vec<MatchNumber> = vec![MatchNumber {length: 0, number: Vec::new()}; n+1];
    let mut mtchs = vec![0; n+1];

    for i in 1..n+1 {
      for &e in &a {
        if i < f(e)  {
          continue;
        }
        else {
          if mtchs[i - f(e)] + f(e) != i {
            continue;
          }
          else {
            mtchs[i] = i;
            let mut m = dp[i - f(e)].clone();
            m.push(e);
            dp[i] = cmp::max(dp[i].clone(), m);
          }
        }
      }
    }


    for &e in  &dp[n].number {
      print!("{}", e);
    }
    println!("");
}

fn f(x: u64) -> usize {
  match x {
    1 => 2,
    2 => 5,
    3 => 5,
    4 => 4,
    5 => 5,
    6 => 6,
    7 => 3,
    8 => 7,
    9 => 6,
    _ => std::usize::MAX/2
  }
}




#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Debug)]
struct MatchNumber {
  length: i64,
  number: Vec<u64>,
}

impl MatchNumber {
  pub fn new() -> MatchNumber {
    MatchNumber {length: 0, number: Vec::new()}
  }

  fn push(&mut self, c: u64) {
    self.length += 1;
    self.number.push(c);
  }


}


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

#define MAX 20

int main(void)
{
    char in[MAX + 1];
    scanf("%s", in);
    int len = strlen(in);

    int i;
    char out[MAX + 1];
    for (i = 0; i < len; i++) {
        out[i] = in[len - i - 1];
    }
    out[i] = '\0';

    printf("%s\n", out);

    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>//復習必須
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
int main () {
    string s ;
    cin >> s;
    int flag = 1;

    for (int i = s.size() - 1; i >= 2; i--){
        if (i > 3 && (s[i] == 'e' && s[i - 1] == 's' && s[i - 2] == 'a' && s[i - 3] == 'r' && s[i - 4] == 'e'))
        {
            i -= 4;
        }
        else if (i > 3 && (s[i] == 'm' && s[i - 1] == 'a' && s[i - 2] == 'e' && s[i - 3] == 'r' && s[i - 4] == 'd'))
        {
            i -= 4;
        }
        else if (i > 4 && (s[i] == 'r' && s[i - 1] == 'e' && s[i - 2] == 's' && s[i - 3] == 'a' && s[i - 4] == 'r' && s[i - 5] == 'e'))
        {
 
            i -= 5;
        }
        else if (i > 5 && (s[i] == 'r' && s[i - 1] == 'e' && s[i - 2] == 'm' && s[i - 3] == 'a' && s[i - 4] == 'e' && s[i - 5] == 'r' && s[i - 6] == 'd'))
        {
            i -= 6;
        }
        else
        {
            flag = 0;
            break;
        }
    }
    if (flag)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
    return 0 ;
}

 


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	map<int,int> t;
	int ret=0;
	for (int i=1; i<=n; i++)
		cin>>t[i], ret+=t[i];
	int m; cin>>m;
	while(m--) {
		int p,x; cin>>p>>x;
		cout << ret-t[p]+x << endl;
	}
	return 0;
}


Measured memory_bytes: 256
A,B,H,M=gets.split.map(&:to_i)

r_hour=(H*(360/12))+(M*0.5)
r_minute=(M*(360/60))

angle=[(r_hour-r_minute).abs,360-r_hour+r_minute,360-r_minute+r_hour].min

p Math.sqrt((A**2)+(B**2)-(2*A*B*(Math.cos(angle/180*Math::PI))))

Measured memory_bytes: 14728
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <iterator>
using namespace std;

struct AboutTo;

class Node{
public:
	int aa;
	int Lowest;
	bool IsSelected;
	vector<AboutTo> ToCollection;
	Node(){
		Lowest = 2147483647;
		IsSelected = false;
	}
	void Reset(){
		Lowest = 2147483647;
		IsSelected = false;
	}
};
struct AboutTo{
	Node* To;
	int Cost;
	int Time;
};

int GetShortest(const int a,const Node GoalNode, vector<Node> &aNodeCol, const int IsTime){
	aNodeCol[a].IsSelected = true;
	int TempMin = 2147483647;
	int aNode;
	for (auto i = aNodeCol.begin(); i != aNodeCol.end(); ++i){
		if ((*i).IsSelected){
			for (auto j = (*i).ToCollection.begin(); j != (*i).ToCollection.end(); ++j){
				if (!(*((*j).To)).IsSelected){
					if (IsTime){
						if (TempMin>(*i).Lowest + (*j).Time){
							TempMin = (*i).Lowest + (*j).Time;
							aNode = (*((*j).To)).aa;
						}
					}
					else{
						if (TempMin>(*i).Lowest + (*j).Cost){
							TempMin = (*i).Lowest + (*j).Cost;
							aNode = (*((*j).To)).aa;
						}
					}
				}
			}
		}
	}
	aNodeCol[aNode].Lowest = TempMin;
	if (aNode != GoalNode.aa){	
		return GetShortest(aNode, GoalNode, aNodeCol, IsTime);
	}
	return TempMin;
}

int main(){
	while (true){
	int n, m;
	cin >> n >> m;
	if (n == 0 && m == 0)break;
		vector<Node> NodeCollection;
		for (int i = 0; i < m; ++i){
			Node aNode;
			aNode.aa = i;
			NodeCollection.push_back(aNode);
		}
		for (int i = 0; i < n; ++i){
			int a, b, cost, time;
			cin >> a >> b >> cost >> time;
			NodeCollection[a - 1].ToCollection.push_back({ &NodeCollection[b - 1], cost, time });
			NodeCollection[b - 1].ToCollection.push_back({ &NodeCollection[a - 1], cost, time });
		}
		/*
		12 9
		1 2 5 5
		2 3 4 4
		3 6 3 10
		6 9 1 1
		9 8 7 6
		8 7 4 3
		7 4 2 1
		4 1 10 14
		2 5 7 8
		5 8 9 10
		4 5 9 9
		5 6 10 1
		*/
		int k;
		cin >> k;
		for (int i = 0; i < k; ++i){
			int p, q, r;
			cin >> p >> q >> r;
			NodeCollection[p - 1].Lowest = 0;
			if (p == q){cout << 0 << endl;
			}
			else{
				cout << GetShortest(p - 1, NodeCollection[q - 1], NodeCollection, r) << endl;
			}
			for (auto i = NodeCollection.begin(); i != NodeCollection.end(); ++i){
				(*i).Reset();
			}
		}
		
	}
	return 0;
}

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

#define pb            push_back
#define mp            make_pair
#define ins           insert
#define endl          '\n'
#define all(x)        x.begin(),x.end()
#define debug(X)      { cerr<<endl<<(#X)<<" = "<<(X)<<endl; }
//#define cerr if(0)cerr

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    vi a(3,0);
    bool ok=1;

    cin>>a[0]>>a[1]>>a[2];
    sort(all(a));
    
    if (a[0]==a[1] && a[1]!=a[2]) ok=0;
    if (a[1]==a[2] && a[0]!=a[1]) ok=0;

    cout<<(ok?"No":"Yes")<<endl;
}



Measured memory_bytes: 256
namespace ABC123_B
{
    using System;
    using static System.Console;
    using System.Linq;
    using System.Collections.Generic;
    class Program
    {
        static void Main(string[] args)
        {
            var _list = new List<int>();
            for (int i = 0; i < 5; i++)
            {
                _list.Add(ReadInput());
            }
            var nodivd = _list.Where(x => x % 10 != 0).ToList();
            var divd = _list.Where(x => x % 10 == 0).ToList();
            nodivd.Sort((a, b) => b % 10 - a % 10);
            divd.AddRange(nodivd);
            var total = divd
                .Select(
                (x, i) =>
                {
                    if (i < 4)
                    {
                        return x % 10 != 0 ? Math.Ceiling(x / 10.0) * 10 : x;
                    }
                    else
                    {
                        return x;
                    }
                }
                ).Sum();
            WriteLine(total);
        }
        static int ReadInput()
        {
            return int.Parse(ReadLine());
        }

    }

}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
class UnionFind {
public:
    vector < ll > par; // 各元の親を表す配列
    vector < ll > siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1);
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};
#define MAXN 100001
bool ne[MAXN];
int main() {
    int n, m;
    cin >> n >> m;
    UnionFind tree(n);
    for (int i = 1; i <= m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        tree.merge(x - 1, y - 1);
    }
    memset(ne, false, sizeof(ne));
    for (int i = 0; i < n; i++) {
        ne[tree.root(i)] = true;
    }
    int ret = 0;
    for (int i = 0; i < n; i++) {
        if (ne[i]) {
            ret++;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 4828
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
ll gcd(ll a, ll b){
  if(b==0) return a;
  else gcd(b,a%b);
}
ll lcm(ll a, ll b){
  return a/gcd(a,b)*b;
}
int main(){
  int n;
  string s;
  int ans=1;
  cin >> n >> s;
  rep(i,n-1){
    if(s[i]!=s[i+1])ans++;
  }
  
  cout <<ans << endl;
  return 0;
}


Measured memory_bytes: 512
//ABC135C
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}

int main(void){
	int n;
	scanf("%d",&n);
	int a[n], b[n];
	int i;
	//データの読み込み5
	
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++){
		b[i] = a[i];
	}
	quick_sort(a,0,n-1);
	for(i=0;i<n;i++){
		if(b[i] == a[n-1]){
			printf("%d\n",a[n-2]);
		}else{
			printf("%d\n",a[n-1]);
		}
	}
	return 0;
}

Measured memory_bytes: 3072
s=input();sl=len(s)
t=['01'*(sl//2),'10'*(sl//2)]
a,b=0,0
if sl%2:
	t[0]+='0';t[1]+='1'
for i,j,k in zip(s,t[0],t[1]):
	if i==j: a+=1
	if i==k: b+=1
print(min(a,b))

Measured memory_bytes: 3444
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    MOD = 10**9 + 7
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    K = NI()
    S = SI()
    LS = len(S)

    f = [1] * (K+LS)
    r = [1] * (K+LS)
    c = 1
    for i in range(1, K + LS):
        c = (c * i) % MOD
        f[i] = c
        r[i] = pow(c, MOD - 2, MOD)

    def comb(n, k):
        return (f[n] * r[k] * r[n - k]) % MOD

    ans = 0
    for i in range(K+1):
        ans = (ans + pow(25,i,MOD) * pow(26,K-i,MOD) * comb(i+LS-1,LS-1)) % MOD
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 103924
/*
 * Matheus Oliveira
 * 08:51:15 02/05/2020
 * a.cpp
*/

#include <bits/stdc++.h>
using namespace std;

#define EPS
#define INF
#define MAXN
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define sc(x) scanf("%d", &x);
#define sc2(x, y) scanf("%d %d", &x, &y);
#define sc3(x, y, z) scanf("%d %d %d", &x, &y, &z);
#define debug(x) printf("%s: %d\n", #x, x);
#define debugarr(x, bg, ed) printf("%s: ", #x); for(int i = bg; i < ed; i++) printf("%d%c", x[i], (i == ed-1) ? '\n' : ' ');

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

int main() {
	int k, a, b, aux;

	scanf("%d", &k);
	scanf("%d %d", &a, &b);
	
	bool ok = false;
	aux = k;
	
	while(aux <= b) {
		if(aux >= a) {
			if(aux%k == 0) ok = true;
		}
		aux += k;
	}

	if(ok) printf("OK\n");
	else printf("NG\n");

	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<queue>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

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

using namespace std;

typedef long long ll;

#define MAX 100010
string S,T;
int Q,a[MAX],b[MAX],c[MAX],d[MAX];

const string alpha = "AB";
int sumS[2][MAX]; // 0 -> A, 1 -> B
int sumT[2][MAX]; // 0 -> A, 1 -> B

void init_sumST() {
  rep(i,(int)S.size()) {
    rep(j,2) {
      if( i ) sumS[j][i] = sumS[j][i-1];
      if( alpha[j] == S[i] ) ++sumS[j][i];
    }
  }
  rep(i,(int)T.size()) {
    rep(j,2) {
      if( i ) sumT[j][i] = sumT[j][i-1];
      if( alpha[j] == T[i] ) ++sumT[j][i];
    }
  }
}

void compute() {
  init_sumST();
  rep(i,Q) {
    ll SA,SB;
    SA = sumS[0][b[i]];
    if( a[i] - 1 >= 0 ) SA -= sumS[0][a[i]-1];
    SB = sumS[1][b[i]];
    if( a[i] - 1 >= 0 ) SB -= sumS[1][a[i]-1];
    ll miniS = SA + SB * 2LL;
    
    ll TA,TB;
    TA = sumT[0][d[i]];
    if( c[i] - 1 >= 0 ) TA -= sumT[0][c[i]-1];
    TB = sumT[1][d[i]];
    if( c[i] - 1 >= 0 ) TB -= sumT[1][c[i]-1];
    ll miniT = TA + TB * 2LL;
    if( miniS % 3LL == miniT % 3LL ) puts("YES");
    else puts("NO");
  }
}

int main() {
  cin >> S >> T >> Q;
  rep(i,Q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    --a[i], --b[i], --c[i], --d[i];
  }
  compute();
  return 0;
}


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

int main(){
    int S,tmpa=0,cnt=0;
    int ans = 0;
    cin >> S;
    vector<int> a(1000000,0);
    a[0] = S; 
    while (1)
    {
        if (a[cnt]%2==0)
        {
            a[cnt+1] = a[cnt]/2;
        }
        else
        {
            a[cnt+1] = 3*a[cnt]+1;
        }
        
        for (int i = 0; i < cnt; i++)
        {
            tmpa = a[i];
            if (a[cnt]==tmpa)
            {
                ans = cnt+1;
                break;
            }
        }
        
        if (ans!=0)
        {
            break;
        }
        
    cnt++;
    }
  cout << ans;
}

Measured memory_bytes: 4096
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    q,h,s,d=map(int,input().split())
    n=int(input())

    h=min(h,2*q)
    s=min(s,2*h)
    d=min(d,2*s)

    if(n&1):
        print(d*(n//2)+s)
    else:
        print(d*(n//2))
resolve()

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

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


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

  int n;
  cin >> n;
  string s;
  cin >> s;
  set<int> pos[10];
  rep(i,n){
    int a = s[i] - '0';
    pos[a].insert(i);
  }
  int ret = 0;
  rep(i,10){
    if(pos[i].size() == 0)continue;
    rep(j,10){
      if(pos[j].size() == 0)continue;
      rep(k,10){
        int l = *pos[i].begin();
        int r = *pos[j].rbegin();
        if(l >= r)continue;
        if(pos[k].upper_bound(l) != pos[k].end()){
          int ml = *pos[k].upper_bound(l);
          if(ml < r){
            ret++;
          }
        }
      }
    }
  }
  cout << ret << endl;
}


Measured memory_bytes: 1664
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let l: usize = sc.read();
    let a: f64 = l as f64 / 3.0;
    println!("{:.10}", a * a * a);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}
pub mod utils {
    const DYX: [(isize, isize); 8] = [
        (0, 1),   //right
        (1, 0),   //down
        (0, -1),  //left
        (-1, 0),  //top
        (1, 1),   //down right
        (-1, 1),  //top right
        (1, -1),  //down left
        (-1, -1), //top left
    ];

    pub fn try_adj(y: usize, x: usize, dir: usize, h: usize, w: usize) -> Option<(usize, usize)> {
        let ny = y as isize + DYX[dir].0;
        let nx = x as isize + DYX[dir].1;
        if ny >= 0 && nx >= 0 {
            let ny = ny as usize;
            let nx = nx as usize;
            if ny < h && nx < w {
                Some((ny, nx))
            } else {
                None
            }
        } else {
            None
        }
    }
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int N,pos[2][2000],dp[2001][2001],cum[2][2001][4001];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N;
    F0R(i,2*N) {
        char x; int y; cin >> x >> y; y--;
        int t = (x == 'B');
        pos[t][y] = i;
        //cout << "ZZ " << t << " " << y << " " << i+1 << "\n";
        F0R(j,y+1) cum[t][j][i+1] ++;
    }
    F0R(i,2) F0R(j,N+1) FOR(k,1,2*N+1) cum[i][j][k] += cum[i][j][k-1];
    
    //cout << cum[0][0][6] << "\n";
    F0R(i,N+1) F0R(j,N+1) dp[i][j] = MOD;
    dp[0][0] = 0;
    F0R(i,N+1) F0R(j,N+1) {
        if (i != N) dp[i+1][j] = min(dp[i+1][j],dp[i][j]+cum[0][i][pos[0][i]]+cum[1][j][pos[0][i]]);
        if (j != N) dp[i][j+1] = min(dp[i][j+1],dp[i][j]+cum[0][i][pos[1][j]]+cum[1][j][pos[1][j]]);
    }
    
    cout << dp[N][N];
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 78464
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	long long n, m;
	cin >> n >> m;

	long long c_pairs = m / 2;
	long long ans = 0;
	long long x = min(n, c_pairs);
	ans += x;
	n -= x;
	c_pairs -= x;
	if (!n) {
		ans += c_pairs / 2;
	}

	cout << ans << "\n";

	return 0;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    //cout << max(0, min({B - A, D - C, B - C})) << endl;
    cout << max(0, min(B, D) - max(A, C)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

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

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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))

bool IsPrime(int);

/***** MAIN *****/
signed main() {
  string sample[] = {"SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
  string s;
  cin >> s;
  REP(i, 7) {
    if(s == sample[i]) {
      cout << i+1;
      break;
    }
  }
  cout << "\n";
  return 0;
}
/***** MAIN *****/

bool IsPrime(int a) {
  if(a <= 1) return false;
  if(a == 2) return true;
  if(a%2 == 0) return false;
  for(int i = 3; i*i <= a; i+=2) {
    if(a%i==0) return false;
  }
  return true;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fore(x,a,b) for(int x=a, qwerty=b; x<qwerty; x++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define pb push_back
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fst first
#define snd second
#define mset(a,v) memset((a),(v),sizeof(a))
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
using namespace std;
typedef long long ll;
const int N=200500;
int n;
int a[512];
ll dp[512][512],sp[512][512];
ll f(int i, int j){
}
int main(){FIN;
	cin>>n;
	fore(i,0,n)cin>>a[i];
	fore(i,0,n)dp[i][i]=0;
	fore(i,0,n)fore(j,i,n){
		ll s=0;fore(k,i,j+1)s+=a[k];
		sp[i][j]=s;
	}
	fore(l,1,n){
		fore(i,0,n){
			int j=min(i+l,n-1);
			if(i==j)continue;
			ll &r=dp[i][j];
			r=dp[i][i]+dp[i+1][j]+a[i]+sp[i+1][j];
			fore(k,i+1,j)r=min(r,dp[i][k]+dp[k+1][j]+sp[i][k]+sp[k+1][j]);
		}
	}
	cout<<dp[0][n-1]<<"\n";
}

Measured memory_bytes: 3968
import numpy as np
N = int(input())
A = list(map(int,input().split()))
A.sort()
lenA = len(A)
while(True):
    minA = 1000000001
    for i in range(lenA):
        if A[i] != 0:
            if minA > A[i]:
                minA = A[i]
                idx = i

    for i in range(lenA):
        if i != idx:
            A[i] %= minA
    
    if A.count(0) == N-1:
        break

A.sort()
print(A[-1])


Measured memory_bytes: 23120
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int N, C;
  int s,t,c;
  int maxt = 0;
  vector<pair<int,int> > vec[30];
  
  scanf("%d%d",&N,&C);

  for(int i=0;i<N;i++){
    scanf("%d%d%d",&s,&t,&c);
    c--;
    vec[c].push_back({s,t});
    maxt = max(maxt, t);
  }

  vector<pair<int,int> > vv;

  for(int i=0;i<C;i++){
    sort(vec[i].begin(), vec[i].end());

    int l = -1, r=-1;
    
    for(int j=0;j<vec[i].size();j++){
      if(r == vec[i][j].first){
        r = vec[i][j].second;
      } else {
        if(l != -1) vv.push_back({l,r});
        l = vec[i][j].first;
        r = vec[i][j].second;
      }
    }

    if(l != -1) vv.push_back({l,r});    
  }

  int sum[SIZE] = {};
  
  for(int i=0;i<vv.size();i++){
    sum[vv[i].first-1]++;
    sum[vv[i].second]--;
  }

  int ans = 0;

  for(int i=0;i<=maxt;i++){
    sum[i+1] += sum[i];
    ans = max(ans, sum[i]);
  }

  printf("%d\n",ans);
  return 0;
}



Measured memory_bytes: 2676
// Abhinav -- organize and stay in moment
#include <bits/stdc++.h>
using namespace std; 
#define ff first
#define ss second
using namespace std;
#define MP make_pair
#define pb push_back
#define ll long long
#define int long long
#define f(i,x,n) for(int i=x;i<n;i++)
#define ld long double
#define mod 1000000007
int x,y,d;
void gcd(int a,int b){
	if(b==0){
		d=a;
		x=1;
		y=0;
		return ;
	}
	gcd(b,a%b);
	int X,Y;
	X=y;
	Y=x-(a/b)*y;
	x=X;  y=Y;
}
int a,b,c,m; 
int exp(int a,int b){
	m=b+1;
	int res=1;
	while(b!=0){
		if(b&1){
			res*=a;
			res%=m;
		}
		b/=2;
		a*=a; a%=m;
	}
	return res;
}
void prime(){
	int n; cin>>n;
	if(n<2){
		cout<<"composite\n";
		return ;
	}else if(n==2){
		cout<<"prime\n";
		return ;
	}else if(n%2==0){
		cout<<"composite\n";
		return ;
	}else {
		for(int i=3;i*i<=n;i+=2){
			if(n%i==0){
				cout<<"composite\n";
				return ;
			}
		}
		cout<<"prime\n";
	}
}
void toutient(int n) {
    vector<int> phi(n + 1);
    phi[0] = 0;
    phi[1] = 1;
    for (int i = 2; i <= n; i++)
        phi[i] = i - 1;

    for (int i = 2; i <= n; i++)
        for (int j = 2 * i; j <= n; j += i)
              phi[j] -= phi[i];
	cout<<phi[n];
}
int pr[1000005];
int dig(int a){
	int s=0;
	while(a!=0){
		s+=(a%10);
		a/=10;
	}
	return s;
}
int ans[1000005];
vector<int> vp;
void seive(){
	pr[0]=pr[1]=1;
	for(int i=2;i<1000005;++i){
		if(pr[i]==0){
			vp.pb(i);
			for(int j=2*i;j<1000005;j+=i){
				pr[j]=1;
			}
		}
	}
}
int fpp(int a){
	int r=0;
	while(a%2==0){
		a/=2; ++r;
	}
	return r;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b,c; cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
int main()
{
	int color[8] = {0, 0, 0, 0, 0, 0, 0, 0};
	int specialcolor = 0;
	int N;
	std::cin >> N;
	for(int i = 0; i < N; i++)
	{
		int c;
		std::cin >> c;
		if(1 <= c && c <= 3199)
		{
			color[c / 400]++;
		}
		else
		{
			specialcolor++;
		}
	}
	int min = 0;
	for(int i = 0; i < 8; i++)
	{
		min += color[i] > 0 ? 1 : 0;
	}
	if(min != 0)
	{
		std::cout << min << ' ' << min + specialcolor << std::endl;
	}
	else
	{
		std::cout << 1 << ' ' <<  specialcolor << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int N,M,i,place;
    int mas[1001],go[1001];

    while(scanf("%d%d",&N,&M),N+M){

    for(i=1;i<=N;i++){
        scanf("%d",&mas[i]);
    }
    for(i=1;i<=M;i++){
        scanf("%d",&go[i]);
    }

    place=1;

    for(i=1;i<=M;i++){
        place+=go[i];
        place+=mas[place];
        if(place>=N){
            break;
        }
    }
    printf("%d\n",i);
}

    return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>

int main(){
    int N,a,b;
    std::string s;
    std::cin >> a >> b >> N;
    if(a+b>=N){
        std::cout << "Yes" << std::endl;
    }else{  
    std::cout << "No" << std::endl;

    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=3025;
char str[maxn],c[maxn];
int dp[maxn][maxn];
int main(){
    scanf("%s",str+1);
    scanf("%s",c+1);
    int len=strlen(str+1),lens=strlen(c+1);
    for(int i=len;i>=1;i--){
        for(int j=lens;j>=1;j--){
            if(str[i]==c[j])dp[i][j]=dp[i+1][j+1]+1;
            else dp[i][j]=max(dp[i+1][j],dp[i][j+1]);
        }
    }
    int l=1,r=1;
    while(l<=len&&r<=lens){
        if(str[l]==c[r]){
            printf("%c",str[l]);
            l++,r++;
        }
        else if(dp[l][r]==dp[l+1][r])l++;
        else r++;
    }
    printf("\n");
    return 0;
}

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

using namespace std;

int main()
{
	stack<int> si;
	char str[10010];
	for(int i=0;(str[i]=getchar())!='\n'?true:(str[i]=0,false);i++);
	for(int i=0;i<strlen(str);i++)
	{
		//printf("%d\n",i);
		if(isdigit(str[i]))
		{
			int t;
			sscanf(&str[i],"%d",&t);
			si.push(t);
			while(isdigit(str[i])) i++;
		}
		else if(str[i]=='+')
		{
			int s1=si.top();si.pop();
			int s2=si.top();si.pop();
			si.push(s1+s2);
			i++;
		}
		else if(str[i]=='-')
		{
			int s1=si.top();si.pop();
			int s2=si.top();si.pop();
			si.push(s2-s1);
			i++;
		}
		else if(str[i]=='*')
		{
			int s1=si.top();si.pop();
			int s2=si.top();si.pop();
			si.push(s1*s2);
			i++;
		}
	}
	printf("%d\n",si.top());
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i=0;i<N;i++){
    cin >> vec.at(i);
  }
  int count=0;
  for (int i=0;i!=1;i=vec.at(i)-1){
    count++;
    if (count==N){
      count=-1;
      break;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 640
program sandglass
  implicit none
  integer :: x, k, q, a(100000), tt(200000,2), ans(100000), i
  integer :: tlft, trit, alft, arit, t0, t1, s
  logical :: rev
  a = 0
  tt = 0
  ans = 0
  read(*,*) x
  read(*,*) k
  read(*,*) tt(1:k,1)
  read(*,*) q
  do i = 1, q
    read(*,*) tt(k+i,1), a(i)
    tt(k+i,2) = i
  end do
  call merge_sort(tt(1:k+q,1:2))
  tlft = 0
  trit = x
  alft = 0
  arit = x
  rev = .false.
  t0 = 0
  do i = 1, k+q
    t1 = tt(i,1)
    s = tt(i,2)
    alft = alft-(t1-t0)
    if (alft.lt.0) then
      tlft = tlft-alft
      if (tlft.gt.x) tlft = x
      alft = 0
    end if
    arit = arit-(t1-t0)
    if (arit.lt.0) then
      trit = trit+arit
      if (trit.lt.0) trit = 0
      arit = 0
    end if
    if (tlft.ge.trit) then
      if (rev) then
        tlft = trit-1
        if (tlft.lt.0) tlft = 0
      else
        trit = tlft+1
        if (trit.gt.x) trit = x
      end if
    end if
    t0 = t1
    if (s.eq.0) then
      rev = .not.rev
      alft = x-alft
      arit = x-arit
      cycle
    end if
    if (a(s).le.tlft) then
      ans(s) = alft
    else if (a(s).ge.trit) then
      ans(s) = arit
    else
      ans(s) = a(s)-tlft+alft
      if (rev) ans(s) = -a(s)+tlft+alft
    end if
    if (rev) ans(s) = x-ans(s)
  end do
  do i = 1, q
    write(*,'(i0)') ans(i)
  end do
  stop
contains
  subroutine merge_sort(c)
    implicit none
    integer, intent(inout) :: c(:,:)
    integer :: n, m, l, u, i
    n = size(c(:,1))
    m = n
    l = 1
    do while (m.gt.1)
      do i = 1, m/2
        u = min(2*i*l,n)
        call merger(c(2*(i-1)*l+1:(2*i-1)*l,:),c((2*i-1)*l+1:u,:))
      end do
      l = 2*l
      m = (m+1)/2
    end do
    return
  end subroutine merge_sort
  subroutine merger(c1,c2)
    implicit none
    integer, intent(inout) :: c1(:,:), c2(:,:)
    integer :: c(size(c1(:,1))+size(c2(:,1)),size(c2(1,:)))
    integer :: i1, i2, n1, n2
    i1 = 1
    i2 = 1
    n1 = size(c1(:,1))
    n2 = size(c2(:,1))
    do while ((i1.le.n1).and.(i2.le.n2))
      if (c1(i1,1).le.c2(i2,1)) then
        c(i1+i2-1,:) = c1(i1,:)
        i1 = i1+1
      else
        c(i1+i2-1,:) = c2(i2,:)
        i2 = i2+1
      end if
    end do
    if (i1.le.n1) then
      c(i1+i2-1:n1+n2,:) = c1(i1:n1,:)
    else if (i2.le.n2) then
      c(i1+i2-1:n1+n2,:) = c2(i2:n2,:)
    end if
    c1 = c(1:n1,:)
    c2 = c(n1+1:n1+n2,:)
    return
  end subroutine merger
end program sandglass

Measured memory_bytes: 5236
#include<cstdio>
#include<iostream>
#include<vector>
#include<tuple>
#include<queue>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>

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

using namespace std;

int main(int argc, char* argv[]){
  long long int X;
  long long int M = 100;
  long long int ans = 0;
  cin >> X;

  while (M < X){
    M = M * 1.01;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
#define uint unsigned int
#define ushort unsigned short
#define ulong unsigned long

ll MOD = 10e9 + 7;
int match_value[10] = {0, 2, 5 ,5 ,4 ,5 ,6 ,3 ,7 ,6};
int dp[10001];

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> use_match(m);
    REP(i, m) cin >> use_match[i];
    /*sort(use_match.begin(), use_match.end(), [&](int x, int y) -> int {
        return match_value[x] < match_value[y]; 
    });*/
    sort(use_match.begin(), use_match.end(), greater<int>());
    REP(i, n+1) dp[i] = INT_MIN;
    dp[0] = 0;
    for(int i=1; i<=n; i++) {
        REP(j, m) {
            int index = i-match_value[use_match[j]];
            if (index >= 0) dp[i] = max(dp[i], dp[index]+1);
        }
    }
    string res;
    while(n > 0) {
        REP(i, m) {
            if (n-match_value[use_match[i]] < 0) continue;
            if (dp[n-match_value[use_match[i]]] == (dp[n]-1)) {
                res += to_string(use_match[i]);
                n -= match_value[use_match[i]];
                break;
            }
        }
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
   if ( (abs(a-b) <=d &&  abs(b-c) <= d ) || (abs(a-c) <=d ) ){
    cout << "Yes"  << endl;
   }
  else{
    cout << "No"  << endl;
  }

}

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

int main(){
    long long a, b, k;
    cin >> a >> b >> k;

    long long temp = min(a, k);
    a -= temp;
    k -= temp;
    
    b -= min(b, k);
    cout << a << " " <<  b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<pr> vp;
typedef vector<vp> vpp;
typedef vector<vector<ll> > graph;
#define pb push_back
#define mp make_pair
#define endl '\n'
void set_val(vector<ll>& v, ll val){for(ll i=0;i<v.size();i++) v[i]=val;}

ll mod = pow(10,9) + 7;
ll modulo = 998244353;
double pi = 3.141592653589793238;
ll i_mov[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
ll j_mov[8] = {1, 1, 1, 0, -1, -1, -1, 0};


ll power(ll a, ll n)
{
    if(n==0)
    return 1;
    ll temp = power(a,n/2);
    if(n%2==0)
    return (temp*temp)%mod;
    return (((temp*temp)%mod)*a)%mod;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout<<setprecision(10);
    ll n, m;
    cin>>n>>m;
    vector<ll> a(n);
    ll g = a[0];
    int count = 0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        a[i]/=2;
        if(a[i]&1 == 1)
        count++;
        
    }
    ll l = a[0];
    for(int i=1;i<n;i++)
    {
        g = __gcd(l, a[i]);
        l = (l*a[i])/g;
        // cout<<g<<" "<<l<<endl;
        if(l>m)
        {
            l = -1;
            break;
        }
    }
    // cout<<l<<endl;
    if(l==-1)
        cout<<0;
    else if(count == n)
    cout<< (m/l + 1)/2;
    else if(count == 0)
    {
      for(int i=0;i<n;i++)
      {
        if((l/a[i])%2 == 0)
        {
          l = -1;
          break;
        }
      }
      if(l==-1)
        cout<<0;
      else
        cout<< (m/l + 1)/2;        
    }
    else
    cout<<0;
    
    
    
} 

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
static const int l = 10000;

int main(){
    string s, t; cin >> s >> t;
    bool ans = false;
    for ( int i = 0; i < s.size(); ++i){
        if(s == t){
            ans = true;
            break;
        }
        s = s.back() + s.substr(0, s.size() - 1);
    }
    if (ans) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

Map = []
M = []
for _ in range(H):
    M.append(input())
Map = [list(i) for i in M]
tmpH = [2**h for h in range(H)]
tmpW = [2**w for w in range(W)]

#print(Map)
########################

numH = 2**H
numW = 2**W
count = 0
result = 0

for nh in range(numH):
    for nw in range(numW):
        for h_id in range(len(tmpH)):
            for w_id in range(len(tmpW)):
                if tmpH[h_id] & nh == 0 and tmpW[w_id] & nw == 0 and Map[h_id][w_id] == '#':
                    count += 1
        if count == K:
            result += 1
        count = 0

print(result)

Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define gap cout<<endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(int i=0;i<n;i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())


int main(){
	int n;
	cin>>n;
	map<pair<int,int>,int> mp;
	FOR(i,1,n){
		string tmp=to_string(i);
		if(tmp[sz(tmp)-1]=='0') continue;
		if(tmp[0]=='0') continue;
		int first=tmp[0]-'0';
		int last=tmp[sz(tmp)-1]-'0';
		mp[{first,last}]++;
	}
	ii first;
	ii second;
    int ans=0;
    
	for(auto i:mp){
		for(auto j:mp){
			first=i.first;
			second=j.first;
			//dbg2(first.first,first.second);
			if(first.first==second.second&&second.first==first.second){
			   //dbg2(first.first,first.second);
			   //dbg2(second.first,second.second);
			 ans+=(i.second*j.second);
			    
			}

		}
	}
	cout<<ans<<endl;
}

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

int main(void) {
  int K;
  cin >> K;
  int ans = 0;
  for (int i = 1; i <= K; i++) {
    for (int j = 1; j <= K; j++) {
      for (int k = 1; k <= K; k++) {
        ans += __gcd(__gcd(i, j), k);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3652
H, W = map(int, input().split())
mapp = (['.' * (W + 2)]
        + ['.%s.' % input() for _ in range(H)]
        + ['.' * (W + 2)])

dh = [-1, -1, -1, 0, 0, 1, 1, 1]
dw = [-1, 0, 1, -1, 1, -1, 0, 1]
for h in range(1, H + 1):
    line = ''
    for w in range(1, W + 1):
        if mapp[h][w] == '#':
            line += '#'
            continue

        line += str(sum(mapp[h + dhi][w + dwi] == '#' for dhi, dwi in zip(dh, dw)))
    print(line)

Measured memory_bytes: 3064