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

using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define pf 				push_front
#define mp              make_pair
#define pii             pair<int,int>
#define MAX 			1000000
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
void c_p_c()
{
#ifndef  ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
bool complete(int satisfied[], int n)
{
	int i;
	for (i = 0; i < n; i++)
	{
		if (satisfied[i] != 1)
			return false;
	}
	return true;
}
void swap(int *x, int *y)
{
	int t = *x;
	*x = *y;
	*y = t;
}

bool f(int x, int y)
{
	return x > y;
}
int Lucky(int n)
{
	int c = 0;
	while (n != 0)
	{
		int r = n % 10;
		if (r == 4 || r == 7)
			c++;
		n /= 10;
	}
	return c;
}
int32_t main()
{
	
	int x;
	cin >> x;
	//map<string, int>ma;

	//string s[4] = {"AC", "TLE", "WA", "RE"};
	int freq[x];
	//int temp = x;
	int ac = 0, tle = 0, wa = 0, re = 0;
	while (x--)
	{
		string s;
		cin >> s;
		if (s == "AC")
			ac++;
		else if (s == "TLE")
			tle++;
		else if (s == "WA")
			wa++;
		else
			re++;
	}
	cout << "AC" << " x " << ac << endl;
	cout << "WA" << " x " << wa << endl;
	cout << "TLE" << " x " << tle << endl;

	cout << "RE" << " x " << re << endl;

}



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

int main()
{
    int D;
    cin >> D;
    int c[26];
    int sd[D][26];
    for (int i = 0; i < 26;i++)
        cin >> c[i];
    for (int i = 0; i < D;i++){
        for (int k = 0; k < 26;k++){
            cin>>sd[i][k];
        }
    }
    int ans[D];
    ans[0] = 0;
    int select = 0;
    int tmp = 0;
    for (int i = 0; i < D; i++){
        for (int k = 0; k < 26;k++)
            if (tmp!=max(tmp, sd[i][k])){
                tmp = max(tmp, sd[i][k]);
                select = k;
            }
        ans[i] = select + 1;
        tmp = 0;
    }
    for (int i = 0; i <D;i++)
        cout << ans[i] << endl;
}



Measured memory_bytes: 3676
#!/usr/bin/env python3
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
cnt = []
tmp = 1
for i in range(n-1):
    if a[i] == a[i+1]:
        tmp += 1
    else:
        cnt.append(tmp)
        tmp = 1
cnt.append(tmp)
#最終の時も必ず追加する

cnt.sort()
if len(cnt) > k:
    ans = sum(cnt[-k:])
else: ans = n
print(n-ans)

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

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);

		StringTokenizer st = new StringTokenizer(br.readLine());
		int h = Integer.parseInt(st.nextToken());
		int w = Integer.parseInt(st.nextToken());

		StringTokenizer st1 = new StringTokenizer(br.readLine());
		int si = Integer.parseInt(st1.nextToken());
		int sj = Integer.parseInt(st1.nextToken());

		StringTokenizer st2 = new StringTokenizer(br.readLine());
		int ei = Integer.parseInt(st2.nextToken());
		int ej = Integer.parseInt(st2.nextToken());

		char[][] a = new char[h][w];

		for (int i = 0; i < h; i++) {
			String str = br.readLine();
			for (int j = 0; j < w; j++) {
				a[i][j] = str.charAt(j);
			}
		}

		bfs(a, si - 1, sj - 1, ei - 1, ej - 1, h, w);
		out.close();
	}

	static class Pair {
		int x;
		int y;
		int cst;

		Pair(int x, int y, int cst) {
			this.x = x;
			this.y = y;
			this.cst = cst;
		}
	}

	static int[] walkH = { 0, 1, 0, -1 };
	static int[] walkW = { 1, 0, -1, 0 };
	static int[] warpH = { 1, 1, -1, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1 };
	static int[] warpW = { 1, -1, 1, -1, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1, 0, 1, 2, 2 };

	static void bfs(char[][] a, int si, int sj, int ei, int ej, int h, int w) {
		PriorityQueue<Pair> q=new PriorityQueue<>((x,b)->(x.cst-b.cst));
		q.add(new Pair(si, sj, 0));

		

		while (!q.isEmpty()) {
			Pair rem = q.poll();

			if (rem.x == ei && rem.y == ej) {
				System.out.println(rem.cst);
				return;
			}
			if(a[rem.x][rem.y]=='#') continue;

			a[rem.x][rem.y] = '#';


			for (int k = 0; k < 4; k++) {
				int nx = walkH[k] + rem.x;
				int ny = walkW[k] + rem.y;
				if (nx >= 0 && ny >= 0 && nx < h && ny < w && a[nx][ny] == '.' ) {
					q.add(new Pair(nx, ny, rem.cst));	
				}
			}

			for (int k = 0; k < warpH.length; k++) {
				int nx = warpH[k] + rem.x;
				int ny = warpW[k] + rem.y;
				if (nx >= 0 && ny >= 0 && nx < h && ny < w && a[nx][ny] == '.') {
					q.add(new Pair(nx, ny, rem.cst + 1));
				}
			}
		}

		System.out.println(-1);
	}
}

Measured memory_bytes: 63072
house = Array.new(120,0)
n = gets.to_i
for i in 1..n
  b,f,r,v = gets.split.map(&:to_i)
  if b ==1
      house[10*f+r-11] += v
  elsif b == 2
      house[10*f+r+19] += v
  elsif b == 3
      house[10*f+r+49] += v
  else 
      house[10*f+r+79] += v
  end
