akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int H,W; cin >> H >> W;
	V<string> s(H); rep(i,H) cin >> s[i];
	VV<int> a(H,V<int>(W,1e9));
	a[0][0] = 0;
	rep(i,H) rep(j,W){
		if(i!=H-1) chmin(a[i+1][j],a[i][j]+(s[i][j]==s[i+1][j]?0:1));
		if(j!=W-1) chmin(a[i][j+1],a[i][j]+(s[i][j]==s[i][j+1]?0:1));
	}
	int tmp = a[H-1][W-1] + (s[0][0] == '#') + (s[H-1][W-1] == '#');
	cout << tmp/2 << endl;
}


Measured memory_bytes: 384
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
#define M 1000000007

int n, x, S[201];
long long memo[201][100100] = {};
long long fact[100002], facti[100002];

long long modinv(int a, int m) {
    int x = m, y = a, p = 1, q = 0, r = 0, s = 1;
    while (y != 0) {
        int u = x / y;
        int x0 = y; y = x - y * u; x = x0;
        int r0 = p - r * u, s0 = q - s * u;
        p = r; r = r0; q = s; s = s0;
    }
    return q < 0 ? q + m : q;
}

long long prod(int a, int b) {
    if (a > b) return 1;
    return fact[b] * modinv(fact[max(0, a-1)], M) % M;
}

long long calc(int i, int y) {
    if (i == 0) return y;
    if (memo[i][y] < 0) {
        long long ans = 0;
        for (int j = 0; j < i; j++) {
            int z = y % S[j];
            int k = upper_bound(S, S+n, z) - S; // k remains
            long long coeff = prod(k+1, i-1) % M;
            if (k >= 0) coeff = coeff * calc(k, z) % M;
            ans += coeff;
        }
        memo[i][y] = ans % M;
    }
    return memo[i][y];
}

int main() {
    cin >> n >> x;
    for (int i = 0; i < n; i++) cin >> S[i];
    sort(S, S+n);
    memset(memo, -1, sizeof memo);
    fact[0] = 1; facti[0] = 1;
    for (int i = 1; i <= 100000; i++) {
        fact[i] = (fact[i-1] * i) % M;
        facti[i] = modinv(fact[i], M);
    }
    cout << calc(n, x) << endl;
}


Measured memory_bytes: 158976
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
class coor {
  public:
    int x, y, h;
};
void dfs(const vector<coor> A, int x, int y) {
    if (y > 100) return;
    bool match = true;
    int h = -1;
    for (int i = 0; i<(int)A.size(); i++) if (A[i].h != 0) {
        h = A[i].h+abs(x-A[i].x)+abs(y-A[i].y);
        break;
    }
    for (int i = 0; i<(int)A.size(); i++) if(A[i].h != max(0, h-abs(x-A[i].x)-abs(y-A[i].y))) {
        match = false;
        break;
    }
    if (match) {
        printf("%d %d %d\n", x, y, h);
        return;
    }
    if (x == 100) return dfs(A, 0, y+1);
    return dfs(A, x+1, y);
}
void Main(){
    int N = read();
    vector<coor> I(N);
    for (auto& i:I) {
        i.x = read();
        i.y = read();
        i.h = read();
    }
    dfs(I, 0, 0);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 13696
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = LLONG_MAX;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
int main() {
    int n,y;cin >> n >> y;
    rep(i, y/1000+10) {
        rep(j, y/5000+10) {
            if(n-i-j>=0&&i*1000+j*5000+(n-i-j)*10000==y) {
                cout << n-i-j << ' ' << j << ' ' << i << endl;
                return 0;
            }
        }
    }
    cout << -1 << ' ' << -1 << ' ' << -1 << endl;
    return 0;
}

Measured memory_bytes: 3568
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N;
std::vector<LL>A;

LL f(LL b)
{
	LL res = 0;
	rep(i, N) res += abs(A[i] - b);
	return res;
}

int main()
{
	in >> N;
	A.resize(N);
	rep(i, N)
	{
		in >> A[i];
		A[i] -= i + 1;
	}
	LL l = -1123456789, r = 1123456789;
	while (r - l > 1)
	{
		LL m = (l + r) / 2;
		if (f(m - 1) < f(m + 1)) r = m;
		else l = m;
	}
	out << std::min(f(l), f(r)) << std::endl;
	return 0;
}

//https://beta.atcoder.jp/contests/arc100/submissions/2828148
//で、24行目をi + 1に

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		// 1行目入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();

		// 行列の生成と行列内容入力
		long[][] A = CreateMatrix(n, m);
		long[][] B = CreateMatrix(m, l);

		// 行列の積計算
		long[][] C = MatrixMultiplication(A, B);

		// 表示処理
		Print(C);

	}

	// 行列生成と行列内容入力、行列(long2次元配列)を返す
	static long[][] CreateMatrix(int y, int x) {
		long[][] Matrix = new long[y][x];
		for (int i = 0; i < y; i++) {

			for (int k = 0; k < x; k++) {

				// 入力
				Matrix[i][k] = sc.nextInt();
			}
		}
		return Matrix;
	}

	// 行列の積計算し、計算結果の行列(long二次元配列)を返す
	static long[][] MatrixMultiplication(long[][] A, long[][] B) {
		long[][] C = new long[A.length][B[0].length];
		for (int k = 0; k < B.length; k++) {

			for (int i = 0; i < A.length; i++) {

				for (int j = 0; j < B[0].length; j++) {

					C[i][j] += A[i][k] * B[k][j];
				}
			}
		}
		return C;
	}

	// 表示処理
	static void Print(long[][] C) {
		// System.out.println(C.length);
		for (int i = 0; i < C.length; i++) {
			System.out.print(C[i][0]);
			for (int j = 1; j < C[0].length; j++) {
				// 数字の間にスペースを入れる
				System.out.print(" " + C[i][j]);
			}
			System.out.println();

		}
	}

}



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

