akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <cassert>
#define For(i, a, b) for (int i = a; i < b; ++i)
#define Out(i, a, b) for (int i = a - 1; i >= b; --i)
#define pb push_back
#define x first
#define y second
#define files(FileName) read(FileName); write(FileName)
#define read(FileName) freopen((FileName + ".in").c_str(), "r", stdin)
#define write(FileName) freopen((FileName + ".out").c_str(), "w", stdout)
using namespace std;
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }
 
  
const string FileName = "input";
 
typedef long long base;
 
const int MAXN = 2e4;
 
long long X;
 
int main() {
    ios::sync_with_stdio(0);
    //read(FileName);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> X;
    for (int i = 1;;++i) {
        X -= i;
        if (X == 0) {
            cout << i << endl;
            return 0;
        } else if (X < 0) {
            cout << i << endl;
            return 0;
        }
    }
}  
 
/*
2 AB 11
2!2
3 ABB 122
3!3
4 ABB 2222
4!3
5 ABBBB 12222
5!5
6 ABBB 121222
6!4
7 ABBBB 1212122
7!5
8 ABBB 12121212
8!4
9 ABBBBBBBB 122222222
9!9
10 ABBBBB 1212222222
10!6
11 ABBBBBBBB 12121222222
11!9
12 ABBBBB 121212122222
12!6
13 ABBBBBBBB 1212121212222
13!9
14 ABBBBB 12121212121222
14!6
15 ABBBBBBBB 121212121212122
15!9
16 ABBBBB 1212121212121212
16!6
17 ABBBBBBBBBBBBBBBB 12222222222222222
17!17
18 ABBBBBBBBB 121222222222222222
18!10
19 ABBBBBBBBBBBBBBBB 1212122222222222222
19!17
20 ABBBBBBBBB 12121212222222222222
20!10
[Finished in 3.1s]
*/

Measured memory_bytes: 256
using System;
using System.Linq;
namespace aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            string input;
            int count1 = 0, count2 = 0;
            while((input = Console.ReadLine()) != null){
                int[] val = (from q in input.Split(',') select int.Parse(q)).ToArray();
                count1 += (val[0] * val[0] + val[1] * val[1] == val[2] * val[2] ? 1 : 0);
                count2 += (val[0] == val[1] ? 1 : 0);
            }
            Console.WriteLine(count1);
            Console.WriteLine(count2);
        }
    }
}

Measured memory_bytes: 5912
s=input()

if s=='SUN':
    print(7)
if s=='MON':
    print(6)
if s=='TUE':
    print(5)
if s=='WED':
    print(4)
if s=='THU':
    print(3)
if s=='FRI':
    print(2)
if s=='SAT':
    print(1)


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

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

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

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


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

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

  int N;
  cin >> N;
  VL xs(N);
  REP(i,N) cin >> xs[i];

  int ix = 0;
  REP(i,N) if(abs(xs[i]) > abs(xs[ix])) ix = i;

  vector<PII> qs;
  if(xs[ix] > 0){
	qs.EB(ix, 0);
	qs.EB(ix, 0);
	REP(i,N-1){
	  qs.EB(i, i+1);
	  qs.EB(i, i+1);
	}
  }
  else{
	qs.EB(ix, N-1);
	qs.EB(ix, N-1);
	for(int i=N-1;i>0;--i){
	  qs.EB(i, i-1);
	  qs.EB(i, i-1);
	}
  }

  cout << SZ(qs) << endl;
  for(auto p: qs) cout << p.FF+1 << " " << p.SS+1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int x, y;
    cin >> x >> y;
    int ans;
    if (x == y) cout << 2 * max(x, y) << endl;
    else cout << 2 * max(x, y) - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,i,j,a[1000],w,b,k,c[1001],d[1001],e[1001];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&c[i],&d[i],&e[i]);
		a[i]=0;
	}
		for(i=0;i<n;i++){
			w=0;
			b=0;
			k=0;
			for(j=0;j<n;j++){
			if(i!=j){
				if(c[i]==c[j]){
					w=1;
				}
				if(d[i]==d[j]){
					b=1;
				}
				if(e[i]==e[j]){
					k=1;
				}
			}
			}
			if(w==0){
				a[i]+=c[i];
			}
			if(b==0){
				a[i]+=d[i];
			}
			if(k==0){
				a[i]+=e[i];
			}		
		}
	for(i=0;i<n;i++){
		printf("%d\n",a[i]);
	}
	return 0;
}

Measured memory_bytes: 1040
#include <iostream>
#include <vector>
#define eol '\n'
using namespace std;

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

  long long n,m;
  cin >> n >> m;

  long ans = 0;
  if (n < m / 2) {
    ans = n + (m - 2*n) / 4;
  } else {
    ans = m / 2;
  }

  cout << ans << eol;
  
  return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) static_cast<int>((x).size())

using LL = long long;
template<class T, size_t D>
struct vec : vector<vec<T, D - 1>> {
  template<class... Args>
  vec(size_t n = 0, Args... args)
    : vector<vec<T, D - 1>>(n, vec<T, D - 1>(args...)) {}
};
template<class T>
struct vec<T, 1> : vector<T> {
  template<class... Args>
  vec(Args... args)
    : vector<T>(args...) {}
};

template<class T>
inline bool asMn(T& a, const T& b) { return a > b ? a = b, true : false; }
template<class T>
inline bool asMx(T& a, const T& b) { return a < b ? a = b, true : false; }
inline int nex(int i, int n) { return i == n - 1 ? 0 : i + 1; }
inline int pre(int i, int n) { return !i ? n - 1 : i - 1; }

mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

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

  int x; cin >> x;
  cout << 360 / __gcd(x, 360) << '\n';

  return 0;
}

Measured memory_bytes: 3608
// AtCoder template
// sabaより胡蝶しのぶさんの方が可愛いのではないか？
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

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

    int h,w; cin >> h >> w;
    vector<string> s(h); rep(i,h) cin >> s[i];
    vector<vector<int>> dp(h,vector<int>(w, 30000));
    dp[0][0] = (s[0][0] == '#');
    rep(i,h-1){
        if(s[i+1][0] == '.') dp[i+1][0] = dp[i][0];
        else dp[i+1][0] = dp[i][0] + (s[i][0] == '.');
    }

    rep(i,w-1){
        if(s[0][i+1] == '.') dp[0][i+1] = dp[0][i];
        else dp[0][i+1] = dp[0][i] + (s[0][i] == '.');
    }

    for(int i = 1; i < h; i++) for(int j = 1; j < w ; ++j){
        if(s[i][j] == '#') dp[i][j] = min(dp[i-1][j] + (s[i-1][j] == '.') , dp[i][j-1] + (s[i][j-1] == '.'));
        else dp[i][j] = min(dp[i-1][j], dp[i][j-1]);
    }
    cout << dp[h-1][w-1] << endl;
}

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

using namespace std;

#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
#define ll long long

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

	int n;
	cin >> n;
	vector<int> v(n);
	for(int i = 0; i < n; i++) {
		cin >> v[i];
	}
	sort(all(v));
	int x = v[n / 2];
	int y = v[(n / 2) - 1];
	cout << abs(x - y) << "\n";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch November30 | diff November30.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address November30.cpp && ./a.out

/*
 
 12/1/2019
 
 4:00-
 
 */

int A,B,C,D;

