akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  /* your code */
	struct node *cur=nil->next;
	while(cur!=nil && cur->key!=key){
		cur=cur->next;
	}
	return cur;
}

void init(){
	nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
	if(t==nil){return;}
	t->prev->next=t->next;
	t->next->prev=t->prev;
	free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  /* your code */
	deleteNode(nil->prev);
}

void delete(int key){
  /* your code */
	deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  /* your code */

	x->next=nil->next;
	nil->next->prev=x;
	nil->next=x;
	x->prev=nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}


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

int main() {
  int A, B, C, D;

  cin >> A >> B >> C >> D ;

  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
// Problem : D - Powerful Discount Tickets
// Contest : AtCoder - AtCoder Beginner Contest 141
// URL : https://atcoder.jp/contests/abc141/tasks/abc141_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
    return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
    mem(isprime,true);
    for(ll p=2;p*p<=n;p++)
    {
        if(isprime[p]==true)
        {
            for(ll i=p*p;i<=n;i+=p)
                isprime[i]=false;
        }
    }
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
void solve()
{
    ll n,m;
    cin>>n>>m;
   	ll a;
   	priority_queue<ll> pq;
   	rep(i,0,n)
   	{
   		cin>>a;
   		pq.push(a);
   	}
   	rep(i,0,m)
   	{
   		a=pq.top();
   		pq.pop();
   		a=a/2;
   		pq.push(a);
   	}
   	ll sum=0;
   	while(!pq.empty())
   	{
   		a=pq.top();
   		pq.pop();
   		sum+=a;
   	}
   	cout<<sum;
}
int main()
{
    ll inpoup = 0;
    if(inpoup==1)
    {
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
    }
    IOS
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 1400
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double ld;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)


ll f(ll n){
    ll count = 0;
    while(n%2 == 0){
        n /= 2;
        count++;
    }

    return count;
}

int main() {
    ll N;
    cin >> N;
    vector<ll> a(N);

    ll result=0;
    rep(i,N){
        ll a;
        cin >> a;
        result += f(a);
    }

    cout << result << endl;;
    
      

}


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

/*
int LCS(string a,int n1,string b,int n2)
{
	if(n1==0 || n2==0)
	return 0;	
	
	if(a[n1-1]==b[n2-1])
	{
		return 1+LCS(a,n1-1,b,n2-1);
	}
	
	else
	{
		return max(LCS(a,n1-1,b,n2),LCS(a,n1,b,n2-1));
	}
}
*/
string LCS(string a,string b)
{
	int m=a.size();
	int n=b.size();
	
	int dp[m+1][n+1];
	
	for(int i=0;i<=m;i++)
	dp[i][0]=0;
	
	for(int j=0;j<=n;j++)
	dp[0][j]=0;
	
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(a[i-1]==b[j-1])
			{
				dp[i][j]=1+dp[i-1][j-1];
			}
			else
			{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}

	
	int i=m,j=n;
	string ans;
	while(i>=1 && j>=1)
	{
		if(a[i-1]==b[j-1])
		{
			ans+=a[i-1];
			i--;
			j--;
		}
		else
		{
			if(dp[i-1][j]>dp[i][j-1])
			{
				i--;
			}
			else
			{
				j--;
			}
		}
	}
	reverse(ans.begin(),ans.end());
	return ans;
}

int main()
{
	string a,b;
	cin>>a>>b;
	
	cout<<LCS(a,b);
}


Measured memory_bytes: 38780
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
 
#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)
 
#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
using namespace std;
 
const int MX = 100 * 1000 + 7;
 
vector<int> g[MX];
bool was[MX];
int f[MX];
 
int dfs(int v) {
    if (was[v]) {
        return f[v];
    }
    was[v] = true;
    for (int to : g[v]) {
        f[v] = max(f[v], dfs(to) + 1);
    }
    return f[v];
}
int main() {
#ifdef FASTIO
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
    }
 
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, dfs(i));
    }
 
    cout << ans << "\n";
    return 0;
}
 

Measured memory_bytes: 7424
#include<iostream>
#include<algorithm>

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

class Dice
{
private:
	int tmp;
public:
	int lab[6];
	void rE(){
		tmp = lab[0];
		lab[0] = lab[3];
		lab[3] = lab[5];
		lab[5] = lab[2];
		lab[2] = tmp;
	}
	void rN(){
		tmp = lab[0];
		lab[0] = lab[1];
		lab[1] = lab[5];
		lab[5] = lab[4];
		lab[4] = tmp;
	}
	void rS() {
		tmp = lab[0];
		lab[0] = lab[4];
		lab[4] = lab[5];
		lab[5] = lab[1];
		lab[1] = tmp;
	}
	void rW() {
		tmp = lab[0];
		lab[0] = lab[2];
		lab[2] = lab[5];
		lab[5] = lab[3];
		lab[3] = tmp;
	}
	void rR() {
		tmp = lab[1];
		lab[1] = lab[2];
		lab[2] = lab[4];
		lab[4] = lab[3];
		lab[3] = tmp;
	}
	int get3(int top, int front) {
		int i;
		rep(i,3) {
			rN();
			if (top == lab[0]) break;
			rW();
			if (top == lab[0]) break;
		}
		rep(i,3) {
			if (front == lab[1]) break;
			rR();
		}
		return lab[2];
	}
	bool check(Dice &D) {
		int i;
		rep(i,6) if (lab[i] != D.lab[i]) return false;
		return true;
	}
	bool equal(Dice &D) {
		int i;
		rep(i,3) {
			rN();
			if (lab[0] == D.lab[0]) break;
			rW();
			if (lab[0] == D.lab[0]) break;
		}
		rep(i,4) {
			if (check(D)) return true;
			rR();
		}
		return false;
	}
};


