akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	int data[100][100];
	int r,c;
	ll int sum;
	cin >> r >> c;
	REP(i,r) REP(j,c) cin >> data[i][j];
	REP(i,r){
		sum = 0;
		REP(j,c){
			cout << data[i][j] << " ";
			sum += data[i][j];
		}
		cout << sum << endl;
	}
	ll int sum2 = 0;
	REP(i,c){
		sum = 0;
		REP(j,r){
			sum += data[j][i];
		}
		sum2 += sum;
		cout << sum << " ";
	}
	cout << sum2 << endl;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
struct PalindromicTree{
  struct node{
    map<char,int> nxt;
    int len,suf,hei,app,cnt;
  };
  string s;
  vector<node> v;
  vector<int> ord;
  int n,suff;
  PalindromicTree(){}
  PalindromicTree(string s_):s(s_),v(s_.length()+10){
    n=2;
    suff=1;
    v[0].app=v[1].app=-1;
    v[0].len=-1;v[1].len=0;
    v[0].suf=v[1].suf=0;
    v[0].hei=v[1].hei=0;
    build();
  }
  
  bool addchar(int pos){
    char ch=s[pos];
    int cur=suff;
    while(1){
      if(pos-1-v[cur].len>=0&&s[pos-1-v[cur].len]==ch) break;
      cur=v[cur].suf;
    }
    if(v[cur].nxt.count(ch)){
      suff=v[cur].nxt[ch];
      v[suff].cnt++;
      return false;
    }
    suff=n++;
    v[suff].len=v[cur].len+2;
    v[suff].app=pos-v[suff].len+1;
    v[suff].cnt=1;
    v[cur].nxt[ch]=suff;
    
    if(v[suff].len==1){
      v[suff].suf=1;
      v[suff].hei=1;
      return true;
    }
    while(1){
      cur=v[cur].suf;
      if(pos-1-v[cur].len>=0&&s[pos-1-v[cur].len]==ch){
	v[suff].suf=v[cur].nxt[ch];
	break;
      }
    }
    v[suff].hei=v[v[suff].suf].hei+1;
    return true;
  }
  
  void calcOrder(){
    ord.clear();
    ord.push_back(0);
    ord.push_back(1);
    for(int i=0;i<(int)ord.size();i++){
      for(auto &p:v[ord[i]].nxt) ord.push_back(p.second);
    }
  }
  
  void calcCount(){
    assert(ord.size());
    for(int i=(int)ord.size()-1;i>=0;i--){
      v[v[ord[i]].suf].cnt+=v[ord[i]].cnt;
    }
    v[0].cnt=v[1].cnt=0;
  }

  void build(){
    for(int i=0;i<(int)s.size();i++) addchar(i);
    calcOrder();
    calcCount();
  }
  
};
//END CUT HERE

struct RollingHash{
  typedef unsigned long long ull;
  string S;
  ull B;
  vector<ull> hash,p;
  int len;
  RollingHash(){}
  RollingHash(string S,ull B=1000000007LL):S(S),B(B){init();};
  void init(){
    len=S.length();
    hash.resize(len+1);
    p.resize(len+1);
    hash[0]=0;p[0]=1;
    for(int i=0;i<len;i++){
      hash[i+1]=hash[i]*B+S[i];
      p[i+1]=p[i]*B;
    }
  }
  //S[l,r)
  ull find(int l,int r){
    return hash[r]-hash[l]*p[r-l];
  }
};

signed main(){
  string s,t;
  cin>>s>>t;
  PalindromicTree p1(s),p2(t);
  RollingHash r1(s),r2(t);
  using ull = RollingHash::ull;
  map<ull,Int> m1[55555],m2[55555];
  for(int i=0;i<(int)p1.n;i++){
    PalindromicTree::node& u=p1.v[i];
    if(u.app<0) continue;
    m1[u.len][r1.find(u.app,u.app+u.len)]=u.cnt;
  }
  for(int i=0;i<(int)p2.n;i++){
    PalindromicTree::node& u=p2.v[i]; 
    if(u.app<0) continue;
    m2[u.len][r2.find(u.app,u.app+u.len)]=u.cnt;
  }
  Int ans=0;
  for(int i=1;i<=(int)s.length();i++){
    for(auto p:m1[i]){
      ans+=m2[i][p.first]*p.second;
    }
  }
  cout<<ans<<endl;
  return 0;
}


/*
verified on 2017/07/20
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2292
*/

Measured memory_bytes: 31452
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
stringstream __ss__;
#define debug __ss__
#endif

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) debug << *i << " "; debug << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;i--)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);i--)
#define rep0(i,n) for(i=0;i<(n);++i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define SS stringstream
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

int dis(pint a,pint b){
	int res=abs(a.Y-b.Y);
	if(a.Y%2==0){
		if(b.Y%2==0){
			res+=max(abs(a.X-b.X)-abs(a.Y-b.Y)/2,0);
		}else{
			if(a.X<b.X){
				res+=max(abs(a.X-b.X)-abs(a.Y-b.Y)/2,0);
			}else{
				res+=max(abs(a.X-b.X)-abs(a.Y-b.Y)/2-1,0);
			}
		}
	}else{
		if(b.Y%2==0){
			if(a.X<b.X){
				res+=max(abs(a.X-b.X)-abs(a.Y-b.Y)/2-1,0);
			}else{
				res+=max(abs(a.X-b.X)-abs(a.Y-b.Y)/2,0);
			}
		}else{
			res+=max(abs(a.X-b.X)-abs(a.Y-b.Y)/2,0);
		}
	}
	return res;
}