end

for i in 0..119
  print " #{house[i]}"
  puts "" if i%10 == 9
  puts "#"*20 if (i == 29 ||i ==59 || i == 89)
end


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

int main() {
    int N;
    cin >> N;
    vector<int> x(N), y(N);
    rep(i, N) cin >> x[i] >> y[i];
    map<P, int> cnts;

    for(int i=0; i<N; i++) {
        map<P, int> temp;
        for(int j=0; j<N; j++) {
            P tmp = P(x[i]-x[j], y[i]-y[j]);
            if(i != j) temp[tmp]++;
        }
        for(auto& p: temp) {
            cnts[p.first]++;
        }
    }

    int mx = 0;
    for(auto& p: cnts) {
        mx = max(mx, p.second);
    }

    cout << N-mx << endl;
    return 0;
}

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

int main() {

  string S;
  cin >> S;

  char c_3 = S[2];
  char c_4 = S[3];
  char c_5 = S[4];
  char c_6 = S[5];

  int N = 0;
  if (c_3 == c_4) {
    N++;
  }
  if (c_5 == c_6) {
    N++;
  }

  if (N == 2) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3624
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {

	public static void main(String[] args)throws java.lang.Exception
    {		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n =Integer.parseInt(br.readLine()),a=0,b=0,c=0,d=0;
		while(n-->0) {
			String s=br.readLine();
			if(s.equals("AC")) ++a;
			else if(s.equals("WA")) ++b;
			else if(s.equals("TLE")) ++c;
			else ++d;
		}
		System.out.println("AC"+" x "+a+"\n"+"WA"+" x "+b+"\n"+
						"TLE"+" x "+c+"\n"+"RE"+" x "+d+"\n");

	}

}

Measured memory_bytes: 43784
import java.io.InputStream;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.concurrent.atomic.AtomicInteger;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    Map<String, AtomicInteger> votes = new HashMap<>();
    int tempMax = 0;
    for (int i = 0; i < n; i++) {
      tempMax = Math.max(
        votes.computeIfAbsent(
          sc.next(), k -> new AtomicInteger(0)
        ).incrementAndGet(), tempMax);
    }
    final int maxVotes = tempMax;
    votes.entrySet().stream()
      .filter(e -> e.getValue().get() == maxVotes)
      .map(Map.Entry::getKey)
      .sorted()
      .forEach(pw::println);
  }
}


Measured memory_bytes: 89260
#include <stdio.h>
#include <stdbool.h>
#define rep(i, n) for(int i = 0; i < n; ++i)


int main(void) {
  int n, m, q, i, j, k, now = 0;
  scanf("%d%d%d", &n, &m ,&q);
  int a[m], qu[q], next[n], before[n];
  bool f[n];
  rep(i, n) f[i] = true, next[i] = i + 1, before[i] = i - 1;
  next[n - 1] = 0, before[0] = n - 1;
  rep(i, m) scanf("%d", &a[i]);
  rep(i, q) scanf("%d", &qu[i]);
  rep(i, m) {
    int cnt = 0;
    while(cnt != a[i]) {
      if(a[i] % 2) {
        now = before[now],++cnt;
      } else {
        now = next[now], ++cnt;
      }
    }
    f[now] = false;
    before[next[now]] = before[now];
    next[before[now]] = next[now];
    now = next[now];
  }
  /*rep(i, m) printf("%d ", f[i] ? 1 : 0);
  printf("\n");*/
  rep(i, q) printf("%d\n", f[qu[i]] ? 1 : 0);
  return 0;
}


