akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

//候補クラス
class Candidate implements Comparable<Candidate> {
	int d; // 距離
	int v; // 頂点

	Candidate(int v, int d) {
		this.d = d;
		this.v = v;
	}

	// 距離が短いほど優先する
	@Override
	public int compareTo(Candidate o) {
		return d - o.d;
	}
}

//辺クラス
class Edge {
	int to; // どの頂点へ伸びているか
	int cost; // 距離

	Edge(int to, int cost) {
		this.to = to;
		this.cost = cost;
	}
}

public class Main {
	static List<List<Edge>> G; // 隣接リストで表現したグラフ
	static int[] dist; // 最短距離（仮定も含む）
	static int[] prev; // 最短距離（仮定も含む）
	static int INF = Integer.MAX_VALUE / 2;

	static void dijkstra(int sv) {
		Arrays.fill(dist, INF);
		dist[sv] = 0;
		Queue<Candidate> candidates = new PriorityQueue<Candidate>();
		candidates.offer(new Candidate(sv, 0)); // 最初に始点と距離0の候補を入れておく
		while (!candidates.isEmpty()) {
			Candidate c = candidates.poll();
			int v = c.v;
			int d = c.d;
			if (dist[v] < d) {
				continue;
			}
			List<Edge> edges = G.get(v);
			for (Edge e : edges) {
				if (dist[e.to] > dist[v] + e.cost) {
					dist[e.to] = dist[v] + e.cost;
					prev[e.to] = v;
					candidates.offer(new Candidate(e.to, dist[e.to]));
				}
			}
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		G = new ArrayList<List<Edge>>();
		for (int i = 0; i < N; i++) {
			G.add(new ArrayList<Edge>());
		}

		for (int j = 0; j < M; j++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			G.get(a).add(new Edge(b, 1));
			G.get(b).add(new Edge(a, 1));

		}
		dist = new int[N];
		prev = new int[N];
		dijkstra(0);
//		for (int i = 0; i < N; i++) {
//			System.out.print(dist[i] + " ");
//		}
//		System.out.println();
		System.out.println("Yes");
		for (int i = 1; i < N; i++) {
			System.out.println((prev[i] + 1));
		}
//		System.out.println();
	}
}


Measured memory_bytes: 82176
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  char c;
  cin>>c;
  if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u'){
    cout<<"vowel"<<endl;
  }else{
    cout<<"consonant"<<endl;
  }
  return 0;
}


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

#define loop(i,n) for(int i=1;i<=n;i++)
int pat[17][17];
bool out[17][17];

int solve(){
	int a, b, n, x, y;
	cin >> a >> b;
	if (a == 0)return 0;
	cin >> n;
	loop(i, a)loop(j, b)pat[i][j] = out[i][j] = 0;
	loop(i, n){
		cin >> x;
		cin >> y;
		out[x][y] = 1;
	}
	pat[1][1] = 1;
	loop(i, a){
		loop(j, b){
			if (out[i][j])continue;
			if (i > 1)pat[i][j] += pat[i - 1][j];
			if (j > 1)pat[i][j] += pat[i][j - 1];
		}
	}
	cout << pat[a][b] << endl;
	return 1;
}

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