int d[110][110];

int main() {
	int m,n,s,t,res;
	pint c,x;
	IL{
		cin>>m;
		if(m==0)break;
		res=0;
		cin>>n>>s;
		rep(i,n){
			rep(j,m){
				d[i][j]=INF;
			}
		}
		rep(i,s){
			cin>>c.X>>c.Y;
			--c.X;
			--c.Y;
			rep(i,n){
				rep(j,m){
					chmin(d[i][j],dis(MP(i,j),c));
				}
			}
		}
rep(i,n){
rep(j,m){
debug<<d[i][j]<<" ";
}
debug<<endl;
}
		cin>>t;
		rep(i,t){
			int r=0;
			cin>>x.X>>x.Y;
			--x.X;
			--x.Y;
			rep(i,n){
				rep(j,m){
					if(d[i][j]>dis(MP(i,j),x))++r;
				}
			}
			chmax(res,r);
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var A = sc.nextLong();
        var B = sc.nextLong();
        var C = sc.nextLong();
        var K = sc.nextLong();

        var odd = B - A;
        var even = (A + C) - (B + C);

        if (K % 2 == 0) {
            WriteLine(even);
        } else {
            WriteLine(odd);
        }
    }
}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 13140
<?php
$S=fgets(STDIN);
$A=str_split($S);
$c=0;
for ($i=0; $i <count($A) ; $i++) {
  // code...
  for ($j=$i+1; $j <count($A) ; $j++) {
    // code...
    if($A[$i]==$A[$j]){
      $c++;
      break 2;
    }
  }
}
if($c==0){
  echo "yes";
}else{
  echo "no";
}
 ?>


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

char a,b,c,d;

int main(){
	cin >> a >> b >> c >> d;
	if((a == b && b == c) || (b == c && c == d)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 384
Ans=[]
i=0
while True:
    l=input().split()
    m=int(l[0])
    f=int(l[1])
    r=int(l[2])
    if m==-1 and f==-1 and r==-1:
        break
    elif m==-1 or f==-1:
        Ans.append("F")
    elif m+f>=80:
        Ans.append("A")
    elif m+f>=65 and m+f<80:
        Ans.append("B")
    elif m+f>=50 and m+f<65:
        Ans.append("C")
    elif m+f>=30 and m<50:
        if r>=50:
            Ans.append("C")
        else:
            Ans.append("D")
    else:
        Ans.append("F")
    i+=1

m=0
while m<i:
    print(Ans[m])
    m=m+1



Measured memory_bytes: 5604
#![allow(non_snake_case)]
#![allow(unused_imports)]
use ascii::AsciiChar;
use ascii::AsciiStr;
use itertools::Itertools as _;
use permutohedron::LexicalPermutation as _;
use petgraph::algo::dijkstra;
use petgraph::algo::min_spanning_tree;
use petgraph::data::FromElements;
use petgraph::graph::NodeIndex;
use petgraph::graph::UnGraph;
use petgraph::unionfind::UnionFind;
use proconio::fastout;
use proconio::input;
use proconio::marker::Chars;
use proconio::marker::Usize1;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;
use superslice::Ext as _;

// 模範解 (解説を見て書いた)

#[fastout]
fn main() {
    input! {
        N: usize,
    }

    let mut ans: usize = 0;

    for i in 1..=N {
        // for k in 1..=N {
        //     ans += if k % i == 0 { k } else { 0 };
        // }

        // i + 2i + 3i + ... ni (ni <= N)
        let n = N / i;
        ans += (i + n * i) * n / 2;
    }
    println!("{}", ans);
}


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

int main(){
	int N;
	cin>>N;
	vector<int> s;
	int tmp;
	for(int i=0;i<N;++i){
		cin>>tmp;
		s.push_back(tmp);
	}
	sort(s.begin(),s.end());
	int ans=accumulate(s.begin(),s.end(),0);
	if(ans%10==0){
		for(int i=0;i<N;++i){
			if(s[i]%10!=0){
				ans-=s[i];
				break;
			}
		}
	}
	if(ans%10==0)cout<<0<<endl;
	else cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
using namespace std;
const int N=100005;
int f[N];
int getf(int x)
{
	return f[x]==x?x:f[x]=getf(f[x]);
}
set<int> mat[N];
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	map<pair<int,int>,int> occur;
	queue<pair<int,int> > Q;
	for(int i=1;i<=n*2-2;i++)
	{
		int u,v;
		cin>>u>>v;
		mat[u].insert(v);
		mat[v].insert(u);
		if(u>v)
			swap(u,v);
		if(++occur[make_pair(u,v)]==2)
			Q.push(make_pair(u,v));
	}
	for(int i=1;i<=n;i++)
		f[i]=i;
	while(!Q.empty())
	{
		int u=getf(Q.front().first),v=getf(Q.front().second);
		Q.pop();
		mat[u].erase(v);mat[v].erase(u);
		if(mat[u].size()<mat[v].size())
			swap(u,v);
		for(int x:mat[v])
		{
			if(x>v)
				occur[make_pair(v,x)]=0;
			else
				occur[make_pair(x,v)]=0;
			mat[x].erase(v);
			mat[x].insert(u);
			if(x>u)
			{
				if(++occur[make_pair(u,x)]==2)
					Q.push(make_pair(u,x));
			}
			else
			{
				if(++occur[make_pair(x,u)]==2)
					Q.push(make_pair(x,u));
			}
			mat[u].insert(x);
		}
		f[v]=u;
		mat[v].clear();
	}
	int cnt=0;
	for(int i=1;i<=n;i++)
		cnt+=getf(i)==i;
	if(cnt==1)
		cout<<"YES\n";
	else
		cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 39296
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;

const double W[12] = {0., 48., 51., 54., 57., 60., 64., 69., 75., 81., 91., (double)INF};
const string CLASS[11] = {"light fly", "fly", "bantam", "feather", "light", "light welter", "welter", "light middle", "middle", "light heavy", "heavy"};

int main(void){
    for(double w; cin >> w;)
        rep(i, 11) if(W[i] < w && w <= W[i + 1]) cout << CLASS[i] << endl;

    return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define deb(x) cout << #x << " => " << x << endl

ll H[101][100001];

ll knapSack(int *vals, int *wgs, int n, int w) {
    if (n < 0) return 0;
    if (w == 0) return 0;

    if (H[n][w] != -1) {
        return H[n][w];
    }
    ll res = knapSack(vals, wgs, n - 1, w);
    if (w >= wgs[n]) {
        res = max(res, knapSack(vals, wgs, n - 1, w - wgs[n]) + vals[n]);
    }
    H[n][w] = res;
    return res;
}

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

    int n, w;
    cin >> n >> w;
    int vals[n], wgs[n];
    for (int i = 0; i < n; i++) {
        cin >> wgs[i] >> vals[i];
    }
    memset(H, -1, sizeof H);
    cout << knapSack(vals, wgs, n - 1, w) << endl;

    return 0;
}

Measured memory_bytes: 79232
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
   char c;
   cin>>c;
   if(c>='A' && c<='Z')
   cout<<'A'<<endl;
   else
   cout<<'a'<<endl;
   return 0;
    
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long N, M;
    cin >> N >> M;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end(), greater<int>());
    long double sum = 0;
    for (int i = 0; i < N; i++) {
        sum += A[i];
    }
    if (A[M - 1] >= sum / (long double) (4 * M)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

int solve(int N, const vector<int>& xs)
{
    return 0;
}

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

    int N, A, B;
    cin >> N >> A >> B;

    cout << min(N*A, B) << '\n';

    return 0;
}


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

int cnt[100];
int d[100][100];
int dp[100][100];

int main() {
	string s;
	int n;
	for (n = 0; getline(cin, s) && s != ""; n++) {
		s += ',';
		stringstream ss(s);
		char c;
		for (; ss >> d[n][cnt[n]] >> c; cnt[n]++);
	}
	dp[0][0] = d[0][0];
	for (int i = 1; i < n; i++) {
		rep(j, cnt[i]) {
			if (i <= n / 2) {
				if (!j)dp[i][j] = dp[i - 1][j] + d[i][j];
				else dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - 1]) + d[i][j];
			}
			else {
				if (j == cnt[i - 1] - 1) dp[i][j] = dp[i - 1][j] + d[i][j];
				else dp[i][j] = max(dp[i - 1][j], dp[i - 1][j + 1]) + d[i][j];
			}
		}
	}
	printf("%d\n", dp[n - 1][0]);
}

Measured memory_bytes: 3312
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<cfloat>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

#define PI (3.1415926535)
#define EPS (1e-10)

int main(){
  int n;
  while(cin>>n){
    ll f = 1ll;
    do{
      f *= n;
    }while(--n!=0);
    cout << f << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tp3 = tuple<int, int, int>;
using Mat = vector<vector<ll>>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
template<typename T>
T chmin(T& l, T r) {
    return l = min(l, r);
}
template<typename T>
T chmax(T& l, T r) {
    return l = max(l, r);
}
// ============ template finished ============

int main()
{
    string s, t;
    cin >> s >> t;
    rep(i, s.size())if (s[i] != t[i]) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    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 <iostream>
#include <cstdio>
#include <bitset>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;
using ll=long long;
using vint=vector<int>;
using pint=pair<int,int>;

const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

void solve(){
	int A, B, K;
	cin >> A >> B >> K;
	REP(i, A, B+1){
		if(i < A+K || B-K < i){
			printf("%d\n", i);
		}
	}
}

int main(){
	solve();
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();
        int ans = 0;
       
        if( k<=a ){
            ans = k;
        }else if( a<k & k<=a+b ){
            ans = a; 
        }else if( a+b<k & k<=a+b+c){
            ans = a - (k-a-b);
        }

        System.out.println( ans );

    }
}

Measured memory_bytes: 35768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ESP 1e-5

int main(void){
    int x;
    cin >> x;
    if(x >= 400 && x <= 599){
	cout << 8 << endl;
    }else if (x >= 600 && x <= 799){
	cout << 7 << endl;
    }else if(x >= 800 && x <= 999){
	cout << 6 << endl;
    }else if(x >= 1000 && x <= 1199){
	cout << 5 << endl;
    }else if(x >= 1200 && x <= 1399){
	cout << 4 << endl;
    }else if (x >= 1400 && x <= 1599){
	cout << 3 << endl;
    }else if(x >= 1600 && x <= 1799){
	cout << 2 << endl;
    }else if(x >= 1800 && x <= 1999){
	cout << 1 << endl;
    }
    return 0;
    
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
#define MOD (ll)(998244353)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

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

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a,b; cin>>a>>b;
	b=b*2+1;
	cout<<((a+b-1)/b)<<"\n";
	return 0;
}

















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

num_minus = [1 if i<0 else 0 for i in a]
abs_list = [abs(i) for i in a]

if sum(num_minus)%2 == 0:
   print(sum(abs_list))
else:
   min_val = min(abs_list)
   print(sum(abs_list)-2*min_val)


Measured memory_bytes: 14224
#include<iostream>
#include<algorithm>
#include<iomanip>

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	int p[200000 + 100] = {};
	int csum[200000 + 100] = {};
	for (int i = 0; i < N; i++)cin >> p[i];

	for (int i = 0; i < N; i++)csum[i + 1] = csum[i] + p[i];
	int ans = 0;
	for (int i = 0; i <= N - K; i++) {
		ans = max(ans, csum[i + K] - csum[i]);
	}
	double out = ans;
	out += 1.0 * K;
	cout << setprecision(10) << out / 2.0 << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<climits>
#include<cctype>
#include<map>
#include<queue>
#include<iomanip>

using namespace std;

int main(){

    int n;
    cin >> n;
    vector<int>a(n);
    vector<int>non10;
    int sum = 0;

    for(int i = 0;i <n;i++){
    	cin >> a[i];
    	sum += a[i];
    	if(a[i]%10 != 0){
    		non10.push_back(a[i]);
    	}
    }

    sort(a.begin(),a.end());

    if(sum%10 !=0 ){
    	cout << sum  <<endl;
    }else if(non10.size() == 0){
    	cout << 0 << endl;
    }else{
    	sort(non10.begin(),non10.end());
    	cout << sum - non10[0] << endl;
    }

   return 0;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
double memo[301][301][301];
int n;
double solve(int x, int y, int z){
	if(x==0 && y==0 && z==0) return 0;
	if(memo[x][y][z]>0) return memo[x][y][z];
	double ans=((double)n)/((double)(x+y+z));
	if(x>0) ans+=((double)x)/((double)(x+y+z))*solve(x-1, y, z);
	if(y>0) ans+=((double)y)/((double)(x+y+z))*solve(x+1, y-1, z);
	if(z>0) ans+=((double)z)/((double)(x+y+z))*solve(x, y+1, z-1);
	return memo[x][y][z]=ans;
}
int main()
{
	cin>>n;
	int ct[3]={};
	for(int i=0; i<n; i++){
		int a; cin>>a;
		ct[a-1]++;
	}
	printf("%.10lf\n", solve(ct[0], ct[1], ct[2]));
	return 0;
}

Measured memory_bytes: 213248
#include <stdio.h>
 
int main(void)
{
int n=0,m=0,i,j,sum=0;

int A[100][100]={0},b[100]={0};


scanf("%d %d", &m,&n);
for(j=0;j<m;j++){
	for(i=0;i<n;i++){
			scanf("%d",&A[j][i]);
	}
}

for(j=0;j<n;j++){
	scanf("%d",&b[j]);
}

for(j=0;j<m;j++){
	for(i=0;i<n;i++){
		sum=sum+A[j][i]*b[i];
	}
	printf("%d\n",sum);
	sum=0;
}



         
     
    return (0);
}

Measured memory_bytes: 648
X, Y = map(int, input().split())

def mod_Combination(n, k, mod):
    def ext_gcd(a, b):
        if b == 0:
            return a, 1, 0
        else:
            d,x,y = ext_gcd(b,a%b)
            x-=(a//b)*y 
        return d,y,x
    p,q=1,1
    for i in range(n-k+1, n+1):
        p=(p*i)%mod
    for i in range(2, k+1):
        q=(q*i)%mod
    return int(p*(ext_gcd(q, mod)[1]%mod)%mod)

a = (2*X - Y)/3
b = (2*Y - X)/3

if (X+Y)%3 != 0:
    ans = 0

elif a<0 or b<0:
    ans = 0

else:
    ans = mod_Combination(int(a + b), int(a), 10**9 + 7)

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
int X;
int Y;
char S[2000][2002];
int dp1[2000][2000];
int dp2[2000][2000];
int dp3[2000][2000];
int dp4[2000][2000];
int main(){
  int i, j, k, res, tmp;
  rd(X);
  rd(Y);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<X;Lj4PdHRW++){
      rd(S[Lj4PdHRW]);
    }
  }
  for(i=0;i<X;i++){
    for(j=0;j<Y;j++){
      dp1[i][j] = 1;
      dp2[i][j] = 1;
      if(i-1 >= 0){
        dp1[i][j] += dp1[i-1][j];
      }
      if(j-1 >= 0){
        dp2[i][j] += dp2[i][j-1];
      }
      if(S[i][j]=='#'){
        dp1[i][j] = dp2[i][j] = 0;
      }
    }
  }
  for(i=X-1;i>=0;i--){
    for(j=Y-1;j>=0;j--){
      dp3[i][j] = 1;
      dp4[i][j] = 1;
      if(i+1 < X){
        dp3[i][j] += dp3[i+1][j];
      }
      if(j+1 < Y){
        dp4[i][j] += dp4[i][j+1];
      }
      if(S[i][j]=='#'){
        dp3[i][j] = dp4[i][j] = 0;
      }
    }
  }
  res = 0;
  for(i=0;i<X;i++){
    for(j=0;j<Y;j++){
      tmp = dp1[i][j] + dp2[i][j] + dp3[i][j] + dp4[i][j] - 3;
      chmax(res, tmp);
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190609-2 [beta]

// --- original code ---
// int X, Y;
// char S[2000][2002];
// int dp1[2000][2000];
// int dp2[2000][2000];
// int dp3[2000][2000];
// int dp4[2000][2000];
// {
//   int i, j, k, res, tmp;
//   rd(X,Y,S(X));
// 
//   rep(i,X) rep(j,Y){
//     dp1[i][j] = 1;
//     dp2[i][j] = 1;
//     if(i-1 >= 0) dp1[i][j] += dp1[i-1][j];
//     if(j-1 >= 0) dp2[i][j] += dp2[i][j-1];
//     if(S[i][j]=='#') dp1[i][j] = dp2[i][j] = 0;
//   }
// 
//   for(i=X-1;i>=0;i--) for(j=Y-1;j>=0;j--){
//     dp3[i][j] = 1;
//     dp4[i][j] = 1;
//     if(i+1 < X) dp3[i][j] += dp3[i+1][j];
//     if(j+1 < Y) dp4[i][j] += dp4[i][j+1];
//     if(S[i][j]=='#') dp3[i][j] = dp4[i][j] = 0;
//   }
// 
//   res = 0;
//   rep(i,X) rep(j,Y){
//     tmp = dp1[i][j] + dp2[i][j] + dp3[i][j] + dp4[i][j] - 3;
//     res >?= tmp;
//   }
//   wt(res);
// }


Measured memory_bytes: 66688
#include <iostream>
#include <vector>
#include <math.h>

#define POW(X) (X)*(X)

using namespace std;

int main(){
  double x1,y1,x2,y2,x3,y3;
  vector<double> x1l,y1l,x2l,y2l,x3l,y3l;
  int n;

  cin >> n;

  for(int i=0; i<n; i++){
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    x1l.push_back(x1);
    y1l.push_back(y1);
    x2l.push_back(x2);
    y2l.push_back(y2);
    x3l.push_back(x3);
    y3l.push_back(y3);
  }

  double ex,ey,fx,fy;
  double a,b,c,d,e,f,r;

  for(int i=0; i<n; i++){
    x1=x1l[i];
    y1=y1l[i];
    x2=x2l[i];
    y2=y2l[i];
    x3=x3l[i];
    y3=y3l[i];

    a = -((y2-y1)*POW(y3)+(-POW(y2)+POW(y1)-POW(x2)+POW(x1))*y3+y1*POW(y2)+(-POW(y1)+POW(x3)-POW(x1))*y2+(POW(x2)-POW(x3))*y1)/((2*x2-2*x1)*y3+(2*x1-2*x3)*y2+(2*x3-2*x2)*y1);
    b =  ((x2-x1)*POW(y3)+(x1-x3)*POW(y2)+(x3-x2)*POW(y1)+(x2-x1)*POW(x3)+(POW(x1)-POW(x2))*x3+x1*POW(x2)-POW(x1)*x2)/((2*x2-2*x1)*y3+(2*x1-2*x3)*y2+(2*x3-2*x2)*y1);
    r = sqrt((a-x1)*(a-x1) + (b-y1)*(b-y1));
    printf("%0.3f %0.3f %0.3f\n",a,b,r);
  }

  return 0;
}

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

int main() {
    int h, w, k; cin >> h >> w >> k;
    char c0[h][w];
    char c[h][w];
    rep(i, h)rep(j, w){
        cin >> c0[i][j];
        c[i][j] = c0[i][j];
    } 
    int ans = 0;
    // cout << "now";
    rep(i, 1<<h){
        rep(j, 1<<w){
            rep(m, h){
                if(i>>m & 1){
                    rep(a, w){
                        if(c[m][a] == '#') c[m][a] = '.';
                    }
                }
            }
            rep(l, w){
                if(j>>l & 1){
                    rep(a, h){
                        if(c[a][l] == '#') c[a][l] = '.';
                    }
                }
            }
            // rep(a, h){
            //     rep(b, w){
            //         cout << c[a][b];
            //     }
            //     cout << endl;
            // }
            int sum = 0;
            rep(i, h)rep(j, w){
                if(c[i][j] == '#') sum++;
            }
            if(sum == k){
                ans++;
                // cout << sum << " ++" << k << endl;
            }

            rep(a, h)rep(b, w) c[a][b] = c0[a][b];
        }
    }
    cout << ans << endl;


    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int sum=0;
  
  for(int i=0;i<N;i++){
    int l,r;
    cin >> l >> r;
    sum +=r-l+1;
  }
  cout << sum <<endl;
}


Measured memory_bytes: 256
s = int(input())

m = 1
memo = [s]
while True:
    m += 1
    if memo[-1]%2 == 0:
        a = memo[-1]/2
    else:
        a = memo[-1]*3+1

    if a in memo:
        print(m)
        break
    else:
        memo.append(a)

Measured memory_bytes: 3060
#include <stdio.h>

int permutation(int a, int b, int c, int d);

int main() {
	int n;
	int i, j, k, l;
	int count = 0;

	while(scanf("%d", &n) != EOF) {
		count = 0;
		for(i = 0; i <= 9; i++) 
		for(j = i; j <= 9; j++) 
		for(k = j; k <= 9; k++) 
		for(l = k; l <= 9; l++) 
			if((i + j + k + l) == n) {
				count += permutation(i, j , k, l);
			}
		printf("%d\n", count);
	}
	return 0;
}

int permutation(int a, int b, int c, int d) {
	// a <= b <= c <= d
	if(a == b) {
		if(b == c) {
			if(c == d) return 1;
			else return 4;
		} else {
			if(c == d) return 6;
			else return 12;
		}
	} else {
		if(b == c) {
			if(c == d) return 4;
			else return 12;
		} else {
			if(c == d) return 12;
			else return 24;
		}
	}
	return 0;
}

Measured memory_bytes: 596
n = 100000
plist = range(2,n+1)
for i in range(n):
    if plist[i]**2>n:
        break
    plist = [num for num in plist if num % plist[i] != 0 or num == plist[i]]
ok = [0]*n
for p in plist:
    ok[p] += 1
    if p*2-1 < n:
        ok[p*2-1] += 1
li = []
cnt = 0
for i in range(n):
    if ok[i] == 2:
        cnt += 1
    li.append(cnt)
Q = int(input())
qlist = []
for i in range(Q):
    l, r = map(int, input().split())
    qlist.append((l,r))
for x in qlist:
    (l, r) = x
    print(li[r]-li[l-1])

Measured memory_bytes: 64732
taka_h, taka_a, aoki_h, aoki_a = map(int, input().split())

while True:
    aoki_h -=taka_a
    taka_h -= aoki_a
    if(aoki_h <=0):
        print("Yes")
        break
    elif(taka_h <= 0):
        print("No")
        break


Measured memory_bytes: 9108
#include<stdio.h>

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

    int as[m];
    for(i = 0; i < m; i++) {
        scanf("%d", &as[i]);
    }   

    int answer, b, scores[n], j;
    for(j = 0; j < n; j++) scores[j] = 0;
    for(i = 0; i < m; i++) {
        answer = as[i];
        for(j = 0; j < n; j++) {
            scanf("%d", &b);
            if(b == answer) {
                scores[j]++;
            } else{
                scores[answer - 1]++;                                                                              
            }   
        }   
    }   

    for(j = 0; j < n; j++) printf("%d\n", scores[j]);

    return 0;
}

Measured memory_bytes: 596
N = int(input())
W = list(map(int, input().split()))

a, b = 0, 1
a_sum, b_sum = 0, 0
for i in range(N):
    if a_sum > b_sum:
        b_sum += W[-b]
        b += 1
    else:
        a_sum += W[a]
        a += 1

print(abs(a_sum-b_sum))

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

int main() {
	int a, b, x;
	cin >> a >> b >> x;
	int c = x - a;
	if (a > x) cout << "NO" << endl;
	else if (c <= b)cout << "YES" << endl;
	else cout << "NO";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define CYES cout<<"Yes"<<"\n";
#define CNO cout<<"No"<<"\n";
#define CFS cin.tie(nullptr);ios::sync_with_stdio(false);
#define CST(x) cout<<fixed<<setprecision(x);
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
const int IINF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = (int) 1e9 + 7;
const string MM = " ";

int main(){
    string s, t;
    cin >> s >> t;
    cout << t << s << "\n";
}

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

int main(){
	int R,G,B,N,r,g,b,result;
	cin>>R>>G>>B>>N;
	result=0;
	
	for(r=0;r<=N/R;r++){
		for(g=0;g<=(N-r*R)/G;g++){
			if((N-r*R-g*G)%B==0){
				result+=1;
			}
		}
	}
	cout<<result<<endl;
	return 0;
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL unsigned long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
LL A[100000];

LL ans = 1;
bool flag = 0;

LL digit(LL x){
	LL ret = 0;
	LL num = x;
	for(int i=0;i<18;i++){
		if(num%10LL!=0) ret = i;
		num /= 10LL;
	}
	return ret+1LL;
}

void solve(){
	for(int i=0;i<N;i++){
		if(A[i]==0){
			ans = 0;
			return;
		}
	}
	for(int i=0;i<N;i++){
		LL a = digit(ans);
		LL n = digit(A[i]);
		// cout << "ans=" <<ans << " ";
		// cout << "A=" <<A[i] << " ";
		// cout << "a=" <<a << " ";
		// cout << "n=" <<n << " ";
		// cout << endl << ans*A[i] << endl;
		// cout << 1000000000000000000LL << endl;
		if(a+n-1LL>19LL){
			flag = 1;
			//cout << "stop" << endl;
			return;
		}
		if(a+n-1LL==19LL){
			if(ans*A[i]!=1000000000000000000LL){
				flag = 1;
				//cout << "stopper" << endl;
				return;
			}
		}
		if(ans*A[i]>1000000000000000000LL){
			flag = 1;
			//cout << "stopper" << endl;
			return;
		}
		ans *= A[i];
	}
}

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];

    solve();

	if(flag){
		cout << -1 << endl;
		return 0;
	}
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

int main(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll count=0;
    vll r(n,0);
    vll g(n,0);
    vll b(n,0);
    if(s[0]=='R') r[0]++;
    if(s[0]=='G') g[0]++;
    if(s[0]=='B') b[0]++;
    repi(i,1,n){
        if(s[i]=='R'){
            r[i]=r[i-1]+1;
            g[i]=g[i-1];
            b[i]=b[i-1];
        }
        else if(s[i]=='G'){
            r[i]=r[i-1];
            g[i]=g[i-1]+1;
            b[i]=b[i-1];
        }
        else if(s[i]=='B'){
            r[i]=r[i-1];
            g[i]=g[i-1];
            b[i]=b[i-1]+1;
        }
    }
    ll ss=0;
    rep(i,n-2){
        repi(j,i+1,n-1){
            if(s[i]!=s[j]){
                if(s[i]!='R'&&s[j]!='R'){
                    count+=r[n-1]-r[j];
                    if(j*2-i<n&&s[j*2-i]=='R') count-=1;
                }
                else if(s[i]!='G'&&s[j]!='G'){
                    count+=g[n-1]-g[j];
                    if(j*2-i<n&&s[j*2-i]=='G') count-=1;
                }
                else if(s[i]!='B'&&s[j]!='B'){
                    count+=b[n-1]-b[j];
                    if(j*2-i<n&&s[j*2-i]=='B') count-=1;
                }
            }
        }
    }
    cout<<count<<endl;
}

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

typedef unsigned long long ull;

int main(void){
	int n,i,j;
	int *nextTown,*visited;
	int nowTown,prevTown,visitedCount,ans,loopCount;
	ull k;
	scanf("%d%llu",&n,&k);
	nextTown=(int *)calloc(n+1,sizeof(int));
	visited=(int *)calloc(n+1,sizeof(int));
	for(i=1;i<=n;i++){
		scanf("%d",&nextTown[i]);
	}
	nowTown=1;
	prevTown=0;
	visitedCount=1;
	while(visited[nowTown]==0 && visitedCount<=k){
		//printf("%d: nowTown= %d\n",visitedCount,nowTown);
		visited[nowTown]=visitedCount;
		visitedCount++;
		prevTown=nowTown;
		nowTown=nextTown[prevTown];
	}
	//puts("Loop detected");
	if(visitedCount<=k){
		//printf("nowTown: %d\n",nowTown);
		loopCount=visitedCount-visited[nowTown];
		k-=visitedCount-1;
		k%=loopCount;
		//printf("k: %d\n",k);
		for(i=0;i<k;i++){
			prevTown=nowTown;
			nowTown=nextTown[prevTown];
		}
	}
	printf("%llu\n",nowTown);
	free(nextTown);
	free(visited);
}


Measured memory_bytes: 3072
#include <cstdio>
using namespace std;
int n;
int k;
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;++i){
		for(int j=1;i*j<n;++j){
			++k;
		}
	}
	printf("%d\n",k);
	return 0;
}


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

int main() {
    double pi=3.141592653589793238;
    double a,b,h,m, c, k;
    cin >> a >> b >> h >> m;
    k=2*pi*(60*h-11*m)/720;
    if(k>pi) k=2*pi*(11*m-60*h)/720;
    c=sqrt(a*a+b*b-2*a*b*cos(k));


    cout << fixed << setprecision(10);
    cout << c;
}

Measured memory_bytes: 4092
# AGC011B - Colorful Creatures
from itertools import accumulate


def main():
    N = int(input())
    A = sorted(map(int, input().split()))
    ac = list(accumulate(A))
    ans = 1
    for i, j in zip(ac[:-1][::-1], A[1:][::-1]):
        if i * 2 >= j:
            ans += 1
        else:
            break
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14428
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#define debug(x) cout<<x<<"\n";
#define Max(a,b) ((a)>(b)?(a):(b))
typedef long long ll;
const ll inf=0x3f3f3f3f3f3f;
using namespace std;
int main()
{	
	string s;
	cin>>s;
	int p=0,g=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='g')
		g++;
		if(s[i]=='p')
		p++;
	}
	int r=(s.size()+1)/2,len=s.size();
	int ans=min(len-r,g);
	ans-=min(p,r);
	cout<<ans<<"\n";
	return 0;
} 

Measured memory_bytes: 512
#include <stdio.h>
//#include <math.h>

void swap(int x[],int r,int l){
	int tmp;
	tmp=x[r];
	x[r]=x[l];
	x[l]=tmp;
}

void qsort(int x[],int l,int r){
	int i,j,p;
	i=l;
	j=r;
	p=x[(r+l)/2];
	while(1){
		while(p>x[i])i++;
		while(p<x[j])j--;
		if(i>=j)break;
		swap(x,i,j);
		i++;
		j--;
	}
	if(l<i-1)qsort(x,l,i-1);
	if(j+1<r)qsort(x,j+1,r);
}

int abs(int n){
	if(n<0)return n*(-1);
	else return n;
}


int main(){
	int n,m;
	int ta[110];
	int ha[110];
	int i,j,k,l;
	int st,sh;
	int b;

	while(1){
		scanf("%d %d",&n,&m);
		if(n==0&&m==0)break;
		st=0;
		sh=0;
		for(i=0; i<n; i++){
			scanf("%d",&ta[i]);
			st+=ta[i];
		}
		for(i=0; i<m; i++){
			scanf("%d",&ha[i]);
			sh+=ha[i];
		}
		qsort(ta,0,n-1);
		qsort(ha,0,m-1);
		b=1;
		for(i=0; (i<n&&b); i++){
			for(j=0; j<m; j++){
				if(st-ta[i]+ha[j]==sh-ha[j]+ta[i]){
					printf("%d %d\n",ta[i],ha[j]);
					b=0;
					break;
				}
			}
		}
		if(b)printf("-1\n");
	}
	return 0;
}

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

N = int(input().split()[0])
xu_list = []

for _ in range(N):
    x, u = list(input().split())
    xu_list.append((float(x), u))

total = 0

for xu in xu_list:
    x, u = xu
    total += x * 38 * 10 ** 4 if u == "BTC" else x

ans = total
print(ans)


Measured memory_bytes: 3060
mod = 10**9+7
n = int(input())
s = input()
d = {}
for i in s:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
result = 1
for i, j in d.items():
    result = (result*(j+1))%mod

print((result-1)%mod)

Measured memory_bytes: 39408
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    long long int n,p,q,r,cur,i,j,k,x,y,z,c1=0,c2=0,c3=0,f=0;
    //cin>>n>>k;
    //map<long long int,long long int>m;
    //vector<long long int>v;
    //set<long long int>s;
    cin>>x>>y;
    while(x<=y)
    {
       x=x*2;
       c1++;
    }
    cout<<c1<<endl;

    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;


int main(void){
    int len;
    string s;
    cin>>len;
    cin>>s;
    vector<int>pos[10];
    for(int i=0;i<s.length();i++){
        int x=s[i]-'0';
        pos[x].push_back(i);
    }
    int ans=0;
    for(int i=0;i<=999;i++){
        int y=i;
        int c=y%10;
        y=(y-c)/10;
        int b=y%10;
        y=(y-b)/10;
        int a=y;
        for(int j=0;j<(int)pos[a].size();j++){
            int l=pos[a][j];
            auto itr1=upper_bound(pos[b].begin(),pos[b].end(),l);
            if(itr1==pos[b].end())continue;
            int m=*itr1;
            auto itr2=upper_bound(pos[c].begin(),pos[c].end(),m);
            if(itr2==pos[c].end())continue;
            int n=*itr2;
            //cout<<a<<b<<c<<" "<<l<<m<<n<<endl;
            if((l<m)&&(m<n)){
                ans++;
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
bool used[333];
int n,m;
int a[333][333];
int cnt[333];
int id[333];
main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)cin>>a[i][j];
		cnt[a[i][0]]++;
	}
	int ans=n;
	for(int ccc=m;ccc--;)
	{
		int mi=-1;
		for(int i=1;i<=m;i++)
		{
			if(cnt[i]==0)continue;
			if(mi<0||cnt[mi]<cnt[i])mi=i;
		}
		ans=min(ans,cnt[mi]);
		used[mi]=1;
		if(ccc)
		{
			for(int i=0;i<n;i++)
			{
				cnt[a[i][id[i]]]--;
				for(;used[a[i][id[i]]];id[i]++);
				cnt[a[i][id[i]]]++;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#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 n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    bool ok = true;
    rep(i, n) {
        if (a[i]%2==0) {
            if (a[i]%3!=0 && a[i]%5!=0) {
                ok = false;
                break;
            }
        }
    }
    if(ok) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    return 0;
}

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

int main() {
  int N;
  int sum = 0;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    int l,r;
    cin >> l >> r;
    sum += r - l +1;
  }
  cout << sum << endl;
}


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

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

  string a, b, c, ans;
  cin >> a >> b >> c;

  ans += a[0];
  ans += b[0];
  ans += c[0];

  cout << ans << endl;

  return (0);
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

struct UnionFind{
	vector<int> rnk,par;

	UnionFind(int sz) : rnk(sz,0),par(sz){
		for(int i = 0;i < sz;i++) par[i] = i;
	}

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

	void unite(int x,int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(rnk[x] < rnk[y]) swap(x,y);
		par[y] = x;
		if(rnk[x] == rnk[y]) rnk[x]++;
	}
	
	bool same(int x,int y){
		return (find(x) == find(y));
	}
};

signed main(){
	int n,w,h,x[40010],y[40010];
	bool hasEdge = false;
	cin >> n >> w >> h;
	for(int i = 0;i < n;i++){
		cin >> y[i] >> x[i];
		y[i]--;x[i]--;
		if(x[i] == 0 || y[i] == 0 || x[i] == h - 1 || y[i] == w - 1) hasEdge = true;
	}
	vector<int> xs[100010],ys[100010];
	for(int i = 0;i < n;i++){
		xs[x[i]].push_back(i);
		ys[y[i]].push_back(i);
	}
	UnionFind uf(n);
	for(int i = 0;i < h;i++){
		for(int j = 0;j + 1 < xs[i].size();j++) uf.unite(xs[i][j],xs[i][j + 1]);
	}
	for(int i = 0;i < w;i++){
		for(int j = 0;j + 1 < ys[i].size();j++) uf.unite(ys[i][j],ys[i][j + 1]);
	}
	set<int> st;
	for(int i = 0;i < n;i++) st.insert(uf.find(i));
	if(st.size() == 1) cout << n - 1 << endl;
	else cout << n - st.size() + (st.size() - 1) * 2 + !hasEdge << endl;
}


Measured memory_bytes: 12116
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n,m) for(int i=n;i<m;i++)
int main(){
  int n,a,b;cin>>n>>a>>b;
  int ans=0;
  rep(i,0,n){
    int t;cin>>t;
    if(t<a||t>=b)ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int a[MAX_N];
int Q;

int main()
{
	P p1,p2;
	P p;
	scanf("%d%d%d%d",&p1.first,&p1.second,&p2.first,&p2.second);
	P a = P(p2.first-p1.first,p2.second-p1.second);
	scanf("%d",&Q);
	rep(i,Q){
		scanf("%d%d",&p.first,&p.second);
		P b = P(p.first - p1.first,p.second - p1.second);
		double sa = sqrt(a.first*a.first + a.second*a.second);
		double sb = sqrt(b.first*b.first + b.second*b.second);
		double rt = (a.first*b.first+a.second*b.second)/(sa*sa);
		printf("%.10f %.10f\n",p1.first+rt*a.first,p1.second+rt*a.second);
	}
	return 0;
}

Measured memory_bytes: 3224