akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct Node{
  int key;
  struct Node* prev;
  struct Node* next;
};
typedef struct Node* NodePointer;
NodePointer head;
void init()
{
  head = (NodePointer)malloc(sizeof(struct Node));
  head->prev = head;
  head->next = head;
}
 
NodePointer search(int s)
{
  NodePointer x = head->next;
  while(x!=head && x->key != s) x = x->next;
  return x;
}
 
void insert(int m)
{
  NodePointer x;
  x=(NodePointer)malloc(sizeof(struct Node));
  x->key = m;
  x->next = head->next;
  head->next->prev = x;
  head->next = x;
  x->prev = head;
}
 
void delete(int del)
{
  NodePointer x = search(del);
  if(x == head) return;
  x->prev->next = x->next;
  x->next->prev = x->prev;
}
 
void deleteFirst(){
  NodePointer x = head->next;
  if(x == head) return;
  x->prev->next = x->next;
  x->next->prev = x->prev;
}
 
void deleteLast(){
  NodePointer x = head->prev;
  if(x == head) return;
  x->prev->next = x->next;
  x->next->prev = x->prev;
}
 
int main()
{
  int i,n,m;
  NodePointer j;
  char str[17];
  init();
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%s",str);
    if(!strcmp(str,"insert")){
      scanf("%d",&m);
      insert(m);
    }
    else if(!strcmp(str,"delete")){
      scanf("%d",&m);
      delete(m);
    }
    else if(!strcmp(str,"deleteFirst")){
      deleteFirst();
    }
    else if(!strcmp(str,"deleteLast")){
      deleteLast();
    }
  }
  
  for(j = head->next; j!=head;){
    printf("%d",j->key);
    if((j=j->next) != head) printf(" ");
  }
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 34976
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>/
// #include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair

#define mod 998244353LL
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG printf("Hi\n")
#define INF 2000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2
#define SZ(z) ((int)z.size())
#define sq(x) ((x)*(x))

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL)

#define EPS 1e-7

// using namespace __gnu_pbds;
using namespace std ;

// typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

typedef long double T ;

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define maxn 100005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

#define maxn 300005

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

    int ans = 0 ;

    for(int i=1; i<=m ; i++)
    {
        for(int j=22 ; j<=d ; j++)
        {
            if( j%10 >= 2 && (j/10)*(j%10) == i ) ans++ ;
        }
    }

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

    return 0 ;
}


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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

// del

i64 n, a, b;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n >> a >> b;
    cout << min(n * a, b);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d,count=0;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    while(a>0 && c>0){
        if(count%2==0){
            c=c-b;
        }else{
            a=a-d;
        }
        count++;
    }
    if(a>0){
        printf("Yes");
    }else{
        printf("No");
    }
}


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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

int main(int argc, const char* argv[]) {
	ll n, k;
	cin >> n >> k;
	vector<ll> h(n);
	rep(i, n) cin >> h[i];

	vector<ll> dp(n);
	dp[0] = 0;
	dp[1] = absi(h[0] - h[1]);

	repd(i, 2, n) {
		ll min_cost = LLONG_MAX;
		repd(j, 1, ll(min(k + 1, i + 1))) {
			ll tmp = dp[i-j] + absi(h[i] - h[i-j]);
			if(tmp < min_cost) {
				min_cost = tmp;
			}
		}
		dp[i] += min_cost;
	}

	cout << dp.back() << endl;

	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define mod 1000000007
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
int main()
{
	sync;
	//to be the king
	char c;
	cin>>c;
	cout<<(char)(c+1);
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
using namespace std;
using ll = long long;
using ld = long double;
ll mod = ll(1e9)+7;
ll inf = ll(5e18);
template<typename T1, typename T2> ll ceill(T1 a, T2 b){ return (a+b-1)/b; }
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) for (auto vvv : vv) cout << vvv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class BCountBalls {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ll n, a, b;
	    in >> n >> a >> b;
	    ll d = n / (a+b);
	    ll res = d * a + min(a, (n - d*(a+b)));
	    out << res << endl;
	}
};