Measured memory_bytes: 5252
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n, m;
  cin >> n >> m;
  vector<i64> r[m];
  for (i64 i = 0; i < m; i++)
  {
    i64 k;
    cin >> k;
    r[i].resize(k);
    for (i64 j = 0; j < k; j++)
      cin >> r[i][j];
  }
  vector<i64> p(m);
  for (i64 i = 0; i < m; i++)
    cin >> p[i];
  i64 ans = 0;
  for (i64 i = 0; i < (1 << n); i++)
  {
    bool ok = true;
    for (i64 j = 0; j < m; j++)
    {
      i64 cnt = 0;
      for (i64 k : r[j])
        if (i & (1 << k - 1))
          cnt++;
      if (cnt % 2 != p[j])
        ok = false;
    }
    if (ok)
      ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n, l = readmi()
s = 0
t = []
for i in range(1, n + 1):
    s += i + l - 1
    t.append(i + l - 1)
mn = 0x1FFFFFFF
index = 0
for i in range(len(t)):
    if mn > abs(s - s - t[i]):
        mn = abs(s - s - t[i])
        index = i
print(s - t[index])

Measured memory_bytes: 6216
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
r = 0

n.times do |i|
  e = 0
  if b[i] > a[i]
    e += a[i]
    b[i] -= a[i]
    if b[i] > 0
      if b[i] >= a[i+1]
        e += a[i+1]
        a[i+1] = 0
      else
        e += b[i]
        a[i+1] -= b[i]
      end
    end
  else
    e += b[i]
  end
  r += e
end

puts r

Measured memory_bytes: 16684
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

signed main() {
	int n, x, t;
	cin >> n >> x >> t;
	cout << t * ((n + x - 1) / x) << endl;
	return 0;
}

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

#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define REP(i, N) for (long long i = 0; i < (N); i++)
#define FORR(i, a, b) for (long long i = (a); i >= (b); i--)
#define REPR(i, N) for (long long i = n; i >= 0; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ALL(s) (s).begin(), (s).end()
#define pb(a) push_back(a)

#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

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

int main()
{
    ll N,M;
    ll ans;
    cin >> N >> M;
    ans = min(N, M / 2);
    M -= ans * 2;
    ans += M/4;
    cout << ans << endl;
}


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

using namespace std;

struct CityInfo {
	long pref;
	long year;
	long order;
};
CityInfo *Cities;

void Swap(vector<CityInfo*> *cinfo, int i, int j)
{
	CityInfo *temp;

	temp = (*cinfo)[i];
	(*cinfo)[i] = (*cinfo)[j];
	(*cinfo)[j] = temp;
}

void Q_SORT(vector<CityInfo*> *cinfo, int left, int right)
{
	int i, j;
	int pivot;

	i = left;                      /* ソートする配列の一番小さい要素の添字 */
	j = right;                     /* ソートする配列の一番大きい要素の添字 */

	pivot = (*cinfo)[(left + right) / 2]->year; /* 基準値を配列の中央付近にとる */

	while (1) {                    /* 無限ループ */

		while ((*cinfo)[i]->year < pivot)       /* pivot より大きい値が */
			i++;                   /* 出るまで i を増加させる */

		while (pivot < (*cinfo)[j]->year)       /* pivot より小さい値が */
			j--;                   /*  出るまで j を減少させる */
		if (i >= j)                /* i >= j なら */
			break;                 /* 無限ループから抜ける */

		Swap(cinfo, i, j);             /* x[i] と x[j]を交換 */
		i++;                       /* 次のデータ */
		j--;
	}
	//ShowData(x, 10);               /* 途中経過を表示 */

	if (left < i - 1)              /* 基準値の左に 2 以上要素があれば */
		Q_SORT(cinfo, left, i - 1);     /* 左の配列を Q ソートする */
	if (j + 1 < right)            /* 基準値の右に 2 以上要素があれば */
		Q_SORT(cinfo, j + 1, right);    /* 右の配列を Q ソートする */
}


int main()
{
	long N, M;
	long order = 0;
	struct PrefInfo {
		// long pno;
		vector<CityInfo*> *citylist;
	};
	PrefInfo *Prefs;

	cin >> N >> M;

	Prefs = (PrefInfo *)malloc(sizeof(PrefInfo)*N);
	for (long i = 0; i < N; i++)
	{
		Prefs[i].citylist = new vector<CityInfo*>;
	}

	Cities = (CityInfo *)malloc(sizeof(CityInfo)*M);

	for (long i = 0; i < M; i++)
	{
		cin >> Cities[i].pref >> Cities[i].year;
		Cities[i].order = 0;

		Prefs[Cities[i].pref - 1].citylist->push_back(&(Cities[i]));
	}

	for (long i = 0; i < N; i++)
	{
		if (Prefs[i].citylist->size() > 1)
		{
			Q_SORT(&*(Prefs[i].citylist), 0, (Prefs[i].citylist->size())-1);
		}
	}

	for (long i = 0; i < N; i++)
	{
		long order = 1;
		for (auto itr = Prefs[i].citylist->begin(); itr != Prefs[i].citylist->end(); ++itr)
		{
			(*itr)->order = order;
			order++;
		}
	}

	for (long i = 0; i < M; i++)
	{
		cout << setfill('0') << setw(6) << Cities[i].pref << setfill('0') << setw(6) << Cities[i].order << endl;
	}

	return(0);
}


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

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

    map<int, int> mp;
    for(int i = 0; i < n; i++){
        cin >> a;
        mp[a]++;
    }

    int ans = 0;
    for(auto x : mp){
        if(x.first == x.second) continue;
        if(x.first > x.second) ans += x.second;
        else ans += x.second - x.first;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4736
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

vector<vector<ll> > table;
vector<P> roads;
vector<P> qs;

int main() {
  string A, B, C;
  cin >> A >> B >> C;

  string ans = "";
  ans = ans + A[0] + B[1] + C[2];

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
/**
 *    author:  FromDihPout
 *    created: 2020-08-15
**/

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


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	long long x, k, d;
	cin >> x >> k >> d;
	x = abs(x);

	long long smallest = x % d, used = min((x - smallest) / d, k);
	x -= used * d;
	if (used == k) {
		cout << x << '\n';
		return 0;
	}

	long long smallest2 = smallest - d;
	if ((k - used) % 2 == 0) {
		cout << smallest << '\n';
	}
	else {
		cout << abs(smallest2) << '\n';
	}
}


Measured memory_bytes: 3652
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int n;
  cin >> n;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  for (int i = 1; i < n; i++) {
    if (v[i] == v[i - 1]) {
      v.erase(v.begin() + i - 1, v.begin() + i + 1);
      i--;
      n -= 2;
    }
  }
  cout << v.size() << endl;
}


Measured memory_bytes: 1024
N,M = map(int,(input().split()))
line = [[] for _ in range(N)]
for i in range(M):
    a,b = map(int,(input().split()))
    line[a-1].append(b-1)
    line[b-1].append(a-1)
ans = []
for i in line[0]:
    ans.append(i)
for i in line[N-1]:
    ans.append(i)

if len(set(ans)) != len(ans):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 104396
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int len,x,l,r;
	char a[100005],c;
	cin>>a;
	len=strlen(a);
	for(int i=0;i<26;i++)
	{
		l=0;
		r=-1;
		c='a'+i;
		x=0;
		for(int j=0;j<len;j++)
		{
			if(a[j]==c) ++x;
			else --x;
			if(x>0&&j-l>0)
			{
				r=j;
				break;
			}
			if(x<0)
			{
				l=j+1;
				x=0;
			}
		}
		if(r!=-1)
		{
			printf("%d %d\n",l+1,r+1);
			return 0;
		}
	}
	printf("-1 -1\n");
	return 0;
 } 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
