akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
  int i;
  int t,n,max1,max2,min1,min2,b0,b1,b2,b3,b4,m1,m2,m3,m4,s1,s2,s3,s4;
  for(;;){
    scanf("%d",&n);
    if(n==0)
      break;
    max1=max2=14400;
    min1=min2=-1;
    for(i=0;i<n;i++){
      scanf("%d%d%d%d%d%d%d%d%d",&b0,&m1,&s1,&m2,&s2,&m3,&s3,&m4,&s4);
      t=m1*60+m2*60+m3*60+m4*60+s1+s2+s3+s4;
      if(t<max1){
	max2=max1;
	b2=b1;
	max1=t;
	b1=b0;
      }else if(t<max2){
	max2=t;
	b2=b0;
      }
      if(t>min1){
	min2=min1;
	b3=b4;
	min1=t;
	b4=b0;
      }else if(t>min2){
	min2=t;
	b3=b0;
      }
    }
    printf("%d\n%d\n%d\n",b1,b2,b3);
  }
  return 0;
}

Measured memory_bytes: 0
# coding : utf-8

class Parallelism
  def solve
    n = gets.chomp.to_i
    n.times do
      x1, y1, x2, y2, x3, y3, x4, y4 =
        gets.chomp.split.map {|s| s.to_r}
      #p x1, y1, x2, y2, x3, y3, x4, y4
      ab = (y2 - y1) / (x2 - x1) rescue Float::INFINITY
      cd = (y4 - y3) / (x4 - x3) rescue Float::INFINITY
      if ab == cd then
        puts "YES"
      else
        puts "NO"
      end
    end
  end
end

Parallelism.new.solve

Measured memory_bytes: 6152
import scala.io.Source

object Main extends App {
  val src = Source.stdin.getLines
  val org_dice = src.next.split(" ").map(_.toInt).toList
  val directions = src.next

  def sDirection(dice: List[Int]) = List(dice(4), dice(0), dice(2), dice(3), dice(5), dice(1))
  def nDirection(dice: List[Int]) = List(dice(1), dice(5), dice(2), dice(3), dice(0), dice(4))
  def wDirection(dice: List[Int]) = List(dice(2), dice(1), dice(5), dice(0), dice(4), dice(3))
  def eDirection(dice: List[Int]) = List(dice(3), dice(1), dice(0), dice(5), dice(4), dice(2))

  def roll(dice: List[Int], direction: Char): List[Int] = {
    if (direction == 'N') nDirection(dice)
    else if (direction == 'S') sDirection(dice)
    else if (direction == 'E') eDirection(dice)
    else wDirection(dice)
  }

  println(directions.foldLeft(org_dice)(roll).head)
}