using ll=long long;
class BIT{
    int N;
    vector<int> dat;
    public:
    BIT(int N):N(N),dat(N,0){};
    void add(int pos,int x){
        pos++;
        while(pos<=N){
            dat[pos-1]+=x;
            pos+=pos&-pos;
        }
    }
    int query(int pos){
        int res=0;
        while(pos>0){
            res+=dat[pos-1];
            pos-=pos&-pos;
        }
        return res;
    }
    int query(int l,int r){
        return query(r)-query(l);
    }

};
int main(){
    string s;
    cin>>s;
    int n=s.size();
    vector<int> cnt('z'-'a'+1,0);
    vector<int> pos('z'-'a'+1,0);
    for(int i=0;i<n;i++){
        cnt[s[i]-'a']++;
        pos[s[i]-'a']=i;
    }
    int oddcnt=count_if(cnt.begin(),cnt.end(),[](int c){return c%2==1;});
    if(oddcnt>1){
        cout<<-1<<endl;
        return 0;
    }
    ll res=0;
    int fr=0;
    vector<int> checked(n,false);
    BIT bit(n);
    for(int i=0;i<n;i++){
        if(checked[i]) continue;
        if(cnt[s[i]-'a']==1){
            res+=abs(n/2-fr);
            continue;
        }
        checked[i]=true;
        res+=n-1-pos[s[i]-'a']-bit.query(pos[s[i]-'a'],n);
        
        checked[pos[s[i]-'a']]=true;
        bit.add(pos[s[i]-'a'],1);
        while(--pos[s[i]-'a']>=0){
            if(s[pos[s[i]-'a']]==s[i] && !checked[pos[s[i]-'a']]){
                break;
            }
        }
        cnt[s[i]-'a']-=2;
        fr++;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 2180
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	int A;   //高橋くんのクッキー
	int B;   //青木くんのクッキー
	int K;   //交換回数

	A = scan.nextInt();
	B = scan.nextInt();
	K = scan.nextInt();

	for(int i = 0; i < K; i++){
	    //偶数
	    if(A % 2 == 0){
	    }
	    //奇数
	    else{
		A--;
	    }

	    A /= 2;
	    B += A;

	    //先攻後攻交代
	    int tmp = A;
	    A = B;
	    B = tmp;
	}

	if(K % 2 == 0){
	    System.out.println(A + " " + B);
	}else{
	    System.out.println(B + " " + A);
	}
    }
}


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

namespace ConsoleApp1
{
    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            B();
        }

        static void B()
        {
            var A = Read();
            var B = Read();
            if (A.Length > B.Length)
            {
                Console.WriteLine("GREATER");
                return;
            }
            else if (A.Length < B.Length)
            {
                Console.WriteLine("LESS");
                return;
            }

            for (int i = 0; i < A.Length; i++)
            {
                if (A[i] > B[i])
                {
                    Console.WriteLine("GREATER");
                    return;
                }

                if (A[i] < B[i])
                {
                    Console.WriteLine("LESS");
                    return;
                }
            }
            Console.WriteLine("EQUAL");
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static IList<string> ReadSplit() => Read().Split().ToList();
        static IList<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
    }
}


Measured memory_bytes: 11092
#pragma warning (disable :4996)
#include <iostream>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int N = 2e6 + 10;

int n;
int A[N], B[N], C[N];
void CountingSort(int A[], int B[], int k) {
	for (int i = 0; i <= k; i++) C[i] = 0;
	for (int i = 1; i <= n; i++) C[A[i]]++;
	int flag = 0;
	for (int i = 0; i <= k; i++) {
		if (C[i]) {
			while (C[i]--) {
				if (!flag) printf("%d", i);
				else printf(" %d", i);
				flag = 1;
			}
		}
	}
	printf("\n");
}
int main() {
	int k = -1;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &A[i]);
		k = max(k, A[i]);
	}
	CountingSort(A, B, k);

	return 0;
}


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

#define println(msg) cout << msg << endl
#define yes_or_no(flag) if (flag) { println("Yes"); } else { println("No"); }

int main() {
  // 入力
  int A, B;
  cin >> A >> B;
  
  // 計算
  int count = 0;
  for (int i = A; i <= B; i++) {
    string s = to_string(i);
    int x = s.size() / 2;
    bool all = true;
    for (int j = 0; j < x; j++) {
      if (s[j] != s[s.size() - j - 1]) {
        all = false;
      }
    }
    if (all) {
      count++;
    }
  }
  
  // 出力
  println(count);
}


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