Measured memory_bytes: 3072
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mk make_pair
#define pi pair<int, int>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
using namespace std;
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1},{0,0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;

/*
设 dp[i] 为长为 i 时取 ⌊i2⌋ 个数的最大和。

当 i 为奇数时，如果取 ai，dpi=dpi−2+ai，否则 dpi=dpi−1。

当 i 为偶数时，如果取 ai，dpi=dpi−2+ai，否则 dpi=pre_sumi−1。

比如当 i=4 时，如果不取 a4，要想在之前的 a1 a2 a3 中取够 2 个数，

只能取 a1 a3，即从  a1 起间隔为 2 取数作奇数位的前缀和。
*/
const int N=2e5+5;
ll a[N];
ll pre_sum[N]={};
ll dp[N]={};

int main()
{
   IOS;
   int n;
   cin >> n;
   rep(i,1,n) cin >> a[i];
   pre_sum[1]=a[1];
   for(int i=3;i<=n;i+=2) pre_sum[i]=pre_sum[i-2]+a[i];
   rep(i,2,n){
       if(i&1) dp[i]=max(dp[i-1],dp[i-2]+a[i]);
       else dp[i]=max(pre_sum[i-1],dp[i-2]+a[i]);
   }
   cout << dp[n];
}


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

signed main(){
    int N;
    cin >> N;
    
    int ans = 0;
    if(N != 1){
        for(int i=0;i<N;i++){
            ans += i;
        }
    }
    
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DEvenRelation solver = new DEvenRelation();
        solver.solve(1, in, out);
        out.close();
    }

    static class DEvenRelation {
        static DEvenRelation.Node[] graph;
        static boolean[] visited;

        static void dfs(int a, int c) {
            visited[a] = true;
            graph[a].color = c;
            for (DEvenRelation.Pair i : graph[a].edges) {
                if (!visited[i.x]) {
                    if (i.y % 2 == 0) {
                        dfs(i.x, c);
                    } else {
                        dfs(i.x, (c + 1) % 2);
                    }
                }
            }
        }

        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int n = sc.nextInt();
            graph = new DEvenRelation.Node[n];
            for (int i = 0; i < n; i++) {
                graph[i] = new DEvenRelation.Node();
                graph[i].edges = new ArrayList<>();
            }
            visited = new boolean[n];
            int x, y, z;
            DEvenRelation.Pair p;
            for (int i = 0; i < n - 1; i++) {
                x = sc.nextInt() - 1;
                y = sc.nextInt() - 1;
                z = sc.nextInt();
                p = new DEvenRelation.Pair();
                p.x = y;
                p.y = z;
                graph[x].edges.add(p);
                p = new DEvenRelation.Pair();
                p.x = x;
                p.y = z;
                graph[y].edges.add(p);
            }
            dfs(0, 0);

            for (int i = 0; i < n; i++) {
                out.println(graph[i].color);
            }
        }

        static class Pair {
            int x;
            int y;

        }

        static class Node {
            ArrayList<DEvenRelation.Pair> edges;
            int color;

        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 65312
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
using namespace std;

typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vint;
typedef vector<uint> vuint;
typedef vector<ull> vull;
typedef vector<ll> vll;

#define init(type,var) type var;cin>>var;
#define vinit(type,var,n) vector<type> var((uint)n);rep(i,0,n)cin>>var[i];
#define linit(type,var,n) list<type> var;rep(i,0,n){type _v;cin>>_v;var.push_back(_v);}
#define range(container) container.begin(),container.end()
#define rep(i,first,end) for(ull i=(first);i<(end);i++)
#define outl(out) cout<<(out)<<endl;

const ull INF = (ull)(-1LL);

typedef ull ntype;

typedef vector<ntype> vntype;
typedef list<ntype> lntype;

int main(void)
{
	init(ntype, n);
	map<string, bool> m;
	rep(i, 0, n){
		init(string, s);
		m[s] = true;
	}

	outl(m.size());

	return 0;
}

Measured memory_bytes: 19120
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <map>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <algorithm>
#include <unordered_map>
using namespace std;

#define ll long long

const int maxn = 5e6 + 7;

char s[maxn];
ll k;

int main() {
  scanf("%s", s + 1);
  scanf("%lld", &k);
  int n = strlen(s + 1);
  ll cnt = 0;
  bool same = true;
  for (int i = 2; i <= n; i++) {
    if (s[i] == s[i - 1]) {
      ++cnt;
      ++i;
    }
  }
  for (int i = 2; i <= n; i++) {
    if (s[i] != s[i - 1])
      same = false;
  }
  if (same) {
    printf("%lld\n", (n * k) / 2);
  }
  else {
    if (s[1] != s[n]) {
      printf("%lld\n", cnt * k);
    }
    else {
      ll a = 0, b = 0;
      for (int i = 1; i <= n; i++) {
        if (s[i] == s[1])
          ++a;
        else 
          break;
      }
      for (int i = n; i >= 1; i--) {
        if (s[i] == s[n])
          ++b;
        else 
          break;
      }
      printf("%lld\n", cnt * k + ((a + b)/2 - (a/2 + b/2)) * (k - 1));
    }
  }

}

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

ll saiki(ll h){
  if(h==1){
    return 1;
  }
  ll a = 2 * saiki(h/2)+1;
  return a;
}

int main(){
  ll h;
  cin >> h;
  cout << saiki(h) <<endl;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val t = mutableListOf<Int>()
    val sorted = mutableListOf<Int>()
    repeat(n) {
        val x = sc.nextInt()
        t.add(x)
        sorted.add(x)
    }

    sorted.sortDescending()

    for (x in t) {
        if (x == sorted[0]) {
            println(sorted[1])
        } else {
            println(sorted[0])
        }
    }
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
     cout << fixed << setprecision(15);

    string s;
    ld l;
    cin >> l;

    cout <<  l*l*l/27    << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

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


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

	vector<int> b;
	for (int i = n - 1; i >= 1; i -= 2) {
		b.push_back(a[i]);
	}
	b.push_back(a[0]);

	int ini;
	if (n % 2 == 1) ini = 1;
	else ini = 2;
	for (int i = ini; i < n - 1; i += 2) {
		b.push_back(a[i]);
	}

	for (int i = 0; i < n - 1; i++) {
		cout << b[i] << " ";
	}
	cout << b[n - 1] << endl;
}


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

int selectionSort(int A[], int N){
  int i, j, t, cnt = 0, minj;
  for (i = 0; i < N-1; i++) {
    minj = i;
    for (j = i; j < N; j++){
      if (A[j] < A[minj]) minj = j;
    }
    swap(A[i], A[minj]);
      if (i != minj) cnt++;
      }
  return cnt;
}

int main() {    
  int i, N, cnt, A[100];
  cin >> N;
  for (i = 0; i < N; i++) cin >> A[i];
  cnt = selectionSort(A, N);
  for (i = 0; i < N; i++){
    if (i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << cnt << endl;
}


Measured memory_bytes: 3116
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskD {
		final int infinity = (int) 1e9;
		int n;
		int[] a;
		int[][][][] dp;
		boolean[][][][] was;

		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			n = in.nextInt();
			n += 2;
			a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = in.nextInt();
			}
			dp = new int[2][2][n][n];
			was = new boolean[2][2][n][n];
			int ans = solve(0, 0, 0, 1);
			out.println(ans);
		}

		private int solve(int whoMoves, int canPass, int i, int j) {
			if (was[whoMoves][canPass][i][j]) {
				return dp[whoMoves][canPass][i][j];
			}
			was[whoMoves][canPass][i][j] = true;
			int res = whoMoves == 0 ? -infinity : +infinity;
			if (canPass == 1) {
				int nxt = solve(whoMoves ^ 1, 0, i, j);
				if (whoMoves == 0) {
					res = Math.max(res, nxt);
				} else {
					res = Math.min(res, nxt);
				}
			}
			int k = Math.max(i, j) + 1;
			if (k < n) {
				int ni = i;
				int nj = j;
				if (whoMoves == 0) {
					ni = k;
				} else {
					nj = k;
				}
				int nxt = solve(whoMoves, 1, ni, nj);
				if (whoMoves == 0) {
					res = Math.max(res, nxt);
				} else {
					res = Math.min(res, nxt);
				}
			} else {
				int score = Math.abs(a[i] - a[j]);
				if (whoMoves == 0) {
					res = Math.max(res, score);
				} else {
					res = Math.min(res, score);
				}
			}
			dp[whoMoves][canPass][i][j] = res;
			return res;
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



Measured memory_bytes: 130116
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
using ll = long long;
using ull = unsigned long long;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;

int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll l, r, res;
    cin >> l >> r;
    if((r/2019)*2019 >= l) {
        res = 0;
    } else {
        res = 2e9;
        l = l%2019;
        r = r%2019;
        for(ll i = l; i <= r; i++) {
            for(ll j = i+1; j <= r; j++) {
                res = min(res, (i*j)%2019);
            }
        }
    }
    cout << res << "\n";
    return 0; 
}

Measured memory_bytes: 256
//walking path
#if 0
    所要時間は
#endif // 0
#include<iostream>
#define MAX 20
using namespace std;

int main()
{
    int num;
    cin>>num;
    bool v[MAX][MAX],h[MAX][MAX];
    for(int i=0;i<num;i++)
    {
        int p,q;//the place of target
        int t;//the number of disconnected load
        cin>>p>>q;
        cin>>t;
        for(int m=0;m<=p;m++)
            for(int n=0;n<=q;n++)
            {
                h[m][n]=v[m][n]=true;
            }
        for(int j=0;j<t;j++)
        {
            int x1,y1,x2,y2;
            cin>>x1>>y1>>x2>>y2;
            if(x1==x2)
                v[x2][max(y1,y2)]=false;
            else if(y1==y2)
                h[max(x1,x2)][y2]=false;
        }
        for(int m=0;m<=p;m++)
            for(int n=0;n<=q;n++)
        {
           // h[m][n]=v[m][n]=true;
            //cout<<h[m][n]<<"    "<<v[m][n]<<endl;
        }
        int path[MAX][MAX];
        //path[0][0]=1;
        for(int m=0;m<=p;m++)
        {
            for(int n=0;n<=q;n++)
            {
                if(m==0&&n==0)
                    path[m][n]=1;
                else if(m==0)
                    path[m][n]=v[m][n]*path[m][n-1];
                else if(n==0)
                    path[m][n]=h[m][n]*path[m-1][n];
                else
                    path[m][n]=h[m][n]*path[m-1][n]+v[m][n]*path[m][n-1];
            }
        }
        if(path[p][q])
            cout<<path[p][q]<<endl;
        else
            cout<<"Miserable Hokusai!"<<endl;
    }
}



Measured memory_bytes: 3064
import numpy as np

H,W = map(int,input().split())
A = np.zeros((H,W))
for c in [1,-1]:
    for i in range(H):
        num = list(map(int,input().split()))
        A[i,:] += np.array(num) * c

M = 160*80
dp = [[0]*W for _ in range(H)]
dp[0][0] = 1 << M
for i in range(H):
    for j in range(W):
        if i > 0:
            dp[i][j] |= dp[i-1][j]
        if j > 0:
            dp[i][j] |= dp[i][j-1]
        a = abs(A[i,j])
        dp[i][j] = (dp[i][j] << int(a)) | (dp[i][j] >> int(a))
i = M
while True:
    if (dp[H-1][W-1] >> i) & 1:
        print(i-M)
        break
    i += 1

Measured memory_bytes: 29796
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 8;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int n, k; cin >> n >> k;
    int a[n]; rep(i, n) cin >> a[i];
    for(int i = k; i < n; ++i) {
        if(a[i] > a[i - k]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        //conpare a[i] and a[i - k]
    }
}


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

int main(){
	bool use[11];
	string in;
	
	while(1){
		int c1,c2,c3,c;
		double per=0.0;
		getline( cin, in );
		if( in.length()==0 )	break;
		sscanf(in.c_str(),"%d %d %d", &c1, &c2, &c3);
		for( int i=1; i<=10; i++ )	use[i] = false;
		use[c1] = use[c2] = use[c3] = true;
		c = c1 + c2;
		for( int i=1; i<=10; i++ ){
			if( !use[i] ){
				if( c+i <= 20 ){
					per += 1.0 / 7.0;
				}
			}
		}
		cout << (per>=0.5?"YES":"NO") << endl;
	}
	return 0;
}

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

signed main(){
  string S,A;
  cin>>S;
  int Si=S.size();
  rep(i,Si){
    if(S[i]!='B'){
      A+=S[i];
    }else{
      if(A.size()==0)continue;
      A.pop_back();
    }
  }
  cout<<A<<endl;
  return 0;
}

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

bool isprime(ll a)
{
	ll count=0;
	for(int i=1;i*i<=a;i++)
	{
		if(a%i==0)count+=2;
		if(i*i==a)count--;
	}
	
	if(count==2)return true;
	else
	return false;
	
}


vector<ll>d(151,0);
ll digitsum(ll n)
{
	ll s=0;
		while(n>0)
		{
			s+=n%10;
			n=n/10;
		}
		return s;
		
	
}
void solve()
{
	
 ll n,k;
 cin>>n>>k;
 
 ll a[n];
 for(auto &i:a)cin>>i;
 sort(a,a+n);
 
 ll ans=0;
 for(auto i:a)
 {
 	ans+=i;
 	k--;
 	if(k==0)
 	break;
 }
 
 cout<<ans;


}




int main()
{


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

		solve();
	
return 0;

		
	}
	
	
	


Measured memory_bytes: 3620
#include<iostream>

using namespace std;

int main()
{
  int x,n;
  
  cin >> x >> n;
  
  int p[101];
  for(int i=0;i<n;i++) cin >> p[i];
  
  for(int j=0;true;j++)
  {
    int c = x-j;
    bool ok = true;
  	for(int i=0;i<n;i++)
    {
      if(p[i]==c)
      {
        ok = false;
        break;
      }
    }
    
    if(ok)
    {
      cout << c << endl;
      break;
    }
    
    c = x+j;
    ok = true;
  	for(int i=0;i<n;i++)
    {
      if(p[i]==c)
      {
        ok = false;
        break;
      }
    }
    
    if(ok)
    {
      cout << c << endl;
      break;
    }
    
  }
  
  return 0;
}

Measured memory_bytes: 3644
#pragma region Macros

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

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int N, K;
    cin >> N >> K;
    int a = K;
    a *= pow((K - 1), (N - 1));

    cout << a;
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 4016
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

struct Item{
  int value,weight;
};

int dp[10005];

Item item[105];

signed main(){
  int n,w;
  cin>>n>>w;
  
  for(int i=0; i<n; i++) cin>>item[i].value>>item[i].weight;
  
  for(int i=0; i<n; i++){
    for(int j=0; j+item[i].weight<=w; j++){
      dp[j+item[i].weight]=max(dp[j+item[i].weight], dp[j]+item[i].value);
    }
  }
  
  cout<<dp[w]<<en;
}




Measured memory_bytes: 3152
using System;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        char[] s = Console.ReadLine().ToCharArray();
        Console.WriteLine(solve(s, s.Length));
    }
    static int solve(char[] s, int n) {
        char[] s1 = new char[n];
        char[] s2 = new char[n];
        for(int i = 0; i < n; i ++) {
            if(i%2==0) {
                s1[i] = '1';
                s2[i] = '0';
            }
            else {
                s1[i] = '0';
                s2[i] = '1';
            }
        }
        int count1 = 0;
        int count2 = 0;
        for(int i = 0; i < n; i ++) {
            if(s[i] != s1[i]) count1 ++;
            if(s[i] != s2[i]) count2 ++;
        }
        return Math.Min(count1,count2);
    }
}

Measured memory_bytes: 11872
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const int mnx = 3e5 + 9;
const int mod = 1e9 + 7;

bool bl;
int n, p;
int a;

int main() {

cin >> n >> p;

for(int i=0; i<n; i++) {
    cin >> a;
    if (a % 2) {
        bl = true;
    }
}

if (bl) {
    cout << (1ll<<(n-1)) << '\n';
} else {
    if (p == 0) {
        cout << (1ll<<n) << '\n';
    } else {
        cout << 0 << '\n';
    }
}

return 0;

}


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

int main(void) {
  long k, a, b, ans = 1, en = 0, tes;

  if(scanf("%lld %lld %lld", &k, &a, &b) == 1);

  if(a > b - 2 || k < a) {
    ans = k + 1;
  } else {
    k -= (a - 1);
    ans = a;

    ans -= a * (k / 2);
    ans += b * (k / 2);
    if(k % 2 != 0) {
      ans++;
    }
  }

  printf("\n%ld", ans);


  return 0;
}


Measured memory_bytes: 128
// C# program to build the smallest number 
// by removing n digits from a given number 
using System;
using System.Collections.Generic;
using System.Linq;
class GFG
{
    public static void Main(String[] args)
    {

        var n = int.Parse(Console.ReadLine());

        var arr = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

        Secret(n, arr);
    }

    public static void Secret(int n, long[] h)
    {
        Dictionary<long, long> dic = new Dictionary<long, long>();
        for (int i = 0; i < n; i++)
        {
            if (dic.ContainsKey(h[i] + i))
            {
                dic[h[i] + i]++;
            }
            else
            {
                dic.Add(h[i] + i, 1);
            }
        }
        long count = 0;
        for (int i = 0; i < n; i++)
        {
            if (dic.ContainsKey(i - h[i]))
                count += dic[i - h[i]];
        }

        Console.Write(count);

    }
}




Measured memory_bytes: 48444
using System;

namespace IssueB
{
    class Program
    {
        static void Main(string[] args)
        {
            var count = int.Parse(Console.ReadLine());
            var temp = Console.ReadLine().Split(' ');
            var res = 0.0;
            for (int i = 0; i < temp.Length; i++)
            {
                res += (1.0 / double.Parse(temp[i]));
            }

            Console.WriteLine(1.0f / res);
        }
    }
}

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

inline void smin ( int& d, const int& x )  {
	( d > x ) ? d = x : 0 ;
}

using namespace std ;

char s [234567] ;

unordered_map < int, int > dp ;

const int N = 1 << 26 ;

//bitset < N > vis ;

int main ( )  {
	scanf ( "%s", s ) ;
	int stat = 0 ;
	int l = strlen ( s ) ;
	dp [0] = 0 ;
	for ( int i = 0 ; i < l ; ++ i ) {
		stat ^= ( 1 << ( s [i] - 'a' ) ) ;
		int trans = INT_MAX ;
		for ( int j = 0 ; j < 26 ; ++ j ) {
			auto k = dp.find ( stat ^ ( 1 << j ) ) ;
			if ( k != dp.end ( ) ) smin ( trans, k -> second ) ;
		}
		auto k = dp.find ( stat ) ;
		if ( k != dp.end ( ) )  smin ( k -> second, trans + 1 ) ;
		else dp [stat] = trans + 1 ;
	}
	if ( ! stat || __builtin_popcount ( stat ) == 1 ) return cout << 1 << endl, 0 ;
	return cout << dp [stat] << endl, 0 ;
}


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

int main() {
  
double h,w,x,y;
cin>>w>>h>>x>>y;
double area=w*h/2;
cout<<fixed<<setprecision(10)<<area<<" ";
if(x==w/2&&y==h/2){
  cout<<1<<endl;

}
else{
  cout<<0<<endl;
}

}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a.sort()
m=10**10
for i in range(n):
	if abs(a[i]-a[-1]/2)<m:
		m=abs(a[i]-a[-1]/2)
for i in range(n):
	if abs(a[i]-a[-1]/2)==m:
		print(a[-1],a[i])
		break


Measured memory_bytes: 14428
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))


