akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdlib;

void main() {
    auto K = readln.chomp.to!int;
    long[] ans = iota(1L, 10L).array;

    int idx = 0;

    while (idx < K) {
        auto L = ans.length.to!int;
        foreach (i; idx..L) {
            auto ld = ans[i] % 10;
            if (ld > 0) ans ~= ans[i] * 10 + ld - 1;
            ans ~= ans[i] * 10 + ld;
            if (ld < 9) ans ~= ans[i] * 10 + ld + 1;
        }
        idx = L;
    }

    ans[K-1].writeln;
}


Measured memory_bytes: 9852
n , e , r = map(int,input().split())
inf = 1145141919810364364
es = []

def bf(st):
    d = [inf] * n
    d[st] = 0
    i = 0
    while True:
        update = False
        i += 1
        if i > n:
            return -1
        
        for p,q,r in es:
            if d[p] != inf and d[q] > d[p] + r:
                d[q] = d[p] + r
                update = True
        if update == False:
            break   
            
    return d

for _ in range(e):
    x , y , z = map(int,input().split())
    es.append([x,y,z])

a = bf(r)
if bf(r) == -1:
    print("NEGATIVE CYCLE")
else:
    for i in range(n):
        if a[i] == inf:
            print("INF")
        else:
            print(a[i])


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)
typedef vector<int> Array;
typedef vector<Array> Graph;
int visit[100005];
Graph G(100005);
Graph G2(100005);
vector<int> path;
int N;
bool flag = false;
int cnt;

void dfs(int now){
    visit[now] = 1;
    for(int i=0;i<G[now].size();i++){
        int next = G[now][i];
        if(visit[next]==-1){
            if(next==N-1){
                flag = true;
            }else{
                if(!flag){
                    dfs(next);
                }else{
                    break;
                }
            }
        }
    }
    if(flag) path.push_back(now);
}

int dfs_count(int now){
    cnt++;
    visit[now] = 1;
    for(int i=0;i<G2[now].size();i++){
        int next = G2[now][i];
        if(visit[next]==-1){
            dfs_count(next);
        }
    }
}

int main(){
    cin >> N;
    int as[N];
    int bs[N];
    REP(i, N-1){
        int a, b;
        cin >> a >> b;
        a--;b--;
        as[i] = a;
        bs[i] = b;
    }
    REP(i, N-1){
        G[as[i]].push_back(bs[i]);
        G[bs[i]].push_back(as[i]);
    }
    REP(i, N) visit[i] = -1;
    path.push_back(N-1);
    dfs(0);
    int cut1 = path[path.size()/2 - 1];
    int cut2 = path[path.size()/2];
    if(cut1 > cut2) swap(cut1, cut2);
    REP(i, N-1){
        if(as[i]>bs[i]) swap(as[i], bs[i]);
        if(as[i]!=cut1 || bs[i]!=cut2){
            G2[as[i]].push_back(bs[i]);
            G2[bs[i]].push_back(as[i]);
        }
    }
    REP(i, N) visit[i] = -1;
    cnt = 0;
    dfs_count(0);
    int x = cnt;
    REP(i, N) visit[i] = -1;
    cnt = 0;
    dfs_count(N-1);
    int y = cnt;/*
    REP(i, path.size()){
        cout << path[i] << " ";
    }
    cout << endl;
    cout << x << " " << y << endl;
    */
    cout << (x>y?"Fennec":"Snuke") << endl;
    return 0;
}

Measured memory_bytes: 15864
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */

ll pow_i(ll x, ll p){
    ll ans = 1;
    while(p > 0){
        ans *= x;
        p--;
    }
    return ans;
}

ll N, A, B, C;
vector<vector<ll>> make_set(ll X, vector<ll> L){
    vector<vector<ll>> ans(3);
    for (int i = 0; i < N; ++i) {
        ll d = X % 4;
        if(d != 3){
            ans[d].push_back(L[i]);
        }
        X /= 4;
    } // end i
    return ans;
}

ll cost(ll A, vector<ll> target){
    ll ret = 0;
    ll sum = accumulate(target.begin(), target.end(), 0ll);
    ret += abs(A - sum);
    ret += 10 * (target.size() - 1);
    return ret;
}

ll calc(int X, const vector<ll>& L){
    auto V = make_set(X, L);
    if(V[0].empty() or V[1].empty() or V[2].empty()){
        return INF;
    }

    ll ans = cost(A, V[0]) + cost(B, V[1]) + cost(C, V[2]);

    return ans;
}