int main(){
  string s;
  cin>>s;
  int count=0,anscount=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='A'||s.at(i)=='C'||s.at(i)=='T'||s.at(i)=='G'){
      count++;
    }
    if(s.at(i)!='A'&&s.at(i)!='C'&&s.at(i)!='T'&&s.at(i)!='G'){
      count=0;
    }
    if(anscount<count){
      anscount=count;
    }
  }
  cout<<anscount<<endl;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int list[n][n];
	for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) list[i][j] = -1;
	for (int i = 0; i < n; i++) {
		int k = ri();
		for (int j = 0; j < k; j++) {
			int x = ri() - 1;
			int y = ri();
			list[i][x] = y;
		}
	}
	int res = 0;
	for (int i = 0; i < 1 << n; i++) {
		bool ok = true;
		for (int j = 0; j < n; j++) {
			if (i >> j & 1) {
				for (int k = 0; k < n; k++) {
					if (j != k && list[j][k] != -1 && list[j][k] != (i >> k & 1)) ok = false;
				}
			}
		}
		if (ok) res = std::max(res, __builtin_popcount(i));
	}
	std::cout << res << std::endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
    
    void run()
    {
	
	String[] kang = {"a", "b", "c", "d", "e", "f", "g", "h",
			 "i", "j", "k", "l", "m", "n", "o", "p",
			 "q", "r", "s", "t", "u", "v", "w", "x", 
			 "y","z", 
			 "ld", "mb", "mp", "nc", "nd", "ng", "nt",
			 "nw", "ps", "qu", "cw","ts","B"}; 
	
	Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();
	int[][] ans=new int[kang.length][kang.length];
	while(sc.hasNext()){
	    String str=(sc.next()+"A");
	    String temp;
	    int front=kang.length -1; //B
	    //System.out.println(str);
	    
	    for(int i=0;i<str.length()-1;i++){
		for(int j=kang.length-2;j>=0;j--){
		    temp=str.substring(i,i+kang[j].length());
		    //  System.out.println(kang[j]+" "+temp);
		    if(kang[j].equals(temp)){
			ans[front][j]++;
			front = j;
			i+=kang[j].length()-1;
			break;
		    }
		}
	    }
	}
	for(int i=0;i<kang.length-1;i++){
	    int max=0;
	    for(int j=0;j<kang.length-1;j++){
		max= ans[i][max] >=ans[i][j] ? max:j;
	    }
	    System.out.println(kang[i]+" "+kang[max]+" "+ans[i][max]);
	}
    }
	
    public static void main(String[] args)
    {
	new Main().run();	
    }
}

Measured memory_bytes: 12000
n = int(input())


def sum_digits(n):
    result = 0
    while True:
        result += (n % 10)
        n //= 10
        if n == 0:
            break

    return result


min_of_sum = 10 ** 5
for a in range(1, n):
    b = n - a
    digits_sum_of_a = sum_digits(a)
    digits_sum_of_b = sum_digits(b)
    digits_sum = digits_sum_of_a + digits_sum_of_b
    if digits_sum < min_of_sum:
        min_of_sum = digits_sum

print(min_of_sum)


Measured memory_bytes: 2940
import sys
input = sys.stdin.buffer.readline

N, T = map(int, input().split())
food = []
for i in range(N):
    a, b = map(int, input().split())
    food.append((a, b))

dp = [[0 for _ in range(T)] for _ in range(N+1)]
prev = [[0 for _ in range(T)] for _ in range(N+1)]
for i in range(N):
    for t in range(T):
        a, b = food[i]
        if t+a < T:
            if dp[i+1][t+a] < dp[i][t] + b:
                dp[i+1][t+a] = dp[i][t] + b
                prev[i+1][t+a] = t
        if dp[i][t] > dp[i+1][t]:
            dp[i+1][t] = dp[i][t]
            prev[i+1][t] = t

max_sum = 0
max_t = 0
for t in range(T):
    if dp[-1][t] > max_sum:
        max_sum = dp[-1][t]
        max_t = t

cur_T = max_t
used = [0] * N
for i in range(N, 0, -1):
    if prev[i][cur_T] == cur_T - food[i-1][0]:
        cur_T -= food[i-1][0]
        used[i-1] = 1

max_b = 0
for i in range(N):
    if used[i] == 0:
        max_b = max(max_b, food[i][1])

print(max_sum + max_b)


Measured memory_bytes: 191880
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var D = new int[] { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

            int K;

            K = int.Parse(Console.ReadLine());

            Console.WriteLine(D[K - 1]);
        }
    }
}



Measured memory_bytes: 11092
#include<iostream>
using namespace std;
int main(){
	int n,k;
	cin >> n >> k;
	int x[100];
	for(int i=0;i<n;i++) cin >> x[i];
	int ans=0;
	for(int i=0;i<n;i++) ans+=2*min(x[i],k-x[i]);
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int num = scanner.nextInt();
		ArrayList<Long> list =  new ArrayList<Long>();
		for(int i = 0; i < num; i++) {
			list.add(scanner.nextLong());
		}
		long res = 0;

		for(long j : list) {
			res += j - 1;
		}

		System.out.println(res);
	}
}

Measured memory_bytes: 27884
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int a, b, c;