int sea = 0, mountain = 0, home = 0;
int a,b,c,n;
int main(){
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> a >> b >> c;
    int nsea = max(mountain, home) + a;
    int nmountain = max(sea, home) + b;
    int nhome = max(sea, mountain) + c;
    sea = nsea;
    mountain = nmountain;
    home = nhome;
  }
  cout << max(max(sea, mountain), home) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();
        int k = sc.nextInt();
        if(e-a > k){
          System.out.println(":(");
        }else{
          System.out.println("Yay!");
        }

    }
}


Measured memory_bytes: 22608
#include<algorithm>
#include<bitset>
#include<complex>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
using namespace std;

#define re register
//#define int long long 
#define Pi 3.1415926535897932384626433832795
#define LD double
#define SC (Pi*5)
#define inf 2000000000
#define MAX 100000000

struct FastIO{
	static const int S=1048576;
	char buf[S],*L,*R;int stk[20],Top;
	~FastIO(){clear();}
	inline char nc(){return L==R&&(R=(L=buf)+fread(buf,1,S,stdin),L==R)?EOF:*L++;}
	inline void clear(){fwrite(buf,1,Top,stdout);Top=0;}
	inline void pc(char ch){Top==S&&(clear(),0);buf[Top++]=ch;}
	inline void endl(){pc('\n');}
	FastIO& operator >> (int& ret){ret=0;int f=1;char ch=nc();while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=nc();}while(ch>='0'&&ch<='9'){ret=ret*10+ch-'0';ch=nc();}ret*=f;return *this;}
	FastIO& operator >> (char* s){re int Len=0;re char ch=nc();while(ch!='\n'){*(s+Len)=ch;Len++;ch=nc();}}
	FastIO& operator << (int x){if(x<0){pc('-');x=-x;}do{stk[++stk[0]]=x%10;x/=10;}while(x);while(stk[0]) pc('0'+stk[stk[0]--]);return *this;}
	FastIO& operator << (char ch){pc(ch);return *this;}
	FastIO& operator << (string str){re int Len=str.size()-1;for(stk[0]=0;Len>=0;Len--) stk[++stk[0]]=str[Len];while(stk[0]) pc(stk[stk[0]--]);return *this;}
}fin,fout;
#define File freopen("loveround.in","r",stdin);freopen("loveround.out","w",stdout); 

