akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    long long n; cin >> n;
    string s = "";
    while (n)
    {
        s += (char)((--n % 26) + 'a');
        n /= 26;
    }
    reverse(s.begin(), s.end());
    cout << s << '\n';
    return 0;
}

Measured memory_bytes: 3620
/*
VS CL.exe でコンパイルするなら，文字コードは UTF-8 with BOM
言語:
C++
OS:
Microsoft Windows 10 Home (64 bit)
コンパイル:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall x86_amd64 & cl  /EHsc /nologo $file_name

*/

#include <iostream>
// #include <stdio.h>
#include <string>
#include <sstream>		// ss
#include <vector>


using namespace std;

void psI(int *arr, int n) {
	for(int i=0; i<n; i++) {
		cout << arr[i] << "_";
	}
}

void write_inner()
{
}

template <typename T, typename... ARGV>
void write_inner(T first, ARGV... argv)
{
	std::cout << first << " ";
	write_inner(argv...);
}

template <typename... ARGV>
void write(ARGV... argv)
{
	write_inner(argv...);
	std::cout << std::endl;
}

int main() {
	int n;
	cin >> n;
	long long result = 0;
	long long div = 1000000000 + 7;


	// cout << 10 % 3 << " [rad]" << endl;

	vector<int> ts(n), as(n), hs(n), isOks(n);

	for(int i=0; i<n; i++) {
		cin >> ts[i];
		hs[i] = 0;
		isOks[i] = 0;
	}
	for(int i=0; i<n; i++) {
		cin >> as[i];
	}

	int preH = 0;
	for(int i=0; i<n; i++) {
		if (preH < ts[i]) {
			isOks[i] = 1;
		}
		preH = ts[i];
	}

	result = 1;
	preH = 0;
	for(int i=n-1; i>=0; i--) {
		// if (preH < as[i]) {
		// 	if (ts[i] != as[i]) {
		// 		cout << 0 << endl;
		// 		return 0;
		// 	} else {
		// 		// １通り
		// 	}
		// }

		if (isOks[i] == 1) {
			if (preH < as[i]) {
				if (ts[i] != as[i]) {
					cout << 0 << endl;
					return 0;
				} else {
					// １通り
				}
			} else {
				if (ts[i] <= as[i]) {
					// 1
				} else {
					cout << 0 << endl;
					return 0;
				}
			}

		} else {
			if (preH < as[i]) {
				if (ts[i] >= as[i]) {
					// 1
				} else {
					cout << 0 << endl;
					return 0;
				}
			} else {


				if (ts[i] >=  as[i]) {
					result *= as[i];
				} else {
					result *= ts[i];
					// cout << 0 << endl;
					// return 0;
				}

			}

		}

		preH = as[i];
		result %= div;
	}

	cout << result << endl;
	// psI(&isOks.front(), n);

	// write(n);
	// write(as[0]);
	// write(as[1]);
	// write(as[n]);
	// write(as[n+1]);




	return 0;
}



Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		long NUM = 2019l;
		long l = nl();
		long r = nl();
		if (r - l >= 2019) {
			out(0);
			return;
		}
		l %= NUM;
		r %= NUM;

		long ans = Long.MAX_VALUE;

		for (long i = l; i <= r - 1; i++) {
			for (long j = i + 1; j <= r; j++) {
				long res = (i * j) % NUM;
				if (ans > res) {
					ans = res;
				}
			}
		}
		out(ans);

	}

	/*
	 * 以下メソッド集
	 */

	public static void permutation(String q, String ans) {
		// Base Case
		if (q.length() <= 1) {
			System.out.println(ans + q);
		}
		// General Case
		else {
			for (int i = 0; i < q.length(); i++) {
				permutation(q.substring(0, i) + q.substring(i + 1),
						ans + q.charAt(i));
			}
		}
	}

	static char[][] same(char[][] c, int h, int w) {

		char[][] a = new char[h][w];
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				a[i][j] = c[i][j];
			}
		}
		return a;

	}

	static int countkuro(char[][] c) {

		int count = 0;
		for (char[] cc : c) {
			for (char ccc : cc) {
				if ('#' == ccc) {
					count++;
				}
			}
		}
		return count;
	}

	static void debug() {

		out("---");
	}

	static void debug(Object a) {

		out("-------");
		out(a);
		out("-------");
	}

	static int ketasuu(int n) {

		String str = "" + n;
		return str.length();
	}

	static int account(String str) {

		String target = "AC";
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if (target.equals(str.substring(i, i + target.length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {

		return sc.nextInt();
	}

	static long nl() {

		return sc.nextLong();
	}

	static double nd() {

		return sc.nextDouble();
	}

	static String n() {

		return sc.next();
	}

	static char[] nc() {

		return sc.next().toCharArray();
	}

	static int kaijo(int n) {

		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {

		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {

		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {

		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(Object obj) {
		System.out.println(obj);
	}

	static void outn(Object obj) {
		System.out.print(obj);
	}

	static double max(double d, double e) {

		return Math.max(d, e);
	}

	static long max(long a, long b) {

		return Math.max(a, b);
	}

	static long min(long d, long e) {

		return Math.min(d, e);
	}

	static int min(int a, int b) {

		return Math.min(a, b);
	}
}

class XY {

	int h;
	int w;
	int d;

	XY(int h, int w, int d) {
		this.h = h;
		this.w = w;
		this.d = d;
	}
}


Measured memory_bytes: 35956
using System;
using System.Collections.Generic;

    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();

            List<string> input = new List<string>(line.Split(' '));

            string M = input[0];
            string D = input[1];

            int Mn = int.Parse(M);
            int Dn = int.Parse(D);

            int count = 0;

            for(int i = 1; i <= Dn; i++)
            {


                double d = i;
                int d10 = (int)(Math.Floor(d/10));
                int d1 = (int)(d - d10*10);

                if (d1 < 2) continue;
                if (d10 < 2) continue;

                for (int k=1; k <= Mn; k++)
                {
                    if(k == d10 * d1)
                    {
                        count++;
                    }
                }
            }

            Console.WriteLine(count);

        }
    }



Measured memory_bytes: 11220
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;

fn main() {
    let (n, w): (usize, usize);
    input!(n, w);
    const INF: usize = 999_999_999_999;
    let mut v = vec![];
    let mut dp = vec![vec![0; 1000 * n + 1]; n + 1];

    for _ in 0..n {
        let (vi, we): (usize, usize);
        input!(we, vi);
        v.push((we, vi));
    }

    for i in 0..n + 1 {
        for j in 0..1000 * n + 1 {
            if i == 0 && j == 0 {
                dp[i][j] = 0;
                continue;
            }
            if i == 0 {
                dp[i][j] = INF;
                continue;
            }

            if j < v[i - 1].1 {
                dp[i][j] = dp[i - 1][j];
            } else {
                dp[i][j] = std::cmp::min(dp[i - 1][j], dp[i - 1][j - v[i - 1].1] + v[i - 1].0);
            }
        }
    }

    let mut ans = 0;
    let mut s = 0;

    for (i, z) in dp[n].iter().enumerate() {
        if *z == INF {
            continue;
        }
        if *z > w {
            continue;
        }
        ans = std::cmp::max(ans, i);
    }
    p(ans);
}

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

using namespace std;
const int MAXN=100001;
int n,m,st[MAXN],et[MAXN],c[MAXN],pre[2*MAXN],res[2*MAXN];

int main()
{
	cin >> n >> m;
	for(int i=1;i<=n;i++) cin >>st[i] >>et[i] >>c[i];
	for(int i=1;i<=m;i++)
	{
		memset(pre,0,sizeof(pre));
		for(int j=1;j<=n;j++) if(c[j]==i) pre[st[j]*2-1]++,pre[et[j]*2]--;
		for(int j=1;j<=2*MAXN-2;j++) pre[j]+=pre[j-1];
		for(int j=1;j<=2*MAXN-2;j++) if(pre[j]>0) res[j]++;
	}
	
	int ans=0;
	for(int i=1;i<=2*MAXN-2;i++) ans=max(ans,res[i]);
	cout << ans;
	return 0;
}

Measured memory_bytes: 3072
// includes, macros {{{
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <climits>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

#define rep(i, s, e)    for (int i = (s); i < (int)(e); i++)
//#define PB(e) push_back(e)
//#define MP(a, b) make_pair(a, b)

// for debug
#define kita            cout << "kita\n"
#define print2(i, n)    cout << (i) << ": " << (n) << endl
#define print3(i, j, n)     cout << "(" << (i) << ", " << (j) << ") : " << (n) << endl
#define print4(i, j, n, m)  cout << "(" << (i) << ", " << (j) << ") : " << (n) << ", " << (m) << endl
#define print_mat(mat, h, w) for(int i=0;i<(h);i++){for(int j=0;j<(w);j++){cout << mat[i][j] << " ";}cout << endl;}
 
typedef long long ll;
typedef unsigned long long ull; // }}}

ll N, T;

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

    ll mmin=9111222333;
    ll mmax=0;
    ll dmax=0;

    map<ll, ll> mmap;

    for(ll i=0;i<N;i++){
        ll A;
        cin >> A;
        mmin = min(mmin, A);
        mmax = max(mmax, A);
        
        if(A-mmin == dmax){
            mmap[dmax] = mmap[dmax] + 1;
        }
        if(A-mmin > dmax){
            dmax = A-mmin;
            mmap[dmax] = 1;
        }
    }

    cout << mmap[dmax] << endl;

    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define EQ(x, y) (abs(x - y) < 1e-9)
typedef long long ll;

const int N = 1e5 + 1;
char s[N], t[N];
int n, m;
int freq[26];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;

	cin >> s >> t;
	n = strlen(s), m = strlen(t);
	for (int i = 0; i < n; ++i)
		++freq[s[i] - 'a'];
	for (int i = 0; i < m; ++i)
	{
		if (freq[t[i] - 'a'] == 0)
		{
			cout << -1 << '\n';
			return 0;
		}
	}

	vector<int> pos[26];
	for (int i = 0; i < n; ++i)
		pos[s[i] - 'a'].push_back(i);

	int p1 = 0, p2 = 0;
	ll ans = 0;
	while (p1 != m)
	{
		vector<int> &cur = pos[t[p1] - 'a'];
		auto it = lower_bound(cur.begin(), cur.end(), p2);
		if (it != cur.end())
		{
			ans += *it - p2 + 1;
			p2 = *it + 1;
			if (p2 == m)
				p2 = 0;
			++p1;
		}
		else
		{
			ans += n - p2;
			p2 = 0;
		}
	}
	cout << ans << '\n';

#ifdef local
	cout << setprecision(3) << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif
	return 0;
}

Measured memory_bytes: 1148
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main()
{
    string s;
    cin >> s;
    int score = 0;
    for (int i = 0; i < s.length(); i++) {
        if (i % 2 == 0 && s[i] == 'p') score--;
        else if (i % 2 == 1 && s[i] == 'g') score++;
    }
    cout << score << endl;

    return 0;
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline
N,C = map(int, input().split())

X = []

for i in range(N):
  x,c = map(int, input().split())
  X.append((x,c))
  
PS1 = [[0,0,0]]
PS2 = [[0,0,0]]
QS1 = [[0,0,0]]
QS2 = [[0,0,0]]

# PS[i] = c,i,c0
# PS1:右回りで得られるコスト（行きのxのロス組み込み
# PS2:右回り＋Oに帰るまでで得られるコスト
# i:Xのindex。

for i in range(N):
  c1, xx, c0 = PS1[i]
  c2, _,  _  = PS2[i]
  x,c = X[i]
  PS1.append([c0+c-x, i+1, c0+c])
  PS2.append([c0+c-x*2, i+1, c0+c])

for i in range(N):
  c1, xx, c0 = QS1[i]
  c2, _,  _  = QS2[i]
  x,c = X[N-i-1]
  x = C-x
  QS1.append([c0+c-x, i+1, c0+c])
  QS2.append([c0+c-x*2, i+1, c0+c])

PS1.sort(reverse=True)
PS2.sort(reverse=True)

"""
print(PS1)
print(PS2)
print(QS1)
print(QS2)
"""

# 左回りのINDEXをqとする。ただし原点=0とする
# するとQSindex + PSindex <= N であればOKで
# かつPSがソート済単調減少なので、貪欲に取れるはず
ans = 0
ps1index, ps2index = 0,0
for q in range(N+1):
  while PS1[ps1index][1] + q > N:
    ps1index += 1
  while PS2[ps2index][1] + q > N:
    ps2index += 1
  a1 = PS1[ps1index][0] + QS2[q][0]
  a2 = PS2[ps2index][0] + QS1[q][0]
  ans = max(ans, a1,a2)
  
print(ans)

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

int bubbleSort(int n, int a[]) {
  int cnt = 0;
  bool flag = true;
  while (flag) {
    flag = false;
    for (int i=n-1;i>0;i--)
      if (a[i] < a[i-1]) {
        swap(a[i], a[i-1]);
        flag = true;
        cnt++;
      }
  }
  return cnt;
}

int main() {
  int n, a[100];
  cin >> n;
  for (int i=0;i<n;i++)
    cin >> a[i];

  int cnt = bubbleSort(n, a);
  for (int i=0;i<n-1;i++)
    cout << a[i] << " ";
  cout << a[n-1] << endl;
  cout << cnt << endl;
  
}



Measured memory_bytes: 3096
#include <stdio.h>
#include <math.h>

int ball_invest(int balls[11],int ball_num,int B[11],int C[11],int bn,int cn){
	int is_possible = 0;
	int i;
	/*printf("B:");
	for(i = 1;i <= 10;i++){
		printf("%d,",B[i]);
	}
	printf("\nC:");
	
	for(i = 1;i <= 10;i++){
		printf("%d,",C[i]);
	}*/
	//printf("\n\n");

	if(B[bn] < balls[ball_num]){
		if(ball_num == 10){
		//printf("\nGET\n");
		return 1;
		}
		B[bn+1] = balls[ball_num];
		is_possible += ball_invest(balls,ball_num + 1,B,C,bn+1,cn);
		B[bn+1] = 0;
	}
	if(C[cn] < balls[ball_num]){
		if(ball_num == 10){
		//printf("\nGET\n");
		return 1;
		}
		C[cn+1] = balls[ball_num];
		is_possible += ball_invest(balls,ball_num + 1,B,C,bn,cn+1);
		C[cn+1] = 0;
	}
	//printf("is_possible:%d\n",is_possible);
	return is_possible;
}

int main(void){
	int B[11];
	int C[11];
	int balls[11];
	int i;
	int n;
	int is_possible = 0;
	
	scanf("%d",&n);
	for(;n > 0;n--){
		B[0] = 0;
		C[0] = 0;
		for(i = 1;i <= 10;i++){
			scanf("%d",&balls[i]);
			B[i] = 0;
			C[i] = 0;
		}
		is_possible = ball_invest(balls,1,B,C,0,0);
		
		if(is_possible >= 1)printf("YES\n");
		else printf("NO\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
int main(void){
  long long S;
  cin >> S;
  int ans = 1000;
  while(S >= 100){
    int X = S % 1000;
    ans = min(ans, abs(753 - X));
    S /= 10;
  }
  cout << ans << endl;
  return 0;
}
  

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
bool next_animal(bool a, bool b, char ch){
	if(b){
		if(ch == 'o') return a;
		else return !a;
	}else{
		if(ch == 'o') return !a;
		else return a;
	}
}
int main(){
	int N;
	string s;
	bool isSheep[100000];
	cin >> N >> s;
	for(int i = 0; i < 4; i++){
		fill(isSheep, isSheep + N, false);
		for(int j = 0; j < 2; j++){
			if(i & (1 << j)) isSheep[j] = true;
			else isSheep[j] = false;
		}
		for(int j = 2; j < N; j++){
			isSheep[j] = next_animal(isSheep[j - 2], isSheep[j - 1], s[j - 1]);
		}
		if(next_animal(isSheep[N - 2], isSheep[N - 1], s[N - 1]) == isSheep[0] && 
		next_animal(isSheep[N - 1], isSheep[0], s[0]) == isSheep[1]){
			for(int j = 0; j < N; j++){
				if(isSheep[j]) cout << 'S';
				else cout << 'W';
			}
			cout << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(void){
    int a[4],i,b;
    
    scanf("%d",&b);
    for(i=0;i<4;i++){
        a[i]=b%10;
        if(i>0){
            if(a[i]==a[i-1]){
                printf("Bad\n");
                return 0;
            }
        }
        b/=10;
    }
    printf("Good\n");
    return 0;
}


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

using namespace std;

#define MAX 50001
#define INF 1e9

class YAML{
public:
  string s;
  int state;
  vector<string> next;
};

vector<int> space;
YAML yaml[MAX];

int getState(string &str,int d,vector<string> &v){
  string now = str.substr(d);
  string s,t;
  int x = -1;
  for(int i = 0 ; i < (int)now.size() ; i++){
    if(now[i] == ':'){ x = d+i+2; break; }
    s += now[i];
  }
  v.push_back(s);
  if(x < (int)str.size()){
    t = str.substr(x);
    v.push_back(t);
    return 1;
  }
  return 0;
}

vector<string> make_graph(int cur,int sp){
  int len = space.size();
  vector<string> res;
  if(cur == len || yaml[cur].state == 1){ return res; }
  int now = cur;
  while(true){
    if(now == len || sp > space[now]){ break; }
    if(space[now] == INF){ now++; continue; }
    if(sp == space[now]){
      res.push_back(yaml[now].s);
      cur = now;
    }else if(sp < space[now]){
      if(yaml[cur].next.size() == 0){
        yaml[cur].next = make_graph(now,space[now]);
      }
    }
    now++;
  }
  return res;
}

int main(){
  int idx = 1;
  string order,in;
  map<string,int> mp;
  space.push_back(-1);
  yaml[0].s = "->";
  cin >> order; cin.ignore();
  while(getline(cin,in)){
    int cnt = 0;
    for(int i = 0 ; i < (int)in.size() ; i++){
      if(in[i] == ' '){
        cnt++;
      }else{ break; }
    }
    space.push_back(cnt);
    vector<string> v;
    yaml[idx].state = getState(in,cnt,v);
    yaml[idx].s = v[0];
    mp[yaml[idx].s] = idx;
    if(yaml[idx].state == 1){
      yaml[idx].state = 0;
      yaml[idx].next.push_back(v[1]);
      idx++;
      yaml[idx].s = v[1];
      yaml[idx].state = 1;
      mp[yaml[idx].s] = idx;
      space.push_back(INF);
    }
    idx++;
  }
  /*
  for(int i = 0 ; i < idx ; i++){
    cout << yaml[i].s << " " << yaml[i].state << " ";
    for(auto x : yaml[i].next){
      cout << x << " ";
    }
    cout << endl;
  }
  cout << endl;
  */
  yaml[0].next = make_graph(1,space[1]);
  /*
  for(int i = 0 ; i < idx ; i++){
    cout << yaml[i].s << ": ";
    for(auto x : yaml[i].next){
      cout << x << " ";
    }
    cout << endl;
  }
  */
  string t;
  vector<string> strs;
  for(int i = 0 ; i < (int)order.size() ; i++){
    if(order[i] == '.'){
      if(!t.empty()){ strs.push_back(t); }
      t.clear();
    }else{
      t += order[i];
    }
  }
  strs.push_back(t);
  int now = 0,len = strs.size();
  bool found = true;
  for(int i = 0 ; i < len ; i++){
    vector<string> vec = yaml[now].next;
    bool ok = false;
    for(int j = 0 ; j < (int)vec.size() ; j++){
      if(vec[j] == strs[i]){
        ok = true;
        break;
      }
    }
    now = mp[strs[i]];
    if(!ok){
      found = false;
      break;
    }
  }
  int size = yaml[now].next.size();
  if(!found || size == 0){
    cout << "no such property" << endl;
  }else{
    if(size != 1){
      cout << "object" << endl;
    }else{
      string ans = yaml[now].next[0];
      if(yaml[mp[ans]].state == 1){
        cout << "string \"" << ans << "\"" << endl;
      }else{
        cout << "object" << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
void solve(long long N) {
  vector<LL> nums;
  for (int i = 0; i < (1 << 18); i++) {
    int tmp = i;
    LL num = 0;
    bool ok = true;
    vector<int> used(4, 0);
    while (tmp != 0) {
      num *= 10;
      if (tmp % 4 == 0) {
        ok = false;
      }
      if (tmp % 4 == 1) num += 3;
      if (tmp % 4 == 2) num += 5;
      if (tmp % 4 == 3) num += 7;
      used[tmp % 4]++;
      tmp /= 4;
    }
    for (int i = 1; i <= 3; i++)
      if (used[i] == 0) ok = false;
    if (ok) {
      // if (i < 100) cout << num << endl;
      nums.push_back(num);
    }
  }
  int ans = 0;
  for (auto num : nums) {
    if (num <= N) ans++;
  }
  cout << ans << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 640
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        ll n;
        cin >> n;
        ll l0 = 2, l1 = 1, l2 = 2;
        rep(i, n - 1) {
            l2 = l0 + l1;
            l0 = l1, l1 = l2;
        }
        if (n == 1) cout << 1 << endl;
        else cout << l2 << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}	

Measured memory_bytes: 256
#!/usr/bin/env python3

import itertools

N, M, Q = map(int, input().split())
lis = [list(map(int, input().split())) for _ in range(Q)]

ans = 0
cnt = 0
X = [i for i in range(1, M+1)]

for i in itertools.combinations_with_replacement(X, r=N):
    cnt = 0
    j = list(i)
    for k in lis:
        if j[k[1]-1] - j[k[0]-1] == k[2]:
            cnt += k[3]
    ans = max(ans, cnt)

print(ans)

Measured memory_bytes: 9216
S = str(input())
n = len(S)
L = ["A","C","G","T"]
w = [0]
for i in range(n):
    if S[i] in L:
        cnt = 0
        for j in range(i,n):
            if S[j] not in L:
                cnt += 1
                w.append(len(S[i:j]))
                break
        if cnt == 0:
            w.append(len(S[i::]))
print(max(w))

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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

const int N = 100005;
int dp[N][3], n, k, R, S, P;
string T;

int rec(int x, int d) {
	if (x > n) {
		return 0;
	}
	int &ret = dp[x][d];
	if (ret != -1) return ret;
	ret = 0;
	int w = 0;
	if (d == 0 && T[x] == 's') {
		w = R;
	} else if (d == 1 && T[x] == 'p') {
		w = S;
	} else if (d == 2 && T[x] == 'r') {
		w = P;
	}
	for (int i = 0; i < 3; i++) {
		if (i != d) {
			ret = max(ret, rec(x + k, i));
		}
	}
	return ret += w;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    memset(dp, -1, sizeof dp);
    cin >> n >> k >> R >> S >> P >> T;
    int res = 0;
    for (int i = 0; i < min(n, k); i++) {
		res += max(rec(i, 0), max(rec(i, 1), rec(i, 2)));
	}
	cout << res;
    return 0;
}


Measured memory_bytes: 12616
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			long n = scanner.nextLong();
			long m = scanner.nextLong();
			if (1L == n) {
				if (1L == m) {
					System.out.println(1);
				} else {
					System.out.println(m - 2);
				}
			} else {
				if (1L == m) {
					System.out.println(n - 2);
				} else {
					System.out.println((n - 2) * (m - 2));
				}
			}
		}
	}
}


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

using namespace std;

int main() {
    int t;
    cin >> t;
    int  s = 0;
    vector<int>v;
    for (int i = 0; i < t; i++) {
      int x;
      cin >> x;
      v.push_back(x);
      s += x;
    }
    sort(v.begin(), v.end());
    if( s % 10 != 0) {
        cout << s << endl;
        return 0;
    }
    for (int i = 0; i < t; i++) {
        s = s - v[i];
        if(s % 10 != 0) {
            cout << s << endl;
            return 0;
        }
        else {
            s = s + v[i];
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long int;

int main(){
    int n; cin >> n;
    int even = 0, odd = 0;
    int a;
    for(int i=0; i<n; i++){
        cin >> a;
        if(a % 2 == 0){
            even++;
        }
        else{
            odd++;
        }
    }
    if(odd % 2 == 0){
        cout << "YES" << endl;
    }
    else if(odd == 1 && even == 0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

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

void print(pair<int,int> *data,int n)
{
  for(int i=0;i<n;i++)
    cout<<"["<<data[i].first<<","<<data[i].second<<"] ";
  cout<<endl;
}

int main()
{
  int n;
  for(;cin>>n,n;)
    {
      int m;
      cin>>m;
      pair<int,int> target[m];
      int sx,sy;
      cin>>sx>>sy;
      target[0]=make_pair(0,0);
      for(int i=1;i<m;i++)
	{
	  int tx,ty;
	  cin>>tx>>ty;
	  target[i]=make_pair(tx-sx,ty-sy);
	}
      // cout<<"target:";
      //print(target,m);

      for(int num=0;num<n;num++)
	{
	  //  cout<<"num,n="<<num<<" "<<n<<endl;
	  int mm;
	  cin>>mm;
	  pair<int,int> data[mm];
	  pair<int,int> noumal[mm];
	  int sx,sy;
	  cin>>sx>>sy;
	  data[0]=make_pair(0,0);
	  noumal[0]=make_pair(sx,sy);

	  for(int j=1;j<mm;j++)
	    {
	      int tx,ty;
	      cin>>tx>>ty;
	      data[j]=make_pair(tx-sx,ty-sy);
	      noumal[j]=make_pair(tx,ty);
	    }
	  pair<int,int> rev[mm];
	  sx=noumal[mm-1].first;
	  sy=noumal[mm-1].second;
	  rev[0]=make_pair(0,0);
	  int jj=1;
	  for(int j=mm-2;j>=0;j--)
	    {
	      int tx=noumal[j].first;
	      int ty=noumal[j].second;
	      rev[jj]=make_pair(tx-sx,ty-sy);
	      jj++;
	    }


	  //cout<<"data "<<num+1<<":";
	  //print(data,mm);
	  //cout<<"rev "<<num+1<<":";
	  //print(rev,mm);

	  if(mm!=m)
	    continue;
	  // int dx[]={1,-1,-1,1};
	  //	  int dy[]={1,1,-1,-1};
	  bool flag =false;
	  for(int i=0;i<4&& !flag;i++)
	    {
	      for(int j=0;j<m&&!flag;j++)
		{
		  if(target[j].first!=data[j].first ||
		     target[j].second!=data[j].second
		     )
		    break;
		  if(j==m-1)
		    flag=true;
		}
	      for(int j=0;j<m&&!flag;j++)
		{
		  if(target[j].first!=rev[j].first ||
		     target[j].second!=rev[j].second
		     )
		    break;
		  if(j==m-1)
		    flag=true;
		}

	      for(int j=0;j<m&&!flag;j++)
		{
		  swap(data[j].first,data[j].second);
		  data[j].first=-data[j].first;
		}

	      for(int j=0;j<m&&!flag;j++)
		{
		  swap(rev[j].first,rev[j].second);
		  rev[j].first=-rev[j].first;
		}
	      //	      cout<<"swapdata "<<num+1<<":";
	      //print(data,mm);

	    }
	  if(flag)
	      cout<<num+1<<endl;
	}


      cout<<"+++++"<<endl;
    }

}

Measured memory_bytes: 1164
x, y = map(int, input().split())
cnt = 0

if y < x and abs(x) > abs(y):
    x *= -1
    cnt += 1
else:
    if y < 0 and y < x:
        y *= -1
        cnt += 1

    if x > 0 and y < x:
        x *= -1
        cnt += 1

if x * y < 0:
    cnt += 1
cnt += abs(abs(x) - abs(y))

print(cnt)

Measured memory_bytes: 3064
package main
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"sort"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main(){
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()
	N, C, K :=  nextInt(), nextInt(), nextInt()
	T := nextInts(N)
	sort.Ints(T)
	ans := 1
	passenger := 1
	limit := T[0]+K
	for i:=1; i<N; i++{
		if limit < T[i] || passenger == C{
			ans++
			passenger = 1
			limit = T[i]+K
		}else{
			passenger++
		}
	}
	fmt.Fprintln(out, ans)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInts(n int) []int{
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

Measured memory_bytes: 5188
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 100005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


void solve(){
    int a, b, c, k; cin>>a>>b>>c>>k;
    if(k <= a){
        cout<<k;
        return;
    }
    if(k <= a+b){
        cout<<a;
        return;
    }
    int v = k-a-b;
    cout<<a-v;
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}





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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int par[2][200010];

int find(int id, int x) {
  if (par[id][x] == x) return x;
  return par[id][x] = find(id, par[id][x]);
}

void unite(int id, int x, int y) {
  x = find(id, x);
  y = find(id, y);
  if (x == y) return;
  par[id][y] = x;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  int N, K, L;  
  cin >> N >> K >> L;

  for (int i = 0; i < N; i++) {
    par[0][i] = par[1][i] = i;
  }

  for (int i = 0; i < K; i++) {
    int p, q;
    cin >> p >> q;
    p--, q--;
    unite(0, p, q);
  }

  for (int i = 0; i < L; i++) {
    int r, s;
    cin >> r >> s;
    r--, s--;
    unite(1, r, s);
  }

  map<pii, int> mp;
  for (int i = 0; i < N; i++) {
    mp[pii(find(0, i), find(1, i))]++;
  }
  
  for (int i = 0; i < N; i++) {
    cout << mp[pii(find(0, i), find(1, i))] << (i + 1 == N ? '\n' : ' ');
  }

  return 0;
}

Measured memory_bytes: 13568
#include<cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
#include <map>
using namespace std;
int main(){
  int n;
  int a[26];
  int m[26];
  string ans;
  for (int i=0;i<26;i++){
    a[i]=0;
    m[i]=50;}
  string s;
  cin>>n;
  for (int i=0;i<n;i++){
    cin>>s;
    for (int j=0;j<s.size();j++){
      int t;
      t=s[j]-'a';
      a[t]+=1;
    }
    for (int j=0;j<26;j++){
      if (a[j]<m[j])m[j]=a[j];
      a[j]=0;
    }
  }
  for (int i=0;i<26;i++){
    char c;
    c='a'+i;
    ans=ans+string(m[i],c);
  }
  cout<<ans;
  return 0;
}
      
  


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

int main(void)
{
	string instr;



	while(cin >> instr, !cin.eof() ){

		int ilen = instr.length()-1;
		int JOI = 0, IOI = 0;
		for(int i = 1; i < ilen; i++){
			if(instr[i] == 'O' && instr[i+1] == 'I'){
				if(instr[i-1] == 'J')
					JOI++;
				if(instr[i-1] == 'I')
					IOI++;
			}
		}
		cout << JOI << endl << IOI << endl;
	}

	return 0;
}

Measured memory_bytes: 1196
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        void solve(InputReader in, PrintWriter out) {
            String S = in.next();
            int price = 700;
            for (char c : S.toCharArray()) {
                if (c == 'o') {
                    price += 100;
                }
            }
            out.println(price);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
    }
}


Measured memory_bytes: 21460
#include <stdio.h>
#include <limits.h>

int max(int a, int b) { return a > b ? a : b; }
int min(int a, int b) { return a < b ? a : b; }

int main(void)
{
    int n, max_profit, min_value;
    int R[2000000];

    /* 値の受け取り */
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &R[i]);

    /* 初期化 */
    max_profit = INT_MIN;
    min_value = R[0];

    /* 最大利益の計算 */
    for (int j = 1; j < n; j++)
    {
        max_profit = max(max_profit, R[j] - min_value);
        min_value = min(min_value, R[j]);
    }

    /* 出力 */
    printf("%d\n", max_profit);

    return 0;
}


Measured memory_bytes: 2624
#include<bits/stdc++.h>
#define pb push_back
using namespace std;

int main()
{
    int N, M;
    cin>>N >> M;
    vector<string> a, b;
    string s;
    for(int i=0;i<N;i++)
    {
        cin>>s;
        a.pb(s);
    }
    for(int i=0;i<M;i++)
    {
        cin>>s;
        b.pb(s);
    }
    int flag=0;
    for(int i=0;i<N;i++)
    {
        for(int j=0;j<N;j++)
        {
            if(a[i][j] == b[0][0])
            {
                flag=0;
                for(int k=0;k<M;k++)
                {
                    if(i+k >= N)
                        break;
                    for(int l=0;l<M;l++)
                    {
                        if(j+l < N)
                        {
                            if(a[i+k][j+l]==b[k][l])
                            {
                                if(k==M-1 && l==M-1)
                                {
                                    cout << "Yes\n";
                                    return 0;
                                }

                            }
                            else
                            {
                                flag=1;
                                break;
                            }

                        }
                        else
                        {
                            flag=1;
                            break;
                        }
                    }
                    if(flag==1)
                        break;
                }
            }
        }
    }
    cout <<  "No\n";
    return 0;
}


Measured memory_bytes: 256
let rec for_fold a b v f = if a > b then v else for_fold (a+1) b (f v a) f
let () =
  Scanf.scanf "%d" @@ fun n ->
  let rec f c i m =
    if c = 0 then []
    else if i mod 2 = 0 || i mod 3 = 0 || i mod 5 = 0 then
      i :: f (c-1) (i+1) (m+i)
    else f c (i+1) m
  in
  let xs = List.rev @@ f (n-2) 2 0 in
  let m = List.fold_left (fun s x -> (s+x) mod 30) 0 xs in
  let x0 = List.hd xs in
  for_fold (x0+1) 30000 None (fun z i ->
    match z with
    | Some _ -> z
    | None -> begin
      if (i mod 2) * (i mod 3) * (i mod 5) > 0 then None else
      for_fold (i+1) 30000 None @@ fun z j ->
        match z with
        | Some _ -> z
        | None ->
            if (j mod 2) * (j mod 3) * (j mod 5) > 0 then None else
            if (i+j+m) mod 30 = 0 then Some (i, j) else None
    end)
  |> (fun (Some (y, z)) ->
      List.rev (z::y::xs) |> List.iter (Printf.printf "%d ");
      print_newline ())

Measured memory_bytes: 5248
#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <cmath>
#include <cstdlib>
#include <locale>
#include <map>
#include <functional>
#include <utility>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define MS1(I) memset(I, -1, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define pb push_back 
#define ALL(I) (I).begin(), (I).end()
#define MAX 105
#define F first
#define S second
typedef const void CV;
typedef long long LL;
typedef unsigned long long ULL;
int store[2][105];
int dp[2][105];
int main(void){
    int n; scanf("%d", &n);
    rep1(i, 1, 3) rep1(j, 1, n+1) scanf("%d", store[i] + j);
    dp[1][1] = store[1][1];
    rep1(j, 2, n+1) dp[1][j] = store[1][j] + dp[1][j-1];
    dp[2][1] = store[2][1] + store[1][1];
    rep1(j, 2, n+1) dp[2][j] = store[2][j] + max(dp[1][j], dp[2][j-1]);
    printf("%d", dp[2][n]);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N = 0;

typedef long long int ll;

using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    bool posible = false;
    int ope1 = c%b;
    fore(i,0,b){
        int ope2 = ((a%b)*(i%b))%b;
        //cout<<ope2<<" "<<ope1<<" \n";
        if(ope1 == ope2){
            posible = true;
            break;
        }
    }
    if(posible){
        cout<<"YES";
    }else{
        cout<<"NO";
    }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

bool check(string s){
    int res = s[0]-'0';
    for(int i=0; i<3; ++i){
        if(s[2*i+1] == '+') res += (s[2*i+2]-'0');
        else res -= (s[2*i+2]-'0');
    }

    if(res == 7) return true;
    else return false;

}

int main(){
    string s; cin >> s;
    
    for(int bit=0; bit<8; ++bit){
        string formula = "";
        for(int i=0; i<3; ++i){
            formula += s[i];
            if(bit&1<<i) formula += '+';
            else formula += '-';
        }
        formula += s[3];
        if(check(formula)){
            cout << formula + "=7" << endl;
            return 0;
        }

    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
    int D, N;
    cin >> D >> N;
    int tmp;
    switch (D) {
        case 0: tmp = 1; break;
        case 1: tmp = 100; break;
        case 2: tmp = 10000; break;
    }
    if (N == 100) cout << tmp * (N + 1) << endl;
    else cout << tmp * N << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

const int INF = 1<<28;
int G[110][110];
int dist[110][110];

int n, m;

bool used[110][110];

int solve() {
  for (int k = 0; k < n; ++k)
	for (int i = 0; i < n; ++i)
	  for (int j = 0; j < n; ++j)
		chmin(dist[i][j], dist[i][k] + dist[k][j]);
  memset(used, 0, sizeof(used));
  for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) {
	  for (int k = 0; k < n; ++k) for (int l = 0; l < n; ++l) {
		  if (G[k][l] >= INF) continue;
		  if (dist[i][j] == dist[i][k] + G[k][l] + dist[l][j])
			used[k][l] = true;
		}
	}
  int res = 0;
  for (int i = 0; i < n; ++i) {
	for (int j = i+1; j < n; ++j) {
	  if (used[i][j] || used[j][i])
		++res;
	}
  }
  return m - res;
}

int main() {
    while (cin >> n >> m) {
        for (int i = 0; i < 110; ++i) {
            for (int j = 0; j < 100; ++j) G[i][j] = dist[i][j] = INF;
            G[i][i] = dist[i][i] = 0;
        }
        for (int i = 0; i < m; ++i) {
            int a, b, c;
            cin >> a >> b >> c;
            --a; --b;
            G[a][b] = G[b][a] = dist[a][b] = dist[b][a] = c;
			
        }
        cout << solve() << endl;
    }
}






Measured memory_bytes: 384
// "header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;

inline double sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
// }}}


signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin >> n >> m;
	string s;
	cin >> s;
	vector<int> vec;
	int now = n;
	do{
		bool flg = false;
		for(int j = m;j > 0;--j){
			if(now - j < 0 || s[now-j] == '1') continue;
			else{
				now -= j;
				flg = true;
				vec.emplace_back(j);
			}
			if(now == 0 || flg) break;
		}
		if(!flg) return cout << -1 << '\n',0;
	}while(now != 0);

	reverse(all(vec));
	rep(i,vec.size()){
		cout << (i == 0 ? "" : " ") << vec[i];
	}
	cout << '\n';

	return 0;
}


Measured memory_bytes: 1480
<?php
// Your code here!

$count = trim(fgets(STDIN));
$num = 0;
$coy=0;

for($j=0; $j<$count; $j++){
    $in = trim(fgets(STDIN));
    $total[] = $in; 
}
sort($total);
// var_dump($total);

for($i=0; $i<$count; $i++){
    if($num < $total[$i]){
        $coy++;
        $num = $total[$i];
    }else{
        continue;
    }
}
echo $coy;
?>


Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define maxn 330400

using namespace std;
typedef long long ll;
ll n,a,b,c[maxn],k,p;
bool f[maxn];

int main()
{
    scanf("%d%d%d",&n,&a,&b);
    if (a+b>n+1||a*b<n) {printf("-1\n");return 0;}
    for (int i=0;i<n;i++) c[i]=n-i;
    reverse(c,c+a);
    k=n-a+1; b=k-b;
    for (int i=1;i<k;i++) {
        p=min(a-1,b);
        reverse(c+a*i,c+a*i+p+1);
        b-=p;
    }
    for (int i=0;i<n;i++) printf("%d ",c[i]); printf("\n");
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) 

typedef long long ll;
const ll mod=1000000007;

int n,T,a;
struct node {
 	ll tt;
 	int id;
 }t[2110];
 
 bool cmp(node a,node b){
 	return a.tt <= b.tt;
}
int x;
int main(){
	while(scanf("%d",&n)!=EOF){
		cin>>T>>a;
		a *= 1000;
		for (int i=0;i<n;i++){
			cin>>x;
			t[i].tt = 1000 * T - x * 6;
			t[i].tt = abs(a - t[i].tt);  
			t[i].id = i+1;
		}
		sort(t,t+n,cmp);
		cout<<t[0].id<<endl;
	}
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	static int d[][];
	static int col[][];
	static int cnt[][];
	static boolean color[];

	public static long discomfort(int k, int c) {
		long ans = 0;
		for(int i = 1; i < cnt[k].length; ++i) {
			long tmp = d[i][c] * cnt[k][i];
			ans += tmp;
		}
		return ans;
	}
	
	public static long solve(int k) {
		long ans = 1000000001;
		if(k == 3)return 0;
		int n = col[0].length;
		int c = d[0].length - 1;
		for (int i = 1; i <= c; ++i) {
			if (!color[i]) {
				color[i] = true;
				long tmp = discomfort(k, i) + solve(k + 1);
				ans = Math.min(ans,  tmp);
				color[i] = false;
			}
		}
		return ans;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), c = sc.nextInt();
		d = new int[c + 1][c + 1];
		col = new int[n][n];
		color = new boolean[c + 1];
		for (int i = 1; i <= c; ++i) {
			for (int j = 1; j <= c; ++j)
				d[i][j] = sc.nextInt();
		}
		cnt = new int[3][c + 1];
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				col[i][j] = sc.nextInt();
				cnt[(i + j) % 3][col[i][j]]++;
			}
		}
		sc.close();
		long ans = solve(0);
		System.out.println(ans);
	}

}


Measured memory_bytes: 79456
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define INF 1e18
#define MOD 1000000007
#define N 1000005
#define BB(V) V[V.size()-2]
#define ex(V) return printf(V),0
using namespace std;
int chk[20];
int a[200005];
int main(){
	int n,p=0;
	scanf("%d",&n);
	ll ans=0;
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
		while(p<i){
			int f=0;
			for(int j=0;j<20;j++)if(chk[j]&&((1<<j)&a[i])!=0){f=1;break;}
			if(f){
				for(int j=0;j<20;j++)if(a[p]&(1<<j))chk[j]=0;
				p++;
			}
			else break;
		}
		for(int j=0;j<20;j++)if(a[i]&(1<<j))chk[j]=1;
		ans+=i-p+1;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 1024