akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;

int main() {
    int a, b, k;

    cin >> k >> a >> b;

    for (int i = a; i < b+1; i++)
    {
        if((i % k) == 0){
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;
    
}


Measured memory_bytes: 3596
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define Q queue
#define Qi Q<int>
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
using namespace std;
using namespace std::chrono;

 

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

  int n;
  cin >> n;
  int a[n], b[n];
  for (int i = 0;i < n; i++)
    cin >> a[i] >> b[i];
  sort(a, a + n);
  sort(b, b + n);
  if (n & 1){
    cout << b[(n + 1) / 2 - 1] - a[(n + 1) / 2 - 1] + 1 << endl;
  }
  else{
    cout << (b[n / 2 - 1] + b[n/2] - a[n / 2 - 1] - a[n / 2]) + 1 << endl;
  }
  
}


Measured memory_bytes: 6772
#include <bits/stdc++.h> 
using namespace std;
typedef vector<bool> bool_vector;
typedef vector<int> int_vector;
typedef vector<long long> long_vector;
typedef vector<double> double_vector;

typedef vector< vector<int> > int_matrix;
typedef vector<string> string_vector;
typedef vector< vector<string> > string_matrix;

int_vector get_prime(int n){  
    bool_vector memo(n+1, true);
    memo[0] = false;
    memo[1] = false;
    int_vector p_list;
    int sqn = floor(sqrt(n));
    for (size_t i = 2; i < sqn + 1; i++)
    {
        int s = n;
        if (memo[i] == true) {
            int m=i;
            while(m + i <= n) {
                m+=i;
                memo[m] = false;
            }        
        }
    }
    for (size_t i = 2; i<n+1; i++) {
        if (memo[i] == true) p_list.push_back(i);
    }
    return p_list;
}

int get_min_prime(int n){
    int s = n;
    int_vector primes = get_prime(s-1);
    size_t size = primes.size();
    while(true){
        int i;
        for (i = 0; i < size; i++)
        {
            if (s % primes[i] == 0) break;
        }
        if (i==size) return s;
        s++;        
    }
}

int main(){
    int n;
    cin >> n;
    cout << get_min_prime(n) << endl;
}

Measured memory_bytes: 384
#■標準入力ショートカット


def get_next_int():
    return int(float(input()))


def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])


def get_next_str():
    return input()


def get_next_strs(delim=" "):
    return tuple(input().split(delim))


def get_next_by_types(*value_types, delim=" "):
    return tuple([t(x) for t, x in zip(value_types, input().split(delim))])


def solve():
    N, amount = get_next_ints()

    made_amount = 0
    donuts = []
    min_donut = float('inf')
    for _ in range(N):
        donut = get_next_int()
        donuts.append(donut)
        min_donut = min(min_donut, donut)

    remain = amount - sum(donuts)
    made_amount += N
    made_amount += int(remain / min_donut)
    print(made_amount)