template<typename T>inline void read(T &FF){
	T RR=1;FF=0;char CH=getchar();
	for(;!isdigit(CH);CH=getchar())if(CH=='-')RR=-1;
	for(;isdigit(CH);CH=getchar())FF=(FF<<1)+(FF<<3)+(CH^48);
	FF*=RR;
}
template<typename T>void write(T x){
	if(x<0)putchar('-'),x*=-1;
	if(x>9)write(x/10);
	putchar(x%10+48);
}
double d,x,ans=0;
int main(){
	int n;
	cin>>n>>d>>x;
    for(double m=2*n;n--;m-=2){
        ans+=d+(m-1)/2*x;
        d+=(2*d+5*x)/m;
        x+=4*x/m;
    }printf("%.10lf\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long N, long long K){
    ll cnt = 0;
    while(N>0){
        cnt++;
        N /= K;
    }
    cout<<cnt<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


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

using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define all(vec) vec.begin(),vec.end()
#define ff first
#define ss second
#define inf 4e18
#define MOD 1000000007
#define pb push_back
#define for1(low,high,k) for(int i=low;i<high;i+=k)
#define for2(low,high,k) for(int j=low;j<high;j+=k)
#define rev(high,low,k) for(int i=high;i>=low;i-=k) 

int main(){
	fast;
	lli n,k;
	cin>>n>>k;
	vector <lli> vec(n);
	for (int i=0;i<n;i++){
		cin>>vec[i];
		vec[i]-=1;
	}
	vector <lli> levels(n,-1);
	int i=0;
	levels[0]=0;
	while (levels[vec[i]]==-1){
		levels[vec[i]]=levels[i]+1;
		i=vec[i];
	}
	int j=levels[vec[i]];
	if (k<j){
		for (int i=0;i<n;i++){
			if (levels[i]==k){
				cout<<i+1<<endl;
				break;
			}
		}
	}
	else{
	k=k-j+1;
	lli maxx=levels[i]-levels[vec[i]]+1;
	for (int l=0;l<n;l++){
		if (levels[l]<j) levels[l]=-1;
		else levels[l]-=j;
	}
	k=k%maxx;
	
	for (int i=0;i<n;i++){
		if (levels[i]!=-1 && (levels[i]+1)%maxx==k){
			cout<<i+1<<endl;
			break;
		}
	}
	}
}

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

int main(){
	int a[3];
	for (int i = 0; i < 3; i++){
		cin >> a[i];
	}
	sort(a, a + 3);
	if (a[0] == a[1] && a[2] == 7){
		cout << "YES" << endl;
		return 0;
	}
	else{
		cout << "NO" << endl;
		return 0;
	}
}

Measured memory_bytes: 256
N = int(input())
for ai in range(1,3500):
    for bi in range(1,3500):
        try:
            ci = N*ai*bi/(4*ai*bi-N*ai-N*bi)
        except:
            continue
        if ci == int(ci) and ci > 0:
            print(ai,bi,int(ci))
            exit()


Measured memory_bytes: 73172
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int[] n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        Console.WriteLine(Math.Max(Math.Min(n[1], n[3]) - Math.Max(n[0], n[2]),0));
    }
}


Measured memory_bytes: 11348
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys
import itertools

import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, L = map(int, readline().split())
S = read().decode('utf8').split()

S.sort()

print(*S,sep='')

Measured memory_bytes: 12484
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