int main() {
	ios::sync_with_stdio(false);
	cin >> a >> b >> c;
	if (c >= a&&c <= b)cout << "Yes\n";
	else cout << "No\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
  
  string S;
  string Sr;
  cin >> S;
  Sr=S;
  int len = S.length();
  for(int i=0; i<=len; i++){
    Sr[i]=S[len-i-1];
  }
  
  bool tsuyoi=true;
  
  if(S.compare(Sr)){
    tsuyoi = false;
  }
  
  string p = S.substr(0,(len-1)/2);
  string pr = Sr.substr((len-1)/2+1,len-1);
  if(p.compare(pr)){
    tsuyoi = false;
  }
  //cout << pr <<"\n";
  string p2 = S.substr((len-1)/2+1,len-1);
  string p2r = Sr.substr(0,(len-1)/2);
  if(p2.compare(p2r)){
    tsuyoi = false;
  }
  //cout << p2r <<"\n";
  
  if(tsuyoi){
    cout << "Yes";
  }else{
    cout << "No";
  }
  
  return 0;
}

Measured memory_bytes: 256
n, m, x = map(int, input().split())
r = []
for _ in range(n):
    r.append(list(map(int, input().split())))
r_all = [0 for i in range(m+1)]
for i in range(m+1):
    for j in range(n):
        r_all[i] += r[j][i]
def d(r_sum):
    achieved = True
    for u in r_sum[1:]:
        if u < x:
            achieved = False
    return achieved
if d(r_all) == False:
    print(-1)
else:
    ans = r_all[0]
    for i in range(2**n):
        r_sum = [0 for i in range(m+1)]
        buy = '0' * (n-(len(bin(i))-2))+bin(i)[2:]
        for j in range(n):
            if buy[j] == "1":
                for k in range(m+1):
                    r_sum[k] += r[j][k]
        if d(r_sum) == True and r_sum[0] < ans:
            ans = r_sum[0]
    print(ans)
        

Measured memory_bytes: 9196
using System;

class Program {
    static void Main (string[] args) {
        var inp = Console.ReadLine().Split(' ');
        string isHi = "No";

        bool ch_h = false;
        for(int i = 0;i < inp[0].Length;i++) {
            if(ch_h) {
                if(inp[0][i].Equals('i')) {
                    ch_h = false;
                    if(i == inp[0].Length - 1) {
                        isHi = "Yes";
                        break;
                    }
                    continue;
                }
            } else {
                if(inp[0][i].Equals('h')) {
                    ch_h = true;
                    continue;
                } else {
                    break;
                }
            }

        }

        Console.WriteLine(isHi);
    }
}

Measured memory_bytes: 11092
using System;

class Program
{
  const int INF = int.MaxValue;

  static void Main(string[] args)
  {
    int N;
    if (!int.TryParse(Console.ReadLine(), out N)) return;
    string[] sh = Console.ReadLine().Split(' ');
    int[] h = new int[N];
    for (int i = 0; i < N; i++)
    {
      if (!int.TryParse(sh[i], out h[i])) return;
    }
    
  	// DP table
    int[] dp = new int[100010];
    for (int i = 0; i < 100010; i++) dp[i] = INF;
    dp[0] = 0;
    
    for (int i = 0; i < N - 1; i++)
    {
      ChMin(ref dp[i+1], dp[i]+Math.Abs(h[i] - h[i+1]));
      if (i+2 < N) ChMin(ref dp[i+2], dp[i]+Math.Abs(h[i] - h[i+2]));
    }

    Console.WriteLine(dp[N-1]);
  }

  static bool ChMin(ref int a, int b)
  {
    if (a > b)
    {
      a = b;
      return true;
    }
    return false;
  }
}

Measured memory_bytes: 16864
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static int[][] map;
	static int[][] directions8= {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
	static int[][] directions4= {{-1,0},{1,0},{0,-1},{0,1}};
	static int ans;
	static int[] parent;//union-find用
	static int[] rank;//union-find用

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] L = new int[N];
		for(int i = 0;i<N ; i++) {
			L[i] = sc.nextInt();
		}

		Arrays.sort(L);
		ans = 0;

		for(int i = 0;i<N ; i++) {
			for(int j = i+1;j<N ; j++) {
				for(int k = j+1;k<N ; k++) {
					if(L[i]!= L[j]&&L[j]!= L[k]&&L[i]!= L[k]) {
						if(L[i]+L[j]>L[k]) {
							ans++;
						}
					}


				}
			}
		}


		System.out.println(ans);
	}

	//素数判定
	public static boolean isPrime(long num) {
		if (num < 2) return false;
		else if (num == 2) return true;
		else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

		double sqrtNum = Math.sqrt(num);
		for (int i = 3; i <= sqrtNum; i += 2)
		{
			if (num % i == 0)
			{
				// 素数ではない
				return false;
			}
		}

		// 素数である
		return true;
	}

	//BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for(int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
		return b == 0 ? a: gcd(b, a % b);
	}

	//Union-Find用の配列を要素数nで初期化
	static void ufInit(int n){
		parent = new int[n];
		rank = new int[n];
	}

	//Union-Findの要素の最上位の親（グループ名）を返す
	static int ufFind(int a) {
		if(parent[a]==a) {
			return a;
		}else {
			return ufFind(parent[a]);
		}
	}

	//Union-Find木を連結する
	static void ufUnite(int a, int b) {
		a = parent[a];
		b = parent[b];

		if(a==b) {
			return;
		}
		if(rank[a] > rank[b]){
			parent[b]=a;
		}else {
			parent[a]=b;
			if(rank[a]==rank[b]) {
				rank[b]++;
			}
		}
	}

	static boolean ufSame(int a, int b) {
		return ufFind(a)==ufFind(b);
	}
}


