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

#define REP(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define REPS(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define RREP(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define RREPS(i, n) for (int i = ((int)(n)); i > 0; i--)
#define IREP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define IREPS(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVISORT(v) sort(v.begin(), v.end(), greater<int>());
#define ALL(v) v.begin(), v.end()
#define MP(n, m) make_pair(n, m);

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using ll = long long;
using ul = unsigned long;

typedef long long ll;

template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

const int mod=1e9+7;

int binary_search(VI& a, int key) {
    int left = 0, right = (int)a.size() - 1;
    while (right >= left) {
        int mid = left + (right - left) / 2;
        if (a[mid] == key) return mid;
        else if (a[mid] > key) right = mid - 1;
        else if (a[mid] < key) left = mid + 1;
    }
    return -1;
}

void printv(VI& v){
  REP(i,v.size()) cout << v[i] << " ";
  cout << endl;
}

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

	int n;
	cin>>n;

  int ans = 3*n*n;

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

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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}

int main()
{
	fast;
	int n;
	cin >> n;
	if (n < 3)
	{
		cout << 0;
		return 0;
	}
	vi a(n);
	FOR(n)
	{
		cin >> a[i];
	}
	cout << en;
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			if (a[i] == a[j])
				continue;
			for (int k = j + 1; k < n; k++)
			{
				if (a[i] == a[k] || a[j] == a[k])
					continue;
				if (a[i] + a[j] > a[k] && a[j] + a[k] > a[i] && a[k] + a[i] > a[j])
				{
					ans++;
				}
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 3644
<?php
$weekdays = [
    'SUN' => 7,
    'MON' => 6,
    'TUE' => 5,
    'WED' => 4,
    'THU' => 3,
    'FRI' => 2,
    'SAT' => 1,
];

$stdin = trim(fgets(STDIN));
echo $weekdays[$stdin].PHP_EOL;

Measured memory_bytes: 4856
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int A,B,C;
	cin>>A>>B>>C;
	int M=max({A,B,C});
	cout<<A+B+C-M<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <ctype.h>
#include <algorithm>
 
#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
const int INF = 1e9;
 
using namespace std;
 
int main() {
    stringstream result;
    while(1) {
        string str;
        int m;
        cin >> str;
        if (str == "-")
            break;
        cin >> m;
        int h = 0;
        REP(i, m) {
            cin >> h;
            str += str.substr(0, h);
            str.erase(0, h);
        }
        result << str << endl;
    }
    cout << result.str();
    return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    string s;
    cin >> s;
    cout << (s == "ABC" ? "ARC" : "ABC") << endl;
    return 0;
}


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

using namespace std;
#define ll long long int
int n;
vector<int> a;
vector<int> adj[200007];

vector<int> vv,ans;
multiset<int> s;
void dfs(int u, int p){
    s.insert(a[u]);
	int del=-1;
	auto it=s.lower_bound(a[u]);
	if(++it!=s.end()) del=*it,s.erase(it);
	ans[u]=s.size();
    for(auto v:adj[u]){
        if(v!=p){
            dfs(v,u);
        }
    }
    if(del!=-1) s.insert(del);
	s.erase(s.find(a[u]));
}

int main()
{
    cin >> n;
    a.resize(n+1);
    ans.resize(n+1);
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n-1;i++){
        int u,v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs(1,0);
    for(int i=1;i<=n;i++){
        cout << ans[i] << endl;
     }
}


Measured memory_bytes: 30100
#include <bits/stdc++.h>
#define rg register
#define us unsigned
#define ll long long
#define ui <int>
#define pi <int, int>
#define tmpl template <typename typ>
#define oprt operator
#define sp putchar(32)
#define el putchar(10)
#define flin(x) freopen(x, "r", stdin)
#define flout(x) freopen(x, "w", stdout)
#define flio(x) flin(x".in"), flout(x".out")
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define itrt iterator
using namespace std;
tmpl inline bool up(typ &x, const typ &y) { return x < y ? x = y, 1 : 0; }
tmpl inline bool dn(typ &x, const typ &y) { return y < x ? x = y, 1 : 0; }
tmpl inline bool inr(const typ &x, const typ &l, const typ &r) { return !(x < l) && !(r < x); }
namespace orh {
inline void useios() { ios_base::sync_with_stdio(false); cin.tie(0); }
inline char rc() { rg char ch; while (!isgraph(ch = getchar())); return ch; }
tmpl typ ri() {
	rg typ x = 0; rg bool neg = false; rg char ch;
	while (!inr(ch = getchar(), '0', '9')) neg |= ch == '-';
	do x = (x << 1) + (x << 3) + (ch ^ 48); while (inr(ch = getchar(), '0', '9'));
	return neg ? -x : x;
}
tmpl typ ru() {
	rg typ x = 0; rg char ch;
	while (!inr(ch = getchar(), '0', '9'));
	do x = (x << 1) + (x << 3) + (ch ^ 48); while (inr(ch = getchar(), '0', '9'));
	return x;
}
tmpl void wi(rg typ x) {
	if (x < 0) { putchar('-'); x = -x; }
	static int sta[42]; rg int top = 0; rg typ t;
	do t = x / 10, sta[top++] = x - (t << 1) - (t << 3), x = t; while (x);
	while (top) putchar(sta[--top] ^ 48);
}
tmpl void wu(rg typ x) {
	static int sta[42]; rg int top = 0; rg typ t;
	do t = x / 10, sta[top++] = x - (t << 1) - (t << 3), x = t; while (x);
	while (top) putchar(sta[--top] ^ 48);
}
}

const int maxn = 2e5 + 5;
int n, m, a[maxn];
ll sum;

signed main() {
	orh::useios();
	
	cin >> n >> m;
	if (m >= n) {
		cout << "0" << endl;
		return 0;
	}
	for (rg int i = 1; i <= n; ++i)
		cin >> a[i];
	
	sort(a + 1, a + n + 1, greater<int>());
	for (rg int i = m + 1; i <= n; ++i)
		sum += (ll)a[i];
	
	cout << sum << endl;
	
	return 0; 
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
#include <string>
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std;

int main(){
    int a,b; cin >> a >> b;
    int out =0;
    if(a > b*2){
        out = a - b*2;
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 3156
#include<stdio.h>



int main()
{
	int n ;
	int h[ 100 + 1 ] ;

	int sa[ 5 ] ;

	int w ;
	int cnt ;

	int i ;


	while( scanf( "%d" ,&n ) ,n * 1 )
	{
		for( i = w = cnt = 0 ; i <= n ; ++i )
		{
			scanf( "%d" ,&h[ i ] ) ;
		}


		sa[ 0 ] = h[ 1 ] - h[ 0 ] ;

		sa[ 1 ] = h[ n ] - h[ n - 1 ] ;

		sa[ 2 ] = h[ n / 2 ] - h[ ( n / 2 ) - 1 ] ;

		sa[ 3 ] = h[ ( n / 2 ) + 1 ] - h[ n / 2 ] ;



		if( sa[ 0 ] == sa[ 1 ] || sa[ 1 ] == sa[ 2 ] || sa[ 1 ] == sa[ 3 ] )
		{
			sa[ 4 ] = sa[ 1 ] ;
		}

		if( sa[ 0 ] == sa[ 2 ] || sa[ 0 ] == sa[ 3 ] )
		{
			sa[ 4 ] = sa[ 0 ] ;
		}



		for( i = 1 ; i <= n ; ++i )
		{
			if( h[ i ] - h[ i - 1 ] != sa[ 4 ] )
			{
				++cnt ;


				if( cnt > 1 )
				{
					w = h[ i - 1 ] ;
				}

				if( h[ i + 1 ] - h[ i ] == sa[ 4 ] )
				{
					w = h[ i - 1 ] ;
				}

				if( i == n && w < 1 )
				{
					w = h[ i ] ;
				}
			}
		}


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


	return 0 ;
}

Measured memory_bytes: 2720
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

int main(void) {
    vector<ll> cnt;
    ll n, i, tmp=0, ans=0;
    cin >> n;
    ll a[n];
    
    for(i=0; i<n; i++)
        cin >> a[i];
    sort(a, a+n);
    
    for(i=0; i<n; i++) {
        tmp=0;
        while(a[i]==a[i+1]) {
            tmp++;
            i++;
        }
        cnt.push_back(tmp);
    }
    
    for(i=0; i<cnt.size(); i++) {
        if(cnt[i]%2==0)
            ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define sii set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for(ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()
#define INF 1000000000
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
 
 
 
ll power(ll b,ll e,ll m)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
}


void solve()
{
	int d,t,s;
	cin>>d>>t>>s;
	if(t*s>=d) cout<<"Yes";
	else cout<<"No";
}


int main()
{
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
  fastio
  int tt=1;
  // cin>>tt;
  while(tt--)
  {
    solve();
    cout<<"\n";
  }
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using i64 = long long;

std::vector<std::set<int>> g;
std::vector<std::deque<int>> d;
std::vector<int> done, depth, par;

void dfs(int v, int p) {
    done[v] = 1;
    par[v] = p;
    bool l = true;
    for (auto to : g[v]) {
        if (to == p || done[to]) continue;
        l = false;
        depth[to] = depth[v] + 1;
        dfs(to, v);
    }
    if (!l) d[depth[v]].push_back(v);
}

int main() {
    int n, m;
    std::cin >> n >> m;
    g.resize(n + 1); d.resize(n + 1); depth.resize(n + 1); done.resize(n + 1); par.resize(n + 1);
    for (int i = 0; i < m; i++) {
        int u, v;
        std::cin >> u >> v;
        g[u].insert(v);
        g[v].insert(u);
    }

    if (m & 1) {
        std::cout << -1 << std::endl;
        return 0;
    }

    int r = 1;
    for (int i = 2; i <= n; i++) if (g[r].size() < g[i].size()) r = i;
    dfs(r, 0);

    int md = 0;
    while (!d[md + 1].empty()) md++;
    auto add_edge = [&](int u, int v) { std::cout << u << " " << v << std::endl; };
    for (int i = md; i >= 0; i--) {
        for (auto v : d[i]) {
            int lim = g[v].size();
            lim = lim / 2 * 2;
            std::vector<int> w(g[v].begin(), g[v].end());
            std::sort(w.begin(), w.end(), [&](int lhs, int rhs) {
                return depth[lhs] > depth[rhs];
            });
            for (int j = 0; j < lim; j++) {
                auto to = w[j];
                add_edge(v, to);
                g[v].erase(to);
                g[to].erase(v);
            }
        }
    }

    return 0;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
void debug(istringstream&){}
template <char sep=',', class Head, class... Tail>
void debug(istringstream& iss, Head&& head, Tail&&... tail)
{
  string name;
  getline(iss, name, ',');
  cerr << sep << name << "=" << head;
  debug(iss, forward<Tail>(tail)...);
}
#define DEBUG(...) \
  do{ \
    istringstream ss(#__VA_ARGS__); \
    debug<' '>(ss, __VA_ARGS__); \
    cerr<<endl; \
  }while(0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int N;
double memo[301][301][301];
double solve(int x1, int x2, int x3){
  if(memo[x1][x2][x3]) return memo[x1][x2][x3];

  double& res = memo[x1][x2][x3];
  if(x1+x2+x3 == 0) return 0;
  int x0 = N - (x1+x2+x3);

  if(x1) res += (1 + solve(x1-1, x2, x3)) * x1 * 1. / N; else res += 1. * x1 / N;
  if(x2) res += (1 + solve(x1+1, x2-1, x3)) * x2 * 1. / N; else res += 1. * x2 / N;
  if(x3) res += (1 + solve(x1, x2+1, x3-1)) * x3 * 1. / N; else res += 1. * x3 / N;
  res += x0 * 1. / N;
  res /= 1. - x0 * 1. / N;

  return res;
}

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

  cin >> N;
  VI xs(4);
  REP(i,N){
    int x;
    cin >> x;
    xs[x]++;
  }

  cout << fixed << setprecision(12) << solve(xs[1], xs[2], xs[3]) << endl;

  return 0;
}


Measured memory_bytes: 213376
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

void solve(){
    int n,m;cin >> n >> m;
    vector<bool>b(n+1,0);
    vector<int>t(n+1,0);
    for(int i = 0;i<m;i++){
        int a;string s;
        cin >> a >> s;
        if(s=="WA"&&b[a]==0) t[a]++;
        if(s=="AC") b[a] = 1;
    }
    int ans = 0;int p = 0;
    for(int i = 0;i<=n;i++){
        if(b[i]){
            ans++;
            p += t[i];
        }
    }
    cout << ans <<' '<<p;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3712
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[1010][1010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc,cd[1010][1010];
vector<int> va,vb,vc;

ll nPr(ll maxnum,ll target){
    ll value=1;
    for(int i=0;i<target;i++){
        value*=(maxnum-i);
    }
    return value;
}

ll powm(int target,int repeat){
    ll result=1;
    for(int i=0;i<repeat;i++)result*=target;
    return result;
}

vector<int> to2(int target,int digit){
    vector<int> tovec;
    for(int i=0;i<digit;i++){
        tovec.push_back(target%2);
        target=target>>1;
    }
    return tovec;
}

int main(){
    cin>>s;
    n=s.size();
    for(int i=0;i<n;i++)aa[i]=s[i]-int('0');
    m=0;
    z=0;
    for(int i=0;i<powm(2,n-1);i++){
        va=to2(i,n-1);
        z=aa[0];
        for(int i=0;i<n-1;i++){
            if(va[i]==0){
                z*=10;
                z+=aa[i+1];
            }
            else{
                m+=z;
                z=aa[i+1];
            }
        }
        m+=z;
    }
    C m E;
    
}

Measured memory_bytes: 256
import numpy as np

D = int(input())
c = np.array( list(map(int, input().split())) )
s = [[] for i in range(365)]
for i in range(D):
  s[i] = np.array( list(map(int, input().split())) )
#
last = np.array( [-1]*26 )
av = np.array( [0]*26 )
id = np.identity(4,dtype=int)

def fav(d,c):
  return( s[d] - sum( c*(d-last) ) + c*(d-last) )
#
  
v = 0
for d in range(D):
  av = fav( d, c )
  m = max(av)
  for t in range(26):
    if av[t] == m:
      last[t] = d
      v += av[t]
      print(t+1)
      break
#


Measured memory_bytes: 27160
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int N, T;
  cin >> N >> T;
  int ans = INF;
  rep(i,N) {
    int c, t;
    cin >> c >> t;
    if (t > T) continue;
    ans = min(ans, c);
  }
  if (ans == INF) {
    cout << "TLE" << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define rep(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
using namespace std;
static const LL INF = 1LL<<61LL;
typedef pair<int,int> PII;

LL N;
LL V[2016];
LL mem[3][2016][2016];

LL cal(int n,int p,int pp){
    LL res=0;
    if(mem[n][p][pp]!=0)return mem[n][p][pp];
    if(p-1==pp||p==0&&pp==N-1){
        return 0;
    }
    if(n==0){
        rep(i,N){
            int next1=i+1,next2=i-1;
            if(i+1==N)next1=0;
            if(i-1<0)next2=N-1;
            res=max(cal(2,next1,next2)+V[i],res);
        }
    }
    else if(n==2){
        LL MAX;
        LL MAX_i;
        if(V[p]<V[pp]){
            MAX=V[pp];
            MAX_i=pp-1;
            if(pp-1<0)MAX_i=N-1;
            res=max(cal(1,p,MAX_i),res);
        }
        else {
            MAX=V[p];
            MAX_i=p+1;
            if(p+1>=N)MAX_i=0;
            res=max(cal(1,MAX_i,pp),res);
        }
    }
    else if(n==1){
        int next1=p+1,next2=pp-1;
        if(p+1==N)next1=0;
        if(pp-1<0)next2=N-1;
        res=max(cal(2,next1,pp)+V[p],max(cal(2,p,next2)+V[pp],res));
    }
    return mem[n][p][pp]=res;
}


int main(){
    cin>>N;
    rep(i,N){
        cin>>V[i];
    }
    cout<<cal(0,0,0)<<endl;
}

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

using namespace std;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	int a=0,w=0,t=0,r=0;
	for(int i=0;i<n;i++){
		string s;
		cin >> s;
		if(s[0]=='A')
			a++;
		else if(s[0]=='W')
			w++;
		else if(s[0]=='T')
			t++;
		else 
			r++;
	}
	cout<<"AC x "<<a<<"\n";
	cout<<"WA x "<<w<<"\n";
	cout<<"TLE x "<<t<<"\n";
	cout<<"RE x "<<r<<"\n";
}

//AC, WA, TLE, or RE.


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

int main(){
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    cout<<min(a,b)<<" ";
    if(a+b<=n){
        cout<<0;
    }
    else{
        int ans=n-a-b;
        cout<<-ans;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,x;
string s;

int main(){
	cin>>n>>x>>s;
	ll res=0;
	if(x==2||x==5){
		for(int i=0;i<n;i++){
			int t=s[i]-'0';
			if(t%x==0) res+=i+1;
		}
	}
	else{
		int t=1,y=0;
		vl a(x);
		a[0]++;
		for(int i=n-1;i>=0;i--){
			(y+=(s[i]-'0')*t)%=x;
			a[y]++;
			(t*=10)%=x;
		}
//		for(auto i:a) cout<<i<<' ';cout<<endl;
		for(int i=0;i<x;i++) res+=a[i]*(a[i]-1)/2;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 640
import sys, re, os
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
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n, A, B, C = MAP()

l = [INT() for i in range(n)]

def dfs(cur, a, b, c):
    if cur == n:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C) - 30
        else:
            return 10 ** 9
    
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)



print(dfs(0, 0, 0, 0))

Measured memory_bytes: 5192
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int t;
  cin>>t;
  for(int i=0;i<t;i++){
    int h,w;
    cin>>h>>w;
    int k=__gcd(h,w);
    h/=k;w/=k;
    if(h==w){
      cout<<1<<" "<<0<<endl;
      continue;
    }
    if((h*w)%2){
      cout<<(h*w)/2+1<<" "<<(h*w)/2<<endl;
    }else{
      cout<<1<<" "<<1<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
using namespace std;
#define dbg(x) cerr << #x " = " << x <<endl;

const int MAXN = 1e3 + 5;
string a[MAXN];
bool cmp(string a, string b)
{
	return a < b;
}

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

Measured memory_bytes: 256
import sys
from collections import defaultdict,Counter

sys.setrecursionlimit(10**7)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    k=ii()
    s=input()
    print(s if len(s)<=k else s[:k]+"...")
    


if __name__ == "__main__":
    main()

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

public class Problem_C
{
  public static void Main(string[] args)
  {
    var nums = Console.ReadLine().Select(c => (int)Char.GetNumericValue(c)).ToArray();
    if (nums[0] + nums[1] + nums[2] + nums[3] == 7) Console.WriteLine($"{nums[0]}+{nums[1]}+{nums[2]}+{nums[3]}=7");
    else if (nums[0] + nums[1] + nums[2] - nums[3] == 7) Console.WriteLine($"{nums[0]}+{nums[1]}+{nums[2]}-{nums[3]}=7");
    else if (nums[0] + nums[1] - nums[2] + nums[3] == 7) Console.WriteLine($"{nums[0]}+{nums[1]}-{nums[2]}+{nums[3]}=7");
    else if (nums[0] + nums[1] - nums[2] - nums[3] == 7) Console.WriteLine($"{nums[0]}+{nums[1]}-{nums[2]}-{nums[3]}=7");
    else if (nums[0] - nums[1] + nums[2] + nums[3] == 7) Console.WriteLine($"{nums[0]}-{nums[1]}+{nums[2]}+{nums[3]}=7");
    else if (nums[0] - nums[1] + nums[2] - nums[3] == 7) Console.WriteLine($"{nums[0]}-{nums[1]}+{nums[2]}-{nums[3]}=7");
    else if (nums[0] - nums[1] - nums[2] + nums[3] == 7) Console.WriteLine($"{nums[0]}-{nums[1]}-{nums[2]}+{nums[3]}=7");
    else if (nums[0] - nums[1] - nums[2] - nums[3] == 7) Console.WriteLine($"{nums[0]}-{nums[1]}-{nums[2]}-{nums[3]}=7");
  }
}

Measured memory_bytes: 13396
p = input().split()
ans = []
ans.append(int(p[0]) * int(p[2]))
ans.append(int(p[0]) * int(p[3]))
ans.append(int(p[1]) * int(p[2]))
ans.append(int(p[1]) * int(p[3]))
ans = sorted(ans)
print(ans[-1])

Measured memory_bytes: 9188
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <complex>
#include <iomanip>
#include <cassert>
 
using namespace std;

typedef long long ll;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = 3e18;
  if ((b - a) % 2 == 0) {
    ans = min(ans, (b - a) / 2);
  }
  ans = min(ans, a - 1 + (b - a + 1) / 2);
  ans = min(ans, n - b + (b - a + 1) / 2);
  cout << ans << '\n';
} 


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

int sumDigit(int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

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

    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if (a <= sumDigit(i) && sumDigit(i) <= b) ans += i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> dx = {1, -1, 0, 0, 0, 0};
vector<int> dy = {0, 0, 1, -1, 0, 0};
vector<int> dz = {0, 0, 0, 0, 1, -1};
int main(){
  int A, B, C, N;
  cin >> A >> B >> C >> N;
  set<tuple<int, int, int>> st;
  for (int i = 0; i < N; i++){
    int x, y, z;
    cin >> x >> y >> z;
    st.insert(make_tuple(x, y, z));
  }
  long long ans = 2 * ((long long) A * B + (long long) B * C + (long long) C * A);
  for (auto T : st){
    int x = get<0>(T);
    int y = get<1>(T);
    int z = get<2>(T);
    for (int i = 0; i < 6; i++){
      ans++;
      int x2 = x + dx[i];
      int y2 = y + dy[i];
      int z2 = z + dz[i];
      if (x2 < 0){
        ans -= 2;
      }
      if (x2 > A - 1){
        ans -= 2;
      }
      if (y2 < 0){
        ans -= 2;
      }
      if (y2 > B - 1){
        ans -= 2;
      }
      if (z2 < 0){
        ans -= 2;
      }
      if (z2 > C - 1){
        ans -= 2;
      }
      if (st.count(make_tuple(x2, y2, z2))){
        ans--;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3228
n, m = list(map(int, input().split()))
l = [list(map(int, input().split())) for _ in range(m)]
l = sorted(l, key=lambda x: x[1])

bmax = 0
ans = 0
for a, b in l:
    if bmax > a:
        continue
    bmax = b
    ans += 1
print(ans)

Measured memory_bytes: 65456
#include <bits/stdc++.h>
#define PI acos(-1.0)
#define maxn 200010
typedef long long LL;
using namespace std;
struct node {
    LL x, y;
}s, t, p[maxn];
bool cmp1(node u, node v) { return u.y < v.y; }
bool cmp2(node u, node v) { return u.y > v.y; }
LL a[maxn];
int main() {
    scanf("%lld%lld%lld%lld", &s.x, &s.y, &t.x, &t.y);
    double ans = 1.0 * (abs(s.x-t.x)+abs(s.y-t.y)) * 100;
    LL n;
//    printf("%.15f\n", ans);

    scanf("%lld", &n);
    for (LL i = 0; i < n; ++i) scanf("%lld%lld", &p[i].x, &p[i].y);
    if (s.x == t.x) {
        LL lo = s.y, hi = t.y;
        if (lo > hi) swap(lo, hi);
        bool flag = false;
        for (LL i = 0; i < n; ++i) {
            if (p[i].x == s.x && p[i].y > lo && p[i].y < hi) { flag = true; break; }
        }
        if (flag) ans += (PI * 10 - 20);
    }
    else {
        if (s.x > t.x) swap(s, t);
        if (s.y < t.y) {
            sort(p, p + n, cmp1);
            LL i = 0, tot = 0, cnt = 0;
            vector<LL> v(n+1, 1e18);
            while (p[i].y < s.y) ++i;
            for (; i < n; ++i) {
                if (p[i].y > t.y) break;
                if (p[i].x < s.x || p[i].x > t.x) continue;
                *lower_bound(v.begin(), v.end(), p[i].x) = p[i].x;
//                while (tot > 0 && p[i].x < a[tot-1]) --tot;
//                a[tot++] = p[i].x;
//                cnt = max(cnt, tot);
            }
            cnt = lower_bound(v.begin(), v.end(), 1e18) - v.begin();
            if (cnt == min(t.y-s.y, t.x-s.x)+1) {
                --cnt;
                ans += (PI * 5 - 20) * cnt;
                ans += (PI * 10 - 20);
            }
            else ans += (PI * 5 - 20) * cnt;
        }
        else if (s.y > t.y) {
            sort(p, p + n, cmp2);
            LL i = 0, tot = 0, cnt = 0;
            vector<LL> v(n+1, 1e18);
            while (p[i].y > s.y) ++i;
            for (; i < n; ++i) {
                if (p[i].y < t.y) break;
                if (p[i].x < s.x || p[i].x > t.x) continue;
                *lower_bound(v.begin(), v.end(), p[i].x) = p[i].x;
//                while (tot > 0 && p[i].x < a[tot-1]) --tot;
//                a[tot++] = p[i].x;
//                cnt = max(cnt, tot);
            }
            cnt = lower_bound(v.begin(), v.end(), 1e18) - v.begin();
            if (cnt == min(s.y-t.y, t.x-s.x)+1) {
                --cnt;
                ans += (PI * 5 - 20) * cnt;
                ans += (PI * 10 - 20);
            }
            else ans += (PI * 5 - 20) * cnt;
        }
        else {
            bool flag = false;
            for (LL i = 0; i < n; ++i) {
                if (p[i].y == s.y && p[i].x > s.x && p[i].x < t.x) { flag = true; break; }
            }
            if (flag) ans += (PI * 10 - 20);
        }
    }
    printf("%.15f\n", ans);
    return 0;
}
/*
0 0 5 3
4
1 0
2 1
3 2
4 3
*/


Measured memory_bytes: 4992
//****** @mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define PB push_back
#define endl "\n"
#define MOD 1000000007
#define MOD2 998244353
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)


void solve() {
   string a,b;cin>>a>>b;
   int dp[a.length()+1][b.length()+1];
   memset(dp,0, sizeof(dp));
   for(int i=1;i<=a.length();i++){
       for(int j=1;j<=b.length();j++){
           if(a[i-1]==b[j-1]){
               dp[i][j]=1+dp[i-1][j-1];
           }
           dp[i][j]=max({dp[i][j],dp[i-1][j],dp[i][j-1]});
       }
   }
   deque<char> v;
   int i=a.length(),j=b.length();
   while (i>0 && j>0){
       if(a[i-1]==b[j-1]){
           v.push_front(a[i-1]);
           i--;j--;
       }else{
           if(dp[i-1][j]>dp[i][j-1]){
               i--;
           } else{
               j--;
           }
       }
   }
   for(auto x:v){
       cout<<x;
   }
}
int32_t main() {
    IOS;
    int test = 1;
//    cin >> test;
    for(int i=1;i<=test;i++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 70656
#pragma GCC optimize ("Ofast")
#include <iostream>
#include <algorithm>
using namespace std;

inline void fastin(int &num) {
    int c;
    num = 0;
    c = getchar();
    for (; (c > 47 && c < 58); c = getchar()) num = num * 10 + c - 48;
}

inline void fastout(int n) {
    int N = n, rev, count = 0;
    rev = N;
    if (N == 0) { putchar('0'); putchar('\n'); return ;}
    while ((rev % 10) == 0) { ++count; rev /= 10;}
    rev = 0;
    while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10;}
    while (rev != 0) { putchar(rev % 10 + '0'); rev /= 10;}
    while (count--) putchar('0');
}

int main(){
    int n, k; fastin(n); fastin(k);
    int h[n];
    for (int i = 0; i < n; ++i) fastin(h[i]);
    sort(h, h + n);

    int mm = 1e9 + 334;

    for (int i = 0; i < n - k + 1; ++i){
        mm = min(mm, h[k + i - 1] - h[i]);
    }
    fastout(mm);
    
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> a(H, vector<char>(W));
    rep(i, H) rep(j, W) cin >> a[i][j];
    vector<vector<int>> ng(H, vector<int>(W));
    rep(i, W) {
        int cnt = 0;
        rep(j, H) {
            if(a[j][i] == '.')
                cnt++;
        }
        if(cnt == H) {
            rep(j, H) { ng[j][i] = 1; }
        }
    }

    rep(i, H) {
        int cnt = 0;
        rep(j, W) {
            if(a[i][j] == '.')
                cnt++;
        }
        if(cnt == W) {
            rep(j, W) { ng[i][j] = 1; }
        }
    }
    rep(i, H) {
        int ok = 0;
        rep(j, W) {
            if(!ng[i][j]) {
                cout << a[i][j];
                ok = 1;
            }
        }
        if(ok)
            cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int main(){
    int h,w;
    cin >> h >> w;
    char s[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> s[i][j];
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                bool t=true;
                for(int k=0;k<4;k++){
                    int x=j+dx[k];
                    int y=i+dy[k];
                    if(0<=x&&x<w&&0<=y&&y<h&&s[y][x]=='#'){
                        t=false;
                    }
                }
                if(t){
                    puts("No");
                    return 0;
                }
            }
        }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 256
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Solve is
   A : Integer;
   B : Integer;
begin
   Get (A);
   Get (B);
   if A+B >= 10 then
      Put_Line ("error");
   else
      Put_Line (Integer'Image (A+B));
   end if;
end Solve;

Measured memory_bytes: 3684
import java.util.*;
import static java.lang.System.out;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int time = sc.nextInt();
        int h = 0;
        int m = 0;
        int s = 0;
        if(time >= 60*60) {
            h = time/(60*60);
            time -= 60*60*h;
        }
        if(time >= 60) {
            m = time/60;
            time -= 60*m;
        }
        s = time%60;

        out.println(String.format("%d:%d:%d", h, m, s));
    }
}



Measured memory_bytes: 26344
S = input()
ans1 = ans2 = 0
for i, s in enumerate(S):
    if i % 2 == 0 and s == '0':
        ans1 += 1
    if i % 2 == 1 and s == '1':
        ans1 += 1
    if i % 2 == 0 and s == '1':
        ans2 += 1
    if i % 2 == 1 and s == '0':
        ans2 += 1
print(min(ans1, ans2))


Measured memory_bytes: 3188
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	k := scanInt()
	a := scanInts(n)

	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = -1
	}
	p := 0
	cnt := 0
	tmp := 0
	for cnt != n {
		if arr[p] != -1 {
			tmp = arr[p]
			cnt -= arr[p]
			break
		}
		arr[p] = cnt
		p = a[p] - 1
		cnt++
	}

	if k <= tmp {
		for i := 0; i < n; i++ {
			if arr[i] == k {
				fmt.Fprintln(wr, i+1)
				return
			}
		}
	}

	k -= tmp
	k %= cnt
	// debug(arr, k, tmp)
	for i := 0; i < n; i++ {
		if arr[i]-tmp == k {
			fmt.Fprintln(wr, i+1)
			return
		}
	}
}


Measured memory_bytes: 6452
#include<stdio.h>
int main(){
  int c=0,i;
  char s[1002];
  char m[9][8]={
    {"',.!?   "},
    {"abcABC  "},
    {"defDEF  "},
    {"ghiGHI  "},
    {"jklJKL  "},
    {"mnoMNO  "},
    {"pqrsPQRS"},
    {"tuvTUV  "},
    {"wxyzWXYZ"}
  };
  while(scanf("%s",s)!=EOF){
    for(i=0;s[i];i++){
      if(s[i]==s[i+1])c++;
      else{
	if(s[i]=='0')while(c--)printf(" ");
	else {
	  if     (s[i]=='1'           )c%=5;
	  else if(s[i]=='7'||s[i]=='9')c%=8;
	  else                         c%=6;
	  printf("%c",m[s[i]-'0'-1][c]);
	}
	c=0;
      }
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 524
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int[] digits(int n) {
    return n.to!string.map!(c => cast(int)c - '0').array;
}

int calc(int a, int b) {
    int ans = 0;
    for (int i = a; i <= b; i++) {
        auto d = digits(i);
        auto t = d.dup;
        t.reverse();
        if (d == t) {
            ans++;
        }
    }
    return ans;
}

void main() {
    auto ab = readints;
    int a = ab[0], b = ab[1];
    writeln(calc(a, b));
}


Measured memory_bytes: 1276
#include <iostream>
using namespace std;
using Int = int64_t;
int main() {
    Int W, H, x, y;//WTF
    cin >> W >> H >> x >> y;
    cout << W * H / 2 << ((W * H) % 2 ? ".5 " : " ") << (2 * x == W && 2 * y == H) << endl;
}


Measured memory_bytes: 256
import numpy as np

s = input()
t = input()

len_s = len(s)
len_t = len(t)

ma = 0
for i in range(len_s - len_t + 1):
    ma = max(ma, np.sum(np.array(list(s[i: i + len_t])) == np.array(list(t))))

ans = len_t - ma

print(ans)

Measured memory_bytes: 27292
S=input()
n=len(S)
flag=0
S1=S[0:(n-1)//2]
S2=S[(n+2)//2:]
if S1==S1[::-1] and S2==S2[::-1] and S==S[::-1]:
    pass
else:
    flag=1
print('Yes' if flag==0 else 'No')

Measured memory_bytes: 38384
#include <iostream>
 
 
using namespace std;
 
template<class T> inline int gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
 
 
 
int main(){
 
int n;
  cin >> n;
  int a[n];
 
  for(int i=0;i<n;i++){
   cin >> a[i];
  }
    
  int l[n+1],r[n+1];
  
  l[0]=0;
  r[n]=0;
  
  for(int i=0; i<n;i++){
   l[i+1]=gcd(l[i],a[i]);
   r[n-i-1]=gcd(r[n-i],a[n-i-1]);
  }
  
 
  
  int m=0;
  for(int i=0;i<n;i++){
  m=max(m,gcd(l[i],r[i+1]));
  }
  
  
 cout << m << endl;
 
 
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cassert>
#include<iomanip>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<28)
#define PI 3.14159265358979
#define MAX 45
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long double ld;
int n,m;
ld p[MAX];
//ld area[MAX][MAX][MAX];//area[start point][last point][new point] := the area
ld dp[MAX][MAX][MAX];//dp[start point][last point][the number] := maximum area

inline
double getArea(int i,int j)
{
  assert(i < n && j < n);
  return sin((p[j]-p[i])*2*PI)/2.0;//S = (b*c*sinA)/2,in this case, b = c = 1
}


int main()
{
  while(cin >> n >> m,n|m)
    {
      rep(i,n)cin >> p[i];

      //init_area();

      rep(i,MAX)rep(j,MAX)rep(k,MAX)dp[i][j][k] = -inf;
      rep(i,MAX)rep(j,MAX)dp[i][j][2] = 0;
      ld ans = -inf;
      rep(sp,n)
	{
	  REP(cnt,2,m)
	    {
	      REP(lp,sp+1,n)
		{
		  REP(np,lp+1,n)
		    {
		      if(dp[sp][lp][cnt] == -inf)continue;

		      dp[sp][np][cnt+1] = max(dp[sp][np][cnt+1],
					      dp[sp][lp][cnt]+getArea(sp,lp)+getArea(lp,np)+getArea(np,sp));
	
		     
		      if(cnt+1 <= m)
			ans = max(ans,dp[sp][np][cnt+1]);  
		    }
		}
	    }
	}

      cout << setiosflags(ios::fixed) << setprecision(6) << ans << endl;

    }
  return 0;
}

Measured memory_bytes: 2728
package main

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

func main() {
	a := getInt()
	b := getInt()
	c := getInt()

	if b-a == c-b {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}

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

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N = int(input())
aa = inpl()

ans = 0
for i in range(N):
	if i == aa[aa[i]-1]-1:
		ans += 1

print(ans//2)


Measured memory_bytes: 15600
# -*- coding: utf-8 -*-
import math
n, d = map(int, input().split())
x = [[]]*n
for i in range(n):
    x[i] = list(map(int, input().split()))

count = 0
for i in range(n):
    for j in range(i+1, n):
        sq_dist = 0
        for k in range(d):
            sq_dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k])
        dist = math.sqrt(sq_dist)
        if dist.is_integer():
            count += 1
print(count)


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

using namespace std;
using ll = long long;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    string S;
    cin >> S;
    if(S[2]==S[3] && S[4]==S[5]) _PR("Yes");
    else _PR("No");

    return 0;
}

/*



*/

Measured memory_bytes: 256
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    X = int(input())
    if X >= 30:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    solve()

Measured memory_bytes: 72784
N = gets.to_i
es = {}
(N-1).times{
  a,b = gets.split.map &:to_i
  es[a] ||= {}; es[b] ||= {}
  es[a][b] = es[b][a] = 1
}
ranges = Array.new(N+1,nil)
parities = Array.new(N+1,nil)
K = gets.to_i
K.times {
  v,q = gets.split.map &:to_i
  ranges[v] = [q,q]
  parities[v] = q%2
}

queue = [[1,0]]
while queue.size > 0 do
  n,s = queue.pop
  case s
  when 0
    queue << [n,1]
    ks = es[n]
    ks.each{ |m,_|
      es[m].delete(n)
      queue << [m,0]
    }
  when 1
    r = ranges[n]
    q = parities[n]
    rs = es[n].keys.map{ |m| ranges[m] }.compact.map{ |a,b| [a-1,b+1] }
    qs = es[n].keys.map{ |m| parities[m] }.compact.map{ |q| q ^ 1 }
    if r && q
      rs << r
      qs << q
    end
    if qs.uniq.size > 1
      puts "No"; exit 
    end
    next if qs.size == 0 # rs.size == 0
    rmin = rs.map{ |a,b| a }.max
    rmax = rs.map{ |a,b| b }.min
    if rmax < rmin
      puts "No"; exit
    end
    ranges[n] = [rmin, rmax]
    parities[n] = qs[0]
  end
end

puts "Yes"
numbers = Array.new(N+1, nil)
queue = [[1,nil]]
INF = 10**9
while queue.size > 0 do
  n,w = queue.pop
  vs = []
  if w
    vs << w-1
    vs << w+1
  end
  range = ranges[n]
  if range
    vs << range[0]
  end
  v = range ? vs.find{ |v| range[0] <= v && v <= range[1] } : vs[0]
  numbers[n] = v
  es[n].each{ |m,_|
    queue << [m,v]
  }
end

puts numbers[1..-1]


Measured memory_bytes: 68848