solve()

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
    int n;
    cin >> n;
    REP(i, n) {
        int y, m, d;
        cin >> y >> m >> d;
        int cnt = 0;
        while (1) {
            if (y == 1000 && m == 1 && d == 1) break;
            if (y % 3 == 0) {
                if (d == 20) {
                    m++;
                    d = 1;
                } else {
                    d++;
                }
                if (m == 11) {
                    y++;
                    m = 1;
                }
            } else {
                if (m % 2 == 0) {
                    if (d == 19) {
                        m++;
                        d = 1;
                    } else {
                        d++;
                    }
                } else {
                    if (d == 20) {
                        m++;
                        d = 1;
                    } else {
                        d++;
                    }
                }
                if (m == 11) {
                    y++;
                    m = 1;
                }
            }
            cnt++;
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a,b,ans=0;
	scanf("%d%d%d",&n,&a,&b);
	for(int i=1;i<=n;i++){
		int s=0;
		for(int j=i;j>0;j/=10){
			s+=j%10;
		}
		if(a<=s&&s<=b)  ans+=i;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
card_size = 3
c = []
for i in range(card_size):
  c.append(list(map(int, input().split())))

a = []
for i in range(card_size):
  a_ = []
  for j in range(card_size):
    a_.append(c[i][j])

  a.append(a_)

for i in range(card_size):
  a_ = []
  for j in range(card_size):
    a_.append(c[j][i])

  a.append(a_)

a_ = []
for i in range(card_size):
  a_.append(c[i][i])

a.append(a_)

a_ = []
for i in range(card_size):
  a_.append(c[i][card_size-i-1])

a.append(a_)

maru = [
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
]
 
ans = 0
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(8):
        for k in range(3):
            if b == a[j][k]:
                maru[j][k] = 1
                if maru[j] == [1, 1, 1]:
                    ans = 1
 
if ans == 1:
    print("Yes")
else:
    print("No")



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

int main() {
  string o, e; cin >> o >> e;
  rep(i,o.size()) {
    cout << o[i];
    if (i < e.size()) cout << e[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <climits>
#include <vector>
#include <queue>
 
#define MAX_V 1024
using namespace std;
 
void get_map();
void check();
struct edge
{
  int to;
  int weight;
};
 
 
const int INF = INT_MAX/4;
vector<edge> g[2000];
int graph[MAX_V][MAX_V];
int dist[MAX_V];
int numofedge;
int vertex;
int start;
int flag=0;
 
int main()
{
  get_map();
  check();
  //for(int i=0;i<vertex;i++)
    {
      for(int j=0;j<vertex;j++)
    {
      //if(i==j)
        {
          if(graph[start][j]<INF/2 && graph[j][j]<0)
        {
          cout << "NEGATIVE CYCLE" <<endl;
          return 0;
        }
        }
    }
    }
   
    for(int i=0;i<vertex;i++)
      {
    if(graph[start][i]>=INF/2)
      {
        cout << "INF" << endl;
      }
    else
      {
    cout << graph[start][i] << endl;
      }
      }
  return 0;
}
 
int fastmin(int a, int b)
{
    int c = a-b;
  return (((c)>>31)&(c))+b;
}
 
void check()
{
  //  int next;
  //int here = start;
  //for(int i=0;i<vertex;i++)
   
  for(int k=0;k<vertex;k++)//v=4
    {
      for(int i=0;i<vertex;i++)
    {
      int gik= graph[i][k];
      for(int j=0;j<MAX_V;j++)
        {

          //if(graph[i][k] !=INF && graph[k][j]!=INF)
        {
          graph[i][j]= min(gik+graph[k][j], graph[i][j]);
        }
        }
    }
    }
   
}
 
void get_map()
{
  int edge, from ,to;
  cin >> vertex >> numofedge >> start;
   
  fill(graph[0], graph[vertex], INF);
   
  for(int i=0;i<vertex;i++)
    {
      for(int j=0;j<vertex;j++)
      {
    if(i==j)
      {
        graph[i][j]=0;
      }
    /*else
      {
        graph[i][j]=INF;
        }*/
      }
    }
 
  /*for(int i=0;i<vertex;i++)
    {
      dist[i]=INF;
    }
  */
  for(int i=0;i<numofedge;i++)
    {
      cin>>from>>to;
      cin >> graph[from][to];
    }
 
  /*  for(int i=0;i<numofedge;i++)
    {
      int from, to, weight; 
      cin >> from >> to >> weight;
      g[from].push_back({to , weight});
   }
  */ 
 
  /*  for(int i=0;i<vertex;i++)
    {
      for(int j=0;j<vertex;j++)
    {
      cout << graph[i][j] << " ";
    }
      cout << endl;
      }*/
  // dist[start]=0;
   
  /*  cout << vertex << endl;
  for(int i=0;i<vertex;i++)
    {
      for(int j=0;j<vertex;j++)
    {
      cout << graph[i][j] << " ";
    }  
      cout << endl;    
      }*/
   
 
}

Measured memory_bytes: 5300
#include <bits/stdc++.h>
using namespace std;
int main(void){
    std::deque<int> deqa;
    std::deque<int> deqb;
    int a,b,hit,blow;
    hit = 0;
    blow = 0;
    while (cin >> a) {
        int tmp = a;
        deqa.emplace_back(tmp);
        for (int i=0;i<3;i++) {
            cin >> a;
            deqa.emplace_back(a);
        }
        for (int j=0;j<4;j++) {
            cin >> b;
            deqb.emplace_back(b);
        }
        int a1 = deqa[0];
        int b1 = deqb[0];
        int a2 = deqa[1];
        int b2 = deqb[1];
        int a3 = deqa[2];
        int b3 = deqb[2];
        int a4 = deqa[3];
        int b4 = deqb[3];
        if (a1==b1) {
            hit++;
        } else if (b1==a2 || b1==a3 || b1==a4) {
            blow++;
        }
        if (a2==b2) {
            hit++;
        } else if (b2==a1 || b2==a3 || b2==a4) {
            blow++;
        }
        if (a3==b3) {
            hit++;
        } else if (b3==a1 || b3==a2 || b3==a4) {
            blow++;
        }
        if (a4==b4) {
            hit++;
        } else if (b4==a1 || b4==a2 || b4==a3) {
            blow++;
        }
        cout << hit << " " << blow << endl;
        
        deqa.clear();
        deqb.clear();
        hit = 0;
        blow = 0;
    }
}


Measured memory_bytes: 3076
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
const int maxn = 1e5 + 10;

int n, m, deg[maxn], Max, Cnt, A, B;

int head[maxn], cnt;
struct Edge { int to, nxt; } e[maxn << 1];
void addedge(int a, int b) {
	e[++cnt] = (Edge) { b, head[a] }; head[a] = cnt;
	e[++cnt] = (Edge) { a, head[b] }; head[b] = cnt;
	++deg[a], ++deg[b];
}

void dfs(int u, int fa = 0) {
	if (u == A && fa) std::cout << "Yes\n", exit(0);
	if (u == B) return ;
	for (int i = head[u], v; i; i = e[i].nxt)
		if ((v = e[i].to) != fa) dfs(v, u);
}
int main() {
	std::ios::sync_with_stdio(false), std::cin.tie(0), std::cout.tie(0);
	std::cin >> n >> m;
	for (int i = 0, a, b; i < m; ++i) std::cin >> a >> b, addedge(a, b);
	for (int i = 1; i <= n; ++i) if (deg[i] & 1) {
		std::cout << "No\n";
		return 0;
	} else {
		Max = std::max(Max, deg[i]);
		if (deg[i] == 4) { ++Cnt; if (A) B = i; else A = i; }
	}
	if (Max < 4 || (Max == 4 && Cnt == 1)) { std::cout << "No\n"; return 0; }
	if (Max > 4 || Cnt > 2) { std::cout << "Yes\n"; return 0; }
	dfs(A), std::cout << "No\n";
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535897932;
const ll MOD = 1000000007;

const int N = 13;
ll dp[100001][N] = { 0 };

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

	dp[0][0] = 1;
	int mul = 1;
	for (int i = 0; i < s.size(); i++) {
		char c = s[s.size()-1-i];
		if (c == '?') {
			rep(k, 10) rep(j, N) {
				dp[i+1][(k * mul + j) % N] += dp[i][j];
				dp[i+1][(k * mul + j) % N] %= MOD;
			}
		}
		else {
			int k = c - '0';
			rep(j, N) {
				dp[i + 1][(k * mul + j) % N] += dp[i][j];
				dp[i + 1][(k * mul + j) % N] %= MOD;
			}
		}
		mul = (mul * 10) % N;
	}
	cout << dp[s.size()][5] << endl;
	return 0;
}

Measured memory_bytes: 10624
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//辺のための構造体
struct Edge{
    int from, to;
    Int cost;
};

template <typename T>
vector<T> dijkstra(vector<vector<Edge>> &G, int s) {
    int V = G.size();
    vector<T> d(V); fill(d.begin(), d.end(), numeric_limits<T>::max());
    priority_queue<pair<T, int> , vector< pair<T, int> >, greater< pair<T, int> > > que;
    d[s] = 0;
    que.push(make_pair(0,s));

    while(!que.empty()) {
        pair<T, int> p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        for(int i=0; i<G[v].size(); i++) {
            Edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(make_pair(d[e.to], e.to));
            }
        }
    }
    return d;
}



int main(){
    cin.tie(0);

    int N, M, S, T;
    cin >> N >> M >> S >> T;
    vector<vector<Edge>> snu(N+1);
    vector<vector<Edge>> yen(N+1);
    for (int i = 0; i < M; i++){
        int u, v;
        Int a, b;
        cin >> u >> v >> a >> b;
        Edge e;
        e.to = v;
        e.cost = a;
        yen[u].push_back(e);
        e.to = u;
        yen[v].push_back(e);
        e.cost = b;
        snu[v].push_back(e);
        e.to = v;
        snu[u].push_back(e);
    }
    vector<Int> vyen = dijkstra<Int>(yen, S);
    vector<Int> vsnu = dijkstra<Int>(snu, T);
    vector<Int> v(N+1);
    for (int i = 1; i <= N; i++){
        v[i] = vyen[i] + vsnu[i];
    }
    vector<Int> ans(N+1);
    Int mi = 10000000000000000;
    for (int i = N; i >= 1; i--){
        mi = min(v[i], mi);
        ans[i] = mi;
    }
    for (int i = 1; i <= N; i++){
        cout << 1000000000000000LL - ans[i] << endl;
    }

    return 0;
} 


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

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;

//少数点表示
//cout <<std::fixed << std::setprecision(14)

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int n,m;
    cin >>n >> m;
    if(n==m){
        cout << "Yes"<<endl;
    }else{
        cout << "No" << endl;
    }
    return 0;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)


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

    ll count = 1;
    ll ans = 0;
    rep(i,n){
        ll tmp;
        cin >> tmp;
        if(tmp == count){
            count++;
        }else{
            ans++;
        }
    }

    if(count == 1){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }

    

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define maxc 100010
struct ss{
    ll a,b,c;
    int add;
}s[maxc];
int cmp(ss x,ss y){
    if(x.a==y.a)
        return x.b<y.b;
    else
        return x.a<y.a;
}
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>s[i].a>>s[i].b;
        s[i].add=i;
    }
    sort(s,s+m,cmp);
    int k=s[0].a;
    int l=1;
    for(int i=0;i<m;i++){
        if(s[i].a>k){
            k=s[i].a;
            l=1;
        }
            s[i].c=l;
            l++;
    }
    /*for(int i=0;i<m;i++)
        cout<<s[i].a<<" "<<s[i].b<<" "<<s[i].add<<" "<<s[i].c<<endl;*/
    int a[maxc][15];
    for(int i=0;i<m;i++){
        int q=0;
        while(s[i].c!=0){
            a[s[i].add][q++]=s[i].c%10;
            s[i].c/=10;
        }
        while(q<6)
            a[s[i].add][q++]=0;
        while(s[i].a!=0){
            a[s[i].add][q++]=s[i].a%10;
            s[i].a/=10;
        }
        while(q<12)
            a[s[i].add][q++]=0;
    }
    for(int i=0;i<m;i++){
        for(int j=11;j>=0;j--)
            cout<<a[i][j];
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 10496
import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
# MOD = 10 ** 9 + 7
MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

def main():
    h, w = ns()
    ch, cw = ns()
    ch, cw = ch - 1, cw - 1
    dh, dw = ns()
    dh, dw = dh - 1, dw - 1

    map = [list(input()) for _ in range(h)]

    table = [[-1 for _ in range(w)] for __ in range(h)]
    group = {}

    pos = [[-1, 0], [1, 0], [0, -1], [0, 1]]

    cnt = -1
    for i in range(h):
        for j in range(w):
            if map[i][j] == "." and table[i][j] == -1:
                cnt += 1
                group[cnt] = [[i, j]]
                que = collections.deque()
                que.append([i, j])
                table[i][j] = cnt

                while que:
                    y, x = que.popleft()
                    for py, px in pos:
                        ty = y + py
                        tx = x + px
                        if 0 <= ty < h and 0 <= tx < w:
                            if map[ty][tx] == "." and table[ty][tx] == -1:
                                table[ty][tx] = cnt
                                que.append([ty, tx])
                                group[cnt].append([ty, tx])

    ini_group = table[ch][cw]
    req_group = table[dh][dw]
    done_group = set()
    done_group.add(ini_group)

    nxt = {ini_group}
    ans = 0

    while len(nxt):
        if req_group in done_group:
            break

        tmp = []
        for nxti in nxt:
            tmp.extend(group[nxti])
        que = collections.deque(tmp)

        nxt = set()
        for _ in range(len(que)):
            y, x = que.popleft()
            for py in range(-2, 3):
                for px in range(-2, 3):
                    if i == 0 and j == 0:
                        continue
                    ty = y + py
                    tx = x + px
                    if 0 <= ty < h and 0 <= tx < w:
                        if table[ty][tx] != -1 and table[ty][tx] not in done_group:
                            nxt.add(table[ty][tx])
                            done_group.add(table[ty][tx])

        ans += 1

    print(ans if req_group in done_group else -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 184852
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long t = in.nextLong() * 1000;
            long a = in.nextLong() * 1000;

            long[] h = in.nextLongArray(n);

            int ans = -1;
            long min = Long.MAX_VALUE;
            for (int i = 0; i < n; i++) {
                if (min > Math.abs(t - h[i] * 6 - a)) {
                    ans = i;
                    min = Math.abs(t - h[i] * 6 - a);
                }
            }

            out.println(ans + 1);
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public long nextLong() {
            return Long.parseLong(nextString());
        }

        public long[] nextLongArray(int n) {
            long[] res = new long[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextLong();
            }
            return res;
        }

    }
}



Measured memory_bytes: 21716
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const long long MOD = 1000000007;


vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main(void){
    ll n;
    ll p;
    cin >> n >> p;
    const auto &res = prime_factorize(p);
    ll ans = 1;
    REP(i, res.size()){
        // cout << res[i].first << " " <<  res[i].second << endl;
        if( (res[i].second / n) != 0){
            ans *= pow(res[i].first , (res[i].second / n));
        }
    }
    cout << ans << endl;
    return 0;
}

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

void dfs(int v, vector<vector<bool>> graph, vector<bool> &memo){
    memo[v] = true;
    for(int w = 0; w < 50; w++){
        if(graph[v][w] == false) continue;
        if(memo[w] == true) continue;
        dfs(w, graph, memo);
    }
}

int main(){

    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    vector<vector<bool>> graph(50, vector<bool>(50));
    for(int i = 0; i < M; i++){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    int ans = 0;

    for(int i = 0; i < M; i++){
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

        vector<bool> memo(50, false);

        dfs(0, graph, memo);

        bool bridge = false;
        for(int j = 0; j < N; j++) if(memo[j] == false) bridge = true;
        if(bridge) ans++;

        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main() {
   int h,w; cin >> h >> w;
   vector<string> a(h + 2);
   rep(i,h) cin >> a[i + 1];

    for (int i = 0; i < h + 2; ++i) {
        if(i == 0 || i == h + 1) for (int j = 0; j < w + 2; ++j) a[i] += '#';
        else if(i < h + 1){
            a[i].insert(0,"#");
            a[i].insert(w + 1,"#");
        }
    }
    rep(i,h + 2) print(a[i]);
}

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

const int N=200005;
const int inf=1000000000;

struct ST{
	int l,r,mn,pos;
}t[2][N<<2];
int n,l,r,m;
int a[N],b[N];
struct node{
	int l,r,x,y;
	node(){}
	node(int l,int r,int x,int y):l(l),r(r),x(x),y(y){}
	friend bool operator<(node c,node d){
		return a[c.x]>a[d.x];
	}
};
priority_queue<node> q;

void update(int k){
	t[0][k].mn=min(t[0][k<<1].mn,t[0][k<<1|1].mn);
	if (t[0][k].mn==t[0][k<<1].mn) t[0][k].pos=t[0][k<<1].pos;
	else t[0][k].pos=t[0][k<<1|1].pos;
	t[1][k].mn=min(t[1][k<<1].mn,t[1][k<<1|1].mn);
	if (t[1][k].mn==t[1][k<<1].mn) t[1][k].pos=t[1][k<<1].pos;
	else t[1][k].pos=t[1][k<<1|1].pos;
}

void build(int k,int l,int r){
	t[0][k].l=l; t[0][k].r=r;
	t[1][k].l=l; t[1][k].r=r;
	if (l==r){
		t[l&1][k].mn=a[l];
		t[l-1&1][k].mn=inf;
		t[0][k].pos=t[1][k].pos=l;
		return;
	}
	int mid=(l+r)>>1;
	build(k<<1,l,mid);
	build(k<<1|1,mid+1,r);
	update(k);
}

void query(int tp,int k,int L,int R,int &mn,int &p){
	if (L<=t[tp][k].l&&t[tp][k].r<=R){
		if (t[tp][k].mn<mn) mn=t[tp][k].mn,p=t[tp][k].pos;
		return;
	}
	int mid=(t[tp][k].l+t[tp][k].r)>>1;
	if (L<=mid) query(tp,k<<1,L,R,mn,p);
	if (R>mid) query(tp,k<<1|1,L,R,mn,p); 
}

void push(int l,int r){
	int a,b,p1,p2;
	a=b=inf;
	query(l&1,1,l,r,a,p1);
	query(l-1&1,1,p1,r,b,p2);
	q.push(node(l,r,p1,p2));
}

int main(){
	int i; node k;
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	build(1,1,n);
	push(1,n);
	while (!q.empty()){
		k=q.top(); q.pop();
		b[++m]=k.x; b[++m]=k.y;
		if (k.l+1<k.x) push(k.l,k.x-1);
		if (k.y+1<k.r) push(k.y+1,k.r);
		if (k.x+1<k.y) push(k.x+1,k.y-1);
	}
	for (i=1;i<=m;i++) printf("%d ",a[b[i]]);
	return 0;
}

Measured memory_bytes: 22772
s = input()
for i in [0]*int(input()):
    l = input().split()
    if l[0] == "print":print(s[int(l[1]):int(l[2])+1])
    elif l[0] == "replace":s = s[0:int(l[1])] + l[3] + s[int(l[2])+1:]
    else:s = s[:int(l[1])] + "".join(reversed(s[int(l[1]):int(l[2])+1])) +s[int(l[2])+1:]


Measured memory_bytes: 5616
n = int(input())
arr = list(map(int,input().split()))
acc = [0 for i in range(n)]
acc[0] = arr[0]

for i in range(1,n):
    acc[i] = acc[i-1]+arr[i]

alr = {}
ans = 0
# print(acc)
for i in range(n):
    if acc[i] not in alr:
        alr[acc[i]] = 1
    else:
        ans += alr[acc[i]]
        alr[acc[i]] += 1
    # print(ans)
    # print(acc)

ans += acc.count(0)
print(ans)

Measured memory_bytes: 41076
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
const int INF = 100000000;


ll n;
ll a[100010];
ll b[100010];

int main(){

    cin >> n;
    for(int i = 1; i <= n+1; i++){
        cin >> a[i];
    }
    for(int i = 1; i <= n; i++){
        cin >> b[i];
    }

    ll ans = 0;

    for(int i = n; i > 0; i--){
        if(a[i+1] > b[i]){
            ans += b[i];
            b[i] = 0;
        }
        else{
            ans += a[i+1];
            b[i] -= a[i+1];
        }

        if(a[i] > b[i]){
            ans += b[i];
            a[i] -= b[i];
        }
        else{
            ans += a[i];
            a[i] = 0;
        }
    }

    cout << ans << endl;

    return 0;
}

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

#define say(a) cout<<a<<endl
#define say1(a,b) cout<<a<<" "<<b<<endl
#define loop(a,b) for(int i=a;i<b;i++)
vector<int> v[200009];
int main()
{
    int n,m,s=0;
    scanf("%d %d",&n,&m);
    m*=2;
    m++;
    s=n/(m);
    s+=((n%m)>0)?1:0;
    say(s);
}




Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define EPS 1000000
using namespace std;
int main(){
	long long n,i;
	double fs,ans=0,f;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>f;
		ans+=(EPS/f);
	}
	fs=ans/EPS;
	cout<<1/fs<<endl;
	return 0;
}

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

using namespace std;

int main()
{
    char ch[15];
    scanf("%s",ch);
    int num[15]={0};
    int s[150] = {0};
    int flag =1;
    if(ch[0] != 'A') flag =0;
    if(ch[1] >= 'A'&&ch[1]<='Z') flag =0;
    if(ch[strlen(ch)-1] >='A'&&ch[strlen(ch)-1]<='Z')flag = 0;
    for(int i =2;i<strlen(ch)-1;i++)
    {
        s[ch[i]]++;
    }
    int cnt =0;
    for(int i ='A';i<'Z';i++)
    {
        if(s[i]>0) cnt++;
        if(s[i]!=0&&i!='C') flag = 0;
        if(s[i] >1&&i=='C') flag = 0;
    }
    if(cnt == 0) flag = 0;
    if(flag == 0) printf("WA");
    else printf("AC");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int retu[8][3] = {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}, {0, 3, 6}, {1, 4, 7}, {2, 5, 8}, {0, 4, 8}, {2, 4, 6}};

int main(){
    int A[9];
    cins(A, A + 9);
    int N;
    cin >> N;
    int b[N];
    cins(b, b + N);
    for(int i = 0; i < 9; i++){
        for(int j: b){
            if(j == A[i]){
                A[i] = -1;
                break;
            }
        }
    }
    bool ans = false;
    for(int i = 0; i < 8; i++){
        int sum = 0;
        for(int j: retu[i]){
            sum += A[j];
        }
        if(sum == -3){
            ans = true;
        }
    }
    Yes(ans);
}


Measured memory_bytes: 256
SA = list(input())
SB = list(input())
SC = list(input())

L = len(SA) + len(SB) + len(SC) + 10

turn = "a"

for i in range(L):
    if turn == "a":
        if len(SA) == 0:
            print("A")
            break
        else:
            turn = SA[0]
            SA.pop(0)
    elif turn == "b":
        if len(SB) == 0:
            print("B")
            break
        else:
            turn = SB[0]
            SB.pop(0)
    elif turn == "c":
        if len(SC) == 0:
            print("C")
            break
        else:
            turn = SC[0]
            SC.pop(0)

    


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N):
    for x in range(50000+1):
        if math.floor(x*1.08) == N:
            return x
    return ':('


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6720
N,M = map(int,input().split())
A = [[0]*N,[1]*N]
A[0][0] = 1
A[1][0] = 0

for i in range(M):
  x,y = map(int,input().split())
  if A[0][x-1] > 0:
    A[0][y-1] += 1
  else:
    A[1][y-1] += 1
  if A[1][x-1] > 0:
    A[1][x-1] -= 1
  else:
    A[0][x-1] -= 1
print(len([i for i in A[0] if i > 0]))

Measured memory_bytes: 11208
import java.io.*;
import java.util.*;
class Program{

}
class Main{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int temp,max = Integer.MIN_VALUE, sum = 0;
        while(N-->0){
            temp = in.nextInt();
            max = Math.max(temp, max);
            sum += temp;
        }
        if (sum-max>max) System.out.println("Yes");
        else System.out.println("No");
    }
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  ll n, m;
  cin >> n >> m;

  ll ans = 1;
  for(ll i = 1; i * i <= m; ++i)
  {
    if (m % i == 0 && i * n <= m)
    {
      ans = max(ans, i);
      if (m / i * n <= m) ans = max(ans, m / i);
    }
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

int main() {
   int A = 0;
   int B = 0;
   int C = 0;
  
  cin >> A >> B >> C;
  
  if(A+B+C >21)
  {cout << "bust" <<endl;}
  else
  {cout << "win" << endl;}
  
  
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long LL;
#define M(a,b) memset(a,b,sizeof(a))
#define pb push_back
const int maxn = 100000+5;
const LL mod = 1000000007;
int main() {

    int sx,sy,tx,ty;
    scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
    for (int i=sy;i<ty;++i) {
        putchar('U');
    }
    for (int i=sx;i<tx;++i) {
        putchar('R');
    }
    for (int i=sy;i<ty;++i) {
        putchar('D');
    }
    for (int i=sx;i<tx;++i) {
        putchar('L');
    }
    putchar('D');
    for (int i=sx;i<tx+1;++i) {
        putchar('R');
    }
    for (int i=sy;i<ty+1;++i) {
        putchar('U');
    }
    putchar('L');
    putchar('U');
    for (int i=sx;i<tx+1;++i) {
        putchar('L');
    }
    for (int i=sy;i<ty+1;++i) {
        putchar('D');
    }
    putchar('R');
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "map"
#include "vector"

using namespace std;
int main()
{
	int n;
	int a1=0,a2=0,a4=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int num;
		cin>>num;
		if(num%4==0)
			a4++;
		else if(num%2==0)
			a2++;
		else
			a1++;
	}
	if((a4+1==a1&&a2==0)||(a4>=a1))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;	
	system("pause");
}


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

int main() {
 int k, s, a;
  cin >> k >> s;
  a = 0;
  
  for(int i = 0; i <= k; i++){
    for(int j = 0; j <= k; j++){
      if(s - i - j >= 0 && s - i - j <= k){
        a++;
      }
    }
  }
  
  cout << a << endl;
}

Measured memory_bytes: 256
def dt(n):
  table = [0] * (n + 1)
  r = 0
    
  for i in range(1, n + 1):
    for j in range(i, n + 1, i):
      table[j] += 1
    
  for i in range(1,n+1):
    r += i*table[i]
    
  return r

N = int(input())
print(dt(N))

Measured memory_bytes: 146112
def saiki(i,cost,score_list):
   if i == n:
       if min(score_list) >= x:
           ans.append(cost)
   else:
       temp = [score_list[j]+book_list[i][j+1] for j in range(m)]
       saiki(i+1,cost,score_list)
       saiki(i+1,cost+book_list[i][0],temp)

n,m,x = map(int,input().split())
book_list = [list(map(int, input().split())) for _ in range(n)]
ans=[]
saiki(0,0,[0]*m)
print(min(ans) if len(ans)!=0 else -1)

Measured memory_bytes: 9312
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    rep(i, 0, n) cin >> x[i];

    int ans = 0;
    rep(i, 0, n) ans += min(x[i], abs(x[i] - k)) * 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
int n,dis[100005];
vector<pii> v[100005];
priority_queue<pii,vector<pii>,greater<pii>> pq;
bool vis[100005];
void dijkstra(){
    pq.push(mpr(0,0));
    rep(i,1,n) dis[i]=inf;
    while(!pq.empty()){
        pii g=pq.top();pq.pop();
        int c=g.se;
        if(vis[c]) continue;
        vis[c]=1;
        rap(i,0,v[c].size()){
            pii x=v[c][i];int to=x.fi,cost=x.se;
            if(dis[to]>dis[c]+cost){
                dis[to]=dis[c]+cost;
                pq.push(mpr(dis[c]+cost,to));
            }
        }
    }
}
void add(int x,int y,int c){
    v[x].pb(mpr(y,c));
}
int main()
{
    scanf("%d",&n);
    if(n==1){printf("1");return 0;}
    rep(i,1,n){
        add(i,(i==n?1:i+1),1);
        if(i!=(i-1)*10%n+1) add(i,(i-1)*10%n+1,0);
    }
    add(0,2,1);
    dijkstra();
    //rep(i,0,n) printf("%d%c",dis[i],i==n?'\n':' ');
    printf("%d\n",dis[1]);
    return 0;
}

Measured memory_bytes: 6908
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vll vector<long long>
#define pll pair<long long, long long>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1e18
 

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
  ll n;
  cin>>n;
  ll i,j;
  ll a[n];
  array<ll,2> freq[2][100005];
  clr(freq);
  for(i=0;i<n;i++)
  {
    cin>>a[i];
    freq[i%2][a[i]][0]++;
    freq[i%2][a[i]][1]=a[i];
  }
  for(i=0;i<2;i++)
  {
    sort(freq[i],freq[i]+100005);
    reverse(freq[i],freq[i]+100005);
  }
  ll res=INF;
  for(i=0;i<2;i++)
  {
    for(j=0;j<2;j++)
    {
      if(freq[0][i][1]==freq[1][j][1])
      {
        continue;
      }
      // cout<<freq[0][i][1]<<" "<<freq[1][j][1]<<"\n";
      ll tans=0;
      tans+=(n-freq[0][i][0]-freq[1][j][0]);
      res=min(res,tans);
      // cout<<tans<<"\n";
    }
  }
  cout<<res<<"\n";

}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 7556
#![allow(unused_imports)]
#![allow(unused_variables)]

use itertools::Itertools;
use proconio::marker::*;
use proconio::*;

#[fastout]
fn main() {
    input! {
        x:i32, y:i32, z:i32,
    }

    println!("{} {} {}", z, x, y);
}


Measured memory_bytes: 2172
package main

import "fmt"

func getGcd(a, b int) (g int) {
	if a < b {
		g = getGcd(b, a)
	} else {
		if a%b == 0 {
			g = b
		} else {
			g = getGcd(b, a%b)
		}
	}
	return
}

func abs(a int) (b int) {
	if a < 0 {
		b = -a
	} else {
		b = a
	}
	return
}

func main() {
	var n, x int
	fmt.Scan(&n, &x)

	p := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
	}

	max := abs(x - p[0])
	for i := 0; i < n; i++ {
		max = getGcd(max, abs(x-p[i]))
	}

	fmt.Println(max)
}


Measured memory_bytes: 5504
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var x = p[0];
		var y = p[1];
		for(int i = 0; i <= Math.Max(x, 100-x); i++)
		{
			if(i * 2 + (x-i)*4==y)
			{
				Console.WriteLine("Yes");
				return;
			}
		}
		Console.WriteLine("No");
	}

	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 27544
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    vector<string> s(3);
    rep(i,3){
        cin>>s[i];
        cout<<s[i][i];
    }
    cout<<endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		boolean[][] array = new boolean[h][w];
		int h2 = sc.nextInt();
		int w2 = sc.nextInt();
		for (int i = 0; i < h2; i++) {
			Arrays.fill(array[i], true);
		}
		
		for (int i = 0; i < w2; i++) {
			for (int j = 0; j < array.length; j++) {
				array[j][i] = true;
			}
		}
		
		int count = 0;
		
		for (boolean[] tmp : array) {
			for (boolean flag : tmp) {
				if (!flag) {
					++count;
				}
			}
		}
		
		System.out.println(count);
	}
}


Measured memory_bytes: 22996