void solve(istream &cin) {
    cin >> N >> A >> B >> C;
    if(!cin) return;
    vector<ll> L(N) ;
    for (int i = 0;i < N; ++i) {
        cin >> L[i];
    } // end i
    ll end = pow_i(4, N);
    ll ans = INF;
    for (int i = 0; i < end; ++i) {
        auto res = calc(i, L);
        ans = min(res, ans);
    } // end i

    cout << ans << endl;
}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    cerr << "DEBUG MODE" << endl;
    string test_cases = "test.txt";
    auto fs = fstream(test_cases, fstream::in);
    while(fs) {
        solve(fs);
    }
#else
    solve(cin);
#endif
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.Double;

public class Main {

    public static void main(String[] args) {
      Scanner reader=new Scanner(System.in);
      int  n=reader.nextInt();
      int  k=reader.nextInt();
      int d[]=new int[k];
      int a[][]=new int[k][k];
      Set<Integer> set=new HashSet<Integer>();
      for(int i=0;i<k;i++)
      {
        d[i]=reader.nextInt();
        for(int j=0;j<d[i];j++)
        {
          set.add(reader.nextInt());

        }

      }
      System.out.println(n-set.size());

      }
}


Measured memory_bytes: 46356
import java.util.*;
class Main {
    public static final int MAX = 1000000000;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int ar[] = new int[n];
        for(int i = 0; i < n; i++) {
            ar[i] = sc.nextInt();
        }
        int dp[] = new int[n];
        Arrays.fill(dp, MAX);
        dp[n - 1] = 0;
        for(int i = n - 2; i >= 0; i--) {
            for(int j = 1; j <= k; j++) {
                if(i + j < n) {
                    dp[i] = Math.min(dp[i], dp[i + j] + Math.abs(ar[i + j] - ar[i]));
                }
            }
        }
        System.out.println(dp[0]);
    }
}


Measured memory_bytes: 53116
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    string s[2];
    cin >> s[0] >> s[1];
    bool flag = true;
    rep(i,3){
        if(s[0][i] != s[1][2-i]) flag = false;
    }
    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF=999999999;

int main() {
 string N;
 cin>>N;
 bool k=false;
 for(int i=1;i<N.size();i++){
     if(N[i]!='9'){k=true;break;}
 }
 if(k){cout<<N[0]-'1'+9*(N.size()-1)<<endl;}
 else{cout<<9*(N.size()-1)+N[0]-'1'+1<<endl;}
 
 return 0;}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ru = [0] * (n+1)
mod = 1000000007
for i in range(n):
  ru[i+1] = (ru[i] +pow(i+1,mod-2,mod))%mod
kei = [0] * n
for i in range(n):
  kei[i] += ru[n-i]
  kei[i] += ru[i+1]-1
fact = [1]*(n+10000+1)
for i in range(n+10000):
    fact[i+1] = ((i+1) * fact[i]) % mod
ans = 0
for i in range(n):
  ans += (fact[n] * kei[i])%mod*a[i]
  ans %= mod
print(ans)

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

typedef long long   ll;
typedef long double ld;
using namespace std;

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

    int t=1;
    while(t*(t+1)<2*x){
        t++;
    }
    cout << t << "\n";
    return 0;
}

Measured memory_bytes: 256
n = int(input())
pancake = list(map(int, input().split()))

ans = 10**9
for i in range(4):
    cnt = [0] * n
    cnt[0] += i
    for j in range(n-1):
        diff = pancake[j] - cnt[j]
        if diff > 0:
            cnt[j] += diff
            cnt[j+1] += diff
    diff = pancake[n-1] - cnt[n-1]
    if diff > 0:
        cnt[n-1] += diff

    if ans > sum(cnt):
        ans = sum(cnt)