void solve() {
  int res=(A!=C);
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>A>>B>>C>>D;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize "-O3"
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define NumberOfOnes __builtin_popcount
#define LSOne(S) (S & (-S))
#define ll long long
#define two pair<int,int>
#define twoll pair<ll,ll>
#define four pair<two,two>
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define y1 y1922
#define INF 1000000000000000000
#define P 1000000007
#define lmax 1000000000
#define nn 1000003
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define vi vector<int>
#define vll vector<ll>
#define vtwo vector<two>
#define ALL(container) (container).begin(), (container).end()
#define sz(container) (int)(container.size())
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define mid(a,b) (a+b>>1)
#define minN 0
#define maxN 10000000
#define na(x) ((x)<P?(x):(x)-P)
#define ab(a) (-(a)<(a)?(a):-(a))
#define FAST std::ios::sync_with_stdio(false)
#define xRand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define rnd rng
#define IT iterator
typedef
tree<
  int,// aq pair<int,int> shegidzlia
  null_type,
  less/*_equal*/<int>,// aqac
  rb_tree_tag,
  tree_order_statistics_node_update>
ordered_set;
// '_equal' mashin ginda roca multiset gchirdeba
template<class key, class value,class cmp = std::less<key>>
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;
ordered_map<int, int> my_map;
inline int rin(){
	int x=0,w=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if (ch=='-') w=0,ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
inline int bin(){
	int x=0;char ch=getchar();
	while (ch<'0'||ch>'9') ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x;
} 
int r1, r2, c1, c2;
ll iv[3000000], f1[3000000], f2[3000000]; 
ll nck(int n, int k) {
	return f1[n]*f2[k]%P*f2[n-k]%P;
}
int main(){FAST;xRand;
iv[1]=1;
for(int i=2; i<3000000; ++i)
	iv[i]=P-P/i*iv[P%i]%P;
f1[0]=f2[0]=1;
for(int i=1; i<3000000; ++i) {
	f1[i]=f1[i-1]*i%P;
	f2[i]=f2[i-1]*iv[i]%P;
}
cin>>r1>>c1>>r2>>c2;
cout<<((nck(r2+c2+2,c2+1)-nck(r1+c2+1,c2+1)-nck(r2+c1+1,c1)+nck(r1+c1,c1))%P+P)%P;
	// you should actually read the stuff at the bottom
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?), slow multiset operations
	* do smth instead of nothing and stay organized
	* unordered_map, hash_map, scanf, calculate answer instead of ans*K
*/
/*


                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
                 *   *   * *   *
                  *   *   *   *
                   *   * *   *
                     *  *   *
					   *  *


*/




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

int main() {
	int x, y;
	cin >> x >> y;
	if (4*x < y) {
		cout << "No" << endl;
		return 0;
	}
	rep(i, x+1) {
		if (i * 2 + (x - i) * 4 == y) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3632
// AOJ 2531 Avant-garde Art
// 2018.2.9 bal4u

#include <stdio.h>
#include <string.h>

#define INF 0x30303030
int a[8002];
int dp[8002];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int bsch(int x, int r)
{
	int m, l = 0;

    while (l < r) {
        m = l+((r-l)>> 1);
        if (dp[m] < x) l = m + 1; else r = m;
    }
	return l;
}

int main()
{
	int n, k, i, j, f, t, ans;

	n = in(), k = in();
	for (i = 0; i < n; i++) a[i] = in();

	ans = 0;
	for (i = 0; i < n; i++) {
		f = 0, memset(dp, INF, a[i]<<2);
		for (j = i; j < a[i]; j++) {
			if (a[i] >= a[j]) continue;
			t = bsch(a[j], f+1);
			dp[t++] = a[j];
			if (f < t) f = t;
		}
		f++;
		if (ans < f) ans = f;
	}
	ans += k; if (ans > n/2) ans = n/2;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2108
def main():
    primes = [11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491,
              521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031,
              1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381, 1451, 1471, 1481, 1511,
              1531]
    n = int(input())
    print(*primes[:n])

main()


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

int main() {
  vector<int> v(3);
  for (int i = 0; i < 3; i++) cin >> v[i];

  sort(v.begin(), v.end());
  if (v[0] == 5 && v[1] == 5 && v[2] == 7) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>

using namespace std;

const int MAX = 50;
const int INF = (1<<25);

bool come[MAX][MAX][MAX][MAX];
int M[MAX][MAX];
int w,h,stx,sty,skx,sky;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
struct data{
  int t,tx,ty,kx,ky;
  data(int t,int tx, int ty, int kx, int ky):t(t),tx(tx),ty(ty),kx(kx),ky(ky){}
};
queue<data> Q;

void init(){
  //fill(come[0][0][0],come[0][0][0]+MAX*MAX*MAX*MAX,INF);
  while(!Q.empty())Q.pop();
  memset(come,false,sizeof(come));
}

void input(){
  cin >> stx >> sty >> skx >> sky;
  for(int i = 0; i < h; i++)
    for(int j = 0; j < w; j++) cin >> M[i][j];
}

bool isMovable(int x, int y){return 0<=x&&x<w&&0<=y&&y<h&&M[y][x]==0;}

int bfs(){
  
  Q.push(data(0,stx-1,sty-1,skx-1,sky-1));

  while(!Q.empty()){
    data now = Q.front();
    Q.pop();

    if(now.t > 100) return -1;
    if(now.tx == now.kx && now.ty == now.ky) return now.t;
    
    if(come[now.tx][now.ty][now.kx][now.ky]) continue;
    come[now.tx][now.ty][now.kx][now.ky] = true;

     for(int i = 0; i < 4; i++){
      data nex = now;
      nex.tx += dx[i];
      nex.ty += dy[i];
      nex.kx -= dx[i];
      nex.ky -= dy[i];
      nex.t++;

      if(!isMovable(nex.tx,nex.ty)){
	nex.tx = now.tx;
	nex.ty = now.ty;
      }
      if(!isMovable(nex.kx,nex.ky)){
	nex.kx = now.kx;
	nex.ky = now.ky;
      }
      Q.push(nex);
    }
  }
  return -1;
}

void solve(){
  // dfs(0,stx-1,sty-1,skx-1,sky-1);
  int ans = bfs();
  if(ans == -1) cout << "NA" << endl;
  else cout << ans << endl;
}

int main(){
  while(cin >> w >> h && w+h){
    init();
    input();
    solve();
  }
  return 0;
}

Measured memory_bytes: 8392
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
int main() {
  int a, b;
  cin >>a >> b;
  if(a>=13)cout << b << endl;
  else if(a>=6)cout << b/2<< endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
  
#define max 100
  
int main(){
  int i,j,n,min,minj,ans=0;
  
  int data[max][max];
  int flag[max],d[max];
  
  scanf("%d",&n);
  
  for(i = 0 ; i < n ; i++){
    flag[i] = 0;
    d[i] = 2001;
  }
  d[0] = 0;
  
  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      scanf("%d",&data[i][j]);
    }
  }
  
  for(i = 0 ; i <= n ; i++){
    min = 2001;
      
    for(j = 0 ; j < n ; j++){
      if((d[j] < min) && (flag[j] == 0 )){
    min = d[j];
    minj = j;
      }
    }
    flag[minj] = 1;
    for(j = 0 ; j < n ; j++){
      if(data[minj][j] != -1 && data[minj][j] < d[j] && flag[j] ==0){
  
    d[j] = data[minj][j];
      }
    }
  }
  for(i = 0 ; i < n ; i++){
    ans += d[i];
  }
  printf("%d\n",ans);
  
  return 0;
  
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
const int MAX = 100000;

int main() {
	int N, c = 0;
	static int p[MAX];
	cin >> N;
	for (int i = 0;i < N;i ++)cin >> p[i];
	for (int i = 0;i < N;i ++) {
		if (p[i] == i + 1) {
			c ++;
			if (i != N - 1 && p[i + 1] == i + 2) i ++;
		}
	}
	cout << c;
	return 0;
}
/*
1、自分が(i番目かつi)でないなら→動かす必要がない(0手)
2、自分がi番目かつiなら
2.1、自分の次がi番目かつiなら→そこと入れ替えれば両方消える
2.2、自分の次が(i番目かつi)でないなら→とりあえずそこと入れ替え
結論:動的計画でおｋ
*/

Measured memory_bytes: 640
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = [0] + A
#print(A)

machi = 1
road = [0,1]
Keiyu = [0]*(N+1)

for n in range(1, N+1):
    if Keiyu[machi] == 0:
        Keiyu[machi] = n
        road.append(A[machi])
        machi = A[machi]
    else:
        S = Keiyu[machi] - 1
        E = n - 1
        break

#print(road)
#print(Keiyu)
#print(S)
#print(E)

if K <= S:
    print(road[K+1])
else:
    K = K - S
    K = S + K % (E-S)
    print(road[K+1])



Measured memory_bytes: 32292
#include <stdio.h>
int main(){
    int H,W,i,j;
    
    while(1){

    scanf("%d %d",&H,&W);
    if(H==0 && W==0) break;
    
    for(j=0;j<H;j++){
    for(i=0;i<W;i++){
        
        if(i!=0 && i!=W-1){
        if(j!=0 && j!=H-1) printf(".");
        else printf("#");
        }
        else printf("#");
    }
    
    printf("\n");
    }
    
    printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2028
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int mergecount(vector<int> &a) {
    int count = 0;
    int n = a.size();
    if (n > 1) {
        vector<int> b(a.begin(), a.begin() + n/2);
        vector<int> c(a.begin() + n/2, a.end());
        count += mergecount(b);
        count += mergecount(c);
        for (int i = 0, j = 0, k = 0; i < n; ++i)
        if (k == c.size())       a[i] = b[j++];
        else if (j == b.size())  a[i] = c[k++];
        else if (b[j] <= c[k])   a[i] = b[j++];
        else                   { a[i] = c[k++]; count += n/2 - j; }
    }
    return count;
}

int main() {
    int n; cin >> n;
    vector<int> a;
    rep(i,n){
        int a_; cin >> a_;
        a.push_back(a_);
    }

    ll ans = mergecount(a);

    sort(a.begin(), a.end());
    rep(i,n){
        cout << a[i];
        if(i!=n-1){
            cout << ' ';
        }
    } 
    cout << endl;

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



Measured memory_bytes: 3172
#include<stdio.h>

int main()
{
	int i,a,b,n,high;
	scanf("%d%d", &a, &b);
	n = b - a;
	high = 0;
	for (i = 1; i <= n; i++)
	{
		high = high + i;
	}
	printf("%d", high - b);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<string>
#include<string>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
#define ll long long
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int sum[3];
    sum[0]=a+b;
    sum[1]=b+c;
    sum[2]=c+a;
    sort(sum,sum+3);
    printf("%d\n",sum[0]);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#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 INF 1<<30

typedef pair<int,int> pii;

int dp[1000][1000];         // dp[i][j] : ³ i, ¼a j ÜÅÌÍÍÉ¨³Üé
int m,n;
int h1[100];
int r1[100];
int h2[100];
int r2[100];

int solve(int h, int r, int x, int y) { // x : êYÌðã©çÇ±ÜÅgÁ½©@y : ñY
  // printf("%d,%d  %d,%d ",h,r,x,y);
  if (dp[h][r]>=0) {
//    cout << dp[h][r] << endl;
    return dp[h][r];
  }
  //cout << endl;
  int res = 0;
  for (int i=x-1; i>=0; --i) {
    if (h>h1[i] && r>r1[i])
      res = max(res, solve(h1[i],r1[i],i,y));
  }
  for (int i=y-1; i>=0; --i) {
    if (h>h2[i] && r>r2[i])
      res = max(res, solve(h2[i],r2[i],x,i));
  }
  return dp[h][r] = res + 1;
}

int main() {
  while(cin >> n, n) {
    REP(i,n) 
      cin >> h1[i] >> r1[i];
    cin >> m;
    REP(i,m)
      cin >> h2[i] >> r2[i];
    memset(dp,-1,sizeof(dp));
    cout << max(solve(h1[n-1],r1[n-1], n-1, m), solve(h2[m-1],r2[m-1], n, m-1)) << endl;
  }
}

Measured memory_bytes: 0
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);
parse_tuple!(A, B, C, D);
parse_tuple!(A, B, C, D, E);

// ===

const INF: usize = 100010;

fn main() {
    let (n, c): (usize, usize) = read();
    let mut ranges = vec![vec![]; c];
    for _i in 0..n {
        let (s, t, ci): (usize, usize, usize) = read();
        ranges[ci-1].push((s, t));
    }

    let mut imo = vec![0; INF+10];
    for i in 0..c {
        ranges[i].sort();
        let mut mod_ranges = vec![];
        let mut last_s = INF;
        let mut last_t = INF;
        for &(s, t) in &ranges[i] {
            if s == last_t {
                last_t = t;
            } else {
                if last_t != INF {
                    mod_ranges.push((last_s, last_t));
                }
                last_s = s;
                last_t = t;
            }
        }
        if last_t != INF {
            mod_ranges.push((last_s, last_t));
        }
        for (s, t) in mod_ranges {
            imo[s] += 1;
            imo[t+1] -= 1;
        }
    }

    let mut ans = 0;
    for i in 0..INF {
        imo[i+1] += imo[i];
        ans = max(ans, imo[i+1]);
    }
    println!("{}", ans);
}


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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

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

  int MAX = max(A, B), MIN = min(A, B);
  if (MAX == 1) {
    cout << "1 2\n.#" << BR;
    return 0;
  }
  string S = ".#";
  if (MAX == A) S = "#.";

  int H = 90, W = 80;
  vector<vector<ll>> cells(H, vector<ll>(W , 0));

  int h = 1, w = 1;
  while(MAX > 1) {
    cells[h][w] = 1;
    if (w + 2 < W) {
      w += 2;
    } else {
      h += 3;
      w = 1;
    }
    MAX--;
  }

  if (MIN > 1) rep(i, h + 2, H) rep0(j, W) cells[i][j] = 1;
  else cells[H - 1][W - 1] = 1;

  h += 3;
  w = 1;
  MIN--;
  while(MIN > 0) {
    cells[h][w] = 0;
    if (w + 2 < W) {
      w += 2;
    } else {
      h += 3;
      w = 1;
    }
    MIN--;
  }

  cout << H << SP << W << BR;
  rep0(i, H) {
    rep0(j, W) {
      cout << S[cells[i][j]];
    }
    cout << BR;
  }

  return 0;
}

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

namespace AGC010Addition
{
    class Program
    {
        static void Main(string[] args)
        {
            int N;
            N = int.Parse(Console.ReadLine());
            string[] vals = Console.ReadLine().Split(' ');
            int A;
            int numOdd = 0;
            for (int i=0; i < N; i++)
            {
                A = int.Parse(vals[i]);
                if (A % 2 == 1)
                    numOdd++;
            }
            if (numOdd % 2 == 0)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}


Measured memory_bytes: 18016
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<iostream>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
using namespace std;
#define rep2(x,from,to) for(long long (x)=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 1000000000000000
long long n,C;
long long d[33][33];
long long c[505][505];
long long coun[3][33];
long long ans;
long long res;
int main()
{
    cin>>n>>C;
    ans=INF;
    rep(i,C)
    {
        rep(j,C)
        {
            cin>>d[i][j];
        }
    }
    rep(i,n)rep(j,n)cin>>c[i][j];
    rep(i,n)rep(j,n)c[i][j]--;
    rep(i,n)
    {
        rep(j,n)
        {
            coun[(i+j)%3][c[i][j]]++;
        }
    }
    rep(ci,C)
    {
        rep(cj,C)
        {
            rep(ck,C)
            {
                if((ci-cj)*(cj-ck)*(ck-ci)==0)continue;
                res=0;
                rep(i,C)
                {
                    res+=coun[0][i]*d[i][ci];
                    res+=coun[1][i]*d[i][cj];
                    res+=coun[2][i]*d[i][ck];
                }
                ans=min(ans,res);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2176
def can_not_realize(N, t_list, x_list, y_list) -> bool:
    # t_n と t_n+1 間 での移動判定
    for i in range(N):
        diff_t = t_list[i + 1] - t_list[i]
        diff_x = abs(x_list[i + 1] - x_list[i])
        diff_y = abs(y_list[i + 1] - y_list[i])

        sum_of_moving = diff_x + diff_y

        # 時刻t >= sum_of_moving でないと実現不可能
        if diff_t < sum_of_moving:
            return True

        # 偶奇が一致しないと実現不可能
        if not (diff_t % 2 == sum_of_moving % 2):
            return True

    return False

def actual(N, t_list, x_list, y_list):
    # t=0 で (0,0) を追加する
    t_list = [0] + t_list
    x_list = [0] + x_list
    y_list = [0] + y_list

    if can_not_realize(N, t_list, x_list, y_list):
        return 'No'

    return 'Yes'

N = int(input())

t_list, x_list, y_list = [], [], []

for _ in range(N):
  t, x, y = list(map(int, input().split()))
  t_list.append(t)
  x_list.append(x)
  y_list.append(y)
  
print(actual(N, t_list, x_list, y_list))

Measured memory_bytes: 14168
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<cmath>
using namespace std;

int ax,ay,bx,by,becx,becy;
double s,c,kyori;

void solve(int x,int y){

    int becp,becq;
    becp=(x-ax);
    becq=(y-ay);

    double d= sqrt((double)becp*(double)becp+(double)becq*(double)becq);
    if(d==0) cout<<x<<" "<<y<<endl;
    else{
    double cc=((double)becx*(double)becp+(double)becy*(double)becq)/(d*kyori);
    double k = d*cc;
    double ansx,ansy;
    ansx=(double)ax+ k*c;
    ansy=(double)ay+ k*s;
    printf("%.8f %.8f\n",2*ansx-x, 2*ansy-y);
    }
}

int main(){

cin>>ax>>ay>>bx>>by;

kyori= sqrt(((double)ax-(double)bx)*((double)ax-(double)bx)+((double)ay-(double)by)*((double)ay-(double)by));
s=((double)by-(double)ay)/kyori;
c=((double)bx-(double)ax)/kyori;
becx=(bx-ax);
becy=(by-ay);
int n,x,y;
cin>>n;
for(int i=0;i<n;i++){
    cin>>x>>y;

    solve(x,y);
}

    return 0;
}


Measured memory_bytes: 3232
#include <stdio.h>
char exchange(char c) {
      if('A' <= c && c <= 'Z') {
          return c + ('a' - 'A');
      }
      if('a' <= c && c <= 'z') {
          return c - ('a' - 'A');
      }
      else return c;
  }
int main(void){
   char ch;
   while(1){
   scanf("%c" ,&ch);
  // printf("%c", ch);
   printf("%c" , exchange(ch));
   if(ch == '\n') break;
   }
  return 0;
}


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

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

  if ( a%2 == 1 && b%2 == 1 ) {
    cout << "Odd" << endl;
  }
  // ここにプログラムを追記
  else{
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
#include<map>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
#include<bitset>
#include<climits>
#include<list>
#include<iomanip>
#include<stack>
#include<set>
#include<ctime>
#define pb push_back
#define pii pair<int,int>
#define LL long long int
using namespace std;
const int MAXN=105;
const int MAXM=1005;
int n,m,C;
bool vis[MAXN][MAXM]={0};
int dp[MAXN][MAXM]; // dp[i][j]表示 从初始点到 i ?点修改 j 条??最小的花?
vector<pii >G[MAXN];
void spfa(int s){
    pii now;
    queue<pii >q; //（i?点，改j条?）
    dp[s][0]=0;
    q.push(make_pair(s,0));
    vis[s][0]=1;
    while(!q.empty()){
        int now_v=q.front().first,now_c=q.front().second;q.pop();
        if(now_c>m) continue; //修改?数大余了??数
        vis[now_v][now_c]=0;
        for(int i=0;i<G[now_v].size();++i){
            int next_v=G[now_v][i].first,w=G[now_v][i].second;

            if(dp[next_v][now_c+1]>dp[now_v][now_c]){ //修改?
                dp[next_v][now_c+1]=dp[now_v][now_c];
                if(!vis[next_v][now_c+1]) {
                    q.push(make_pair(next_v,now_c+1));
                    vis[next_v][now_c+1]=1;
                }
            }
            if(dp[now_v][now_c]+w<=C&&dp[next_v][now_c]>dp[now_v][now_c]+w){ //不修改?
                dp[next_v][now_c]=dp[now_v][now_c]+w;
                if(!vis[next_v][now_c]){
                    q.push(make_pair(next_v,now_c));
                    vis[next_v][now_c]=1;
                }
            }

        }
    }
    for(int i=0;i<=m;++i){
        if(dp[n][i]!=0xfffffff) {
            cout<<i<<endl;
            return;
        }
    }
}
int main(){
    int a,b,c;
    while(scanf("%d%d%d",&n,&m,&C)!=EOF){
        memset(vis,0,sizeof(vis));
        for(int i=0;i<MAXN;++i) for(int j=0;j<MAXM;++j) dp[i][j]=0xfffffff;
        for(int i=0;i<=n;++i) G[i].clear();
        for(int i=0;i<m;++i){
            scanf("%d%d%d",&a,&b,&c);
            G[a].pb(make_pair(b,c));
        }
        spfa(1);
    }
}

Measured memory_bytes: 1768
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long a=sc.nextLong(),b=sc.nextLong(),f=1;
    if(a<=0&&b>=0){
      System.out.println("Zero");
    }else if(a>0){
      System.out.println("Positive");
    }else{
      if((b-a)%2==0){
        System.out.println("Negative");
      }else{
        System.out.println("Positive");
      }
    }
  }
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
const unsigned int M = 1000000007;
#define ll long long
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int k, n;
    while(cin>>n>>k){
        cout<<(6-(n+k))<<endl;
    }
    return 0;
}


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

using namespace std ; 
const int N =1e5 + 7  ; 

int n , w ; 

long long ans[N] ; 

int main(){
    
    ios_base::sync_with_stdio(0) ; 
    cin.tie(0) ; 
    //freopen("in.in" , "r" , stdin) ; 

    cin>>n>>w ; 

    for(int i = 1 ; i < N ; i++){
        ans[i] = - 1e9  ;
    }

    for(int i = 0 ;i < n ;i++){
        int a , b; 
        cin>>a>>b ; 
        for(int j = w - a  ; j >=0 ; j--){
            ans[j+a] = max(ans[j+a] , ans[j] + b) ; 
        }
    }
    long long sol = 0 ; 
    for(int i = 0 ;i <=w ;i++){
        sol = max(sol , ans[i]) ; 
    }
    cout<<sol ;
    return 0 ; 
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int main(){
    int H; cin >> H;
    int W; cin >> W;
    int h; cin >> h;
    int w; cin >> w;
    int all = H * W;
    all -= h*W + w*H;
    all += h * w;
    cout << all << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
#define P pair<int, int>
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;
ll modpow(ll, ll);
ll comb(ll, ll);


int main()
{
	ll x, y; cin >> x >> y;
	if ((2 * x - y) % 3 != 0 || (2 * y - x) % 3 != 0 || (2 * x - y) < 0 || (2 * y - x) < 0)
	{
		co(0);
		return 0;
	}
	else
	{
		ll a = (2 * x - y) / 3;
		ll b = (2 * y - x) / 3;
		ll ans = comb(a + b, a);
		co(ans);
	}
	return 0;
}

ll modpow(ll a, ll p)
{
	if (p == 0)return 1;
	else if (p == 1)return a;
	else if (p % 2 == 0)return (modpow(a, p / 2) * modpow(a, p / 2)) % mod;
	else return (modpow(a, p - 1) * a) % mod;
}

ll comb(ll n, ll m)
{
	if (n / 2 < m)return comb(n, n - m);
	ll resMul = 1;
	ll resDiv = 1;
	for (ll i = 1; i <= m; i++)
	{
		resMul *= (n - i + 1);
		resMul %= mod;
		resDiv *= i;
		resDiv %= mod;
	}
	ll res = (resMul * modpow(resDiv, mod - 2)) % mod;
	return res;
}


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

main(){
	int N;
	cin  >> N;
	int H[N];
	for (int i = 0;i<N;i++){
		cin >> H[i];
	}
	int min = 101;
	int Loop = 1;
	int count = 0;
	int start = -1;
	int last = N;
	while(Loop){
		for (int i = 0;i<N;i++){
			if (H[i] != 0){
				start = i;
				break;
			}
		}
		if(start == -1){
			Loop = 0;
			break;
		}
		for (int i = start + 1;i<N;i++){
			if (H[i] == 0){
				last = i;
				break;
			}
		}
		for (int i = start;i<last;i++){
			if (min > H[i]){
				min = H[i];
			}
		}
		for (int i = start;i<last;i++){
			H[i] = H[i] - min;
		}
		count = count + min;
		start = -1;
		last = N;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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()
#define CMAX(m, x)  m = max(m,x);
#define CMIN(m, x)  m = min(m,x);
#define itn int
typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
int main(){
    int n, m;
    cin >> n >> m;
    vector<int> tem(n);
    vector<int> da(n,-1);
    REP(i,n)
        cin >> tem[i];
    int cnt = 0;
    REP(i,m){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        if(tem[a] > tem[b] && da[a] != 0){
            da[a] = 1;
            da[b] = 0;
        }else if(tem[a] < tem[b] && da[b] != 0){
            da[b] = 1;
            da[a] = 0;
        }else{
            da[a] = 0;
            da[b] = 0;
        }
    }
    REP(i,n){
        if(da[i] != 0)
            cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
ll ans=0;
ll gcd(ll a,ll b){
  if(!b) return ans=ans-a;
  ans+=a/b*b*2;
  gcd(b,a%b);
}
int main(){
    ll n,x;
    cin>>n>>x;
    cout<<gcd(n-x,x)+n;
}

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

int A = 0, B = 0, j;

int main(){
    for(;;){
        if(cin >> j){
            A = 0;
            B = 0;
            if(j == 0){
                break;
            }
            for(int i = 0; i < j; i++){
                int as, bs;
                cin >> as >> bs;
                if(as > bs){
                    A += as + bs;
                }else if(as < bs){
                    B += as + bs;
                }else{
                    A += as;
                    B += bs;
                }
            }
            cout << A << " " << B << endl;
        }else{
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int L,R, d; cin >>L>>R>>d;
  auto num = [](int a, int n) {
    int ret = 0;
    ret += a/n;
    return ret;
  };
  int ans = num(R, d) - num(L-1, d);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3588
import java.util.*;

public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(System.in);
        String c = sc.nextLine();
        switch (c){
            case "SUN":
                System.out.println("7");
                break;
            case "MON":
                System.out.println("6");
                break;
            case "TUE":
                System.out.println("5");
                break;
            case "WED":
                System.out.println("4");
                break;
            case "THU":
                System.out.println("3");
                break;
            case "FRI":
                System.out.println("2");
                break;
            case "SAT":
                System.out.println("1");
                break;
        }
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
deque<int> Q;
int main()
{
	bool h=0;
	int n,x;cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if(!h) Q.push_back(x);
		else   Q.push_front(x);
		h^=1;
	}
	if(!h)
		while(!Q.empty())
		{
			printf("%d ",Q.front());
			Q.pop_front();
		}
	else
		while(!Q.empty())
		{
			printf("%d ",Q.back());
			Q.pop_back();
		}
	return 0;
}

Measured memory_bytes: 2944
n = int(input())
a = list(map(int, input().split()))
m = {}

def addToMap(v):
    if v in m:
        m[v] += 1
    else:
        m[v] = 1

for i in range(n):
    v1, v2, v3 = a[i]-1, a[i], a[i]+1
    addToMap(v1)
    addToMap(v2)
    addToMap(v3)

maxK = 0
maxV = 0

for key, val in m.items():
    if val > maxV:
        maxK = key
        maxV = val

print(maxV)


Measured memory_bytes: 64236
# 深さdの現実的な上限を先に決める
N = int(input())
# Aは，葉として残す必要があるものの数
A = list(map(int, input().split()))

# 深さdのノード数の上限
limit = [1]  # ルートのノードの上限数 : 当然1
for d in range(1, N+1):
    if d == N:  # 1番深いところの上限はA[N]
        limit.append(A[d])
    else:
        limit.append((limit[-1]-A[d-1])*2)
        if limit[-1] < 0:
            print(-1)
            exit()

# Nが0の時の処理
if N == 0:
    if A[0] != 1:
        print(-1)
        exit()

# 1番深いところから構築して最後にsumを取る
ans = [limit[-1]]
# 1番深いところから構築しており，今現在のオードの数
now_node = limit[-1]
for d in range(N-1, -1, -1):
    ans.append(min(now_node+A[d], limit[d]))
    now_node = ans[-1]  # 現在のノードの数

# 構築したものに対してジャッジする
ans.reverse()
for d in range(N):
    if (ans[d]-A[d])*2 < A[d+1]:
        print(-1)
        exit()
print(sum(ans))


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

const int MAX = 100005;

int binarySearch(int A[], int n, int key) {
  int left = 0;
  int right = n;
  int mid {0};
  int index = -1;
  while (left < right) {
    mid = (left + right) / 2;
    if (A[mid] == key) {
      return mid;
    } else if (A[mid] > key) {
      right = mid;
    } else if (A[mid] < key) {
      left = mid + 1;
    }
  }
  return index;
}

int main() {
  // input
  int n {0}, q{0}, cnt {0};
  int S[MAX];
  int T[MAX];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> S[i];

  cin >> q;
  for (int i = 0; i < q; i++) cin >> T[i];

  // main part
  for (int i = 0; i < q; i++) {
    if (binarySearch(S, n, T[i]) != -1) cnt++;
  }
  cout << cnt << endl;

  return 0;
}



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

using namespace std;

typedef long long ll;

const ll INF = -1145141919810;

int N, W;
ll dp[100][100001];
int weight[100], value[100];

int main() {
	cin >> N >> W;
	for (int i = 0; i < N; i++) {
		cin >> weight[i] >> value[i];
	}

	for (int i = 0; i < N; i++)
		for (int j = 0; j <= W; j++)dp[i][j] = INF;

	dp[0][0] = 0;
	dp[0][weight[0]] = value[0];

	for (int i = 1; i < N; i++) {
		for (int j = 0; j <= W; j++) {
			dp[i][j] = dp[i - 1][j];
			if (j - weight[i] >= 0) {
				dp[i][j] = max(dp[i - 1][j - weight[i]] + value[i], dp[i][j]);
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i <= W; i++) {
		ans = max(ans, dp[N - 1][i]);
	}
	cout << ans << endl;
	return 0;
}

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

color_n = [0 for i in range(9)]

for i in a:
    if 1 <= i <= 399:
        color_n[0] += 1
    
    elif 400 <= i <= 799:
        color_n[1] += 1
    
    elif 800 <= i <= 1199:
        color_n[2] += 1
    
    elif 1200 <= i <= 1599:
        color_n[3] += 1
    
    elif 1600 <= i <= 1999:
        color_n[4] += 1
    
    elif 2000 <= i <= 2399:
        color_n[5] += 1
    
    elif 2400 <= i <= 2799:
        color_n[6] += 1
    
    elif 2800 <= i <= 3199:
        color_n[7] += 1
    
    else:
        color_n[8] += 1

print(max(8-color_n[:-1].count(0), 1),8-color_n[:-1].count(0)+color_n[-1])
    


Measured memory_bytes: 38384
#include<stdio.h>
void f(int *a,int *b){
  int i,j;
  scanf("%d:%d-%d:%d",&i,a,&j,b);
  *a+=60*i;
  *b+=60*j;//printf("%d %d\n",*a,*b);
}
int main(){
  int n,m,i,k,s,t,d[110][2],h[110]={};
  int a[110]={};
  int b[110]={};
  scanf("%d",&n);
  for(i=0;i<n;i++)f(&d[i][0],&d[i][1]);
  scanf("%d",&m);
  while(m--){
    scanf("%d",&k);
    while(k--){
      f(&s,&t);
      for(i=0;i<n;i++){
	if(s<=d[i][0]&&d[i][1]<=t)a[i]++;
      }
    }
  }
  scanf("%d",&m);
  while(m--){
    scanf("%d",&k);
    while(k--){
      f(&s,&t);
      for(i=0;i<n;i++){
	if(s<=d[i][0]&&d[i][1]<=t)b[i]++;
      }
    }
  }
  for(i=m=0;i<n;i++)m+=a[i]<b[i]?a[i]:b[i];
  printf("%d\n",m);
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
int fx4[] = {1 , -1 , 0 , 0};
int fy4[] = {0 , 0 , 1 , -1};
int Kfx[]= {-2,-2,2,2,1,1,-1,-1}; ///knight move x - exis
int Kfy[]= {1,-1,1,-1,2,-2,2,-2}; ///knight move y- exis
int fx8[]= {1,1,1,0,0,-1,-1,-1};
int fy8[]= {0,1,-1,1,-1,0,1,-1};
#define ll long long int
#define pii pair<int,int>
#define llu unsigned long long
#define inf 1<<28
#define gama 0.57721566490
#define PI              acos(-1.0)
#define INF             0x7fffffff
#define MOD             1000000007
#define EPS             1e-7
#define all(r)(r).begin(),(r).end()
/*
bool status[mx];
void sieve(){
   long long int  i,j;
    for(i=2;i<=mx;i++)
    {
        status[i]=0;
    }
    for( i=2;i<=sqrt(mx);i++){
        if(status[i]==0)
        {
            for(j=i*i;j<=mx;j+=i){
                status[j]=1;
            }
        }
    }
}*/
ll BM( ll a , ll b , ll m )
{
    if ( b == 0 ) return 1 ;
    ll x = BM(a,b/2,m);
    x = (( x % m) * (x % m))%m;

    if( b % 2 ) x = (( x % m) * (a %m)) % m ;
    return x ;
}
#define dd double
#define sc scanf
#define pr printf
#define VI vector<int>
#define VS vector<string>
#define VC vector<char>
#define VLL vector<long long int>
#define FILE freopen("input.txt","rt",stdin); freopen("output.txt","w",stdout);
#define p_b push_back
#define mem(x,y) memset(x,y,sizeof(x))
#define F(i,a,b) for(i=a;i<=b;i++)
#define sc1(a) scanf("%d",&a)
#define scL1(a) scanf("%lld",&a)
#define scL2(a,b) scanf("%lld%lld",&a,&b)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define fori(N)          for(int i = 0; i<(N); i++)
#define forj(N)         for(int j = 0; j<(N); j++)
#define fork(N)         for(int k = 0; k<(N); k++)
#define forl(N)         for(int l = 0; l<(N); l++)
#define ford(N)         for(int d = 0; d<(N); d++)
#define fori1(N)          for(int i = 1; i<=(N); i++)
#define forj1(N)         for(int j = 1; j<=(N); j++)
#define fork1(N)         for(int k = 1; k<=(N); k++)
#define ford1(N)         for(int d = 1; d<=(N); d++)
#define sqr(x)           (x)*(x)
#define TEST int test,te=0;cin>>test;
#define segment_tree int l=(n*2),r=(n*2)+1,mid=(l+r)/2
#define Mx 100005
#define mx 10005

int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);///Beware of use it, if u use it dont use scanf or printf
	string a;
	int n;
	cin>>n>>a;
	int cnt=0;
	for(int i=0;i<a.size();i++){
		if(i==0 or i==1)continue;
		if(a[i]=='C'){
			if(a[i-1]=='B' and a[i-2]=='A')cnt++;
		}
	}
	cout<<cnt<<endl;    
}


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

int main() {
 int N;
  map<int,int>memo;
  int a;
  cin >>N;
  for(int i=0;i<N;i++){
  cin >>a;
  memo[a]=i+1;
  }
   for(int i=0;i<N-1;i++){
  cout <<memo[i+1]<<' ';
  }
  cout <<memo[N]<<endl;
}


Measured memory_bytes: 5504
/*        ~ABC 171~
 *    code by kazalika   */
#include <bits/stdc++.h>
using namespace std;



int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for (int i = 0; i < n; ++i)
    cin >> p[i];
  int ans = 0;
  sort(p.begin(), p.end());
  for (int i = 0; i < k; ++i)
    ans += p[i];
  cout << ans;
}

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

int main() {
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  
  int sum = 0;
  if ( (N - K) > 0 ){
    sum = K * X + (N - K) * Y;
  }
  else {
    sum = N * X;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,x) for(ll i=0;i<x;i++)
#define INF 1e18
typedef long long ll;
using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int> X(N);
    REP(i,N)cin>>X[i];
    sort(X.begin(),X.end());
    ll ans=INF;
    REP(i,X[N-1]){
        ll anss=0;
        REP(j,N){
            anss+=pow(i+1-X[j],2);
        }
        ans=min(ans,anss);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256