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

#define TASKNAME ""

using namespace std;

const int INF = 1e9 + 7;
const int MAXN = 1e6 + 7;
const double EPS = 1e-8;

int main() {
    #ifdef MY
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #else
        //freopen(TASKNAME".in", "r", stdin);
        //freopen(TASKNAME".out", "w", stdout);
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // MY
    ll n;
    cin >> n;
    if (n == 1) {
        cout << "Yes\n";
        cout << "2\n";
        cout << "1 1\n1 1\n";
        return 0;
    }
    for (ll i = 2; i < n; i++) {
        if (i * (i + 1) == 2 * n) {
            cout << "Yes\n";
            cout << i + 1 << "\n";
            vector <vector <ll> > res;
            ll now = 1;
            for (ll j = 0; j <= i; j++) {
                cout << i << " ";
                res.push_back({});
                for (ll k = 0; k < j; k++) {
                    res.back().push_back(res[k][j - 1]);
                }
                while (res.back().size() != i) {
                    res.back().push_back(now++);
                }
                for (ll x : res.back()) {
                    cout << x << " ";
                }
                cout << "\n";
            }
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}


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

using namespace std;

#define ll long long

int main()
{
	ll K;
	cin >> K;

	queue < ll > que;
	for (int i = 1; i <= 9; i++) {
		que.push(i);
	}

	ll index = 0;
	ll nb = 0;

	while (index < K) {
		index++;
		nb = que.front();
		que.pop();
		ll mod10 = nb % 10;
		if (mod10 != 0) {
			que.push(10 * nb + mod10 - 1);
		}
		que.push(10 * nb + mod10);
		if (mod10 != 9) {
			que.push(10 * nb + mod10 + 1);
		}
	}

	cout << nb << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) 
    	cout << "Yes" << endl;
    else cout << "No" << endl;
	return 0;
} 

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

#define X first
#define Y second

const int MaxN = 2e5 + 10;
int n, m, l[MaxN], r[MaxN], d[MaxN];
int val[MaxN], par[MaxN];
bool vis[MaxN];
vector <pair<int, int>> e[MaxN];
queue <int> q;

int f(int x) {
    if (x != par[x]) par[x] = f(par[x]);
    return par[x];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	for (int i = 0; i < n; i++) par[i] = i;
	for (int i = 0; i < m; i++) {
	    cin >> l[i] >> r[i] >> d[i];
	    e[--l[i]].push_back({--r[i], d[i]});
	    e[r[i]].push_back({l[i], -d[i]});
	    if (f(l[i]) != f(r[i])) {
	        par[par[l[i]]] = par[r[i]];
	    }
	}
	for (int i = 0; i < n; i++) {
	    if (par[i] != i) continue;
	    vis[i] = true;
	    q.push(i);
	    while (q.size()) {
	        int x = q.front();
	        q.pop();
	        for (auto y : e[x]) {
	            if (vis[y.X] && val[y.X] != val[x] + y.Y) {
	                cout << "No";
	                return 0;
	            }
	            if (!vis[y.X]) {
	                vis[y.X] = true;
	                val[y.X] = val[x] + y.Y;
	                q.push(y.X);
	            }
	        }
	    }
	}
	cout << "Yes";
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (ll i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll N,ans;	cin>>N;
	ll s[12][12];
 	 FOR(i,0,10){
    	FOR(j,0,10){
          s[i][j]=0;
        }
    }
	FOR(i,0,N+1){
		string str=to_string(i);
      	int num1 = str[0]-'0';
      	int num2 = i%10;
		s[num1][num2]++;
      
	}
  
	FOR(i,1,10){
		FOR(j,i,10){
			if(i==j)	ans+=s[i][i]*s[i][i];
			else ans+=s[i][j]*s[j][i]*2;
		}
	}
	cout<<ans<<endl;
    

    return 0;
}




Measured memory_bytes: 256
//Author: kaiyu
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <iomanip>
using namespace std;
typedef long long ll;
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<int,int>
#define endl "\n"
#define tt ll tc;cin >> tc;while(tc--)
#define int3(x,y,z) ll x,y,z;cin >> x >> y >> z;
#define int2(x,y) ll x,y;cin >> x >>y;
#define int1(x) ll x;cin>>x;
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
bool cm(pair<string,int>p1,pair<string,int>p2) {
    return p1.ss > p2.ss;
}
#define int long long

int par[100005],n,m;

int find(int a) {
    if(par[a] < 0) {
        return a;
    }
    else return par[a] = find((par[a]));
}

void xunion(int a, int b) {

    par[a] = min(par[a],par[b]);
    par[b] = a;
}
int32_t main() {
    int1(n)
    vector<vi>kk(n+1);
    for (int i = 2; i <=n; ++i) {
        int x;
        cin >> x;
        kk[x].pb(i);

    }
    for (int j = 1; j <=n ; ++j) {
        cout << kk[j].size() << endl;
    }
        return 0;
}




Measured memory_bytes: 13984
#include <stdio.h>
#include<stdlib.h>
int main()
{
    long long a ,i,sum;
    while(scanf("%lld",&a)!=EOF)
   {
    sum=1;
    for (i=1;i<=a;i++)
    {
        sum=(sum*i);
    }
    printf("%lld\n",sum); 
    }
    return 0;
}

Measured memory_bytes: 596
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String s1 = s.substring(0, (s.length() - 1) / 2);
		String s2 = s.substring(((s.length() + 3) / 2) - 1, s.length());
		if (s.equals(new StringBuffer(s).reverse().toString()) && s1.equals(new StringBuffer(s1).reverse().toString())
				&& s2.equals(new StringBuffer(s2).reverse().toString())) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21716
def main():
	N = int(input())
	S = list(input())
	R = []
	G = []
	B = []
	cnt = 0
	for i in range(len(S)):
		if S[i] == "R":
			R.append(i)
		elif S[i] == "G":
			G.append(i)
		elif S[i] == "B":
			B.append(i)
	l = len(B)
	for i in range(len(R)):
		r = R[i]
		for j in range(len(G)):
			g = G[j]
			cnt += l
			if g > r:
				M = g
				m = r
			elif r > g:
				M = r
				m = g
			d = M - m
			if (M + d) < N and S[M + d] == "B":
				cnt -= 1
			if (m - d) >= 0 and S[m - d] == "B":
				cnt -= 1
			if (M + m) % 2 == 0 and S[int((M + m) / 2)] == "B":
				cnt -= 1
	print(cnt)

main()

Measured memory_bytes: 9200
# -*- coding: utf-8 -*-
A, B = map(int, input().split(' '))

if A == 0 or B == 0:
    print('Zero')

elif A <= 0 and 0 <= B:
    print('Zero')

elif A > 0 and B > 0:
    print('Positive')

else: #A < 0 and B < 0:
    n = (B - A + 1)
    if n % 2 == 0:
        print('Positive')
    else:
        print('Negative')




Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  ll k;
  cin >> s >> k;
  REP(i,k){
    if(s[i]!='1'){
      cout << s[i] << endl;
      return 0;
    }
  }
  cout << 1 << endl; 
  return 0;
}

Measured memory_bytes: 256
from fractions import gcd


A, B, C, D = map(int, input().split())
lcm = C * D // gcd(C, D)
print(
    B - B//C - B//D + B//lcm
    - ((A-1) - (A-1)//C - (A-1)//D + (A-1)//lcm)
)

Measured memory_bytes: 5048
/*
      author : nishi5451
      created: 11.08.2020 20:57:56
*/

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


int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << max(max(a,b),c)*10 + a + b + c - max(max(a,b),c) << endl;
    return 0;
}


Measured memory_bytes: 3604
object Main {
  import java.io.PrintStream

  def main(args: Array[String]): Unit = {
    val s = new Main()
    val ps = new PrintStream(Console.out)
    Console.withOut(ps) {
      s.solve()
    }
    ps.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag
  import scala.Console

  val MOD = 1000000007

  def solve(): Unit = {
    val N = ni()
    val P = na(N, -1)
    val R = Array.ofDim[Int](N)
    rep(N) { i =>
      R(P(i)) = i
   }

    var cnt = 0
    var mx = 0
    rep(N - 1) { i =>
      if (R(i + 1) > R(i)) {
        cnt += 1
        mx = max(cnt, mx)
      } else {
        cnt = 0
      }
    }

    println(N - mx - 1)
  }


  class InputReader(reader: BufferedReader) {
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(Console.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    rep(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    rep(n) { i =>
      rep(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    rep(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Int](as.length + 1)
    rep(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

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

int main(){
    int n,d;
    cin>>n>>d;
    vector<vector<int>> x(n,vector<int>(d));
    rep(i,n) rep(j,d) cin>>x[i][j];

    int ans=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            int num=0;
            double dist=0;
            for(int k=0;k<d;k++){
                num+=pow(x[i][k]-x[j][k],2);
            }
            dist=sqrt(num);
            if(ceil(dist)==floor(dist)) ans++;
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3732
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 300004
#define INF 1e16

using namespace std;

ll n,m,ar[N];
ll seg[4*N][2];
ll lazy[4*N][2];

void relax(ll low,ll high,ll pos,ll id)
{
    if(lazy[pos][id] != 0)
    {
        seg[pos][id] += lazy[pos][id];

        if(low != high)
        {
            lazy[pos*2+1][id] += lazy[pos][id];
            lazy[pos*2+2][id] += lazy[pos][id];
        }

        lazy[pos][id]=0;
    }

    return;
}

void update(ll low,ll high,ll pos,ll slow,ll shigh,ll val,ll id)
{
    relax(low,high,pos,id);
    if(slow > shigh)
        return;

    if(low >= slow && high <= shigh)
    {
        seg[pos][id] += val;

        if(low != high)
        {
            lazy[pos*2+1][id] += val;
            lazy[pos*2+2][id] += val;
        }

        return;
    }
    if(low > shigh || high < slow)
        return;

    ll mid = (low+high)/2;

    update(low,mid,pos*2+1,slow,shigh,val,id);
    update(mid+1,high,pos*2+2,slow,shigh,val,id);

    return;
}

ll getval(ll low,ll high,ll pos,ll slow)
{
    relax(low,high,pos,0);
    relax(low,high,pos,1);

    if(low == high && low == slow)
    {
        return seg[pos][0] + seg[pos][1]*slow;
    }
    if(low > slow || high < slow)
        return 0;

    ll mid = (low+high)/2;

    return getval(low,mid,pos*2+1,slow)+getval(mid+1,high,pos*2+2,slow);
}

int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n >> m;

    rep(i,0,n)
        cin >> ar[i];

    rep(i,0,n-1)
    {
        ll arxi = ar[i];
        ll telos = ar[i+1];

        if(ar[i] == ar[i+1])
            continue;
        else if(ar[i] < ar[i+1])
        {
            update(0,m,0,1,ar[i],ar[i+1]-ar[i],0);
            update(0,m,0,ar[i+1]+1,m,ar[i+1]-ar[i],0);

            update(0,m,0,ar[i]+1,ar[i+1],-1,1);
            update(0,m,0,ar[i]+1,ar[i+1],ar[i+1]+1,0);
        }
        else
        {
            update(0,m,0,1,ar[i+1],-1,1);
            update(0,m,0,1,ar[i+1],ar[i+1]+1,0);

            update(0,m,0,ar[i]+1,m,-1,1);
            update(0,m,0,ar[i]+1,m,m+ar[i+1]+1,0);

            update(0,m,0,ar[i+1]+1,ar[i],m-ar[i]+ar[i+1],0);
        }
    }

    ll ans = INF;

    rep(i,1,m+1)
    {
        ll res = getval(0,m,0,i);

//        cout << i << "  " << res << endl;
        ans = min(ans,res);
    }

    cout << ans;

    return 0;
}



Measured memory_bytes: 14592
import bisect

x = int(input())

s = {1}
for a in range(2, 1000):
    for b in range(2, 11):
        c = a ** b
        if c > 1000:
            break
        s.add(c)
s = sorted(s, reverse=True)
for a in s:
    if a <= x:
        print(a)
        exit(0)


Measured memory_bytes: 9052
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
using namespace std;

struct StronglyConnectedComponents {
    int id = 0;
    vector<vector<int>> gg, rg;
    vector<int> comp, order, seen, depth;
    StronglyConnectedComponents(int n) : \
        gg(n), rg(n), comp(n, -1), seen(n, 0), depth(n, 1) { }
    void add_edge(int x, int y) {
        gg[x].emplace_back(y);
        rg[y].emplace_back(x);
    }
    void dfs(int u) {               // order, seen
        seen[u] = true;
        for (int v: gg[u]) if (!seen[v]) dfs(v);
        order.emplace_back(u);
    }
    void rdfs(int u, int _id) {     // comp, depth
        comp[u] = _id;
        for (int v: rg[u]) {
            if (comp[v] == -1) rdfs(v, _id);
            depth[u] = max(depth[u], depth[v] + 1);
        }
    }
    int build() {
        for (int u = 0; u < (int)gg.size(); ++u) if (!seen[u]) dfs(u);
        reverse(begin(order), end(order));
        for (int u: order) if (comp[u] == -1) rdfs(u, id++);
        return id;                  // id < n -> has_cycle
    }
    vector<vector<int>> make_graph() {
        vector<vector<int>> g_comp(id);
        set<pair<int, int>> connect;
        for (int u = 0; u < (int)gg.size(); ++u) for (int v: gg[u]) {
            int x = comp[u], y = comp[v];
            if (x == y) continue;
            if (connect.count({x, y})) continue;
            g_comp[x].emplace_back(y);
            connect.emplace(x, y);
        }
        return g_comp;
    }
    int operator[](int k) { return comp[k]; }
};

template<typename T>
struct Arborescence {
    const T INF = numeric_limits<T>::max();
    using Graph = vector<vector<pair<int, T>>>;
    Graph g;
    Arborescence(int n) : g(n) { };
    void add_edge(int u, int v, T w) { g[u].emplace_back(v, w); }
    T build(Graph &g, int r, T sum) {
        int n = g.size();
        vector<int> par(n, -1);
        vector<T> w_in(n, INF);
        for (int u = 0; u < n; u++) for (auto &e: g[u]) {
            if (w_in[e.first] > e.second) {
                w_in[e.first] = e.second, par[e.first] = u;
            }
        }
        StronglyConnectedComponents scc(n);
        for (int u = 0; u < n; u++) if (r != u) {
            if (par[u] == -1) return INF;
            scc.add_edge(par[u], u), sum += w_in[u];
        }
        int sz = scc.build();
        if (sz == n) return sum;    // no cycle
        Graph g_comp(sz);
        for (int u = 0; u < n; u++) for (auto &e: g[u]) {
            if (scc[u] == scc[e.first]) continue;
            g_comp[scc[u]].emplace_back(scc[e.first], e.second - w_in[e.first]);
        }
        return build(g_comp, scc[r], sum);
    }
    T build(int r) {
        T res = build(g, r, 0);
        return res == INF ? -1 : res;
    }
};

int main() {
    int n, m; cin >> n >> m;
    int r; cin >> r;
    Arborescence<long long> mst(n);
    while (m--) {
        int u, v, w; cin >> u >> v >> w;
        mst.add_edge(u, v, w);
    }
    cout << mst.build(r) << endl;
    return 0;
}



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

int sosu[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199};

int jousu[210];

void clearjo(){
	for(int i=0;i<=210;i++)jousu[i]=0;
}

void setj(int n)
{
	int index=0;
	for(;;)
	{
		if(n%sosu[index]==0)
		{
			n/=sosu[index];
			jousu[sosu[index]]++;
			//cout << n << endl;
		}
		else index++;
		
		if(n==1)break;
	}
}

int main()
{
	int ans=0,tmp;
	int n;
	cin >> n;
	
	for(int i=1;i<=n;i+=2)
	{
		setj(i);
		tmp=1;
		for(int j=0;j<sizeof(sosu)/sizeof(int);j++)
		{
			tmp*=(jousu[sosu[j]]+1);
			if(tmp>8)break;
		}
		if(tmp==8)ans++;
		//cout << i << ":" << tmp << endl;
		clearjo();
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;            //

int main(void)
{
    int A, B;
    cin >> A >> B;

    if (A + B >= 10)
    {
        cout << "error" << endl;
    }
    else
    {
        cout << A + B << endl;
    }

    return (0);
}

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

string s;
ll cnt=0;
ll a=0,b=0,c=0;
ll as=0,bs=0,cs=0;

int main(){
  cin>>s;
  for(int i=0;i<(int)s.size();i++){
    if(s[i]=='.')cnt=0;
    if(s[i]=='.'||s[i]=='('||s[i]==')')continue;
    a=a*10+(s[i]-'0');
    as++;
    cnt++;
  }
  c=a;
  cs=as;
  for(int i=0;i<(int)s.size();i++){
    if(s[i]=='(')b=0,bs=0;
    if(s[i]=='.'||s[i]=='('||s[i]==')')continue;
    b=b*10+(s[i]-'0');
    bs++;
  }

  if( (int)s.find('.') == -1 ){
    cout<<s<<"/1"<<endl;
    return 0;
  }
  
  if( (int)s.find('(') != -1 ){
    
    
    for(int i=0;i<bs;i++){
      a*=10;
      as++;
    }
    a+=b;


    ll A=1,C=1;
    as=cnt+bs;
    cs=cnt;
    for(int i=0;i<as;i++)A*=10;
    for(int i=0;i<cs;i++)C*=10;
    //    cout<<a<<' '<<c<<endl;
    //    cout<<as<<' '<<cs<<endl;
    //    cout<<A<<' '<<C<<endl;
    ll X=a-c,Y=A-C,Z=__gcd(X,Y);
    cout<<X/Z<<'/'<<Y/Z<<endl;
  }else{
    ll X=a;
    ll Y=1;
    for(int i=0;i<cnt;i++)Y*=10;

    ll Z=__gcd(X,Y);
    cout<<X/Z<<'/'<<Y/Z<<endl;
  }
  return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

/*template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
*/
int main(){
   int n,k;cin>>n>>k;
   string s;cin>>s;
   
    int l=0,r=0;
    char temp = 'a';
    int ans=0;
    
    for(int i=0;i<n;i++){
    	if(s[i]=='L'&&temp!=s[i]){
    		l++;
		}
		if(s[i]=='R'&&temp!=s[i]){
    		r++;
		}
		
		temp=s[i];
		
		if(min(r,l)>k){
			ans=i-1;
			
			for(int j=i+1;j<n;j++){
				if(s[j]==s[j-1]){
					ans++;
				}
			}
		    cout<<ans<<endl;return 0;
		}
	}
	
	cout<<n-1<<endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;
#define F first
#define S second
#define RE register
#define random(x) (rand()%x)
#define LOG(a,b) (log(a)/log(b))
#define N 200005
#define mod 998244353
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3fll
int n;
ll d,a[N],ans=0,dpl[N],dpr[N];
int main(){
	scanf("%d%lld",&n,&d);
	for(int i=1;i<=n;++i){
		scanf("%lld",a+i);
		ans+=a[i];
	}
	ans+=d*(n-1);
	dpl[1]=a[1];
	for(int i=2;i<=n;++i) dpl[i]=min(dpl[i-1]+d,a[i]);
	dpr[n]=a[n];
	for(int i=n-1;i;--i) dpr[i]=min(dpr[i+1]+d,a[i]);
	for(int i=2;i<n;++i) ans+=min(dpl[i],dpr[i]);
	printf("%lld\n",ans);
	return 0;
}

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

#define SORT(v) sort(v.begin(),v.end())
#define si(n) scanf("%d",&n)
#define sii(n,m) scanf("%d %d",&n,&m)
#define sl(n) scanf("%lld",&n)
#define sll(n,m) scanf("%lld %lld",&n,&m)
#define ss(cad) scanf("%s",cad)
#define PB push_back
#define fst first
#define scn second
#define DBG(x) cerr << #x << " = " << (x) << endl; 
#define M 1000000007
#define N_MAX 100010

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vp;

char cad[100];

int main()
{
	int n;
	si(n);
	map<string, int> mapa;
	int maxi = -1;
	for(int i = 0; i < n; i++)
	{
		ss(cad);
		maxi = max(maxi, ++mapa[string(cad)]);
	}

	for(const auto p: mapa)
	{
		if(p.scn == maxi)
			printf("%s\n",p.fst.c_str());
	}
    return 0;
}


Measured memory_bytes: 23808
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

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

  int32_t N, R;
  int32_t res;
  //string N;
  cin >> N >> R;
  if (N > 10) {
    res = R;
  } else {
    //R = res - 100 * (10 - N);
    res = R + 100 * (10 - N);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))

# マイナスの数が偶数ならば、絶対値を取って和を出力する。
# マイナスの数が奇数ならば、絶対値を取った和から絶対値が一番小さいもの*2を引く。
abs_min = 10**9
flag = False
if A.count(0) >= 1:
  flag = True
neg_count = 0
ans = 0
for a in A:
  ans += abs(a)
  if a < 0:
    neg_count += 1
  if abs(a) < abs_min:
      abs_min = abs(a)
if neg_count %2 == 0:
  flag = True

if flag:
  print(ans)
else:
  print(ans - 2 * abs_min)

Measured memory_bytes: 19972
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

vector<vector<pair<Int,Int>>> graph;
vector<Int> color;

void dfs(Int v, Int col, Int dis) {
	color[v] = col;

	Int temp;
	for (auto next_v:graph[v]) {
		if (color[next_v.first] != -1)continue;
		else {
			temp = next_v.second;
			if (temp % 2) {
				dfs(next_v.first, 1 - col, temp);
			}
			else {
				dfs(next_v.first, col, temp);
			}
		}
	}

}

int main() {

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

	Int N;
	cin >> N;

	graph.resize(N,vector<pair<Int,Int>>());
	Int a, b, c;
	for (Int i = 0; i < N-1; i++) {
		cin >> a >> b >> c;
		graph[a - 1].push_back(make_pair(b - 1,c));
		graph[b - 1].push_back(make_pair(a - 1,c));
	}

	color.resize(N,-1);//-1未読、0白、1黒
	dfs(0, 0, 0);

    for (Int i = 0; i < N; i++) {
		printf("%lld\n", color[i]);
    }
}

Measured memory_bytes: 9984
#include <stdio.h>
int main(void)
{
	int a, b, c, x, i;
	scanf("%d %d %d", &a, &b, &c);

	for (x = a; x <= b; x++) {
		if (c%x == 0) {
			i = i + 1;
		}
	}
	printf("%d\n", i);

	return 0;
}


Measured memory_bytes: 2104
#!usr/bim/python
#! -*- coding: utf-8 -*-

n = raw_input()
n = int(n)

t = []

for i in range(n):
    temp = raw_input()
    temp = int(temp)
    t.append(temp)

def gcd(a,b):
    r = a % b
    while not r == 0:
        a = b
        b = r
        r = a % b
    return(b)

x = 1
for i in range(n):
    y = t[i]
    gcdxy = gcd(x,y)
    lcm = x*y/gcdxy
    x = lcm

print x


Measured memory_bytes: 2568
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int cnt[100005];
int main(){
    int n,m;
    cin >> n>> m;
    rep(i,m){
        int a,b;
        cin >> a>> b;
        a--;b--;
        cnt[a]=1-cnt[a];
        cnt[b]=1-cnt[b];
    }
    int ok=1;
    rep(i,n){
        if(cnt[i]==1){
            ok=0;
        }
    }
    if(ok==1){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 4024
package main

import (
  "fmt"
)

func absInt(x int) int {if x >= 0 {return x}; return -x}

func main() {
  var a, b, c, d int
  fmt.Scan(&a, &b, &c, &d)
  ans := "No"
  if absInt(c - a) <= d || (absInt(a - b) <= d && absInt(c - b) <= d) {
    ans = "Yes"
  }
  fmt.Println(ans)
  
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
#define int long long
signed main(){
  int X;
  cin >> X;
  int now = 100;
  int ans = 0;
  while(now < X){
    now *= 1.01;
    ans++;
  }
  cout << ans;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        if (N%2 == 0) {
            System.out.println(N/2);
        } else {
            System.out.println(N/2+1);
        }
    }
}

Measured memory_bytes: 21716
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

int read()
{
	int x = 0, f = 1; char c = getchar();
	while(!isdigit(c)) { if(c == '-') f = 0; c = getchar(); }
	while(isdigit(c)) { x = (x << 3) + (x << 1) + (c ^ 48); c = getchar(); }
	return f ? x : -x;
}

typedef long long LL;
const int maxn = 60, mod = 1e9 + 7;
int inv[maxn], fac[maxn], ifac[maxn], f[maxn][maxn];

int C(int N, int M) { return (LL)fac[N] * ifac[M] % mod * ifac[N - M] % mod; }

int main()
{
	int n = read();

	inv[0] = inv[1] = fac[0] = fac[1] = ifac[0] = ifac[1] = 1;
	for(int i = 2; i <= n; ++i)
	{
		fac[i] = (LL)fac[i - 1] * i % mod;
		inv[i] = (LL)(mod - mod / i) * inv[mod % i] % mod;
		ifac[i] = (LL)ifac[i - 1] * inv[i] % mod;
	}

	f[1][0] = f[1][1] = 1;
	for(int i = 1; i < n; ++i)
		for(int j = 0; j <= i; ++j) if(f[i][j])
			for(int x = 0; x + i <= n; ++x)
				for(int y = 0; y + x + i <= n; ++y)
					if((x + y) && (x + y >= j) && (!((x + y - j) & 1)))
						(f[i + x + y][abs((x + y - j) / 2 + j - x)] += (LL)f[i][j] * C(i + x + y, x + y) % mod * C(x + y, x) % mod) %= mod;

	cout << f[n][0] << endl;

	return 0;
}

Measured memory_bytes: 256
N, A, B, C, D = map(int, input().split())
S = input()

from sys import exit

# check
goal = max(C, D)
if "##" in S[A-1:goal]:
    print("No")
    exit()

if C < D:
    # Bから先に動く
    print("Yes")

else:
    # 入れ替わる必要がある

    # cehck : 初期値で入れ替えられる
    # if "..." in S[B-2:D]:
    if ('...' in S[B-1:D]) or ('...' in S[B-2:B+1]) or ('...' in S[D-2:D+1]):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define endl        "\n"

const int mod = 1e9+7;

inline int add(int a, int b) { int res = a + b; if(res >= mod) res -= mod;  return res; }
inline int sub(int a, int b) { int res = a - b; if(res < 0) res += mod; return res;}
inline int mul(int a, int b) { return (a * b)%mod; }


void solve() {
    int n, k, c;    cin >> n >> k >> c;
    string s; cin >> s;
    int mark[n];  memset(mark, 0, sizeof mark);
    int cur = k;
    for(int i=n-1; i>=0; i--) {
        if(s[i]=='o') {
            mark[i] = cur;
            cur--;
            i -= c;
        }
    }
    cur = 1;
    for(int i=0; i<n; i++) {
        if(s[i]=='o') {
            if(mark[i] == cur) {
                cout << i+1 << endl;
            }
            cur++;
            i += c;
        }
    }
}

signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);

    int T = 1;
    //cin >> T;

    while(T--) {
        solve();
    }
    return 0;
}

/*
Find the earliest and latest day of the i-th working day. If for some i they are the same, this is a day bound to work.
You can greedily iterate the days to find the earliest days. Also, reversely iterating the days gives the latest days
*/


Measured memory_bytes: 3348
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define ff first
#define ss second
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
#define pi 3.1415926535

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int h, w, k;
	cin >> h >> w >> k;
	int arr[h + 1][w + 1];
	for (int i = 1; i <= h; i++)
	{
		for (int j = 1; j <= w; j++)
		{
			char c;
			cin >> c;
			if (c == '.')
				arr[i][j] = 0;
			else
				arr[i][j] = 1;
		}
	} int nas = 0;
	for (int o = 0;   o < (1 << h); o++)
	{
		vector<int >v;
		for (int i = 0; i < h; i++)
		{
			if (((1 << i) & o ) != 0)
				v.pb(i + 1);
		}
		for (int p = 0; p < (1 << w); p++)
		{
			vector<int >v1;
			for (int i = 0; i < w; i++)
			{
				if (((1 << i) & p ) != 0)
				{ v1.pb(i + 1);}
			}
			int cnt = 0;
			for (int i = 1; i <= h; i++)
			{
				int f = 0;
				for (int j = 0; j < v.size(); j++)
				{
					if (v[j] == i)
					{
						f = 1; break;
					}
				}
				if (f == 1)
					continue;
				for (int j = 1; j <= w; j++)
				{
					int u = 0;
					for (int jj = 0; jj < v1.size(); jj++)
					{
						if (v1[jj] == j)
						{
							u = 1; break;
						}
					}
					if (u == 1)
						continue;
					else if (arr[i][j] == 1)
						cnt++;

				}
			}
			//cout << cnt << endl;
			if (cnt == k)
				nas++;
		}
	}
	cout << nas;
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)


int main(){
	long N;
	long predict_T,predict_A;	
	vector<long> T_array;
	vector<long> A_array;
	cin>>N;

	REP(i,N){
		int T,A;
		cin>>T>>A;
		T_array.push_back(T);
		A_array.push_back(A);
	}

	
	predict_T = T_array[0];
	predict_A = A_array[0];

	for(int i = 1; i < N;i++){

		long T_c ,A_c;


		T_c = predict_T / T_array[i];
		A_c = predict_A / A_array[i];
		if(predict_T % T_array[i] != 0)T_c++;
		if(predict_A % A_array[i] != 0)A_c++;
		long ad = max(T_c,A_c);
		predict_T = ad * T_array[i];
		predict_A = ad * A_array[i];
	}

	cout<<(predict_T + predict_A)<<endl;
	return 0;

}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000
#define LLINF 1e18

void solve_abc_a() {
	ll n, m;
	ll x, y;
	ll a, b, d;
	ll c;
	//char c;
	ll h, w;
	ll k;
	string s, t;
	ll l_ans = 0;
	string s_ans = "NG";
	ll l, r;

	cin >> n >> d;

	rep(i, n) {
		cin >> x >> y;
		if (x * x + y * y <= d * d) {
			l_ans++;
		}
	}

	cout << l_ans << "\n";

	return;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(7);

	solve_abc_a();

	return 0;
}


Measured memory_bytes: 3660
N = input()
a = []
for i in range(N):
	a = map(int, raw_input().split())
	b = [0]
	for i in a:
		j = 0
		while j < 3:
			if i > b[j]:
				b.insert(j, i)
				break
			j += 1
	if b[0]**2 == b[1]**2 + b[2]**2:
		print "YES"
	else:
		print "NO"

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


int main() {
	int num[32]={ 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};
	int k;
	cin >> k;
	cout << num[k - 1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>
 
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>
 
#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;
 
template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<< ' ' ; cout << endl; }
template<class T>void pp(T v){ EACH(it,v) cout << *it << ' ' ; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

struct Data {
  multiset<ll> s;
  ll _sum = 0;
  void push(ll a) { s.insert(a); _sum += a; }
  ll popMax() {
    auto it = s.end(); it--;
    ll value = *it; s.erase(it);
    _sum -= value;
    return value;
  }
  ll popMin() {
    auto it = s.begin();
    ll value = *it; s.erase(it);
    _sum -= value;
    return value;
  }
  ll min() {
    return *s.begin();
  }
  ll max() {
    auto it = s.end(); --it;
    return *it;
  }
  ll sum() {
    return _sum;
  }
  int size() { return s.size(); }
};

int main() {
  int q;
  while (cin >> q) {
    Data lo, hi;
    ll bs = 0;
    REP(iter, q) {
      ll op, a, b; cin >> op;
      if (op == 1) {
        cin >> a >> b;
        bs += b;
        if (a > hi.min()) {
          hi.push(a);
        } else {
          lo.push(a);
        }
        while (lo.size() < hi.size() + 1) {
          lo.push(hi.popMin());
        }
        while (lo.size() > hi.size() + 1) {
          hi.push(lo.popMax());
        }
        // cout << "---" << endl;
        // cout << "lo: " << lo.sum() << ' ' ; pp(lo.s);
        // cout << "hi: " << hi.sum() << ' ' ; pp(hi.s);
      } else {
        ll x = lo.max();
        ll result = bs;
        result += x * lo.size() - lo.sum();
        result += hi.sum() - x * hi.size();
        cout << x << ' ' << result << endl;
      }
    }
  }
}


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

int main(){
  string S;
  cin >> S;
  int L=S.size();
  int N=L/2;
  for(int i=1; i<N; i++){
    int Ans=1;
    for(int j=0; j<N-i; j++){
      if(S.at(j)!=S.at(N-i+j)){
        Ans=0;
      }
    }
    if(Ans==1){
      cout << L-2*i << endl;
      break;
    }
  }
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  int p[n];
  for(int i = 0; i < n; i++) {
    cin >> p[i];
  }
  int ans = 0;
  
  for(int i = 1; i < n - 1; i++) {
    if(p[i - 1] < p[i] && p[i] < p[i + 1]) {
      ans++;
    }else if(p[i - 1] > p[i] && p[i] > p[i + 1]) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
cnt=0
cntt=0

for i in a:
	if i<x:
		cnt+=1
	if i>x:
		cntt+=1
		
print(min(cnt,cntt))

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

int N, K, Q;

int main() {
	cin >> N >> K >> Q;
	vector<int> ans(N, Q - K);
	for (int i = 0; i < Q; i++) {
		int q;
		cin >> q; q--;
		ans[q]--;
	}

	for (int i = 0; i < N; i++) {
		if (ans[i] < 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 1024
n, k = map(int, input().split())
tele = list(map(int, input().split()))
	
city = 1
visited_cities = []
foo = [0]*n
while foo[city - 1] < 1 and k > 0:
	visited_cities.append(city)
	foo[city - 1] += 1
	city = tele[city - 1]
	k -= 1
	
if k == 0:
	print (city)
else:
	visited_cities = visited_cities[visited_cities.index(city):]	
	print (visited_cities[k % len(visited_cities)])

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = INF + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 3000 + 7;

int n, m;
string s, t;

bool read () {
	static char buf[N];
	if (scanf("%s", buf) != 1)
		return false;
	s = buf;
	n = sz(s);
	scanf("%s", buf);
	t = buf;
	m = sz(t);
	return true;
}

int dp[N][N];
pt p[N][N];

void upd(int i1, int j1, int i2, int j2, int val){
	if (dp[i1][j1] >= dp[i2][j2] + val) return;
	dp[i1][j1] = dp[i2][j2] + val;
	p[i1][j1] = mp(i2, j2);
}

void solve() {	
	forn(i, n + 1) forn(j, m + 1)
		dp[i][j] = -INF;
	dp[0][0] = 0;
	forn(i, n + 1) forn(j, m + 1){
		if (i + 1 <= n) upd(i + 1, j, i, j, 0);
		if (j + 1 <= m) upd(i, j + 1, i, j, 0);
		if (i + 1 <= n && j + 1 <= m && s[i] == t[j]) upd(i + 1, j + 1, i, j, 1);
	}
	string ans = "";
	pt cur = mp(n, m);
	while (cur.x > 0 || cur.y > 0){
		int nx = p[cur.x][cur.y].x;
		int ny = p[cur.x][cur.y].y;
		if (nx < cur.x && ny < cur.y)
			ans += s[nx];
		cur = mp(nx, ny);
	}
	reverse(all(ans));
	printf("%s\n", ans.c_str());
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
	
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

	while(read()) {	
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

Measured memory_bytes: 106112
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

A,B,T = inputIL()

print((T//A)*B)

Measured memory_bytes: 64620
#include<stdio.h>
int main(void){
  int n,a[10];
  scanf("%d",&n);
  int all=1,bad=1;
  for(int loop=0;loop<n;++loop){
    scanf("%d",a+loop);
    all*=3;
    if(a[loop]%2==0){
      bad*=2;
    }
  }
  printf("%d",all-bad);
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=3005,MOD=1e9+7;
int n,m;
int dp[MAXN][MAXN][2];
int main()
{
	//freopen("piling.in","r",stdin);
	//freopen("piling.out","w",stdout);
	scanf("%d %d",&n,&m);
	dp[0][0][1]=1;
	for(int i=1;i<=n;i++)
	{
		dp[0][i][0]=1;
	}
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<=n;j++)
		{
			for(int k=0;k<2;k++)
			{
				if(j>0)
				{
					dp[i+1][j-1][k|(j==1)]+=dp[i][j][k];
					dp[i+1][j-1][k|(j==1)]%=MOD;
				}
				if(j>0)
				{
					dp[i+1][j][k|(j==1)]+=dp[i][j][k];
					dp[i+1][j][k|(j==1)]%=MOD;
				}
				if(j<n)
				{
					dp[i+1][j][k]+=dp[i][j][k];
					dp[i+1][j][k]%=MOD;
					dp[i+1][j+1][k]+=dp[i][j][k];
					dp[i+1][j+1][k]%=MOD;
				}
			}
		}
	}
	int ans=0;
	for(int i=0;i<=n;i++)
	{
		ans+=dp[m][i][1];
		ans%=MOD;
	}
	printf("%d\n",ans);
	fclose(stdin);
	fclose(stdout);
}

Measured memory_bytes: 70656
#include <stdio.h>
#include <math.h>
 
int main(void){
    double a,b,c;
    scanf("%lf %lf %lf",&a,&b,&c);
    c=c*3.14159265/180.0;
    printf("%f\n",a*b*sin(c)/2);
    printf("%f\n",a+b+sqrt(a*a+b*b-2*a*b*cos(c)));
    printf("%f\n",b*sin(c));
    return 0;
}

Measured memory_bytes: 676
// "header" {{{
#pragma GCC optimize("Ofast")

#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define int int64_t
#define double long double
#define Fixed fixed << setprecision(10)
#define moke_pair make_pair

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int64_t mod1 = 1000000007;
constexpr int64_t mod2 = 998244353;

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

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class T,class U> using umap = unordered_map<T,U>;

inline int64_t updiv(int64_t n,int64_t d){ return ((n + d -1) / d); }
inline int square(int a){ return a * a; }

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

signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    int a,b;
    cin >> a >> b;
    rep(i,n-1){
        int t,s;
        cin >> t >> s;

        int tmp1 = updiv(b,s);
        int tmp2 = updiv(a,t);

        a = max(tmp1,tmp2) * t;
        b = max(tmp1,tmp2) * s;
    }

    cout << a + b << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;



int main(){
    int N;
    cin >> N;
    int K;
    cin >> K;
    
    int h[N];
    for(int i=0; i<N; i++){
        cin >> h[i];
    }
    
    int dp[N];
    for(int i=0; i<N; i++){
        dp[i]=INF;
    }
    dp[0]=0;
    
    for(int i=0; i<N; i++){
        for(int k=1; k<=K; k++){
            if(i+k>=N){break;}
            dp[i+k]=min(dp[i+k], dp[i]+abs(h[i]-h[i+k]));
        }
    
    }
    
    cout<<dp[N-1]<<endl;
    return 0;
}


Measured memory_bytes: 1024