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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(12);
    }
} fast;

/* template */
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) (x).erase(unique(all(x)), (x).end())
#define int long long

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

/* const */
const int inf = 1e9 + 7;

/* main */
signed main(void)
{
    string s;
    cin >> s;
    string sc;
    sc = s;
    eunique(sc);
    rep(i, sc.size())
    {
        if (count(all(s), sc[i]) % 2 != 0)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
   int n = 0,x = 0;;
   scanf("%d%d", &n, &x);
   int l[n];
   for(int i = 0; i < n; i++) {
      scanf("%d", &l[i]);
   }
   int i = 1;
   int d = 0;
   while(1) {
      d += l[i-1];
      if(d <= x) {
         i++;
         continue;
      }
      break;
   }

   printf("%d\n", i);
   return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mem(a,b) memset((a),(b),sizeof(a))
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
using namespace std;
#define _GLIBCXX_PERMIT_BACKWARD_HASH
#include <ext/hash_map>
using namespace __gnu_cxx;
struct str_hash{size_t operator()(const string& str)const{return __stl_hash_string(str.c_str());}};
typedef long long ll;
typedef unsigned long long ull;
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDD pair<double,double>
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-6;
const int MAX=1e5+10;
const ll mod=1e9+7;
int main()
{
	int n,s;
	char a[111];
	while(~scanf("%d",&n))
	{
		sprintf(a,"%d",n);
		s=0;
		for(int i=0;i<strlen(a);i++) s+=a[i]-'0';
		if(n%s==0) puts("Yes");
		else puts("No");
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();//点の数
      	int d = sc.nextInt();//距離
        long x[] =new long[n];
        long y[] =new long[n];
      	int count=0;
      
      for(int i=0;i<n;i++){
        x[i]=sc.nextLong();      
        y[i]=sc.nextLong(); 
      }
      
      for(int i=0;i<n;i++){
    	if(Math.sqrt(x[i]*x[i]+y[i]*y[i])<=d){
			count+=1;
        }
      }
      
     System.out.println(count); 
    } 
}








Measured memory_bytes: 64052
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
int n,d;
cin>>n>>d;
int a[n][d];
for(int i=0;i<n;i++)
{
for(int o=0;o<d;o++)
{
cin>>a[i][o];
}
}
int res=0;
for(int i=0;i<n;i++)
{
for(int o=i+1;o<n;o++)
{
    int cnt=0;
for(int j=0;j<d;j++)
{
cnt+=(a[i][j]-a[o][j])*(a[i][j]-a[o][j]);
}
int h=sqrt(cnt);
if(h*h==cnt)
{
res++;
}
}
}
cout<<res<<endl;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int a[n];bool dp[k+1];
	dp[0]=false;
	for(int i=1;i<=k;i++){
		dp[i]=false;
	}
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=k;i++){
		for(int j=0;j<n;j++){
			if(i>=a[j]){
				dp[i]=dp[i]||(!dp[i-a[j]]);
			}
		}
	}
	// for(int i=0;i<k;i++){
	// 	cout<<dp[i]<<endl;
	// }
	if(!dp[k]){
		cout<<"Second"<<endl;
	}
	else{
		cout<<"First"<<endl;
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


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

ll od(ll n, ll m) {
	if (m%n != 0) { return 0; }

	return od(n, m / n)+1;
}


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

	vector<ll> a(N + 1);
	repn(i, N) cin >> a[i];

	string ans = "second";

	repn(i, N) {
		if (a[i] % 2 == 1) { ans = "first"; }
	}

	cout << ans;

	

	system("PAUSE");
}


Measured memory_bytes: 1272
#include <stdio.h>
int main(){
	long long n;
	for(;~scanf("%lld",&n)&&n;){
		long long r=0;
		int i=2;
		for(;;i++){
			long long x=n-(long long)i*(i-1)/2;
			if(x<i)break;
			if(x%i==0)r++;
		}
		printf("%lld\n",r);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;


int main(){
    int X; cin >> X;
    if (X >= 30){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;
int minn(int i,int j)
{
    if(i<j){
        return i;
    }
    else return j;
}
int main()
{
    int a,b,c,d,k,h;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
    k=minn(a,b);h=minn(c,d);
    printf("%d\n",k+h);
    return 0;
}

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


int main () {
    int n, w, i, j, itmv, itmw, v1, v2;
    int value[100], weight[100];
    int **wv, *wv_data;

    scanf("%d %d", &n, &w);
    for (i=0; i<n; i++) {
        scanf("%d %d", &value[i], &weight[i]);
    }

    wv_data = (int*)malloc(sizeof(int) * (n+1) * (w+1));
    wv = (int**)malloc(sizeof(int*) * (n+1));
    for (i = 0; i <= n; i++) {
        wv[i] = &(wv_data[i*(w+1)]);
    }

    for (i=0; i <= w; i++) {
        wv[0][i] = 0;
    }
    for (i=1; i <= n; i++) {
        wv[i][0] = 0;
    }

    for (i = 1; i <= n; i++) {
        itmv = value[i-1];
        itmw = weight[i-1];
        for (j = 1; j <= w; j++) {
            if (j >= itmw) {
                v1 = wv[i-1][j-itmw] + itmv;
                v2 = wv[i-1][j];
                wv[i][j] = v1 > v2 ? v1 : v2;
            }
            else {
                wv[i][j] = wv[i-1][j];
            }
        }
    }
    printf("%d\n", wv[n][w]);

    free(wv_data);
    free(wv);

    return 0;
}

Measured memory_bytes: 4516
package main

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

func main() {
	n := getInt()
	ans := float64((n+1)/2) / float64(n)

	fmt.Println(ans)
}

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

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

func getFloat() float64 {
	f, err := strconv.ParseFloat(getString(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

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


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

typedef struct{
	long long a;
	long long b;
}data;

int sortfnc(const void *x,const void *y){return ((data*)x)->a - ((data*)y)->a;}

int main(void){
	long long n,k,a,b,i;
	data p[131072];
	scanf("%lld%lld",&n,&k);
	for(i = 0;i < n;i++){
		scanf("%lld%lld",&a,&b);
		p[i].a=a;p[i].b=b;
	}
	qsort(p,n,sizeof(data),sortfnc);
	for(i = 0;i < n;i++){
		if(p[i].b >= k){printf("%lld\n",p[i].a);return 0;}
		k-=p[i].b;
	}
	return 0;
}

Measured memory_bytes: 3324
#include<iostream>
using namespace std;
int n,A[1<<17];
main()
{
    cin>>n;
    int id=0;
    for(int i=0;i<n;i++)
    {
        cin>>A[i];
        if(A[id]>A[i])id=i;
    }
    cout<<id+1<<endl;
}


Measured memory_bytes: 3492
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1) 

const ll INF = 10010001010;
const int inf = 2000000000;


typedef tuple<string, int, int> TUP;

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

int main()
{
    int A, B;
    cin >> A >> B;
    if(B%A == 0){
        cout << A + B << endl;
    }
    else{
        cout << B - A << endl;
    }
}


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

int main() {
	int n; cin >> n;
	ll sum = 0;
	rep(i, n) {
		ll v; cin >> v;
		sum += v;
	}
	cout << sum / n << endl;
}

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

int main() {
	int n, h, mx = 0, ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> h;
		if (h >= mx) {
			ans++;
			mx = h;
		}
	}
	cout << ans << endl;
}

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

int main(){
  string S;
  cin >> S;
  if(S.at(2)==S.at(3) && S.at(4)==S.at(5)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
    

Measured memory_bytes: 3576
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

bool Solve(const vector<int> take, int a, int b) {
  vector<bool> can(51);
  can[a] = true;
  for (int x : take) for (int i = 0; i <= 50; ++i) if (can[i]) can[i % x] = true;
  return can[b];
}

bool Solve(vector<int> take, int k, const vector<int>& a, const vector<int>& b) {
  for (int i = 1; i <= k; ++i) take.push_back(i);
  sort(take.rbegin(), take.rend());
  for (int i = 0; i < a.size(); ++i) if (!Solve(take, a[i], b[i])) return false;
  return true;
}

int main()
{
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> b[i];
  vector<int> take;
  if (!Solve(take, 50, a, b)) {
    cout << -1 << endl;
    return 0;
  }
  while (!Solve(take, 0, a, b)) {
    int k = 1;
    while (!Solve(take, k, a, b)) k++;
    take.push_back(k);
  }
  ll result = 0;
  for (ll x : take) result |= 1LL << x;
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a,b,k,i;
	scanf("%d %d %d",&a,&b,&k);
	for(i=0;i<k;i++){
		if(a+i > b){
			break;
		}
		printf("%d\n",a+i);
	}
	for(i=k-1;i>=0;i--){
		if(b-i <= a+k-1){
			continue;
		}
		printf("%d\n",b-i);
	}
}

Measured memory_bytes: 128
#n=int(input())
a,b,c=map(int,input().split())
k=int(input())
t=0
while(b<=a):
  b=b*2
  t+=1
while(c<=b):
  c=c*2
  t+=1
if t>k:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 9176
#include <iostream>

int main()
{
    int n;
    std::cin >> n;
    long long ans = 0;
    for (int i=1; i<=n; ++i) {
        long num = n / i;
        ans += i * (num * (num + 1) / 2);
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 3612
import math
t=input().split(' ')
a=int(t[0]);b=int(t[1]);x=int(t[2])
if x>=a**2*b*0.5:
    print(math.degrees(math.atan(2*b/a-2*x/a**3)))
else:
    print(math.degrees(math.atan(a*b**2/(2*x))))

Measured memory_bytes: 3060
while True:
    a,b = map(int,input().split())
    if a == 0 or b == 0:
        break
    else:
        for i in range(1, a+1):
            if i %2 ==1:
                s = '#.' * b
                print(s[:b])
            else:
                t='.#' * b
                print(t[:b])
            if i == a:
                print('')


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

int main() {
  int a;
  cin >> a ;
  
 if (a <1200 ){
  cout << "ABC" <<endl;
}
  else if (a <2800){
    cout << "ARC" <<endl;
  }
  else{
    cout << "AGC" << endl;
}
}
  




Measured memory_bytes: 256
function Main(input) {
  var A = parseInt(input.split(" ")[0]);
  var B = parseInt(input.split(" ")[1]);
  
  var plus = A + B;//-32
  var multi = A * B;//-33
  var minus = A - B;//-34
  
  console.log(Math.max(plus,multi,minus));
  
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include <iostream>
#include <algorithm>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
#include <string>
#include <iostream>
using namespace std;

int main() {
	
	int N;
	string M;
	cin >> N >>M;
		if (N >= 3200) {
			cout << M << endl;
		}
		else{
			cout << "red" << endl;
	}
		
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
 int n,m,x;
  cin >> n >>m >>x ;
  vector<int> P(m+1);
  for(int i=0;i<m;i++){
    cin >>P.at(i);}
  P[m]=0;
  sort(P.begin(), P.end()); 
  int cnt_a=0;
  int cnt_b=0;
for(int i=0;i<m+1;i++){
if(P[i] !=0 && P[i] <= x-1)cnt_a++;
  if(P[i] >= x+1 && P[i] <= n-1)cnt_b++;
  

}
  
  cout << min(cnt_a,cnt_b) <<endl;
  
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
	int n,x=0,maxVal =0;
	string s;
	
	scanf("%d",&n); getchar();
	cin>>s;
	//cout<<s<<endl;
	for(int i=0;i<n;i++){
		s[i] == 'D' ? x-- : x++;
		//printf("%c %d\n",s[i], x);
		maxVal = max(maxVal,x);
	}
	printf("%d\n",maxVal);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		
		int count = 0;
		for(int i = 0; i<s.length(); i++) {
			if(s.charAt(i) == '1') count++;
		}
		
		System.out.println(count);
	}

}


Measured memory_bytes: 22996
#include <iostream>
#include <vector>

using namespace std;

int dist(int& x, int& y) {
	return abs(x - y);
}
int minCost(int n, vector <int>& h) {
	vector <int> dp(n + 1, 0);
	dp[2] = dist(h[0], h[1]);
	for (int i = 3; i <= n; ++i) {
		dp[i] = min(dist(h[i - 1], h[i - 2]) + dp[i - 1], 
dist(h[i - 1], h[i - 3]) + dp[i - 2]);
}
	return dp[n];
}


int main() {
	int n, x;
  	cin >> n;
  	vector <int> v;
  	for(int i = 0; i < n; ++i) 
      cin >> x, v.push_back(x);
  	cout << minCost(n, v) << endl;
}



Measured memory_bytes: 1144
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

// #define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << H << " ";
    debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

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

double a, b, x;
double res;
double pi = acos(-1);

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    cin >> a >> b >> x;
    if (a*a*b/2 < x) {
        // x = a * a * (b - a tanθ / 2)
        res = atan (2 * (b - x / a / a) / a);
    } else {
        // x = a * b * b / (2 * tanθ)
        res = atan (a * b * b / 2 / x);
    }
    cout << res * 180 / pi << '\n';

    return 0;
}


Measured memory_bytes: 4036
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#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(x) (x).begin(),(x).end()
signed main(){
    int n,k;
    cin>>n>>k;
    if(k==0){
        cout<<n*n<<endl;
        return 0;
    }
    int ans=0;
    FOR(i,k+1,n+1){
        //cerr<<i<<" "<<(i-k)*(n/i)+(n%i-k<0?0:n%i-k+1)<<endl;
        ans+=(i-k)*(n/i);
        if(n%i==k){
            ans++;
        }else if(n%i-k>=0){
            ans+=n%i-k+1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n,c=map(int,input().split())
xv=[list(map(int,input().split()))for _ in range(n)]
l=[0]
s=0
for x,v in xv:
	s+=v
	l.append(max(l[-1],s-x))
r=[0]
s=0
for x,v in xv[::-1]:
	s+=v
	r.append(max(r[-1],s-(c-x)))
ans=max(l+r)
s=0
for i in range(n):
	s+=xv[i][1]
	ans=max(ans,s-2*xv[i][0]+r[n-i-1])
s=0
for i in range(n-1,-1,-1):
	s+=xv[i][1]
	ans=max(ans,s-2*(c-xv[i][0])+l[i])
print(ans)

Measured memory_bytes: 36964
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


if __name__ == '__main__':
    N, M = map(int, input().split())
    PY = []
    for i in range(M):
        P, Y = map(int, input().split())
        PY.append([Y, P, i + 1])
    PY.sort()

    # cnt: key=県, value=すでに幾つの市がその県に属しているか
    # res: [市の番号, 県の番号, 順番]
    cnt = {}
    res = []
    for y, p, i in PY:
        if p not in cnt:
            cnt[p] = 1
        else:
            cnt[p] += 1
        res.append([i, p, cnt[p]])

    res.sort()
    for i, p, x in res:
        print('{:06}{:06}'.format(p, x))


Measured memory_bytes: 42172
N = int(input())
A = list(map(int, input().split()))

B = [0] * N # どの箱にボールを入れたかのリスト（0,1のみ入る）
ans = [] # ボールを入れた箱のインデックスを格納するリスト

for n in range(N-1,-1,-1): # 箱は、後ろから見ていく
  num = 0 # その箱の倍数の箱に入っているボールの合計数
  
  # その箱の倍数の箱に入っているボールの個数を計上
  for j in range(2*(n+1), N+1 , n+1): 
    num += B[j-1]
    
  # 合計数がAと一致していない場合
  if num % 2 != A[n]:
    B[n] = 1
    ans.append(n+1)

count = len(ans)
print(count)
if count > 0:
    print(' '.join(map(str, ans)))

Measured memory_bytes: 19816
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  int k,x;cin >> k>>x;
  for(int i = max(x-k+1, -1000000);i<= min(x+k-1,1000000);++i){
    cout << i << " ";
  }
  return 0;
}


Measured memory_bytes: 256
import fractions

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

Measured memory_bytes: 5048
#include<stdio.h>
int main(void){
	int n,r;
	int p,c;
	int i,j;
	int k = 0;
	int card[50],tmp[50];
	while(scanf("%d %d",&n,&r)){
		if(n == 0 && r == 0){
			break;
		}
		for(i = 0;i < n;i++){
			card[i] = n - i;
		}
		for(i = 0;i < r;i++){
			scanf("%d %d",&p,&c);
			for(j = 0;j < c;j++){
				tmp[k] = card[p - 1 + j];
				k++;
			}
			for(j = 0;j < p - 1;j++){
				tmp[k] = card[j];
				k++;
			}
			for(j = 0;j < p + c - 1;j++){
				card[j] = tmp[j];
			}
			k = 0;
		}
		printf("%d\n",card[0]);
	}
	return 0;
}

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

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a > b) {
		swap(a, b);
	}
	if (b > c) {
		swap(b, c);
	}
	if (a > b) {
		swap(a, b);
	}
	cout << c - a << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
	int n;
	double x[10],y[10],sum=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%lf%lf",&x[i],&y[i]);
	for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)sum+=sqrt((x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i]));
	printf("%.10lf\n",sum*2/n);
} 

Measured memory_bytes: 256
class Stack:
    def __init__(self):
        self.stack = []

    def push(self, num):
        self.stack.append(num)

    def pop(self):
        return self.stack.pop(-1)


if __name__=="__main__":
    input_values = list(input().split())

    stack = Stack()

    for v in input_values:
        if v == "+":
            a = stack.pop()
            b = stack.pop()
            stack.push(a + b)
        elif v == "-":
            # a, b の順番を逆にする必要あり
            b = stack.pop()
            a = stack.pop()
            stack.push(a - b)
        elif v == "*":
            a = stack.pop()
            b = stack.pop()
            stack.push(a * b)
        else:
            stack.push(int(v))

    print(stack.pop())


Measured memory_bytes: 5596
#include<bits/stdc++.h>
#define ll long long int
#define ff first
#define ss second
#define eps 1e-9

using namespace std;
int arr[1000001];
int main()
{

    ll t,n,m,f,a,b,c,l,r,q,k,x,y,z,ans,mn,mx,sum=0;
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);


    cin>>n;
    vector< ll > in;

    mx = -1;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        mx = max(mx,x);

        if(arr[x]==1)
        {
            arr[x]=-1;
        }
        else if(arr[x]==0)
        {
            arr[x]=1;
            in.push_back(x);
        }
    }

    //cout<<"HERE"<<endl;


    for(int i=0;i<in.size();i++)
    {
        x = c = in[i];

        while(1)
        {
            x+=c;
            if(x<=mx)
            arr[x]=0;
            else
                break;
        }
    }

    c=0;
    for(int i=0;i<1000001;i++)
    {
        if(arr[i]==1)
        {
            c++;
        }
    }

    cout<<c<<endl;


}


Measured memory_bytes: 9156
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i) 
constexpr int  INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	/
	/
	/
	*/
	int a, b;
	cin >> a >> b;
	if (a == 1 || b == 1) {
		if (a == b) {
			cout << "Draw" << endl;
		}
		else if(a == 1){
			cout << "Alice" << endl;
		}
		else {
			cout << "Bob" << endl;
		}
	}
	else {
		if (a == b) {
			cout << "Draw" << endl;
		}
		else if(a > b){
			cout << "Alice" << endl;
		}
		else {
			cout << "Bob" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O4")
#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 MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e17)
#define int ll
#define EPS (1e-6)
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){
	b%=MOD;
	int ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int a,b; cin>>a>>b;
	cout<<6-a-b<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define P pair<int,int>
const LL inf = 0x3f3f3f3f;
const LL mod = 1e9+7;
const LL N = 1e5+10;
template <typename tp> inline void read(tp &x)
{
    x=0;char c=getchar();int f=0;
    for(;c>'9'||c<'0';f|=(c=='-'),c=getchar());
    for(;c<='9'&&c>='0';x=(x<<3)+(x<<1)+c-'0',c=getchar());
    if(f) x=-x;
}
int n,x[N],zz,flag;
bool cmp(int a,int b){return a>b;}
int main()
{
	read(n);
	for(int i=1;i<=n;i++) read(x[i]);
	sort(x+1,x+n+1,cmp);
	for(int i=0;i<=n;i++)
		if(x[i+2]<=i+1) {flag=i;break;}
	for(int i=1;i<=n;i++)
		if(x[i]>flag)
			zz=i;
	if((x[flag+1]-flag)%2==1&&(zz-flag)%2==1)
		puts("Second");
	else puts("First");
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var M = vals[1];
        var A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        var rest = N - A.Sum();
        if (rest < 0)
        {
            rest = -1;
        }

        Console.WriteLine(rest);
    }
}

Measured memory_bytes: 29376
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K, M, A;
  int x=0;
  int y=0;
  cin >> N >> M;
  vector<int> P(M);
  vector<string> R(M);
  vector<bool> AC(N, false);
  vector<int> WA(N);
  
  for (int i=0;i<M; i++) {
    cin >> P[i] >> R[i];
  }
  
  for (int i=0;i<M; i++) {
    if (R[i]=="AC") {
      if (AC[P[i]-1]==false) {
        AC[P[i]-1]=true;
        x++;
      }
    }
    else {
      if (AC[P[i]-1]==false) WA[P[i]-1]++;
    }
  }
  for (int i=0;i<N; i++) {
    if (AC[i]==true) {
      y += WA[i];
    }
  }  
  
  cout << x << " " << y << endl;
      
  

  return 0;
  
}

Measured memory_bytes: 6528
#include <iostream>
using namespace std;
int main(){
  string s; cin >> s;
  bool ok = 1;
  if(s[0] != 'A') ok = 0;
  int res = 0;
  for(int i=2;i<=s.size()-2;i++){
    if(s[i]=='C') res++;
  }
  if(res!=1) ok = 0;
  int m = 0;
  for(int i=0;i<s.size();i++){
    if('A'<=s[i] && s[i] <= 'Z') m++;
  }
  if(m!=2) ok = 0;
  if(ok) cout << "AC";
  else cout << "WA";
}

Measured memory_bytes: 256
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
	int x;
	cin >> x;
	int a = x / 500;
	int ans = a * 1000 + ((x - a * 500) / 5) * 5;
	cout << ans << endl;
	return 0;
}


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

int n, s,t, w, a[100005];
vector<int> b, c;
int main()
{
	int i;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf ("%d", &a[i]);
		w = (w ^ a[i]);
	}
	if (w == 0) cout << "Yes";
	else cout << "No";
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vll &a){sort(a.begin(),a.end()) ;}
//void myrev(vll &a){reverse(a.begin(),a.end()) ;}

int main(){
	string s ; cin >> s ;
	int ans = s.size()*10 ;
	for(int i=0;i<s.size()-1;i++){
		if(s.at(i)!=s.at(i+1)) ans = min(ans,max(i+1,(int)s.size()-1-i)) ;
	}
	if(ans==s.size()*10){
		cout << s.size() << endl ;
		return 0 ;
	}
	cout << ans << endl ;
}


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

typedef vector<int> vi; 
typedef long long ll;
#define F first 
#define S second 
#define PB push_back 
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define pmod 1000000007
#define INF 1000000000000000000
#define pi atan(1)*4
#define modi 1000000

void solve(){
	
	ll k;
	cin >> k;
	
	bitset<2000000> alfa;
	
	ll res = 7%k;
	
	alfa[res] = 1;
	ll counter = 1;
	
	bool can = true;
	
	while(res != 0){
		
		res = (res*10+7)%k;
		
		if(alfa[res]){
			can = false;
			res = 0;
		}
		
		alfa[res] = 1;
		
		counter++;
	}
	
	if(can) cout << counter << endl;
	
	if(!can) cout << -1 << endl;
	
}

int main(){
	
	ifstream fin ("text.in");
    ofstream fout ("text.out");   
	
	ll t = 1;
					
	while(t--) solve();
	
	return 0;
}

Measured memory_bytes: 3880
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

int N,K;
cin>>N>>K;

int r,s,p;
cin>>r>>s>>p;

string t;
cin>>t;

long long ans=0;


rep(i,N){
    if(i<K){

    if(t[i]=='r')ans+=p;
    else if(t[i]=='s')ans+=r;
    else if(t[i]=='p')ans+=s;
    }
    else {
    if(t[i]==t[i-K]){
        t[i]='a';
        continue;
        }
    if(t[i]=='r')ans+=p;
    else if(t[i]=='s')ans+=r;
    else if(t[i]=='p')ans+=s;

    }
}
cout<<ans<<endl;


return 0;

}
/*
5 2
8 7 6
rsrpr

27

7 1
100 10 1
ssssppr

211

30 5
325 234 123
rspsspspsrpspsppprpsprpssprpsr

4996
*/


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

int main() {
	 int a, b, c;
	cin>>a>>b>>c;
	if(a==b) {
		cout<<c<<endl;
	
	}
	if(b==c) {
		cout<<a<<endl;
	}
	if(a==c) {
		cout<<b<<endl;
	}

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <string>
typedef long long lint;

namespace utils{
	template <class T> inline void apn(T &x,const T y){x>y?x=y:0;}
	template <class T> inline void apx(T &x,const T y){x<y?x=y:0;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

int main(){
	std::string ra="maerd",rb="remaerd",rc="esare",rd="resare";
	std::string s,t;
	std::cin>>s;
	for(int i=s.size()-1; ~i; --i){
		t+=s[i];
		if(t==ra||t==rb||t==rc||t==rd) t="";
	}
	puts(t.size()?"NO":"YES");
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
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); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
	string q, w;
	while(cin>>q){
		string e = ".";
		if(q==e){
			break;
		}
		cin >> w;
		string s, t;
		ans = 0;
		sum = 0;
		cnt = 0;
		s = '\"';
		s += q;
		s.push_back('\"');
		t = '\"';
		t += w;
		t.push_back('\"');
		if(s==t){
			cout << "IDENTICAL" << endl;
			continue;
		}
		vs vsa, vsb, vta, vtb;
		sum = 1;
		REP(i,s.size()) {
			if(s[i]=='\"'){
				if(sum==1){
					vsa.push_back(s.substr(cnt, i - cnt));
					cnt = i + 1;
					sum *= -1;
				}else if(sum==-1){
					vsb.push_back(s.substr(cnt, i - cnt));
					cnt = i + 1;
					sum *= -1;
				}
			}
		}

		cnt = 0;
		sum = 1;
		REP(i,t.size()) {
			if(t[i]=='\"'){
				if(sum==1){
					vta.push_back(t.substr(cnt, i - cnt));
					cnt = i + 1;
					sum *= -1;
				}else if(sum==-1){
					vtb.push_back(t.substr(cnt, i - cnt));
					cnt = i + 1;
					sum *= -1;
				}
			}
		}


		if(vsb.size()!=vtb.size()){
			cout << "DIFFERENT" << endl;
			continue;
		}
		bool f = false;
		REP(i,vsb.size()) {
			if(vsb[i]!=vtb[i]){
				cout << "DIFFERENT" << endl;
				f = true;
				break;
			}
		}
		if(f){
			continue;
		}

		REP(i,vsa.size()) {
			if(vsa[i]!=vta[i]){
				ans++;
			}
		}
		if(ans>1){
			cout << "DIFFERENT" << endl;
			continue;
		}
		if(ans==1){
			cout << "CLOSE" << endl;
			continue;
		}
	}
	return 0;
}



Measured memory_bytes: 3164
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <string.h>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
using namespace std;

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LL MOD = 1000000007;
const int INF = 1e9;
const LL LINF = 1LL * INF * INF;
const int MAXN = 200007;
const LD EPS = 1e-7;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int n, a, b;
	cin >> n >> a >> b;
	cout << (((a - b) % 2) ? "Borys" : "Alice");
	//cout << endl; system("pause");
	return 0;
}

Measured memory_bytes: 256
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double

#define pll pair<ll,ll>
#define ff first
#define ss second

#define pb push_back
#define all(x) x.begin(),x.end()

#define MOD  1000000007
const int N = 100005; 

#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
   ll n,m,k;
   cin >> n >> m >> k;
   map<ll,ll> row,col;
   map<pair<ll,ll>,bool> y1;
   for(ll i=0,x,y;i<k;i++)
   {
        cin >> x >> y;
        y1[{x,y}] = 1;
        row[x]++;
        col[y]++;
   }
   vector<pll> r,c;
   for(auto X:row)   r.pb({X.ss,X.ff});
   for(auto X:col)   c.pb({X.ss,X.ff});
   sort(all(r));
   sort(all(c));
   reverse(all(r));
   reverse(all(c));
   ll ans = 0;
   for(ll i=0;i<r.size();i++)
   {
        if(r[i].ff==r[0].ff)
        {   
            for(ll j=0;j<c.size() && c[j].ff==c[0].ff;j++)
            {
                ll sum = r[i].ff + c[j].ff;
                if(y1[{r[i].ss,c[j].ss}])  sum--;
                else   
                {
                    ans = sum;
                    break;
                }
                ans = max(sum,ans);
            }
        }
        else   break;
   } 
   cout<<ans;
}

int main()
{
    FAST;
    int t = 1;
 // cin >> t;
    for(int i=1;i<=t;i++)
    {
        solve();
    }
}

Measured memory_bytes: 87456
/*input
4
3 1 4 2
10 20 30 40
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define endl '\n'
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n;
int dp[200007];

int query(int n){
	int ans = 0;
	while(n>0){
		ans = max(dp[n],ans);
		n -= n&(-n);
	}

	return ans;
}
void update(int n,int val){
	while(n<200006){
		dp[n] = max(dp[n],val);
		n += n&(-n);
	}
}

int32_t main(){ 
	cin>>n;
	int a[n],b[n];
	for(int i = 0;i<n;i++)	cin>>a[i];
	for(int i = 0;i<n;i++)	cin>>b[i];
	for(int i=0;i<n;i++){
		int qq = query(a[i]-1);
		if(a[i]>0){
			update(a[i],qq+b[i]);
		}
		// else
		// 	update(i,b[i]);
	}
	cout<<query(200005);
}

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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b && b==c) cout<<1<<endl;
  else if((a!=b && b!=c) && c!=a) cout<<3<<endl;
  else cout<<2<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                                              \
  cout << #v << "=(" << v[0];                                                  \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; }                     \
  cout << ")" << endl;
#define mdebug(m)                                                              \
  cout << #m << "=" << endl;                                                   \
  REP(i_debug, m.size()) {                                                     \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; }    \
    cout << endl;                                                              \
  }
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) {
  REP(i, a.size()) {
    cin >> a[i];
    a[i]--;
  }
}

ll mod = 1000000007;

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

  if (X == 7 || X == 5 || X == 3) {
    cout << "YES" << endl;
    return 0;
  } else {
    cout << "NO" << endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using vc=vector<char>;
using vvc=vector<vc>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

vvi side;
int H,W,K;

void dfs(vi v,int i) {
  if(i==H) {
    v.push_back(H);
    side.push_back(v);
    return;
  }
  dfs(v,i+1);
  v.push_back(i);
  dfs(v,i+1);
}

int main() {
  cin >> H >> W >> K;
  vvc S(H,vc(W));
  rep(h,H) {
    rep(w,W) cin >> S[h][w];
  }
  
  vector<vvi> sum(H,vvi(H,vi(W+1)));
  rep(h1,H) {
    rep2(h2,h1,H) {
      rep(w,W) {
        int count=0;
        rep2(h,h1,h2+1) count+=S[h][w]-'0';
        sum[h1][h2][w+1]=sum[h1][h2][w]+count;
      }
    }
  }
  
  dfs({0},1);
  int ans=INF;
  rep(i,side.size()) {
    int count=side[i].size()-2,l=0;
    while(true) {
      bool flag=true;
      int r=l;
      while(flag&&r<W) {
        r++;
        rep(j,side[i].size()-1)
          flag&=sum[side[i][j]][side[i][j+1]-1][r]-sum[side[i][j]][side[i][j+1]-1][l]<=K;
      }
      if(r==l+1) {
        count=INF;
        break;
      }
      l=r-1;
      if(!flag) count++;
      if(r==W) break;
    }
    ans=min(ans,count);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3972
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>

using namespace std;

int n, k;

void read(int &para)
{
	char ch = getchar();
	while (ch<'0' || ch>'9')
		ch = getchar();
	int x = 0;
	while (ch >= '0'&&ch <= '9')
		x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	para = x;
}

int Min = 0x7f7f7f7f;

int main(int argc, char ** argv)
{
	read(n), read(k);
	if (!(n%k))
		cout << 0 << endl;
	else
		cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL
#define MAX 500001
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;

Node treeMinimum(Node x){
while(x->left!=NIL){
  x=x->left;
}
return x;
}

Node treeMaximum(Node x){
while(x->right!=NIL){
  x=x->right;
}
return x;
}

Node treeSearch(Node x, int k){
while ( x!=NIL && k!=x->key){
  if(k<x->key) x=x->left;
  else x=x->right;
}
return x;
}

Node treeSuccessor(Node x){
Node y;
if(x->right !=NIL) return treeMinimum(x->right);

y=x->parent;
while ( y !=NIL && x == y->right) {
  x=y;
  y=y->parent;
}
return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
if(z->left == NIL || z->right ==NIL){
  y=z;
}
else y= treeSuccessor(z);

if(y->left != NIL) x=y->left;
else x=y->right;

if(x !=NIL) x->parent=y->parent;
if(y->parent==NIL) root=x;
else if(y==y->parent->left) y->parent->left=x;
else y->parent->right=x;

if(y!=z) z->key=y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

while( x!=NIL){
  y=x;
  if(z->key<x->key) x=x->left;
  else x=x->right;
}
z->parent=y;
if(y==NIL)root=z;
else{
  if(z->key<y->key) y->left=z;
  else y->right=z;
}
}

void inorder(Node u){
if(u==NIL) return;
inorder(u->left);
printf(" %d",u->key);
inorder(u->right);
}
void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}


Measured memory_bytes: 25120
#include<iostream>

using namespace::std;

#define MOD 1000000007

long long int fac[5000005],rev[5000005];

int main(){
	int x,y;
	cin>>x>>y;
	if((x+y)%3){
		cout<<0<<'\n';
		return 0;
	}
	int n=(x+y)/3;
	fac[0]=fac[1]=1;
	for(int i=2;i<=n;i++)
		fac[i]=(fac[i-1]*i)%MOD;
	rev[1]=1;
	for(int i=2;i<=n;i++)
		rev[i]=(MOD-(((MOD/i)%MOD)*rev[MOD%i])%MOD)%MOD;
	rev[0]=1;
	for(int i=2;i<=n;i++)
		rev[i]=(rev[i]*rev[i-1])%MOD;
	if(x<n || y<n)
		cout<<0<<'\n';
	else cout<<(fac[n]*((rev[y-n]*rev[x-n])%MOD))%MOD<<'\n';
}

Measured memory_bytes: 12544
def calc(a, t):
	ans = t
	for i in range(0, len(a)-1):
		if a[i+1]-a[i] < t: ans = ans + a[i+1] - a[i]
		else: ans = ans + t
	return ans

N, T = map(int, raw_input().split())
timelist = map(int, raw_input().split())

print calc(timelist, T)


Measured memory_bytes: 20036
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <fstream>

using namespace std;
using ll = long long;

#define PRI(n) cout << n << " "<<endl;
#define PRI2(n, m) cout << n << " " << m << " "<<endl;

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

const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const ll MOD = 1e9 + 7;

struct edge;
struct UnionFind;

bool isPrime(ll x);

ll GCD(ll a, ll b);

ll LCM(ll a, ll b);

ll nCr(int n, int r);


struct UnionFind {
    vector<int> par;
    vector<int> rank;

    UnionFind(int N) {
        for (int i = 0; i < N; ++i) {
            par.push_back(i);
            rank.push_back(0);
        }
    }

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

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)return;
        if (rank[x] < rank[y])par[x] = y;
        else {
            par[y] = x;
            if (rank[x] == rank[y])rank[x]++;
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

ll N, M;
string S;
vector<edge> X[100010];
bool B[100010];
int D[100010];

int main() {
    cin >> N;
    ll a,b;
    cin >>a;
    REP(i,N-1){
        cin >>b;
        a = LCM(a,b);
    }
    PRI(a)
    return 0;
}

struct edge {
    int to, cost;
    bool flag = false;
};

bool isPrime(ll x) {
    if (x == 0)return 0;
    if (x == 1)return 0;
    if (x == 2)return 1;
    if (x % 2 == 0)return 0;
    FOR(i, 3, x - 1) {
        if (x % i == 0)return 0;
    }
    return 1;
}

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

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll nCr(int n, int r) {
    vector<ll> C(r + 1);
    C[0] = 1;
    FOR(i, 1, n) for (int j = min(i, r); j < 1; --j)C[j] = (C[j] + C[j - 1]) % MOD;
    return C[r];
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a,b;
  cin >> a >> b;
  int n = b - a;
  n = n*(n+1)/2;
  int ans = n - b;
  cout << ans << endl;
}


Measured memory_bytes: 256