int main() {
	BCountBalls solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
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 MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
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();
}

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

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

  int x, a;
  cin >> x >> a;

  if (x < a)
    cout << 0 << endl;
  else
    cout << 10 << endl;

  return 0;
}

Measured memory_bytes: 256
using System;

namespace ITP1_5_B
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 1; ; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                int h = int.Parse(input[0]);
                int w = int.Parse(input[1]);

                if (h == 0 && w == 0)
                    break;

                for (int j=1; j<=h; j++)
                {
                    for (int k=1; k<=w; k++)
                    {
                        if (j == 1 || j == h)
                        {
                            Console.Write("#");
                        }
                        else
                        {
                            if (k == 1 || k == w)
                            {
                                Console.Write("#");
                            }
                            else
                            {
                                Console.Write(".");
                            }
                        }
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 8884
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
bool chmax(T &a, const T &b) {if (a < b){ a = b; return 1;} return 0;}
template <class T>
bool chmin(T &a, const T &b) {if (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" <<endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int ans = 0;
    int t;
    REP(i,n) {
        cin >> t;
        if (t >= k) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define min(a, b) (a > b ? b : a)

int main() {
    int a, b, c;
    while (std::cin >> a >> b >> c && a && b && c) {
        int n;
        std::cin >> n;

        int min = min(min(a * a + b * b, b * b + c * c), a * a + c * c);
        for (int i = 0; i < n; i++) {
            int r;
            std::cin >> r;
            std::cout << (min < 4 * r * r ? "OK" : "NA") << std::endl;
        }
    }
}

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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif

using namespace std;

long long len[55];

map<pair<ll, ll>, ll> memo;

long long f(long long level, long long ub) {
    if (ub <= 0) return 0;
    auto key = make_pair(level, ub);
    if (memo.count(key)) return memo[key];
    assert(ub <= len[
            level]);
//    cout << level << " " << ub << endl;
    if (level == 0) {
        return ub == 1;
    }
    if (ub == len[level]) ub--;
    long long secondBegin = len[level] - 1 - len[level - 1];
    ll ans = 0;

    if (secondBegin <= ub) {
        ans += f(level - 1, min(ub - secondBegin, len[level - 1]));
    }
    if (ub >= secondBegin) ans++;
    if (ub >= secondBegin - 1) {
        ans += f(level - 1, min(len[level - 1], ub - 1));
    } else {
        ans += f(level - 1, ub - 1);
    }

    return memo[key] = ans;
}

void solve(ll N, ll X) {
    len[0] = 1;
    for (int i = 1; i < 55; i++) len[i] = len[i - 1] * 2 + 3;
//    cout << f(1, 3) << endl;
//    for (int i = 1; i <= len[2]; i++) {
//        cout << f(2, i) - f(2, i - 1) << " ";
//    }
//    cout << endl;
    cout << f(N, X) << endl;
}


void main_(istream &cin) {
    ll N;
    ll X;
    cin >> N;
    cin >> X;
    solve(N, X);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 256
p = lambda x,y:x+y
m = lambda x,y:x-y
t = lambda x,y:x*y
ope = {'+':p, '-':m, '*':t}

data = [int(s) if s.isdigit() else s for s in input().split()]
while len(data) > 1:
	isope = [isinstance(d,str) for d in data]
	ope_idx = isope.index(True)
	xy = data[ope_idx-2:ope_idx]
	ans = ope[data[ope_idx]](*xy)
	data = data[:ope_idx-2] + [ans] + data[ope_idx+1:]

print(data[0])

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

using namespace std;

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vii         vector<pair<int,int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define endl '\n'
#define int long long int
#define TIME (chrono::steady_clock::now().time_since_epoch().count())
using namespace std;
void solve(){

    int n, m;cin >> n >> m;
    int ans = (n*(n-1))/2;
    ans += (m*(m-1))/2;
    cout << ans;





}

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    int t = 1;
   // cin >> t;
    while(t--)solve();
}




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

for x in range(0, 101):
  for y in range(0, 101):
    if(x == 0 and y == 0):
      continue
    if(x + y == a and 2*x + 4*y == b):
      print("Yes")
      exit()
print("No")

Measured memory_bytes: 9180
import sys
readline = sys.stdin.readline

from collections import deque

N, M, Q = map(int, readline().split())
abcd = [list(map(int, readline().split())) for i in range(Q)]
abcd = [(a-1, b-1, c, d) for a,b,c,d in abcd]

ans = -1e18
q = deque()
def rec():
    global ans
    if len(q) == N:
        s = 0
        l = list(q)
        for a,b,c,d in abcd:
            if l[b] - l[a] == c:
                s += d
        ans = max(ans, s)
    else:
        for j in range(q[-1], M + 1):
            q.append(j)
            rec()
            q.pop()

q.append(1)

rec()
print(ans)


    

Measured memory_bytes: 9476
/* ex4_2
   tamayama  */

#include<stdio.h>
#include<math.h>
#define PI 3.1415926535

double dist(int length_A,int length_B,int hour,int minute);
int main(void){
    int A,B,H,M;
    double distance;
    scanf("%d %d %d %d",&A,&B,&H,&M);
    distance = dist(A,B,H,M);
    printf("%.10f\n",distance);
    return 0;
}

double dist(int length_A,int length_B,int hour,int minute){
    double rad_A,rad_B;
    double rad;
    double rad_diff;
    double length;

    rad_A = (double)((hour * 30 + minute * 0.5) * PI / 180.0);    /*12時の位置から時針の角度*/
    rad_B = (double)(6 * minute * PI / 180.0);    /*12時の位置から分針の角度*/
    rad_diff = rad_A - rad_B;
    rad = fabs(rad_diff);    /*時針と分針の角度を求める*/
    length = sqrt(length_A * length_A + length_B * length_B - 2 * length_A * length_B * cos(rad));    /*余弦定理*/
    return(length);
}

Measured memory_bytes: 2580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "

int main(){
    int n,k;cin>>n>>k;
    vector<int>a(n);
    rep(i, n)cin>>a[i];
    sort(a.begin(), a.end());
    int sum = 0;
    rep(i, k)sum+=a[i];
    co(sum);
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    string n;
    cin >> n;
    rep(i, 3)if(n[i] == '1')n[i] = '9';else n[i] = '1';
    cout << n;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s2 = "0000000000";
int n;
int dfs(int n2, int m){
	if(n2 == n){
		cout << s2.substr(0,n) << endl;
      return 0;
	}
	int flag;
	for(int i = 0;i <= m;i++){
      s2[n2] = ('a' + i);
      dfs(n2 + 1, m);
    }
  s2[n2] = ('a' + m + 1);
  dfs(n2 + 1, m + 1);
}
int main(){
	cin >> n;
	dfs(0, -1);
}

Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
    long long a, b ,c;

    cin >> a >> b >> c;

    long long  minv = a*b*c;
    if(a %2 != 0 and b %2 != 0 and c %2 != 0){
        long long  a_div1 = a/2;
        long long  a_div2 = a - a/2;
        long long  b_div1 = b/2;
        long long  b_div2 = b - b/2;
        long long  c_div1 = c/2;
        long long  c_div2 = c - c/2;

        /*printf("a_div1 %d\n", a_div1);
        printf("a_div2 %d\n", a_div2);
        printf("b_div1 %d\n", b_div1);
        printf("b_div2 %d\n", b_div2);
        printf("c_div1 %d\n", c_div1);
        printf("c_div2 %d\n", c_div2);*/

        long long  a_div = abs(a_div1*b*c - a_div2*b*c);
        long long  b_div = abs(b_div1*a*c - b_div2*a*c);
        long long  c_div = abs(c_div1*a*b - c_div2*a*b);

        minv = min(minv, a_div);
        minv = min(minv, b_div);
        minv = min(minv, c_div);
    }
    else{
        minv = 0;
    }

    cout << minv << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back



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

    vector<int> b;

    for(int i=0;i<n;i++){
        if(a[i]%2==0){
            b.pb(a[i]);
        }
    }

    int ans=0;

    for(int i=0;i<b.size();i++){
        if(b[i]%3==0||b[i]%5==0){
        }else{
            ans=1;
            break;
        }
    }

    if(ans==1){
        cout << "DENIED" << endl;
    }else{
        cout << "APPROVED" << endl;
    }
}

Measured memory_bytes: 256
// ITP2_1_B Deque
import java.util.Scanner;

class Deque {
  int A[];
  int front = 500000, back = 499999;

  Deque() {
    A = new int[1000000];
  }

  void push(int d, int x) {
    if (d == 0) {
      front--;
      A[front] = x;
    } else {
      back++;
      A[back] = x;
    }
  }

  void pop(int d) {
    if (d == 0) {
      front++;
    } else {
      back--;
    }
  }
}

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    sc.nextInt();
    Deque d = new Deque();
    while (sc.hasNext()) {
      switch (sc.nextInt()) {
        case 0:
          d.push(sc.nextInt(), sc.nextInt());
          break;
        case 1:
          System.out.println(d.A[d.front + sc.nextInt()]);
          break;
        case 2:
          d.pop(sc.nextInt());
      }
    }
  }
}


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

int main() {
    int n, result = 1;
    cin >> n;
    int p[n + 1], q[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
        q[p[i]] = i;
    }
    for (int i = 2, current = 1; i <= n; i++) {
        if (q[i] > q[i - 1]) {
            current++;
            result = max(result, current);
        } else {
            current = 1;
        }
    }
    cout << n - result;
    return 0;
}

Measured memory_bytes: 1792
n,a,b = map(int,input().split())
s = list(input())
cnt = 0
cnt_b =0

for i in s:
    if i == 'a' :
        if cnt < a+b:
            cnt+=1
            print('Yes')
        elif cnt >= a+b:
            print('No')
    
    elif i == 'b':
        if cnt < a+b and cnt_b < b:
            cnt +=1
            cnt_b +=1
            print('Yes')
        elif cnt >= a+b or cnt_b >= b:
            print('No')
    
    elif i == 'c':
        print('No')


Measured memory_bytes: 4712
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

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

    string c;
    cin >> c;
    c[0] = c[0] + 1;
    cout << c << "\n";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Numerics;

public class Program
{
    public static void Main(string[] args)
    {
        string[] line = Console.ReadLine().Split(' ');

        int n = int.Parse(line[0]);
        int m = int.Parse(line[1]);

        int[] dp = new int[m + 1];
        for (int i = 0; i < n; i++)
        {
            line = Console.ReadLine().Split(' ');
            for (int j = 1; j < line.Length; j++)
            {
                dp[int.Parse(line[j])]++;
            }
        }

        Console.WriteLine(dp.Where(i => i == n).Count());
        Console.ReadLine();
    }
}


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

const int MAX_LEN = 100000;

int main() {
  string s, t;
  int q, sl[MAX_LEN+2] = {0}, tl[MAX_LEN+2] = {0};
  cin >> s >> t >> q;
  for (int i=0; i<s.length(); i++) {
    sl[i+1] = sl[i];
    if (s[i] == 'A') {
      sl[i+1]++;
    } else if (s[i] == 'B') {
      sl[i+1] += 2;
    }
  }
  for (int i=0; i<t.length(); i++) {
    tl[i+1] = tl[i];
    if (t[i] == 'A') {
      tl[i+1]++;
    } else if (t[i] == 'B') {
      tl[i+1] += 2;
    }
  }
  for (int i=0; i<q; i++) {
    int a, b, c, d, scnt, tcnt;
    cin >> a >> b >> c >> d;
    scnt = sl[b] - sl[a-1];
    tcnt = tl[d] - tl[c-1];
    if (scnt % 3 == tcnt % 3) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>
int main(void) {
	int n,i,ans,k,a,b;
	scanf("%d", &n);
	int num[10000];
	for (i = 1; i <= n; i++) {
		scanf("%d", &num[i]);
	}
	k = 1;
	ans = 0;
	for (k = 1; k <= n;k++) {
		a = num[k];
		while (a % 2 == 0) {
			ans++;
			a = a / 2;
		}
		
	
		
	}

	printf("%d", ans);












	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std ;
signed main(){
  string s,t ;
  cin >> s >> t ;
  int n = s.size(),m=t.size() ;
  vector<vector<int>>dp(n+1,vector<int>(m+1)) ;
    
  for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++){
      if(s[i-1]==t[j-1])
        dp[i][j]=1+dp[i-1][j-1] ;
      else 
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]) ;
    }
  string ans ;
  int i=n,j=m ;
  while(i>0||j>0){
    if(i>0&&dp[i-1][j]==dp[i][j])
      --i ;
    else if(j>0&&dp[i][j-1]==dp[i][j])
      --j ;
    else
      ans+=s[i-1],--i,--j ;
  }
  reverse(ans.begin(),ans.end()) ;
  cout << ans << endl ;
}

Measured memory_bytes: 38600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i, N) cin >> v[i];
    int ans = 0;
    vector<int> v2(N);
    rep(i, N) {
        cin >> v2[i];
        ans += v2[i];
    }

    vector<int> v3(N - 1);
    rep(i, N - 1) cin >> v3[i];

    for(int i = 0; i < N - 1; i++) {
        // cout << v[i] + 1 << " " << v[i + 1] << endl;
        if(v[i] + 1 == v[i + 1]) {
            ans += v3[v[i] - 1];
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>

using namespace std;

int main(){
  int N;
  cin >> N;
  int x[110];
  int y[110];
  int h[110];
  for (int i = 0; i < N; i++) {
    cin >> x[i];
    cin >> y[i];
    cin >> h[i];
  }

  for (int i = 0; i < N; i++) {
    if (h[i]) {
      swap(x[0], x[i]);
      swap(y[0], y[i]);
      swap(h[0], h[i]);
      break;
    }
  }
	

  for (int i = 0; i < 101; i++) {
    for (int j = 0; j < 101; j++) {
      bool flag = true;
      int d_x = abs(x[0] - i);
      int d_y = abs(y[0] - j);
      int H = h[0] + d_x + d_y;
      for (int k = 1; k < N; k++) {
	if (h[k] != max(H - abs(x[k] - i) - abs(y[k] - j), 0)) {
	  flag = false;
	  break;
	}
      }
      if (flag) {
	cout << i << " " << j << " " << H << endl;
	return 0;
      }
    }
  }
  
}


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

//conversion
//------------------------------------------
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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#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())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a);i>(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1000000000;
const LL MOD = 1000000007;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

int main() {
  int N;
  cin >> N;
  LL ans=1;
  REP(i,N) {
    ans *= i+1;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define Nmax 3005

using namespace std;

long long v[Nmax], n, dp[Nmax][Nmax];

void read()
{
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> v[i];
    }
}

void solve()
{
    int parityOfFirst = n % 2;
    int parityOfSecond = (parityOfFirst + 1) % 2;

    for (int i = 1; i <= n; ++i) {
        dp[i][i] = v[i];
    }

    for (int left = n; left >= 0; --left) {
        for (int right = 1; right <= n; ++right) {
            if (left <= right) {
                if ((right - left + 1) % 2 == parityOfFirst) {
                    dp[left][right] = max(dp[left][right - 1] + v[right], dp[left + 1][right] + v[left]);
                }
                else {
                    dp[left][right] = min(dp[left][right - 1] - v[right], dp[left + 1][right] - v[left]);
                }
            }
        }
    }
    cout << dp[1][n];
}

int main()
{
    ios_base::sync_with_stdio(false);
    read();
    solve();
    return 0;
}


Measured memory_bytes: 70144
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define INF ((ll)1<<31)-1
#define P std::pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int gcd(int a,int b){
	if(!a)return b;
	return gcd(b%a,a);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
int h,w,a[100010],b[100010],rb[100010];
signed main(){
	cin>>h>>w;
	rep(i,h)cin>>a[i];
	rep(i,w)cin>>b[i];
	sort(b,b+w);
	rep(i,w){
		rb[i]=b[i];
		if(i)rb[i]+=rb[i-1];
	}
	int ans=0;
	rep(i,h){
		int c=upper_bound(b,b+w,a[i])-b;
		ans+=rb[c-1]+a[i]*(w-c);
	}
	cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 5488
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<vector<int>> A(N,vector<int>(2));
  for(int i=0;i<N;i++){
    for(int j=0;j<2;j++){
      cin>>A.at(i).at(j);
    }
  }
  int c=0;
  int a=1;
  for(int i=0;i<N;i++){
    if(A.at(i).at(0)==A.at(i).at(1))c++;
    else c=0;
    
    if(c==3){
      cout<<"Yes"<<endl;
      a=0;
      break;
    }
  }
  if(a)cout<<"No"<<endl;
}
  

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

// #define mod (int) 998244353
// #define MOD (int) 1e9+7
// // Big two primes
// #define X 1001100011100001111ll
// #define all(a) a.begin(),a.end()
// #define for0(i, n) for (int i = 0; i < n; i++)
// #define for1(i, n) for (int i = 1; i <= n; i++)
// #define loop(i,a,b) for (int i = a; i < b; i++)
// #define bloop(i,a,b) for (int i = a ; i>=b;i--)
// #define tc(t) int t; cin >> t; while (t--)
// //#define int long long
// #define ll long long
// #define pb emplace_back
// #define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
// #define in(x) scanf("%d", &x)
// #define rr return 0
// #define prec(n) fixed<<setprecision(n)
// #define maxpq priority_queue<int>
// #define minpq priority_queue<int, vector<int>, greater<int> >
// #define inf (int)(1e18)
// #define ini(a, i) memset(a, i, sizeof(a))
// #define vi vector<int>
// #define fi first
// #define se second
// #define endl "\n"
// #define ii pair<int, int>
// #define vii vector<ii>
// #define sz(s) s.size()


char a[1000][1000];


int main(){
    long long int mod = 1e9+7;
    int h,w;
    cin>>h>>w;
    int i,j,dp[h][w];
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            char c;
            cin>>c;
            a[i][j]=c;
            dp[i][j]=0;
            //cout<<a[i][j]<<" ";
            //cout<<dp[i][j]<<" ";
        }
       //cout<<endl;
    }
    dp[0][0]=1;
    int r=1,cl=1;
    for(i=1;i<h;i++){
        if(a[i][0]=='#')
            r=0;
        dp[i][0]=r;    
    }
    for(i=1;i<w;i++){
        if(a[0][i]=='#')
            cl=0;
        dp[0][i]=cl;

    }
    for(i=1;i<h;i++){
        for(j=1;j<w;j++){ 
            if(a[i][j]=='#')
                continue;   
            dp[i][j]=((dp[i-1][j])%mod+(dp[i][j-1])%mod)%mod;
        }
    }
    cout<<dp[h-1][w-1]<<endl;
    return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

bool solve(){
  ll n=0;
  string s,t;cin>>s>>t;
  rep(i,s.size())n+=(s[i]!=t[i]);
  cout<<n<<endl;
  return false;
}

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


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

int treasure[5002][5002];
int x[5000];int y[5000];
int cpx[5000]; int cpy[5000];
map<int,int> xind;
map<int,int> yind;
int main()
{
	fill(treasure[0],treasure[5000],0);
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>x[i]>>y[i];
		cpx[i]=x[i];
		cpy[i]=y[i];
	}
	sort(cpx,cpx+n);
	sort(cpy,cpy+n);
	for(int i=0;i<n;i++)
	{
		xind[cpx[i]]=i;
		yind[cpy[i]]=i;
	}
	//座圧した座標で累積和
	for(int i=0;i<n;i++)
		treasure[xind[x[i]]+1][yind[y[i]]+1]++;
	//累積和
	//横
	for(int i=1;i<5002;i++)
	{
		for(int j=1;j<5002;j++)
			treasure[i][j]+=treasure[i][j-1];
	}
	//縦
	for(int i=1;i<5002;i++)
	{
		for(int j=1;j<5002;j++)
			treasure[i][j]+=treasure[i-1][j];
	}
	// for(int i=0;i<n+1;i++)
	// {
	// 	for(int j=0;j<n+1;j++)
	// 		cerr<<treasure[i][j]<<" ";
	// 	cerr<<endl;
	// }
	//クエリ
	for(int i=0;i<m;i++)
	{
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		a--;b--;
		int aind,bind,cind,dind;
		aind=upper_bound(cpx,cpx+n,a)-cpx;
		if(a<*(cpx+aind))
			aind--;
		bind=upper_bound(cpy,cpy+n,b)-cpy;
		if(b<*(cpy+bind))
			bind--;
		cind=upper_bound(cpx,cpx+n,c)-cpx;
		dind=upper_bound(cpy,cpy+n,d)-cpy;
		aind++;bind++;
		//cerr<<aind<<" "<<bind<<" "<<cind<<" "<<dind<<endl;
		int ans=treasure[cind][dind]-treasure[cind][bind]-treasure[aind][dind]+treasure[aind][bind];
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 101408
import java.util.Scanner;
import java.util.HashMap;
public class Main {

    public static void main(String[] args) {
        Scanner Ent = new Scanner(System.in);
        String palabra = Ent.next();
        HashMap tablaHash = new HashMap();
        char arreglo[] =palabra.toCharArray();
        for (int i = 0; i < arreglo.length; i++) {
            if(!tablaHash.containsKey(arreglo[i])){
                tablaHash.put(arreglo[i], arreglo[i]);
            }
        }
        if(tablaHash.size() == 2){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
    
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

struct UnionFind {
    vector<int> par, s;
    UnionFind(int n=2e5) { init(n); }
    void init(int n) {
        s.assign(n, 1); par.resize(n);
        iota(par.begin(), par.end(), 0);
    }
    int find(int x) {
        if(par[x] == x) return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(s[x] < s[y]) par[x] = y, s[y] = s[x] + s[y];
        else par[y] = x, s[x] = s[x] + s[y];
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return s[find(x)]; }
};

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n;
    cin >> n;
    UnionFind uf(200001);
    REP(i, n) {
        ll x, y;
        cin >> x >> y;
        x--, y--;
        uf.unite(x, y+100000);
    }

    vector<ll> a(200001), b(200001);
    REP(i, 200001) {
        if(i < 100000) a[uf.find(i)]++;
        else b[uf.find(i)]++;
    }
    ll ans = 0;
    REP(i, 200001) {
        if(uf.find(i) == i) {
            ans += a[i] * b[i];
        }
    }
    cout << ans-n << endl;

    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main() {
  int N,K,Q;
  cin >> N >> K >> Q;
  vector<int> A(Q),Point(N,0);
  
  rep(i,Q)cin>>A.at(i);
  
  rep(i,Q)Point.at(A.at(i)-1)++;

  rep(i,N)
  {
  	if(Point.at(i) > Q-K)cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1408
#!/usr/bin/env python3

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    Acnt = [0] * N
    Acnt[0] = 1
    telepo = [1]
    i = 0
    while True:
        Acnt[A[i] - 1] += 1
        if Acnt[A[i] - 1] > 1:
            break
        telepo.append(A[i])
        i = A[i] - 1
    roop_s = telepo.index(A[i])
    roop = len(telepo) - roop_s

    ans = 0
    if K < roop_s:
        ans = K
    else:
        ans = K - roop_s
        ans %= roop
        ans += roop_s

    print(telepo[ans])


if __name__ == "__main__":
    main()


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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
// static const ll MAX = 1000000;
static const ll INFTY = 1e12;

struct edge {
    ll to;
    char cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

#include <iostream>
using namespace std;

const int MAX = 10000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];


int main(void){

    int K;
    cin >> K;
    int gu = K/2;
    int ki = (K+1)/2;
    cout << gu * ki << endl;


}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    string s, t; cin >> s >> t;
    FOR(i, 0, n)cout << s[i] << t[i];
    cout << "\n";
}

Measured memory_bytes: 256
Thp, Tatk, Ahp, Aatk = map(int, input().split())
flag = 0
while(1):
    Ahp -= Tatk
    if Ahp <= 0:
        print("Yes")
        break
    Thp -= Aatk
    if Thp <= 0:
        print("No")
        break

Measured memory_bytes: 61748
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    int n, d;
    cin >> n >> d;
    int t, f, bt = 0, bf = 1;
    ll ans = 0, num = 0;
    while(n-- > 0){
        cin >> t >> f;
        if(t-bt < abs(f-bf)){
            ans = -1;
            break;
        }
        if(bf-1 + f-1 <= t-bt){
            ans += num * (bf-1);
            num = 0;
        }else if(num == d){
            ans = -1;
            break;
        }
        ans += num * abs(t-bt);
        num++;
        bt = t, bf = f;
    }
    if(ans != -1)   ans += num * (bf-1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3088
#import <stdio.h>

double sqrt(double x) {
    double         xHalf = 0.5 * x;
    long long int  tmp   = 0x5FE6EB50C7B537AAl - ( *(long long int*)&x >> 1);//initial guess
    double         xRes  = * (double*)&tmp;
    
    xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
    xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
    xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
    xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
    return xRes * x;
}

int main(){
    long n;
    scanf("%ld",&n);
    n=sqrt(n);
    printf("%ld", n*n);
}


Measured memory_bytes: 2164
from bisect import bisect_left
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
x = a[-1]
b = (x+1)*1.0/2
num = bisect_left(a,int(b))
if num==0: y = a[0]
else:
	if b-a[num-1] > a[num]-b: y = a[num]
	else: y = a[num-1]
if n==2: y=a[0]
print(x,y)

Measured memory_bytes: 14052
#include <bits/stdc++.h>
#define ll long long int
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define pb(v, a) v.push_back(a)
#define Sort(v) sort(v.begin(), v.end())
#define INF 0x3f3f3f3f
#define For(m) for (auto it = m.begin(); it != m.end(); it++)
#define mod 1000000007
#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);
using namespace std;


int main()
{
    fast
  ll n;
  cin >> n;
  ll k;
  cin >> k;
  ll arr[n];
  fr(i,0,n)cin >> arr[i];
  ll dp[n];
  dp[0]=0;
  dp[1]=abs(arr[1]-arr[0]);
  fr(i,2,n)
  {
      dp[i]=dp[i-1]+abs(arr[i]-arr[i-1]);
      fr(j,2,k+1)
      {
          if((i-j)>=0)
          dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
      }
  }
  cout << dp[n-1];
  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;
int main(void)
{
	int a, b, c;
	int zahyou=0;
	int count = 0;
	int n, x;
	cin >> n >> x;
	vector<int> l(n);
	int i;
	for (i = 0; i < n; i++)
	{
		cin >> l[i];
	}
	zahyou =0;
	count++;
	for (i = 0; i < n; i++)
	{
		zahyou = zahyou + l[i];
		if (zahyou > x)
		{
			break;
		}
		count++;
	}
	cout << count << endl;

	return 0;
	
}


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

int gcd(int a, int b){
    return b == 0 ? a : gcd(b, a%b);
}

int main(){
    int p, q;
    cin >> p >> q;
    
    int g = gcd(p, q);
    p /= g, q /= g;

    int ans = 1;
    for(int i = 2; i*i <= q; i++){
        if(q % i == 0){
            ans *= i;
            while(q % i == 0)   q /= i;
        }
    }
    ans *= q;

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


Measured memory_bytes: 3104