akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iostream>
#include<cstring>
#define ll long long
#define maxn 100005
			 
#define p 1000000007
#define re(i,a,b) for(int i=a;i<=b;i++)
#define for_edge(x) for(int i=head[x];i;i=e[i].nxt)
using namespace std;
inline int read(){char c=getchar();int f=1;int ans = 0;while(c>'9'||c<'0'){if(c=='-')f=-f;c=getchar();}while(c<='9'&&c>='0'){ans =ans*10+c-'0';c=getchar();}return ans*f;}
//_____________________________________________________________________________________________________
deque<int>q;
int vis[maxn],dis[maxn];
int main()
{
	int k = read();
	memset(dis,0x3f,sizeof(dis));
	dis[1] = 1;
	q.push_back(1);
	while(!q.empty() )
	{
		int x = q.front() ; 
		q.pop_front() ;
		if(vis[x])
			continue;
		vis[x] = 1;
		if(dis[x*10%k]>dis[x])
		{
			dis[x*10%k] = dis[x];
			q.push_front(x*10%k);
		}
		if( dis[(x+1)%k]>dis[x] + 1 )
		{
			dis[(x+1)%k] = dis[x] + 1;
			q.push_back((x+1)%k);
		}
	}
	printf("%d\n",dis[0]);
    return 0;
}



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

int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}, n;

int main() {
    scanf("%d", &n);
    printf("%d", a[n-1]);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;

ll yaku(ll N,ll i){
  if(N%i==0) return i+(N/i); 
    else return 1000000000000;
}
int main() {
  
ll N;
 in(N);
  ll ans = 1000000000000;
  for(ll i=1;i<=sqrt(N)+1;i++){
    ans = min(ans,yaku(N,i));
  }
  out(ans-2);
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int count = 0;
        int i1 = 0;
        for (; count < X;) {
            i1++;
            count += i1;
        }
        int dif = X-count;
        if (dif == 0) {
            System.out.println(i1);
            return;
        }
        int i2 = 0;
        for (; 0 < dif;) {
            i2++;
            dif -= i2;
        }
        System.out.println(i1-i2); 
    }
}


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

namespace ConsoleApp21
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] AB = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int x = AB[0] + AB[1];
            int y = AB[0] - AB[1];
            int z = AB[0] * AB[1];
            int ans = 0;
            if (x <= y)
            {
                if (y <= z) { ans = z; }
                else { ans = y; }
            }
            else
            {
                if (x >= z) { ans = x; }
                else { ans = z; }
            }
            Console.WriteLine(ans);
        }
    }
}

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

void solv() {
    string str;
    cin >> str;
    if (str.size() == 2) {
        if (str[0] == str[1]) {
            cout << "1 2" << endl;
            return;
        }
        else{
            cout << "-1 -1" << endl;
            return;
        }
    }
    rep(i, str.size() - 2) {
        set<char> c;
        c.insert(str.at(i));
        c.insert(str.at(i + 1));
        c.insert(str.at(i + 2));
        if (c.size() < 3) {
            cout << i + 1 << " " << i + 3 << endl;
            return;
        }
    }
    cout << "-1 -1" << endl;
}

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

Measured memory_bytes: 512
L,R=map(int,input().split())
min=2019
for i in range(L,R+1):
    for k in range(i+1,R+1):
        mod=(i*k)%2019
        if mod<min:
            min=mod
        if mod==0:
            min=0
            break
    else:
        continue
    break
print(min)


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

num = {}
ans = 0
for i, v in enumerate(A):
    p = v+i
    m = i-v
    if p not in num:
        num[p] = 1
    else:
        num[p] += 1
    if m in num:
        ans += num[m]
print(ans)

Measured memory_bytes: 118728
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n, c, k;
  cin >> n >> c >> k;
  V t(n);
  for (auto &v : t) cin >> v;
  sort(t.begin(), t.end());
  int i = 0;
  int cnt = 0;
  while (i < n) {
    int tx = t[i]+k;
    int bus = c;
    for (int j = i; t[j] <= tx && bus > 0; j++) {
      i++;
      bus--;
    }
    cnt++;
  }
  dump(cnt);
  return 0;
}


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

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

    int M;
    cin >> M;
    string red[M];
    for(int i = 0; i < M; ++i){
        cin >> red[i];
    }

    int resultMax[N] = {1};
    for(int i = 0; i < N; ++i){
        for(int j = 1; j < N; ++j){
            if(blue[i] == blue[j]) {
                ++resultMax[i];
            }
        }
    }

    for(int i = 0; i < N; ++i){
        for(int j = 0; j < M; ++j){
            if(blue[i] == red[j]) {
                --resultMax[i];
            }
        }
    }

    int max = resultMax[0];
    for(int i = 0; i < N; ++i){
        if(max < resultMax[i]){
            max = resultMax[i];
        }
    }

  if(max < 0) {
    max = 0;
  }
    cout << max;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