Measured memory_bytes: 36280
import java.io.ByteArrayInputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	
	String INPUT = "";
	
	public static void main(String[] args) throws Exception { new Main().run(); }
	
	void run() {
		Scanner sc = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(new ByteArrayInputStream(INPUT.getBytes()));
		PrintWriter out = new PrintWriter(System.out);
		
		solve(sc, out);
		out.flush();
	}
	
	void solve(Scanner sc, PrintWriter out) {
		int S = sc.nextInt();
		
		int sec = S%60;
		int min = S/60;
		int hour = min/60;
		min = min-hour*60;
		System.out.println(hour + ":" + min + ":" + sec);
	}
}



Measured memory_bytes: 26356
#include <iostream>
#include <string>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long sum[200020] = { 0 }, sum1[200020] = { 0 };
int main() {
#define int long long
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		sum[i] = sum[i - 1] + x;
	}
	for (int j = 1; j <= m; j++) {
		int y;
		cin >> y;
		sum1[j] = sum1[j - 1] + y;
	}
	int ans = 0;
	for (int l = 0; l <= n; l++) {
		if (k - sum[l]<0) {
			break;
		}
		auto itr = upper_bound(sum1, sum1 + m + 1, k - sum[l]);
		int c = distance(sum1, itr);
		if (l + c > ans) {
			ans = l + c;
		}
	}
	cout << ans - 1<< endl;
	return 0;
}



Measured memory_bytes: 6756
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    if (a == b && b == c && a == c) {
        cout << "No" << endl;
    } else if (a != b && b != c && a != c) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int dx[] = {1, 1, 1, 0, 0, -1, -1, -1};
int dy[] = {1, 0, -1, 1, -1, 1, 0, -1};

int main(){
    int h, w;
    cin >> h >> w;
    string a[h];
    for(int i=0; i<h; i++){
        cin >> a[i];
    }
    
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(a[i][j] == '.'){
                a[i][j] = '0';
                for(int k=0; k<8; k++){
                    int nx = j+dx[k], ny = i+dy[k];
                    if(0<=nx && nx<w && 0<=ny && ny<h && a[ny][nx] =='#'){
                        a[i][j]++;
                    }
                }
            }
        }
    }

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cout << a[i][j];
        }
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
class _Node {
  constructor(key, parent = null, left = null, right = null) {
    this.key = key;
    this.parent = parent;
    this.left = left;
    this.right = right;
  }

  getChildrenNumber() {return Number(this.left !== null) + Number(this.right !== null);}

  isLeftChild() {
    if (this.parent === null) return null;
    return this.parent.left === this;
  }

  getLeftOrRight() {return this.isLeftChild() ? 'left' : 'right';}

  getSuccessor() {
    let n;
    if (this.right !== null) {
      n = this.right;
      while (n.left !== null) n = n.left;
    } else {
      n = this.parent;
      while (!n.isLeftChild && n.parent != null) n = n.parent;
    }
    return n;
  }
}

class BinaryTree {
  constructor() {
    this.root = null;
  }

  static get Node() { return _Node; }

   insert(key) {
     if (this.root === null) {
       this.root = new BinaryTree.Node(key);
       return;
     }
     let x = this.root, y;
     let newNode = new BinaryTree.Node(key);
     while (x !== null) {
       y = x;
       x = key < x.key ? x.left : x.right;
     }
     newNode.parent = y;
     y[key < y.key ? 'left' : 'right'] = newNode;
   }


  find(key, n = this.root) {
    if (n === null || n.key === key) return n;
    return this.find(key, n[key < n.key ? 'left' : 'right']);
  }

  delete(key) {
    const n = this.find(key);
    if (n === null) return;
    let leftOrRight = n.getLeftOrRight();
    switch (n.getChildrenNumber()) {
    case 0:
      n.parent[leftOrRight] = null;
      break;
    case 1:
      n.parent[leftOrRight] = n.left || n.right;
      n.parent[leftOrRight].parent = n.parent;
      break;
    default:
      let skey = n.getSuccessor().key;
      this.delete(skey);
      n.key = skey;
    }
  }

  printByIneorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      innerFunc(n.left);
      str += ` ${n.key}`;
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  printByPreorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      str += ` ${n.key}`;
      innerFunc(n.left);
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  print() {
    this.printByIneorder();
    this.printByPreorder();
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  const tree = new BinaryTree();
  lines.forEach(function(cmd) {
    switch (cmd.charAt(0)) {
    case 'i': tree.insert(Number(cmd.split(' ')[1])); break;
    case 'f': console.log(tree.find(Number(cmd.split(' ')[1])) ? 'yes' : 'no'); break;
    case 'd': tree.delete(Number(cmd.split(' ')[1])); break;
    default: tree.print();
    }
  });
})();



Measured memory_bytes: 203228
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Os")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(ll i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        freopen("error.txt","w",stderr);
    #endif
}

