akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();

    if(S.substring(0,N/2).equals(S.substring(N/2,N))){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 22740
#include <stdio.h>

int main(void) {
	int hit_num;
	char hit_numbers[100][12];
	int hit_money[100];
	int get_money;
	char input_number[12];
	int input_num;
	int i,j,k;
	while(1) {
		scanf("%d%d",&hit_num,&input_num);
		if(hit_num==0)break;
		for(i=0;i<hit_num;i++) {
			scanf("%s%d",hit_numbers[i],&hit_money[i]);
		}
		get_money=0;
		for(i=0;i<input_num;i++) {
			scanf("%s",input_number);
			for(j=0;j<hit_num;j++) {
				for(k=0;k<8;k++) {
					if(hit_numbers[j][k]!='*' &&
						hit_numbers[j][k]!=input_number[k])break;
				}
				if(k>=8) {
					get_money+=hit_money[j];
					break;
				}
			}
		}
		printf("%d\n",get_money);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;

int main(){
  int N;  cin >> N;
  cout << N*N*N << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

int a;
vector<int> l;

void printParentIfAvailable(int index) {
    if (index / 2) {
        cout << "parent key = " << l[index / 2 - 1] << ", ";
    }
}

void printLeftIfAvailable(int index) {
    if (index * 2 <= a) {
        cout << "left key = " << l[index * 2 - 1] << ", ";
    }
}

void printRightIfAvailable(int index) {
    if (index * 2 + 1 <= a) {
        cout << "right key = " << l[index * 2] << ", ";
    }
}

int main() {
    cin >> a;
    PUSH(a, l);
    REP(i,a) {
        cout << "node " << i+1 << ": key = " << l[i] << ", ";
        printParentIfAvailable(i+1);
        printLeftIfAvailable(i+1);
        printRightIfAvailable(i+1);
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1220
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("CODEFESTIVAL");
            //Yes
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("FESTIVALCODE");
            //No
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("CF");
            //Yes
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("FCF");
            //Yes
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        string S = InputList[0];

        Console.WriteLine(Regex.IsMatch(S, "C.*F") ? "Yes" : "No");
    }
}


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

int main()
{
  int H, W;

  while(true){
      cin >> H >> W;
      if(H==0&W==0) break;
      else {
        for(int i=0; i<H; i++){
          for(int j=0; j<W; j++){
            if(i==0|i==H-1|j==0|j==W-1){
              cout << "#";
            }
            else  cout << ".";
          }
          cout << endl;
        }
        cout << endl;
      }
  }
}


Measured memory_bytes: 3084
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
#include<vector>
using namespace std;

int main(void) {
	int r, g, b;
	cin >> r >> g >> b;
	if ((10 * g + b) % 4 == 0) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int MAX_NUM = 105;
const int MAX_WEIGHT = 10005;

int main()
{
    int N, W, dp[MAX_NUM][MAX_WEIGHT] = {}, v[MAX_NUM], w[MAX_NUM], ans = -1;
    cin >> N >> W;
    for(int i=0;i<N;++i) cin >> v[i] >> w[i];
    
    for(int i=0;i<N;++i)
    {
        for(int j=0;j<W+1;++j)
        {
            if(j >= w[i])
            {
                dp[i+1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
                ans = max(dp[i+1][j], ans);
            }
            else{
                dp[i+1][j] = dp[i][j];
            }

        }
    }

    cout << ans << endl;
}


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

#define SZ(v) ((int)(v).size())
using ll = long long;

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

	int ahealth, astr, bhealth, bstr;
	cin >> ahealth >> astr >> bhealth >> bstr;
	int p(0);
	while (1)
	{
		if (!p)
		{
			bhealth -= astr;
			if (bhealth <= 0)
			{
				cout << "Yes" << endl;
				return 0;
			}
		}
		else
		{
			ahealth -= bstr;
			if (ahealth <= 0)
			{
				cout << "No" << endl;
				return 0;
			}
		}
		p ^= 1;
	}
}


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long w = sc.nextLong();
        long h = sc.nextLong();
        long x = sc.nextLong();
        long y = sc.nextLong();
        
        if (w == x * 2 && h == y * 2) {
            System.out.println((double) w * h / 2 + " " + 1);
        } else {
            System.out.println((double) w * h / 2 + " " + 0);
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
using namespace std;

int main(){
	int a[4],b[4];
	while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]){
		int hit = 0, blow = 0;
		for(int i = 0; i < 4; i++){
			if(b[i] == a[i])hit++;
			else{
				for(int j = 0; j < 4; j++){
					if(b[i] == a[j])blow++;
				}
			}
		}
		cout << hit << " " << blow << endl;
	}
}


Measured memory_bytes: 3016
#include "bits/stdc++.h"
using namespace std;


int main()
{
	string s;
	cin >> s;
	int n = s.size();

	vector<int> ans(n);
	int cnt_odd = 0;
	int cnt_even = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') {
			if (i % 2 != 0) {
				cnt_odd++;
			} else {
				cnt_even++;
			}
			continue;
		} else {
			if (i % 2 != 0) {
				ans.at(i) += cnt_odd;
				ans.at(i - 1) += cnt_even;
			} else {
				ans.at(i) += cnt_even;
				ans.at(i - 1) += cnt_odd;
			}
			cnt_odd = 0;
			cnt_even = 0;
		}
	}
	cnt_odd = 0;
	cnt_even = 0;
	for (int i = n - 1; 0 <= i; i--) {
		if (s[i] == 'L') {
			if (i % 2 != 0) {
				cnt_odd++;
			} else {
				cnt_even++;
			}
			continue;
		} else {
			if (i % 2 != 0) {
				ans.at(i) += cnt_odd;
				ans.at(i + 1) += cnt_even;
			} else {
				ans.at(i) += cnt_even;
				ans.at(i + 1) += cnt_odd;
			}
			cnt_odd = 0;
			cnt_even = 0;
		}
	}

	for (int i = 0; i < n; i++) {
		cout << ans.at(i) << " ";
	}
	cout << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 

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

  vector<ll> dp(n,1ll<<60);
  vector<ll> h(n);

  rep(i,n) cin >> h.at(i);

  dp.at(0) = 0;
  dp.at(1) = abs(h.at(1) - h.at(0));

  for(int i=2; i<n; i++){
    chmin(dp.at(i), dp.at(i-1)+abs(h.at(i)-h.at(i-1)));
    chmin(dp.at(i), dp.at(i-2)+abs(h.at(i)-h.at(i-2)));
  }

  cout << dp.at(n-1) << endl;

}


Measured memory_bytes: 1792
use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();

    let mut iter = input.split_whitespace();
    let a = iter.next().unwrap().parse::<i32>().unwrap();
    let b = iter.next().unwrap().parse::<i32>().unwrap();
    let area = a * b;
    let perimeter = 2 * a + 2 * b;

    println!("{} {}", area, perimeter);
}



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

int main(){
    int x;
    cin >> x;
    if(x == 7 || x == 5 || x == 3) cout << "YES ";
    else cout << "NO ";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int sum=0;
  string s,t;
  cin>>s>>t;
  for(int i=0;i<3;i++){
    if(s[i]==t[i]){
      sum+=1;
    }
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    b = LI()
    ans = []
    for j in range(n):
        for i in range(len(b))[::-1]:
            if b[i] == i+1:
                x = b.pop(i)
                ans.append(x)
                break
    if b:
        print(-1)
    else:
        print(*ans[::-1],sep = "\n")
    return

#B
def B():
    n,a,b,c,d = LI()
    s = S()
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    k = b
    while b < d:
        if s[b+1] == ".":
            b += 1
        else:
            if s[b+2] == "#":
                print("No")
                return
            b += 2
    b = k
    if c < d:
        while a < c:
            if s[a+1] == ".":
                a += 1
            else:
                if s[a+2] == "#":
                    print("No")
                    return
                a += 2
        print("Yes")
    else:
        for i in range(b-1,d):
            if s[i:i+3].count(".") == 3:
                print("Yes")
                return
        print("No")
    return

#C
def C():
    n,a,b,c,d = LI()
    if abs(b-a) > (n-1)*d:
        print("NO")
        return
    if 2*c <= (n-1)*(d-c):
        print("YES")
        return
    mi = a-(n-1)*d
    m = c+d
    f = 1+(n-1)*(d-c)
    if f >= m:
        print("YES")
        return
    if (b-mi)%m < f:
        print("YES")
    else:
        print("NO")
    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 39536
import sys
h, w = map(int, input().split())
if h == 1 or w == 1:
  print(1)
  sys.exit()
ans = h//2*w
if h%2 != 0:
  if w%2 != 0:
    ans += w//2+1
  else:
    ans += w/2
print(int(ans))

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

int main(){
  ll n,a,b;cin >> n >> a >> b;
  ll ans=n/(a+b);
    if(n%(a+b)>=a){
      ans*=a;
      ans+=a;
    }else{
      ans*=a;
      ans+=n%(a+b);
    }
  cout << ans << endl;
}


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

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

ll LCM(ll a, ll b) {
    ll x=a*b,r;
    if(a<b)
        swap(a, b);

    r = a%b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }

    return x/b;
}

int RR(int x) {
    int r=0;
    while(x%2 == 0) {
        x /= 2;
        r++;
    }
    return r;
}

int main() {
    ll N,M,x=1,t;
    cin >> N >> M;
    vector<ll> a(N);

    rep(i,N) {
        cin >> a.at(i);
        if(a.at(i)%2 == 1) {
            cout << 0 << endl;
            return 0;
        }
        a.at(i) /= 2;
    }

    t = RR(a.at(0));
    rep(i,N) {
        if(RR(a.at(i)) != t) {
            cout << 0 << endl;
            return 0;
        }
        a.at(i) >>= t;
    }
    M >>= t;
    
    rep(i,N) {
        x = LCM(x, a.at(i));
        if(x > M) {
            cout << 0 << endl;
            return 0;
        }
    }

    cout << (M/x+1)/2 << endl;
}

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

int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    long long ans = 0;
    for(int b=k+1;b<=n;b++)
    {
        long long t = n/b;
        ans += t*(b-k);
        t = n%b;
        if(t>=k) ans += t-k+1;
    }
    if(k == 0) ans -= n;
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <iostream>

using namespace std;

int main(void){
    int K;
    string S;
    cin >> K;
    cin >> S;
    if(S.length()<=K) cout<<S<<"\n";
    else {
        for(int i = 0; i < K; i++) {
            printf("%c", S[i]);
        }
        printf("...\n");
    }

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define PI 3.14159265358979
#define ll long long
using namespace std;

int ipow(int x,int y)
{
	int z = 1;
	for (int i = 0; i < y; i++) {
		z *= x;
	}

	return z;
}

void next(int* ar,int n,int deg)
{
	for (int i = 0; i < deg; i++) {
		ar[i] = n % 2;
		n /= 2;
	}
}

struct text {
	int cost;
	int point[12];
};

int main()
{
	int n, m, x;
	cin >> n >> m >> x;
	//cin >> n;
	int cost = -1;
	int* use = new int[n];
	int z = ipow(2, n);
	vector<text> dp(n);
	vector<int> p(m, 0);
	int dcost = 0;

	for (int i = 0; i < n; i++) {
		cin >> dp[i].cost;
		for (int j = 0; j < m; j++) {
			cin >> dp[i].point[j];
		}
	}

	for (int i = 0; i < z; i++) {
		next(use, i, n);
		dcost = 0;
		for (int j = 0; j < m; j++) {
			p[j] = 0;
		}
		for (int j = 0; j < n; j++) {
			if (use[j]) {
				dcost += dp[j].cost;
				for (int k = 0; k < m; k++) {
					if (p[k] >= x)continue;
					p[k] += dp[j].point[k];
				}
				bool flag = true;
				for (int k = 0; k < m; k++) {
					if (p[k] < x) {
						flag = false;
						break;
					}
				}
				if (flag) {
					if (cost == -1 || cost > dcost) {
						cost = dcost;
					}
				}
			}
		}
	}
	
	printf("%d", cost);
	


	return 0;
}



Measured memory_bytes: 3732
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define all(a) a.begin(),a.end()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)

typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

const int inf = 1e9;

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

int R;
int W[2], H[2];
int X[2], Y[2];
int A[2][502][502];

bool used[502][502];

vpii data[2];

void bfs(int num)
{
	typedef pair<int, pii> Data;
	memset(used, false, sizeof(used));

	priority_queue<Data> q;

	q.push(Data(-1, pii(Y[num], X[num])));
	used[Y[num]][X[num]] = true;

	if (num == 0) {
		data[num].PB(pii(1, 0));
	} else {
		data[num].PB(pii(0, 0));
		data[num].PB(pii(0, 1));
	}

	int ma = 1;
	int cnt = 0;

	while (q.size()) {
		Data p = q.top(); q.pop();

		int cur = -p.fst;

		if (ma < cur) {
			if (num == 0) {
				data[num].back().scd = cnt;
				ma = cur;
				data[num].PB(pii(ma, 0));
			} else {
				data[num].back().fst = cnt;
				ma = cur;
				data[num].PB(pii(0, ma));
			}
		}

		cnt++;

		rep(i, 4) {
			int ny = p.scd.fst + dy[i], nx = p.scd.scd + dx[i];

			if (ny < 0 || ny >= H[num] || nx < 0 || nx >= W[num] || used[ny][nx]) continue;
			used[ny][nx] = true;

			q.push(Data(-A[num][ny][nx], pii(ny, nx)));
		}
	}

	if (num == 0) {
		data[num].back().scd = cnt;
	} else {
		data[num].back().fst = cnt;
	}
}

signed main()
{
	while (cin >> R, R) {
		data[0].clear();
		data[1].clear();

		rep(i, 2) {
			cin >> W[i] >> H[i] >> X[i] >> Y[i];

			--X[i], --Y[i];

			rep(j, H[i]) rep(k, W[i]) {
				cin >> A[i][j][k];
			}
		}

		bfs(0);
		bfs(1);

		int mi = inf;

		data[1].PB(pii(inf, inf));

		rep(i, data[0].size()) {
			pii a = data[0][i];

			chmin(mi, a.fst + lower_bound(all(data[1]), pii(R - a.scd, -inf))->scd);
		}

		cout << mi << endl;
	}
}

Measured memory_bytes: 7528
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int[] d = new int[101];
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        d[a] += 1;
        d[b] += 1;
        d[c] += 1;
        int ans = 0;
        for (int i = 1; i <= 100; i++) {
            if (0 < d[i]) {
                ans += 1;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}
using path=pair<ll,ll>;
using graph=vector<vector<path>>;

vl dijkstra(graph &g, ll s) {
  vl d(g.size(), LINF);
  priority_queue<path, vector<path>, greater<>> que;
  d[s] = 0;
  que.push(path(0, s)); // cost, index
  while (!que.empty()) {
    path p = que.top(); que.pop();
    int i = p.second;
    if (d[i] < p.first) continue;
    each(x, g[i]) {
      if (d[x.second] > d[i] + x.first) {
        d[x.second] = d[i] + x.first;
        que.push(path(d[x.second], x.second));
      }
    }
  }

  return d;
}

void solve() {
  VAR(int, H, W);
  graph g(10, vector<path>());

  rep(i, 0, 10) {
    rep(j, 0, 10) {
      VAR(int, c);
      g[i].push_back(path(c, j));
    }
  }

  vvi wall(H, vi(W));

  rep(i, 0, H) {
    rep(j, 0, W) {
      in(wall[i][j]);
    }
  }

  vector<ll> v(10);
  rep(i, 0, 10) {
    v[i] = dijkstra(g, i)[1];
  }

  ll ans = 0;

  rep(i, 0, H) {
    rep(j, 0, W) {
      if (wall[i][j] == -1) continue;
      ans += v[wall[i][j]];
    }
  }

  print(ans);
}


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

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        List<int> list = new List<int>();
        for(int i = 0; i < n; i++)
        {
            list.Add(int.Parse(Console.ReadLine()));
        }
        int c = 0;
        List<int> list2 = list.Distinct().ToList();
        for(; ; )
        {
            try
            {
                list2.Remove(list2.Max());
                c++;
            }
            catch
            {
                break;
            }
        }
        Console.WriteLine(c);
    }
}

Measured memory_bytes: 13280
#include<iostream>
#include<algorithm>
using namespace std;
int main (void)
{ 
  long long int n,x,m,ans=0;;
  int i,j,k,d[1000000],dis,l1,l2;
  bool c[1000000];
  
  for(i=0;i<1000000;i++){c[i]=0;d[i]=0;}
  cin>>n>>x>>m;
  c[x]=1;
  d[1]=x;
  if(n<10000000)
  {
    for(i=0;i<n;i++)
    {
     ans+=x;
     x=(x*x)%m;
    }
    cout<<ans<<endl;
    return 0;
  }
  
  
  for(i=0;i<n;i++)
  {
    x=x*x;
    x=x%m;
    if(c[x]==0){c[x]=1;d[i+2]=x;}
    else
    {
      for(j=1;j<n;j++)
      {
        if(d[j]==x)
        {
          dis=i+2-j;
          l2=i+2;
          l1=j;
          break;
        }
      }
      break;
    }
  }
  long long int loop=(n-l1+1)/dis,nokori=(n-l1+1)%dis;
   for(i=l1;i<l2;i++){ans+=d[i];}
   ans*=loop;
  
   for(i=1;i<l1;i++){ans+=d[i];}
  
   for(i=0;i<nokori;i++)
   {
     ans+=d[i+l1];
   }
  
  cout<<ans<<endl;

  
  return 0;
}

Measured memory_bytes: 8504
from collections import Counter

class UnionFind:
    __slots__ = ['id']
    def __init__(self, n):
        self.id = [-1] * n
    def find(self, x):
        if self.id[x] < 0:
            return x
        else:
            self.id[x] = self.find(self.id[x])
            return self.id[x]
    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.id[s1] <= self.id[s2]:
                self.id[s1] += self.id[s2]
                self.id[s2] = s1
            else:
                self.id[s2] += self.id[s1]
                self.id[s1] = s2
            return True
        return False
    def subsetall(self):
        a = []
        for i in range(len(self.id)):
            if self.id[i] < 0:
                a.append((i, -self.id[i]))
        return a

if __name__ == '__main__':
    N, K, L = map(int, input().split())

    uf_K = UnionFind(N)
    uf_L = UnionFind(N)
    for _ in [0] * K:
        p, q = map(int, input().split())
        uf_K.union(p - 1, q - 1)
    for _ in [0] * L:
        r, s = map(int, input().split())
        uf_L.union(r - 1, s - 1)

    keys, d = [], Counter()
    for i in range(N):
        key = uf_K.find(i), uf_L.find(i)
        keys.append(key)
        d[key] += 1

    print(*(d[key] for key in keys))

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

int main() {
    string C;
    cin >> C;
    if (C == "a")
    cout << "b" << endl;
    else if (C == "b")
    cout << "c" << endl;
    else if (C == "c")
    cout << "d" << endl;
    else if (C == "d")
    cout << "e" << endl;
    else if (C == "e")
    cout << "f" << endl;
    else if (C == "f")
    cout << "g" << endl;
    else if (C == "g")
    cout << "h" << endl;
    else if (C == "h")
    cout << "i" << endl;
    else if (C == "i")
    cout << "j" << endl;
    else if (C == "j")
    cout << "k" << endl;
    else if (C == "k")
    cout << "l" << endl;
    else if (C == "l")
    cout << "m" <<endl;
    else if (C == "m")
    cout << "n" << endl;
    else if (C == "n")
    cout << "o" << endl;
    else if (C == "o")
    cout << "p" << endl;
    else if (C == "p")
    cout << "q" << endl;
    else if (C == "q")
    cout << "r" << endl;
    else if (C == "r")
    cout << "s" << endl;
    else if (C == "s")
    cout << "t" << endl;
    else if (C == "t")
    cout << "u" << endl;
    else if (C == "u")
    cout << "v" << endl;
    else if (C == "v")
    cout << "w" << endl;
    else if (C == "w")
    cout << "x" << endl;
    else if (C == "x")
    cout << "y" << endl;
    else if (C == "y")
    cout << "z" << endl;

}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        int n = Reader.NextInt;
        int last = 0;
        int cur = 0;
        int max = 0;
        for (int i = 0; i < n; i++)
        {
            var h = Reader.NextInt;
            if (last >= h) cur++;
            else
            {
                max = Max(max, cur);
                cur = 0;
            }
            last = h;
        }
        Console.WriteLine(Max(max, cur));
    }
}

