akhauriyash/Code-Regression huggingface dataset:
/******Old_school_@23******/
/******Why_would_a_compiler_lie?******/
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,fma") 
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define lld               long long int
#define ld                long double
#define pb                push_back
#define ppb               pop_back 
#define mp                make_pair
#define F                 first
#define S                 second
#define nl                '\n'
#define all(c)            (c).begin(),(c).end()
#define rall(c)           (c).rbegin(),(c).rend()
#define sz(c)             (c).size()
#define tr(x,a)           for(auto &a : x)
#define psnt(x,a)         (x).find(a)!=(x).end()
#define vpsnt(x,a)        find(all(x),a)!=(x).end()
#define lexichar(x,y)     lexicographical_compare(x,x+strlen(x),y,y+strlen(y)) //modify the ranges
#define lexistr(x,y)      lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()) 
#define MOD               1000000007
#define pi                3.1415926536
#define tod               1
#define itr(i,a,b)        for(lld i=a;i<=b;i++)
#define itrn(i,a,b)       for(lld i=a;i>=b;i--)
#define iot(n)            for(lld i=0;i<n;i++)
#define pls(n,arr)        lld arr[n]; iot(n)  cin>>arr[i];
#define bye               fflush(stdout)

typedef pair<lld,lld>     pii;
typedef pair<string,lld>  psi;
template <typename T>
bool mycomp(T x,T y){ 
   return (x==y);  //give your condition here
}
bool paircomp(const pair<lld,lld> &x,const pair<lld,lld> &y){ 
return x.second<y.second;
}
void dfs(vector<lld> adj[],bool vis[],lld s,lld &cnt ){
    vis[s]=true;
    cnt++;
    for(auto &p:adj[s]){
        if(!vis[p]){
            dfs(adj,vis,p,cnt);
        }
    }
}
int main(){
       ios_base::sync_with_stdio(false);
             cin.tie(0);
            cout.tie(0);
            lld n,m; cin>>n>>m;
      vector<lld> adj[n];
      
      iot(m){
          lld x,y; cin>>x>>y;
          adj[x-1].pb(y-1);
          adj[y-1].pb(x-1);
      }
      bool vis[n];
      memset(vis,false,sizeof(vis));
      lld ans=0;
      for(lld i=0;i<n;i++){
          if(!vis[i]) { lld p=0; 
          dfs(adj,vis,i,p);
            ans=max(ans,p);
          }
      }
      cout<<ans;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N, M, X;
    cin >> N >> M >> X;
    vector<vector<int>> A(12, vector<int>(12, 0));
    vector<ll> C(N);
    rep(0, i, N)
    {
        cin >> C.at(i);
        rep(0, j, M)
        {
            cin >> A.at(i).at(j);
        }
    }
    int sum;
    int ans = 1000000000;
    int ansflag = 0;
    for (int tmp = 0; tmp < (1 << N); tmp++)
    {
        bitset<12> bit(tmp);
        sum = 0;
        vector<int> now(M, 0);
        rep(0, i, N)
        {
            if (bit.test(i))
            {
                sum += C.at(i);
                rep(0, j, M)
                {
                    now.at(j) += A.at(i).at(j);
                }
            }
        }

        int flag = 1;
        rep(0, i, M)
        {
            if (now.at(i) < X)
            {
                flag = 0;
            }
        }
        if (flag)
        {
            ansflag = 1;
            ans = min(ans, sum);
        }
    }
    if (ansflag)
    {
        cout << ans << endl;
    }
    else
    {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 3636
import java.io.*

val pw = PrintWriter(System.out)
const val MOD = 1000000007L
const val INF = 2147483647
const val LINF = 9223372036854775807L

fun main(args: Array<String>) {
    solve()
    pw.flush()
}

fun solve() {
    val (n, k) = nextLongList()
    if(k == 0L){
        println(n * n)
        return
    }

    var ans = 0L
    val tmp = n - k
    ans += (tmp + 1) * tmp / 2
    for (b in k + 1 until n){
        val rest = n - b
        val div = rest / b
        val mod = rest % b
        ans += div * (b - k) + max(0, mod - k + 1)
    }

    println(ans)
}

fun println(v: String) {
    pw.println(v)
}

fun print(v: String) {
    pw.print(v)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ").toMutableList()
fun nextIntList(index: Int = 0) = next().split(" ").map { it.toInt() + index }.toMutableList()
fun nextLongList(index: Long = 0L) = next().split(" ").map { it.toLong() + index }.toMutableList()
fun nextDoubleList() = next().split(" ").map { it.toDouble() }.toMutableList()

fun ary(n: Int, init: String = "") = Array(n) { init }
fun intAry(n: Int, init: Int = 0) = IntArray(n) { init }
fun longAry(n: Int, init: Long = 0L) = LongArray(n) { init }
fun doubleAry(n: Int, init: Double = 0.0) = DoubleArray(n) { init }
fun ary2(n: Int, m: Int, init: String = "") = Array(n) { Array(m) { init } }
fun intAry2(n: Int, m: Int, init: Int = 0) = Array(n) { IntArray(m) { init } }
fun longAry2(n: Int, m: Int, init: Long = 0) = Array(n) { LongArray(m) { init } }
fun doubleAry2(n: Int, m: Int, init: Double = 0.0) = Array(n) { DoubleArray(m) { init } }
fun ary3(n: Int, m: Int, k: Int, init: String = "") = Array(n) { Array(m) { Array(k) { init } } }
fun intAry3(n: Int, m: Int, k: Int, init: Int = 0) = Array(n) { Array(m) { IntArray(k) { init } } }
fun longAry3(n: Int, m: Int, k: Int, init: Long = 0L) = Array(n) { Array(m) { LongArray(k) { init } } }
fun doubleAry3(n: Int, m: Int, k: Int, init: Double = 0.0) = Array(n) { Array(m) { DoubleArray(k) { init } } }

fun abs(n: Int): Int = Math.abs(n)
fun abs(n: Long): Long = Math.abs(n)
fun abs(n: Double): Double = Math.abs(n)
fun max(vararg values: Int) = if (values.isEmpty()) -INF else values.max()!!
fun max(vararg values: Long) = if (values.isEmpty()) -LINF else values.max()!!
fun min(vararg values: Int) = if (values.isEmpty()) INF else values.min()!!
fun min(vararg values: Long) = if (values.isEmpty()) LINF else values.min()!!
fun swap(a: String, b: String) = Pair<String, String>(b, a)
fun swap(a: Int, b: Int) = Pair<Int, Int>(b, a)
fun swap(a: Long, b: Long) = Pair<Long, Long>(b, a)
fun swap(a: Double, b: Double) = Pair<Double, Double>(b, a)

fun gcd(a: Int, b: Int): Int = if (a % b == 0) b else gcd(b, (a % b))

Measured memory_bytes: 38676
#include "bits/stdc++.h"

#pragma warning(disable:4996)
using namespace std;

vector<vector<int>>djk(const vector<vector<int>>&edges, const int S) {
	vector<vector<int>>dp(edges.size(),vector<int>(2,1e9));
	dp[S][0]=0;

	queue<pair<int,int>>que;
	que.emplace(S,0);
	while (!que.empty()) {
		auto p(que.front());
		que.pop();
		const int now(p.first);
		const bool odd(p.second);

		for (auto e : edges[now]) {
			const int nextcost(dp[now][odd]+1);
			if (dp[e][!odd] > nextcost) {
				dp[e][!odd]=nextcost;
				que.emplace(e,!odd);
			}
		}
	}
	return dp;
}
vector<long long int> divisor(long long int n) {
	vector<long long int> res;
	for (long long int i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			res.push_back(i);
			if (i * i != n) res.push_back(n / i);
		}
	}
	sort(begin(res), end(res));
	return res;
}

int main() {
	int N,M,S,T;cin>>N>>M>>S>>T;
	S--;T--;
	vector<vector<int>>edges(N);
	for (int i = 0; i < M; ++i) {
		int a,b;cin>>a>>b;
		a--;b--;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}
	auto dp(djk(edges,S));
	int ans=dp[T][1];

	if (dp[T][0] == 2) {
		ans=2;
	}
	else {
		if(ans==1)ans=3;
		else if (ans > 1e8) {
			ans=-1;
		}
		else {
			while (divisor(ans).size()!=2) {
				ans+=2;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
} 


Measured memory_bytes: 13744
using System;

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int a, b;
            string[] str = Console.ReadLine().Split(' ');
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);
            Console.WriteLine(a*b + " " + 2*(a+b));
        }
    }
}



Measured memory_bytes: 15872
N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

X = sorted([a for a in A if a >= 0])
Y = sorted([a for a in A if a < 0], key=lambda x: abs(x))

if 2 * (min(K, len(Y)) // 2) + len(X) >= K:
    ans = 1
    if K % 2 == 1:
        ans *= X.pop()
        K -= 1

    XX = [(x1 * x2) for x1, x2 in zip(*[iter(X[::-1])] * 2)]
    YY = [(y1 * y2) for y1, y2 in zip(*[iter(Y[::-1])] * 2)]
    ZZ = sorted(XX + YY)

    for i in range(K // 2):
        ans *= ZZ.pop()
        ans %= MOD

    print(ans)

else:
    ans = 1
    Z = sorted(X + Y, key=lambda x: abs(x), reverse=True)
    for i in range(K):
        ans *= Z.pop()
        ans %= MOD
    print(ans)


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

a = []
i = 0
for i in range(N):
    a.append(int(0))
    while list[i] % 2 == 0:
        a[i] = a[i] + 1
        list[i] = int(list[i]/2)
print(min(a))

Measured memory_bytes: 3060
#include <iostream>
#include <map>

using namespace std;

template<typename T>
struct ring4 {
    T elem[4];

    ring4() {}

    ring4(T a, T b, T c, T d) {
        elem[0] = a;
        elem[1] = b;
        elem[2] = c;
        elem[3] = d;
    }

    T operator[](int x) {
        return elem[x % 4];
    }

    bool operator==(ring4<T> &r) {
        for (int i = 0; i < 4; ++i)
            if (this->elem[0] == r[i])
                for (int j = 1; j < 4; ++j) {
                    if (this->elem[j] != r[i + j]) break;
                    if (j == 3)return true;
                }
        return false;
    }

    int indexOf(T v) {
        for (int i = 0; i < 4; ++i) {
            if (elem[i] == v) return i;
        }
        return -1;
    }
};

template<typename T>
struct dice {
    map<T, ring4<T> > faces;
    T u;
    T s;

    dice(T f1, T f2, T f3, T f4, T f5, T f6) {
        u = f1;
        s = f2;
        faces[f1] = ring4<T>(f5, f4, f2, f3);
        faces[f2] = ring4<T>(f1, f4, f6, f3);
        faces[f3] = ring4<T>(f1, f2, f6, f5);
        faces[f4] = ring4<T>(f1, f5, f6, f2);
        faces[f5] = ring4<T>(f1, f3, f6, f4);
        faces[f6] = ring4<T>(f2, f4, f5, f3);
    }

    T U() {
        return u;
    }

    T S() {
        return s;
    }

    T E() {
        return faces[u][faces[u].indexOf(s) + 1];
    }

    T N() {
        return faces[u][faces[u].indexOf(s) + 2];
    }

    T W() {
        return faces[s][faces[s].indexOf(u) + 1];
    }

    T D() {
        return faces[s][faces[s].indexOf(u) + 2];
    }

    void rollTo(char direction) {
        T tmpS = s, tmpU = u;
        switch (direction) {
            case 'N':
                s = D();
                u = tmpS;
                break;
            case 'E':
                u = W();
                break;
            case 'S':
                u = N();
                s = tmpU;
                break;
            case 'W':
                u = E();
                break;
            default:;
        }
    }
};

int main() {
    int face[6];
    for (int i = 0; i < 6; ++i) cin >> face[i];
    dice<int> D1(face[0], face[1], face[2], face[3], face[4], face[5]);
    for (int i = 0; i < 6; ++i) cin >> face[i];
    dice<int> D2(face[0], face[1], face[2], face[3], face[4], face[5]);
    bool whether = (D1.faces[D1.u] == D2.faces[D1.u]);
    cout << (whether ? "Yes" : "No") << endl;
    return 0;
}



Measured memory_bytes: 3120
/*
 /+==================================================+\
//+--------------------------------------------------+\\
|.|\\...>>>>>>> Hollwo_Pelw(ass) 's code <<<<<<<...//|.|
\\+--------------------------------------------------+//
 \+==================================================+/
*/
#include <bits/stdc++.h>
using namespace std;
// type
typedef long long ll;
typedef long double ld;
// loop
//#define For(i, l, r)        for (int i = l; i < r; i++)
//#define ForE(i, l, r)       for (int i = l; i <= r; i++)
//#define Ford(i, r, l)       for (int i = r; i > l; i--)
//#define FordE(i, r, l)      for (int i = r; i >= l; i--)
//#define Fora(i, a)          for (auto i : a)
// I/O
#define open(file, in, out) if (fopen(file in, "r")) {        \
                                freopen(file in, "r", stdin);  \
                                freopen(file out, "w", stdout); \
                            }
#define FAST_IO             std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define setpre(n)           fixed << setprecision(n)
// pair
#define F                   first
#define S                   second
#define pii                 pair<int, int>
#define pll                 pair<ll, ll>
#define pdd                 pair<ld, ld>
// vector & !!?(string)
#define eb                  emplace_back
#define pb                  push_back
#define all(a)              a.begin(), a.end()
#define rall(a)             a.rbegin(), a.rend()
#define sz(a)               a.size()
#define len(a)              a.length()
// geometry calculate
#define pi                  acos(-1.0)
#define g_sin(a)            sin(a*pi/180)
#define g_cos(a)            cos(a*pi/180)
#define g_tan(a)            tan(a*pi/180)
// set val
#define ms0(a)              memset(a,        0, sizeof(a));
#define ms1(a)              memset(a,        1, sizeof(a));
#define msn1(a)             memset(a,       -1, sizeof(a));
#define msinf(a)            memset(a, 0x3f3f3f, sizeof(a));
// constant
const int mod1 = 998244353, mod = 1e9+7;
const int MAXN = 100005, MAXM = 200010;
// code
//#define int long long

int a[505][505];
int H, W, h, w;
void Solve() {
    cin >> H >> W >> h >> w;
    if (H%h == 0 && W%w == 0){
        cout << "No";
        return;
    }
    cout << "Yes\n";
    for (int i = 1; i <= H; i ++){
        for (int j = 1; j <= W; j ++){
            if (i % h == H % h && j % w == W % w)
                a[i][j] = 5e8 + 1;
            else if (i % h == 0 && j % w == 0)
                a[i][j] = (-1 * h * w - 5e8);
            else
                a[i][j] = 1;
            cout << a[i][j] << ' ';
        }
        cout << endl;
    }
    
}

signed main(){
    open("", ".inp", ".out");
    FAST_IO;
    int TC = 1;
    //cin >> TC;
    while(TC--) Solve();
    return 0;
}
/*

./-=====>>><<<-------- DEBUG -------->>><<<=====-\.
/.................................................\

+====================== INP ======================+


+====================== OUT ======================+


\................................................./
.\-=====>>><<<--------= END =-------->>><<<=====-/.
*/


Measured memory_bytes: 4624
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  //
  ll n, t;
  cin >> n >> t;
  vector<pll> p;
  vl a(n), b(n);
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    p.push_back({x, y});
    // cin >> a[i] >> b[i];
  }
  sort(ALL(p));
  rep(i, n) {
    a[i] = p[i].first;
    b[i] = p[i].second;
    // cerr << a[i] << endl;
  }
  vector<vector<ll>> data(n + 1, vector<ll>(t + 3001, 0));
  rep(i, n) {
    rep(j, t + 3001) {
      if (j < a[i]) {
        data[i + 1][j] = data[i][j];
      } else if (j - a[i] < t) {
        data[i + 1][j] = max(data[i][j], data[i][j - a[i]] + b[i]);
      } else {
        data[i + 1][j] = data[i][j];
      }
      // cerr << data[i + 1][j] << " ";
    }
    // cerr << endl;
  }
  ll ans = 0;
  rep(i, t + 3001) { ans = max(ans, data[n][i]); }
  cout << ans << endl;
  // cerr << data[n][t] << endl;
  return 0;
}