int main()
{
    vok();
    int n;
    IN n;
    vll a(n);
    loop(i,0,n)
    {
        IN a[i];
    }
    ll x=0;
    loop(i,2,n)
    {
        x^=a[i];
    }
    ll sum=a[0]+a[1];
    if(sum%2!=x%2)
    {
        OUT -1<<endl
        return 0;
    }
    ll add=(sum-x)/2;
    if(a[0]<add)
    {
        OUT -1<<endl
        return 0;
    }
    if(add&x)
    {
        OUT -1<<endl
        return 0;
    }
    rloop(i,60,0)
    {
        if(!((x>>i)&1))
        {
            continue;
        }
        if((add+(1LL<<i))>a[0])
        {
            continue;
        }
        add+=(1LL<<i);
    }
    if(add==0)
    {
        OUT -1<<endl
        return 0;
    }
    OUT (a[0]-add)<<endl
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define Mod(n) n % 1000000007
const int dx[8] = {1, 0, -1, 0, -1, 1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
int main()
{    
    int N;
    cin >> N;
    int l,r;
    int sum = 0;
    for(int i = 0;i < N;i++)
    {
        cin >> l >> r;
        sum += r - l + 1;
    }
    cout << sum << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    llint d, n;
    cin >> d >> n;

    // corner
    if (n == 100) {
        if (d == 0)
            cout << 101;
        else if (d == 1)
            cout << 10100;
        else
            cout << 1010000;

    } else if (d == 0)
        cout << n;
    else {
        llint div = pow(100, d);
        cout << div * n;
    }
}

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

using namespace std;

int main() {
    int n, m, k; cin >> n >> m >> k;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            if (i * j + (n - i) * (m - j) == k) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    } 
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long int
#define ld long double
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr)

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

int main() {
    fastIO;
    int n, x, t;
    cin >> n >> x >> t;

    int sum = 0, tot = 0;

    while (tot < n) {
        sum += t;
        tot += x;
    }
    cout << sum;
}


Measured memory_bytes: 3648
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  int plen,cnum,width,cspace;
  string s;
  string blank,space;
  vector<string>list;
  while(cin>>plen>>cnum>>width>>cspace,plen){
    blank=space="";
    for(int i=0;i<width;i++)blank+=".";
    for(int i=0;i<cspace;i++)space+=".";
    list.clear();
    getline(cin,s);
    while(getline(cin,s),s!="?"){
      if(s.length()==0)s=".";
      while(s.length()%width != 0)s+=".";
      for(int i=0;i+width<=s.length();i+=width)
	list.push_back(s.substr(i,width));
    }
    while(list.size()%(plen*cnum) != 0)list.push_back(blank);

    int line=0,column=0,page=0;
    while(plen*cnum*page < list.size()){
      s="";
      for(column=0;column<cnum;column++){
	if(column!=0)s+=space;
	int i = line + column*plen + page*plen*cnum;
	if(i <= list.size())s+=list[i];
	else s+=blank;
      }
      cout<<s<<endl;
      line++;
      if(line >= plen){
	line=0;
	page++;
	puts("#");
      }
    }
    puts("?");
  }
}

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

using namespace std;
using llong = long long int;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const int MOD = 1000000007;
const int INF = 1000000000;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int h, w;
vector<vector<char> > field;
vector<vector<int> > dist;

int bfs(int sx, int sy, int gx, int gy) {
    queue<pair<int, int> > PQ;
    PQ.push(make_pair(sx, sy));

    while (! PQ.empty()) {
        int x = PQ.front().first, y = PQ.front().second;
        PQ.pop();
        if (x == gx && y == gy) break;

        for (int i = 0; i < 4; ++i) {
            if (x + dx[i] < 0 || x + dx[i] >= h || y + dy[i] < 0 || y + dy[i] >= w) continue;
            if (field[x + dx[i]][y + dy[i]] == '#') continue;
            if (dist[x + dx[i]][y + dy[i]] > dist[x][y] + 1) {
                PQ.push(make_pair(x + dx[i], y + dy[i]));
                dist[x + dx[i]][y + dy[i]] = dist[x][y] + 1;
            }
        }
    }

    return dist[gx][gy];
}