int main() {
	int n,i,j,k;
	cin >> n;
	Dice dice[n];
	rep (i,n) {
		rep(j,6) cin >> dice[i].lab[j];
	}
	//process
	rep(i,n) {
		REP(j,i+1,n) {
			if (dice[i].equal(dice[j])) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds; 
using ll = long long int;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order() - 0 indexing
// order_of_key() - number of elements strictly smaller
ll power(ll x, ll y){
    ll res=1;x=x;
    while(y>0){
        if(y&1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
//---------------------------------------GL HF------------------------------------------------------
// -------------------------------------ManavJ07----------------------------------------------------
signed main()
{
    fastio();   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll N;
        cin>>N;
        cout<<N+N*N+N*N*N<<endl;
    }
}

Measured memory_bytes: 3576
#include <array>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <utility>
#include <tuple>
#include <algorithm>
#include <limits>
#include <fstream>
#include <numeric>
#include <stack>
#include <queue>
#include <list>
#include <cstring>
#include <unordered_set>

namespace
{
	template<int N>
	std::array<int, N> GetValue(std::istream& stream)
	{
		std::string buf;
		std::getline(stream, buf);

		std::stringstream sstr(buf);
		std::array<int, N> retval;

		for (int i = 0; i < N; ++i)
		{
			std::getline(sstr, buf, ' ');
			retval[i] = std::stoi(buf);
		}

		return retval;
	}

	std::vector<int> GetValue(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::getline(stream, buf);
		std::stringstream sstr(buf);

		std::vector<int> retval;
		retval.reserve(num);

		std::string input;;
		for (int i = 0; i < num && std::getline(sstr, input, delim); ++i)
		{
			retval.push_back(std::stoi(input));
		}

		return retval;
	}

	int GetValue(std::istream& stream)
	{
		int in;
		stream >> in;

		return in;
	}

	std::vector<std::string> GetValueString(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::vector<std::string> retval;
		retval.reserve(num);

		std::getline(stream, buf);
		std::stringstream sstr(buf);

		for (int i = 0; i < num && std::getline(sstr, buf, delim); ++i)
		{
			retval.push_back(std::move(buf));
		}

		return retval;
	}

	template<typename T>
	void PrintLine(const std::vector<T>& sequence)
	{
		std::cout << sequence[0];

		for (size_t i = 1; i < sequence.size(); ++i)
		{
			std::cout << ' ' << sequence[i];
		}

		std::cout << std::endl;
	}

	template<typename T>
	void Print(const std::vector<T>& sequence)
	{
		for (const auto& e : sequence)
		{
			std::cout << e << '\n';
		}

		std::cout << std::flush;
	}

	bool Solve(const std::vector<int>& A, size_t index, int n)
	{
		if (n == 0)
		{
			return true;
		}

		if (index == A.size())
		{
			return false;
		}

		return Solve(A, index + 1, n) || Solve(A, index + 1, n - A[index]);
	}
}

int main(int argc, char* argv[])
{
	auto file = (argc == 1) ? std::ifstream() : std::ifstream(argv[1]);
	std::istream& stream = (argc == 1) ? std::cin : file;
	if (argc == 1)
	{
		std::cin.tie(0);
		std::ios::sync_with_stdio(false);
	}

	int a_num = GetValue<1>(stream)[0];
	std::vector<int> A = GetValue(stream, a_num, ' ');
	int q_num = GetValue<1>(stream)[0];

	for (int i = 0; i < q_num; ++i)
	{
		int q;
		stream >> q;

		if (Solve(A, 0, q))
		{
			std::cout << "yes\n";
		}
		else
		{
			std::cout << "no\n";
		}
	}

	std::cout << std::flush;
}



Measured memory_bytes: 3228
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

typedef long long ll;

int N;
vector<int> A;

int main(void) {
	cin >> N;

	A.resize(N + 1);
	for (int i = 0; i <= N; ++i)
		A[i] = i;

	for (int i = 3; i <= N; i += 3)
		A[i] = 0;
	for (int i = 5; i <= N; i += 5)
		A[i] = 0;

	ll ans = accumulate(A.begin(), A.end(), (ll)0);
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 7132
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

data = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(data[K-1])

Measured memory_bytes: 38384
#include<stdio.h>
int main()
{  long long a,b,c,k;
   scanf("%lld %lld %lld %lld",&a,&b,&c,&k);
     if(k%2==0)
        printf("%lld\n",a-b);
     else
       printf("%lld\n",b-a);

}

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

const int N = 100010;

int n, m;
double ans = 0, power[N];

int main() {
    cin >> n >> m;
    double tmp = 0.5;
    for(int i = 1; i <= 100000; ++i) {
        power[i] = tmp;
        tmp /= 2.0;
    }
    for(int i = 1; i <= n; ++i) {
        int cnt = 0, now = i;
        while(now < m) now *= 2, ++cnt;
        if(!cnt) ans += 1.0 / n;
        else ans += 1.0 / n * power[cnt];
    }
    printf("%.12lf\n", ans);
}

Measured memory_bytes: 1024
#include<queue>
#include<cstdio>

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

using namespace std;

const int INF=1<<29;

template<class T> struct Edge{
	int v,rev;
	T capa,flow;
};

template<class T>
struct AdjList:public vector< vector< Edge<T> > >{
	AdjList(int n):vector< vector< Edge<T> > >(n){}
};

template<class T>
void add_edge(AdjList<T> &adj,int u,int v,T capa){
	adj[u].push_back((Edge<T>){v,adj[v].size()  ,capa,0});
	adj[v].push_back((Edge<T>){u,adj[u].size()-1,capa,0});
}

template<class T>
T augment(AdjList<T> &adj,int s,int t){
	int n=adj.size();
	vector<int> pre(n);
	vector<bool> vis(n); vis[s]=true;

	queue< pair<int,T> > qu;
	qu.push(make_pair(s,INF));

	T res=0;
	while(!qu.empty()){
		int u=qu.front().first;
		T water=qu.front().second;
		qu.pop();

		if(u==t){ res=water; break; }

		rep(i,adj[u].size()){
			Edge<T> &e=adj[u][i];
			if(!vis[e.v] && e.capa-e.flow>0){
				vis[e.v]=true;
				pre[e.v]=e.rev;
				qu.push(make_pair(e.v,min(water,e.capa-e.flow)));
			}
		}
	}

	if(res>0){
		for(int v=t;v!=s;){
			Edge<T> &e1=adj[v][pre[v]];
			Edge<T> &e2=adj[e1.v][e1.rev];
			e1.flow-=res;
			e2.flow+=res;
			v=e1.v;
		}
	}

	return res;
}

template<class T>
T Edmonds_Karp(AdjList<T> &adj,int s,int t){
	T ans=0;
	for(T water=1;water>0;ans+=water) water=augment(adj,s,t);
	return ans;
}

bool vis[500];
bool dfs(int u,int t,AdjList<int> &adj){
	vis[u]=true;
	if(u==t) return true;
	rep(i,adj[u].size()){
		Edge<int> &e=adj[u][i];
		if(!vis[e.v] && e.capa-e.flow>0 && dfs(e.v,t,adj)){
			e.flow++;
			adj[e.v][e.rev].flow--;
			return true;
		}
	}
	return false;
}

int main(){
	int n,m,q; scanf("%d%d%d",&n,&m,&q);
	AdjList<int> adj(n);
	rep(i,m){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		add_edge(adj,u,v,1);
	}

	int ans=Edmonds_Karp(adj,0,n-1);

	while(q--){
		int type,u,v; scanf("%d%d%d",&type,&u,&v); u--; v--;
		if(type==1){
			int i,i_rev;
			for(i=0;i<adj[u].size();i++) if(adj[u][i].v==v) break;
			if(i<adj[u].size()){
				i_rev=adj[u][i].rev;
				adj[u][i].capa=adj[v][i_rev].capa=1;
			}
			else add_edge(adj,u,v,1);
		}
		else{
			int i,i_rev;
			for(i=0;i<adj[u].size();i++) if(adj[u][i].v==v) break;
			i_rev=adj[u][i].rev;

			if(adj[u][i].flow<0){
				swap(u,v);
				swap(i,i_rev);
			}

			if(adj[u][i].flow==0){
				adj[u][i].capa=adj[v][i_rev].capa=0;
				adj[u][i].flow=adj[v][i_rev].flow=0;
			}
			else{
				if(ans>0){
					rep(w,n) vis[w]=false;
					dfs(n-1,0,adj);
					ans--;
				}

				if(adj[u][i].flow!=0){
					rep(w,n) vis[w]=false;
					dfs(u,v,adj);
				}
				adj[u][i].capa=adj[v][i_rev].capa=0;
				adj[u][i].flow=adj[v][i_rev].flow=0;
			}
		}
		ans+=Edmonds_Karp(adj,0,n-1);

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

	return 0;
}

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

int main(){
    bool A=1;
    while(A){
        int a,b;
        string op;
        cin >> a >> op >> b;
        if (op!="?") {
            if (op=="+") {cout << a+b << endl;}
            else if (op=="-") {cout << a-b << endl;}
            else if (op=="*") {cout << a*b << endl;}
            else {cout << a/b << endl;}
        }
        else {A=0;}
    }
}


Measured memory_bytes: 3124
import java.util.Scanner;

public class Main {

	public Main() {
		// TODO 自動生成されたコンストラクター・スタブ
	}

	public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			// 整数の入力
			int a,b;
			int result;
			a = sc.nextInt();
			b = sc.nextInt();
			sc.close();
			if(a>=13)result=b;
			else if(a>=6) result=b/2;
			else result=0;

			// 出力

			System.out.println(result);
	}
}

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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);

int main() {
    ll a, b, q;
    cin >> a >> b >> q;
    vector<ll> s(a+2), t(b+2), x(q);
    s[0] = -1*INF;
    t[0] = -1*INF;
    s[a+1] = INF;
    t[b+1] = INF;
    rep(i, a) cin >> s[i+1];
    rep(i, b) cin >> t[i+1];
    rep(i, q) cin >> x[i];

    rep(i, q) {
        vector<vector<ll>> D(2, vector<ll>(2));
        D[0][0] = *(lower_bound(ALL(s), x[i])-1);
        D[0][1] = *lower_bound(ALL(s), x[i]);
        D[1][0] = *(lower_bound(ALL(t), x[i])-1);
        D[1][1] = *lower_bound(ALL(t), x[i]);
        ll ans = INF;
        rep(k, 2) {
            rep(l, 2) {
                rep(m, 2) {
                    ll tmp;
                    tmp = my_abs(x[i]-D[k][l]) + my_abs(D[k][l]-D[1-k][m]);
                    if(ans > tmp) ans = tmp;
                }
            }
        }
        // cout << D[0][0] << ' ' << D[0][1] << endl;
        cout << ans << endl;
    }

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}



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

// using namespace std;



// const int N = 100000, MAXI = 10000;

// int getRandom(int l, int r) {
//     return l + rand() % (r - l + 1);
// }



// // Driver code to test above functions
// int main() 
// {
//     freopen("output.txt", "r", stdin);
//     freopen("input.txt", "w", stdout);
   
//     srand(time(nullptr));
   
//     int tc = 30;
//     cout << tc << "\n";
//     //int n = 2;
//     while (tc--)
//     {
//         int n = getRandom(99900, 100000);
//         cout << n << "\n";
//         int a[n+1];
//         for(int i=1;i<=n;i++)
//         {
//             if(i==1)
//                 a[1] = getRandom(2, n);
//             else if(i==n)
//                 a[n] = getRandom(1, n-1);
//             else
//             {
//                 int x = getRandom(1, i-1);
//                 int y = getRandom(i+1, n);

//                 int flag = rand()%2;

//                 if(flag==0)
//                     x = y;

//                 a[i] = x;
//             }
//             cout << a[i] << " ";
//         }
//         cout << "\n~\n";
//     }

//     return 0;
// }








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


 

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



// int main()
// {
//     freopen("input.txt","r", stdin);
//     freopen("output.txt","w", stdout);

//     ios_base::sync_with_stdio(0);
//     cin.tie(NULL);
//     cout.tie(NULL);

//     int t;
//     cin >> t;
//     while(t--)
//     {
        
//     }
   
//     return 0;
// }














//  /* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod (int)(1e9+7)
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 200005
 

// Driver code to test above functions
int32_t main()
{
   
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
 
    
    
    int n, k;
    cin >> n >> k;

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

    sort(a, a+n);
    int ans = 0;
    for(int i=0;i<k;i++)
        ans += a[i];

    cout << ans;
    
    return 0; 
}



Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main() {
  char input[20];
  int field[20][20];
  
  while(scanf("%s", input) != EOF) {
    memset(field, 0, sizeof(field));

    for(int i = 0 ; i < 9 ; i++) {
      field[0][i] = (input[i]-'0' + input[i+1]-'0') % 10;
    }
    
    for(int i = 1 ; i < 9 ; i++) {
      for(int j = 0 ; j <= 8-i ; j++) {
	if(j < 0) break;
	field[i][j] = (field[i-1][j] + field[i-1][j+1]) % 10;
      }
    }
    /*for(int i = 0 ; i < 9 ; i++) {
      for(int j = 0 ; j <= 8-i ; j++) {
      cout << field[i][j] << ' ';
	}
      cout << endl;
      }
    cout << endl;*/
    cout << field[8][0] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>

#include<cmath>
#include<iostream>
#include<fstream>

#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<sstream>
#include<stack>

using namespace std;

int main()
{
    long long int n,i,j,a,b,c,aa,bb,digit,digit1,ck=0,dk=0;
    while(scanf("%lld %lld", &a, &b)!=EOF){

    aa = a +b;
    c = aa;
    while(aa){
        aa/=10;
        ck++;
        }

    cout<<ck<<endl;
    ck=0;
    }
}



Measured memory_bytes: 3036
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
char board[10][10];
bool s[10], b[10], n1[20], n2[20];
bool f(int i, int j, int p) {
	if (p == 8) {
		for (int i = 0; i < 8; i++) {
			for (int j = 0; j < 8; j++) {
				cout << board[i][j];
			}cout << endl;
		}
		return 1;
	}
	if (i >= 8)return 0;
	if (j >= 8)return f(i + 1, 0, p);
	bool b00l = 1;
	if (s[i])b00l = 0;
	if (b[j])b00l = 0;
	if (n1[i + j])b00l = 0;
	if (n2[i - j + 7])b00l = 0;
	if (!b00l)return f(i, j + 1, p);
	else {
		s[i] = 1; b[j] = 1; n1[i + j] = 1; n2[i - j + 7] = 1;
		board[i][j] = 'Q';
		if (f(i, j + 1, p + 1))return 1;
		s[i] = 0; b[j] = 0; n1[i + j] = 0; n2[i - j + 7] = 0;
		board[i][j] = '.';
		return f(i, j + 1, p);
	}
}
signed main() {
	for (int i = 0; i < 8; i++) for (int j = 0; j < 8; j++)board[i][j] = '.';
	bool b00l = 1;
	int n; cin >> n;
	for (int p = 0; p < n; p++) {
		int i, j; cin >> i >> j;
		board[i][j] = 'Q';
		if (s[i])b00l = 0; s[i] = 1;
		if (b[j])b00l = 0; b[j] = 1;
		if (n1[i + j])b00l = 0; n1[i + j] = 1;
		if (n2[i - j + 7])b00l = 0; n2[i - j + 7] = 1;
	}
	if (!b00l) { cout << "No Answer\n"; return 0; }
	b00l = f(0, 0, n);
	if (!b00l) { cout << "No Answer\n"; return 0; }
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long LL;
const long long M=1000000007;
#define ri register int 
#define rl register long long
int n,m,i,j,q[200005],l,r,a[200005],vis[200005],ans;
bool flag=false;
int main()
{
	l=1;
	r=0;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(i=1;i<=n;)
	{
		for(j=i;j<=n&&a[j]<a[j+1];j++);
		if(j-i+1>=m)
			if(flag)
				ans--;
			else
				flag=true;
		i=j+1;
	}
	for(i=1;i<m;i++)
	{
		while(l<=r&&a[q[r]]<a[i])
			r--;
		q[++r]=i;
	}
	for(i=m;i<=n;i++)
	{
		while(l<=r&&q[l]<=i-m)
			l++;
		while(l<=r&&a[q[r]]<a[i])
			r--;
		if(l>r)
			vis[i-m]++;
		q[++r]=i;
	}
	l=1;
	r=0;
	for(i=n;i>=n-m+2;i--)
	{
		while(l<=r&&a[q[r]]>a[i])
			r--;
		q[++r]=i;
	}
	for(i=n-m+1;i>=1;i--)
	{
		while(l<=r&&q[l]>=i+m)
			l++;
		while(l<=r&&a[q[r]]>a[i])
			r--;
		if(l>r)
			vis[i]++;
		q[++r]=i;
	}
	ans+=n-m+1;
	for(i=1;i<=n;i++)
		if(vis[i]==2)
			ans--;
	cout<<ans;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int A, B, T;
	cin >> A >> B >> T;
	cout << (int)(T / A) * B << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
s, t = str(input()), str(input())
ls, lt = len(s), len(t)

dp = [[0] * (lt + 1) for _ in range(ls + 1)]
dp[0][0], dp[1][0], dp[0][1] = 0, 0, 0
for i in range(ls):
    for j in range(lt):
        dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j])
        if s[i] == t[j]:
            dp[i + 1][j + 1] = max(dp[i][j] + 1, dp[i + 1][j + 1])

ans = []
tmp_i, tmp_j, cnt = ls, lt, dp[ls][lt]
while tmp_i * tmp_j > 0:
    if dp[tmp_i][tmp_j] == dp[tmp_i - 1][tmp_j]:
        tmp_i -= 1
    elif dp[tmp_i][tmp_j] == dp[tmp_i][tmp_j - 1]:
        tmp_j -= 1
    else:
        tmp_i, tmp_j = tmp_i - 1, tmp_j - 1
        ans.append(s[tmp_i])
print(''.join(ans[::-1]))


Measured memory_bytes: 112988
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;

int main() {
	int S;
	cin >> S;
	cout << S / 3600 << ":" << (S%3600)/60 << ":" << S % 60 << endl;
	return 0;
}

Measured memory_bytes: 1168
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

dic = defaultdict(int)
ans = 0
for i in range(len(S)):
	if S[i] != S[::-1][i]:
		ans += 1
print(int(ans/2))


Measured memory_bytes: 5200
#DP1
import sys
n=int(input())
h=list(map(int,input().split()))
if n==2:
    print(abs(h[1]-h[0]))
    sys.exit()
data=[0,abs(h[1]-h[0]),abs(h[2]-h[0])]
for i in range(3,n):
    data.append(min(data[i-1]+abs(h[i]-h[i-1]),data[i-2]+abs(h[i]-h[i-2])))
print(data[-1])

Measured memory_bytes: 55616
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    long long n,m,i,k;
    cin>>n>>m;
    long long dp[n+1];
/*for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }*/
    memset(dp,-1,sizeof(dp));
    dp[0]=1;
    dp[1]=1;
    while(m--)
    {
        cin>>k;
        dp[k]=0;
    }
    for(i=2;i<=n;i++)
    {
        if(dp[i]!=0)
        {
           dp[i]=(dp[i-1]%1000000007+dp[i-2]%1000000007)%1000000007;
        }

    }
    /*for(auto i:dp)
    {
        cout<<i<< " ";
    }*/
    cout<<dp[n]<<endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
// end of Template

int h,w,c[20][20],a[300][300];
bool vis[20];
ll dist[20][20],ans;
void dijkstra(int start){
    for(int i=0;i<=9;i++)vis[i]=false;
    for(int i=0;i<=9;i++){
        dist[start][i] = INT_MAX;
    }
    dist[start][start] = 0;
    priority_queue < pii > q;
    q.push (mp (0,start) );

    while(!q.empty()){
        int node = q.top().se;
        q.pop();
        if(!vis[node]){
            vis[node] = true;
            for(int nex = 0; nex < 10 ; nex ++){
                if(dist[start][nex] > dist[start][node] + c[node][nex]){
                    dist[start][nex] = dist[start][node] + c[node][nex];
                    q.push (mp (-1 * dist[start][nex],nex) );
                }

            }
        }

    }
}
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>h>>w;
    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++){
            cin>>c[i][j];
        }
    }
    for(int i=0; i<=9; i++){
        dijkstra(i);
    }

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>a[i][j];
            if(a[i][j]>=0)ans += dist[a[i][j]][1];
        }
    }
    cout<<ans<<newl;

}


Measured memory_bytes: 512
let readIntArray () =
    stdin.ReadLine().Split(" ") |> Array.map int

let choice ok ng bool = if bool then ok else ng

readIntArray ()
|> fun [| a; b; c; d |] ->
    let x =
        Seq.initInfinite ((*) b) |> Seq.findIndex ((<=) c)

    let y =
        Seq.initInfinite ((*) d) |> Seq.findIndex ((<=) a)

    x <= y
|> choice "Yes" "No"
|> printfn "%s"


Measured memory_bytes: 29540
#include<iostream>
#include<deque>
using namespace std;
int main(){
    int q,p,d,x,j;
    cin>>q;
    deque<int> a;
    for(int i=0;i<q;i++){
        cin>>j;
        if(j==0){
            cin>>d>>x;
            if(d==0){
                a.push_front(x);
            }
            else if(d==1){
                a.push_back(x);
            }
        }
        else if(j==1){
            cin>>p;
            cout<<a.at(p)<<endl;
        }
        else if(j==2){
            cin>>d;
            if(d==0){
                a.pop_front();
            }
            else if(d==1){
                a.pop_back();
            }
        }
    }
    return 0;
}



Measured memory_bytes: 4620
a,b,c,d = map(int,input().split())

print((d-b)*"U"+(c-a)*"R"+(d-b)*"D"+(c-a+1)*"L"+(d-b+1)*"U"+(c-a+1)*"R"+"DR"+(d-b+1)*"D"+(c-a+1)*"L"+"U")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <boost/foreach.hpp>
using namespace std;
#define pi 2*asin(1.0)
#define MAX 10000000
#define MOD 1000000007
#define _GLIBCXX_DEBUG
 
vector<long> fac(MAX);
vector<long> finv(MAX);
vector<long> inv(MAX);
vector<long> Primelist;
//template functions
/////////////////////////
void Prinit(){
long PR=10000001;
vector<long> P(PR,0);
for(long i=2;i*i<PR;i++){
    if(P.at(i)==0){
        long j=i;
      j+=i;
        while(j<PR){
            P.at(j)=1;
             j+=i;         
        }
    }
}

for(long i=2;i*i<PR;i++){//Primelist.size()=446
    if(P.at(i)==0){
        Primelist.push_back(i);
    }
}
}

void Cominit(){
  fac.at(0)=fac.at(1)=1;
  finv.at(0)=finv.at(1)=1;
  inv.at(1)=1;
  for(long i=2;i<MAX;i++){
      fac.at(i)=(fac.at(i-1)*i)%MOD;
      inv.at(i)=MOD-inv.at(MOD%i)*(MOD/i)%MOD;
      finv.at(i)=finv.at(i-1)*inv.at(i)%MOD;
  }
}

long facComb(long N,long M){// nCm%
if(N<M) return 0;
if(N<0||M<0) return 0;
return fac.at(N)*(finv.at(M)*finv.at(N-M)%MOD)%MOD;
}

long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}

long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}