Measured memory_bytes: 44228
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, b;//bは500円の端数
  cin >> N >> A;
  b = N % 500;
  if(A >= b){
     cout << "Yes" << endl;
  }
  else{
     cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.txt"
 


int main() {
	int Q; cin >> Q;
	while (Q--) {
		int N; cin >> N;
		string st; cin >> st;
		vector<vector<int>>needs(2, vector<int>(N + 1));
		for (int i = 0; i < 4 * N; ++i) {
			int num(i);
			int row = num>= 2 * N;
			num %= (2 * N);
			int col = (num + 1) / 2;
			needs[row][col] |= (st[i] == 'Y');
		}
		vector<vector<int>>dp(N + 2, vector<int>(3,100000));
		dp[0][0] = 0;
		for (int i = 0; i <= N; ++i) {
			if (!needs[0][i] && !needs[1][i]) {
				for (int f = 0; f < 3; ++f) {
					for (int t = 0; t < 3; ++t) {
						dp[i + 1][t] = min(dp[i + 1][t], dp[i][f] + 1+abs(f - t));
					}
				}
			}
			else if (!needs[0][i] && needs[1][i]) {
				int nums[3][3] = {
					{3,2,2},
					{2,1,1},
					{2,1,1},
				};
				for (int f = 0; f < 3; ++f) {
					for (int t = 0; t < 3; ++t) {
						dp[i + 1][t] = min(dp[i + 1][t], dp[i][f] + 1 + nums[f][t]);
					}
				}
			}
			else if (needs[0][i] && !needs[1][i]) {
				int nums[3][3] = {
					{ 1,1,2 },
					{ 1,1,2 },
					{ 2,2,3 },
				};
				for (int f = 0; f < 3; ++f) {
					for (int t = 0; t < 3; ++t) {
						dp[i + 1][t] = min(dp[i + 1][t], dp[i][f] + 1 + nums[f][t]);
					}
				}
			}
			else {
				int nums[3][3] = {
					{ 3,2,2 },
					{ 2,2,2 },
					{ 2,2,3 },
				};
				for (int f = 0; f < 3; ++f) {
					for (int t = 0; t < 3; ++t) {
						dp[i + 1][t] = min(dp[i + 1][t], dp[i][f] + 1 + nums[f][t]);
					}
				}
			}
		}
		cout << -1+dp[N + 1][0] << endl;

	}
	return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
// using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

struct edge {
  int to, cost;
};

vector<vector<edge>> graph;
vector<bool> visited;
vector<int> dist;

void dfs(int s) {
  visited[s] = true;
  rep(i, graph[s].size()) {
    int to = graph[s][i].to, cost = graph[s][i].cost;
    if (visited[to]) continue;
    dist[to] = (dist[s] + cost) % 2;
    dfs(to);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //////////////////////////////////////
  int n;
  cin >> n;
  graph.resize(n);
  visited.resize(n);
  dist.resize(n);
  rep(i, n) {
    visited[i] = false;
    dist[i] = INF;
  }
  rep(i, n - 1) {
    int u, v, w;
    cin >> u >> v >> w;
    w %= 2;
    --u;
    --v;
    graph[u].push_back(edge{v, w});
    graph[v].push_back(edge{u, w});
  }
  dist[0] = 0;
  dfs(0);
  rep(i, n) cout << dist[i] << endl;
  return 0;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=int(a);i<=int(b);i++)
#define ROF(i,a,b) for(int i=int(b);i>=int(a);i--)
#define pb push_back
#define pq priority_queue
#define ps push
#define x first
#define y second
using namespace std;
long long n,anw;
int main(){
    cin>>n;
    anw=((n-1)*n)/2;
    cout<<anw;
}


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

int main() {
#ifdef TEST
    freopen("input", "r", stdin);
#endif

    double x1, x2, y1, y2;
    scanf("%lf", &x1);
    scanf("%lf", &y1);
    scanf("%lf", &x2);
    scanf("%lf", &y2);

    printf("%f", sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));

    return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
struct UnionFind {
    VI d;
    UnionFind(int n = 0): d(n,-1) {}
    int find(int x) {
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x,int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x,int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};
int deg[100005];
VI to[100005];

int main() {
    int n;
    cin >> n;
    VI x(n);
    rep(i,n) cin >> x[i];
    SORT(x);
    int sum = 0;
    rep(i,n) {
        sum += x[i];
    }
    sum /= n;
    int ans = 0;
    rep(i,n) {
        ans += (x[i] - sum)*(x[i] - sum);
    }
    int ans2 = 0;
    rep(i,n) {
        ans2 += (x[i] - sum -1) * (x[i] - sum -1);
    }
    int ans3 = 0;
    rep(i,n) {
        ans3 += (x[i] - sum + 1) * (x[i] - sum + 1);
    }
    ans = min(ans,ans2);
    ans = min(ans,ans3);
    
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

map<vector<int>, int> mt;
int flag[4];

vector<int> rotate(vector<int> x){
	return vector<int>{x[3],x[0],x[1],x[2]};
}

int main()
{
	int n;
	cin>>n;
	vector<vector<int> > faces(n,vector<int>(4));
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 4; j++){
			cin>>faces[i][j];
		}
	}
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 4; j++){
			faces[i] = rotate(faces[i]);
			mt[faces[i]]++;
		}
	}

	ll ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++){
			vector<int> upper = faces[i];
			vector<int> lower = faces[j];

			for(int p = 0; p < 4; p++){
				upper = rotate(upper);
				mt[upper]--;
				lower = rotate(lower);
				mt[lower]--;
			}

			for(int k = 0; k < 4; k++){
				upper = rotate(upper);
				vector<int> side[4];
				side[0] = vector<int>{upper[1],upper[0],lower[1],lower[0]};
				side[1] = vector<int>{upper[2],upper[1],lower[0],lower[3]};
				side[2] = vector<int>{upper[3],upper[2],lower[3],lower[2]};
				side[3] = vector<int>{upper[0],upper[3],lower[2],lower[1]};

				ll cnt = 1;
				for(int l = 0; l < 4; l++){
					flag[l] = 0;
				}
				for(int l = 0; l < 4; l++){
					if(mt.count(side[l])>0 && mt[side[l]] > 0){
						cnt *= mt[side[l]];
						flag[l]++;
						for(int p = 0; p < 4; p++){
							side[l] = rotate(side[l]);
							mt[side[l]]--;
						}
					}else{
						cnt = 0;
						break;
					}
				}
				// if(cnt != 0) cout << cnt << endl;
				ans += cnt;
				for(int l = 0; l < 4; l++){
					if(flag[l]>0){
						for(int p = 0; p < 4; p++){
							side[l] = rotate(side[l]);
							mt[side[l]]++;
						}
					}
				}
				// cout << ans << endl;
			}

			for(int p = 0; p < 4; p++){
				upper = rotate(upper);
				mt[upper]++;
				lower = rotate(lower);
				mt[lower]++;
			}
		}
	}

	cout << ans/3 << endl;

	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

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

    vector<int> P(N);
    rep(i,0,N){
        cin>>P[i];
    }
    int minP=1000000;
    int ans=0;

    rep(i,0,N){
        if(minP>P[i]){
            ans++;
            minP=P[i];
        }
    }

    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
lst = []

for i in range(n):
    a = int(input())
    xy = []
    for j in range(a):
        x, y = map(int, input().split())
        xy.append([x-1, y])
    lst.append(xy)

ans = 0
# 全探索
# iのビットに含まれる'1'が正直者
# 0000 0000 0000 0001
# ~
# 0111 1111 1111 1111
for i in range(2**n):
    flag = 0
    # 全ての人の証言を検証
    for j in range(n):
        # 正直者か確認(不親切な人の証言はどうでもいい)
        if (i >> j) & 1:
            # 証言の確認
            for x, y in lst[j]:
                # x番の人に対する証言が間違っていれば終了
                if (i >> x) & 1 != y:
                    flag = 1
                    break
    # 全ての正直者の証言に異常がなければ
    if flag == 0:
        # 2進数表記の'1'の数が正直者の数
        ans = max(ans, bin(i).count('1'))
print(ans)


