akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#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() {
    int n, m;
    cin >> n >> m;
    vector<P> p(m);
    rep(i,m) cin >> p[i].first >> p[i].second;
    rep(x,1000){
        int keta = 1;
        int nx = x/10;
        vector<int> d(1,x%10);
        while(nx){
            keta++;
            d.push_back(nx%10);
            nx /= 10;
        }
        if(keta != n) continue;
        bool ok = true;
        reverse(d.begin(), d.end());
        rep(i,m){
            if(d[p[i].first-1] != p[i].second) ok = false;
        }
        if(ok){
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
 
a = [i**5 for i in range(120)]
for i in range(120):
    for j in range(i+1,120):
        if a[j]-a[i] == n:
            print(j,i)
            break
        if a[j]+a[i] == n:
            print(j,-i)
            break
    else: continue
    break


Measured memory_bytes: 9028
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

m = a[:]
cnt = 0
for i in range(n):
    if m[i] < b[i]:
        cnt += m[i] + min(m[i+1], b[i]-m[i])
        m[i+1] -= min(m[i+1], b[i]-m[i])
    else:
        cnt += b[i]

print(cnt)


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

int main(){
    int height[10];
    
    for(int i=0;i<10;i++){
        do{
            cin >> height[i];
        }while(height[i]<0 || height[i]>10000);
    }
    
    sort(height,height+10);
    
    for(int i=9;i>6;i--)
        cout << height[i]<<endl;
    
    return 0;
}

Measured memory_bytes: 1176
# coding: utf-8
from functools import lru_cache

import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

@lru_cache(maxsize = None)
def f(v):
    if not arc[v]:
        return(0)
    return(max(f(nv) for nv in arc[v]) + 1)

n, m = map(int, input().split()) # 2 <= n <= 10^5, 1 <= m <= 10^5
arc = [[] for _ in range(n)]
for _ in range(m):
    x, y = map(int, input().split())
    arc[x - 1].append(y - 1)
print(max(f(v) for v in range(n)))


Measured memory_bytes: 182272
import java.util.*;
public class Main {

	public static int lowerbound(List<Integer> a, int key) {
		if(a.get(a.size()-1) < key)
			return a.size();
		int lb = 0, ub = a.size()-1, mid;
		do {
			mid = (ub+lb)/2;
			if(a.get(mid) < key)
				lb = mid + 1;
			else
				ub = mid;
		}while(lb < ub);
		return ub;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		Map<Integer, List<Integer>> sa = new HashMap<>();
		boolean[] ta = new boolean[26];
		for(int i = 0; i < 26; i++)
			sa.put(i, new ArrayList<Integer>());
		for(int i = 0; i < s.length(); i++) {
			sa.get(s.charAt(i)-'a').add(i);
			sa.get(s.charAt(i)-'a').add(i+s.length());
		}
		for(int i = 0; i < t.length(); i++)
			ta[t.charAt(i)-'a'] = true;
		for(int i = 0; i < 26; i++) {
			Collections.sort(sa.get(i));
			if(ta[i] && sa.get(i).size() == 0) {
				System.out.println(-1);
				return;
			}
		}
		long ans = 0;
		int point = 0;
		for(int i = 0; i < t.length(); i++) {
			int x = sa.get(t.charAt(i)-'a').get(lowerbound(sa.get(t.charAt(i)-'a'), point))+1;
			ans += x-point;
			point = x % s.length();
		}
		System.out.println(ans);

	}

}

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define SZ(v)       (ll)(v).size()
#define ALL(v)      (v).begin(),(v).end()
#define UNIQ(v)     sort(ALL(v));(v).erase(unique(ALL(v)),(v).end())
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define PERM(c)     for(bool p=1;p;p=next_permutation(ALL(c)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>
#define SHOW(x)     cout<<#x<<" = "<<x<<endl

template<typename T>string join(const vector<T>& v, string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(d.length());}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v)
{if(SZ(v))s<<join(v,", ");return s;}

const ll inf = 1e15;
const ll mod = 1e9+7;
const double eps = 1e-10;

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

ll d[202][202];
ll V;

void init() {
    fill((ll *)d, (ll *)d + 202 * 202, inf);
    REP(i, 202) d[i][i] = 0;
}

void add_edge(ll v1, ll v2, ll c) {
    d[v1][v2] = d[v2][v1] = c;
}

void warshall_floyd() {
    REP(k, V) REP(i, V) REP(j, V) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

int main() {
    ll N, M, R; cin >> N >> M >> R;
    vector<ll> r(R); REP(i, R) cin >> r[i], r[i]--;
    
    V = N;
    init();
    REP(i, M) {
        ll a, b, c; cin >> a >> b >> c;
        a--; b--;
        add_edge(a, b, c);
    }
    warshall_floyd();
    
    ll ans = inf;
    vector<ll> v(R);
    iota(ALL(v), 0);
    PERM(v) {
        ll sum = 0;
        REP(i, R-1) sum += d[r[v[i]]][r[v[i+1]]];
        ans = min(ans, sum);
    }
    cout << ans << endl;
    
    return 0;
}


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

long long gcd(long long a, long long b)
{
    if (b > a)
    {
        swap(a, b);
    }

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

    return b;
}

int main()
{
    int N;
    long long T[100] = {0};
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> T[i];
    }
    if (N == 1)
    {
        cout << T[0] << endl;
        return 0;
    }

    long long a, b;
    a = T[0];
    b = T[1];
    long long tmp_gcd = gcd(a, b);
    long long ans = a / tmp_gcd * b;

    if (N == 2)
    {
        cout << ans << endl;
        return 0;
    }
    for (int i = 2; i < N; i++)
    {
        a = ans;
        b = T[i];
        tmp_gcd = gcd(a, b);
        ans = a / tmp_gcd * b;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> button(N);
  int place = 1;
  int count = 0;
  
  for (int i=0; i<N; i++){
    cin >> button.at(i);
  }
  
  while (count <= N){
    count += 1;
    place = button.at(place-1);
    if (place == 2){
      break;
    }
  }
  if (count > N){
    cout << -1 << endl;
  }
  else {
    cout << count << endl;
  }
}

Measured memory_bytes: 640
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 5e1 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int a, b;
	cin >> a >> b;
	cout << b * 2 - a << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var ABCDEF = Sarray();
            var A = ABCDEF[0];
            var B = ABCDEF[1];
            var C = ABCDEF[2];
            var D = ABCDEF[3];
            var E = ABCDEF[4];
            var F = ABCDEF[5];
            var ww = 100 * A;
            var sg = 0L;
            for (var a = 0; a <= 30; ++a)
                for (var b = 0; b <= 30; ++b)
                {
                    var w = 100 * (A * a + B * b);
                    if (0 == w) continue;
                    var sl = w / 100 * E;
                    for (var c = 0; c <= sl / C; ++c)
                    {
                        if (F < w + C * c) continue;
                        var d = Min((sl - C * c) / D, (F - w - C * c) / D);
                        var s = C * c + D * d;
                        var t = 100.0 * s / (w + s);
                        if (100.0 * sg / ww < t)
                        {
                            ww = w + s;
                            sg = s;
                        }
                    }
                }
            WriteLine($"{ww} {sg}");
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 28200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;


int main() {
    int N,L;
    cin>>N>>L;
    int B=L+N-1;
    int A;
    if((L+N-1)<=0){
        A=B;
    }
    else if(L>=0){
        A=L;
    }
    else{
        A=0;
    }
    int ans=(B+L)*(B-L+1)/2-A;
    cout<<ans<<"\n";
    return 0;
}


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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int a, b;

signed main()
{
    cin >> a >> b;

    int ans = max(a + b, a - b);

    cout << max(ans, a * b) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int i,n,a_n[1000];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a_n[i]);
    }
    for(i=n-1;i>=0;i--){
        if(i>0){
            printf("%d ",a_n[i]);
        }else{
            printf("%d",a_n[i]);
        }
    }
    putchar('\n');
    return 0;
}


Measured memory_bytes: 2048
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);
	static int N;

	public static void main(String[] args){

		N = scan.nextInt();
		String[] cards = new String[N];
		String[] copys = new String[N];
		String[] ins = new String[N];
		for(int i = 0; i < N; i++){
			cards[i] = scan.next();
			copys[i] = cards[i];
			ins[i] = cards[i];
		}

		// ??????????????????
		for(int i = 0; i < N; i++){
			for(int j = N-1; j >= i+1; j--){
				String sj = cards[j].substring(1);
				String sjj = cards[j-1].substring(1);
				int vj = Integer.parseInt(sj);
				int vjj = Integer.parseInt(sjj);
				if(vj < vjj){
					String work = cards[j];
					cards[j] = cards[j-1];
					cards[j-1] = work;
				}
			}
		}

		for(int i = 0; i < N; i++){
			System.out.printf(i != N-1? "%s " : "%s\n", cards[i]);
		}
		System.out.printf("%s\n", isStable(ins, cards)? "Stable" : "Not stable");

		// ???????????????
		for(int i = 0; i < N; i++){
			int minj = i;
			for(int j = i; j < N; j++){
				String sj = copys[j].substring(1);
				String sjj = copys[minj].substring(1);
				int vj = Integer.parseInt(sj);
				int vjj = Integer.parseInt(sjj);
				if(vj < vjj){
					minj = j;
				}
			}
			if(i != minj){
				String work = copys[minj];
				copys[minj] = copys[i];
				copys[i] = work;
			}
		}

		for(int i = 0; i < N; i++){
			System.out.printf(i != N-1? "%s " : "%s\n", copys[i]);
		}
		System.out.printf("%s\n", isStable(ins, copys)? "Stable" : "Not stable");
	}

	public static boolean isStable(String[] in, String[] out){
		for(int i = 0; i < N; i++){
			for(int j = i+1; j < N; j++){
				for(int a = 0; a < N; a++){
					for(int b = a+1; b < N; b++){
						String si = in[i].substring(1);
						String sj = in[j].substring(1);
						int vi = Integer.parseInt(si);
						int vj = Integer.parseInt(sj);
						if(vi == vj && in[i].equals(out[b]) && in[j].equals(out[a])){
							return false;
						}
					}
				}
			}
		}
		return true;
	}
}