long GCM(long A,long B){
            long W,r;
    if(A<B){

        W=B;
        B=A;
        A=W;
    }
    while(A%B!=0){
        r=A%B;
        A=B;
        B=r;
    }
    return B;
}
long LCM(long A,long B){
    return (A*B)/GCM(A,B);
}

long upDiv(long a,long b){
  return (a+b-1)/b;
}

long strtolong(string str){
istringstream ss;
ss=istringstream(str);
long num;
ss>>num;
return num;
}

long chartolong(char ch){
long num;
num=ch-'0';
return num;
}

string longtostr(long N){
    string str;
    str=to_string(N);
    return str;
}









/////////////////////////


//Answer


int main() {
long N;
cin>>N;
vector<long> L(N);
for(long i=0;i<N;i++){
cin>>L.at(i);
}
sort(L.begin(),L.end());
long ok,ng,low,high,a,b,value,ans=0;
for(long i=0;i<N;i++){
    for(long j=i+1;j<N;j++){
         low=L.at(j)-L.at(i);
         high=L.at(j)+L.at(i);
        auto itr1=lower_bound(L.begin(),L.end(),low+1);
         a=itr1-L.begin();
        auto itr2=lower_bound(L.begin(),L.end(),high);
         b=itr2-L.begin();
         value=b-a;
        if(a<=i&&i<b){
            value--;
        }
        if(a<=j&&j<b){
            value--;
        }
        ans+=value;
    }
}

cout<<ans/3<<endl;

}