print(ans)



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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			
			Console.WriteLine(n * 800 - (n / 15) * 200);
        }
	}
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
typedef long long ll;
typedef multiset<ll> S;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
int main(){
    ll n,m;cin>>n>>m;
    vector<bool> a(n*m,false),b(n*m,false);
    rep(i,n){
        int x;cin>>x;
        x--;
        if(a[x]){
            cout<<0<<endl;
            return 0;
        }
        a[x]=true;
    }
    rep(i,m){
        int x;cin>>x;
        x--;
        if(b[x]){
            cout<<0<<endl;
            return 0;
        }
        b[x]=true;
    }
    ll ans=1,x=0,y=0,sum=0;
    for(int j=n*m;j>0;j--){
        if(a[j-1]&&b[j-1]){
            sum++;
            x++;y++;
        }
        else if(a[j-1]){
            ans*=y;
            ans%=mod;
            x++;
            sum++;
        }
        else if(b[j-1]){
            ans*=x;
            ans%=mod;
            y++;
            sum++;
        }
        else{
          ans=(ans*(x*y-sum))%mod;
          sum++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int W, a, b;
    cin >> W >> a >> b;
    if (a + W < b)
    {
        cout << b - (a + W) << endl;
    }
    else if (b + W < a)
    {
        cout << a - (b + W) << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
#define ll long long
int n;
ll cnt=980100;
int a[110],p[110];
signed main(){
	cin>>n;
	for(ll i=1;i<=n;i++){cin>>a[i];}
	for(int i=1;i<=100;i++)p[i]=i;
	for(ll i=1;i<=100;i++){
		ll cntt=0;
		for(ll j=1;j<=n;j++){
			ll abc=abs(a[j]-p[i]);
			cntt+=pow(abc,2);
		}
		if(cntt<cnt)cnt=cntt;
	}
	cout<<cnt<<endl;
} 

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	
	
	long mod = 1_000_000_007;

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		int h = fs.nextInt();
		int w = fs.nextInt();
		int k = fs.nextInt();
		
		if(w == 1) {
			System.out.println(1);
			return;
		}
		
		long[][] dp = new long[h+1][w];
		dp[0][0] = 1;
		
		for(int i = 1; i <= h; i++) {
			
			for(int j = 0; j < pow(2,w-1); j++) {
				
				int[] yokosen = new int[w-1];
				for(int l = 0; l < w-1; l++) {
					int bit = 1 << l;
					if((j & bit) > 0) {
						yokosen[l] = 1;
					}
				}
				
				boolean valid = true;
				for(int l = 1; l < w-1; l++) {
					if(yokosen[l-1] == 1 && yokosen[l] == 1) {
						valid = false;
						break;
					}
				}
				
				if(!valid) {
					continue;
				}
				
				
				for(int l = 0; l < w-1;l++) {
					if(yokosen[l] == 1) {
						dp[i][l] = (dp[i][l] + dp[i-1][l+1])%mod;
						dp[i][l+1] = (dp[i][l+1] + dp[i-1][l])%mod;
					}else {
						
						
						if(l == 0) {
							dp[i][l] = (dp[i][l] + dp[i-1][l])% mod;
						}
						if(l == w-2) {
							dp[i][l+1] = (dp[i][l+1] + dp[i-1][l+1])%mod;
						}
						if(l != 0 && yokosen[l-1] == 0){
							dp[i][l] = (dp[i][l] + dp[i-1][l])% mod;
						}
					}
				}
			}
		}
		
		System.out.println(dp[h][k-1]);
	}

	
	public int pow(int base, int n) {
		int retVal = 1;
		while (n > 0) {
			if ((n & 1) == 1) {
				retVal *= base;
			}
			n >>= 1;
			base *= base;
		}
		return retVal;
	}
	
	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 35368
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

const int MAX = 1110000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void comb_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X, Y;
    cin >> X >> Y;
    comb_init();
    if((X + Y) % 3 != 0) cout << 0 << endl;
    else{
        int x = (2 * Y - X) / 3;
        int y = (2 * X - Y) / 3;
        cout << comb(x+y, x) << endl;
    }
}

Measured memory_bytes: 26240
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;
typedef long long ll;

int main() {
   ll A, B, C;
   cin >> A >> B >> C;
   ll ans = 0;
   if (A + B < C) ans = A + B + B + 1;
   else ans = B + C;
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int N,K,i,a=0;
  int x[100];
  cin>>N>>K;
  for(i=0;i<N;i++){
    cin>>x[i];
    if(x[i]<K-x[i]){
      a+=x[i];
    }
    else{
      a+=K-x[i];
    }
  }
  cout<<a*2<<endl;

  return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

void YES(bool b) {cout << (b?"YES\n":"NO\n");}
void Yes(bool b) {cout << (b?"Yes\n":"No\n");}
void yes(bool b) {cout << (b?"yes\n":"no\n");}
void Yay(bool b) {cout << (b?"Yay!\n":":(\n");}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll k,cnt=0,x;
	queue<ll> q;
	cin >> k;
	rep(i,9) q.push(i+1);
	while(cnt<k){
		cnt++;
		x=q.front();
		q.pop();
		if(x%10!=0) q.push(10*x+(x%10)-1);
		q.push(10*x+(x%10));
		if(x%10!=9) q.push(10*x+(x%10)+1);
	}
	cout << x << endl;
	return 0;
}


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

#define int long long
#define ci(m)     for(int i=0;i<m;i++)
#define cj(m)     for(int j=0;j<m;j++)
#define ck(m)     for(int k=0;k<m;k++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;
int is(int n,int i)
{
    while(n%i==0)
        n=n/i;
    return n%i==1;
}
int solve(int n)
{
    int ans=1;
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            int cnt=0;
            while(n%i==0)
            {
                n=n/i;
                cnt++;
            }
            ans*=(cnt+1);
        }
    }
    if(n!=1)
        ans*=2;
    return ans;
}
int32_t main() {
    nitin;
    int n;
    cin>>n;
    int ans=0;
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)
            {ans+=is(n,i);
        if(i*i!=n)
        ans+=is(n,n/i);}
    }
    ans+=solve(n-1);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int n; cin >> n;
	vector<int> v(n);
	rep(i,n) cin >> v[i];
	sort(rall(v));
	int count1=0;
	int count2=0;
	rep(i,n){
		if (i%2==0){
			count1 += v[i];
		}else{
			count2 += v[i];
		}
	}
	cout << count1 - count2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, D, N, ans=0;
    vector<int> V(3);
    char tmp1, tmp2;
    string S[3];
    bool flag=true;
    
    cin >> S[0] >> S[1] >>S[2];

    if(S[0][S[0].size()-1] !=S[1][0] || S[1][S[1].size()-1] != S[2][0])
	flag =false;

    if(flag)
	puts("YES");
    else
	puts("NO");
    

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    // if(A+B==C || B+C==A || C+A==B)
    // 	puts("Yes");
    // else
    // 	puts("No");
}