Measured memory_bytes: 3064
import bisect
n = int(input())
L = list(map(int, input().split()))
L.sort()

cnt = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        index = bisect.bisect_left(L[j+1:], L[i] + L[j])
        cnt += index

print(cnt)

Measured memory_bytes: 69764
#include <iostream>
using namespace std;
int main() {

	int s;
	int m;
	int h;

	cin >> s;

	h = s / 3600;
	s = s - h * 3600;

	m = s / 60;
	s = s - m * 60;

	cout << h << ":" << m << ":" << s << endl;




	return 0;
}



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

typedef long long ll;
#define gc getchar()
inline int read(){
	int x=0,f=1;char c=gc;
	for(;c<48||c>57;c=gc)
		if(c=='-')f=-1;
	for(;c>47&&c<58;c=gc)
		x=x*10+c-48;
	return x*f;
}
#define io read()

#define maxn 200005
int n,a[maxn],f[maxn],ans;

inline void init(){
	n=io;
	for(int i=1;i<=n;++i)a[i]=io;
	for(int i=1;i<=n;++i){
		f[a[i]]=f[a[i]-1]+1;
	}
	for(int i=1;i<=n;++i)
		ans=max(ans,f[i]);
	printf("%d\n",n-ans);
}

inline void solve(){
	
}

int main(){
	init();
	solve();
	return 0;
}

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

#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a) {
	os << '{';
	for(int i=0;i<sz(a);i++)
	{
		if(i>0&&i<sz(a)-1)
			os << ", ";
		os << a[i];
	}
	os << '}';
    return os;
}
const int N=101;
const int W=1e5+1;
ll dp[N][W];
int main()
{
    for(int i=0;i<N;i++)
    {
        for(int j=0;j<W;j++)
            dp[i][j]=LLONG_MIN;
    }
    int n,w;
    scanf("%i %i",&n,&w);
    vector<pair<int,int> > items(n);
    for(int i=0;i<n;i++)
        scanf("%i %i",&items[i].f,&items[i].s);
    dp[0][0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<W;j++)
        {
            if(dp[i][j]!=LLONG_MAX)
            {
                if(j+items[i].f<=w)
                    dp[i+1][j+items[i].f]=max(dp[i+1][j+items[i].f],dp[i][j]+items[i].s);
                dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
            }
        }
    }
    ll best=0;
    for(int i=0;i<W;i++)
    {
        best=max(best,dp[n][i]);
    }
    printf("%lld\n",best);
    return 0;
}


Measured memory_bytes: 79104
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		if (solution()) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

	public static boolean solution() {
		int[] group1 = {1, 3, 5, 7, 8, 10, 12};
		int[] group2 = {4, 6, 9, 11};

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();

		if(x == 2 || y == 2) {
			return false;
		}
		for(int i = 0; i < group1.length; i++) {
			if(x == group1[i]) {
				for(int j = 0; j < group1.length; j++) {
					if(y == group1[j]) {
						return true;
					}
				}
			}
		}
		for(int i = 0; i < group2.length; i++) {
			if(x == group2[i]) {
				for(int j = 0; j < group2.length; j++) {
					if(y == group2[j]) {
						return true;
					}
				}
			}
		}

		return false;

	}

}


Measured memory_bytes: 21844
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        _out.println((a <= c && c <= b ? "Yes" : "No"));
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 21844
n = int(input())
a = list(map(int,input().split()))
ans = 10**9  # テキトーに大きな値入れておく
for i in range(n):
    if a[i] % 2 == 1:
        print(0)
        quit()

    count = 0
    while a[i] % 2 == 0:
      a[i] //= 2
      count += 1
    ans = min(ans, count)

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	ll n; cin>>n;
	ll m=MOD,ans=0;
	rep(i,0,n){
		ll a; cin>>a;
		if(m>=a) ans++;
		m=min(m,a);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	// buf := make([]byte, 10000)
	// scanner.Buffer(buf, 1000000)
	return scanner
}

func scanInt() int {
	if sc.Scan() {
		t := sc.Text()
		if v, err := strconv.Atoi(t); err == nil {
			return v
		}
		panic(fmt.Sprintln("Could't scan int from input", t))
	}
	panic(sc.Err())
}

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

var sc *bufio.Scanner = newScanner()

type city struct {
	p, id, year int
}

type cities []*city

func (p cities) Len() int { return len(p) }
func (p cities) Less(i, j int) bool {
	return p[i].p < p[j].p || (p[i].p == p[j].p && p[i].year < p[j].year)
}
func (p cities) Swap(i, j int) { p[i], p[j] = p[j], p[i] }

func main() {
	_, m := scanInt(), scanInt()
	c := make(cities, m)

	for i := 0; i < m; i++ {
		p, y := scanInt(), scanInt()
		c[i] = &city{p, 0, y}
	}

	s := make(cities, m)
	copy(s, c)
	sort.Sort(c)

	c[0].id = 1
	for i := 1; i < m; i++ {
		if c[i-1].p == c[i].p {
			c[i].id = c[i-1].id + 1
		} else {
			c[i].id = 1
		}
	}

	for i := 0; i < m; i++ {
		fmt.Printf("%06d%06d\n", s[i].p, s[i].id)
	}
}


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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << (a) << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

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

int cnt[3];

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

    string s; cin >> s;
    for (char c : s) cnt[c-'a']++;
    sort(cnt, cnt+3);
    bool ok = cnt[2] - cnt[0] <= 1;
    cout << (ok ? "YES" : "NO") << endl;

    return 0;
}


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