Measured memory_bytes: 237444
import java.util.*;
import java.io.*;
public class Main{
   public static void main(String [] args){
     Scanner sc=new Scanner(System.in);
     int n=sc.nextInt();
     
     int [][] arr=new int[n][3];
     for(int i=0;i<n;i++){
       arr[i][0]=sc.nextInt();
       arr[i][1]=sc.nextInt();
       arr[i][2]=sc.nextInt();
     }
     int [][] dp=new int[n+1][3];

     for(int i=1;i<=n;i++){
       
      dp[i][0]=arr[i-1][0]+Math.max(dp[i-1][1],dp[i-1][2]);//if selects a
      dp[i][1]=arr[i-1][1]+Math.max(dp[i-1][0],dp[i-1][2]);//if selects b 
      dp[i][2]=arr[i-1][2]+Math.max(dp[i-1][0],dp[i-1][1]);//if selects c

     }

     System.out.println(Math.max(dp[n][0],Math.max(dp[n][1],dp[n][2])));

    }
   }
 

Measured memory_bytes: 98396
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define inf 500000000
#define IOS ios_base::sync_with_stdio(0)
#define meM(y,a) memset(y,a,sizeof y)
#define sC(a) scanf("%d",&a)
#define alL(a) a.begin(),a.end()
#define prinT(a,sz)  cout<<a[0];for(int i=1;i<sz;i++)cout<<" "<<a[i];cout<<endl
#define ranD srand(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int>pi;
typedef pair<ll,ll>pll;
//int fx[]={0,0,1,-1};
//int fy[]={1,-1,0,0};
//int gx[]={0,0,1,1,1,-1,-1,-1};
//int gy[]={1,-1,0,1,-1,0,1,-1};
bool check(int n,int p){return (1<<p)&n;}