Measured memory_bytes: 256
using System;

class Prog{
    static void Main(){
        var s = Console.ReadLine();
        var t = Console.ReadLine();
        int k = 0;
        for(int i = 0;i<s.Length;i++){
            if(s[i] != t[i]){
                k++;
            }
        }
        Console.WriteLine(k);
    }
}

Measured memory_bytes: 27436
#include <bits/stdc++.h>
using namespace std;
int main(){
    int64_t a, b, c, k, sum = 0;
    cin >> a >> b >> c >> k;
    if (a >= k )sum = k;
    else if (a + b >= k)sum = a;
    else{
        sum = a - (k - a - b);
    }
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(123456789)
#define LINF (long long int)(123456789012345678)
#define MAX_V 1000


int main(void){
	int N,W;
	cin>>N>>W;
	vector<int> w,v;
	int a,b;
	rep(i,N){
		cin>>a>>b;
		w.push_back(a);
		v.push_back(b);
	}

	vector< vector<ll> > dp;
	rep(i,N+1){
		dp.push_back(vector<ll>());
		rep(j,W+1){
			dp[i].push_back(0);
		}
	}

	rep(i,N){
		rep(sum_w, W+1){
			if(sum_w < w[i]){
				dp[i+1][sum_w] = dp[i][sum_w];
			}else{
				dp[i+1][sum_w] = max(dp[i][sum_w], dp[i][sum_w-w[i]] + v[i]);
			}
		}
	}
	cout<<dp[N][W]<<endl;
	return 0;
}






Measured memory_bytes: 80248
#include<iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;


int main()
{
    int n;
    cin >> n;
    long long m = 0, sum=0;
    vector<long long> a(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

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

    }

    cout << sum;

    return 0;
}



Measured memory_bytes: 4836
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  int k;cin>>k;
  vector<vector<vector<int>>>zeon(k,vector<vector<int>>(k,vector<int>(2,0)));
  rep(i,n)
  {
    int x,y;
    char c;
    cin>>x>>y>>c;
    x=x%(2*k);
    y=y%(2*k);
    int cc=c=='B';
    if((x>=k)^(y>=k))
    {
      cc=1-cc;
    }
    x%=k;
    y%=k;
    zeon[x][y][cc]++;
  }
  vector<vector<int>>sum1(k+1,vector<int>(k+1,0));
  auto sum2=sum1;
  rep(i,k)rep(j,k)sum1[i+1][j+1]=sum1[i+1][j]+zeon[i][j][0];
  rep(j,k)rep(i,k)sum1[i+1][j+1]+=sum1[i+1][j+1]+sum1[i][j+1];

  rep(i,k)rep(j,k)sum2[i+1][j+1]=sum2[i+1][j]+zeon[i][j][1];
  rep(j,k)rep(i,k)sum2[i+1][j+1]+=sum2[i+1][j+1]+sum2[i][j+1];
  int res=0;

  rep(i,k+1)rep(j,k+1)
  {
    int tres1=0,tres2=0;
    tres1=sum1[k][k]-sum1[k][j]-sum1[i][k]+2*sum1[i][j];
    tres1+=sum2[k][j]+sum2[i][k]-2*sum2[i][j];

    tres2=sum2[k][k]-sum2[k][j]-sum2[i][k]+2*sum2[i][j];
    tres2+=sum1[k][j]+sum1[i][k]-2*sum1[i][j];
    chmax(res,tres1);
    chmax(res,tres2);

  }
  //cout<<sum1[k][k]<<endl;
  cout<<res/2<<endl;


  return 0;

}