ll gcd(ll a,ll b){
  if (a%b==0){
    return(b);
  }
  else{
  return(gcd(b,a%b));
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,K;
  cin>>N>>K;
  vector<ll> A(N);
  ll gcd_all=0ll;
  for(int i=0;i<N;i++){
    cin>>A[i];
    gcd_all=gcd(gcd_all,A[i]);
  }
  sort(rALL(A));
  ll max=A[0];

  if(K<=max && K%gcd_all==0){
    cout<<"POSSIBLE"<<endl;
  }else{
    cout<<"IMPOSSIBLE"<<endl;
  }
}


Measured memory_bytes: 1024
#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 a, ans;
  cin >> a;
  ans = a + pow(a, 2) + pow(a, 3);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4004
a, b, c, d = gets.split.map(&:to_i)
n = (b-a)+1
lcm = c.lcm(d)
cc = b/c - (a-1)/c
dc = b/d - (a-1)/d
cdc = b/(lcm) - (a-1)/(lcm)

puts n - (cc + dc - cdc)

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

int main () {
	std::ios::sync_with_stdio (0);
	std::string str;
	std::cin >> str;
	if (str[0] != 'A') {
		std::cout << "WA\n"; return 0;
	}
	if (str.size () < 2 || !(str[1] >= 'a' && str[1] <= 'z')) {
		std::cout << "WA\n"; return 0;
	}
	int ok = 0;
	for (int i = 2; i + 1 < str.size (); ++i) {
		if (str[i] == 'C') ++ok;
		else if (!(str[i] >= 'a' && str[i] <= 'z')) {
			std::cout << "WA\n"; return 0;
		}
	}
	if (!(str.back () >= 'a' && str.back () <= 'z')) {
		std::cout << "WA\n"; return 0;
	}
	if (ok == 1) std::cout << "AC\n";
	else std::cout << "WA\n";
}


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

int main(int argc, char const *argv[]) {
  int n, s_taro, s_hanako;
  string taro, hanako;

  cin >> n;

  int i;
  s_taro = 0;
  s_hanako = 0;
  for (i = 0; i < n; i++) {
    cin >> taro >> hanako;
    if (taro == hanako) {
      s_hanako++;
      s_taro++;
    } else if (taro > hanako) {
      s_taro += 3;
    } else {
      s_hanako += 3;
    }
  }
  cout << s_taro << " " << s_hanako << endl;

  return 0;
}


Measured memory_bytes: 3152
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var S = ReadLine();
		WriteLine(S[0] == S[2] ? "Yes" : "No");
		var s = new Stack<int> { 1, 2 };
	}
}
static class Func
{
	public static void Add<T>(this Stack<T> q, T x) => q.Push(x);
	public static void Add<T>(this Queue<T> q, T x) => q.Enqueue(x);
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
using arr = array<ll, 3>;
int main() {
    init();
    ll N;
    cin >> N;
    vc<arr> A(N);
    rep(i, N) cin >> A[i][0] >> A[i][1] >> A[i][2];

    sort(all(A), [](arr a1, arr a2) { return a1[0] + a1[1] < a2[0] + a2[1]; });

    ll S = 10000;
    vvc<ll> dp(N + 1, vl(S * 2 + 1, 0));

    rep(i, N){
        auto [w, s, v] = A[i];
        rep(j, S * 2 + 1){
            chmax(dp[i + 1][j], dp[i][j]);
            if(j <= s)
                chmax(dp[i + 1][j + w], dp[i][j] + v);
        }
    }

    cout << *max_element(all(dp[N])) << endl;
}

Measured memory_bytes: 163696
// https://atcoder.jp/contests/abc125/tasks/abc125_b
#include <bits/stdc++.h>
using namespace std;

int main(void)
{
  int N;
  cin >> N;
  vector<int> V(N);
  vector<int> C(N);
  int costs = 0;

  for (int i = 0; i < N; i++)
    cin >> V.at(i);
  for (int i = 0; i < N; i++)
    cin >> C.at(i);
  for (int i = 0; i < N; i++)
    if(V.at(i) - C.at(i) > 0)
      costs += V.at(i) - C.at(i);

  cout << costs << endl;
}

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

int main(){
 int n,i,j;
 int cards[4][13]={0};
 char suit; //?????????
 int num;;
 
 cin>>n;
 
 for(i=0;i<n;i++){
  cin>>suit>>num;
  
  if(suit=='S'){
   cards[0][num-1]++;
  }else if(suit=='H'){
   cards[1][num-1]++;
  }else if(suit=='C'){
   cards[2][num-1]++;
  }else{
   cards[3][num-1]++;
  }
 }
 for(i=0;i<4;i++){
  for(j=0;j<13;j++){
   if(cards[i][j]==0){
    if(i==0){
     cout<<'S'<<" "<<j+1<<endl;
    }else if(i==1){
     cout<<'H'<<" "<<j+1<<endl;
    }else if(i==2){
     cout<<'C'<<" "<<j+1<<endl;
    }else{
     cout<<'D'<<" "<<j+1<<endl;
    }
   }
  }
 }
 
 return 0;
}

Measured memory_bytes: 3092
/*
author : w2sc
  date : 2019/12/21
  time : 14:10:52
*/
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
using namespace std;
const int INF=0x3f3f3f3f;
const double EPS=1e-10,PI=acos(-1.);
struct Point{
    double x,y;
    Point(){}
    Point(double xx,double yy){x=xx,y=yy;}
    Point operator -(Point A){return Point(x-A.x,y-A.y);}
    Point operator +(Point A){return Point(x+A.x,y+A.y);}
    Point operator *(double k){return Point(k*x,k*y);}
    double operator *(Point A){return x*A.x+y*A.y;}
    double operator ^(Point A){return x*A.y-y*A.x;}
    double len2(){return x*x+y*y;}
    double len(){return sqrt(len2());}
};
typedef Point Vec;
struct Line{
    Point A,B;
    Vec v,v0;
    Line(){}
    Line(Point AA,Point BB)
    {A=AA,B=BB;v=(B-A),v0=v*(1/(B-A).len());}
    double area(Point C){return (((B-A)^(C-A)));}
    Point crossp(Line tmp)
    {
        double aa=fabs(tmp.area(A)),ab=fabs(tmp.area(B));
        return A+v*(aa/(aa+ab));;
    }
};
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        Point A,B;
        Line a,b;
        scanf("%lf%lf%lf%lf",&A.x,&A.y,&B.x,&B.y);
        a=Line(A,B);
        scanf("%lf%lf%lf%lf",&A.x,&A.y,&B.x,&B.y);
        b=Line(A,B);
        A=a.crossp(b);
        printf("%.10f %.10f\n",A.x,A.y);
    }
    return 0;
}



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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll N,M;

