akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
typedef long long int ll;

#define min(x,y)(x<y?x:y)
 
using namespace std;

#define MAX 1000

int main() {
	FAST;

    int n, m;
    long long x, y, z;
    priority_queue<long long> q1;
    priority_queue<long long> q2;
    priority_queue<long long> q3;
    priority_queue<long long> q4;
    priority_queue<long long> q5;
    priority_queue<long long> q6;
    priority_queue<long long> q7;
    priority_queue<long long> q8;
 
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> x >> y >> z;
        //sum = abs(x) + abs(y) + abs(z);
        q1.push(+x + y + z);
        q2.push(-x + y + z);
        q3.push(+x - y + z);
        q4.push(+x + y - z);
        q5.push(-x - y + z);
        q6.push(+x - y - z);
        q7.push(-x + y - z);
        q8.push(-x - y - z);
    }
 
    long long  sum1 = 0;
    long long  sum2 = 0;
    long long  sum3 = 0;
    long long  sum4 = 0;
    long long  sum5 = 0;
    long long  sum6 = 0;
    long long  sum7 = 0;
    long long  sum8 = 0;
    while (m--) {
        sum1 += q1.top(); q1.pop();
        sum2 += q2.top(); q2.pop();
        sum3 += q3.top(); q3.pop();
        sum4 += q4.top(); q4.pop();
        sum5 += q5.top(); q5.pop();
        sum6 += q6.top(); q6.pop();
        sum7 += q7.top(); q7.pop();
        sum8 += q8.top(); q8.pop();
    }
 
    priority_queue<long long> total_sum;
    total_sum.push(sum1);
    total_sum.push(sum2);
    total_sum.push(sum3);
    total_sum.push(sum4);
    total_sum.push(sum5);
    total_sum.push(sum6);
    total_sum.push(sum7);
    total_sum.push(sum8);
 
    cout << total_sum.top() << endl;
 
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

void dfs(vector<vector<int>>& g, vector<int>& color, int pre) {
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t; cin >> s >> t;
    int n = s.length();
    int ans = 0;
    for(int i = 0; i < n; ++ i) {
        ans += (s[i]!=t[i]);
    }
    cout << ans << endl;
    return 0;
}

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

#define N 100005

typedef struct pp{
  char name[100];
  int t;
}Process;

int head,tail,n;
Process Q[N];

void enqueue(Process x){
  Q[tail]=x;
  tail=(tail+1)%N;
}

Process dequeue(){
  Process x=Q[head];
  head=(head+1)%N;
  return x;
}

int min(int a,int b){
  int n;
  n=a<b?a:b;
  return n;
}

int main(){
  int elaps=0,c;
  int i,q;
  Process u;
  scanf("%d %d",&n,&q);

  for(i=1;i<=n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head=1;
  tail=n+1;

  while(head!=tail){
    u=dequeue();
    c=min(q,u.t);
    u.t-=c;
    elaps+=c;
    if(u.t>0){
      enqueue(u);
    }
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}




Measured memory_bytes: 11872
#include <iostream>
#include <cmath>
#include <math.h>

using namespace std;

int main()
{
	int nA, nB, nH, nM;
	cin >> nA;
	cin >> nB;
	cin >> nH;
	cin >> nM;

	const double nPI = 3.141592653589793;
	int nAngleM = 6 * nM;
	double fAngleH = 30 * nH + 0.5 * nM;
	double fAngle;
	double fA;
	

	if (nAngleM > fAngleH)
	{
		fAngle = nAngleM - fAngleH;
		fA = sqrt((nA * nA) + (nB * nB) - 2 * nA * nB * cos((nPI * (fAngle) / 180)));
		//cout << setprecision(2)<<fA;
		printf("%.20f", fA);
	}
	else
	{
		fAngle = fAngleH - nAngleM;
		fA = sqrt((nA * nA) + (nB * nB) - 2 * nA * nB * cos((nPI * (fAngle) / 180)));
		//cout << fA;
		printf("%.20f", fA);
	}
}

Measured memory_bytes: 4136
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
        solve();
    }

    public static void solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0;i<n;i++){
        	a[i] = sc.nextInt();
        }
        int count = 0;

        for(int i=0;i<n-1;i++){
        	if(a[i] == a[i+1]){
        		count++;
        		i++;
        	}
        }
        System.out.println(count);
    }
}

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