Measured memory_bytes: 141184
import math
n,d = map(int,input().split())
x = []
while True:
  try:
    tmp = list(map(int,input().split()))
    x.append(tmp)
    
  except:
    break
    
ans = 0
for i in range(n):
  for j in range(i+1,n):
    t = 0
    for k in range(d):
      t += (x[i][k]-x[j][k])**2
    if int(math.sqrt(t))==math.sqrt(t):
      ans +=1
print(ans)

Measured memory_bytes: 3064
from collections import deque
H,W=map(int,input().split())
A=[input() for _ in range(H)]
visited_area=[[-1]*W for _ in range(H)]
stack=deque([])
for h,c_h in enumerate(A):
    for w,c_w in enumerate(c_h):
        if c_w=='#':
            stack.append([h,w])
def bfs(A,visited_area,stack):
    kotae = 0
    for a in range(H):
        kotae += A[a].count('#')
    while kotae<H*W:
        h, w = stack.pop()
        for x, y in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_h = h + x
            new_w = w + y
            if new_h < 0 or new_h >= H or new_w < 0 or new_w >= W:
                continue
            if A[new_h][new_w] == '.' and visited_area[new_h][new_w] == - 1:
                visited_area[new_h][new_w] = visited_area[h][w]+1
                stack.appendleft([new_h, new_w])
                kotae+=1