def count_cost(xy: list, p: int, q: int):
    n = len(xy)
    cnt = n

    for xi, yi in xy:
        if [xi+p, yi+q] in xy:
            cnt -= 1

    return cnt


n = ni()
xy = [list(li()) for _ in range(n)]

ans = n
for i in range(n):
    for j in range(i+1, n):
        xi, yi = xy[i]
        xj, yj = xy[j]

        p, q = xj - xi, yj - yi

        ans = min(ans, count_cost(xy, p, q))

print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cstdio>
#define rg register
using namespace std;
typedef long long ll;
const int maxn=110;
template <typename Tp> inline int getmin(Tp &x,Tp y){return y<x?x=y,1:0;}
template <typename Tp> inline int getmax(Tp &x,Tp y){return y>x?x=y,1:0;}
template <typename Tp> inline void read(Tp &x)
{
    x=0;int f=0;char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') f=1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    if(f) x=-x;
}
int n,m,top,a[maxn],stk[maxn];
int main()
{
	read(n);read(m);
	for(rg int i=1;i<=m;i++)
	{
		read(a[i]);
		if(a[i]&1) stk[++top]=i;
	}
	if(top>2){puts("Impossible");return 0;}
	if(top>1) swap(a[1],a[stk[2]]);
	if(top) swap(a[m],a[stk[1]]);
	if(a[1]<a[m]) swap(a[1],a[m]);
	if(m==1)
	{
		if(a[1]==1) puts("1\n1\n1");
		else printf("%d\n2\n%d 1\n",a[1],a[1]-1);
		return 0;
	}
	for(rg int i=1;i<=m;i++) printf("%d ",a[i]);
	putchar('\n');
	printf("%d\n%d ",m-(a[m]==1),a[1]+1);
	for(rg int i=2;i<m;i++) printf("%d ",a[i]);
	if(a[m]^1) printf("%d",a[m]-1);
	putchar('\n');
	return 0;
}

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

int main(){
    int n;
    cin >> n;

    long long ans = 0;
    
    int a;
    for(int i = 0; i < n; i++){
        cin >> a;
        while(a%2 == 0){
            ans++;
            a /= 2;
        }
    }

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

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int ans = 0;
  vector<bool> f(1000001, true);
  vector<vector<int>> v(1000001);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    v[a[i]].emplace_back(i);
  }
  for (int i = 1; i <= 1000000; ++i) {
    if (v[i].empty() || !f[i])
      continue;
    if (v[i].size() == 1)
      ans++;
    for (int j = 2 * i; j <= 1000000; j += i)
      f[j] = false;
  }
  cout << ans;
}

Measured memory_bytes: 33360
#include<math.h>
#include<stdio.h>

struct Point { double x, y; };

void koch(int n,Point a,Point b)
{
	if (n == 0)
		return;
	Point s, u, t;
	double th =M_PI * 60.0 / 180.0;
	s.x = (2.0 * a.x + 1.0*b.x) / 3.0;
	s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
	t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
	t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
	u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
	u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

	koch(n - 1, a, s);
	printf("%.8f %.8f\n", s.x,s.y);

	koch(n - 1, s, u);
	printf("%.8f %.8f\n", u.x,u.y);

	koch(n - 1, u, t);
	printf("%.8f %.8f\n", t.x,t.y);

	koch(n - 1, t, b);
}


int main()
{
	Point a, b;
	int n;
	scanf("%d", &n);
	a.x = 0;
	a.y = 0;
	b.x = 100;
	b.y = 0;
	printf("%.8f %.8f\n", a.x, a.y);
	koch(n, a, b);
	printf("%.8f %.8f\n", b.x, b.y);
	return 0;
}


Measured memory_bytes: 2732
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl

//ここからAtCoder向けdefine
#define yes cout << "YES" << endl
#define no cout << "NO" << endl

using namespace std;

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using pint = pair<int,int>;

const int INF = ~(1 << 31);

int n;
vi c, s, f;

void solve(int st, int t){
    /*cerr << "--------------" << endl;
    show(st);
    show(t);*/
    if(st == n - 1){
        cout << t << endl;
        //cerr << "return" << endl;
        return;
    }
    if(t < s[st]){ t = s[st] + c[st]; }
    else{
        int i = s[st];
        while(true){
            if(t <= i) break;

            i += f[st];
        }
        t = i + c[st];
    }

    return solve(st + 1, t);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    int l, m, o;
    rep(i, n){
        cin >> l >> m >> o;
        c.pb(l);s.pb(m);f.pb(o);
    }

    rep(i,n){ solve(i, 0); }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int64_t n, m;
    cin >> n >> m;

    vector<int> vs(n + 1, 0);
    for (int i = 0; i < m; i++)
    {
        int l, r;
        cin >> l >> r;
        vs[r] += 1;
        vs[l - 1] -= 1;
    }
    for (int i = n - 1; i >= 0; i--)
    {
        vs[i] += vs[i + 1];
    }
    int counter = 0;
    for (int i = 1; i <= n; i++)
    {
        if (vs[i] == m)
        {
            counter++;
        }
    }
    cout << counter << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = 100_001;
    boolean[] isPrime = new boolean[N];
    for (int i = 2; i < N; i++) isPrime[i] = true;
    for (int i = 2; i < (int) Math.sqrt(N) + 1; i++) {
      if (isPrime[i]) for (int j = 2; i * j < N; j++) isPrime[i * j] = false;
    }

    int[] acc = new int[N];
    int sum = 0;
    for (int i = 3; i < N; i++) {
      if (isPrime[i] && isPrime[(i + 1) / 2]) sum++;
      acc[i] = sum;
    }

    int Q = scanner.nextInt();
    for (int i = 0; i < Q; i++) {
      int l = scanner.nextInt();
      int r = scanner.nextInt();
      System.out.println(acc[r] - acc[l - 1]);
    }
  }
}