int n,f[200010],q[200010],cnt;LD ans;struct node{int x,y;}a[200010],S,T;
inline bool cmp(node x,node y){return x.x<y.x||(x.x==y.x&&x.y<y.y);}
inline bool inarea(int x,int y){return S.x<=x&&x<=T.x&&S.y<=y&&y<=T.y;}
inline int find(int i){re int l=0,r=cnt,mid,res=0;while(l<=r){mid=l+r>>1;if(q[mid]>a[i].y) res=mid,r=mid-1;else l=mid+1;}return res;}
signed main(){
//	File
	fin>>S.x>>S.y>>T.x>>T.y>>n;
	for(int i=1;i<=n;i++) fin>>a[i].x>>a[i].y;
	if(S.x>T.x){S.x=MAX-S.x;T.x=MAX-T.x;for(int i=1;i<=n;i++) a[i].x=MAX-a[i].x;}
	if(S.y>T.y){S.y=MAX-S.y;T.y=MAX-T.y;for(int i=1;i<=n;i++) a[i].y=MAX-a[i].y;}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++){
		if(!inarea(a[i].x,a[i].y)) continue ;
		if(!cnt||a[i].y>q[cnt]){q[++cnt]=a[i].y;continue ;}
		re int fd=find(i);if(!fd) ;
		else q[fd]=a[i].y;
	}
	ans=(LD)(T.x-S.x+T.y-S.y)*100.0-cnt*(20.0-SC);
	if(cnt==min(T.x-S.x,T.y-S.y)+1) ans+=SC;
	printf("%.16lf\n",ans);