bfs(A,visited_area,stack)
answers=[]
for a in visited_area:
    answers.append(max(a))
print(max(answers)+1)


Measured memory_bytes: 140764
#include <bits/stdc++.h>
using namespace std;
#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++)
#define _LIBCPP_DEBUG 0
#define _GLIBCXX_DEBUG

int main()
{
    int h,w;
    cin >> h>>w;
    vector<char> result((h+2)*(w+2),'#');
    rep(i, h)
    {
        rep(j, w)
        {
            cin >> result[(i+1)*(w+2)+(j+1)];
        }
    }
    rep(i, h+2)
    {
        rep(j, w+2)
        {
            cout << result[i*(w+2)+j];
        }
            cout << endl;
    }
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
typedef long long ll;
ll ean=0; 

ll a[12345];
int main(){
	 ll x,k,d;
	 cin>>x>>k>>d;
		x=abs(x);
		ll y=x%d;
		ll t=x/d;
		if(t>=k)cout<<x-k*d<<endl;
		else{
			if((k-t)%2==0)cout<<y<<endl;
			else cout<<d-y<<endl;
		}
}

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

int main(){
    int num=1,n,cnt;
    cin >> n;
    vector<int> btn(n),visit(n);
    for(int i=0;i<n;i++)
        cin >> btn.at(i);
    for(cnt=1;cnt<n;cnt++){
        num = btn.at(num-1);
        if(num==2)
            break;
    }
    if(cnt<n)
        cout << cnt << endl;
    else
        cout << -1 << endl;        
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) vector<T> v(n); REP(i, n) {cin>>(v)[i];}
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(i, n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(i, n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}
#define vec2d(T, v, m, n) vector<vector<T>> (v)(m, vector<T>(n))
#define nvec2d(T, v, m, n) vec2d(T, v, m, n); REP(j, m){REP(i, n) {cin>>(v[j])[i];}}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))

#define pos position<int>
#define at_(p) at(p.x).at(p.y)

#define GCD(v) gcd(ALL(v), 0l)

template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}

template <typename T>
using vec =vector<T>;

template <typename T>
using vvec =vector<vector<T>>;

class v {
public:
  int a;
  int b;
  int c;
  int d;
};


int main(){
  int n,k;
  cin>>n>>k;
  vec<int> a(n,0);
  for (size_t i = 0; i < k; i++) {
    int d,e;
    cin>>d;
    for (size_t j = 0; j < d; j++) {
      cin>>e;
      a[e-1]++;
    }
  }
  cout<<count(ALL(a),0);
}



/* きょむ〜 */


Measured memory_bytes: 3628
import sys
input = sys.stdin.readline

def main():
    N,M,Q = map(int,input().split())
    go = [[0 for _ in range(N)] for i in range(N)]
    for _ in range(M):
        L,R = map(int,input().split())
        go[L-1][R-1] += 1
        
    qu = []
    for _ in range(Q):
        p,q = map(int,input().split())
        qu.append((p,q))
        
    num = [[0 for _ in range(N)] for _ in range(N)]
    _num = [[0 for _ in range(N)] for _ in range(N+1)]
    for i in range(N):
        num[i][0] = go[i][0]
    for i in range(N):
        for j in range(N-1):
            num[i][j+1] = num[i][j] + go[i][j+1]

    for i in range(N):
        for j in range(N):
            _num[j+1][i] = _num[j][i] + num[j][i]
            
    for i in range(Q):
        p,q = qu[i]
        ans = _num[q][q-1] - _num[p-1][q-1]
        print(ans)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 30064
#include <iostream>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

// UnionFind
class UnionFind {
public:
    vector<int> d;
    UnionFind(int n=0): d(n,-1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y);}
    int size(int x) { return -d[find(x)];}
};

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        uf.unite(a,b);
    }
    int ans = n;
    int k = 0;
    rep(i,n) {
        if(uf.d[i] < 0) {
            ans += uf.d[i];
            ++k;
        }
    }
    --ans; ++k;
    ans += k - 1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3748