int main()
{
	int N, M;
	cin >> N >> M;
	vector<vector<int>> ab( M );
	for( int i = 0; i < N; i++ ) {
		int a, b;
		cin >> a >> b;
		if( a > M ) continue;
		a--;
		ab[a].push_back( b );
	}

	priority_queue<int> que;
	long long ans = 0;
	for( int i = 0; i < M; i++ ) {
		for( auto b : ab[i] ) {
			que.push( b );
		}
		if( que.empty() ) continue;
		ans += que.top();
		que.pop();
	}

	cout << ans <<  endl;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void print(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void print(H head, T ...tail) { cout << head << " "; print(tail...); }

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	ll suma = 0, sumb = 0;
	ll ans = 0x3f3f3f3f3f3f3f3fll;

	int n; cin >> n;
	vector<int> v(n);
	rep(i, 0, n) cin >> v[i], suma += v[i];
	rep(i, 0, n) {
		if (i > 0) chmin(ans, abs(suma - sumb));
		suma -= v[i], sumb += v[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

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

		int[] dp = new int[x + 1];
		dp[0] = 1;
		for (int i = x; i >= 0; i--) {
			for (int j = 1; j <= a && i + j * 500 <= x; j++) {
				dp[i + j * 500] += dp[i];
			}
		}
		for (int i = x; i >= 0; i--) {
			for (int j = 1; j <= b && i + j * 100 <= x; j++) {
				dp[i + j * 100] += dp[i];
			}
		}
		for (int i = x; i >= 0; i--) {
			for (int j = 1; j <= c && i + j * 50 <= x; j++) {
				dp[i + j * 50] += dp[i];
			}
		}

		pr.println(dp[x]);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1<<20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
//???????????????????????\??¨??¨??????
vector<pair<int, int> >adj[MAX];

void dijkstra(){
    priority_queue<pair<int, int> >PQ;
    int color[MAX];
    int d[MAX];
    for(int i = 0; i<n; i++){
        d[i] = INFTY;
        color[i] = WHITE;
    }

    d[0] = 0;
    PQ.push(make_pair(0,0));
    color[0] = GRAY;

    while(!PQ.empty()){
        pair<int, int>f = PQ.top();
        PQ.pop();

        int u = f.second;

        color[u] = BLACK;

        // ??????????°???????????????????????????????????????\
        if(d[u]<f.first*(-1))
            continue;

        for(int j = 0;j<adj[u].size(); j++){
            int v = adj[u][j].first;
            if(color[v]==BLACK)continue;
            if(d[v]>d[u]+adj[u][j].second){
                d[v]=d[u]+adj[u][j].second;
                //priority_queue ?????????????????§??????????????????-1
                PQ.push(make_pair(d[v]*(-1),v));
                color[v]=GRAY;
            }
        }
    }

    for(int i=0;i<n;i++)
        cout<<i<<" "<<(d[i]==INFTY?-1:d[i])<<endl;
}

int main(){
    int k,u,v,c;

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>u>>k;
        for(int j=0;j<k;j++){
            cin>>v>>c;
            adj[u].push_back(make_pair(v,c));
        }
    }

    dijkstra();
}

Measured memory_bytes: 3356
#include<stdio.h>

int main(void) {
        int a, b, c, i, counter;
        scanf("%d %d %d", &a, &b, &c);

        counter = 0;
        for(i=a;i<=b;i++) {
                if(c % i == 0)  counter++;
        }
        printf("%d\n", counter);
        return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

vector<tuple<ll, ll, ll>> cakes;

ll calc_based_on(bool sign_x, bool sign_y, bool sign_z, const int N, const int M) {
    vector<ll> values(N);

    for (int i = 0; i < N; i++) {
        ll x, y, z;
        tie(x, y, z) = cakes[i];

        // printf("x: %lld, y: %lld, z: %lld\n", x, y, z);

        vector<ll> xyz = {x, y, z};
        vector<bool> sign_xyz = {sign_x, sign_y, sign_z};
        ll v = 0;

        for (int j = 0; j < 3; j++) {
            if (sign_xyz[j]) {
                v += xyz[j];
            } else {
                v -= xyz[j];
            }
        }

        // printf("v: %lld\n", v);
        values[i] = v;
    }

    sort(values.begin(), values.end());
    reverse(values.begin(), values.end());

    ll acc = 0;
    for (int i = 0; i < M; i++) {
        // printf("v: %lld\n", values[i]);
        acc += values[i];
    }

    // printf("sign_x: %d, sign_y: %d, sign_z: %d, acc: %lld\n", sign_x, sign_y, sign_z, acc);
    return acc;
}

ll solve(const int N, const int M) {
    ll ans = 0;
    chmax(ans, calc_based_on(true, true, true, N, M));
    chmax(ans, calc_based_on(true, true, false, N, M));
    chmax(ans, calc_based_on(true, false, true, N, M));
    chmax(ans, calc_based_on(true, false, false, N, M));
    chmax(ans, calc_based_on(false, true, true, N, M));
    chmax(ans, calc_based_on(false, true, false, N, M));
    chmax(ans, calc_based_on(false, false, true, N, M));
    chmax(ans, calc_based_on(false, false, false, N, M));
    return ans;
}

int main(void) {
    int N, M;
    cin >> N >> M;

    cakes.resize(N);
    for (int i = 0; i < N; i++) {
        ll x, y, z;
        cin >> x >> y >> z;
        cakes[i] = tie(x, y, z);
    }

    cout << solve(N, M) << endl;

    return 0;
}


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

using namespace std;

int main() {
    int N, K, a;
    scanf("%d%d", &N, &K);
    vector<int> A(N);
    vector<bool> dp(K+1, false);
    for (int i = 0; i < N; ++i) {
        scanf("%d", &a);
        A[i] = a;
        dp[a] = true;
    }
    for (int i = 1; i <= K; ++i) {
        for (int x : A) {
            if (x > i) {
                break;
            }
            if (!dp[i] && !dp[i - x]) {
                dp[i] = true;
            }
        }
    }
    cout << (dp.back() ? "First" : "Second");
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int N; cin >> N;
    vector<long double>x(N);
    vector<string>u(N);
    long double A = 0;
    rep(i, N) {
        cin >> x[i] >> u[i];
        if (u[i].at(0) == 'B')A += x[i] * 380000.0;
        else A += x[i];
    }
    cout << fixed<< setprecision(100) <<A << endl;
}

Measured memory_bytes: 3784
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main()
{
    int n;
    cin >> n;
    string str;
    map<string, int> keihin;
    rep(i, n){
        cin >> str;
        keihin[str]++;
    }
    cout << keihin.size() << endl;
}

Measured memory_bytes: 19260
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n,x,m = MAP()

temp = [x]

present = [-1]*(m+1)

present[x] = 0

i,j = -1, -1

for iter in range(1, n):
    new = (temp[-1]**2)%m
    if(present[new]==-1):
        temp.append(new)
        present[new] = iter
    else:
        i = present[new]
        j = iter
        break
    # print(temp)
# print(i,j)
if(i!=-1):
    sum1 = sum(temp[:i])
    left = n-i
    sum2 = sum(temp[i:j])
    zz = j-i
    sum1+=sum2*(left//zz)
    still = left%zz
    while(still>0):
        sum1+=temp[i]
        i+=1


        still-=1
else:
    sum1 = sum(temp)
print(sum1)

Measured memory_bytes: 72560
#include <bits/stdc++.h>
using namespace std;
string s1, s2;
int main()
{
    cin >> s1 >> s2;
    for(int i = 0; i < s1.length(); i++)
    {
         long long leng = s1.length()-i;
         if(s1.substr(i, leng) == s2.substr(0, leng) && s1.substr(0, s1.length()-leng) == s2.substr(leng, s2.length()-leng))
                {
cout << "Yes" << "\n";
return 0;
                }
        
    }
cout << "No" << "\n";
}


Measured memory_bytes: 256
from collections import deque
s = input()
q = int(input())
d = deque()
for i in s:
  d.append(i)
rv = 0
lst = [1, 0]
for i in range(q):
  z = input()
  if z[0] == '1':
    rv = lst[rv]
  elif z[2] == '1':
    if rv == 1:
      d.append(z[4])
    else:
      d.appendleft(z[4])
  else:
    if rv == 0:
      d.append(z[4])
    else:
      d.appendleft(z[4])
if rv == 1:
  print(''.join(d)[::-1])
else:
  print(''.join(d))

Measured memory_bytes: 14420
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
const double PI = 3.14159265358979323846;
int vector_finder(vector<int> vec, int number) {
  auto itr = find(vec.begin(), vec.end(), number);
  size_t index = distance(vec.begin(), itr);
  if (index != vec.size()) {  // 発見できたとき
    return 1;
  } else {  // 発見できなかったとき
    return 0;
  }
}
unsigned GetDigit(unsigned num) { return log10(num) + 1; }
int main() {
  string a;
  int s = 0, r = 0;
  for (int i = 0; i < 3; i++) {
    cin >> a[i];
    if (a[i] == 'S') {
      s++;
    }
    if (a[i] == 'R') {
      r++;
    }
  }
  if (s == 0) {
    cout << 3;
  }
  if (s == 1) {
    if (a[0] == 'S' && a[1] == 'R' && a[2] == 'R') {
      cout << 2;
    }
    if (a[0] == 'R' && a[1] == 'R' && a[2] == 'S') {
      cout << 2;
    }
    if (a[0] == 'R' && a[1] == 'S' && a[2] == 'R') {
      cout << 1;
    }
  }
  if (s == 2) {
    cout << 1;
  }
  if (s == 3) {
    cout << 0;
  }
}

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

int main() {
  int h, w, n;
  cin >> h >> w >> n;
  int sr, sc;
  cin >> sr >> sc;
  sr--, sc--;
  string s, t;
  cin >> s >> t;

  int now;
  bool ans = true;

  now = sc;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'L') now--;
    if (now < 0) ans = false;
    if (t[i] == 'R') now = min(now + 1, w - 1);
  }

  now = sc;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') now++;
    if (w <= now) ans = false;
    if (t[i] == 'L') now = max(now - 1, 0);
  }

  now = sr;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'U') now--;
    if (now < 0) ans = false;
    if (t[i] == 'D') now = min(now + 1, h - 1);
  }

  now = sr;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'D') now++;
    if (h <= now) ans = false;
    if (t[i] == 'U') now = max(now - 1, 0);
  }
  
  cout << ((ans) ? "YES" : "NO") << endl;
}


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

