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

int main(){
    int n, m; cin >> n >> m;
    vector<int> imos(n + 2, 0);
    for(int i = 0; i < m; i++){
        int c, d; cin >> c >> d;
        if(c < d){
            imos[c]++;
            imos[d]--;
        }
    }

    for(int i = 1; i <= n + 1; i++){
        imos[i] += imos[i - 1];
    }

    int counter = 0;
    for(int i = 0; i <= n + 1; i++){
        if(imos[i] > 0) counter++;
    }

    cout << n + 1 + counter * 2 << endl;
    return 0;
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111

	bool isprime(int x){
	for(int i = 2;i*i<=x;i++){
		if(x%i == 0)return false;
	}
	return x!=1;
}

	void solve(){


		ini(n);
		vi morty;
		int i = 1;
		while(morty.size()!=55){
			i++;
			int tmp = i*5+1;
			while(!isprime(tmp)){
				i++;
				tmp = i*5+1;
			}
			morty.push_back(tmp);
		}
		FOR(i,0,n){
			cout<<morty[i]<<" ";
		}
		out();








	}	























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll X,N;
    cin >>X>>N;
    map<ll,ll>num;
    rep(i,N){
        ll p;
        cin>>p;
        num[p] = 1;
        
    }

  
    ll now = INF;
    ll ans;
    rep3(i,-5,105){
        if(num[i]==1) continue;

        if(abs(X-i)<now){
            now = abs(X-i);
            ans = i;
        }
    }

    
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3600
//Subhash Suman
//Description :

#include <bits/stdc++.h>
#define ll long long int
#define pll pair<ll, ll>
#define pii pair<int, int>

using namespace std;
ll MAX = 1e9;
const int N = 1 << 12;
ll dp[N];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < N; i++)
    {
        dp[i] = MAX;
    }
    int r = 1 << n;
    for (int i = 0; i < m; i++)
    {
        ll a;
        int b;
        int curr_mask = 0;
        cin >> a >> b;
        while (b--)
        {
            int x;
            cin >> x;
            int or_mask = (1 << (x - 1));
            curr_mask |= or_mask;
        }
        for (int temp_mask = 0; temp_mask < r; temp_mask++)
        {
            int new_mask1 = temp_mask & curr_mask;
            dp[new_mask1] = min(dp[new_mask1], a);
            int new_mask2 = temp_mask | curr_mask;
            dp[new_mask2] = min(dp[new_mask2], dp[temp_mask] + a);
        }
    }

    if (dp[r - 1] >= MAX)
    {
        cout << -1 << '\n';
    }
    else
    {
        cout << dp[r - 1] << '\n';
    }
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int arr[n], sum = 0;
    for(int i = 0; i < n; ++i){
        cin >> arr[i];
        sum += arr[i];
    }
    sum = (int)round(double(sum) / double(n));
    int ans = 0;
    for(int i = 0; i < n; ++i){
        ans += (arr[i] - sum) * (arr[i] - sum);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import math
import collections
import sys

#input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]

b=input()
if b=="A":
    print("T")
elif b=="T":
    print("A")
elif b=="G":
    print("C")
elif b=="C":
    print("G")


Measured memory_bytes: 3316
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] tmpArray = br.readLine().split(" ");

		int d = Integer.parseInt(tmpArray[0]);
		int n = Integer.parseInt(tmpArray[1]);

		if(d == 0){
			if(n < 100) System.out.println(n);
			else {
				System.out.println(101);
			}
		}
		else {
			if(n == 100){
				System.out.println((int)(Math.pow(100, d)*101));
			}
			else {
				System.out.println((int)(Math.pow(100, d)*n));
			}
		}
	}

}


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

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

  if ( (A+B)  > (C+D) ) {
    cout << "Left" << endl;
  }
  else if ( (A+B)  < (C+D) ) {
    cout << "Right" << endl;
  }
  else 
     {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
//# define M_PI           3.14159265358979323846264338327950288

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
LL n,A,B,C;
VL arr;
LL rec(LL cur, LL a, LL b, LL c){
	if(cur == n){
		if(min(a, min(b,c)) > 0){
			// we subtract 30 because including some number for the first time does not cost 10 MP(Magic Points), this cost is only for combination
			return abs(a - A) + abs(b - B) + abs(c - C) - 30;
		}
		else
			return INT_MAX;
	}
	LL r1 = rec(cur+1, a, b, c);
	LL r2 = rec(cur+1, a + arr[cur], b, c) + 10;
	LL r3 = rec(cur+1, a, b + arr[cur], c) + 10;
	LL r4 = rec(cur+1, a, b, c + arr[cur]) + 10;
	return min(min(r1, r2), min(r3, r4));
}
int main() {
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
	cin>>n>>A>>B>>C;
	arr.resize(n);
	rep(i,0,n){
		cin>>arr[i];
	}
	cout<<rec(0,0,0,0);

  	return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int n;
    cin >> n;
    unordered_map<string, int> sm;
    rep(i, n) {
        string s;
        cin >> s;
        sort(all(s));
        sm[s]++;
    }
    ll ans = 0;
    for (auto p : sm) {
        int i = p.second;
        ans += ll(i) * (i-1) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10660
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <algorithm>
#include <unordered_map>

using namespace std;
const int INF = 0x3f3f3f3f;
//static const auto _____ = []()
//{
//	ios::sync_with_stdio(false);
//	cin.tie(nullptr);
//	return nullptr;
//}();
typedef long long ll;

int main(int argc, char *argv[]) {
    int N, V;
    cin >> N >> V;
    vector<ll> v(N + 1, 0);
    vector<ll> w(N + 1, 0);
    for (int i = 1; i <= N; i++) {
        cin >> v[i] >> w[i];
    }
    int upper = N * 1000; // 由题目得到的最大价值，每件物品最大价值为1000，有N件物品
    vector<vector<ll>> dp(N + 1, vector<ll>(upper+1, INF)); // 这里求最小容量，所以初始化为-INF
    dp[0][0] = 0; //前0个物品，价值为0的所消耗的最小容量为0
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= upper; j++) {
            if(j < w[i]) dp[i][j] = dp[i-1][j];
            else dp[i][j] = min(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
        }
    }
    // dp[N][i] 存储的是对应前N个物品，价值为i时的最小容量
    // 题目要求我们求最大价值，所以我们更加关注的是dp[N][i]中的i，而不是dp[N][i] = x中的x
    ll res = 0; // 求最大价值
    for (int i = 0; i <= upper; i++) {
        if (dp[N][i] <= V){
            res = i;
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int n,m,t,p;

void solve(){
    vector<vector<int>> table(n,vector<int>(m,1));

    rep(i,t){
        int d,c; cin >> d >> c;
        if(d==1){
            int H = table[0].size();
            int W1 = table.size();
            int W2 = max(c,W1-c);
            vvi cpy(W2,vi(H,0));
            for(int i=0;i<W1-c;i++){
                for(int j=0;j<H;j++){
                    cpy[i][j] = table[i+c][j];
                }
            }
            for(int i=0;i<c;i++){
                for(int j=0;j<H;j++){
                    cpy[i][j] += table[c-1-i][j];
                }
            }
            table = cpy;
        }else{
            int W = table.size();
            int H1 = table[0].size();
            int H2 = max(c,H1-c);
            vvi cpy(W,vi(H2,0));
            for(int i=0;i<W;i++){
                for(int j=0;j<H1-c;j++){
                    cpy[i][j] = table[i][j+c];
                }
            }
            for(int i=0;i<W;i++){
                for(int j=0;j<c;j++){
                    cpy[i][j] += table[i][c-1-j];
                }
            }
            table = cpy;
        }
    }

    rep(i,p){
        int x,y; cin >> x >> y;
        cout << table[x][y] << endl;
    }
}

int main(){
    while(1){
        cin >> n >> m >> t >> p;
        if(n==0 and m==0 and t==0 and p==0) break;
        solve();
    }
}



Measured memory_bytes: 3180
N = int(input())
listo = [0]
for num in range(1,N+1):
    if (num%15 == 0):
        listo.append(0)
    elif (num%3 == 0):
        listo.append(0)
    elif (num%5 == 0):
        listo.append(0)
    else:
        listo.append(num)

print(sum(listo))

Measured memory_bytes: 33756
N, Y = map(int, input().split())


ans = [-1, -1, -1]

for i in range(N+1):
    for j in range(N-i+1):
        k = N - i - j
        if 10000*i + 5000*j + 1000*k == Y:
            ans = [i, j, k]
            break
    else:
        continue
    break

print(ans[0], ans[1], ans[2])


Measured memory_bytes: 3060
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, T = MAP()
A = LIST()
# B = [max(A[i+1:N])-A[i] for i in range(N-1)] # O(N^2)時間かかる
# print(B)
min_ = INF
B = []
for i in A:
	B.append(i-min_)
	# print(min_)
	if min_ > i:
		min_ = i
# print(B)
print(B.count(max(B)))

Measured memory_bytes: 15828
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int MAX_N = 1E5;
constexpr LL INF = 1E18;
int n, m;
vector<int> e[MAX_N];
int a[MAX_N], b[MAX_N];
int fa[MAX_N];
int p[MAX_N];
LL f[MAX_N], s[MAX_N];
int find(int x) {
    while (fa[x] >= 0 && fa[fa[x]] >= 0)
        x = fa[x] = fa[fa[x]];
    return fa[x] >= 0 ? fa[x] : x;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
        a[i] = max(a[i] - b[i], 0);
    }
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u;
        --v;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    fill(fa, fa + n, -1);
    iota(p, p + n, 0);
    sort(p, p + n, [&](int i, int j) {return a[i] < a[j] || a[i] == a[j] && i < j;});
    for (int i = 0; i < n; ++i) {
        int u = p[i];
        f[u] = a[u];
        s[u] = b[u];
        for (int v : e[u]) {
            if (a[v] > a[u] || a[v] == a[u] && v > u)
                continue;
            v = find(v);
            if (u == v)
                continue;
            fa[v] = u;
            s[u] += s[v];
            f[u] = min(f[u], max((LL)a[u], f[v]) - s[v]);
        }
        f[u] += s[u];
    }
    cout << f[find(0)] << "\n";
    return 0;
}

Measured memory_bytes: 9084
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	vector<ll> v(12);
	vector<ll> vv(12);
	rep(i, 12){
		v[i] = pow(26, i);
		if(i) vv[i] = vv[i-1] + v[i-1];
		// print(v[i], vv[i]);
	}

	ll k; cin >> k;
	// k--;
	// cout << v[11] << endl;
	// if(k == 0){
	// 	cout << 'a' << endl;
	// 	return 0;
	// }

	string str = "";
	rrep(i, 12){
		// print(k);
		int num = 0;
		num = (k - vv[i]) / v[i];
		// k %= v[i];
		k -= num * v[i];
		// print(num);
		// if(!i) num++;
		if(num == 0) continue;
		str.insert(str.end(), (char)('a' + num - 1));
	}

	cout << str << endl;

	return 0;
}


Measured memory_bytes: 4088
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
//R 82 L 76
	static int v[]=new int[501];
	static long D=0;
	public static void main(String[] args) {
			int S=sc.nextInt();
			int W=sc.nextInt();
			if(S<=W)p("unsafe");
			else p("safe");
			//String S=sc.next();
			
			//int a[]=new int[N];
			//for(int i=0;i<N;i++) {}
	}
	/*static boolean v(int i,long sum1,long sum2) {
		if(i==N) {
			long b=Math.abs(sum1-sum2);
			if(b==0) {
				if(sum1<=K) {
					return true;
				}else return false;
			}else if(b%D==0) {
				if(Math.max(sum1, sum2)<=K)return true;
				else return false;
			}
			else return false;
		}
		
		if(v(i+1,sum1,sum2+v[i]%D))return true;
		
		if(v(i+1,sum1+D-v[i]%D,sum2))return true;
		return false;
		
	}*/
	
	
	
	//static int memo[][]=new int[501][1000];
	

	

	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 35784
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
ll n,m;
int dp[1005][15];
string s;
ll dfs1(ll pos,ll dep){
	if(dep==0) return 1;
	if(pos==s.length()) return 0;
	ll ans = 0;
	ans+=dfs1(pos+1,dep);
	ans%=mod;
	ans+=(9*dfs1(pos+1,dep-1)%mod);
	ans%=mod;
	return ans%mod;
}
ll dfs2(ll pos,ll dep){
	if(dep==0) return 1;
	if(pos==s.length()) return 0;
	ll ans = 0;
	if(s[pos]=='0') ans+=dfs2(pos+1,dep);
	if(s[pos]>'0')
		ans+=dfs1(pos+1,dep);
	ans%=mod;
	//cout<<ans<<endl;
	if(s[pos]>'0')
		ans+=dfs2(pos+1,dep-1);
	ans%=mod;
	if(s[pos]>'0')
		ans+=(dfs1(pos+1,dep-1)*(s[pos]-'0'-1)%mod);
	ans%=mod;
	return ans%mod;
}
int main() {
	cin>>s;
	cin>>n;
	ll ans = 0;
	ans+=dfs2(1,n-1);
	ans%=mod;
	ans+=(dfs1(1,n-1)*(s[0]-'0'-1)%mod);
	ans%=mod;
	ans+=dfs1(1,n);
	cout<<(ans+mod)%mod;
    return 0;
}



Measured memory_bytes: 256
def resolve():
    '''
    code here
    '''
    import math
    N, X = [int(item) for item in input().split()]
    xs = [int(item) for item in input().split()] + [X]
    xs.sort()

    if N > 2:
        res = math.gcd(xs[1] - xs[0], xs[2] - xs[0])

        for item in xs[3:]:
            res = math.gcd(res, item - xs[0])
    elif N == 2:
        res = math.gcd(xs[1] - xs[0], xs[2] - xs[0])
    else:
        res = xs[1] - xs[0]
    
    print(res)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 20212
from heapq import heappush, heappop
import re
from collections import deque
import sys
import math
input = sys.stdin.readline


def int_raw():
    return int(input())


def ss_raw():
    return input().split()


def ints_raw():
    return tuple(map(int, ss_raw()))


DIV = 10**9+7


def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def ncr(n, r, mod=DIV):
	r = min(r, n-r)
	ret = 1
	for i in range(1, r+1):
		ret = ret * (n-i+1) % mod
		ret = ret * mod_inv(i, mod) % mod
	return ret


def main():
    N,D = ints_raw()
    D2 = D*2+1
    return (N+D2-1)//D2
print(main())


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

int main() {
	int h, w;
	cin >> h >> w;
	int s = 0;
	if (h % 3 && w % 3) {
		s = min(h, w);
		int i = h / 2;
		for (int j = w / 3 - 1; j <= w / 3 + 2; j++) {
			int a[] = {h * j, i * (w - j), (h - i) * (w - j)};
			sort(a, a + 3);
			s = min(s, a[2] - a[0]);
		}
		{
			int t = h;
			h = w;
			w = t;
		}
		i = h / 2;
		for (int j = w / 3 - 1; j <= w / 3 + 2; j++) {
			int a[] = {h * j, i * (w - j), (h - i) * (w - j)};
			sort(a, a + 3);
			s = min(s, a[2] - a[0]);
		}
	}
	cout << s << endl;
	return 0;
}


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

int main() {
    string s;
    cin >> s;
    int x, y;
    cin >> x >> y;
    s += 'T';
    auto ft = find(begin(s), end(s), 'T');
    int xx = ft - begin(s);
    s = string(ft + 1, end(s));
    vector<int> xs, ys;
    for (int l = 0, r = 0, c = 0; r < s.size(); r++) {
        if (s[r] != 'T') continue;
        (c++ % 2 == 1 ? xs : ys).push_back(r - l);
        l = r + 1;
    }

    vector<bitset<18000>> xdp(xs.size() + 1), ydp(ys.size() + 1);
    int origin = 9000;
    xdp[0][xx + origin] = ydp[0][origin] = 1;
    for (int i = 0; i < xs.size(); i++) {
        for (int j = -9000; j < 9000; j++) {
            if (!xdp[i][j + origin]) continue;
            if (j + xs[i] < 9000) xdp[i+1][j + xs[i] + origin] = 1;
            if (j - xs[i] >= -9000) xdp[i+1][j - xs[i] + origin] = 1;
        }
    }
    for (int i = 0; i < ys.size(); i++) {
        for (int j = -9000; j < 9000; j++) {
            if (!ydp[i][j + origin]) continue;
            if (j + ys[i] < 9000) ydp[i+1][j + ys[i] + origin] = 1;
            if (j - ys[i] >= -9000) ydp[i+1][j - ys[i] + origin] = 1;
        }
    }

    cout << (xdp[xs.size()][x + origin] && ydp[ys.size()][y + origin] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 17792
def main():
    N, M = map(int, input().split())
    adj = [[float("inf")] * (N) for _ in range(N)]
    path = [[[] for _ in range(N)] for _ in range(N)]
    for _ in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        adj[a][b] = c
        adj[b][a] = c
        path[a][b].append((a, b))
        path[b][a].append((a, b))
    for i in range(N):
        adj[i][i] = 0
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if adj[i][k] + adj[k][j] < adj[i][j]:
                    adj[i][j] = adj[i][k] + adj[k][j]
                    path[i][j] = path[i][k] + path[k][j]
    used = set()
    for i in range(N):
        for j in range(N):
            for p in path[i][j]:
                used.add(p)
    print(M - len(used))


if __name__ == "__main__":
    main()


Measured memory_bytes: 47600
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N, M, K;
  cin >> N >> M >> K;
  // const int64_t L = static_cast<int64_t>(T.length());
  vector<int64_t> A(N + 1, 0);
  vector<int64_t> B(M + 1, 0);
  for (int64_t i = 1; i <= N; ++i) {
    int64_t a;
    cin >> a;
    if (A[i - 1] == INT64_MAX) {
      A[i] = A[i - 1];
      continue;
    }
    A[i] = A[i - 1] + a;
    if (A[i] > K) {
      A[i] = INT64_MAX;
    }
  }
  for (int64_t i = 1; i <= M; ++i) {
    int64_t b;
    cin >> b;
    if (B[i - 1] == INT64_MAX) {
      B[i] = B[i - 1];
      continue;
    }
    B[i] = B[i - 1] + b;
    if (B[i] > K) {
      B[i] = INT64_MAX;
    }
  }

  int64_t result = 0;
  for (int64_t a = 0; a <= N; ++a) {
    if (A[a] == INT64_MAX) {
      break;
    }
    const int64_t remain = K - A[a];
    auto itr = upper_bound(B.begin(), B.end(), remain);
    const int64_t b = max(static_cast<int64_t>(itr - B.begin()) - 1, 0L);
    if (B[b] != INT64_MAX && A[a] != INT64_MAX && A[a] + B[b] <= K) {
      // cerr << a << ", " << b << ", aa " << A[a] << ", " << B[b] << endl;
      result = max(result, a + b);
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 6356
#include<stdio.h>
#include<string.h>
int main()
{
	int a,b,c,n;
	char s[101];
	while(scanf("%d",&n)!=EOF)
	{
		a=0;
		b=0;
		for(int i=0;i<=n;i++)
		{
			scanf("%c",&s[i]);
		}
		for(int i=0;i<=n;i++)
		{
			if(s[i]=='R')
			{
				a++;
			}
			else if(s[i]=='B')
			{
				b++; 
			}
		}
		if(a>b)
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}
	return 0;	
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
int32_t main(){
    SPEED;
    int n;
    cin >> n;
    int arr[n];
    read(arr);
    int cnt = 1, ans = 0;
    for(int i = 0; i < n; ++i){
        if(arr[i] == cnt) {
            ans++;
            cnt++;
        }
    }
    if(ans == 0) cout << -1 ;
    else cout << n - ans ;
}

Measured memory_bytes: 5184
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>

using namespace std;
typedef long long LL;
const int maxn = 100005;

int x[maxn],p[maxn],c[maxn],w[maxn],n,M,d[maxn];LL K;

void mul(int *a,int *b)
{
	for (int i=1;i<n;i++) w[i]=b[a[i]];
	for (int i=1;i<n;i++) a[i]=w[i];
}
int main()
{
	#ifdef Amberframe
		freopen("agc006c.in","r",stdin);
		freopen("agc006c.out","w",stdout);
	#endif
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&x[i]);
	for (int i=1;i<n;i++) d[i]=x[i+1]-x[i];
	for (int i=1;i<n;i++) c[i]=p[i]=i;
	scanf("%d %lld",&M,&K);
	for (int u,i=1;i<=M;i++)
		scanf("%d",&u),swap(p[u],p[u-1]);
	while (K) {
		if (K&1) mul(c,p);
		mul(p,p);K>>=1;
	}
	LL cur=x[1];
	for (int i=1;i<=n;i++) printf("%lld\n",cur),cur+=d[c[i]];
	return 0;
}

Measured memory_bytes: 3200
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <fstream>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
typedef long long ll;

#define INF 1000000000
#define MAX 100000

bool isprime[MAX];
vector<int> primes;

void make_list(){
    fill(isprime, isprime+MAX, true);
    isprime[0]=isprime[1]=false;
    for(int i=2; i<=MAX/2; i++){
        if(isprime[i]){
            for(int j=i*2; j<=MAX; j+=i) isprime[j]=false;
            primes.pb(i);
        }
    }
}

int main(){
    make_list();
    int m,a,b;
    int n=primes.size();
    while(cin>>m>>a>>b, m|a|b){
        bool flg=true;
        int p,q;
        if(m%2==0) m--;
        while(flg){
            rep(i,n){
                if(m/2 < primes[i]) break;
                if( m%primes[i]==0 && isprime[m/primes[i]]==true ){
                    p = primes[i];
                    q = m/primes[i];
                    if(p>q) swap(p,q);
                    if(a*q>b*p) break;
                    flg=false;
                    break;
                }
            }
            m--;
            if(m>4)m--;
        }
        cout<<p<<" "<<q<<endl;
    }

    return 0;
}

Measured memory_bytes: 1368
import java.util.Scanner;

public class Main {

	static int[][] field;
	static boolean[][] unk;
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		boolean first=true;
		while(true){


			int h=cin.nextInt();
			if(h==0){
				break;
			}
			if(first)
				first=false;
			else{
				System.out.println();
			}
			int w=cin.nextInt();
			field=new int[h+1][w+1];
			unk=new boolean[h][w];
			boolean[][] unk2=new boolean[h][w];
			int cnt=0;
			int cnt2=0;
			for(int i = 0;i<h+1;i++){
				for(int j = 0;j<w+1;j++){
					String s =cin.next();
					if(s.equals("?")){
						unk[i][j]=true;
						cnt++;
						unk2[i][j]=true;
					}
					else{
						field[i][j]=Integer.parseInt(s);
					}
				}
			}
			for(int i = 0;i<h+1;i++){
				for(int j = 0;j<w+1;j++){
					//System.out.print(field[i][j]+" ");
				}
				//System.out.println();
			}
			cnt2=cnt;
			label:for(int aaa=0;aaa<cnt;aaa++){
				for(int i  =0;i<h;i++){
					int sum=0;
					int unkCnt=0;
					int xx=0;
					int yy=0;
					for(int j = 0;j<w;j++){
						sum+=field[i][j];
						if(unk[i][j]){
							unkCnt++;
							xx=i;
							yy=j;
						}
					}
					if(unkCnt==1){
						unk[xx][yy]=false;
						field[xx][yy]=field[i][w]-sum;
						//System.out.println(field[xx][yy]);
						cnt2--;
						continue label;
					}
				}
				for(int j  =0;j<w;j++){
					int sum=0;
					int unkCnt=0;
					int xx=0;
					int yy=0;
					for(int i = 0;i<h;i++){
						sum+=field[i][j];
						if(unk[i][j]){
							unkCnt++;
							xx=i;
							yy=j;
						}
					}
					if(unkCnt==1){
						unk[xx][yy]=false;
						field[xx][yy]=field[h][j]-sum;
						cnt2--;
						//System.out.println(field[xx][yy]);
					}
				}
			}
			if(cnt2==0){
				for(int i =0;i<h;i++){
					for(int j = 0;j<w;j++){
						if(unk2[i][j]){
							System.out.println(field[i][j]);
						}
					}
				}				
			}
			else{
				System.out.println("NO");
			}


		}
	}

}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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;
}


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  // ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  ll a, b, c; cin >> a >> b >> c;
  // string s; cin >> s;
  // vector<ll> a(N); rep(i, N) cin >> a[i];
  
  // ll ans = 0;
  bool ok = false;

  rep(i, 10000) {
    if((a * i) % b == c) {
      ok = true;
      break;
    }
  }
  // cout << ans << endl;
  cout << (ok?"YES":"NO") << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3624
def list_print(A):
    ret = str(A[0])
    for i in range(1, len(A)):
        ret += " " + str(A[i])

    print(ret)
    return True


n = int(input())
A = list(map(int, input().split()))
list_print(A)
for i in range(1, n):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = v

    list_print(A)


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

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

    int k = sqrt(2 * n) + 1;
    if(k * (k-1) != 2 * n){
        cout << "No" << endl;
        return 0;
    }

    int c = 1;
    vector<vector<int>> ans(k);    
    for(int i=0; i<k; i++){
        for(int j=i+1; j<k; j++){
            ans[i].push_back(c);
            ans[j].push_back(c);
            c += 1;
        }
    }

    cout << "Yes" << endl << k << endl;
    for(int i=0; i<k; i++){
        cout << ans[i].size();
        for(int a : ans[i]) cout << " " << a;
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 4464
const N,K=map(x->parse(Int,x),split(readline()))
const H=map(x->parse(Int,x),split(readline()))
const dp=ones(Int,N+1,N+1)*10^13
function main()
	dp[1,1]=0
	for i=1:N,j=2:N+1,k=1:i
		dp[i+1,j]=min(dp[i+1,j],dp[k,j-1]+max(0,H[i]-(k==1 ? 0 : H[k-1])))
	end
	ans=10^13
	for i=1:N+1
		ans=min(ans,dp[i,N-K+1])
	end
	println(ans)
end
main()

Measured memory_bytes: 170340
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
#define fprint(NUM,X) cout << fixed << setprecision(NUM) << (X) << endl
#define fprints(NUM,X,Y) cout << fixed << setprecision(NUM) << (X) << " " << (Y) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[550][550];
double w[1000],v[1000];
double box[200010];
static const int MAX = 100000;
static const int INFTY = (1 << 29);

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;
int indeg[MAX];

void dfs(int s){
  queue<int> que;
  que.push(s);
  V[s] = true;
  while(!que.empty()){
    int u = que.front();que.pop();
    out.push_back(u);
    for(int i = 0;i < G[u].size();i++){
      int v = G[u][i];
      indeg[v]--;
      if(indeg[v] == 0 && !V[v]){
        V[v] = true;
        que.push(v);
      }
    }
  }
}

void tsort(){
  for(int i = 0;i < N;i++){
    indeg[i] = 0;
  }
  for(int u = 0;u < N;u++){
    for(int i = 0;i < G[u].size();i++){
      int v = G[u][i];
      indeg[v]++;
    }
  }
  for(int u = 0;u < N;u++)
    if(indeg[u] == 0 && !V[u])dfs(u);

  for(list<int>::iterator it = out.begin(); it != out.end();it++){
    cout << *it << endl;
  }
}

int main(){
  int p,q,M;
  cin >> N >> M;
  for(int i = 0;i < N;i++)V[i] = false;
  for(int i = 0;i < M;i++){
    cin >> p >> q;
    G[p].push_back(q);
  }

  tsort();
  return 0;
}


Measured memory_bytes: 6216
#include <iostream>

 

 

 

using namespace std;

 

 

 

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: 3104
#include <bits/stdc++.h>
#define int long long
using namespace std;
struct ppap{int x,w;}b[100010];
inline bool cmp(ppap a,ppap b){return a.x>b.x;}
int n,a[100010];
signed main()
{
	ios::sync_with_stdio(0);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1);int cnt=0;
	for(int i=1;i<=n;){
		b[++cnt].x=a[i];int j=i;
		while(a[j]==a[i])j++,b[cnt].w++;
		i=j;
	}
	sort(b+1,b+cnt+1,cmp);int ans=0,p=0,k;
	for(int i=1;i<=n;i++)if(b[i].w>1){
		if(p==0&&b[i].w>3){
			ans=b[i].x*b[i].x;break;
		}
		p++;if(p==1)k=b[i].x;
		else{
			ans=b[i].x*k;break;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define mset(a,i) memset(a,i,sizeof(a))
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define E 1e-6
#define INF 0x3f3f3f3f
void open(){freopen("data.txt","r",stdin);}
void out(){freopen("out.txt","w",stdout);}
const int maxn = 101010;
const int MOD = 1e9 + 7;

int main()
{
    long long n,m;
    cin>>n>>m;
    cout<<n*n-m;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

const int MAXN = 1005;

int n,m,ans;
int dis[MAXN][MAXN];

char s[MAXN][MAXN];

queue<pair<int,int> > Q;

int main()
{
	scanf("%d%d",&n,&m);
	for (int i = 1;i <= n;i++)
		scanf("%s",s[i] + 1);
	for (int i = 1;i <= n;i++)
		for (int j = 1;j <= m;j++)
			if (s[i][j] == '#')
				Q.push(make_pair(i,j));
	for (int i = 1;i <= n;i++)
		for (int j = 1;j <= m;j++)
			if (s[i][j] == '.')
				dis[i][j] = -1;
	while (!Q.empty())
	{
		int x = Q.front().first,y = Q.front().second;
		Q.pop();
		if (x > 1 && dis[x - 1][y] == -1)
		{
			dis[x - 1][y] = dis[x][y] + 1;
			Q.push(make_pair(x - 1,y));
		}
		if (x < n && dis[x + 1][y] == -1)
		{
			dis[x + 1][y] = dis[x][y] + 1;
			Q.push(make_pair(x + 1,y));
		}
		if (y > 1 && dis[x][y - 1] == -1)
		{
			dis[x][y - 1] = dis[x][y] + 1;
			Q.push(make_pair(x,y - 1));
		}
		if (y < m && dis[x][y + 1] == -1)
		{
			dis[x][y + 1] = dis[x][y] + 1;
			Q.push(make_pair(x,y + 1));
		}
	}
	for (int i = 1;i <= n;i++)
		for (int j = 1;j <= m;j++)
			ans = max(ans,dis[i][j]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 10112
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>

bool ok(std::string& res, const std::string& s, const unsigned int N){
const char original = res[N-1];
for (unsigned int i = 1; i < N-1; ++i){
if ((res[i] == 'S' && s[i] == 'o') || (res[i] == 'W' && s[i] == 'x')){
res[i+1] = res[i-1];
}
else if (res[i-1] == 'S'){
res[i+1] = 'W';
}
else {
res[i+1] = 'S';
}
}

if (res[N-1] != original){
return false;
}

if (res[N-1] == 'S'){
if (s[N-1] == 'o' && res[N-2] != res[0]){
return false;
}

if (s[N-1] == 'x' && res[N-2] == res[0]){
return false;
}
}

if (res[N-1] == 'W'){
if (s[N-1] == 'o' && res[N-2] == res[0]){
return false;
}

if (s[N-1] == 'x' && res[N-2] != res[0]){
return false;
}
}


return true;
}

int main(){
std::string line;

std::getline(std::cin, line);
const unsigned int N = atoi(line.c_str());

std::getline(std::cin, line);
const std::string s = line;

std::string res = s;

if (s[0] == 'o'){
res[0] = 'S';
res[N-1] = 'S';
res[1] = 'S';
if (ok(res, s, N)){
std::cout << res << std::endl;
return 0;
}

res[0] = 'S';
res[N-1] = 'W';
res[1] = 'W';
if (ok(res, s, N)){
std::cout << res << std::endl;
return 0;
}

res[0] = 'W';
res[N-1] = 'S';
res[1] = 'W';
if (ok(res, s, N)){
std::cout << res << std::endl;
return 0;
}

res[0] = 'W';
res[N-1] = 'W';
res[1] = 'S';
if (ok(res, s, N)){
std::cout << res << std::endl;
return 0;
}

}


if (s[0] == 'x'){
res[0] = 'S';
res[N-1] = 'S';
res[1] = 'W';
if (ok(res, s, N)){
std::cout << res << std::endl;
return 0;
}

res[0] = 'S';
res[N-1] = 'W';
res[1] = 'S';
if (ok(res, s, N)){
std::cout << res << std::endl;
return 0;
}

res[0] = 'W';
res[N-1] = 'S';
res[1] = 'S';
if (ok(res, s, N)){
std::cout << res << std::endl;
return 0;
}

res[0] = 'W';
res[N-1] = 'W';
res[1] = 'W';
if (ok(res, s, N)){
std::cout << res << std::endl;
return 0;
}

}



std::cout << "-1" << std::endl;

return 0;
}

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

int main() {
  string S;
  cin >> S;
  int count = 0;
  for(int i = 0; i < S.size() / 2; i++) {
    if(S.at(i) != S.at(S.size() - i - 1)) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
def judge(c):
    #2. a1=0を設定し、b1,b2,b3を求める
    a = [0]*3
    b = [0]*3
    
    for i in range(len(b)):
        b[i] = c[0][i]
    
    #3. a2,a3を求める
    for i in range(1,len(a)):
        a[i] = c[i][i] - b[i]
        
        
    #4. ai+bj=cijを満たしているかチェック
    #   True -> Yes, False -> No
    for i in range(len(a)):
        for j in range(len(b)):
            if a[i]+b[j] is not c[i][j]:
                print("No")
                return 0
    
    print("Yes")
    return 0

def main():
    #1. 入力
    matrix = []
    for _ in range(3):
        matrix.append(list(map(int, input().split())))
        
    judge(matrix)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
const int N = 1e2 + 10;
const int mod = 1e9 + 7;
#define int long long
int n;
int ans = 2;


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

    cin >> n;
    if (n == 2)
    {
        cout << 1;
        return 0;
    }
    --n;
    for (int j = 2; j * j <= n; ++j)
    {
        if (n % j == 0)
        {
            int u = n / j;
            if (j == u) ++ans;
            else ans += 2;
        }
    }

    ++n;
    for (int j = 2; j * j <= n; ++j)
    {
        if (n % j == 0)
        {
            int n1 = n;
            while (n1 % j == 0) n1 /= j;
            n1 %= j;
            if (n1 == 1) ++ans;
            int u = n / j;
            if (u != j)
            {
                int n1 = n;
                while (n1 % u == 0) n1 /= u;
                n1 %= u;
                if (n1 == 1) ++ans;
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import collections

mod = 998244353

n = int(input())
d = list(map(int, input().split()))
dc = collections.Counter(d).most_common()
dc = sorted(dc)
if d[0] == 0 and dc[0][1] == 1:
    count = 0
    ans = 1
    last = 1
    for i in dc:
        if i[0] == count:
            ans = ans * (last ** i[1]) % mod
            last = i[1]
            count += 1
        else:
            print(0)
            exit()
    print(ans % mod)
else:
    print(0)

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


int main()
{
    int i;
    int n;
    scanf("%d", &n);
    int R[n];
    for( i = 0; i < n; ++i )
        scanf("%d", &R[i]);
    
    int min = R[0], max = R[1] - R[0];
    for( i = 1; i < n; ++i ){
        max = max < R[i] - min ? R[i] - min : max;
        min = min > R[i] ? R[i] : min;
    }
    
    printf("%d\n", max);
    
    return 0;
}

Measured memory_bytes: 1376
n, m = list(map(int, input().split()))
H = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(m)]

ans = [1] * (n)
route = [1] * (n)
for i in range(len(ab)):
    a, b = ab[i]
    if H[a-1] <= H[b-1]:
      ans[a-1] = 0

    if H[b-1] <= H[a-1]:
      ans[b-1] = 0
    
print(sum(ans))

Measured memory_bytes: 32820