long long int N, ami[6], a, w, p[3];

int main(){
    scanf("%lld", &N);
    for(int i = 0; i < N; ++i){
        scanf("%lld", &w);
        *p = 0;
        p[1] = 1;
        p[2] = 2;
        for(int j = 0; j < w; ++j){
            scanf("%lld", &a);
            swap(p[1], p[a * 2]);
        }
        w = *p * 2 + (p[1] > p[2]);
        //cout << w << endl;
        ++ami[w];
        switch(w){
            case 0:
                return 0 & puts("yes");
                break;
            case 1:
            case 2:
            case 5:
                if(ami[w] > 1)return 0 & puts("yes");
                break;
            default:
                if(ami[w] > 2)return 0 & puts("yes");
        }
    }
    if(ami[3] && ami[4])return 0 & puts("yes");
    if(ami[3] || ami[4]){
        if(ami[1] + ami[2] + ami[5] > 1)return 0 & puts("yes");
    }
    puts("no");
    return 0;
}


Measured memory_bytes: 3136
#include<stdio.h>
#include<math.h>
#include <stdlib.h>

int main(){
	int i, n, a[3], low;
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	for(i = 0; i < n; i++){
		if(i == 0){
			low = a[0];
		}else{
			if(low > a[i]) low = a[i];
		}
	}
	for(i = 1; i <= low; i++){
		if(n == 2){
			if(a[0] % i == 0 && a[1] % i == 0){
				printf("%d\n", i);
			}
		}else{
			if(a[0] % i == 0 && a[1] % i == 0 && a[2] % i == 0){
				printf("%d\n", i);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
 
int main(void){
  int n, d, x;
  int a;
  int i, j;
  scanf("%d %d %d", &n, &d, &x);
  int sum=x;
  for(i=0;i<n;i++){
    scanf("%d", &a);
    for(j=1;j<=d;j+=a){
      sum++;
    }
  }
  printf("%d", sum);
  return 0;
}

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

using namespace std;

int main(){
    long long int N,count=0;
    vector<long long int> f(5,0);
    long long int ans=0,sum=1;
    string name;
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> name;
        if(name[0] == 'M'){
            f[0]++;
        }else if(name[0] == 'A'){
            f[1]++;
        }else if(name[0] == 'R'){
            f[2]++;
        }else if(name[0] == 'C'){
            f[3]++;
        }else if(name[0] == 'H'){
            f[4]++;
        }
    }

    for(int i=0;i<5;i++){
        if(0<f[i]){
            count++;
            sum *= f[i];
        }
    }

    if(count<3){
        cout << 0 << endl;
    }else if(count == 3){
        cout << sum << endl;
    }else if(count == 4){
        for(int i=0;i<5;i++){
            if(f[i]!=0){
                ans += sum/f[i];
            }
        }
        cout << ans << endl;
    }else{
        for(int i=0;i<3;i++){
            for(int j=i+1;j<4;j++){
                for(int n=j+1;n<5;n++){
                    ans += f[i]*f[j]*f[n];
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
//typedef long long int LL;
//typedef __int64 LL;

int n;
int pos[505];;
int ans[250004];

struct Num {
	int num, pos, left;
	Num(int _num, int _pos, int _left) {
		num = _num;
		pos = _pos;
		left = _left;
	}
	Num() {}
};

bool operator<(Num A, Num B) {
	return  (A.pos > B.pos);
}

priority_queue<Num> PQ;
queue<Num> Q;
int remaining[505];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &pos[i]);
		ans[pos[i]] = i;
		PQ.push(Num(i, pos[i], i - 1));
		remaining[i] = i - 1;
	}

	for (int i = 1; i <= n * n; i++) {
		if (ans[i] != 0) {
			if (remaining[ans[i]]) {
				printf("No\n");
				return 0;
			}
			Q.push(Num(ans[i], 0, n - ans[i]));
			continue;
		}

		while (!PQ.empty()) {
			if (PQ.top().left == 0) PQ.pop();
			else break;
		}

		if (PQ.empty()) {
			while (!Q.empty()) {
				Num u = Q.front();
				Q.pop();
				if (u.left == 0) {
					continue;
				}
				ans[i] = u.num;
				u.left--;
				Q.push(u);
				break;

			}
			if (ans[i] == 0) {
				printf("No\n");
				return 0;
			}
			continue;
		}

		while (!PQ.empty()) {
			Num u = PQ.top();
			PQ.pop();
			if (u.left == 0) {
				continue;
			}
			ans[i] = u.num;
			remaining[u.num]--;
			u.left--;
			PQ.push(u);
			break;
		}
		if (ans[i] == 0) {
			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");
	for (int i = 1; i <= n * n; i++) {
		if (i > 1) printf(" ");
		printf("%d", ans[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2176
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string read = rstr();
        string ans = "Yes";
        for(int i=0;i<read.Length;i++){
            if(read[i] == 'U' || read[i] == 'D'){
                continue;
            }
            if(i%2== 0 && read[i] == 'R'){
                continue;
            }
            if(i%2== 1 && read[i] == 'L'){
                continue;
            }
            ans = "No";
        }
        WriteLine(ans);

    
    }
    //各種読取
    static string rstr(){ return ReadLine(); }
    static int rint(){ return int.Parse(ReadLine()); }
    static long rlong(){ return long.Parse(ReadLine()); }
    static string[] stra(){ return ReadLine().Split(' '); }
    static int[] inta(){ string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for(int countup_i=0;countup_i<read_str_array.Length;countup_i++){ return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; }
    static int[,] inta2(int num_array,int in_array){ int[,] int_array2 = new int[num_array,in_array]; for(int i=0;i<num_array;i++){ int[] temp_array = inta(); for(int j=0;j<in_array;j++){ int_array2[i,j] = temp_array[j]; } } return int_array2; }
    static long[] longa(){ string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for(long countup_i=0;countup_i<read_str_array.Length;countup_i++){ return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; }
    static double[] doublea(){ string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for(long countup_i=0;countup_i<read_str_array.Length;countup_i++){ return_double_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_double_array; }
    // A/B小数点以下切上
    static long divideup(long divided,long divid){ long temp_divide = divided/divid; if(divided % divid > 0){ temp_divide++; } return temp_divide; }
    static long GCD(long a,long b){ if(a < b){ long temp = a; a = b; b = temp; } if(a % b == 0){ return b; } else{ long temp = b; b = a%b; a = temp; return GCD(a,b); } }
    static long LCM(long a,long b){ return a * b / GCD(a,b); }
}
//知見
// (string) hogestr -> (char[]) hoge
    // char hoge = hogestr.ToCharArray();
// (char[]) hoge -> (string) hogestr
    // string hoge = new string(hoge);
// Hashtable ×  Dictionary ○
// Dictionary hoge<string,int>
    // hoge.ContainsKey(string) -> return boolean
    // hoge[string] -> return int
    // hoge[int] -> CE
// Dictionary hoge<int1,int2>
    // hoge<int1,int2>: hoge[int1] -> return int2
    // KeyValuePair<int,int> k <-> k.Key == int1 / k.Value == int2
// SortedDictionary() > SortedList() ???
// キュー　-> 幅優先 ???
// スタック -> 深さ優先 ???


Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <queue>
#include <cmath>
#include <random>
#include <fstream>
#include <string>
#include <tuple>
#include <deque>
#include <set>
#include <map>
#include <stack>

#define REP(i, N) for(int i = 0; i< N; i++)
using namespace std;
#define ll long long
const int INF = 1 << 29;
const ll llINF = 10000000000000000;

const int MOD = 1000000007;

#define MAX_N 100100
typedef pair<int, int> P;
typedef pair<ll, ll> llP;

class UnionFindTree{
private:
    int par[MAX_N];
    int urank[MAX_N];
    int size[MAX_N];
public:
    int init(int n);
    int find(int x);
    int unite(int x, int y);
    int same(int x, int y);
    int parnum(int x){return par[x];}
    int ranknum(int x){return urank[x];}
    int sizenum(int x){return size[find(x)];}
};

int UnionFindTree::init(int n){
    REP(i, n){
        par[i] = i;
        urank[i] = 0;
        size[i] = 1;
    }
    return 0;
}

int UnionFindTree::find(int x){
    if(par[x] == x)return x;
    else return par[x] = find(par[x]);
}

int UnionFindTree::unite(int x, int y){
    x = find(x);
    y = find(y);
    
    if(x == y)return 0;
    if(urank[x] < urank[y]){
        par[x] = y;
        size[y] += size[x];
    }else{
        par[y] = x;
        size[x] += size[y];
        if(urank[x] == urank[y])urank[x] ++;
    }
    return 0;
}

int UnionFindTree::same(int x, int y){
    return find(x) == find(y);
}


int bit[100100], N;
int S[100100];
int sum(int i){
    int s = 0;
    while(i  > 0){
        s += bit[i];
        i -= i & -i;
    }
    return s;
}
void add(int i, int x){
    while(i <= N){
        bit[i] += x;
        i += i & -i;
    }
}
int a[100100];

int main(){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3 = x2 + (y1 - y2);
    int y3 = y2 - (x1 - x2);
    int x4 = x3 + (y2 - y3);
    int y4 = y3 - (x2 - x3);
    printf("%d %d %d %d\n", x3, y3, x4, y4);
}


Measured memory_bytes: 888
n=int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans=0
for i in range(n):
    ans+=b[a[i]-1]
    if i<n-1:
        if a[i]==a[i+1]-1:
            ans+=c[a[i]-1]
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}

int main() {
    string s;
    cin >> s;
    cout << s[0] << s[1] << s[2] << endl;
}

Measured memory_bytes: 3624
// Aizu Vol-1 0123: Speed Skating Badge Test
// 2017.7.29

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

char *gets(char *);
char buf[100], *p;

int getDouble(void)
{
	int len = 0, n = 0;

	while (isspace(*p)) p++;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0');
	if (*p == '.') p++;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0'), len++;
#define MAGIC 2
	while (len < MAGIC) n = 10 * n, len++;
	return n;
}

typedef struct { char *a; int t1, t2; } T;
T class[8] = {
	{ "AAA", 3550, 7100 },
	{ "AA",  3750, 7700 },
	{ "A",   4000, 8300 },
	{ "B",   4300, 8900 },
	{ "C",   5000, 10500 },
	{ "D",   5500, 11600 },
	{ "E",   7000, 14800 },
	{ "NA",  100000, 100000 },
};

int main()
{
	int t1, t2;
	T *t;

	while (gets(p = buf) != NULL) {
		t1 = getDouble(), t2 = getDouble();
		for (t = class; ; t++) {
			if (t1 < t->t1 && t2 < t->t2) { puts(t->a); break; }
		}
	}
	return 0;
}

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

int main() {
  int n;  cin >> n;
  int h[n];
  rep(i,n)
  cin >> h[i];
  int ans=0;
  int cnt=0;
  for(int i=0;i<n-1;i++){
    if(h[i+1]<=h[i])
    cnt++;
    else 
    cnt=0;
    ans=max(cnt,ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  ll N,ans=0,t=1;
  cin>>N;
  vector<string> SS;
  
  for(int i=1; i<=N; ++i){
    string Q;
    cin>>Q;
    
    for(int j=0; j<=8; ++j){
      for(int k=j+1; k<=9; ++k){
        if(Q.at(j)>Q.at(k)){
          char a=Q.at(j);
          Q.at(j)=Q.at(k);
          Q.at(k)=a;
        }
      }
    }
    
    SS.push_back(Q);
  }
  
  SORT(SS);
  
  for(int i=1; i<N; ++i){
    if(SS.at(i-1)!=SS.at(i) || i==N-1){
      if(i==N-1 && SS.at(i-1)==SS.at(i)) t++;
      ans+=t*(t-1)/2;
      t=1;
    }
    else t++;
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 5748
#include<iostream>
using namespace std;
 
int main(){
  int width, height, x, y, radius;
  cin >> width >> height >> x >> y >> radius; // read
  
  // judge
  if(x < radius || width < x + radius) {
    cout << "No" << endl;
  } else if (y < radius || height < y + radius) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  
  return 0;
}

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

bool path[8][8];
int cnt,n;

void search(int d,int prev,bool visited[]){
    int i;
    if(d==n){
        cnt++;
        return;
    }
    for(i=1;i<n;i++){
        if(visited[i]==0&&path[prev][i]==1){
            visited[i]=1;
            search(d+1,i,visited);
            visited[i]=0;
        }
    }
    return;
}

int main(void){
  int m,i,a,b;
  cin>>n>>m;
  for(i=0;i<m;i++){
    cin>>a>>b;
    a--;
    b--;
    path[a][b]=1;
    path[b][a]=1;
  }
  
  bool visited[8]={1};
  search(1,0,visited);
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
S=input()
for id,x in enumerate(S):
  if id % 2 == 0:
    if (x not in ["R","U","D"]):
      print("No")
      break
  if id % 2 == 1:
    if (x not in ["L","U","D"]):
      print("No")
      break
else:
  print("Yes")

Measured memory_bytes: 3060
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        s : String,
    }


    let ans : usize = match s.as_str(){
        "SSS" => 0,
        "RRS" => 2,
        "SRR" => 2,
        "RRR" => 3,
        "RSR" => 1,
        "SRS" => 1,
        "RSS" => 1,
        "SSR" => 1,
        _ => 0,
    };

    println!("{}",ans);
}


Measured memory_bytes: 2200
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>

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

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

    int sum = 0;
    string s = to_string(n);
    rep(i, 0, s.size())
    {
        sum += s[i] - '0';
    }
    if (n % sum == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

int main() {
    int c[10][10] = {0};
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }

    int d[10][10] = {0};
    for (int a1 = 0; a1 <= 100; a1++) {
        for (int a2 = 0; a2 <= 100; a2++) {
            for (int a3 = 0; a3 <= 100; a3++) {

                for (int i = 0; i < 3; i++) {
                    for (int j = 0; j < 3; j++) {
                        d[i][j] = c[i][j];
                    }
                }
                for (int i = 0; i < 3; i++) {
                    if (i == 0) {
                        for (int j = 0; j < 3; j++) {
                            d[i][j] -= a1;
                        }
                    }
                    else if (i == 1) {
                        for (int j = 0; j < 3; j++) {
                            d[i][j] -= a2;
                        }
                    }
                    else {
                        for (int j = 0; j < 3; j++) {
                            d[i][j] -= a3;
                        }
                    }
                }

                bool f = true;
                for (int j = 0; j < 3; j++) {
                    for (int i = 0; i < 2; i++) {
                        if (d[i][j] != d[i + 1][j]) f = false;
                    }
                }

                if (f) {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    
    cout << "No" << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include<iostream>
int main(){
    int n,a,b,c,d;
    std::cin>>n>>a>>b>>c>>d;
    
    int cnt1,cnt2,pri1,pri2;
    if(n%a==0){
        cnt1=n/a;
        pri1=cnt1*b;
    }else{
        cnt1=(n/a)+1;
        pri1=cnt1*b;
    }
    if(n%c==0){
        cnt2=n/c;
        pri2=cnt2*d;
    }else{
        cnt2=(n/c)+1;
        pri2=cnt2*d;
    }
    if(pri1<=pri2){
        std::cout<<pri1<<"\n";
    }else{
        std::cout<<pri2<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<string>
#include<cstring>
#include<functional> 
#include<bitset>
using namespace std;
typedef	long long int ll;

int main(){
    int a[200001] = {};
    int n,k;
    cin >> n >> k;
    int ai;
    for(int i = 0; i < n; i++){
        cin >> ai;
        a[ai]++;
    }
    vector<int> v;
    for(int i = 1; i < 200001; i++){
        if(a[i]>0){
            v.push_back(a[i]);
        }
    }
    sort(v.begin(), v.end());
    int res = 0;
    if(v.size()>k){
        for(int i = 0; i < v.size()-k; i++){
            res += v[i];
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 2168
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

#define EPS 1e-10

struct Point {
    double x, y;

    Point (double x = 0, double y = 0) : x(x), y(y) {}
    
    Point operator-(Point p) {
        return Point(x - p.x, y - p.y);
    }

    double dot(Point p) {
        return x * p.x + y * p.y;
    }
    
    double cross(Point p) {
        return x * p.y - y * p.x;
    }
};

int contains(vector<Point> g, Point p) {
    int n = g.size();
    bool x = false;
    for (int i = 0; i < n; i++) {
        Point a = g[i] - p, b = g[(i + 1) % n] - p;
        if (abs(a.cross(b)) < EPS && a.dot(b) < EPS) {
            return 1;
        }
        if (a.y > b.y) {
            swap(a, b);
        }
        if (a.y < EPS && EPS < b.y && a.cross(b) > EPS) {
            x = !x;
        }
    }
    return (x ? 2 : 0);
}

int main() {
    int n, q;
    cin >> n;
    vector<Point> polygon(n);
    for (int i = 0; i < n; i++) {
        cin >> polygon[i].x >> polygon[i].y;
    }
    cin >> q;
    Point p;
    while (q--) {
        cin >> p.x >> p.y;
        cout << contains(polygon, p) << endl;
    }

    return 0;
}

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

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

        long num = 0;

        int k = int.Parse(inp[0]);
        for(int i = 1;i < k + 1;i++) {
            for(int j = 1;j < k + 1;j++) {
                for(int ii = 1;ii < k + 1;ii++) {
                    num += Gcd3(i,j,ii);
                }
            }
        }

        Console.WriteLine(num);
    }

    static int Gcd3 (int a,int b,int c) {
        return Gcd2(Gcd2(a,b),Gcd2(b,c));
    }

    static int Gcd2 (int a,int b) {
        int t = a % b;
        if(t == 0) {
            return b;
        } else {
            return Gcd2(b,t);
        }
    }
}

Measured memory_bytes: 27544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){

    int N,K;cin>>N>>K;
    int M=sqrt(N);
    
    ll dp1[K+1][M+1];//iまでみた、数字がj
    ll dp2[K+1][M+1];//iまでみた推移先がj個
    
    for(int i=0;i<K+1;i++){
        for(int j=0;j<M+1;j++){
            dp1[i][j]=0;
            dp2[i][j]=0;
        }
    }
    
    for(int j=1;j<=M;j++){
        dp1[1][j]=1;
    }
    
    int sum=M;
    
    for(int j=M;j>=1;j--){
        int to=N/j;
        dp2[1][j]=to-sum;
        sum=to;
    }
    
    for(int i=2;i<=K;i++){
        vector<ll> S1(M+1,0),S2(M+1,0);
        for(int k=1;k<=M;k++){
            S1[k]=(S1[k-1]+dp1[i-1][k])%mod;
        }
        for(int k=1;k<=M;k++){
            S2[k]=(S2[k-1]+dp2[i-1][k])%mod;
        }
        for(int j=1;j<=M;j++){
            dp1[i][j]=(S1[M]+S2[M]-S2[j-1]+mod)%mod;
        }
        for(int j=1;j<=M;j++){
            dp2[i][j]=(dp2[1][j]*S1[j])%mod;
        }
    }
    
    ll ans=0;
    
    for(int j=1;j<=M;j++){
        ans+=dp1[K][j];
        ans+=dp2[K][j];
        ans=ans%mod;
    }
    
    cout<<ans<<endl;
    
    
}


Measured memory_bytes: 50688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
    int n;
    cin >> n;
    set<string> s;
    vector<string> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
        s.insert(v[i]);
    }

    bool flag = true;
    for(int i = 0; i < n-1; i++)
        if(v[i].back() != v[i+1][0]) flag = false;
    
    if(flag && (int)s.size() == n) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define vec2 vector<vector<lli>>
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define FRE freopen("input.txt","r",stdin);freopen("ans.txt","w",stdout)
#define mp make_pair
#define pll pair <lli,lli>
#define vll vector <lli>
#define pq2 priority_queue<pair<lli,lli>>
#define f first
#define s second
#define pb push_back
#define pf push_front
#define minii LLONG_MAX
#define all(x) x.begin(), x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define ld long double
const long double pi = 3.1415926535898;
#define dec greater<lli>()
const lli mod=1000000007;
//const lli mod=100000000;
using namespace std;
lli lcm (lli a, lli b) {return ((a*b)/__gcd(a,b));}
lli modpower (lli a,lli b)
{
    if(b==0) return 1;
    lli c=modpower(a,b/2)%mod;
    if (b%2) return (((a*c)%mod)*c)%mod;
    else return (c*c)%mod;
}
lli power (lli a,lli b)
{
    if(b==0) return 1;
    lli c=power(a,b/2);
    if (b%2) return (a*c*c);
    else return c*c;
}
bool prime (lli k)
{
    if (k==1||k==0) return 0;
    bool flag=1;
    lli a=sqrt(k);
    for (int i=2;i<=a;i++)
    {
        if (k%i==0)
        {flag=0;break;}
    }
    return flag;
}
lli sieve (int n)
{
    bool qrr[n+1];
    for (int i=0;i<=n;i++)
    qrr[i]=1;qrr[0]=0;qrr[1]=0;
    for (int i=2;i<=n;i++)
    {
        if (qrr[i]==1)
        {
            for (int j=i;j<=n;j+=i)
            {qrr[j]=0;}
        }
    }
    return 0;
}
int main()
{
    lli n;
    cin>>n;
    if (n%2==0)
    {
        cout<<"-1";
        exit(0);
    }
    lli val=0;
    for (int i=1;i<=100000000;i++)
    {
        val*=10;
        val+=7;
        val%=n;
        if (val==0)
        {
            cout<<i;
            exit(0);
        }
    }
    cout<<"-1";
    return 0;
}

Measured memory_bytes: 3668
const main = (input) => {
 	const s = input.trim()
    const maxCnt = Math.floor(s.length/2)
    let result = 0
    for (let i = 0; i < maxCnt; i++) {
      const a = s[i]
      const z = s[s.length-1-i]
      if (a !== z) result++
    }
  console.log(result)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
import java.util.Scanner;
 class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(),x;
		if(a > b){
			x = a;
			a = b;
			b = x;
		}
		if(a > c){
			x = a;
			a = c;
			c = x;
		}
		if(b > c){
			x = b;
			b = c;
			c = x;
		}
		System.out.println(a+" "+b+" "+c);
	}
 }

Measured memory_bytes: 26216
#include <stdio.h>
int main(){
  int n,b,c,i,s;
  int min = 1000;
  int max = 0;
  int T[20];
  b = 0;
  T[b] = 0;
  while(1){
    scanf("%d",&n);
    if(n == 0)break;
    for(i=0;i<n;i++){
      scanf("%d",&s);
      if(s >= max) max = s;
      if(s <= min) min = s;
      T[b] += s;
    }
    T[b] = (T[b] - (min + max))/ (i - 2);
    b++;
    min = 1000;
    max = 0;
    i = 0;
    T[b] = 0;
  }
  for(c = 0; c<b; c++){
    printf("%d\n",T[c]);
  }
  return 0;
}

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

#define ARC(i, a, b) for(int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)

template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T &anth(T &a, const T &b){ return a = ant(a, b); }
template<class T> T &onth(T &a, const T &b){ return a = ont(a, b); }

int main(){
	int x, y, s;
	while(std::cin >> x >> y >> s, (x || y || s)){
		int max = 0;
		for(int a = 1; a <= s / 2; ++a){
			int b = (s - (a * (100 + x)) / 100 + 1) * 100 / (100 + x);
			if((s - (a * (100 + x)) / 100 + 1) * 100 == b * (100 + x)) --b;
			if((a * (100 + x) / 100) + (b * (100 + x) / 100) == s){
				//printf("%d %d %d+%d=%d\n", a, b, (a * (100 + y) / 100), (b * (100 + y) / 100), (a * (100 + y) / 100) + (b * (100 + y) / 100));
				max = ant(max, (a * (100 + y) / 100) + (b * (100 + y) / 100));
			}
		}
		std::cout << max << std::endl;
	}
}



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

int main(void)
{
	float x,y;
	cin>>x>>y;
	
	//float t = (y-2*x)/2;
	//int t_int = (y-2*x)/2;
	float val = y/x;
	//float t_frac = t - t_int;
	if(int(y)%2 == 0)
	{
		if(val <= 4 && val >= 2)
		{
			cout<<"Yes"<<endl;
		}
		else
		{
			cout<<"No"<<endl;
		}
	}
	else
	cout<<"No"<<endl;
//	cout.precision(6);
//	cout<<fixed<<t<<endl;
	
	return 0;
}


Measured memory_bytes: 3680
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func binarySearch(b []int, max, v int) int {
	min := 0
	i := max / 2
	//count :=0
	for min < max {
		debugf("b: %v\n", b)
		debugf("v: %d, i: %d, min: %d, max: %d\n", v, i, min, max)
		i = (max + min) / 2
		if v <= b[i] {
			min = i + 1
		} else if b[i] < v {
			max = i
			if i == (max + min) / 2 {
				debugf("return3 i: %d\n", i)
				//return i
			}
		}
	}
	debugf("v: %d, i: %d, min: %d, max: %d\n", v, i, min, max)
	debugf("return i: %d\n", min)
	return min
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, n)
	b := make([]int, n)
	for i := range b {
		b[i] = -1
	}

	ans := 0
	for i := range a {
		a[i] = nextInt()
	}
	debugf("a: %v\n", a)
	for i := range a {
		//j := sort.Search(ans, func(k int) bool { return b[k] < a[i] })
		j := binarySearch(b, ans, a[i])
		if b[j] == -1 {
			b[j] = a[i]
			ans++
		} else if b[j] < a[i] {
			b[j] = a[i]
		}// else if b[j] > a[i] && j < n-1 && b[j+1] == -1 {
		//	b[j+1] = a[i]
		//	ans++
		//}
		debugf("b: %v\n", b)
		/*
		for j := range b {
			if b[j] == -1 {
				b[j] = a[i]
				ans++
				break
			} else if b[j] < a[i] {
				b[j] = a[i]
				break
			}
		}
		*/
	}

	_, _ = fmt.Fprintf(writer, "%d", ans)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int n,k;
  cin>>n>>k;
  int h[n];
  int i;
  int dp[n];
  for(i=0;i<n;i++)
  {
  	cin>>h[i];
    dp[i]=INT_MAX;
  }
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(i=2;i<n;i++)  
  {
    int mx=k;
    for(int j=0;j<i && mx>0;j++,mx--)
      dp[i]=min(dp[i],dp[i-j-1]+abs(h[i]-h[i-j-1])); 
  }
  cout<<dp[n-1]<<"\n";  
  return 0;
}

Measured memory_bytes: 1024