/*
AizuOnline A0055
Title
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
double n;
//
main()
{
  double ret;
  
  while(EOF!=scanf("%lf",&n) && n)
    {
      ret=(1+2)*n*(1.0-32.0/243.0)*3;

      printf("%lf\n",ret);

    }

return(0);
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define tcase int _; cin >> _; while(_--)
const int MAX = 1e6;

int n, k;
int v[MAX];
int dp[MAX];

void solve() {
	cin >> n >> k;
	for(int i=0; i<n; i++) cin >> v[i];
	fill(dp, dp+n, INT_MAX);
	dp[0] = 0;
	for(int i=1; i<n; i++) {
		for(int j=1; j<=k && i-j>=0; j++) {
			dp[i] = min(dp[i], abs(v[i]-v[i-j])+dp[i-j]);
		}
	}
	cout << dp[n-1];
}

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

 	solve();

  	return 0;
}



Measured memory_bytes: 4436
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, n; // 1円a枚、N円
  cin >> n >> a;
  if ( (n % 500) > a ) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
# AGC010A - Addition
def main():
    n = int(input())
    A = tuple(map(int, input().rstrip().split()))
    flg = sum(i % 2 == 1 for i in A) % 2 == 0
    print("YES" if flg else "NO")


if __name__ == "__main__":
    main()

Measured memory_bytes: 14232
import java.util.Scanner;

public class Main{
    public static void main(String[]args){
	Scanner stdin = new Scanner(System.in);
	//int x = Integer.parseInt(args[0]);
	int x = stdin.nextInt();
	if(1<=x && x<=100){
	    System.out.println(x*x*x);
	}
    }
}

Measured memory_bytes: 26228
D = int(input())
C = list(map(int, input().split()))
S = [None] * D
for i in range(D):
    S[i] = list(map(int, input().split()))
T = [None] * D
for i in range(D):
    T[i] = int(input())

lasts = [0] * 26
score = 0
for d in range(D):
    t = T[d]-1
    score += S[d][t]
    d += 1
    lasts[t] = d
    score -= sum(C[i] * (d-l) for i, l in enumerate(lasts))
    print(score)

Measured memory_bytes: 69032
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
typedef long long ll;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	// ?????????????????°??????????????????
	int a,b;
	cin >> a >> b;
	if (a < b) {
		cout << "a < b" << endl;
	}
	else if (a > b) {
		cout << "a > b" << endl;
	}
	else {
		cout << "a == b" << endl;
	}
	// ???????????§
}


Measured memory_bytes: 3084
from collections import defaultdict, deque
import sys

N = int(input())
d = defaultdict(int)
for i in range(N):
    d[i+1] = int(input())

#print(d)

q = deque()
q.append(1)

point = 1
count = 1

while N > 0:
    if d[point] == 2:
        print(count)
        sys.exit()
        
    q.append(d[point])
    point = d[point]
    count += 1
    N -= 1

print(-1)

Measured memory_bytes: 18276
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
void solve() {
	int n, k;
	cin >> n >> k;
	int ans = 1;
	for (int i = 1;; ++i) {
		ans *= k;
		if (n < ans) {
			cout << i << endl;
			return;
		}
	}
}
#undef int
int main() {
	init();
	solve();
}

Measured memory_bytes: 256
nm = input().split()
n = int(nm[0])
m = int(nm[1])
a = input().split()
for i in range(n):
    a[i] = int(a[i])
    
b = {0:1}
k = 0
for i in range(n):
    k += a[i]
    k = k%m
    if k in b.keys():
        b[k] += 1
    else:
        b[k] = 1

        
c = b.values()
ans = 0
for i in c:
    ans += i*(i-1)//2
    
print(ans)

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

// using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n;
  cin >> n;
  int durations[n-1], start_time[n-1], periods[n-1];
  for(int i = 0; i < n-1; ++i) {
    cin >> durations[i] >> start_time[i] >> periods[i];
  }

  for(int i = 0; i < n-1; ++i) {
    int t = 0;
    for(int j = i; j < n-1; ++j) {
      // 最初の出発時間になっていない時
      if(t < start_time[j]) t = start_time[j];

      // 出発周期でない時、次の出発まで待つ
      // 次の出発までの時間は、「現在の時刻に何秒足せば、周期の倍数の時刻になるか」という考え方で求められる
      // 現在時刻が周期の倍数でない時には以下の式で求められる
      // 周期 - (現在時刻 % 周期)
      // 例：周期が1000で、現在時刻が1900のとき、あと100足せば周期の倍数になる
      // 100 = 1000 - (1900 % 1000)
      // なお、最初の出発時間は周期の倍数になることが保証されているので、ifではなくelse ifでもいい
      if(t%periods[j]) t += periods[j] - (t % periods[j]);
      t += durations[j];
    }
    cout << t << "\n";
  }
  cout << 0 << "\n";
  return 0;
}
/***** MAIN *****/


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