int main() {
  string S;
  int k, kekka;
  cin >>S;
  k=S.size();
  kekka=0;
  for (int i = 0; i<k; i++){
    if(S.at(i)=='o'){
      kekka++;
    }
  }
  if((8-kekka)>(15-k)){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int n, m;
  cin >> n >> m;
  vector<int> L(m);
  vector<int> R(m);
  REP(i,m){
    int l, r;
    cin >> l >> r;
    L[i] = l;
    R[i] = r;
  }

  int lmax = 0;
  int rmin = 100005;
  REP(i,m){
    lmax = max(lmax, L[i]);
    rmin = min(rmin, R[i]);
  }

  int ans;
  if(rmin - lmax < 0) ans = 0;
  else ans = rmin - lmax + 1;
  cout  << ans << endl;
  return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using lond = long double;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using P = pair<int,int>;
const int INF = 1001001001;//適当に大きな数で初期化

int a[12][12];//行列
int main(){
	int n,m,x;
	cin >> n >> m >> x;
	vector<int> c(n);
	rep(i,n){
		cin >> c[i];
		rep(j,m) cin >> a[i][j];
	}

	int ans = INF;	
	rep(s,1<<n)//1をnビット左シフト 000~111
	{
		int cost = 0;
		vector<int> d(m);//理解度
		rep(i,n){
			//sのi番目が１か知りたい。i分右シフトして&演算子を使おう
			if (s>>i&1)//sのi番目が立っているか(1かどうか)チェック
			{
				cost += c[i];
				rep(j,m) d[j] += a[i][j];
			}
		}
		bool flag = true;
		//1つでもx未満であればfalseとする
		rep(j,m) if (d[j] < x) flag = false;
		if (flag) ans = min(ans,cost);
	}
	if (ans == INF) cout << -1 << endl;
	else cout << ans << endl;
	return 0;

}


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

int main() {
  int64_t n, ans = 10e12, j, tmp;
  cin >> n;

  for (int i = 1, s_n = (int)sqrt(n); i <= s_n; ++i) {
    if (n % i == 0)
      j = n / i;
    tmp = i + j - 2;
    if (ans > tmp)
      ans = tmp;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
import itertools
n = int(input())
k = int(input())
arr = ["plus","double"]
ans = []
tmp = 1

for i in itertools.product(arr,repeat=n):
    for j in i:
        if j == "double":
            tmp *= 2
        else:
            tmp += k
    ans.append(tmp)
    tmp = 1
print(min(ans))

Measured memory_bytes: 3064
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N; cin >> N;
    vl A(N); REP(i, N) cin >> A[i];

    ll ans = 0;
    ll sum = 0;
    int r = 0;
    REP(l, N) {
        while(r < N && (sum & A[r]) == 0) {
            sum += A[r];
            r++;
        }
        ans += (r - 1) - l + 1;

        sum -= A[l];
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1223372036854775807;
const ll mod = 1000000007;		




int main() {

	int n, m, c;
	cin >> n >> m >> c;

	VI b(m), d;
	REP(i, m)cin >> b[i];

	int ans = 0;

	REP(i, n) {
		VI a(m);
		int res = 0;
		REP(j, m) {
			cin >> a[j];
			res += a[j] * b[j];
		}
		if (res + c > 0)ans++;
	}

	cout << ans << endl;

	return 0;


}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



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

	for (int i = 0; i < n; i++)
	{
		int left = 0, right = 0;
		int ball[10];

		for (int j = 0; j < 10; j++)
		{
			cin >> ball[j];
		}

		for (int j = 0; j < 10; j++)
		{
			if (left < ball[j] && right < ball[j])
			{
				if (right < left)
				{
					left = ball[j];
				}
				else
				{
					right = ball[j];
				}
			}
			else if (left < ball[j])
				left = ball[j];
			else if (right < ball[j])
				right = ball[j];
			else
			{
				cout << "NO" << endl;
				break;
			}
		}

		if (right == ball[9] || left == ball[9]) cout << "YES" << endl;
	}

	return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    const int A = 26;
    const int M = 1e5;
    int D; cin >> D;
    vector<int> c(A);
    REP(i,A) cin >> c[i];
    vector<vector<int>> s(D,vector<int>(A));
    REP(i,D) REP(j,A) cin >> s[i][j];

    vector<int> last(A,-1);
    vector<int> ans(D);
    REP(i,D) {
        int mx = 0,a = -1;
        REP(j,A) {
            int tmp = (i-last[j])*c[j] + s[i][j];
            if (mx < tmp) {
                mx = tmp;
                a = j;
            }
        }
        ans[i]=a;
        last[a] = i;
    }
    auto calc = [&](const vector<int> &a){
        vector<int> l(A,-1);
        int score = 0;
        REP(i,D) {
            score += s[i][a[i]];
            last[a[i]] = i;
            REP(j,A) {
                score -= c[j]* (i-l[j]);
            }
        }
        return score;
    };

    int maxscore = calc(ans);

    random_device seed_gen;
    mt19937 engine(seed_gen());
    REP(_,M) {
        vector<int> a(ans);
        a[engine()%D] = engine() % A;
        int tmp = calc(a);
        if (maxscore < tmp) {
            swap(ans,a);
            maxscore = tmp;
        }
    }

    REP(i,D) OUT(ans[i]+1)

    return 0;
}

Measured memory_bytes: 3720
#include <iostream>


int get_digits_sum(int number) {
    int sum = 0;
    for (const auto& c: std::to_string(number)) {
        sum += c - '0';
    }
    return sum;
}


int main() {
    int n, a, b;
    std::cin >> n >> a >> b;
    long long sum = 0;
    for (int i = 1; i <= n; ++i) {
        auto s = get_digits_sum(i);
        if (a <= s && s <= b) {
            sum += i;
        }
    }
    std::cout << sum;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	g := [300][300]int{}
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			fmt.Scan(&g[i][j])
		}
	}

	ex := [300][300]bool{}
	for k := 0; k < n; k++ {
		for i := 0; i < n; i++ {
			for j := 0; j < n; j++ {
				if i == j || j == k || i == k {
					continue
				}

				a := g[i][j]
				b := g[i][k] + g[k][j]

				if a > b {
					fmt.Println(-1)
					return
				}

				if a == b {
					ex[i][j] = true
					ex[j][i] = true
				}
			}
		}
	}

	ans := 0
	for i := 0; i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			if !ex[i][j] {
				ans += g[i][j]
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 5504
// need
#include <iostream>
#include <algorithm>
// data structure
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
//#include <deque>
#include <valarray>
#include <unordered_map>
#include <array>
// stream
//#include <istream>
#include <sstream>
//#include <ostream>
#include <fstream>
// etc
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
//#include <chrono>
#include <random>
#include <numeric>
using namespace std;

int main()
{
  int N;
  long count = 0;
  int l, flag, flag2, min;
  int h[105];
  cin >> N;
  for(int i = 0; i < N; i++)
    cin >> h[i];
  while(1){
    flag = 0;
    flag2 = 0;
	for(int i = 0; i < N; i++){
      if(h[i] != 0){
        l=i;
        flag = 1;
        break;
      }
    }
    if(flag == 0)break;
    min = h[l];
    for(int i = l+1;i < N; i++){
      if(h[i] == 0){
        count += min;
        for(int j = l; j < i; j++)
          h[j] -= min;
        flag2 =1;
        break;
      }
      if(min > h[i])min = h[i];
    }
    if(flag2 == 0){
		for(int i = l; i < N; i++)
          h[i] -= min;
      	count += min;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

int main(){
  int N,i;
  cin >> N >> i;
  cout << N - i + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] num = new int[4];
        for(int i=0; i<6; i++){
            int tmp = sc.nextInt();
            num[tmp-1]++;
        }

        if(Arrays.stream(num).max().getAsInt() >= 3){
            System.out.println("NO");
        }else{
            System.out.println("YES");
        }

    }
}

Measured memory_bytes: 28756
#include<stdio.h>

int main(){
    int n,k;
    scanf("%d %d",&n,&k);

    int d[k],a[k][n];
    int ans[n];

    for(int i = 0;i < n;i++){
        ans[i] = 0;
    }

    for(int i = 0;i<k;i++){
        scanf("%d",&d[i]);
        for(int j = 0;j<d[i];j++){
            scanf("%d",&a[i][j]);
            if(ans[a[i][j]-1] == 0)ans[a[i][j]-1] = 1;
        }        
    }

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

Measured memory_bytes: 1724
from collections import defaultdict as dd
N = int(input())
dic = dd(int)
for i in range(1,N+1):
    dic[(str(i)[0],str(i)[-1])] += 1
res = 0
for i in range(100):
    res += dic[(str(i%10),str(i//10))]*dic[(str(i//10),str(i%10))]
print(res)


Measured memory_bytes: 41452
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define rrep(i,n) for (int i=(int)(n)-1; i>=0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
template<typename T> using Graph = vector<vector<T>>;
template<typename T> using Spacial = vector<vector<vector<T>>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

template<typename T> struct is_pair : false_type{};
template<typename T1, typename T2> struct is_pair<pair<T1, T2>> : true_type{};
template<typename T> struct is_vector : false_type{};
template<typename T> struct is_vector<vector<T>> : true_type{};

template<typename T1, typename T2>
istream &operator >> (istream &istr, pair<T1, T2> &p) {
  istr >> p.first >> p.second;
  return istr;
} 
template<typename T1, typename T2>
ostream &operator << (ostream &ostr, const pair<T1, T2> &p) {
  ostr << p.first << " " << p.second;
  return ostr;
}
template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) return ostr;
  bool vp = is_vector<T>() || is_pair<T>();
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    ostr << (vp ? "\n" : " ") << *itr;
  }
  return ostr;
}

template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

int modpow(int a, long long n, int mod = MOD) {
  int ret = 1;
  do {
    if (n & 1) ret = 1LL * ret * a % mod;
    a = 1LL * a * a % mod;
  } while (n >>= 1);
  return ret;
}

template<typename T>
T GCD(T a, T b) { return b ? GCD(b, a%b) : a; }
template<typename T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

template<typename T1, typename T2>
bool CompareBySecond(pair<T1, T2> a, pair<T1, T2> b) {
  return a.second != b.second ? a.second < b.second : a.first < b.first;
}
template<typename T>
bool CompareBySlope(pair<T, T> a, pair<T, T> b) {
// counterclockwise from 12 o'clock direction
  if (a.first * b.first < 0) return a.first < b.first;
  if (a.first == 0) return a.second >= 0 || b.first > 0;
  if (b.first == 0) return b.second < 0 && a.first < 0;
  return a.second * b.first < a.first * b.second;
}


/* -------- <templates end> -------- */


void solve() {
  double a, b; cin >> a >> b;
  int aMin = ceil(a / 0.08);
  int aMax = ceil((a+1) / 0.08) - 1;
  int bMin = ceil(b / 0.1);
  int bMax = ceil((b+1) / 0.1) - 1;
  if (aMin > bMax || bMin > aMax) cout << -1 << endl;
  else cout << max(aMin, bMin) << endl;
}


/* -------- <programs end> -------- */


signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
n,k,q = map(int,input().split())
A=[int(input()) for i in range(q)]
P=[k-q for i in range(n)]

for i in range(q):
      P[A[i]-1] +=1

for i in range(n):
      if P[i]>0:
            print("Yes")
      else:
            print("No")

Measured memory_bytes: 11792
#include<bits/stdc++.h>
 
using namespace std;
 
 
#define IOS ios::sync_with_stdio(0); cin.tie(0), cout.tie(0)
 
 
#define ll long long int
#define ld long double
 
#define fr first
#define se second
 
 
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) (int)v.size()
#define sunq(v) sort(all(v));v.resize(distance(v.begin(),unique(all(v))))
 
 
#define pb push_back
#define mp make_pair
 
 
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define emla(a, val) memset(a, val, sizeof(a))
#define easm(a, b) (a + b - 1) /b 
 
#define PI 3.141592653589793238
 
 
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
 
 
//bool valid(int i, int j){return i >= 0 && i < n && j >= 0 && j < m;}
 
int n, m, a[55][55];
int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  //clock_t z = clock();
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    int x, y;
    cin >> x >> y;
    a[x][y]++;
    a[y][x]++;
  }
  for(int i = 1; i <= n; i++){
    int cntr = 0;
    for(int j = 1; j <= n; j++)
      if(a[i][j])cntr += a[i][j];
    cout << cntr << endl;
  }

  //debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
  /*
  *try tricky test cases:
    -bounds
    -small input (0, 1)
    -big input
    -random tests
  */
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

typedef long long int ll;

ll mod=1e9+7;

int main(){
    int N,K;
    scanf("%d%d",&N,&K);

    ll ans=1;
    ll high=N,low=0;
    for(int i=0;i<(N+1-K);i++){
        ll diff=(high+(mod-low))%mod;
        ans=(ans+(diff+1)%mod)%mod;
        high=(high+(N-i-1))%mod;
        low=(low+i+1)%mod;
    }

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

Measured memory_bytes: 1728
package main

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

const (
	MAX_STACK_SIZE = 100
)

type stack struct {
	index int
	content []int
}

func newStack(size int) *stack {
	content := make([]int, size, size)
	return &stack{
		index: 0,
		content: content,
	}
}

func (stack *stack) push(x int) {
	stack.content[stack.index] = x
	stack.index += 1
}

func (stack *stack) pop() int {
	stack.index -= 1
	return stack.content[stack.index]
}

func (stack *stack) size() int {
	return stack.index
}

func (stack *stack) String() string {
	return fmt.Sprint("stack: ", stack.content[:stack.size()])
}

func process(x string, stack *stack) {
	switch(x) {
	case "+":
		rhs := stack.pop()
		lhs := stack.pop()
		stack.push(lhs + rhs)
	case "-":
		rhs := stack.pop()
		lhs := stack.pop()
		stack.push(lhs - rhs)
	case "*":
		rhs := stack.pop()
		lhs := stack.pop()
		stack.push(lhs * rhs)
	default:
		num, err := strconv.Atoi(x)
		if err != nil {
			panic(err)
		}
		stack.push(num)
	}
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	stack := newStack(MAX_STACK_SIZE)

	for {
		if token, hasNext := nextText(sc); hasNext {
			process(token, stack)
		} else {
			break
		}
	}
	fmt.Println(stack.pop())
}

func nextText(sc *bufio.Scanner) (string, bool) {
	if (sc.Scan()) {
		return sc.Text(), true
	} else {
		return "", false
	}
}


Measured memory_bytes: 1096
#include<string>
#include<iostream>
#include<cinttypes>
#include<algorithm>

int main(){

	std::string S, T;
	std::cin >> S >> T;

	auto ans_ = S.length();

	for( decltype( S.length() ) i{}; i < ( S.length() - T.length() + 1 ); ++i )
	{

		decltype( ans_ ) t_{};
		for( int j{}; j < T.length(); ++j )
			t_ += S[i + j] != T[j] ? 1 : 0;

		ans_ = std::min( t_, ans_ );
	}

	std::cout << ans_ << "\n";

	return 0;
}

Measured memory_bytes: 3176
let cnt = ref 0

let merge a l m r =
  let init_ary n p =
    let ret = Array.make (n + 1) max_int in
    for i = 0 to n - 1 do
      ret.(i) <- a.(p + i)
    done;
    ret in
  let ai = init_ary (m - l) l in
  let aj = init_ary (r - m) m in
  let i = ref 0 in
  let j = ref 0 in
  for k = l to r - 1 do
    incr cnt;
    if ai.(!i) <= aj.(!j) then begin
      a.(k) <- ai.(!i);
      incr i;
    end else begin
      a.(k) <- aj.(!j);
      incr j;
    end
  done

let rec merge_sort a l r =
  if (l + 1) < r then begin
    let m = (l + r) / 2 in
    merge_sort a l m;
    merge_sort a m r;
    merge a l m r
  end

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  merge_sort a 0 n;
  print_int a.(0);
  for i = 1 to n - 1 do
    print_string " ";
    print_int a.(i);
  done;
  print_newline ();
  print_int !cnt;
  print_newline ()

Measured memory_bytes: 21012
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
    int A=0, B=0, C=0;
    cin >> A >> B >> C;
    cout << ((B/A)>C?C:B/A) << endl;
}

Measured memory_bytes: 256
l=int(input())

import numpy as np
result = 0
for x in np.arange(l/3-0.1, l/3+0.1, 0.1):
  for y in np.arange(x, l/3+0.1, 0.1):
    z = l - (x+y)
    if z <= 0:
      break
    v = x*y*z
    result = max(v, result)
print(result)

Measured memory_bytes: 27128
n=int(input())
d=[10*[0]for _ in range(10)]
ans=0
for i in range(1,n+1):
  s=str(i)
  if s[0]=="0" or s[-1]=="0":
    continue
  else:
    d[int(s[0])][int(s[-1])]+=1
for i in range(1,10):
  for j in range(1,10):
    ans+=d[i][j]*d[j][i]
print(ans)

Measured memory_bytes: 3064
/*Stay true to yourself, yet always be open to learn. Work hard, and never give up on your dreams, 
even when nobody else believes they can come true but you. These are not cliches but real tools you 
need no matter what you do in life to stay focused on your path.
*/

 /*Pppppppp    UU      UU     CCCCCCCC    CCCCCCCC     HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pppppppp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pp          UU      UU     CC          CC           HH     HH     UU      UU
   pp          UUUUUUUUUU     CCCCCCCC    CCCCCCCC     HH     HH     UUUUUUUUUU
   */

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long a ,b ;
    cin >> a >>b ;
    //if(a==b)
    //cout<<1<<endl;
   // else
    if((a+b)%2==0)
    {
      long k = (a+b)/2;
        cout<<k;
    }
    else
    cout<<"IMPOSSIBLE";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
        int a,b,c;
        scanf("%d %d %d",&a,&b,&c);
        if(a==b&&a!=c)
            printf("Yes");
        else if(a==c&&a!=b)
            printf("Yes");
        else if(b==c&&a!=c)
            printf("Yes");
        else
            printf("No");
        return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
long long modpow(long long m, long long n, long long modvalue) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2, modvalue);
        return t * t % modvalue;
    } else {
        return modpow(m, n - 1, modvalue) * m % modvalue;
    }
}
bool bitcheck(ll x, ll y) { return (x >> y) & 1; }

template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;

long long moddiv(long long a, long long b, ll modvalue) { return (a * modpow(b, mod - 2, modvalue)) % modvalue; }

const ll INF = 1LL << 60;

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

ll nCkmod(ll n, ll k, ll modvalue) {
    ll numera = 1;
    for (int i = n; i > n - k; i--) {
        numera *= i;
        numera %= modvalue;
    }
    ll denomi = 1;
    REP(i, k) {
        denomi *= (i + 1);
        denomi %= modvalue;
    }
    return moddiv(numera, denomi, modvalue);
}
map<ll, ll> cnt;
void primeFactors(long long n) {
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        cnt[n]++;
    }
}
int main() {
    ll k;
    cin >> k;
    ll cur = 7;
    REP(i, k) {
        if (cur % k == 0) {
            cout << i + 1 << endl;
            return 0;
        }
        cur = cur * 10 + 7;
        cur %= k;
    }
    cout << -1 << endl;
}

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

const int MAXN = 5e3 + 10, INF = 1e9;

int n, n1, n2;
int a[MAXN << 2], b[MAXN << 2];
char s[MAXN], t[MAXN];

int main() {
	scanf("%d %s %s", &n, s + 1, t + 1);
	for (int i = 1; i < n; ++i) if (s[i] != s[i + 1]) a[(++n1) + n + 20] = i;
	for (int i = 1; i < n; ++i) if (t[i] != t[i + 1]) b[(++n2) + n + 20] = i;
	for (int i = 1; i <= n + 20; ++i) a[n1 + n + 20 + i] = b[n2 + n + 20 + i] = n;
	int ans = INF;
	for (int i = -n1 - 2; i <= n2 + 2; ++i) if ((i & 1) != (s[1] == t[1])) {
		int now = 0;
		for (int j = std::min(0, -i) + n; j <= std::max(n1, -i + n2 + 1) + n + 30; ++j) now += abs(a[j] - b[i + j]);
		ans = std::min(ans, now);
	}
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

const int MAXN = 310;

int n, m;
int a[MAXN][MAXN];
int b[MAXN];
int c[MAXN];
int u[MAXN];
int ans;

void calc()
{
	for (int i = 1; i <= n; ++ i)
	{
		-- u[a[i][c[i]]];
		while (!b[a[i][c[i]]]) ++ c[i];
		++ u[a[i][c[i]]];
	}
	int most = 0;
	for (int j = 1; j <= m; ++ j)
		most = max(most, u[j]);
	ans = min(ans, most);
	for (int j = 1; j <= m; ++ j)
	{
		if (most == u[j])
		{
			b[j] = 0;
			break;
		}
	}
}

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++ i)
		for (int j = 1; j <= m; ++ j)
			scanf("%d", &a[i][j]);
	for (int j = 1; j <= m; ++ j)
		b[j] = 1;
	for (int i = 1; i <= n; ++ i)
	{
		c[i] = 1;
		u[a[i][1]] ++;
	}
	ans = n;
	for (int j = 1; j <= m; ++ j)
	{
		calc();
	}
	cout << ans << endl;
	
	return 0;
}


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