Measured memory_bytes: 62848
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) ((a) < (b) ? (b) : (a))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;



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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
int N, M, Q;
int A[50][4];
int BestScore = 0;
void search(vector<int> X) {
	if (X.size() == 0) {
		for (int i = 1; i <= M; ++i) {
			vector<int> Y = X;
			Y.push_back(i);
			search(Y);
		}
		return;
	}
	if (X.size() == N) {
		int score = 0;
		for (int i = 0; i < Q; ++i) {
			if (X[A[i][1]] - X[A[i][0]] == A[i][2]) {
				score += A[i][3];
			}
		}
//		for (int x : X) { cout << x; }
//		cout << " score: " << score << endl;
		BestScore = max(BestScore, score);
		return;
	}
	int a = X.back();
	for (int i = a; i <= M; ++i) {
		vector<int> Y = X;
		Y.push_back(i);
		search(Y);

	}

}

int main() {
	int i, j, k;
	//ll N, M, K;
	//int N, M, K;

	cin >> N >> M >> Q;
	rep(i, 0, Q) {
		rep(j, 0, 4) {
			cin >> A[i][j];
			A[i][j];
		}
		A[i][0] --;
		A[i][1]--;
	}
	vector<int> X;
	search(X);
	cout << BestScore;

	return 0;

}


Measured memory_bytes: 3632
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author wijebandara
 */
public class Main {
    public static void main(String[] args) {
        try {
            java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
            
            int data[]=new int [1000000];
            
            for (int i = 2; i < 1000000; i++) {
                if(isp(i))
                {
                    data[i]=data[i-1]+1;
                }
                else
                {
                    data[i]=data[i-1];
                }
            }
            String s =in.readLine();
            while(s!=null)
            {               
                System.out.println(data[Integer.parseInt(s)]);
                s =in.readLine();
            }
            
            
        } catch (Exception ex) {
            System.exit(0);
        }
    }
    static boolean isp(int x)
    {
        int a =(int)Math.sqrt(x);
        for (int i = 2; i <=a; i++) {
            if(x%i==0)
            {
                return false;
            }
        }
        return true;
    }
    
}

Measured memory_bytes: 24088
#include<stdio.h>

int main(void){
 
  int i,n,b,c=0,max=0,m;
  
   scanf("%d",&n);
   for(i=1;i<=n;i++){
      b=i;
      while(b>=1){
         if(b%2==0)
            c++;
         b=b/2; 
      }
      if(max<=c){
         max=c;
         m=i;
      }
      c=0;
    }
   
  printf("%d\n",m);  
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>

const int LIMIT=500;

int main(){
  int K;
  scanf("%d",&K);
  if(K<=LIMIT){
    printf("%d\n",K);
    for(int i=0;i<K;i++){
      for(int j=0;j<K;j++){
	if(j) printf(" ");
	printf("%d",j+1);
      }
      printf("\n");
    }
  }else{
    printf("%d\n",LIMIT);
    for(int i=0;i<LIMIT;i++){
      for(int j=0;j<LIMIT;j++){
	if(j) printf(" ");
	int l=(i+j)%LIMIT;
	if((j&1)&&l<K-LIMIT){
	  printf("%d",l+LIMIT+1);
	}else{
	  printf("%d",l+1);
	}
      }
      printf("\n");
    }
  }
  return 0;
}


Measured memory_bytes: 1152
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        a: u128,
        b: String
    };
    if let [s, t] = *b.split('.').collect::<Vec<_>>() {
        let s: u128 = s.parse().unwrap();
        let t: u128 = t.parse().unwrap();
        println!("{}", a * (100 * s + t) / 100);
    }
}


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