using namespace std;
const int N = 1e6 + 5, MOD = 1e9 + 7;
int dp[N];

int add(int a, int b) {return (a + b) % MOD;}
int mul(int a, int b) {return 1ll * a * b % MOD;}
int main() {
    int n, sum = 2; cin >> n;
    dp[0] = dp[1] = 1;
    for (int i = 2; i < n; i++) dp[i] = add(sum, MOD - dp[i - 2]), sum = add(sum, dp[i]);
    int ans = 1;
    for (int i = 1; i < n; i++) ans += mul(n - 1, dp[i - 1]), ans %= MOD;
    for (int i = 1; i < n; i++) ans += add(mul(mul(n - 1, n - 2), dp[i - 1]), mul(dp[i], n - 1)), ans %= MOD;
    cout << add(ans, n - 1) << "\n";
}


Measured memory_bytes: 4096
n=int(input())

import itertools
ans =[]
for i in itertools.permutations(range(1,n+1)):
    ans.append(list(i))
    

p = list(map(int,input().split()))
q = list(map(int,input().split()))

x = ans.index(p)+1
y = ans.index(q)+1

if x -y >=0:
    print(x-y)
elif x-y < 0:
    print(y-x)
    

Measured memory_bytes: 47836
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const ll MOD=1e9+7;
const int INF=1e9;
const double PI=acos(-1);


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

    int n,m;
    cin >> n >> m;
    priority_queue<double> pq;
    rep(i,n) {
        int a;
        cin >> a;
        pq.push(1.0*a);
    } 
    rep(i,m) {
        double d=pq.top();
        pq.pop();
        pq.push(d*0.5);
    }
    ll ans=0;
    while (!pq.empty()) {
        double d=pq.top();
        pq.pop();
        ans+=ll(d);
    }
    cout << ans << endl;

    return 0;
}


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