//	fclose(stdin);fclose(stdout);
	return 0;
}

Measured memory_bytes: 5376
use std::io::Read;
use std::collections::VecDeque;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let mut s: VecDeque<char> = iterator.next().unwrap().chars().collect();

    let mut ans = 0;
    while s.len() >= 2 {
        let mut f = ' ';
        let mut b = ' ';
        {
            f = *s.front().unwrap();
            b = *s.back().unwrap();
        }
        if f == b {
            s.pop_front().unwrap();
            s.pop_back().unwrap();
        } else if f == 'x' {
            s.push_back('x');
            ans += 1;
        } else if b == 'x' {
            s.push_front('x');
            ans += 1;
        } else {
            return "-1".to_string();
        }
    }

    return ans.to_string();
}


Measured memory_bytes: 4352
#include <stdio.h>
#define ll long long int
ll MIN(ll x,ll y){return x<y?x:y;}
ll MAX(ll x,ll y){return x<y?y:x;}
ll ABS(ll x){return x>0?x:-x;}
int main(void){
	int n;
	scanf("%d",&n);
	ll a;
	ll dp[n+1][2];
	dp[0][0] = 0;
	dp[0][1] = -1e10;
	for(int i=1;i<=n;i++){
		scanf("%lld",&a);
		dp[i][0] = MAX(dp[i-1][0]+a,dp[i-1][1]-a);
		dp[i][1] = MAX(dp[i-1][0]-a,dp[i-1][1]+a);	
	}
	printf("%lld",dp[n][0]);
	return 0;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

constexpr int b = 80 * 80 + 3;
constexpr int M = b * 2 + 3;

int main(int argc, const char * argv[]) {
    int H, W;
    cin >> H >> W;
    vvi A(H, vi(W));
    vvi B(H, vi(W));
    rep (i, H) rep (j, W) cin >> A[i][j];
    rep (i, H) rep (j, W) cin >> B[i][j];

    vector<bitset<M>> dp(W+1);

    dp[1][b] = 1;
    rep (i, H) rep (j, W) { 
        int d = abs(A[i][j] - B[i][j]);
        dp[j + 1] |= dp[j];
        dp[j + 1] = (dp[j + 1] << d) | (dp[j + 1] >> d);
    }
    cout << dp.back()._Find_next(b - 1) - b << endl;
    
    return 0;
}


Measured memory_bytes: 384
#include"bits/stdc++.h"
#include"math.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std; 
int main(){
int n;cin >>n;
  vector<int> a(n),b(n);
  rep(i,n) cin>>a[i];
  rep(i,n) b[i]=a[i];
    sort(b.begin(),b.end());
  int x=0;
  rep(i,n){
    if(a[i]==b[n-1])x=i;}
  
  int s=b[n-2];
 for(int i=0;i<n;i++){
   if(i==x)cout<<s<<endl;
           else cout<<a.at(x)<<endl;
}}

Measured memory_bytes: 3200
#include<cmath>
#include<cstdio>
using namespace std;
const int maxn=100000+10;
struct node1{
	int ne,tow;
};
node1 path[maxn*2];
int n,szp,k;
int mp[maxn];
int vis[maxn];
int son[maxn],bro[maxn];
int minp[maxn],fixp[maxn];
inline void addpath(int x,int y){
	szp++;
	path[szp].ne=mp[x];
	mp[x]=szp;
	path[szp].tow=y;
}
inline void addlink(int x,int y){
	addpath(x,y);
	addpath(y,x);
}
void dfs1(int x){
	int f1;
	f1=mp[x];
	while (f1!=0){
		if (vis[path[f1].tow]==0){
			vis[path[f1].tow]=1;
			bro[path[f1].tow]=son[x];
			son[x]=path[f1].tow;
			dfs1(path[f1].tow);
		}
		f1=path[f1].ne;
	}
}

void dfs2(int x){
	int f1;
	f1=son[x];
	while (f1!=0){
		if (fixp[f1]!=-(1<<30)){
			minp[f1]=fixp[f1];
		} else{
			if (minp[x]-1>minp[f1]){
				minp[f1]=minp[x]-1;
			}
		}
		dfs2(f1);
		f1=bro[f1];
	}
	if (fixp[x]==-(1<<30)){
		f1=son[x];
		while (f1!=0){
			if (minp[f1]-1>minp[x]){
				minp[x]=minp[f1]-1;
			}
			f1=bro[f1];
		}
	}
}
bool dfs3(int x){
	int f1;
	f1=son[x];
	while (f1!=0){
		if (abs(minp[f1]-minp[x])!=1) return false;
		if (!dfs3(f1)) return false;
		f1=bro[f1];
	}
	return true;
}
int main(){
	int b1,b2,b3,b4,b5;
	scanf("%d",&n);
	szp=0;
	for (b1=1;b1<=n;b1++)mp[b1]=0;
	for (b1=1;b1<=n-1;b1++){
		scanf("%d%d",&b2,&b3);
		addlink(b2,b3);
	}
	for (b1=1;b1<=n;b1++){
		vis[b1]=0;
		son[b1]=0;
		bro[b1]=0;
	}
	vis[1]=1;
	dfs1(1);
	for (b1=1;b1<=n;b1++){
		//printf("%d %d\n",son[b1],bro[b1]);
		fixp[b1]=-(1<<30);
		minp[b1]=-(1<<30);
	}
	scanf("%d",&k);
	for (b1=1;b1<=k;b1++){
		scanf("%d%d",&b2,&b3);
		fixp[b2]=b3;
		minp[b2]=b3;
	}
	dfs2(1);
	dfs2(1);
	dfs2(1);
	if (dfs3(1)){
		printf("Yes\n");
		for (b1=1;b1<=n;b1++){
			printf("%d\n",minp[b1]);
		}
	} else {
		printf("No\n");
	
	}
}

Measured memory_bytes: 7808
#include <iostream>

using namespace std;

int main(){
  
  int h,w,n;
  cin >> h >> w >> n;
  
  if(h > w){
    cout << (n-1) / h + 1 << endl;
  } else {
    cout << (n-1) / w + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
// ░░░░░░░▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄░░░░░░
// ░░░░░░█░░▄▀▀▀▀▀▀▀▀▀▀▀▀▀▄░░█░░░░░
// ░░░░░░█░█░▀░░░░░▀░░▀░░░░█░█░░░░░
// ░░░░░░█░█░░░░░░░░▄▀▀▄░▀░█░█▄▀▀▄░
// █▀▀█▄░█░█░░▀░░░░░█░░░▀▄▄█▄▀░░░█░
// ▀▄▄░▀██░█▄░▀░░░▄▄▀░░░░░░░░░░░░▀▄
// ░░▀█▄▄█░█░░░░▄░░█░░░▄█░░░▄░▄█░░█
// ░░░░░▀█░▀▄▀░░░░░█░██░▄░░▄░░▄░███
// ░░░░░▄█▄░░▀▀▀▀▀▀▀▀▄░░▀▀▀▀▀▀▀░▄▀░
// ░░░░█░░▄█▀█▀▀█▀▀▀▀▀▀█▀▀█▀█▀▀█░░░
// ░░░░▀▀▀▀░░▀▀▀░░░░░░░░▀▀▀░░▀▀░░░░
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	string s;cin >> s;
	ll d=0;
	for (int i = 0; i < s.size()/2; ++i)
	{
		if(s[i]!=s[s.size()-i-1])d++;
	}
	cout << d;
	return 0;
}

Measured memory_bytes: 256
import numpy as np

n, m, k = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))