static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] Buffer = new byte[BUF_SIZE];
    static int ptr = BUF_SIZE - 1;
    private static void Move() { if (++ptr >= Buffer.Length) { Stream.Read(Buffer, 0, BUF_SIZE); ptr = 0; }  }

    public static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; while (Buffer[ptr] < 48) Move();
            do { res = res * 10 + (Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res;
        }
    }

    public static int NextSInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; int sign = 1; while (Buffer[ptr] < 45) Move(); 
            if (Buffer[ptr] == 45) { Move(); sign = -1; }
            do { res = res * 10 + (Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res * sign;
        }
    }

    public static long NextLong
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            long res = 0; while (Buffer[ptr] < 48) Move();
            do { res = res * 10 + (Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res;
        }
    }

    public static long NextSLong
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            long res = 0; int sign = 1; while (Buffer[ptr] < 45) Move();
            if (Buffer[ptr] == 45) { Move(); sign = -1; }
            do { res = res * 10 + (Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res * sign;
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<vector>
using namespace std;
int solve(const vector<int>& l,vector<int>& a,const int& m,int k,int w,int p){
    
    if(k == m)return w;
    int h;
    if(a[k] < 0){
        h = -1;
        a[k] *= (-1);
    }
    else h = 0;
    for(int i = 0;i < a[k];i++){
        w += l[p+h];
        p += 1 + 2*h;
        if(w >= 100000){
            w %= 100000;
        }
    }
    return solve(l,a,m,k + 1,w,p);

}
int main(){
    int n,m;
    cin >> n >> m;
    vector<int>l(n-1);
    vector<int>a(m);
    for(int i = 0;i < n-1;i++){
        cin >> l[i];
    }
    for(int i = 0;i < m;i++){
        cin >> a[i];
    }
    cout << solve(l,a,m,0,0,0) << endl;
    return 0;
}


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

using namespace std;

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  int ans = (int) 1e9 + 1;
  for (int i = 0; i < n; i++) { /* lower bound */
    vector<int> interval, ok;
    for (int j = 0; j <= n; j++) {
      if (j != n && a[j] >= a[i]) {
        interval.emplace_back(a[j]);
      }
      else {
        if ((int)interval.size() >= k) {
          sort(interval.begin(), interval.end());
          for (int ii = 0; ii < (int) interval.size() - k + 1; ii++) {
            ok.emplace_back(interval[ii]);
          }
        }
        interval.clear();
      }
    }
    sort(ok.begin(), ok.end());
    if ((int) ok.size() >= q) {
      ans = min(ans, ok[q - 1] - a[i]);
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string S;
  cin >> S;
  if (S <= "2019/04/30") cout << "Heisei" << endl;
  else cout << "TBD" << endl;
  return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int dp[5001][2];
vector<int> G[5001];

void dfs(int v){
	int sum=0;
	for(int i=0;i<G[v].size();i++){
		dfs(G[v][i]);
		sum+=max(dp[G[v][i]][0],0);
	}
	dp[v][1]=sum;
	int tmp=0;
	for(int i=0;i<G[v].size();i++){
		tmp=max(dp[G[v][i]][1]+1-dp[G[v][i]][0],tmp);
	}
	dp[v][0]=sum+tmp;
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int p;
		scanf("%d",&p);
		G[p].push_back(i+1);
		memset(dp,-1,sizeof(dp));
		dfs(0);
		printf("%d\n",max(dp[0][0],dp[0][1]));
	}
	return 0;
}

Measured memory_bytes: 3480
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class Task{
public:
    void solve(istream& in, ostream& out){
        int N, K;
        in>>N>>K;
        vvc<int> A(N);
        REP(i, N){
            int t, d;
            in>>t>>d;
            t--;
            A[t].pb(d);
        }
        lint ans = 0, sum = 0;
        priority_queue<int> pq;
        priority_queue<int, vector<int>, greater<int>> S;
        REP(i, N){
            if(A[i].empty()) continue;
            sort(RALL(A[i]));
            int m = LEN(A[i]);
            S.push(A[i][0]);
            sum += A[i][0];
            if(LEN(S)>K){
                sum -= S.top();
                S.pop();
            }
            FOR(j, 1, m) pq.push(A[i][j]);
        }
        for(int i=LEN(S);i;--i){
            while(LEN(S)<K and not pq.empty()){
                sum += pq.top();
                S.push(pq.top());
                pq.pop();
            }
            chmax(ans, sum+1ll*i*i);
            if(not S.empty()){
                sum -= S.top();
                S.pop();
            }
        }
        out<<ans<<'\n';
    }
};

int main(){
    istream& in(cin);
    ostream& out(cout);
    ios_base::sync_with_stdio(false);
    in.tie(nullptr), out.tie(nullptr);
    Task solver;
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 6144
n,m = (int(_) for _ in input().split())

ni = [0 for i in range(n)]
nj = [0 for i in range(n)]

mi = [0 for i in range(m)]
mj = [0 for i in range(m)]

for i in range(n):
    ni[i],nj[i] = (int(_) for _ in input().split())

for i in range(m):
    mi[i],mj[i] = (int(_) for _ in input().split())

ans = [0 for i in range(n)]

for i in range(n):
    min_dist = abs(ni[i]-mi[0])+abs(nj[i]-mj[0])
    ans[i] = 1
    for j in range(m):
        cur_dist = abs(ni[i]-mi[j])+abs(nj[i]-mj[j])
        if(min_dist > cur_dist):
            min_dist = cur_dist
            ans[i] = j+1

for i in ans:
    print(i)

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;


public class Main {
	
	public static int solve(char[] str, int start, int end){
		final boolean is_number = !(str[start + 1] == '[' || str[start + 1] == ']');
		/*
		for(int pos = start; pos < end; pos++){
			System.out.print(str[pos]);
		}
		System.out.println();
		*/
		if(is_number){
			int num = 0;
			for(int pos = start + 1; pos < end - 1; pos++){
				num *= 10;
				num += str[pos] - '0';
			}
			
			return num / 2 + 1;
		}else{
			ArrayList<Integer> list = new ArrayList<Integer>();
			
			
			int depth = 0;
			int d_start = -1;
			
			for(int pos = start; pos < end; pos++){
				if(str[pos] == '['){
					if(depth == 1){
						d_start = pos;
					}
					
					depth++;
				}else if(str[pos] == ']'){				
					depth--;
					
					if(depth == 1){
						final int ret = solve(str, d_start, pos + 1);
						
						list.add(ret);
					}
				}
			}
			
			Collections.sort(list);
			//System.out.println(list);
			
			int size = list.size() / 2 + 1;
			int ret = 0;
			for(int i = 0; i < size; i++){
				ret += list.get(i);
			}
			
			return ret;
		}
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
		
		final int n = sc.nextInt();
		
		
		for(int tt = 0; tt < n; tt++){
			final char[] input = sc.next().toCharArray();
			
			
			
			System.out.println(solve(input, 0, input.length));
			
		}
		
	}

}

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

int f[200][200];
int main() {
	int w, h, n; scanf("%d%d%d", &w, &h, &n);
	rep(i, n) {
		int x, y, a; scanf("%d%d%d", &x, &y, &a);
		switch (a) {
		case 1:f[0][0]++; f[x][0]--; break;
		case 2:f[x][0]++; break;
		case 3:f[0][0]++; f[0][y]--; break;
		case 4:f[0][y]++; break;
		}
	}
	for (int i = 1; i < w; i++)rep(j, h)f[i][j] += f[i - 1][j];
	rep(i, w)for (int j = 1; j < h; j++)f[i][j] += f[i][j - 1];
	int cnt = 0;
	rep(i, w)rep(j, h) {
		if (!f[i][j])cnt++;
	}
	printf("%d\n", cnt);
}

Measured memory_bytes: 256
N=int(input())
A=[0] + list(map(int,input().split()))
B=[0]*(N+1)#ボールの管理

#大きい数字から1まで順に見ていく
for i in reversed(range(1,N+1)):
  ball=0
  base=i+1

  #iからNまでiずつ見てボールを足す(j=iの倍数)
  for j in range(i,N+1,i):
    ball+=B[j]

  #もし足したボールの数%2がA[i]と合わないなら合わせる
  if ball%2 != A[i]:
    B[i] = 1

print(sum(B))#ボールの入った箱の総数
#もしBに1が入っている場所があればその場所を出力
print(*[i for i,b in enumerate(B) if b==1],sep=' ')

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

#define PrintLn(X) cout << X << endl
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)

int main(void)
{
	char a[101];
	char b[101];
	cin >> a >> b;
	if(strlen(a) > strlen(b)){
		PrintLn("GREATER");
		return 0;
	}
	if(strlen(a) < strlen(b)){
		PrintLn("LESS");
		return 0;
	}
	Rep(i, strlen(a)){
		if(a[i] > b[i]){
			PrintLn("GREATER");
			return 0;
		}
		if(a[i] < b[i]){
			PrintLn("LESS");
			return 0;
		}
	}
	PrintLn("EQUAL");
	return 0;
}


Measured memory_bytes: 256
#pragma once

#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define all(collection) (collection).begin(), (collection).end()
#define loop(i, times) for(int i = 0; i < times; i++)
#define seloop(i, start_index, end_index) for(int i = start_index; i < end_index; i++)
#define eqseloop(i, start_index, end_index) for(int i = start_index; i <= end_index; i++)

class ABC99C3
{
public:
	void Run(void)
	{
		cin >> n_;
		ans_ = n_;

		Bank6();
		Bank9();
		sort(bank6_collection_.begin(), bank6_collection_.end(), greater<int>());
		sort(bank9_collection_.begin(), bank9_collection_.end(), greater<int>());

		int count = 0;
		loop (i, n_ + 1)
		{
			count = GetMoney(i);
			if (count < ans_)
				ans_ = count;
		}
		cout << ans_;
	}
private:
	int n_;
	int ans_;
	vector<int> bank6_collection_;
	vector<int> bank9_collection_;
	void Bank6(void)
	{
		int get = 1;
		while (1)
		{
			get *= 6;
			if (100000 <= get)
				break;
			bank6_collection_.push_back(get);
		}
	}
	void Bank9(void)
	{
		int get = 1;
		while (1)
		{
			get *= 9;
			if (100000 <= get)
				break;
			bank9_collection_.push_back(get);
		}
	}
	int GetMoney(const int div)
	{
		int money6 = div;
		int money9 = n_ - div;
		int count = 0;

		for (const auto& elm_bank : bank6_collection_)
		{
			while (0 <= money6 - elm_bank)
			{
				money6 -= elm_bank;
				count++;
			}
		}
		count += money6;

		for (const auto& elm_bank : bank9_collection_)
		{
			while (0 <= money9 - elm_bank)
			{
				money9 -= elm_bank;
				count++;
			}
		}
		count += money9;

		return count;
	}

};



int main()
{
	ABC99C3 abc993c;
	abc993c.Run();
	return 0;
}


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

int che(int x)
{
	if (x>0&&x<=12) return 1;
	return 0;
}
int main()
{
    char a[5];
	for (int i=1; i<=4; i++) cin>>a[i];
	int x=(a[1]-'0')*10+a[2]-'0';
	int y=(a[3]-'0')*10+a[4]-'0';
	if (che(x)&&che(y))
	{
		cout << "AMBIGUOUS";
		return 0;
	}
	if (che(x))
	{
		cout << "MMYY";
		return 0;
	}
	if (che(y))
	{
		cout << "YYMM";
		return 0;
	}
	cout << "NA";
 } 

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static int n;
    static int[] a;
    static int[] dp;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        a = new int[n];
        for (int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }
        dp = new int[n+1];
        dp[0] = 0;
        for (int i=1; i<n; i++) {
            if (i == 1) {
                dp[i] = Math.abs(a[i] - a[i-1]);
            } else {
                dp[i] = Math.min(Math.abs(a[i] - a[i-1]) + dp[i-1], Math.abs(a[i] - a[i-2]) + dp[i-2]);
            }
        }
        System.out.println(dp[n-1]);
    }
}

Measured memory_bytes: 52244
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using Debug;
//using static System.Globalization.CultureInfo;

class Program
{
    class C:IComparable<C>
    {
        public long cost;
        public bool isw;
        public C(long cost,bool isw)
        {
            this.cost = cost;
            this.isw = isw;
        }
        public int CompareTo(C c)
            => cost.CompareTo(c.cost);
    }
    static void Main(string[] args)
    {
        var wh = Input.ar;
        var cost = new C[wh[0] + wh[1]];
        for (var i = 0; i < wh[0]; i++)
            cost[i] = new C(Input.num, true);
        for (var i = 0; i < wh[1]; i++)
            cost[i + wh[0]] = new C(Input.num, false);
        Array.Sort(cost);
        var res = 0L;
        var a = wh[0] + 1;
        var b = wh[1] + 1;
        for (var i = 0; i < wh[0] + wh[1]; i++)
            if (cost[i].isw)
            {
                res += b * cost[i].cost;
                a--;
            }
            else
            {
                res += a * cost[i].cost;
                b--;
            }
        WriteLine(res);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18/2;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 26068
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	q := getNextInt(scanner)
	aa := make([]int, q)
	bb := make([]int, q)
	cc := make([]int, q)
	dd := make([]int, q)
	for i := 0; i < q; i++ {
		aa[i] = getNextInt(scanner) - 1
		bb[i] = getNextInt(scanner) - 1
		cc[i] = getNextInt(scanner)
		dd[i] = getNextInt(scanner)
	}
	var a ans
	a.dfs(0, n, m, q, 1, aa, bb, cc, dd, make([]int, n))
	fmt.Fprintln(writer, a)
}

type ans int

func (a *ans) dfs(i, n, m, q, mx int, aa, bb, cc, dd, ee []int) {
	if i == n {
		s := 0
		for j := 0; j < q; j++ {
			if ee[bb[j]]-ee[aa[j]] == cc[j] {
				s += dd[j]
			}
		}
		if *a < ans(s) {
			*a = ans(s)
		}
		return
	}
	for j := mx; j < m+1; j++ {
		ee[i] = j
		a.dfs(i+1, n, m, q, j, aa, bb, cc, dd, ee)
	}
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  string s;
  cin >> n >> s;
  
  vector<vector<int>> x(250000);
  int keep = 0, it = 0;
  for (int i = 0; i < n; i++) {
    if (s.at(i) == '1') {
      keep++;
    }
    else {
      if (keep == 0) {
        continue;
      }
      else {
        x.at(it).emplace_back(keep);
        keep = 0;
        if (i != n - 1 && s.at(i + 1) == '0') it++;
      }
    }
  }
  if (keep > 0) x.at(it).emplace_back(keep);
  
  int ans = 0;
  for (int i = 0; i <= it; i++) {
    if (x.at(i).size() <= 1) continue;
    vector<vector<int>> y(x.at(i).size() - 1, vector<int>(3, 0)); // left, not, right
    y.at(0).at(0) = x.at(i).at(0);
    y.at(0).at(2) = x.at(i).at(1);
    for (int j = 1; j < x.at(i).size() - 1; j++) {
      y.at(j).at(0) = max({y.at(j - 1).at(0) + x.at(i).at(j) - 1, y.at(j - 1).at(1) + x.at(i).at(j), y.at(j - 1).at(2)});
      y.at(j).at(1) = max({y.at(j - 1).at(0), y.at(j - 1).at(1), y.at(j - 1).at(2)});
      y.at(j).at(2) = max(y.at(j - 1).at(1) + x.at(i).at(j + 1), y.at(j - 1).at(2) + x.at(i).at(j + 1) - 1);
      if (x.at(i).at(j) > 1) y.at(j).at(2) = max(y.at(j).at(2), y.at(j - 1).at(0) + x.at(i).at(j + 1));
    }
    ans += max({y.back().at(0), y.back().at(1), y.back().at(2)});
  }
  
  cout << ans << '\n';
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, k, p, m, y;
string s, t;
ld w;
ll a,b;

// <------------- Implement Functions Here ----------> //

void op(ll i=0,string ans = "", ll sum = 0) {
	if(i == 4) {
		if(sum == 7) {
			t = ans+'7';
		}
		return;
	}
	ans += s[i];
	if(i != 3) {
		op(i+1,ans + '+',sum + (s[i+1]-'0'));
		op(i+1,ans + '-',sum - (s[i+1]-'0'));
	}
	else {
		op(i+1,ans + '=',sum );
	}
}

// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> s;
	op(0,"",(s[0]-'0'));
	cout<<t;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 3620
a = gets.to_i
b = gets.to_s


if a%2 == 0
  c = b.scan(/.{1,#{a/2}}/)
  if c[0] == c[1]
    answer = 'Yes'
  else
    answer = 'No'
  end
else
  answer = 'No'
end

puts answer


Measured memory_bytes: 3836
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] l = new int[N];
		int[] r = new int[N];
		int sum = 0;
		for(int i = 0;i < N;i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
			sum += r[i] - l[i] + 1;
		}
		System.out.println(sum);
	}

}


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


using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(n) n.begin(),n.end()
#define eb emplace_back
#define endl "\n"

const ll maxn=5e5;

const ll maxx=1e13;
const ll mod=1000000007;
const ll mod1=998244353;

ll a[maxn];
map<ll,ll> mp;
string s[maxn];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("test.txt","r",stdin);
    //   freopen("GREEDY.INP", "r", stdin);
    //  freopen("GREEDY.OUT", "w", stdout);
    ll n;
     cin>>n;
     if (n==2)
     {
         cout <<1;
         return 0;
     }
     vector<ll> ans;
     for (ll i=2;i*i<=n;i++)
     {
        if (n%i==0)
        {
           ans.pb(i);
           if (i*i!=n) ans.pb(n/i);
        }
     }
     ll cnt=0;
     ans.pb(n);
     for (auto p:ans)
     {
       //  cout <<p<<endl;
         ll t= n;
         while (t%p==0) t/=p;
         if (t%p==1)
         {
             cnt++;
          //   cout <<p<<endl;

         }
     }
     ll t= n-1;
     for (ll i=2;i*i<=t;i++)
     {
         if (t%i==0)
         {
             cnt++;
             if (t!=i*i) cnt++;
         }
     }
     cnt++;
     //31cout <<endl;
    /* for (int i=2;i<=n;i++)
     {
         ll t= n;
          while (t%i==0) t/=i;
          if (t%i==1)
          {
              cnt++;
            //  cout <<i<<endl;
          }
     }*/
      cout <<cnt;
}


Measured memory_bytes: 4480
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

    if (a > b)
        cout << a - 1 << endl;
    else
        cout << a << endl;

    return 0;
}


Measured memory_bytes: 256