int main()
{
    IOS;
    int n,m;cin>>n>>m;
    priority_queue<int>q;
    for(int i=0;i<n;i++)
    {
        int a;cin>>a;
        q.push(a);
    }
    ll res=0;
    for(int i=0;i<m;i++)
    {
        int top=q.top();
        if(top==0)break;
        q.pop();
        top>>=1;
        q.push(top);
    }
    while(!q.empty())
    {
        res+=q.top();
        q.pop();
    }
    cout<<res<<endl;

}








Measured memory_bytes: 892
double x[100],y[100],t,u,a,b,s;n,i,j,k,c,z;main(m){for(;m=scanf("%d",&n),z=i=n;printf("%d\n",m))for(;!z?j=--i:scanf("%lf,%lf",x+z,y+--z);)for(;!z&&j--;)for(u=acos(hypot(a=x[j]-x[i],b=y[j]-y[i])/2),s=1,t=atan2(b,a);c=0,u<9&&s+3;s-=2)for(a=x[i]+cos(b=t+s*u),b=y[i]+sin(b),k=n;k--;)hypot(a-x[k],b-y[k])<1.1&&++c>m?m=c:0;}

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

typedef long long LL;

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

void work(){
  int n;
  scanf("%d",&n);
  printf("%d\n",360/gcd(n,360));
}