Measured memory_bytes: 61096
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main(){
    int M=1000000007;
   int n;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++)
   cin>>a[i];
   int sum=0;
   for(int i=0;i<n;i++)
   sum=sum+a[i];

   int ans=0;
   vector<int>v;
for(int i=0;i<n-1;i++){
sum=sum-a[i];
ans=ans+(a[i]*(sum%M))%M;
ans=ans%M;

}

cout<<ans<<endl;
   
    return 0;
}

Measured memory_bytes: 5120
mod = 10**9+7
N = int(input())
A = list(map(int, input().split()))
inv = [0]*(N+1)
for i in range(1, N+1):
    inv[i] = pow(i, mod-2, mod)
    inv[i] += inv[i-1]
ans = 0
for i in range(N):
    ans+=(inv[i+1]+inv[N-i]-1)*A[i]
    ans%=mod
for i in range(1, N+1):
    ans*=i
    ans%=mod
print(ans)

Measured memory_bytes: 62576
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int n;
  scan(n);
  vi a(n);
  scan(a);
  int max_index = 0;
  int max_elm = 0;
  rep (i, n) {
    if (max_elm < a[i]) {
      max_elm = a[i];
      max_index = i;
    }
  }
  int second = 0;
  rep (i, n) {
    if (i == max_index) {
      continue;
    }
    second = max(second, a[i]);
  }
  rep (i, n) {
    if (i == max_index) {
      print(second);
    } else {
      print(max_elm);
    }
  }

  return 0;
}