Measured memory_bytes: 76192
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

typedef pair<ll, ll> P;

bool compare_by_b(P a, P b) {
    if (a.second != b.second) {
        return a.second > b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {
    INIT;
    ll N, K;
    cin >> N >> K;

    string S;
    cin >> S;

    vector<ll> nums;
    if (S[0] == '0') nums.pb(0);

    ll cnt = 0;
    rep(i, SZ(S)) {
        if (i == 0) {
            cnt++;
        } else {
            if (S[i - 1] != S[i]) {
                nums.pb(cnt);
                cnt = 1;
            } else {
                cnt++;
            }
        }

        if (i == SZ(S) - 1) {
            nums.pb(cnt);
        }
    }

    // repv(nums) cout << *it << " ";
    // cout << endl;

    ll right = 0;
    ll sum = 0;
    ll res = 0;
    for (ll left = 0; left < SZ(nums); left += 2) {
        while (right < SZ(nums) && (right - left + 1) <= 2 * K + 1) {
            sum += nums[right];
            right++;
        }

        chmax(res, sum);

        if (right == left)
            right += 2;
        else {
            sum -= nums[left];
            sum -= nums[left + 1];
        }
    }

    cout << res << endl;
}

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

const int MAX = 1000010;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    COMinit();
    long long X, Y;
    cin >> X >> Y;
    long long x,y;
    x = (2*X-Y)/3;
    y = (-X+2*Y)/3;
    if(2*X-Y >= 0 && (2*X-Y)%3 == 0 && -X+2*Y >= 0 && (-X+2*Y)%3 == 0){
        cout << COM(x+y,x) << endl;
    }else{
        cout << 0 << endl;
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 23928
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    N = int(readline())
    X = readline().rstrip().decode('utf-8')
    nx = int(X, 2)

    ans = [0] * N

    oc = X.count('1')

    if oc - 1 != 0:
        mx = nx % (oc - 1)
        f = True
    else:
        f = False

    px = nx % (oc + 1)

    for i in range(N):

        if X[i] == '0':
            a = (px + pow(2, N - i - 1, oc + 1)) % (oc + 1)
        elif f:
            a = (mx - pow(2, N - i - 1, oc - 1)) % (oc - 1)
        else:
            ans[i] = 0
            continue

        count = 1
        while a:
            a = a % bin(a).count('1')
            count += 1

        ans[i] = count

    print('\n'.join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 94352
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream> 
 #include <queue>
 #include <vector>
 #include <string>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;
////////////////いろいろあるよ//////////////////////////////////
 
int main(){
  int N;
  cin >> N;
 if(N%2==0)cout << N/2 << endl;
  else cout << (N/2)+1 << endl;
  
}

Measured memory_bytes: 256
#include<cstdio>

int main(){
    int n,m;
    scanf("%d %d", &n, &m);
    int s[m];
    int cost=0;
    for(int i=0;i<m;i++){
        scanf("%d", &s[i]);
        cost += s[i];
    }
    if(cost>n) printf("-1");
    else printf("%d", n-cost);
    return 0;
}

Measured memory_bytes: 1764
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define pb push_back
#define empb emplace_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define vii vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define mapii map<int,int> 
#define mapll map<ll,ll>
#define all(a) a.begin(),a.end()
#define test ll t; cin>>t; while(t--)
#define prec(n) fixed<<setprecision(n)
#define ItsFun ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007

int minimumChar(string S1, string S2) { 
    int n = S1.size(), m = S2.size(); 
  
    int ans = INT_MAX; 
    for (int i = 0; i < m - n + 1; i++) { 
        int minRemovedChar = 0; 
        for (int j = 0; j < n; j++) { 
            if (S1[j] != S2[i + j]) { 
                minRemovedChar++; 
            } 
        } 
        ans = min(minRemovedChar, ans); 
    } 
    return ans; 
}

int main(){
	ItsFun;

	string s, t; cin >> s >> t;
	cout << minimumChar(t,s) << "\n";

	return 0;
}

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

int N, L[10];

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i){
        cin >> L[i];
    }
    
    sort(L, L+N);

    int max = L[N-1];
    int other = 0;
    for (int i = 0; i < N - 1; ++i){
        other += L[i];
    }
    if (max < other){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const ll inf=1001001001001001;
const int Inf=1001001001;
const int mod=1000000007;
int main(){
    ll n,k,ans=inf;cin>>n>>k;
    vi v(n);
    rep(i,n)cin>>v[i];
    rep(i,n-k+1){
        chmin(ans,abs(v[i])+abs(v[i+k-1]-v[i]));
        chmin(ans,abs(v[i+k-1])+abs(v[i+k-1]-v[i]));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
        ($line:expr, $name:ident, $t:tt) => {
            let $name = value!($line, $t);
        };
    }

    macro_rules! values_def {
        ($lines:expr, $n:expr, $name:ident, $t:tt) => {
            let $name = {
                let mut vec = Vec::new();
                for i in 0..$n {
                    let mut next = $lines.next().unwrap().split_whitespace();
                    vec.push(value!(next, $t));
                }
                vec
            };
        };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:i64));
    if n > 999 { "ABD" } else { "ABC" }.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "999" => "ABC",
    test2: "1000" => "ABD",
    test3: "1481" => "ABD",
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
using namespace std;
using ll=int64_t;
using vi=vector<int>;
using VI=vector<ll>;
using vis=vector<string>;
using vvi=vector<vi>;
int main(){
    int n,k;
    cin>>n>>k;
    if(k==1){
        cout<<0<<endl;
        return 0;
    }
    cout<<n-k<<endl;
}

Measured memory_bytes: 3588
/*input
3 4
aabb
aabb
aacc
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long a[1000005],n,freq[150];

int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
	long long q,m,k,h,w,ans=0,sum=0,p,x=0,y=0;
	cin>>h>>w;
	string s;
	for(int i=0;i<h;++i){
		cin>>s;
		for(int j=0;j<s.size();++j)
			++freq[s[j]];
	}
	if(h%2==0 && w%2==0){
		for(int i='a';i<='z';++i)
			if(freq[i]%4) return cout<<"No",0;
		cout<<"Yes";
	}
	else if(h%2 && w%2){
		for(int i='a';i<='z';++i)
			if(freq[i]%4==3) ++sum,++x;
			else if(freq[i]%4==1) ++sum;
			else if(freq[i]%4==2) ++x;
		cout<<(sum==1 && x<=(h+w-2)/2&&((h+w)/2-1-x)%2==0?"Yes":"No");
	}
	else if(h%2 && w%2==0){
		for(int i='a';i<='z';++i)
			if((freq[i]%4)%2) return cout<<"No",0;
			else if(freq[i]%4==2) ++x;
		cout<<(x<=w/2&&(w/2-x)%2==0?"Yes":"No");
	}
	else{
		for(int i='a';i<='z';++i)
			if((freq[i]%4)%2) return cout<<"No",0;
			else if(freq[i]%4==2) ++x;
		cout<<(x<=h/2&&(h/2-x)%2==0?"Yes":"No");
	}
}

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

int n;
pair<int,int> probs[1001];
// iÔÚÜÅÌàÌ©çjÂIÔÌÉKvÈÅ¬Ô
int dp[1001][1001];
const int INF=1000000000;

int main(){
    cin>>n;
    for(int i = 0; i < 1001; i++)for(int j = 0; j < 1001; j++)dp[i][j]=INF;
    for(int i = 0; i < n; i++)
        cin>>probs[i].second>>probs[i].first;
    sort(probs,probs+n);
    dp[0][0]=0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= n; j++){
            if(j==0)
                dp[i+1][j]=dp[i][j];
            else if(dp[i][j-1]+probs[i].second<=probs[i].first)
                dp[i+1][j]=min(dp[i][j],dp[i][j-1]+probs[i].second);
            else
                dp[i+1][j]=dp[i][j];
        }
    }
    for(int i = n; i >= 0; i--){
        if(dp[n][i]!=INF){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<0<<endl;
    return 0;
}

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

int main(){
	int n ; cin >> n ;
	bool ok = true ;
	vector<int> d(n) ;
	for(int i=0;i<n;i++) cin >> d.at(i) ;
	int pos = 0 ;
	for(int i=0;i<n;i++){
		if(i>pos){
			cout << "no" << endl ;
			return 0 ;
		}
		if(pos<i+d.at(i)/10) pos = i+d.at(i)/10 ;
	}
	pos = n-1 ;
	for(int i=n-1;i>=0;i--){
		if(i<pos){
			cout << "no" << endl ;
			return 0 ;
		}
		if(pos>i-d.at(i)/10) pos = i-d.at(i)/10 ;
	}
	cout << "yes" << endl ;
}



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

int main(){
    int r,d,x;
    cin >> r >> d >> x;
    for(int i = 0; i < 10; i++){
        x = r * x - d;
        cout << x << endl;
    }
}


Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;

int sum(int n) {
	if (n == 1) {
		return 1;
	}
	int ans = sum(n - 1);
	ans += n;
	return ans;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;
typedef long long ll;
int main()
{
	ll a,b,n,x,t;
	ll ans;
	cin>>a>>b>>n;
	if(n<b)
		ans = a*n/b;
	else if(b==1)
		ans = 0;
	else{
		x = b-1;
		t = n/b;
		x += (t-1)*b;
		ans = a*x/b - a*(x/b);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int main(){
    int s;
    vector<int> used(1000001,0);
    scanf("%d",&s);
    used[s]=1;
    int x=0;
    int count=1;
    while(x<1){
        count=count+1;
        if(s%2==0){
            s=s/2;
        }
        else{
            s=s*3+1;
        }
        if(used[s]==1){
            x=1;
        }
        else{
            used[s]=1;
        }
    }
    printf("%d\n",count);
    return 0;
    
}


Measured memory_bytes: 4096
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
 string s;
 cin>>s;
 sort(s.begin(),s.end());

 string t;
 cin>>t;
 sort(t.begin(),t.end());
 reverse(t.begin(),t.end());

 if(s<t){
  cout<<"Yes"<<endl;
 }
 else{
  cout<<"No"<<endl;
 }
}


Measured memory_bytes: 256
n, m = map(int, raw_input().split())
A = [raw_input() for i in xrange(n)]
B = [raw_input() for i in xrange(m)]

for i in xrange(n-m+1):
    for j in xrange(n-m+1):
        ok = 1
        for x in xrange(m):
            for y in xrange(m):
                if A[i+x][j+y] != B[x][y]:
                    ok = 0
        if ok:
            print "Yes"
            exit(0)
print "No"


Measured memory_bytes: 2568
#include<bits/stdc++.h>
// iteration and input/output stream
#define rep(i,a,b) for(int i = int(a);i<=int(b);i++)
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define printarr(x) rep(i,0,x.size()-1) cout<<x[i]<<" "; cout<<endl;
#define all(v) v.begin(),v.end()
 
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define tr(cont,it) \
for(decltype(cont.begin()) it = cont.begin(); it!= cont.end() ; it++)
 
#define endl "\n"
#define tc() int t; cin >> t ; while (t--)
//STL shortcuts
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define MP make_pair
 
// Error detection
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
using namespace std;
 
typedef long long int ll; // 64 bit integer
typedef unsigned long long int  ull; // 64 bit unsigned integer
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
 
inline void smax(int &x , int y) { x = max(x , y) ; }
inline void smin(int &x , int y) { x = min(x , y) ; }
 
#define MOD 1000000007
#define inf 4000000000000000000LL
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("err.txt","w",stderr);
    #endif
    SYNC
    int n;
    cin>>n;
    vvi a(n,vi(3,0));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin>>a[i][j];
        }
    }
    
    vvi dp(n,vi(3,-1));// dp[i][j] = maximum happiness if jth(0,1 or 2) activity done on day i
    for (int i = 0; i < 3; i++)
    {
        dp[0][i] = a[0][i];
    }
    for (int i = 1; i < n; i++)
    {
        for (int j = 0; j < 3; j++)
        {//for all colours
            int max_h = 0;
            for (int k = 0; k < 3; k++)
            {
                if(k!=j)max_h = max(max_h,dp[i-1][k]+a[i][j]);

            }
            dp[i][j] = max_h;
        }
    }
    int ans= max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 14288
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
        if (a[0] == a[1]&&a[1]==a[2]&&a[2]==a[0]) { Console.WriteLine(a[0]%2==0?"-1":"0"); }
        else
        {
            long i = 0;
            for (i = 0; i>-1; i++)
            {
                if (a[0] % 2 == 1 || a[1] % 2 == 1 || a[2] % 2 == 1) { break; }
                long karia = a[0];
                long karib = a[1];
                long karic = a[2];
                a[0] = (karib + karic) / 2;
                a[1] = (karia + karic) / 2;
                a[2] = (karia + karib) / 2;
            }
            Console.WriteLine(i.ToString());
        }
        Console.ReadLine();
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
int a[1000][1000];
queue<pair<int,int>> q;
int ans, H, W;

void bfs() {
  int moveX[] = { 1, 0, -1, 0 };
  int moveY[] = { 0, 1, 0, -1 };
  int temp = q.size();
  while (q.size() > 0) {
    pair<int,int> current = q.front();
    q.pop();
    for (int i = 0; i < 4; i++) {
      int x = current.first + moveX[i];
      int y = current.second + moveY[i];
      if (x >= 0 && y >= 0 && y < H && x < W && a[y][x] == 0) {
        a[y][x] = 1;
        q.push(make_pair(x, y));
      }
    }
    temp--;
    if (temp == 0) {
      ans++;
      temp = q.size();
    }
  }
}

signed main() {
  ans = 0;
  cin >> H >> W;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      char c; cin >> c;
      if (c == '.') {
        a[i][j] = 0;
      } else if (c == '#') {
        a[i][j] = 1;
        q.push(make_pair(j, i));
      }
    }
  }
  bfs();
  cout << ans-1 << endl;
}


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

int main() {
	int N,M,cntb=0,cntn=0;
	cin >> N;
	vector<string> s(N);
	for(int i = 0;i < N;i++)
	{
		cin >> s.at(i);
	}
	cin >>M;
	vector<string> t(M);
	for(int i = 0;i < M;i++)
	{
		cin >> t.at(i);
	}
	for(int i = 0;i < N;i++)
	{
		cntn = 0;
		string str = s.at(i);
		for(int j = 0;j < N ;j++)
		{
			if(str == s.at(j))
			{
				cntn++;
			}
		}
		for(int j = 0;j < M ;j++)
		{
			if(str == t.at(j))
			{
				cntn--;
			}
		}
		if(cntn > cntb)
		{
			cntb = cntn;
		}
	}
	cout << cntb << endl;
}

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

int main()
{
    int a, b, c;
    char s[]="No", s1[]="Yes";
    cin>>a>>b;
    if(b<a) cout<<s<<endl;
    else if(b%2==1) cout<<s<<endl;
    else if(b<a*2) cout<<s<<endl;
    else if(b>a*4) cout<<s<<endl;
    else cout<<s1<<endl;
}


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

int main() {
  string S;
  cin>>S;
  if(S[0]!=S[1]&&S[1]!=S[2]&&S[2]!=S[0]){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){

  long long n;

  while( cin >> n , n ){

    long long total = -n;
    for( int i = 1 ; i*i < n ; i++ ){
      if( !(n % i) ){
	total += i + ( n / i );
      }
    }
    if( n == total ) cout << "perfect number" << endl;
    if( n < total ) cout << "abundant number" << endl;
    if( n > total ) cout << "deficient number" << endl;

  }
  return 0;
}

Measured memory_bytes: 1152
def main():
    N, X, M = list(map(int, input().split()))
    visited = [0] * M
    a = X
    path = list()
    while visited[a] == 0:
        visited[a] = 1
        path.append(a)
        a = (a**2) % M
    # ここのaは2度目なのでループの始端。
    # ループに入るまでの項数とループ長を求める。
    offset_size = 0
    for p in path:
        if p == a:
            break
        offset_size += 1
    loop_size = len(path) - offset_size
    # 後は、始端＋ループ＋最終ループに分けて、各値が何回出てくるか計算
    count = [0] * M
    n = 0
    # 始端
    for p in path[:offset_size]:
        count[p] += 1
        n += 1
        if n == N:
            break
    # ループ
    count_loop = (N - n) // loop_size
    for p in path[offset_size:]:
        count[p] += count_loop
        n += count_loop
    # 最後
    for p in path[offset_size:]:
        if n == N:
            break
        count[p] += 1
        n += 1
    print(sum([m * c for m, c in enumerate(count)]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 75924
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

X = get_int

sen = X / 500
amari = X % 500
go = amari / 5

puts sen * 1000 + go * 5


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

using namespace std;

#define ll long long




void solve() {

	string s;
	cin >> s;
	string ekey = "RUD", okey = "LUD";
	for(int i = 0; i <s.length(); i++) {
		if(i % 2 == 0 && ekey.find(s[i]) == string::npos) {
			cout << "No";
			return;
		}
		if(i % 2 == 1 && okey.find(s[i]) == string::npos) {
			cout << "No";
			return;
		}
	}
	cout << "Yes";

	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
  	string s,t;
  	int n;
  	cin>>n>>s>>t;
  	vector<char>x(0);
  	for(int i=0;i<n;i=i+1){
    	x.push_back(s.at(i));
      	x.push_back(t.at(i));
    }
  	for(int i=0;i<2*n;i++){
    	cout<<x.at(i);
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  vector<int64_t>B(N+1);
  B.at(0)=0;
  for(int i=1;i<N+1;i++)
    B.at(i)=B.at(i-1)+A.at(i-1);
  map<int64_t,int64_t>M;
  for(int i=0;i<N+1;i++){
  if(M.count(B.at(i)))
     M.at(B.at(i))++;
     else
     M[B.at(i)]=1;
  
  }int64_t ans=0;
     for(auto p:M){
     auto k=p.first;
       auto v=p.second;
       ans+=(v*(v-1))/2;
     
     }cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 15872
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct Node{
  int key;
  struct Node *right,*left,*parent;
};

struct Node *root,*NIL;

void insert(int);
void inorder(struct Node *);
void preorder(struct Node *);

struct Node * find(struct Node *u,int k){
  while(u!=NIL && k!=u->key){
    if(k<u->key)u=u->left;
    else u=u->right;
  }
  return u;
}

int main(){
  int n,i,x;
  char c[10];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",&c);
    if(c[0]=='f'){
      scanf("%d",&x);
      struct Node *t = find(root,x);
      if(t!=NIL)printf("yes\n");
      else printf("no\n");
    }
    else if(strcmp(c,"insert")==0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strcmp(c,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

void insert(int k){
  struct Node *y = NIL;
  struct Node *x = root;
  struct 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(struct Node *u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

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




Measured memory_bytes: 20452
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;
constexpr char newl = '\n';

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define F first
#define S second
#define debug(x) cout << #x << ": " << x << '\n';

#if 1

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, W;
  cin >> N >> W;

  vector<int> w(N);
  vector<i64> v(N);
  F0R(i, N) {
    cin >> w[i] >> v[i];
  }

  vector<vector<i64>> dp(N + 1, vector<i64>(W + 1));
  FOR(i, 1, N + 1) {
    FOR(j, 1, W + 1) {
      if (j < w[i - 1]) {
        dp[i][j] = dp[i - 1][j];
      }
      else {
        dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
      }
    }
  }
  cout << dp[N][W];
}
#endif


Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define veci(x,n) vector<int> x((int) (n))
#define vecs(x,n) vector<string> x((int) (n))
#define vecbf(x,n) vector<bool> x((int) (n), false)

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
    int N,M,i,j,ans=0,tmp;
    cin >> N >> M;
    char A[N][N], B[M][M];
    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            cin >> A[i][j];
        }
    }
    for(i=0;i<M;i++){
        for(j=0;j<M;j++){
            cin >> B[i][j];
        }
    }
    int y0,x0;
    for(y0=0;y0<N-M+1;y0++){
        for(x0=0;x0<N-M+1;x0++){
            tmp=1;
            for(i=0;i<M;i++){
                for(j=0;j<M;j++){
                    if(A[y0+i][x0+j]!=B[i][j]) tmp=0;
                }
            }
            if(tmp) ans = 1;
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
e=list(map(int,sys.stdin))
m=max(e)+1;a=[1]*m;a[0:2]=0,0
for i in range(2,int(m**.5)+1):
 if a[i]>0:
  for j in range(i*2,m,i):a[j]=0
for i in range(m):a[i]+=a[i-1]
for x in e:print(a[x])


Measured memory_bytes: 45128
#include <iostream>

using namespace std;

long long N;

long long S[500000];

long long A[3] = {3,5,7};
long long count = 0;

long long ret_tri(long long a){
  long long tmp = 1;
  long long Z[11];
  long long num = 0;
  count = 0;
  while(true){
    Z[count] = a%4;
    if(Z[count]== 0){
      return 0;
    }
    num += A[Z[count]-1]*tmp;
    count++;
    tmp *= 10;
    a/=4;
    if(a==0)break;    
  }
  return num;
}

void Set_S(){
  long long number = 0;
  for(long long i=0;i<5000000;i++){
    long long tmp = ret_tri(i);
    if(tmp==0){
      continue;
    }
    long long tmp2 = tmp;
    bool one_a = false,two_a = false,three_a=false;
    bool ok = false;
    for(long long j=0;j<count;j++){
      if(tmp % 10 == 3)one_a = true;
      if(tmp % 10 == 5)two_a = true;
      if(tmp % 10 == 7)three_a = true;
      if(one_a && two_a && three_a)ok = true;
      tmp /= 10;
    }
    if(ok){
      S[number] = tmp2;
      number++;
    }
  }
}

int main(){
  cin >> N;
  Set_S();
  long long coun = 0;
  long long ans = 0;
  while(S[coun] <= N){
    coun++;
  }
  
  cout << coun << endl;
  return 0;
}

Measured memory_bytes: 2176
// È¥°É£¡Æ¤¿¨Çð! °ÑAC´ø»ØÀ´£¡
//      ¤Ø¡¡¡¡¡¡¡¡¡¡£¯|
// ¡¡¡¡/£Ü7¡¡¡¡¡¡ ¡Ï£ß/
// ¡¡ /¡¡©¦¡¡¡¡ £¯¡¡£¯								AC		AC		AC		AC
//    ©¦¡¡Z £ß,£¼¡¡£¯¡¡¡¡ /`©c						AC		AC		AC		AC
//    ©¦¡¡¡¡¡¡¡¡¡¡©c¡¡¡¡ /¡¡¡¡¡µ					AC		AC		AC		AC
// ¡¡Y¡¡¡¡¡¡¡¡¡¡`¡¡ /¡¡¡¡/  /						AC		AC		AC		AC
// ¡¡Øé¡ñ¡¡.¡¡¡ñ¡¡¡¡¡´¡¡/¡¡/						AC		AC		AC		AC
// ¡¡()¡¡ ¤Ø¡¡¡¡¡¡¡¡|¡¡£Ü¡´							AC		AC		AC		AC
// ¡¡¡¡>- ._¡¡ ¥£¡¡ ©¦ £¯£¯							AC		AC		AC		AC
// ¡¡ / ¤Ø¡¡¡¡ /¡¡/£¼| £Ü£Ü							AC		AC		AC		AC
// ¡¡ ©c_/¡¡¡¡(_£¯¡¡ ©¦£¯£¯							AC		AC		AC		AC
// ¡¡¡¡ 7¡¡¡¡¡¡¡¡¡¡¡¡¡¡|£¯							AC		AC		AC		AC
// ¡¡¡¡ £¾¨Dr£þ£þ`-¨D£ß/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

using namespace std;

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

const int Days[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

inline int read()
{
	#define gc getchar
	int ans=0;
	bool f=1;
	char ch=gc();
	
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	
	return f?ans:-ans;
	
	#undef gc
}

typedef long long ll;

char s[1010][1010];
queue<pair<int,int> > qa,qb;
int ans[1010][1010];

#define INF 1000000007

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	int h,w;cin>>h>>w;
	int si,sj,ti,tj;cin>>si>>sj>>ti>>tj;si--,sj--,ti--,tj--;
	for(int i=0;i<h;i++)cin>>s[i];
	
	qa.push(mp(si,sj));qb.push(mp(si,sj));
	
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)ans[i][j]=INF;
	
	ans[si][sj]=0;
	
	do{
		while(!qa.empty())
		{
			int i=qa.front().first,j=qa.front().second;qa.pop();
			qb.push(mp(i,j));
			int d=ans[i][j];
			
			for(int dir=0;dir<4;dir++)
			{
				int curi=i+dx[dir];
				int curj=j+dy[dir];
				
				if(curi<0||curi>=h||curj<0||curj>=w)continue;
				
				if(s[curi][curj]=='#')continue;
				
				if(ans[curi][curj]<=d)continue;
				
				ans[curi][curj]=d;
				
				qa.push(mp(curi,curj));
				qb.push(mp(curi,curj));
			}
		}
		while(!qb.empty())
		{
			int i=qb.front().first,j=qb.front().second;qb.pop();
			int d=ans[i][j];
			
			for(int mi=-2;mi<=2;mi++)for(int mj=-2;mj<=2;mj++)
			{
				int curi=i+mi;
				int curj=j+mj;
				
				if(curi<0||curi>=h||curj<0||curj>=w)continue;
				
				if(s[curi][curj]=='#')continue;
				
				if(ans[curi][curj]<=d+1)continue;
				
				ans[curi][curj]=d+1;
				
				qa.push(mp(curi,curj));
			}
		}
	}while(!qa.empty()||!qb.empty());
	
	if(ans[ti][tj]==INF)cout<<-1;else cout<<ans[ti][tj];
	
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

/*  GOD BLESS  */


Measured memory_bytes: 8652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
inline int rnd(int x){
	return rand()%x;
}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=1005,M=5005,inf=1e9;
int jb[M],dp[N],x[N],n;
vector<int> v[N];
void dfs(int p){
	for(unsigned i=0;i<v[p].size();i++)dfs(v[p][i]);
	for(int i=1;i<=x[p];i++)jb[i]=inf; jb[0]=0;
	for(unsigned i=0;i<v[p].size();i++){
		for(int j=x[p];j>=0;j--){
			int dq=1e9;
			if(j>=x[v[p][i]])dq=min(dq,jb[j-x[v[p][i]]]+dp[v[p][i]]);
			if(j>=dp[v[p][i]])dq=min(dq,jb[j-dp[v[p][i]]]+x[v[p][i]]);
			jb[j]=dq;
			//if(p==1)cout<<jb[j]<<" szbakking "<<j<<endl;
		}
	}
	int ans=inf;
	for(int j=0;j<=x[p];j++)ans=min(ans,jb[j]);
	dp[p]=ans;
	//cout<<dp[p]<<" "<<p<<endl;
}
int main(){
	n=read();
	for(int i=2;i<=n;i++)v[read()].push_back(i);
	for(int i=1;i<=n;i++)x[i]=read();
	dfs(1);
	cout<<(dp[1]<inf?"POSSIBLE":"IMPOSSIBLE")<<endl;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void) {
   int a,b,c,i;
   int cnt=0;
   scanf("%d%d%d",&a,&b,&c);
   for(i = a; i <= b; i++) {
   if(c%i==0) {
     cnt++;
   }
   }
  
  printf("%d\n",cnt);
return 0;
}

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

long int gcd(long int a, long int b)
{
    long int big, small;
    if (a > b)
    {
        big = a;
        small = b;
    }
    else
    {
        big = b;
        small = a;
    }

    long int tmp = 1;
    while (tmp != 0)
    {
        tmp = big % small;
        big = small;
        small = tmp;
    }
    return big;
};

int main()
{
    long int a, b;
    cin >> a >> b;
    cout << a * b / gcd(a, b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<int>a,b;
int main()
{
    int n,temp;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> temp;
        a.push_back(temp);
   }
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> temp;
        cout<<lower_bound(a.begin(), a.end(), temp)-a.begin()<<endl;
    }
}


Measured memory_bytes: 3444
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    count = 0
    for a in A:
        if a%2==1:
            count += 1
    if count%2==1:
        print('NO')
    else:
        print('YES')


if __name__ == '__main__':
    main()


Measured memory_bytes: 18336