ll ze(ll x,ll y){
    return max(x,y)-min(x,y);
};

int main(){
    int n;
    cin >> n;
    int w[n];
    int sum=0;
    for(int i=0; i<n; i++){
        cin >> w[i];
        sum+=w[i];
    }
    int mn=1e9;
    int l=0,r=sum;
    for(int i=0; i<n; i++){
        l+=w[i];
        r-=w[i];
        if(mn>ze(l,r))mn=ze(l,r);
    }
    cout << mn << endl;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var N int
  fmt.Scan(&N)
  d := make([]int, N)
  mochi := make(map[int]int)
  for i := range d {
    fmt.Scan(&d[i])
    mochi[d[i]]++;
  }
  fmt.Println(len(mochi))
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  while(a!=0&&c!=0){
    c-=b;
    if(c<=0){break;}
    a-=d;
    if(a<=0){break;}
  }
  if(a>0){printf("Yes\n");}
  else{printf("No\n");}
  return 0;
}

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

using namespace std;

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  
  string s,t;
  cin>>s>>t;
  
  int x=t.find(s);
  
  if(x==-1)
  {
    cout<<"No";
  }
  else if(x+s.size()+1==t.length())
    cout<<"Yes";
  else 
    cout<<"No";
  
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, m; cin >> n >> m;
    vector<double> a(n); rep(i, n) cin >> a[i];
    sort(all(a));
    reverse(all(a));
    ll sum = accumulate(all(a), (double)0);
    rep(i, m) {
        if (a[i] < (double)sum / (4 * m)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int h, w; cin >> h >> w;
  V<string> s(h); for (int i = 0; i < h; i++) cin >> s[i];
  VV<> a(h - 1);
  auto f = [&](int i, int j) { return s[i][j] == '#'; };
  for (int i = 0; i < h - 1; i++) {
    for (int j = 0; j < w - 1; j++) {
      if (f(i, j) + f(i, j + 1) + f(i + 1, j) + f(i + 1, j + 1) & 1) a[i].push_back(j);
    }
    a[i].push_back(w - 1);
  }
  int res = max(h, w);
  V<V<>::iterator> p(h - 1);
  for (int i = 0; i < h - 1; i++) p[i] = a[i].begin();
  V<> b(h - 1), l(h - 1), r(h - 1);
  for (int j = 0; j < w - 1; j++) {
    for (int i = 0; i < h - 1; i++) {
      while (*p[i] < j) ++p[i];
      b[i] = *p[i] - j + 1;
    }
    stack<int, V<> > st;
    for (int i = 0; i < h - 1; i++) {
      while (!st.empty() and b[st.top()] >= b[i]) st.pop();
      l[i] = b[i] * (i - (!st.empty() ? st.top() : -1));
      st.push(i);
    }
    stack<int, V<> >().swap(st);
    for (int i = h - 2; i >= 0; i--) {
      while (!st.empty() and b[st.top()] >= b[i]) st.pop();
      r[i] = b[i] * ((!st.empty() ? st.top() : h - 1) - i);
      st.push(i);
    }
    for (int i = 0; i < h - 1; i++) res = max(res, l[i] + r[i]);
  }
  cout << res << '\n';
}

Measured memory_bytes: 20480
from collections import *
from heapq import *
import sys

sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]
dij = [(1, 0), (-1, 0), (0, 1), (0, -1)]


def main():
    n,l=MI()
    aa=[i+l for i in range(n)]
    print(sum(aa)-min(aa,key=lambda x:abs(x)))

main()


Measured memory_bytes: 3316
#pragma GCC optimize("O3")

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <assert.h>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <random>
#include <cmath>
#include <chrono>
#include <bitset>

#define ld long double
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;

const int INF = 2e18;
const int MOD = 1e9 + 7;
const int MB = 20;