using ll = long long;
using pii = pair<int, int>;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> res(H, vector<int>(W));
    int N;
    cin >> N;
    int y = -1, x = 0;
    int dy = 1;
    for(int i = 1; i <= N; ++i) {
        int a;
        cin >> a;
        for(int j = 0; j < a; ++j) {
            int ny = y + dy;
            if(ny < 0 || H <= ny) {
                ny -= dy;
                x += 1;
                dy = -dy;
            }
            res[ny][x] = i;
            y = ny;
        }
    }
    for(int i = 0; i < H; ++i) {
        for(int j = 0; j < W; ++j) {
            if(j != 0) {
                cout << ' ';
            }
            cout << res[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define R(x) (x)=read()
const int N = 100005;
char c[N];
int a[N],b[N];
int n,m,T;
using namespace std;
int gcd(int x,int y) {
	if(x%y==0) return y;
	else return gcd(y,x%y);
}
int read() {
	int x=0;char c=getchar();
	while((c<48||c>57)&&c!='-') c=getchar();
	if(c=='-') {c=getchar();while(c>=48&&c<=57) x=x*10-c+48,c=getchar();}
	while(c>=48&&c<=57) x=x*10+c-48,c=getchar();
	return x;
}
void init() {
	
}
int cnt,sum;
void solve() {
	memset(a,-1,sizeof(a));
	R(n);
	for(int i=1;i<=n;i++)
		R(a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n+1;i++) {
		if(a[i]==a[i-1]) cnt++;
		else if(cnt&1) sum++,cnt=1;
		else cnt=1;
	}
	cout<<sum;
	
	
}
int main() {
	init();
	solve();
	return 0;
}

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

AC=0
WA=0
TLE=0
RE=0

for i in range(N):
    j=input()
    if j=='AC': 
        AC+=1
    elif j=='WA':
        WA+=1
    elif j=='TLE':
        TLE+=1
    else:
        RE += 1

print('AC x {}'.format(AC))
print('WA x {}'.format(WA))
print('TLE x {}'.format(TLE))
print('RE x {}'.format(RE))

Measured memory_bytes: 74520
// Problem : D - Equal Cut
// Contest : AtCoder Regular Contest 100
// URL : https://atcoder.jp/contests/arc100/tasks/arc100_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define cerr if(1)cerr
#define size(x) (int)x.size()
#define all(x) x.begin(), x.end()

const int N = 1e6 + 1, mod = 1e9 + 7;

int n, a[N];
ll ans = LLONG_MAX, psum[N];

ll sum(int l, int r) {
	return psum[r] - psum[l - 1];
}

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		psum[i] = psum[i - 1] + a[i];
	}
	for (int i = 2; i < n - 1; i++) {
		int posl = 1;
		for (int j = log2(i); j >= 0; j--) {
			posl += 1 << j;
			if (posl >= i || sum(1, posl) > sum(posl + 1, i)) {
				posl -= 1 << j;
			}
		}
		ll ansl = abs(sum(1, posl) - sum(posl + 1, i));
		ll mnl = min(sum(1, posl), sum(posl + 1, i));
		ll mxl = max(sum(1, posl), sum(posl + 1, i));
		if (posl != i - 1) {
			if (ansl > abs(sum(1, posl + 1) - sum(posl + 2, i))) {
				ansl = abs(sum(1, posl + 1) - sum(posl + 2, i));
				mnl = min(sum(1, posl + 1), sum(posl + 2, i));
				mxl = max(sum(1, posl + 1), sum(posl + 2, i));
			}
		}
		int posr = i + 1;
		for (int j = log2(n - i); j >= 0; j--) {
			posr += 1 << j;
			if (posr > n - 1 || sum(i + 1, posr) > sum(posr + 1, n)) {
				posr -= 1 << j;
			}
		}
		ll ansr = abs(sum(i + 1, posr) - sum(posr + 1, n));
		ll mnr = min(sum(i + 1, posr), sum(posr + 1, n));
		ll mxr = max(sum(i + 1, posr), sum(posr + 1, n));
		if (posr != n - 1) {
			if (ansr > abs(sum(i + 1, posr + 1) - sum(posr + 2, n))) {
				ansr = abs(sum(i + 1, posr + 1) - sum(posr + 2, n));
				mnr = min(sum(i + 1, posr + 1), sum(posr + 2, n));
				mxr = max(sum(i + 1, posr + 1), sum(posr + 2, n));
			}
		}
		ans = min(ans, max(mxl, mxr) - min(mnl, mnr));
	}
	cout << ans;
}


Measured memory_bytes: 6016