int main(){
  int T=1;
  //scanf("%d",&T);
  for (;T--;) work();
  return 0;
}

Measured memory_bytes: 3824
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long k = in.nextLong();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt() - 1;
        }

        int t[] = new int[2 * 100_000];
        Arrays.fill(t, -1);
        t[0] = 0;
        int pos = 0;
        int count = 1;
        int period = 0;
        int stepAtLoopStart = 0;
        int loopStart = 0;
        while (true) {
            int next = a[pos];
            if (t[next] != -1) {
                period = count - t[next];
                stepAtLoopStart = t[next];
                loopStart = next;
                break;
            }
            t[next] = count;
            count++;
            pos = next;
        }

        if (k < stepAtLoopStart) {
            int now = 0;
            for (int i = 0; i < k; i++) {
                now = a[now];
            }
            System.out.println(now + 1);
        } else {
            long step = k - stepAtLoopStart;
            step %= period;
            int now = loopStart;
            for (int i = 0; i < step; i++) {
                now = a[now];
            }
            System.out.println(now + 1);
        }
    }
}

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

int main() {
  string N;
  cin >> N;
  
  if(N[0] == '7') {
    cout << "Yes" << endl;
  }
  
  else if(N[1] == '7') {
    cout << "Yes" << endl;
  }
  
  else if(N[2] == '7') {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}

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

public class Main {
    public static void main(String[] args) throws Exception{

        FastReader fs = new FastReader();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        String s = fs.next();
        boolean hit = false;
        for(int i=0 ; i<3 ; i++){
            if(s.charAt(i)=='7'){
                System.out.println("Yes");
                hit = true;
                break;
            }
        }

        if(!hit)
        System.out.println("No");












        out.close();
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
    //--------------------------------------------------------
}


Measured memory_bytes: 32684
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq  priority_queue<double, std::vector<double>, std::greater<double>>

int lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

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




int main(){
    int N;
    cin >> N;
    vector<int> Q(N), P(N);
    vector<int> A(N);
    ll ans = 0;
    ll pi = 0, qu = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> P[i];
        A[i] = i + 1;
    }
    for (int i = 0; i < N;i++)
    {
        cin >> Q[i];
    }
    int i = 0;
    do
    {
        i++;
        if (A == Q)
        {
            qu = i;
        }
        if(A == P){
            pi = i;
        }
    } while (next_permutation(A.begin(), A.end()));
    cout << abs(qu - pi) << endl;
}


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

int main()
{
    int a[3][3];

    rep(i, 3) rep(j, 3) cin >> a[i][j];

    int n;
    cin >> n;

    rep(i, n)
    {
        int b;
        cin >> b;
        rep(j, 3) rep(k, 3) if (a[j][k] == b) a[j][k] = 0;
    }

    bool bingo = false;
    rep(i, 3)
    {
        int r = 0, c = 0;
        rep(j, 3)
        {
            if (a[i][j] == 0)
                c++;
            if (a[j][i] == 0)
                r++;
        }
        if (c == 3 || r == 3)
            bingo = true;
    }

    int l = 0;
    rep(i, 3) if (a[i][i] == 0) l++;
    if (l == 3)
        bingo = true;
    if (a[2][0] == 0 && a[1][1] == 0 && a[2][0] == 0)
        bingo = true;
    if (bingo)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3616
def main(argv)
  (n, m, k) = gets.chomp.split(' ').map(&:to_i)

  flag = false
  (n + 1).times do |x|
    (m + 1).times do |y|
      z = n * y + m * x - 2 * x * y
      if z == k then
        flag = true
      end
    end
  end
  puts (flag ? 'Yes' : 'No')
end

if self.to_s == 'main' then
  main(ARGV)
end

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

using namespace std;

int main() {
  double h, w;
  cin >> h >> w;
  if (h == 1 || w == 1) {
    cout << "1" << endl;
    return (0);
  }
  double ans = h / 2 * w;
  cout << (unsigned long)(ans + 0.5) << endl;
}

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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}

void No(){
	cout<<"No"<<endl;
	exit(0);
}

template<class T>
void chmax(T& a,T b){
	a=max(a,b);
}

template<class T>
void chmin(T& a,T b){
	a=min(a,b);
}

int main(){
	string s;
	cin>>s;
	string c="CODEFESTIVAL2016";
	int ans=0;
	REP(i,16)
		if(s[i]!=c[i])
			ans++;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main (void)
{
    int A, B;
    scanf("%d%d", &A, &B);
    
    int infX = 10*B;
    int supX = 10*(B+1);
    int X;
    for (X=infX; X<supX; X++) {
        if (X*8/100 == A) {
            break;
        }
    }
    if (X == supX) {
        printf("-1");
    } else {
        printf("%d", X);
    }

    return 0;
}

Measured memory_bytes: 128
N = gets.to_i
A = gets.split(" ").map(&:to_i)
counts = Array.new(N,0)
sum = 0
A.each do |a|
    counts[a - 1] += 1
end
counts.each do |c|
    if c > 1
        sum += c* (c - 1) / 2
    end
end
A.each do |a|
    if counts[a - 1] > 1
        puts sum - counts[a - 1] + 1
    else
        puts sum
    end
end

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


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

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




int main() {

	string s, t;
	cin >> s >> t;

	int ans = 0;
	REP(i, 3) {
		if (s[i] == t[i])ans++;
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
#from operator import itemgetter
#from collections import Counter
#import heapq
#N = int(input())
#N, M = map(int, input().split())
#A = list(map(lambda x: int(x)*(-1), input().split()))
#A = [int(input()) for i in range(N)]
C = [list(map(int, input().split())) for i in range(3)]

all_sum = 0
right_up = 0
right_down = 0
for c in C:
    all_sum += sum(c)
right_up += (C[0][2] + C[1][1] + C[2][0])
right_down += (C[0][0] + C[1][1] + C[2][2])

if all_sum %3 == 0 and right_up == all_sum//3 and right_down == all_sum//3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064