void solve() {
	vector<string> a = { "Sunny", "Cloudy", "Rainy" };
	string s;
	cin >> s;
	int id = 0;
	for (int i = 0; i < 3; i++) if (a[i] == s) id = i;
	id = (id + 1) % 3;
	cout << a[id];
}
signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(12);
	solve();
}

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

vector<pair<int64_t, int>> prime_division(int64_t n){
    vector<pair<int64_t, int>> ret;
    for(int64_t i=2; i*i<=n; i++){
        int cnt = 0;
        while(n % i == 0){
            n /= i;
            cnt++;
        }
        if(cnt) ret.emplace_back(i, cnt);
    }
    if(n > 1) ret.emplace_back(n, 1);
    return ret;
}

int main(){
    int64_t N;
    cin >> N;
    int ans = 0;
    auto pd = prime_division(N);
    for(auto [p, n] : pd){
        int s = 0, r = 0;
        while(s+r+1 <= n){
            r++;
            s += r;
        }
        ans += r;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
while True:
    data = input().split()
    h = int(data[0])
    w = int(data[1])

    if h == 0 and w == 0:
        break

    for a in range(h):
        if a%2 == 0:
            j = 0
        else:
            j = 1
        for i in range(w):
            if i%2 == j:
                print('#',end='')
            else:
                print('.',end='')
        print()
    print()



Measured memory_bytes: 7000
#include <stdio.h>
main(){
  int kazu[101]={0},i,max;
  while(scanf("%d",&i)!=EOF){
    kazu[i]++;
  }
  max=0;
  for(i=0;i<100;i++){
    if(kazu[i] > kazu[max]){
      max=i;
    }
  }
  for(i=0;i<100;i++){
    if(kazu[i] == kazu[max]){
      printf("%d\n",i);
    }
  }
  return 0;
}

Measured memory_bytes: 596
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


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


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

	VI v(n);

	REP(i, n) {
		cin >> v[i];
	}

	SORT(v);

	ANS(v[n - 1] - v[0]);

	return 0;
}



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

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

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes\n";
    else cout << "No\n";

}


Measured memory_bytes: 256
N, Y = map(int, input().split(' '))
is_found = False
for a in range(N + 1):
    for b in range(N + 1 - a):
        c = N - a - b
        if 10000 * a + 5000 * b + 1000 * c == Y:
            is_found = True
            break
    if is_found:
        break

if is_found:
    print(a, b, c)
else:
    print(-1, -1, -1)


Measured memory_bytes: 2940
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>

using namespace std;

#define MOD 1000000007
#define INT_MAX
#define ll long long