int main(){

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

cin>>N>>M;

if(N==1&&M==1) cout<<1<<endl;
else if(N==1&&M>1) cout<<M-2<<endl;
else if(N>1&&M==1) cout<<N-2<<endl;
else if(N==2&&M>1) cout<<0<<endl;
else if(N>1&&M==1) cout<<0<<endl; 
else cout<<(N-2)*(M-2)<<endl;


}
	


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    x = int(input())

    flag = False

    for i in range(-118, 120):
        for j in range(-119, 119):
            if i**5- j**5 == x:
                print(i, j)
                flag = True
                break
        if flag:
            break




if __name__ == '__main__':
    main()

Measured memory_bytes: 63768
#include <bits/stdc++.h>
using namespace std;
int n,k,ans;
void solve()
{
    int ans=1;
    while(n--)
    {
        if (ans<=k) ans*=2;
        else ans+=k;
    }
    cout<<ans<<endl;
}
int main()
{
    while(cin>>n>>k)
        solve();
}

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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    string s; cin >> s;
    Ans(s[0]=='9' || s[1]=='9');
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;


public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		for(; scanner.hasNext();)
		{
			String[] array = scanner.nextLine().split(" ");
			List<String> list = new ArrayList<>(Arrays.asList(array));

			for(int i=0; i<list.size(); i++)
			{
				if(!isNumber(list.get(i)))
				{
					double n = calc(list.get(i-2), list.get(i-1), list.get(i));
					list.set(i-2, String.valueOf(n));
					list.remove(i);
					list.remove(i-1);
					i = 0;
				}
			}
					
			System.out.printf("%1$.6f\n", Double.parseDouble(list.get(0)));	
		}
	}
	
	static boolean isNumber(String value)
	{
		try
		{
			Double.parseDouble(value);
			return true;
		}
		catch (NumberFormatException nfex) 
		{
			return false;
		}
	}
	
	static double calc(String str0, String str1, String sign)
	{
		double n = Double.parseDouble(str0);
		double m = Double.parseDouble(str1);
		switch(sign)
		{
			case "+":
				return n + m;
			case "-":
				return n - m;
			case "*":
				return n * m;
			case "/":
				return n / m;
		}
		
		return 0;
	}
}

Measured memory_bytes: 26528
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
using lll = long long;
using ull = unsigned long long;
using namespace std;



int main(){
  lll ii,jj,kk;
  string s;
  string weather[] = {"Sunny","Cloudy","Rainy"};
  cin >> s;

  for(ii=0;ii<3;ii++){
    if(s == weather[ii]){
      break;
    }
  }
  string ret;
  jj = (ii + 1) % 3;
  cout << weather[jj] << endl;
  
  return 0;
}


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

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

	int x = 0;

	for (int i = 0; i < 2; ++i) {
		x += max(a, b);
		if (a > b) {
			a--;
		}
		else if (a < b) {
			b--;
		}
	}
		
	cout << x << endl;
}


Measured memory_bytes: 256
/*
Problem :
Algorithm :
Status :
*/
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#define DEBUG printf("Passing Line %d in Function [%s].\n",__LINE__,__FUNCTION__);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int INF = 0x3f3f3f3f;
const string S = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
const int L = 128;

int n;
vector<string> vec;

int Query(string s){
    cout << "? " << s << endl;
    int res;
    cin >> res;
    return res;
}

string Merge(int l,int r){
    if(l == r)
        return vec[l];
    int mid = (l + r) >> 1;
    string sl = Merge(l,mid),sr = Merge(mid + 1,r);
    string s = "";
    int lenl = sl.length(),lenr = sr.length();
    for(int i = 0,j = 0,k = n - sl.size();i <= (int)sl.size();i++){
        if(i == (int)sl.size()){
            while(j < (int)sr.size()){
                s += sr[j];
                j++;
            }
            break;
        }
        while(j < (int)sr.size() && Query(s + sr[j] + sl.substr(i)) == k - 1){
            s += sr[j];
            j++;
            k--;
        }
        s += sl[i];
    }
    return s;
}

int main(){
    // freopen("data.in","r",stdin);
    // freopen("data.out","w",stdout);
    for(char c : S){
        string s(L,c);
        int num = L - Query(s);
        if(num)
            vec.push_back(s.substr(0,num));
        n += num;
    }
    string ans = Merge(0,vec.size() - 1);
    cout << "! " << ans << endl;
    return 0;
}


Measured memory_bytes: 3812
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main(){
    fastIO;
    int n,ans=0; cin>>n;
    vector<vector<int> > d(10, vector<int> (10,0) );
    for(int i=1; i<=n; i++){
        int f,l,j=i;
        f = i%10;
        while(j>0) l=j%10, j/=10;
        d[f][l]++;
    }
    for(int i=0; i<=9; ++i){
        for(int j=0; j<=9; ++j){
            ans += (d[i][j] * d[j][i]);
        }
    }
    cout<<ans;
    return 0;
}

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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

const long INF = (long)1e18;

template<class T> void gc (T& x) {
    char c;
    int s = 0;
    x = 0;
    c = getchar_unlocked();
    if (c == '-')
        s = 1;
    else if ('0' <= c && c <= '9')
        x = c - '0';
    while (true) {
        c = getchar_unlocked();
        if (c < '0' || '9' < c)
            break;
        x = x * 10 + (c - '0');
    }
    if (s)
        x = -x;
}