Measured memory_bytes: 2432
import heapq

N, M = [int(n) for n in input().split()]
hq = []
[heapq.heappush(hq, v) for v in [-1*int(n) for n in input().split()]]
[heapq.heappush(hq, -1*(-1*heapq.heappop(hq)//2)) for _ in range(M)]
print(-1*sum(hq))


Measured memory_bytes: 14180
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix

N, M, S, *I = map(int, open(0).read().split())
UVAB, CD = I[:4 * M], I[4 * M:]

R, C, V = [], [], []
for u, v, a, b in zip(*[iter(UVAB)] * 4):
    for i in range(2501 - a):
        R += [(i + a) * 51 + u, (i + a) * 51 + v]
        C += [i * 51 + v, i * 51 + u]
        V += [b, b]

for i, (c, d) in enumerate(zip(*[iter(CD)] * 2), 1):
    for j in range(2501 - c):
        R.append(j * 51 + i)
        C.append((j + c) * 51 + i)
        V.append(d)

D = dijkstra(
    csr_matrix((V, (R, C)), [2500 * 60] * 2),
    indices=min(2500, S) * 51 + 1
)

for i in range(2, N + 1):
    print(int(D[i::51].min()))

Measured memory_bytes: 116212
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			if (a == 0 && b == 0)
				break;
			int sum = 0;
			for (int i = 1; i <= a - 2; i++) {
				for (int j = i + 1; j <= a - 1; j++) {
					if (i + j > b)
						break;
					for (int k = j + 1; k <= a; k++) {
						if (i + j + k > b)
							break;
						if (i + j + k == b)
							sum++;
					}
				}
			}
			System.out.println(sum);
		}
	}
}

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