int main()
{
	string s;
	cin >> s;

	if (s[0] == s[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return (0);
}

Measured memory_bytes: 256
package main

import (
  "fmt"
  "math"
//  "sort"
)

var N, K int

type Pos struct {
  X int64
  Y int64
}

var vec []Pos

func abs(a int64) int64 {
  if a >= 0 {
    return a
  } else {
    return -a
  }
}

func max(a, b int64) int64 {
  if a > b {
    return a
  } else {
    return b
  }
}

func min (a, b int64) int64 {
  if a < b {
    return a
  } else {
    return b
  }
}

func test(lt, rd Pos) int {
  ret := 0
  for i := 0; i < N; i++ {
    cur := vec[i]
    if(lt.X <= cur.X && cur.X <= rd.X && rd.Y <= cur.Y && cur.Y <= lt.Y) {
      ret += 1
    }
  }
  return ret
}

func getArea(lt, rd Pos) int64 {
  var ret int64 = (rd.X - lt.X) * (lt.Y - rd.Y)
  return ret
}

func main() {
  fmt.Scanf("%d %d", &N, &K)

  for i := 0; i < N; i++ {
    var x, y int64
    fmt.Scanf("%d %d", &x, &y)
    vec = append(vec, Pos{x, y})
  }

  var ret int64 = math.MaxInt64


  for i := 0; i < N; i++ {
    for j := 0; j < N; j++ {
      for k := 0; k < N; k++ {
        for l := 0; l < N; l++ {
          tl := Pos{vec[i].X, vec[j].Y}
          tr := Pos{vec[k].X, vec[l].Y}
          if tl.X > tr.X {
            continue
          }
          if tl.Y < tr.Y {
            continue
          }
          retN := test(tl, tr)
          retArea := getArea(tl, tr)
//          fmt.Printf("(%d,%d), (%d,%d) : %d with retN: %d\n", tl.X, tl.Y, tr.X, tr.Y, retArea, retN)
          if retN >= K && retArea < ret {
            ret = retArea
          }
        }
      }
    }
  }


  fmt.Println(ret)
}
//9223372036854775807
//3999999992000000004


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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n)	 for(int i = 0; i < (n); i++)
#define all(a)		 begin(a), end(a)

typedef long long int		   ll;
typedef long long unsigned int llu;

void solve(ll N) {
	int a;
	a = N / 100 + N % 10 * 100 + N / 10 % 10 * 10;
	if(a == N) printf("Yes");
	else printf("No");
}

int main() {
	ll N;
	scanf("%lld", &N);
	solve(N);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}


int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a;
		cin >> a;
		n -= a;
	}
	if (n < 0) {
		cout << -1 << endl;
	}
	else {
		cout << n << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
def dfs(s):
    if int(s) > n:
        return 0
    if all(s.count(c) > 0 for c in "753"):
        ret = 1
    else:
        ret = 0
    for c in "753":
        ret += dfs(s + c)
    return ret


n = int(input())
print(dfs("0"))

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

int main(){
    int N, X;
    cin>>N>>X;

    std::vector<int>x(N);
    for (int i = 0 ; i < N ; i++) {
        cin>>x[i];
    }
    
    std::vector<long long>map(N);
    long long p;
    long long q;
    long long r;
    long long ans = abs(X - x[0]);
    for (int i = 1 ; i < N ; i++) {
        p = abs(X - x[i]);
        q = ans;
        while((r = p % q) != 0) {
            p = q;
            q = r;
        }
        ans = q;
        if (ans == 1) break;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1408
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
string s; int bit[200009];
void add(int pos, int val) {
	for (int i = pos + 1; i <= 200000; i += i & (-i)) {
		bit[i] += val;
	}
}
int sum(int r) {
	int ret = 0;
	for (int i = r; i >= 1; i -= i & (-i)) {
		ret += bit[i];
	}
	return ret;
}
int main() {
	cin >> s;
	int n = s.size(), c = 0;
	vector<int> v(n);
	for (int i = 0; i < 26; i++) {
		vector<int> w1, w2;
		for (int j = 0; j < n; j++) {
			if (s[j] == i + 97) {
				w1.push_back(j);
				w2.push_back(n - j - 1);
			}
		}
		reverse(w2.begin(), w2.end());
		for (int j = 0; j < w2.size(); j++) v[w1[j]] = w2[j];
		if (w2.size() % 2 == 1) c++;
	}
	if (c >= 2) cout << -1 << endl;
	else {
		long long ret = 0;
		for (int i = n - 1; i >= 0; i--) {
			ret += sum(v[i]);
			add(v[i], 1);
		}
		cout << ret / 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int n;
int main()
{
  cin >> n;

  rep(i,n-1){
    rep(j,n){
      if(i>=j) continue;
      int x = i^j;
      int k = 0;
      while(!((x>>k)&1)) k++;
      cout << k+1 << " ";
    }
    cout  << "\n";
  }
  
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    int n,d,x,u,ans=0;
    cin>>n>>d>>x;
    for(int i=0;i<n;i++)
    {
        cin>>u;
        int x=(d-1)/u+1;
        ans+=x;
    }
    ans+=x;
    cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 256
n = int(input())
if n==1:
    print(0)
    import sys
    sys.exit()
ans = 0
for i in range(2,n+1):
    yakusu = 1
    for j in range(2,i+1):
        if i%j==0:
            yakusu += 1
    if yakusu==8 and i%2==1:
        ans += 1
print(ans)


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

using namespace std;

int main()
{
  int n, k, in;
  scanf("%d %d", &n, &k);
  int ans = 0;
  for (int i = 0;i < n;i++){
    scanf("%d", &in);
    if (in >= k)ans++;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
// 解説通り.
// https://img.atcoder.jp/iroha2019-day2/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
const LL MOD = 1e9 + 7;
const int MAX = 101010;
LL F[MAX], IF[MAX], A[MAX];

// Fermat's little theorem を 適用し, 大きな冪乗計算を行えるようにする.
// @param a: べき乗したい正整数.
// @param b: 指数.
// @return: べき乗した計算結果(mod版).
LL mPow(LL a, LL b){
    LL t = 1;
    while(b){
        if(b & 1) t = (t * a) % MOD;
        a *= a;
        a %= MOD;
        b >>= 1;
    }
    return t % MOD;
}

// 配列 F に, 階乗の計算結果を保存し, 配列 IF に, 逆元を保存.
// @param: 特に無し.
// @return: 配列IF の update.
void initialize(){
    F[0] = 1, IF[0] = 1;
    repx(i, 1, MAX){
        F[i] = (F[i - 1] * i) % MOD;
        IF[i] = mPow(F[i], MOD - 2) % MOD;
    }
}

// 組み合わせ(nCk)計算用(mod版).
// ※配列F, IF は, 事前に計算済のものを使う.
// @param n: 対象となる要素の個数.
// @param k: 選択する要素の個数.
// @return: 組み合わせ(nCk)の計算結果.
LL combination(LL n, LL k){
    if(n < 0 || k < 0 || k > n) return 0;
    LL ret = F[n] * IF[k] % MOD * IF[n - k] % MOD;
    return ret;
}

int main(){
    
    // 1. 入力情報.
    LL N, M;
    scanf("%lld %lld", &N, &M);
    rep(i, N) scanf("%lld", &A[i]);
    initialize();
    
    // 2. 解説通り.
    int ans = 0;
    sort(A, A + N, greater<LL>());
    rep(i, N - M + 1) ans += combination(N - i - 1, M - 1) * A[i] % MOD, ans %= MOD;
    sort(A, A + N);
    rep(i, N - M + 1) ans += (MOD - combination(N - i - 1, M - 1) * A[i] % MOD) % MOD, ans %= MOD;
    
    // 3. 出力.
    printf("%lld\n", ans);
    return 0;
    
}

Measured memory_bytes: 2560
X,N = map(int, input().split())		# 5 7 2
A =        list( map(int, input().split()) )	# 1 2 3 4 5 ...

A.sort()


if N==0:
  print(X)
  exit()

if not X in A:
  print(X)
  exit()


l = r = X
while True:
  l -= 1
  if not l in A:
    ans = l
    break

  r += 1
  if not r in A:
    ans = r
    break

print(ans)




Measured memory_bytes: 9200