int main() {
    int N;
    gc (N);
    vector<ll> A (N, 0);
    REP (i, N) gc (A[i]);
    auto itr = ALL (find, A, 0);
    if (itr != end (A)) {
        cout << 0 << endl;
        return 0;
    }
    long ans = 1L;
    for (auto&& Ai : A) {
        if (INF / Ai < ans) {
            cout << -1 << endl;
            return 0;
        }
        ans *= Ai;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3944
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
 
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#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 SORT(c) sort((c).begin(), (c).end())
 
using namespace std;
 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
 
const int MOD = 1000000007;
const char ENDL = '\n';
 
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;
 
bool df[10];
 
bool fn(int n) {
    while (n > 0) {
        if (df[n % 10]) {
            return false;
        }
        n /= 10;
    }
    return true;
}
 
signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);
 
    int n, k;
    cin >> n >> k;
    VI d(k);
    REP(i, k) {
        cin >> d[i];
    }
 
    REP(i, 10) {
        df[i] = false;
    }
    REP(i, k) {
        df[d[i]] = true;
    }
 
    while (fn(n)==false){
        n++;
    }
 
    cout << n << ENDL;
 
    return 0;
}


Measured memory_bytes: 256
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const n = Number(stdin.split('\n')[0])
const s = stdin
  .split('\n')[1]
  .split(' ')

const ans = () => {
  let is4 = false

  for (let i = 0; i < n; i++) {
    if (s[i] === 'Y') {
      is4 = true
    }
  }

  console.log(is4 ? 'Four' : 'Three')
}

ans()