int main (int argc, char *argv[]) {
    cin.tie(0); 
    ios::sync_with_stdio(false);

    cin >> h >> w;
    field.resize(h, vector<char>(w));
    dist.resize(h, vector<int>(w));
    for (int i = 0; i < h; ++i) {
        string S;
        cin >> S;
        for (int j = 0; j < w; ++j) field[i][j] = S[j];
    }

    int ans = 0;
    for (int sx = 0; sx < h; ++sx) {
        for (int sy = 0; sy < w; ++sy) {
            for (int gx = 0; gx < h; ++gx) {
                for (int gy = 0; gy < w; ++gy) {
                    // cout << sx << " " << sy << " " << gx << " " << gy << endl;
                    if (field[sx][sy] == '#' || field[gx][gy] == '#') continue;
                    for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) dist[i][j] = INF;
                    dist[sx][sy] = 0;
                    ans = max(ans, bfs(sx, sy, gx, gy));
                    // cout << ans << endl;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

long long int memo[100005];
long long int h[100005];
long long int n,k;
long long int call(long long int i)
{
	if(i<0)
		return 0;
	if(i==0 || i==1)
	{
		return 0;
	}
	if(memo[i]!=-1)
		return memo[i];
	if(i>1 && i<=k)
	{
		return abs(h[i]-h[1]);
		
	}
	long long int ans=INT_MAX;
	
	for(long long int j=1;j<=k;j++)
	{
		ans=min(ans,call(i-j)+abs(h[i]-h[i-j]));
	}
	memo[i]=ans;
	return memo[i];
	
	
}
 int main()
{
	
	cin>>n>>k;
	for(long long int i=1;i<=n;i++)
	{
		cin>>h[i];
	}
	for(long long int i=1;i<=n;i++)
	{
		memo[i]=-1;
	}
	cout<<call(n);

	return 0;
}

Measured memory_bytes: 6528
N = int(input())

memo = [[0, 0, 0]]
# diff_t = 0
# diff_x = 0
# diff_y = 0

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

# print(memo)

for i in range(1, N+1):
    diff_s = memo[i][0] - memo[i-1][0]
    # print(diff_s)
    diff_m = abs(memo[i][1]-memo[i-1][1])+abs(memo[i][2]-memo[i-1][2])
    if diff_m > diff_s:
        print('No')
        exit()
    if diff_m % 2 == 0 and diff_s % 2 == 0:
        pass
    elif diff_m % 2 == 1 and diff_s % 2 == 1:
        pass
    else:
        print('No')
        exit()



print('Yes')

Measured memory_bytes: 59608
#include<iostream>
using namespace std;
int n, m, a, b;
int main() {
    while (true) {
        cin >> n >> m >> a >> b; if (n == 0)break;
        long double V = 1.0l*n / m;
        if (V >= 1.0l*a) cout << "0" << endl;
        else cout << ((m*a - n) + b - 1) / b << endl;
    }
}

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

int main() {
  ll h,w,n; cin>>h>>w>>n;
  set<P> s,check;
  rep(i, 0, n) {
    int a,b; cin>>a>>b;
    s.insert(P(a, b));
  }
  ll res[10]={};
  res[0]=(ll)(h-2)*(w-2);
  for (P i: s) {
    int a=i.first;
    int b=i.second;
    rep(x, -1, 2) {
      rep(y, -1, 2) {
        int nx=a+x,ny=b+y;
        if (!(1<nx&&nx<=h-1)) continue;
        if (!(1<ny&&ny<=w-1)) continue;
        check.insert(P(nx, ny));
      }
    }
  }
  for (P p: check) {
    int tmp=0;
    rep(x, -1, 2) {
      rep(y, -1, 2) {
        if (s.count(P(p.first+x, p.second+y))) tmp++;
      }
    }
    res[tmp]++;
    res[0]--;
  }
  rep(i, 0, 10) cout<<res[i]<<endl;
}

Measured memory_bytes: 47104
#include <stdio.h>

int main() {
	int n, a[10][10], l[10], c[10], sum, i, j;
	while( 1 ) {
		scanf("%d", &n);
		if (!n) break;
		sum=0;
		for(i=0; i<n*n; i++) {scanf("%d", &a[i%n][i/n]); sum+=a[i%n][i/n];}
		for(i=0; i<n; i++) {
			l[i]=0;
			for(j=0; j<n; j++) l[i]+=a[i][j];
		}
		for(i=0; i<n; i++) {
			c[i]=0;
			for(j=0; j<n; j++) c[i]+=a[j][i];
		}
		for(i=0; i<n; i++) {
			for(j=0; j<n; j++) printf("%5d", a[j][i]);
			printf("%5d\n", c[i]);
		}
		for(i=0; i<n; i++) printf("%5d", l[i]);
		printf("%5d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, rc = 0, wc = 0;
    string c;
    cin >> N >> c;
    REP(i, c.size()) {
        if (c[i] == 'R') rc++;
        else wc++;
    }
    if (wc == 0) {
        cout << 0 << endl;
        return 0;
    }
    int ans = 0;
    REP(i, rc) {
        if (c[i] == 'W') ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3752
#include<iostream>
#include<limits.h>

#define N 100000
int n, k;
int a[N];

int input(){
	int i;
	std::cin >> n >> k;
	for( i = 0; i < n; i++ ){ std::cin >> a[i]; }
	return n;
}

int func(){
	int sum = 0, m = 0, i;
	for( i = 0; i < k; i++ ){ sum += a[i]; }
	m = sum;
	for( i = k; i < n; i++ ){
		sum += a[i] - a[i-k];
		m = (sum>m?sum:m);
	}
	return m;
}

int main(){
	while( input() > 0 ){ std::cout << func() << std::endl; }
	return 0;
}

Measured memory_bytes: 3480
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
int INF = 1001001001;

int main()
{
    int n;
    in n;
    vector<int> a(n);
    rep(i,n)in a[i];
    sort(a.begin(),a.end());
    cout<<a[n-1]-a[0]<<endl;
}


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

int main() {  
  int a, b;
  cin >> a >> b;
  
  int pal = 0;
  int num = 0;
  
  for(int i = 1; i < 10; i++) {
    for(int j = 0; j < 10; j++) {
      for(int k = 0; k < 10; k++) {
        pal = 10000*i + 1000*j + 100*k + 10*j + i;
        if(pal >= a && pal <= b)
          num++;
      }
    }
  }
  
  cout << num << endl;

}

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

int getgcd(int n, int m){
    int r;
    if(n > m){
        int t = m;
        m = n;
        n = t;
    }
    while((r = m % n) != 0){
        m = n;
        n = r;
    }
    return n;
}



int main(){
    int k;
    long ans = 0;
    cin >> k;
    for(int i=1; i <= k; ++i){ 
        for(int j=1; j <= k; ++j){
            for(int l=1; l <= k; ++l){
                ans = ans + getgcd(getgcd(i,j),l);
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int  i,n,j,k,mx,ans[2000001];
string a[2000001],b[2000001];
int main() {
  cin >> n;
  for (i=1; i<=n; i++)
    cin >> a[i];
    a[n+1]="11111111111";
    j=1; k=1;
    sort(a,a+n+1);

    
    for (i=2; i<=n+1; i++)
        if (a[i]!=a[i-1])
    {
        ans[j]=k;

        j=j+k;
        k=1;
    }
    else
    k++;

    for (i=1; i<=n; i++)
        mx=max(mx,ans[i]);

        j=0;
    for (i=1; i<=n; i++)
        if (ans[i]==mx)
    {
        j++;
        b[j]=a[i];
    }
    sort (b,b+j+1);
    for (i=1; i<=j; i++)
        if (i==j)
        cout<<b[i];
    else
        cout<<b[i]<<endl;

}


Measured memory_bytes: 129372
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main()
{
	map <int, int> mp;
	int	n, m, x;
	cin >> n >> m >> x;
	for(int i = 1; i <= m; i++)
	{
		int num;
		scanf("%d", &num);
		mp[num] = 1;
	}
	int a1 = 0;
	for(int i = x + 1; i <= n; i++)
	{
		if(mp[i] == 1) a1++;
	}
	int a2 = 0;
	for(int i = x - 1; i >= 0; i--)
	{
		if(mp[i] == 1) a2++;
	}
	int ans = min(a1, a2);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    long x = sc.nextLong();

    sc.close();

    long count = x / 11 * 2;

    long mod = x % 11;

    if (0 < mod && mod <= 6) {
      count++;
    } else if (mod != 0) {
      count += 2;
    }

    System.out.println(count);
    
  }

}

Measured memory_bytes: 23764
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

from collections import deque

def main():
	n,c=MI()

	li=[[0]*c for _ in range(10**5+1)]
	#print(li)

	for _ in range(n):
		s,t,cc=MI()
		for i in range(s-1,t):
			li[i][cc-1]=1

	ans=0

	for A in li:
		ans=max(ans,sum(A))
	print(ans)









if __name__ == "__main__":
	main()


Measured memory_bytes: 108512
#include <iostream>
#include <vector>

using namespace std;
const int INF = 1000000;

struct Node{
	vector<int>to;
	vector<int>cost;
};
struct node{
	int cost;
	bool visited;
};
Node nodes[101];
int dist[101][101];

void dijkstra(int x,int y){
	int targetNode;
	int cost[101];//xからの距離を保存する
	node mawariNodes[101];
	
	for(int i=0;i<101;i++){
		cost[i] = INF;
		mawariNodes[i].cost = INF;
		mawariNodes[i].visited = false;
	}
	
	targetNode = x;
	
	cost[targetNode] = 0;
	mawariNodes[targetNode].visited = true;
	mawariNodes[targetNode].cost = 0;
	
	while(true){
		
		for(int i=0;i<nodes[targetNode].to.size();i++){
			int now = nodes[targetNode].to[i];//nowは頂点番号　iはnodesに使う
			if(mawariNodes[now].visited)continue;//行ったことがあればぶち込まない
			mawariNodes[now].cost = min(mawariNodes[now].cost,cost[targetNode] + nodes[targetNode].cost[i]);//targetNodeの周りの頂点をぶち込む
		}
		
		int min=INF;
		int nodeNumber = -1;
		for(int i=0;i<101;i++){
			if(mawariNodes[i].visited)continue;//確定してないノード
			if(min > mawariNodes[i].cost){//で一番コストが低いノード
				min = mawariNodes[i].cost;
				nodeNumber = i;
			}
		}
		if(nodeNumber == -1)break;
		if(mawariNodes[y].visited)break;
		
		mawariNodes[nodeNumber].visited = true;
		cost[nodeNumber] = mawariNodes[nodeNumber].cost;
		targetNode = nodeNumber;
	}
	dist[x][y] = cost[y];
	dist[y][x] = cost[y];
}
int main(){
	int N,M;
	int a[1001],b[1001],c[1001];
	
	
	for(int i=0;i<101;i++){
		for(int j=0;j<101;j++){
			if(i == j){
				dist[i][j] = 0;
			}else{
				dist[i][j] = INF;
			}
		}
	}
	
	cin >> N >> M;
	for(int i=0;i<M;i++){
		cin >> a[i] >> b[i] >> c[i];
		a[i]--;
		b[i]--;
		dist[a[i]][b[i]] = c[i];
		dist[b[i]][a[i]] = c[i];
		nodes[a[i]].to.push_back(b[i]);
		nodes[a[i]].cost.push_back(c[i]);
		nodes[b[i]].to.push_back(a[i]);
		nodes[b[i]].cost.push_back(c[i]);
	}

	for(int i=0;i<N;i++){
		for(int j=i;j<N;j++){
			if(i==j)continue;
			dijkstra(i,j);
		}
	}

	int answer = M;
	for(int i=0;i<M;i++){//全ての辺について
		bool isShortest = false;
		for(int j=0;j<N;j++){
			if(dist[j][a[i]] + c[i] == dist[j][b[i]]){
				isShortest = true;
			}
		}
		if(isShortest){
			answer = answer - 1;
		}
	}
	
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 384