int main()
{
    int n,i,j,flag=0;
    scanf("%d",&n);
    for(i=0;4*i<=n;i++)
        for(j=0;7*j<=n;j++)
        if(4*i+7*j==n)
    {
        flag=1;break;
    }
    if(flag)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
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; }

//無限大
const ll INF = 1LL << 60;


//------------------------------------------------
int main() {

    //main
    
    const double PI = acos(-1);
    
    int R;
    cin >> R ;

    double ans = 2*PI*R;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const double EPS = 1e-7;
const long long mod = 1e9 + 7;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define X real()
#define Y imag()
#define cross(a,b) (conj(a)*(b)).imag()
#define dot(a,b) (conj(a)*(b)).real()
#define dist(a,b) ( pow(a.X - b.X, 2) + pow( a.Y - b.Y, 2 ) )
typedef tuple <int, int, int> line;
typedef complex <double> point;
typedef vector <point> polygon;
int n, k, h[1000000], arr[1000000];
int solve( int idx)
{
    if ( idx == n - 1 )
        return 0;
    if ( idx >= n )
        return 2e9;
    if ( arr[idx] != -1 )
        return arr[idx];
    int ans = 2e9;
    for(int i = idx + 1; i < n; i++)
    {
        if ( abs(idx - i) <= k )
            ans = min(ans, abs(h[idx] - h[i]) + solve(i) );
        else
            break;
    }
    arr[idx] = ans;
    return ans;
}
int main()
{
    Hello
    memset(arr, -1, sizeof arr);
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> h[i];
    cout << solve(0);
    return 0;
}



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

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

    int n;
    cin >> n;
    set<int> st;
    rep(i, 1, 10) rep(j, 1, 10) st.insert(i * j);
    if (st.find(n) != st.end())
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, sum = 1;
  cin >> N >> K;
  
  for (int i = 0;i < N; i++) {
    if (sum <= K) sum *= 2;
    else sum += K;
  }
  cout << sum;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    while (scanner.hasNext()) {
      int n = scanner.nextInt();
      if (n == 0) {
        break;
      }
      int[] za = new int[n];
      for (int ii = 0; ii < n; ii++) {
        za[ii] = scanner.nextInt();
      }
      int oo = 32;
      for (int t = 0, zac = 0; oo > 0; t++) {
        if (t % 2 == 0) {
          oo -= (oo - 1) % 5;
        } else {
          oo -= za[zac % n];
          zac++;
        }
        if (oo < 0) {
          oo = 0;
        }
        System.out.println(oo);
      }
    }
  }
}

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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	int n, q, times, cnt = 0;
  string name;
  queue<pair<string, int> > que;
  cin >> n >> q;

  rep(i, n) {
    cin >> name >> times;
    que.push(make_pair(name, times));
  }
  while (!que.empty()) {
    pair<string, int> top = que.front();
    que.pop();
    if (top.second <= q) {
      cnt += top.second;
      cout << top.first << " " << cnt << endl;
    } else {
      cnt += q;
      que.push(make_pair(top.first, top.second - q));
    }
  }
}