Measured memory_bytes: 7372
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		List<Pos>  list = new ArrayList<>();
		list.add(new Pos(0, 0, 0));
		for(int i = 0; i < N;i++){
			list.add(
				new Pos(scanner.nextInt(), scanner.nextInt(), scanner.nextInt())
			);
		}
		
		Pos tmp = list.get(0);
		for (int i = 1; i < list.size(); i++) {
			if(!tmp.isSide(list.get(i))){
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
	
	public static class Pos{
		public final int t;
		public final int x;
		public final int y;
		public Pos(int t, int x, int y){
			this.t = t;
			this.x = x;
			this.y = y;
		}
		
		public boolean isSide(Pos o){
			int time = o.t - this.t;
			int xAxis = Math.abs(this.x - o.x);
			int yAxis = Math.abs(this.y - o.y);
			return xAxis + yAxis <= time && time % 2 == (xAxis + yAxis) % 2 ;
		}
	}
}


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

int main(){
  int A, B, C, K;
  int ans;
  
  cin >> A >> B >> C >> K;

  if(A >= K){
    ans = K;
  }
  else if(A + B >= K){
    ans = A;
  }
  else{
    ans = A  -1 * (K - (A + B));
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<sstream>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const int MAXN = 2e5 + 5;
int a[MAXN];

bool cmp(int a,int b)
{
	return a > b;
}

int main()
{	
	int n,k;
	cin >> n >> k;
	for(int i = 0;i < n;i++){
		scanf("%d",&a[i]);
	}
	sort(a,a + n,cmp);
	LL ans = 0;
	for(int i = k;i < n;i++){
		ans += a[i];
	}
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 1024
s = input()
n = len(s)
ans = [0] * n

s += "R"

pos_LR = -1

for i in range(n):
	if (s[i] == "R" and s[i+1] == "L"):
		pos_RL = i

	if (s[i] == "L" and s[i+1] == "R"):
		length = i - pos_LR

		pos_LR = i

		bigger = int(length // 2) + length % 2
		smaller = length - bigger

		if (i - pos_RL) % 2 == 1:
			ans[pos_RL] = smaller
			ans[pos_RL+1] = bigger
		else:
			ans[pos_RL] = bigger
			ans[pos_RL+1] = smaller


ans = map(str, ans)
print(" ".join(ans))


Measured memory_bytes: 10356
#include <iostream>
using namespace std;
const int N=110;
bool x[N],y[N],z[N];
int main() {
	// your code goes here
	int n,X,Y,Z;
	cin>>n;
	cin>>X;
	for(int i=0;i<X;i++){
		int a;
		cin>>a;
		x[a]=1;
	}
	cin>>Y;
	for(int i=0;i<Y;i++){
		int b;
		cin>>b;
		y[b]=1;
	}
	cin>>Z;
	for(int i=0;i<Z;i++){
		int c;
		cin>>c;
		z[c]=1;
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(!x[i]&&!y[i]&&z[i] || y[i]&&z[i]) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3084
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <climits>

const int MAXN = 200001;

long long int solve(long long int& N)
{
    long long int ans = 1, i = 1;
    while(N!=1)
    {
        N = floor(N / 2);
        ans += pow(2, i);
        i++;
    }

    return ans;
}

int main()
{
    long long int H; std::cin >> H;

    long long int ans = solve(H);

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

Measured memory_bytes: 4040
#include <iostream>
using namespace std;
int main() {
  int input, a, b, c, d;
  cin >> input;
  d = input % 10;
  input = (input - d) / 10;
  c = input % 10;
  input = (input - c) / 10;
  b = input % 10;
  input = (input - b) / 10;
  a = input % 10;
  for (int op1 = 1;; op1 -= 2) {
    for (int op2 = 1; op2 >= -1; op2 -= 2) {
      for (int op3 = 1; op3 >= -1; op3 -= 2) {
        if (a + b * op1 + c * op2 + d * op3 == 7) {
          cout << a << (op1 == 1 ? '+' : '-') << b << (op2 == 1 ? '+' : '-')
               << c << (op3 == 1 ? '+' : '-') << d << "=7";
          return 0;
        }
      }
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define INF 300000
typedef long int ll;
using namespace std;

signed main(){
	int check(int a[51][51],int b[51][51],int c[51][51],int H,int W,int h,int w);
	int a[51][51];
	int b[51][51];
	int c[51][51];

	int H,W;
	int h,w;
	int flag=0;
	ll tmp;
	ll mx=-INF;

	scanf("%d %d",&H,&W);

	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			scanf("%d",&b[i][j]);
		}
	}

	scanf("%d %d",&h,&w);
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			scanf("%d",&c[i][j]);
		}
	}

//end input

	for(int i=0;i<=H-h;i++){
		for(int	j=0;j<=W-w;j++){
			tmp=check(a,b,c,i,j,h,w);
			if(tmp!=-1){
				flag=1;
//cout<<mx<<tmp<<"aa"<<endl;
				mx=max(mx,tmp);
			}
		}
	}
//cout<<flag<<"a"<<endl;
	if(flag==1){
		cout<<mx<<endl;
	}
	else{
		cout<<"NA"<<endl;
	}
	return 0;
}

	long check(int a[51][51],int b[51][51],int c[51][51],int H,int W,int h,int w){
		long sum=0;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(b[H+i][W+j]!=c[i][j]){
					return -1;
				}
				else sum+=a[H+i][W+j];
			}
		}
		return sum;
	}


Measured memory_bytes: 1236
#include <float.h>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s;
  cin >> s;
  int sum = 0;
  int s_len = s.size();
  for (int i = 0; i < s_len / 2; i++) {
    if (s[i] != s[s_len - i - 1]) {
      sum += 1;
    }
  }

  cout << sum << endl;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  if(abs(N-M)>=2){
    cout << "0" << endl;
    return 0;
  }
  long ans=1;
  for(int i=1; i<=N; i++){
    ans = (ans*i)%(long)(1e9+7);
  }
  for(int i=1; i<=M; i++){
    ans = (ans*i)%(long)(1e9+7);
  }
  if(abs(N-M)==1){
    cout << ans << endl;
    return 0;
  }
  cout << (ans*2)%(long)(1e9+7) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int S, h ,m, s,p;
    scanf("%d", &S);
    
    h=S/3600;
    
    p=S%3600;
    
    m=p/60;
    
    s=p%60;
    
    printf("%d:%d:%d\n", h, m, s);
    
    return 0;
    
}



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

int dp[11][100001];
int n, d, x;
int p[10][10];

int main(){
	cin >> n >> d >> x;
	rep(i,d) rep(j,n) cin >> p[i][j];
	rep(i,d) rep(j,100001) dp[i][j] = j;
	for(int i = d-2; i >= 0; i--){
		for(int j = 1; j <= 100000; j++){
			rep(k,n){
				if(p[i][k] > j || p[i][k] >= p[i+1][k]) continue;
				dp[i][j] = max(dp[i][j],p[i+1][k]+dp[i][j-p[i][k]]);
			}
		}
	}
	int ans = x;
	for(int i = 0; i <= d-2; i++) ans = dp[i][ans];
	cout << ans << endl;
}

Measured memory_bytes: 5252
// Air Conditioner

#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>
using namespace std;
const int INF = 1 << 29;
int main ()
{
    long long X;
    cin >> X;
    if (X >= 30) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3132
// Created by Tanuj Jain
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int bottom_up(vector<vector<int>>&v)
{
	int rows=v.size();
	int dp[rows][3];
	dp[0][0]=v[0][0];
	dp[0][1]=v[0][1];
	dp[0][2]=v[0][2];
	for(int i=1;i<rows;i++)
	{
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+v[i][0];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+v[i][1];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+v[i][2];
	}
	return (max(dp[rows-1][0],max(dp[rows-1][1],dp[rows-1][2])));
}
int main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	//#ifndef ONLINE_JUDGE
	//freopen("inputf.in","r",stdin);
	//freopen("outputf.in","w",stdout);
	//#endif

	int t;
	cin>>t;
	vector<vector<int>>v(t,vector<int>(3,0));
	for(int i=0;i<t;i++)
		for(int j=0;j<3;j++)
			cin>>v[i][j];
		cout<<bottom_up(v);
	
	
}

Measured memory_bytes: 6912
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, A, B;
    cin >> N >> A >> B;
    int n = N;
    VEC(int) X(N);
    READVEC(X);
    VEC(lint) dp(N + 1);
    dp[N - 1] = 0;
    dp[N - 2] = min(B * 1LL,  A * 1LL * (X[n - 1] - X[n - 2]));
    FORD(i, N - 3, -1) {
        dp[i] = min(B * 1LL, A * 1LL * (X[i + 1] - X[i])) + dp[i + 1];
        dp[i] = min(dp[i], B + A * 1LL * (X[n - 1]- X[i + 1]));
    }

    cout << dp[0] << endl;
    return 0;
};


Measured memory_bytes: 1408