cum_a = np.r_[[0], np.cumsum(A)]
cum_b = np.r_[[0], np.cumsum(B)]

ans = 0
b_best = m
for a in range(0, n+1):
  ng = False
  for b in range(b_best, -2, -1):
    if b == -1:
      ng = True
      break
    # print(a, b)
    if cum_a[a] + cum_b[b] <= k:
      b_best = b
      ans = max(ans, a + b)
      break
  if ng:
    break

print(ans)
      
  
 
  
  
    

Measured memory_bytes: 58316
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int main(void){
    int n,l,b=0;
    scanf("%d%d",&n,&l);
    int app[n],sum=0;
    for(int i=0;n>i;++i){
        app[i]=l+i;
        sum+=app[i];
        if(app[i]==0)
        ++b;
    }
    int min=app[0],max;
    for(int i=1;n>i;++i)
    min=min<app[i]?min:app[i];
    if(app[n-1]<0)
    max=app[n-1];
    if(b==1)
    printf("%d",sum);
    else if(app[n-1]<0)
    printf("%d",sum-max);
    else{printf("%d",sum-min);}
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;

int main(void)
{
	int n,i,e,h[65000];
	unsigned int x,z,a,w;
	while(1){
		w=0;
		scanf("%d",&n);
		if(n==0) break;
		for(i=0;i<n;i++){
			scanf("%d",&e); w+=e;
		}
		for(i=0;i<n-1;i++) scanf("%d",&h[i]);
		sort(h,h+n-1,greater<int>());
		x=n*w;
		z=w;
		for(i=0;i<n-1;i++){
			z=z+h[i];
			a=(n-(i+1))*z;
			if(a>x) x=a;
		}
		printf("%u\n",x);
	}
	return 0;
}

Measured memory_bytes: 2916
A, B, C, D = map(int, input().split())
 
def gcd(a, b):
    while a%b!=0:
        a, b = b, a%b
    return b
 
X = B//C - (A-1)//C
Y = B//D - (A-1)//D
CD = C*D // gcd(C, D)
XY = B//CD - (A-1)//CD
 
print(B-A+1-(X+Y-XY))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define P pair<int, int>
#define PP pair<P, P>
#define mk make_pair
#define fi first
#define se second
#define V vector<int>
#define VV vector<V>
#define pb push_back
using namespace std;
typedef long long ll;

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

    ll cnt = 0;
    ll cntt = 0;
    for(int i=1; i<=N; i++) {
        if(i%K == 0) cnt++;
        if(K%2 == 0 && i%K == K/2) cntt++;
    }

    ll res = pow(cnt, (ll)3);
    if(K%2) {
        cout << res << endl;
        return 0;
    }
    res += pow(cntt, (ll)3);
    cout << res << endl;
    
    return 0;  
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int gcd(lint a, lint b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

int lcm(lint a, lint b) {
  int x = gcd(a, b);
  return (a / x) * b;
}

signed main() {
  int N;
  cin >> N;
  int T[110];
  for (int i = 0; i < N; i++) {
    cin >> T[i];
  }

  int tmp;
  for (int i = 0; i < N; i++) {
    if (i == 0)
      tmp = T[0];
    else {
      tmp = lcm(tmp, T[i]);
    }
  }

  cout << tmp << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	ll A[100001];
	set<ll> st;
	map<ll,int> stnum;
	scan(N);
	rep(i,N){
		scan(A[i]);
		A[i]=-A[i];
		auto itr=st.upper_bound(A[i]);
		if(itr!=st.end()){
			int num=(*itr);
			stnum[num]--;
			if(stnum[num]==0) st.erase(itr);
			if(st.count(A[i])){
				stnum[A[i]]++;
			}
			else{
				st.insert(A[i]);
				stnum[A[i]]=1;
			}
		}
		else{
			if(st.count(A[i])){
				stnum[A[i]]++;
			}
			else{
				st.insert(A[i]);
				stnum[A[i]]=1;
			}
		}
	}
	int ans=0;
	for(auto itr=st.begin();itr!=st.end();itr++){
		ans+=stnum[(*itr)];
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 11776
import sys
input = sys.stdin.readline

X = int(input().rstrip('\n'))
if X>=1800:
  print(1)
elif X>=1600:
  print(2)
elif X>= 1400:
  print(3)
elif X>=1200:
  print(4)
elif X>=1000:
  print(5)
elif X>=800:
  print(6)
elif X>=600:
  print(7)
else:
  print(8)


Measured memory_bytes: 9172
T1, T2, R1, R2 = map(int, input().split())
if -1 in [R1, R2]:
    if T1<T2:
        print("Alice")
    elif T1>T2:
        print("Bob")
    else:
        print("Draw")
else:
    if R1 > R2:
        print("Alice")
    elif R1 < R2:
        print("Bob")
    else:
        print("Draw")



Measured memory_bytes: 5600
// timusg
#include <iostream>
#include <bits/stdc++.h>

int main(){
	using namespace std;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int mod = 1e9 + 7;
	int cas = 1;
	//cin >> cas;
	while(cas--){
		int64_t n, sum = 0, res = 0;
		cin >> n;
		int64_t a[n];

		for(int64_t i=0; i<n; ++i){
			cin >> a[i];
			sum += a[i];
			sum %= mod;
		}

		for(int i=0; i<n; ++i){
			sum -= a[i];
			if(sum < 0) sum += mod;

			res += a[i]*sum;
			res %= mod;
		}

		cout << res << "\n";
	}
	
	return 0;
}  



Measured memory_bytes: 5168