Measured memory_bytes: 6352
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
signed main(){
	int a,ans=0;
	string s;
	cin>>a;
	f(i,a){
		cin>>s;
		if(s=="E869120")ans++;
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 3208
#include <stdio.h>
int main (void){
  int n, sum, dig, tmp;
  
  scanf("%d", &n);
  
  tmp = n;
  
  while(n){
    sum += n % 10;
    n = n / 10;
  }

  if(tmp % sum == 0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  
  return 0;
}


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

int main() {
	int num[5],AvgSum=0;
	for (int i = 0; i <= 4; i++) {
		cin >> num[i];
	}
	for (int i = 0; i <= 4; i++) {
		if (num[i] < 40) {
			AvgSum += 40;
		}
		else {
			AvgSum += num[i];
		}
	}

	cout << AvgSum / 5 << endl;

	return 0;
} 


Measured memory_bytes: 3108
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#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
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100000],dp[100][100];

int main(){
  cin >> n >> m;
  clr(d,0);
  rep(i,0,m){
    int a,b;
    cin >> a >> b;
    d[a-1]++;
    d[b-1]++;
  }
  rep(i,0,n){
    print(d[i]);
  }
  return 0;
}

Measured memory_bytes: 1024
n = int(input())
s_list = [list(input()) for _ in range(n)]

ans1 = s_list[0]

for i in range(n - 1):
	ans2 = []
	for j in s_list[i + 1]:
		if j in ans1:
			ans1.remove(j)
			ans2.append(j)
	ans1 = ans2

print("".join(sorted(ans1)))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

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

int idx[100];
int t[100];
int n, duration;
int chargeId;
vector<int> pattern[100];

int solve(){
  rep(i,n) t[i] = pattern[i][0];
  memset(idx, 0, sizeof(idx));
  chargeId = -1;
  
  int ans = 0;
  bool fin = true;
  queue<int> waiting;
  bool flag[100];
  memset(flag, false, sizeof(flag));
  
  rep(i,duration){
    if(chargeId == -1 && !waiting.empty()){
      chargeId = waiting.front();
      flag[waiting.front()] = true;
      waiting.pop();
    }
    rep(j,n){
      if(idx[j] % 2 == 0){
	t[j]--;
      }
      else{
	if(chargeId == j || chargeId == -1){
	  t[j]--;
	  chargeId = j;
	  fin = false;
	}
	else{
	  ans++;
	  if(!flag[j]){
	    waiting.push(j);
	    flag[j] = true;
	  }
	}
      }
      if(t[j] == 0){
	if(chargeId == j) fin = true;
	idx[j]++;
	idx[j] %= pattern[j].size();
	t[j] = pattern[j][idx[j]];
      }
    }
    if(fin){
      flag[chargeId] = false;
      chargeId = -1;
    }
  }
  
  return ans;
}
	

int main(){
  while(cin >> n >> duration){
    if(n == 0 && duration == 0) break;

    rep(i,n) pattern[i].clear();
    
    rep(i,n){
      int v;
      while(cin >> v && v){
	pattern[i].push_back(v);
      }
    }

    cout << solve() << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1252
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    int H, W;
    cin >> H >> W;

    vector<string> a;
//    vector<vector<string>> a(H, vector<string>(W));

    vector<int> height(H,1);
    vector<int> width(W,1);

    for (int i = 0; i < H; i++)
    {
        for (int k = 0; k < W; k++)
        {
            string b;
            cin >> b;
            a.push_back(b);
            if(a[i].substr(k,1) == "#"){
                height[i] = height[i] * 0;
                width[k] = width[k] * 0;
            }
        }
    }

    for (int i = 0; i < H; i++)
    {
        int flag = 1;
        for (int k = 0; k < W; k++)
        {
            if(height[i]!=1 && width[k] != 1){
                flag = 0;
                cout << a[i].substr(k,1);
            }
        }
        if(flag == 0) cout << endl;
        flag = 1;
    }
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	ansYES(b - a == c - b);
}

Measured memory_bytes: 256
n=int(input())
s=list(map(int, input().split()))
t=list(map(int, input().split()))
ans=1
if s[s.index(max(s))]!=t[s.index(max(s))]:ans=0
t=t[::-1]
a=[1]+[0]*(n-2)+[1]
for i in range(1,n-1):
    if s[i]<a[i-1]:
        ans=0
        break
    elif s[i]>s[i-1]:a[i]=1
    else:a[i]=s[i-1]
for i in range(1,n-1):
    if t[i]<t[i-1]:
        ans=0
        break
    elif t[i]>t[i-1]:a[n-i-1]=1
    else:a[n-i-1]=min(t[i-1],a[-1*(i+1)])
for i in a:
    ans=(ans*i)%(10**9+7)
print(ans)

Measured memory_bytes: 18624
#include<bits/stdc++.h>
using namespace std;
int m,n,ans; 
int main()
{
	int a[1005]={};
	cin>>m>>n;
	int cnt=n-m;
    for(int i=1;i<=cnt;i++)
    ans+=i;
	cout<<ans-n<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, D, N, ans=0, left, right;
    vector<int> V(3);
    char tmp, tmp2;
    string S, S2;
    bool flag=true;
    
    cin >> A;
    ans = 24 + (24-A);
    cout << ans << endl;

    // if(left <right )
    // 	cout << "Right" <<endl;
    // else if(left > right)
    // 	cout << "Left" <<endl;
    // else
    // 	cout << "Balanced" <<endl;


    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    // if(A+B==C || B+C==A || C+A==B)
    // 	puts("Yes");
    // else
    // 	puts("No");
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

// a,b の最大公約数と、ax + by = gcd(a,b) となる x,y を求める
long long extgcd(long long a, long long b, long long &x, long long &y) {
    long long g = a;
    if(b != 0){
        g = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else{
        x = 1;
        y = 0;
    }
    return g;
}

// ax ≡ gcd(a, m) (mod m) となる x を求める
// a, m が互いに素ならば、関数値は mod m での a の逆数となる
long long mod_inverse(long long a, long long m)
{
    long long x, y;
    extgcd(a, m, x, y);
    return (x % m + m) % m;
}

class FactorialCalculation
{
private:
    const int mod;
    vector<long long> factorial;
    vector<long long> invFactorial;
public:
    FactorialCalculation(int n, int mod) : mod(mod)
    {
        factorial.resize(n+1, 1);
        invFactorial.resize(n+1, 1);
        for(int i=1; i<=n; ++i){
            factorial[i] = factorial[i-1] * i % mod;
            invFactorial[i] = mod_inverse(factorial[i], mod);
        }
    }
    long long getFactorial(int n){
        return factorial[n];
    }
    long long getInvFactorial(int n){
        return invFactorial[n];
    }
    long long getPermutation(int n, int r){
        if(n < r)
            return 0;
        return factorial[n] * invFactorial[n-r] % mod;
    }
    long long getCombination(int n, int r){
        if(n < r)
            return 0;
        return getPermutation(n, r) * invFactorial[r] % mod;
    }
    long long getHomogeneous(int n, int r){
        return getCombination(n+r-1, r);
    }
};

const int MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    ++ n;
    vector<int> v(n);
    for(int i=0; i<n; ++i)
        cin >> v[i];

    vector<int> memo(n, -1);
    int x;
    for(int i=0; ; ++i){
        if(memo[v[i]] != -1){
            x = memo[v[i]] + (n - 1 - i);
            break;
        }
        memo[v[i]] = i;
    }

    FactorialCalculation fc(n, MOD);
    for(int k=1; k<=n; ++k){
        long long ans = fc.getCombination(n, k);
        ans -= fc.getCombination(x, k-1);
        ans %= MOD;
        ans += MOD;
        ans %= MOD;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#pragma GCC optimization ("O3,unroll-loops")
#pragma GCC target ("avx,avx2,fma")
using namespace std;

int32_t main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n; cin >> n;
    vector<int> v(n);
    for (auto &it : v) cin >> it;
    sort(v.begin(), v.end());
    int cnt = 0;
    for (int i = 0; i + 2 < n; i++) for (int j = i + 1; j + 1 < n; j++) for (int k = j + 1; k < n; k++) {
        cnt += v[i] != v[j] && v[j] != v[k] && v[k] != v[i] && v[i] + v[j] > v[k];
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 3644
N , Y = map(int , input().split())
for k1 in range(N + 1):
    for k5 in range(N + 1 - k1):
        k10 = N - k1 - k5
        if k1 + k5 + k10 == N and 1000 * k1 + 5000 * k5 + 10000 * k10 == Y and k10 >= 0:
            print(k10 , k5 , k1)
            exit(0)
print("-1 -1 -1 ")

Measured memory_bytes: 3060
#include<stdio.h>
int main(){
int i,a,b,c,n;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d%d%d",&a,&b,&c);
if(a*a+b*b-c*c==0||a*a+c*c-b*b==0||b*b+c*c-a*a==0)
printf("YES\n");
else
printf("NO\n");}
return 0;
}

Measured memory_bytes: 0
# coding: utf-8
# Your code here!

N, K = map(int, input().rstrip().split(' '))
X = list(map(int, input().rstrip().split(' ')))

min_cost = int(1e10)
for i in range(K, N+1):
    min_cost = min(min_cost, X[i-1] - X[i-K] + min(abs(X[i-1]), abs(X[i-K])))
    
print(min_cost)


Measured memory_bytes: 14252
n, a, b = map(int,input().split())

if abs(a-b) % 2 == 0:
    print(abs(a-b)//2)
else:
    print(min(n - min(a,b), max(a,b)-1, min(a,b)-1+abs(a-b)//2+1, n-max(a,b)+abs(a-b)//2+1))


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>


using namespace std;

int main(){
    int N;
    cin >> N;
    int p[N];
    for(int i=1;i<=N;i++) cin >> p[i];

    int count = 0;
    for(int i=1;i<=N;i++){
        if(p[i]!=i) count++;
    }

    if(count==2||count==0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256