int main(){
    int w, h, n;
    cin>> w >> h >> n;

    int bottom = 0;
    int ceiling = h;
    int right = w;
    int left = 0;
    
    for(int i=0; i<n; i++){
        int x, y, a;
        cin>> x >> y >> a;

        if(a == 1 && left < x){
            left = x;
        }else if(a == 2 && right > x){
            right = x;
        }else if(a == 3 && y > bottom){
            bottom = y;
        }else if(a == 4 && y < ceiling){
            ceiling = y;
        }
    }


    if(right <= left || ceiling <= bottom){
        cout<< 0 <<endl;
    }else{
        cout<<(right-left)*(ceiling-bottom)<<endl;
    } 

    return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  int res = 0;
  while (n) {
    ++res;
    n /= k;
  }
  cout << res << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
 	int n, k;
  	cin >> n >> k;
  	long double a[n];
  	for (int i = 0; i < n; i++) cin >> a[i];
  	long double sum = 0.0;
  	long double mx = 0.0;
  	for (int i = 0; i < k; i++) sum += a[i];
  	mx = max(mx, (sum+k)/2);
  	for (int i = k; i < n; i++) {
     	sum += a[i];
      	sum -= a[i-k];
      	mx = max(mx, (sum+k)/2);
    }
  	cout << setprecision(10) << mx << endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int n,k,l,q[101010],p[101010],a[101010],b[101010];
struct bt
{
	vector<int>v;
	int g(int x)
	{
		if(v[x]<0)
		{
			return x;
		}
		else
		{
			v[x]=g(v[x]);
			return v[x];
		}
	}
	bool lj(int x,int y)
	{
		x=g(x);
		y=g(y);
		if(x==y)
		{
			return false;
		}
		if(v[x]>v[y])
		{
			int t=x;
			x=y;
			y=t;
		}
		v[x]+=v[y];
		v[y]=x;
		return true;
	}
};
int main()
{
	cin>>n>>k>>l;
	bt rd,tn;
	for(int i=0;i<n;i++)
	{
		rd.v.push_back(-1);
		tn.v.push_back(-1);
	}
	for(int i=0;i<k;i++)
	{
		cin>>p[i]>>q[i];
		p[i]--;
		q[i]--;
		rd.lj(p[i],q[i]);
	}
	for(int i=0;i<l;i++)
	{
		cin>>a[i]>>b[i];
		a[i]--;
		b[i]--;
		tn.lj(a[i],b[i]);
	}
	map<pair<int,int>,int>mp;
	for(int i=0;i<n;i++)
	{
		mp[make_pair(rd.g(i),tn.g(i))]++;
	}
	for(int i=0;i<n;i++)
	{
		cout<<mp[make_pair(rd.g(i),tn.g(i))]<<' ';
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 15084
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n),ar(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
        ar.at(i)=a.at(i)-i-1;
    }
    sort(ar.begin(),ar.end());

    int mid = ar.at(n/2);

    long long ans = 0;

    for(int i=0;i<n;i++)
        ans+=abs(mid-ar.at(i));
    
    cout<<ans<<endl;

    return 0;
}

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

#define rep(i, j, k) for (int (i) = (j); (i) < (k); ++(i))
#define repr(i, j, k) for (int (i) = (j); (i) <= (k); ++(i))

using namespace std;

vector<vector<int>> nodes;

int main()
{
	int n, d;
	cin >> n >> d;
	rep(i, 0, n) {
		vector<int> node;
		rep(j, 0, d) {
			int tmp;
			cin >> tmp;
			node.push_back(tmp);
		}
		nodes.push_back(node);
	}
	
	int count = 0;
	rep(i, 0, n) {
		rep(j, i+1, n) {
			int sum = 0;
			rep(k, 0, d) {
				sum += pow((nodes[i][k] - nodes[j][k]), 2);
			}
			int sq = sqrt(sum);
			if (sq*sq == sum) {
				++count;
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 1005


int N,M;
int table[SIZE];

void func(){

	for(int i = 0; i < N; i++){

		table[i] = 0;
	}

	int tmp;

	for(int loop = 0; loop < M; loop++){
		for(int i = 0; i < N; i++){

			scanf("%d",&tmp);
			table[i] += tmp;
		}
	}

	int ans = 0;

	for(int i = 0; i < N; i++){

		ans = max(ans,table[i]);
	}

	printf("%d\n",ans);
}

int main(){

	while(true){

		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 3216
#include <iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  int h[n+1];
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

  int dp[n];
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  int cost_a;
  int cost_b;

  for(int i = 2; i < n; i++){
    cost_a = dp[i - 1] + abs(h[i] - h[i-1]);
    cost_b = dp[i - 2] + abs(h[i] - h[i-2]);
    if (cost_a < cost_b){
      dp[i] = cost_a;
    } else {
      dp[i] = cost_b;
    }
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
import java.math.BigInteger;
    import java.util.*;
    import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    BigInteger n = new BigInteger(sc.next());
    BigInteger c26 = new BigInteger("26");
    BigInteger tmp = BigInteger.ONE;
    BigInteger sum = BigInteger.ONE;
    int digit = 1;
    while (true) {
      tmp = tmp.multiply(c26);
      BigInteger t = sum.add(tmp);
      if (t.compareTo(n) <= 0) {
        digit++;
        sum = t;
      } else {
        break;
      }
    }

    BigInteger remain = n.subtract(sum);
    String s = remain.toString(26);

    Map<Character, String> map = new HashMap<>();
    for (char i = 'a'; i <= 'z'; i++) {
      map.put(BigInteger.valueOf(i - 'a').toString(26).charAt(0), Character.toString(i));
    }
    if (s.length() < digit) {
      String t = "";
      for (int i = 0, len = digit - s.length(); i < len; i++) {
        t += "0";
      }
      s = t + s;
    }
    String result = "";
    for (int i = 0; i < digit; i++) {
      result += map.get(s.charAt(i));
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 27192
#!/usr/bin/env python3
# input
X, K, D = map(int, input().split())
DIV = (X + K * D) // (2 * D)

if X + K * D < 0:
    ans = -(X + K * D)
elif X - K * D > 0:
    ans = X - K * D
else:
    ans = min(X + K * D - DIV * D * 2, -(X + K * D - (1 + DIV) * D * 2))
print(ans)


Measured memory_bytes: 9176
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
    sc.Split(bufio.ScanWords)
    k := nextInt()

    var q Queue
    for i := 1; i < 10; i++ {
        q.Enqueue(i)
    }

    var x int
    for i := 0; i < k; i++ {
        x = q.Dequeue()

        if x%10 != 0 {
            q.Enqueue(10*x + x%10 - 1)
        }

        q.Enqueue(10*x + x%10)

        if x%10 != 9 {
            q.Enqueue(10*x + x%10 + 1)
        }

    }

    fmt.Println(x)
}

// Library

//type Queue []int

type Queue struct {
    data []int
}

func (q *Queue) Enqueue(n int) {
    q.data = append(q.data, n)
}

func (q *Queue) Dequeue() int {
    tmp := q.data[0]
    q.data = q.data[1:]
    return tmp
}

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

func nextInt() int {
    sc.Scan()
    i, _ := strconv.Atoi(sc.Text())
    return i
}

func nextIntArr(n int) []int {
    var a []int
    for i := 0; i < n; i++ {
        a = append(a, nextInt())
    }
    return a
}

// 数値を桁区切りのスライスにする
func digit(n int, list []int) []int {
   if n > 0 {
       return digit(n/10, append(list, n%10))
   }
   return list
}

func sortIntsRev(list []int) {
    sort.Sort(sort.Reverse(sort.IntSlice(list)))
}

func strReverse(s string) string {
    runes := []rune(s)
    for i := 0; i < len(s)/2; i++ {
        runes[i], runes[len(s)-1-i] = runes[len(s)-1-i], runes[i]
    }
    return string(runes)
}



Measured memory_bytes: 7168
#include<iostream>
#include<stdio.h>

using namespace std;

int main(){

	int a, b,c;
	cin >> a >> b >> c;
	if (a < b&&b < c){
		cout << "Yes" << endl;
	}
	if (a > b || b>c || a == b || b == c){
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<Pll> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i).first;
    A.at(i).second = i;
  }
  sort(ALL(A));
  ll counter = 0;
  for(int i = 0; i < N; i++){
    if(i % 2 != A.at(i).second % 2) counter++;
  }
  cout << counter/2 << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <time.h>
using namespace std;
using psi = pair<string,int>;

int main() {
  int N;
  string str;
  int integer;
  int ans;
  vector<tuple<string,int,int>> data;

  cin >> N;
  data.resize(N);
  for (int i=0; i<N; i++) {
    cin >> str >> integer;
    data.at(i) = make_tuple(str, 100-integer, i+1);
  }

  sort(data.begin(), data.end());

  for (int i=0; i<N; i++) {
    cout << get<2>(data.at(i)) << endl;
  }

}

Measured memory_bytes: 256
// By Atul Rathore

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

#define ll long long int
#define f(n) for(int i=0;i<n;i++)
#define p(x) cout<<x<<endl;
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	


int main()
{
	fastio;
	int n;
	cin>>n;
	ll sum=0;
	for(int i=1;i<=n;i++)
	{
		if(i%3!=0 && i%5!=0)sum+=i;
	}
	cout<<sum<<endl;
	
	
	
}


Measured memory_bytes: 3692
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N; cin >> N;
    vector<int> s(N); int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> s[i];
        sum += s[i];
    }

    if (sum%10 == 0) {
        int sum_c = sum;
        sort(s.begin(), s.end());
        for (int i = 0; i < N; i++) {
            if (s[i]%10 != 0) {
                sum -= s[i];
                break;
            }
        }
        if (sum == sum_c) sum = 0;
    }
    
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
bool descending(int a, int b){
    if(a>b) return true;
    else return false;
}
#define ll long long
int main(){
    int n, arr[300005];
    cin >> n;
    ll sum=0;
    for(int i=1; i<=3*n; i++){
        cin >> arr[i];
    }
    sort(arr+1, arr+3*n+1, descending);
    for(int i=2; i<=2*n; i+=2){
        sum+=arr[i];
    }
    cout << sum << endl;
    return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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(a>b){a=b;return 1;}return 0;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int main(){

  int n;
  cin>>n;
  vector<ll> p(n),q(n);
  cin>>p>>q;
  auto a = p;
  sort(a.begin(),a.end());
  int x=0,y=0;
  int cnt = 0;
  do{
    cnt++;
    if(a==p)x=cnt;
    if(a==q)y=cnt;
  }while(next_permutation(a.begin(),a.end()));
  cout<<abs(y-x)<<endl;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main (){
	int A,B,T,count = 0,ans = 0;
  		cin >> A >> B >> T;
  		for(int i = 1;i<=20;i++){
          	//cout << ans <<endl;
          	ans = A * i;
          	if(ans > T + 0.5){
            	break;
            }
            count++;
          //	cout << count <<endl;
        }
  		cout << count * B;
}

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

// pbds
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
// gp_hash_table<int, int> table;

using namespace std;

#define vec vector
#define ALL(x) begin(x), end(x)

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

const int inf = 1000 * 1000 * 1000;
const ll inf64 = 1e18;

const int mod = inf + 7;

int main() {

#ifdef debug
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, m;

    cin >> n >> m;

    vector< int > a(n), b(m);

    for(int &x : a) cin >> x;
    for(int &x : b) cin >> x;

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

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

    for(int i = 0;i + 1 < m;i++) {
        if(b[i] == b[i + 1]) {
            cout << "0\n";
            return 0;
        }
    }

    int rows = 0;
    int cols = 0;
    int busy = 0;

    vector< int > col(n * m + 1, -1), row(n * m + 1, -1);

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

    for(int i = 0;i < m;i++) {
        col[ b[i] ] = i;
    }

    int res = 1;

    for(int x = n * m;x >= 1 && (rows < n || cols < m);x--) {
        if(col[x] != -1 && row[x] != -1) {
            if(rows == n || cols == m) {
                cout << "0\n";
//                cout << "a\n";
                return 0;
            }
            rows++;
            cols++;
            busy++;
        }else if(row[x] != -1) {
            if(rows == n) {
                cout << "0\n";
//                cout << "b\n";
                return 0;
            }
            res = (1ll * res * cols) % mod;
            rows++;
            busy++;
        }else if(col[x] != -1) {
            if(cols == m) {
                cout << "0\n";
//                cout << "c\n";
//                cout << "x = " << x << "\n";
                return 0;
            }
            res = (1ll * res * rows) % mod;
            cols++;
            busy++;
        }else {
            if(cols * rows - busy == 0) {
                cout << "0\n";
//                cout << "d\n";
                return 0;
            }
            res = (1ll * res * (cols * rows - busy)) % mod;
            busy++;
        }
    }

    int ost = n * m - busy;

    for(int i = 1;i <= ost;i++) {
        res = (1ll * res * i) % mod;
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 8064
a,b = map(int,input().split())

def fctr1(n): 
    f = []
    c = 0
    for i in range(2,int(n**0.5)+2):
        while n%i == 0:
            c += 1
            n = n//i
        if c !=0:
            f.append([i,c])
            c = 0
    if n != 1:
        f.append([n,1])
    return f

dlist = fctr1(a)
#print(dlist)
ans = 1
for i in range(len(dlist)):
    if b%dlist[i][0] == 0:
        ans += 1
print(ans)



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

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

int main() {
  int n;
  cin >> n;
  int a[3][n];
  rep(i, n) cin >> a[0][i] >> a[1][i] >> a[2][i];
  int dp[3][n + 1];
  rep(i, 3) rep(j, n + 1) dp[i][j] = 0;
  repi(i, 1, n + 1) {
    rep(j, 3) {
      rep(k, 3) {
        if (j == k) continue;
        chmax(dp[j][i], dp[k][i - 1] + a[j][i - 1]);
      }
    }
  }
  cout << max({dp[0][n], dp[1][n], dp[2][n]}) << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>     
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define rev(i,n) for(ll i=n-1;i>=0;--i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define all(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x,y)* mod_pow(kai(y,y), mod - 2, mod) % mod;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};
//cout << fixed << setprecision(10) << num << endl;
int n, a[200010], b[200010];
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		b[i] = a[i] - (i+1);
	}
	sort(b, b + n);
	int sum = b[(n - 1) / 2];
	int ans = 0;
	rep(i, n) {
		ans += abs(a[i] - (i + 1) - sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <string.h>
#define M 1000000
char H[M][20];

int toi(char c){
  if(c=='A')return 1;
  else if(c=='C')return 2;
  else if(c=='G')return 3;
  else if(c=='T')return 4;
  else return 0;
}

long long int gkey(char *str){
  long long int sum =0,p=1,i,s;
  s=strlen(str);
  for(i=0;i<s;i++){
    sum+=p*(toi(str[i]));
    p=p*5;
  }
  return sum;
}

int h1(int k){
  return k%M;
}
int h2(int k){
  return 1+(k%(M-1));
}

int find(char *str){
  long long int k ,i,h;
  k=gkey(str);
  for(i=0;;i++){
    h=(h1(k)+i*h2(k))%M;
    if(strcmp(H[h],str)==0)return 1;
    else if(strlen(H[h])==0) {
      //printf("ss\n");
      return 0;
    }
  }
  return 0;
}

int in(char str[]){
  long long int k,i,h;
  k=gkey(str);
  // printf("tes\n");
  for(i=0;;i++){
    h = (h1(k)+i*h2(k))%M;
    if(strcmp(H[h],str) == 0)return 1;
    else if (strlen(H[h])==0){
      //printf("tes\n");
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

char strr[M][20],comm[M][10];
int main(){
  int i,n,h;
  //char str[M][20],com[M][10];
  for(i=0;i<M;i++){
    H[i][0]='\0';
  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s%s",comm[i],strr[i]);
  }
  for(i=0;i<n;i++){
    if(comm[i][0]=='i'){
      in(strr[i]);
      // printf("iii\n");
    }
    else{
      if(find(strr[i]) == 1){
	printf("yes\n");
      }
      else printf("no\n");
    }
  }
  return 0;
}



Measured memory_bytes: 50616
def water_charges(w):
    progressive_rate = {
    (float('inf'),30):160,
              (30,20):140,
              (20,10):125,
              (10, 0):0}

    charge = basic_charge = 1150
    for (upper, lower), rate in progressive_rate.items():
        usage = min(w, upper) - lower
        if 0 < usage:
            charge += usage * rate
            
    return charge

import sys
f = sys.stdin

last_water_charges = 4280
while True:
    w = int(f.readline())
    if w == -1:
        break
    print(last_water_charges - water_charges(w))

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

A = input().split(' ')

total = 0
B = [0]
dic = {}

for i in range(N):
    total += int(A[i])
    B.append(total)

for b in B:
    if b in dic:
        dic[b] +=1
    else:
        dic[b] = 1
def C(n):
    return int(n*(n-1)/2)

ans = 0;

for k,v in dic.items():
    ans += C(v)

print(ans)


Measured memory_bytes: 47380
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
const long long inf=1e9+7;
const long long mod=1e9+7;
const int64_t CYCLES_PER_SEC=2800000000;
//
inline uint32_t Xor128(){
	static uint32_t x=123456789;
	static uint32_t y=362436069;
	static uint32_t z=521288629;
	static uint32_t w=88675123;
	uint32_t t=x^(x<<11);
	x=y;y=z;z=w;
	return w=(w^(w>>19))^(t^(t>>8));
}
struct Timer{
	int64_t start;
	Timer(){reset();}
	void reset(){start=getcycle();}
	void plus(double a){start-=(a*CYCLES_PER_SEC);}
	inline double get(){return (double)(getcycle()-start)/CYCLES_PER_SEC;}
	inline int64_t getcycle(){
		uint32_t low,high;
		__asm__ volatile ("rdtsc":"=a"(low),"=d"(high));
		return ((int64_t)low)|((int64_t)high<<32);
	}
};
int main(){
	string s;
	cin>>s;
	int n=s.size();
	for(int i=0;i<n;i++){
		if(s[i]!=s[n-i-1]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	for(int i=0;i<(n-1)/2;i++){
		if(s[i]!=s[(n-1)/2-1-i]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	for(int i=(n+3)/2-1;i<n;i++){
		if(s[i]!=s[n-i-1]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

int main()
{	
	int n,sum = 0;
	cin >> n;
	for(int i = 1;i <= n;i++){
		int len = 0,x = i;
		while(x){
			len++;
			x /= 10;
		}
		if(len % 2 != 0) sum++;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  int N;
  cin >> N;
  int A[110];
  int difmax, t1, t2;
  t1 = std::pow(10,9);
  t2 = -1;
  for(int i = 0; i < N; i++)cin >> A[i];
  for(int i = 0; i<N; i++)if(A[i]<t1)t1=A[i];//min
  for(int i = 0; i<N; i++)if(A[i]>t2)t2=A[i];//max
  cout<< t2 - t1 << endl;
}


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

namespace RangeMinimumQuery {
  template<typename T, std::size_t N>
  void Init(T (&xs)[N], T max_value) {
    static_assert( (N & (~(N - 1))) == N, "N != 2^n");
    for(int i = 0; i < (int)N; ++i) {
      xs[i] = max_value;
    }
  }
  template<typename T, std::size_t N>
  void Update2(T (&xs)[N], int index) {
    if( index <= 1 ) return;
    int parent = index >> 1;
    int brother = index ^ 0x01;
    if( xs[index] < xs[brother] ) {
      xs[parent] = xs[index];
      Update2(xs, parent);
    }
    else {
      if( xs[parent] != xs[brother] ) {
        xs[parent] = xs[brother];
        Update2(xs, parent);
      }
    }
  }
  template<typename T, std::size_t N>
  void Update(T (&xs)[N], int index0, const T& value) {
    xs[(N >> 1) + index0] = value;
    Update2(xs, (N >> 1) + index0);
  }
  template<typename T, std::size_t N>
  T Query2(T (&xs)[N], int left, int right, int rl, int rr, int id) {
    if( rr <= left or right <= rl ) return xs[0];
    if( left <= rl and rr <= right ) return xs[id];
    if( id >= (int)(N >> 1) ) return  xs[id];
    int rm = (rl + rr) / 2;
    return std::min(Query2(xs, left, right, rl, rm, (id << 1) + 0),
                    Query2(xs, left, right, rm, rr, (id << 1) + 1));
  }
  // [left0, right0)
  template<typename T, std::size_t N>
  T Query(T (&xs)[N], int left0, int right0) {
    return Query2(xs, left0, right0, 0, N >> 1, 1);
  }
};
using namespace RangeMinimumQuery;

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A
// 
void Verify_1() {
  int n, q;
  int xs[131072 * 2];
  scanf("%d %d", &n, &q);
  Init(xs, (int)((1U << 31) - 1));
  for(int i = 0; i < q; ++i) {
    int com, x, y;
    scanf("%d %d %d", &com, &x, &y);
    if( com == 0 ) {
      Update(xs, x, y);
    }
    else {
      y += 1;
      printf("%d\n", Query(xs, x, y));
    }
  }
}

int main() {
  Verify_1();  
  return 0;
}

Measured memory_bytes: 4200
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	//n := r.nextInt()
	r.Scan(true)
	a := r.nextStringArray().toInts()
	cnt := 0
	for i := 0; i < len(a); i += 2 {
		if a[i]%2 == 1 {
			cnt++
		}
	}
	fmt.Fprintln(stdout, cnt)
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
#define pb push_back
#define PI 3.14159265
int M = 998244353;
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int cnt = m2 - m1 + (h2 - h1) * 60;
  cout << max(0ll, cnt - k);

}

Measured memory_bytes: 3640