akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
using namespace std;
#define INF INT_MAX
#define N 100005
#define K 101
int n, k;
vector<int> arr;
int dp[N][K];
int solve(int idx, int cur_k){
    int res;
    if(idx == n-1)
        return dp[idx][cur_k] = abs(arr[idx]-arr[idx-cur_k]);
    if(cur_k == k)
        return dp[idx][cur_k] = solve(idx, 0)+abs(arr[idx]-arr[idx-cur_k]);
    if(dp[idx][cur_k] != -1)
        return  dp[idx][cur_k];
    res = solve(idx+1, cur_k+1);
    if(cur_k > 0)
        res = min(res, solve(idx, 0)+abs(arr[idx]-arr[idx-cur_k]));
    return dp[idx][cur_k] = res;
}
int main()
{
    cin >> n >> k;
    memset(dp, -1, sizeof(dp[0][0]) * N * K);
    for(int i=0; i<n; ++i){
        int num;
        cin >> num;
        arr.push_back(num);
    }
    cout << solve(0, 0);
    return 0;
}


Measured memory_bytes: 49528
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <malloc.h>
int main()
{
	int m;
	scanf("%d",&m);
	for (int k = 1; k < 10; k++) {
		int p = m / k;
		if ((p < 10)&&(p*k==m)) {
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
using namespace std;


int main()
{
    int a,b,x;
    scanf("%d%d%d",&x,&a,&b);
    int i,j;
    i=x-a;
    j=x-b;
    if(i<0)i=-i;
    if(j<0)j=-j;
    if(i<j)printf("A\n");
    else printf("B\n");
    return 0;
}




Measured memory_bytes: 128
#include <stdio.h>
#define MONTH 12
int main(void) {
    int cost,income[MONTH],expense[MONTH],savings,i,flag;
    while (1) {
        scanf("%d",&cost);
        if (cost==0) break;
        savings=0,flag=0;
        for (i=0;i<MONTH;i++) {
            scanf("%d %d",&income[i],&expense[i]);
            savings+=income[i]-expense[i];
            if (flag==0&&savings>=cost) flag=i+1;
        }
        if (flag==0) {
            printf("NA\n");
        } else {
            printf("%d\n",flag);
        }
    }
    return 0;
}

Measured memory_bytes: 612
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x);putchar(' ');}
inline void pr2(int x){write(x);putchar('\n');}
int n,A,B;
int main()
{
	n=read();A=read();B=read();
	pr1(min(A,B));pr2(max(0,A+B-n));
	return 0;
}



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

const static int M_MAX = 999999;

int main() {
  int era[ M_MAX + 1 ] = { 0 };

  vector<int> primes;
  era[ 0 ] = era[ 1 ] = 1;
  for( int i = 2; i <= M_MAX; i++ ) {
    if( era[ i ] ) { continue; }
    primes.push_back( i );
    for( int j = i + i; j <= M_MAX; j += i ) {
      era[ j ] = 1; 
    }
  }
  int pLen = primes.size();

  while( 1 ) {
    int m, a, b;
    cin >> m >> a >> b;
    if( !m && !a && !b ) { return EXIT_SUCCESS; }
    
    int ansP = -1, ansQ = -1;
    for( int i = 0; i < pLen ; i++ ) {
      for( int j = 0; j < i + 1; j++ ) {
        int p = primes[ j ];
        int q = primes[ i ];
        if( p * q > m ) { break; }
        if( a * q <= b * p ) { 
          if( ansP == -1 || p * q > ansP * ansQ ) {
            ansP = p;
            ansQ = q;
          }
        }
      }
    }
    cout << ansP << " " << ansQ << endl;
  }
}

Measured memory_bytes: 5500
import java.util.Scanner;

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

        if (x < y && y < z) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}


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

int main()
{
    int N, K;
    cin >> N >> K;
    
    vector<int> A(N+10);
    for (int i=0; i<N; i++) {
        int a;
        cin >> a;

        A.at(a)++;
    }

    int count = 0;
    sort(A.begin(),A.end(),greater<int>());
    for (int i=0; i<K; i++) {
        count += A.at(i);
    }
    cout << N -count << endl;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;


void solve() {
    vector<int>  p(1001, 1);
    int n;
    cin >> n;
    ll res = 1;
    for (int i = 2; i < p.size(); ++i) {
        if (p[i] == 0)
            continue;
        for (int j = i + i; j < p.size(); j += i) {
            p[j] = 0;
        }
    }
    for (int i = 2; i < p.size(); ++i) {
        if (p[i] == 0)
            continue;
        ll m = 1;
        ll x = n;
        while (x > 0) {
            x /= i;
            m += x;
        }
        res = (res * m) % mod;
    }
    cout << res << endl;

}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


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

using namespace std;

int main() {
  int L, A, B, C, D;
  cin >> L >> A >> B >> C >> D;
  L -= max((A + C - 1) / C, (B + D - 1) / D);
  cout << L << endl;
  return 0;
}


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

using namespace std;
template<typename T> void in(T &x) { x = 0; bool neg = false; register T c = getchar(); if (c == '-')neg = true, c = getchar(); while ((c < 48) || (c > 57))c = getchar(); for (; c < 48 || c > 57; c = getchar()); for (; c > 47 && c < 58; c = getchar())x = (x << 3) + (x << 1) + (c & 15); if (neg) x *= -1; }
template<typename T> void out(T n) { bool neg = 0; if (n < 0)n *= -1, neg = 1; char snum[65]; int i = 0; do { snum[i++] = n % 10 + '0'; n /= 10; } while (n); --i; if (neg)putchar('-'); while (i >= 0)putchar(snum[i--]); }
template<typename T> void outln(T n) { bool neg = 0; if (n < 0)n *= -1, neg = 1; char snum[65]; int i = 0; do { snum[i++] = n % 10 + '0'; n /= 10; } while (n); --i; if (neg)putchar('-'); while (i >= 0)putchar(snum[i--]); putchar('\n'); }
#define len(_x) (sizeof((_x)) / sizeof(_x)[0])
#define fastIO ios_base::sync_with_stdio(false); cin.tie(false);
#define ll long long
#define itr(_c) for(auto i=_c.begin();i!=_c.end();i++)
#define itrr(_c)for(auto i=_c.begin();i!=_c.end();i++)
#define f1(_x)for (int i = 0; i < _x; ++i)
#define fr(_x)for (int i = _x; i >0; i--)
#define f2(_x,_y)for (int i = _x; i < _y; ++i)
#define fileIO 	freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi; typedef vector<string> vs; typedef vector<bool> vb; vector<long long>vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;

int main() {
	fastIO
		int a, b, c ;
	std::cin >> a >> b >>c;
	int arr[3] = { a,b,c };
	sort(arr, arr + 3);
	if(a%2==1&& b % 2 ==1  && c % 2 == 1)std::cout << (ll)arr[1]*arr[0];
	else puts("0");
	
	
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <sstream>
#include <set>
#include <map>

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

using namespace std;

struct UnionFind {
    vector<int> v;
    vector<int> vsize;
    int n;
    UnionFind(int nin) {
        n = nin;
        for (int i = 0; i < n; ++i){
            v.push_back(i);
            vsize.push_back(1);
        }
    };

    int FindRoot(int p) {
        int root = p;
        while (v[root] != root) {
            root = v[root];
        }
        while (p!=root) {
            int next = v[p];
            v[p] = root;
            p = next;
        }
        return root;
    }

    void Union(int i, int j) {
        int ir = FindRoot(i);
        int jr = FindRoot(j);
        if (ir != jr) {
            if (vsize[ir] > vsize[jr]){
                v[jr] = ir;
                vsize[ir] += vsize[jr];
            } else {
                v[ir] = jr;
                vsize[jr] += vsize[ir]; 
            }
        }
    };
}; 

int main()
{
    int n, k, l;
    cin >> n >> k >> l;

    UnionFind road(n);
    UnionFind rail(n);

    int q, r;
    loop(i, k) {
        cin >> q >> r;
        road.Union(q - 1, r - 1);
    }
    
    loop(i, l) {
        cin >> q >> r;
        rail.Union(q - 1, r - 1);
    }

    map<pair<int, int>, int> mp;
    loop(i, n) {
        mp[{road.FindRoot(i), rail.FindRoot(i)}]++;
    }
    loop(i, n) {
        cout << mp[{road.FindRoot(i), rail.FindRoot(i)}] << ' ';
    }
    return 0;
}

Measured memory_bytes: 15124
import std.math;
    import std.conv;
    import std.range;
    import std.stdio;
    import std.string;
    import std.container;
    import std.algorithm;
     
    int[100_001] tree;
    int[] a;
    int[] s;
    long n, pairs;
     
    void add(int i)
    {
        for (; i <= n; i |= i + 1)
            ++tree[i];
    }
     
    int get(int r)
    {
        int res;
        for (; r >= 0; r = (r & (r + 1)) - 1)
            res += tree[r];
        return res;
    }
     
    bool ok(int x)
    {
        tree[] = 0;
        foreach (i, val; a) {
            s[i] = val >= x ? 1 : -1;
        }
        foreach (i; iota(n - 1))
          s[i + 1] += s[i];
        //int shift = s.fold!min;
        int shift = 1000000000;
        foreach(val; s)
          shift = min(shift, val);
        long t;
        add(max(-shift, 0));
        foreach (val; s.map!(x => x - shift)) {
            t += get(val);
            add(val);
        }
        return t >= (pairs + 1) / 2;
    }
     
    void main()
    {
        readf("%d\n", &n);
        a = readln.splitter.map!(to!int).array;
        s = new int[a.length];
        pairs = (n * (n + 1)) / 2;
        //auto b = a.fold!(min, max);
        //int l = b[0];
        //int r = b[1];
        int l = a[n - 1];
        int r = a[n - 1];
        foreach (i; iota(n - 1)) {
          r = max(r, a[i]);
          l = min(l, a[i]);
        }
        
        while (l < r) {
            int mid = (l + r + 1) / 2;
            if (ok(mid))
                l = mid;
            else
                r = mid - 1;
        }
        writeln(l);
    }


Measured memory_bytes: 4476
N = int(input())
S = [input() for _ in range(N)]
Alist = [word for word in S if word[-1] == 'A']
Blist = [word for word in S if word[0] == 'B']
ABlist = [word for word in S if word[0] == 'B' and word[-1] == 'A']
Slist = [word.count('AB') for word in S]
C = min(len(Alist),len(Blist))
if len(Alist) == 0 and len(Blist) == 0:
    print(sum(Slist))
elif len(ABlist) == len(Alist) and len(ABlist) == len(Blist):
    print(sum(Slist)+len(ABlist)-1)
else:
    print(sum(Slist)+min(C,N-1))

Measured memory_bytes: 3956
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        String s = sc.next();
        sc.close();

        // 主処理
        String result = s;
        if (k < s.length()) {
            result = s.substring(0, k) + "...";
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 38416
import numpy as np


def count(a):
    i = 0
    while a > 0:
        i += 1
        a -= i
        if a == 0:
            break
        if a < 0:
            i -= 1
            break
    return i


def main(N):
    num = N
    ans = 0
    A = np.zeros((1000000), np.int32)
    i = 2
    last = 0
    if N == 1:
        return 0
    while True:
        if num % i == 0:
            num = num//i
            A[i] += 1
        else:
            i += 1
            if num == 1:
                break
            if i*i > num:
                last = 1
                break
    for j in range(i):
        ans += count(A[j])
    ans += last
    return ans


N = int(input())
print(main(N))


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int Sum(const string&s){
  int n = (int)s.size();
  int sum = 0;
  for(int i = 0; i < n; ++i)sum += s[i] - '0';
  return sum;
}

int main(){
  int a,b; cin >> a >> b;
  cout << (b-a)*(b-a+1)/2-b << endl;
}


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

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	string C[2];
	cin >> C[0] >> C[1];
	reverse(C[0].begin(),C[0].end());
	if(C[0]==C[1]) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 3588
N = int(input())
As = list(map(int, input().split()))
Ns = [0]*N
for A in As:
  Ns[A] += 1
#print(Ns)
r = 1
if N%2 == 1:
  if Ns[0] > 1:
    r = 0
  for i in range(1, N):
    if i%2 == 1 and Ns[i] > 0:
      r = 0
    if i%2 == 0 and Ns[i] > 2:
      r = 0
    if i%2 == 0 and (Ns[i] == 1 or Ns[i] == 2):
      r = (r*2)%1000000007
if N%2 == 0:
  for i in range(0, N):
    if i%2 == 0 and Ns[i] > 0:
      r = 0
    if i%2 == 1 and Ns[i] > 2:
      r = 0
    if i%2 == 1 and (Ns[i] == 1 or Ns[i] == 2):
      r = (r*2)%1000000007
print(r)


Measured memory_bytes: 14324
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
int a[(1<<18)+10]; 
bool visited[(1<<18)+12];
int ranking[(1<<18)+12];
int n; 
set<int> S;
 
int dfs(int u, int fixed=-1)
{
	if(visited[u]) return ranking[u];
	visited[u]=1;
	int mx = -1;
	for(int i=0;i<n;i++)
	{
		if(u&(1<<i))
		{
			int res = dfs(u^(1<<i));
			mx=max(mx,res);
		}
	}
	if(fixed!=-1)
	{
		if(fixed<=mx){cout<<"NO\n"; exit(0);}
		if(S.find(fixed)==S.end()){cout<<"NO\n"; exit(0);}
		S.erase(fixed); ranking[u]=fixed;
		return fixed;
	}
	auto it = S.upper_bound(mx);
	if(it==S.end()){cout<<"NO\n"; exit(0);}
	ranking[u]=(*it); S.erase(ranking[u]);
	return ranking[u];
}
 
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>n;
	for(int i=0;i<(1<<n);i++)
	{
		cin>>a[i]; a[i]--;
	}
	if(a[0]>=1){cout<<"NO\n"; return 0;}
	memset(ranking,-1,sizeof(ranking));
	vector<ii> vec;
	for(int i=0;i<(1<<n);i++)
	{
		if(a[i]>=0) vec.pb(mp(a[i],i));
		S.insert(i);
	}
	vec.pb(mp(0,0)); vec.pb(mp((1<<n)-1,(1<<n)-1));
	sort(vec.begin(),vec.end()); vec.erase(unique(vec.begin(),vec.end()),vec.end());
	for(int i=0;i<vec.size();i++)
	{
		int needpos = vec[i].fi; int id = vec[i].se;
		if(ranking[id]!=-1){cout<<"NO\n"; return 0;}
		dfs(id,needpos);
	}
	vi res;
	res.pb(0);
	for(int i=0;i<n;i++)
	{
		vi nw;
		for(int v:res)
		{
			nw.pb(v); nw.pb(v+(1<<i));
		}
		res=nw;
	}
	for(int i=0;i<(1<<n);i++) res[i]=ranking[res[i]];
	cout<<"YES\n";
	for(int i=0;i<(1<<n);i++)
	{
		cout<<res[i]+1;
		if(i+1<(1<<n)) cout<<' ';
	}
	cout<<'\n';
}


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

using namespace std;
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 29)

using Pi = pair<int, int>;

string to_string(string s) {
  return s;
}

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s)
    ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m)
    ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

int V, E, T;
vector<vector<Pi>> G;
vector<vector<int>> orders;
vector<int> f;
using Ppi = pair<int, pair<int, int>>;

vector<Ppi> get_path(int s, int g) {
  vector<int> d(V, INF), prev(V, -1);
  vector<bool> used(V);
  priority_queue<Ppi, vector<Ppi>, greater<Ppi>> q;
  q.push(Ppi(0, Pi(-1, s)));
  while (!q.empty()) {
    Ppi t = q.top();
    q.pop();
    int l = t.first;
    int from = t.second.first;
    int v = t.second.second;
    if (used[v])
      continue;
    used[v] = 1;
    d[v] = l;
    prev[v] = from;
    if (g == v)
      break;
    for (Pi e : G[v]) {
      if (d[e.second] > l + e.first) {
        q.push(Ppi(l + e.first, Pi(v, e.second)));
      }
    }
  }
  vector<Ppi> ret;
  int now = g;
  while (now != s) {
    ret.push_back(Ppi(d[now] - d[prev[now]], Pi(prev[now], now)));
    now = prev[now];
  }
  return ret;
}

int main() {
  cin >> V >> E;
  G.resize(V);
  f.resize(V);
  FOR(i, E) {
    int u, v, d;
    cin >> u >> v >> d;
    G[u - 1].emplace_back(d, v - 1);
    G[v - 1].emplace_back(d, u - 1);
  }
  FOR(i, V) cin >> f[i];
  cin >> T;
  orders.resize(T);
  int now = 0;
  vector<int> actions(T * 4, -1);
  FOR(i, T) {
    int Nnew;
    cin >> Nnew;
    FOR(j, Nnew) {
      int new_id, dst;
      cin >> new_id >> dst;
      orders[i].push_back(dst - 1);
      if (now <= i) {
        vector<Ppi> ret = get_path(0, dst - 1);
        now = i;
        for (int a = ret.size() - 1; a >= 0; --a) {
          FOR(b, ret[a].first) { actions[now++] = ret[a].second.second + 1; }
        }
        for (int a = 0; a < ret.size(); ++a) {
          FOR(b, ret[a].first) { actions[now++] = ret[a].second.first + 1; }
        }
      }
    }
    int Nput;
    cin >> Nput;
    vector<int> put_id(Nput);
    FOR(j, Nput) cin >> put_id[j];
    cout << actions[i] << endl;
    string verdict;
    int Narchive;
    cin >> verdict >> Narchive;
    vector<int> achieve_id(Narchive);
    FOR(j, Narchive) cin >> achieve_id[j];
  }
  return 0;
}

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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);

    int n;
    cin >> n;
    print(180 * (n - 2));

    return 0;
}


Measured memory_bytes: 764
import sys
a,b = map(int,input().split())

sa = abs(b-a)
tmp1 = 0
for i in range(1,1000):
    tmp2 = int(i*(i+1)/2)
    if tmp2 - tmp1 == sa:
        print(tmp1 - a)
        sys.exit()
    tmp1 = tmp2
print(1)

Measured memory_bytes: 3064
from collections import deque

def main():
    n = int(input())
    V = [None]*(n+1)
    ans = [None]*(n+1)
    for i in range(1, n+1):
        _, _, *v = map(int, input().split())
        V[i] = v
    q = deque([1])
    ans[1] = 0
    while q:
        node = q.pop()
        d = ans[node]+1
        for v in V[node]:
            if ans[v] is None:
                ans[v] = d
                q.appendleft(v)
    print(1, 0)
    for i, distance in enumerate(ans[2:], 2):
        print(i, distance or -1)

if __name__ == "__main__":
    main()


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

#define int long long

int32_t main(){
	int n ;
	cin >> n ;
	int a[n] ;
	for(int i = 0 ; i < n ; i++) cin >> a[i] ;
	int dp[n] = {} ;
	dp[0] = 0 ;
	dp[1] = abs(a[1] - a[0]) ;
	for(int i = 2 ; i < n ; i++){
		dp[i] = min(dp[i-1] + abs(a[i-1] - a[i]) , dp[i-2] + abs(a[i-2] - a[i])) ;
	}
	cout << dp[n-1] ;
	return 0 ;
}



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

int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	if(a < b && b < c)
	{
		cout << "Yes" << endl;
	}
	else 
	{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3080
R,G,B,N = map(int,input().split())
ans = 0
for r in range(N//R + 1) :
    for g in range((N-r)//G + 1) :
        calc = r*R + g*G
        if N < calc :
            break
        if not (N-calc) % B :
            ans += 1
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#define NUM  100


int main(){
  int i=0;
  char c;
  int a[NUM];

  for(i=0;i<NUM;i++){
    a[i]=0;
  }
  i=0;

  while((c=getchar())!='\n'){
    if(c>='0' && c<='9'){
      a[i]=10*a[i]+(c-'0');
    }
    if(c==' '){
      i++;
    }
    if(c=='+'){
      i--;
      a[i-1]+=a[i];
      a[i]=0;
      i--;
    }
    if(c=='-'){
      i--;
      a[i-1]-=a[i];
      a[i]=0;
      i--;
    }
    if(c=='*'){
      i--;
      a[i-1]*=a[i];
      a[i]=0;
      i--;
    }
  }

  printf("%d\n",a[0]);
  
  return 0;
}



Measured memory_bytes: 2144
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
        int n ;
        cin >> n;
        string str;
        map<string, int> m;
        while(n--) {
                cin >> str;
                ++m[str];
        }
        int max = -1;
        for(map<string, int>::const_iterator iter = m.begin(); iter != m.end(); ++iter) {
                if(iter -> second > max) {
                        max = iter -> second;             
                }
        }

        for(map<string, int>::iterator iter = m.begin(); iter != m.end(); ++iter) {
                if(iter -> second == max) {
                        cout << iter -> first << "\n";
                        --(iter -> second);
                             
                }
        }


        return 0;
        
}

Measured memory_bytes: 25216
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
string a;
int main()
{
    cin>>a;
    int ans=0;
    int p=0;
    for(int i=0;i<a.size();i++){
        if(a[i]=='g'){
            if(p>0){
                ans++;
                p--;
            }
            else
                p++;
        }
        else{
            if(p>0)
                p--;
            else{
                p++;
                ans--;
            }

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

Measured memory_bytes: 512
N = int(input())
l = [int(i) for i in input().split(" ")]
l.sort()
M = l[-1]
m = l[0]
ans_l = []
for i in l[1:-1]:
    if i>0:
        ans_l.append(str(m)+" "+str(i))
        m -= i
    else:
        ans_l.append(str(M)+" "+str(i))
        M -= i
ans_l.append(str(M)+" "+str(m))
ans = M - m
print(ans)
[print(j) for j in ans_l]

Measured memory_bytes: 17764
#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#else
#define D(...) ((void)0)
#define NDEBUG
#endif
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
const int N=100005,INF=0x3f3f3f3f;
int S,T,dis[N],pre[N],he,ta,q[N];bool vis[N];
int lnk[N],pp=1;struct ed{int nxt,to,w,c;}G[N*10];
template<typename T>T min(const T&x,const T&y){return x<y?x:y;} 
void ae(int u,int v,int w,int c){
	//D(">>> %d %d %d %d\n",u,v,w,c);
	G[++pp]=(ed){lnk[u],v,w,c},lnk[u]=pp;
	G[++pp]=(ed){lnk[v],u,0,-c},lnk[v]=pp;
}
bool spfa(int S){
	rep(i,1,T)dis[i]=-INF,pre[i]=0;
	int he=0,ta=0;q[++ta%=N]=S,dis[S]=0;
	while(he!=ta){
		int u=q[++he%=N];vis[u]=0;
		for(int i=lnk[u];i;i=G[i].nxt)
			if(G[i].w&&dis[u]+G[i].c>dis[G[i].to]){
				dis[G[i].to]=dis[u]+G[i].c;
				pre[G[i].to]=i^1;
				if(!vis[G[i].to]){
					vis[G[i].to]=1;
					q[++ta%=N]=G[i].to;
				}
			}
	}
	return dis[T]!=-INF;
}
int n,m;
char s[55][55];
signed main(){
	scanf("%d%d",&n,&m);
	rep(i,1,n)scanf("%s",s[i]+1);
	auto zip=[&](int x,int y){
		return (x-1)*m+y;
	};
	S=n*m+1,T=S+1;
	rep(i,1,n){
		rep(j,1,m)if(s[i][j]!='#'){
			if(s[i][j]=='o'){
				ae(S,zip(i,j),1,0);
			}
			if(i<n&&s[i+1][j]!='#'){
				ae(zip(i,j),zip(i+1,j),INF,1);
			}
			if(j<m&&s[i][j+1]!='#'){
				ae(zip(i,j),zip(i,j+1),INF,1);
			}
			ae(zip(i,j),T,1,0);
		}
	}
	int mf=0,mc=0;
	while(spfa(S)){
		int flow=INF;
		for(int i=pre[T];i;i=pre[G[i].to])flow=min(flow,G[i^1].w);
		for(int i=pre[T];i;i=pre[G[i].to])G[i].w+=flow,G[i^1].w-=flow;
		mf+=flow,mc+=flow*dis[T]; 
	}
	printf("%d\n",mc);
	return 0;
}


Measured memory_bytes: 4128
import numpy as np
N, M, K = map(int, input().split())
A = np.cumsum([0] + list(map(int, input().split())))
B = np.cumsum([0] + list(map(int, input().split())))
ans = 0
j = M
for i in range(N+1):
  if A[i] > K:
    break
  while A[i] + B[j] > K:
    j -= 1
  ans = max(ans,i+j)
print(ans)

Measured memory_bytes: 52940
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    cout << (b-1)*(a-1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
int main() {
  std::string A;
  std::string B;
  int number_of_A;
  int number_of_B;
  std::string ball_chosen;
  

  std::cin>> A >> B;
  std::cin>> number_of_A >> number_of_B;
  std::cin>> ball_chosen;
  if(number_of_A <= 10 && number_of_B <= 10 && A != B){
  if(ball_chosen==A){
    std::cout << number_of_A -1 << " " << number_of_B ;
  }
  else if (ball_chosen==B){
    std::cout << number_of_A << " " << number_of_B -1 ;
  }
  }
  }

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

int main() {
 
	long long a, b;
	
	cin >> a >> b;
	long long x = a * b;
   if (a < b) {
      long long tmp;
      tmp = a;
      a = b;
      b = tmp;
   }
   long long r;
   r = a % b;
   while (r != 0) {
      a = b;
      b = r;
      r = a % b;
   }
   cout << x/b  << endl;
      return 0;
}

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

int main(void){
  int A, B;
  cin >> A >> B;
  if(A == 1){
    A = A + 13;
  } 
	if(B == 1){
    B = B + 13;
  }
  if(A > B){
    cout << "Alice";
  } else if(A == B) {
    cout << "Draw";
  } else {
    cout << "Bob";
  }
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;


int main() {

  int n,k;
  int a[100001];

  int max;
  int sum_seq;


  while(cin >> n >> k) {

    if(n==0 && k==0) break;

    for(int i=0;i<n;i++) cin >> a[i];

    max=0;

    sum_seq=0;

    for(int i=0;i<k;i++) sum_seq+=a[i];

    for(int i=0;i<=n-k;i++) {

      if(max<sum_seq) max=sum_seq;

      if(i!=n-k) sum_seq+=a[i+k]-a[i];

    }

    cout << max << endl;

  }

  return 0;

}

Measured memory_bytes: 1256
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll L, R;
    cin >> L >> R;
    ll ans = inf;
    if (R - L >= 2018) {
        rep (i, 2019) {
            for (ll j = i + 1; j < 2019; ++j) {
                ans = min(ans, (i * j) % 2019);
            }
        }
    } else {
        ll ML = L % 2019;
        ll MR = R % 2019;
        if (ML <= MR) {
            for (ll i = ML; i <= MR; ++i) {
                for (ll j = i + 1; j <= MR; ++j) {
                    ans = min(ans, (i * j) % 2019);
                }
            }
        } else {
            rep (i, 2019) {
                if (MR <= i && i <= ML) continue;
                for (ll j = i + 1; j < 2019; ++j) {
                    if (MR <= j && j <= ML) continue;
                    ans = min(ans, (i * j) % 2019);
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 888
#include <stdio.h>
#include <string.h>

int main ()
{
    int N = 0;
    scanf("%d", &N);

    char S[N];
    scanf("%s", S);

    int ans = 0;
    int counter = 0;
    char X[N], Y[N];
    
    memset(X, 0, sizeof(X));
    memset(Y, 0, sizeof(Y));

    for (int i = 0; i < N; i++)
    {
        counter = 0;
        for (int j = 0; j <= i; j++)
        {
            X[j] = S[j];
        }
        for (int k = i; k < N; k++)
        {
            Y[k - i] = S[k + 1];
        }
        
        for (int L = 0; L < N; L++)
        {
            for (int M = L + 1; M < N; M++)
            {
                if (X[L] == X[M])
                {
                    X[M] = '\0';
                }
                if (Y[L] == Y[M])
                {
                    Y[M] = '\0';
                }
            }
        }

        for (int L = 0; L < N; L++)
        {
            for (int M = 0; M < N; M++)
            {
                if (X[L] == '\0' || Y[M] == '\0')
                {
                }
                else if (X[L] == Y[M])
                {
                    counter += 1;
                }
            }
        }

        if (counter > ans)
        {
            ans = counter;
        }
    }
    printf("%d", ans);
    return 0;
}

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

bool my_compare(pair<int, int> a, pair<int, int > b) {
    return a.second < b.second;
}

int main() {
    int N;
    cin >> N;
    int X[N], L[N];
    vector<pair<int, int>> p(N);
    for (int i = 0; i < N; i++) {
        cin >> X[i] >> L[i];
        p[i] = make_pair(X[i] - L[i], X[i] + L[i]);
    }
    sort(p.begin(), p.end(), my_compare);
    int ans = 0;
    int t = INT32_MIN;
    for (pair<int, int> v : p) {
        if (t <= v.first) {
            ans++;
            t = v.second;
        }
        
    }
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 998244353
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 100010
using namespace std;
ll n,m,dep[N],lw[N],din[N],ans,cnt=0;
bool vis[N];
vector<ll> vt[N],bri;
void dfs(ll x,ll lst)
{
	vis[x]=true;
	lw[x]=din[x]=++cnt;
	ll i;
	for(i=0;i<vt[x].size();i++)
	{
		if(vt[x][i]!=lst)
		{
			if(vis[vt[x][i]])
			{
				lw[x]=min(lw[x],din[vt[x][i]]);
			}
			else
			{
				dfs(vt[x][i],x);
				lw[x]=min(lw[x],lw[vt[x][i]]);
			}
		}
	}
	if(lw[x]==din[x]&&x!=0)
	{
		bri.push_back(x);
	}
	return;
}
int main(){
	ll i,x,y;
	scanf("%lld%lld",&n,&m);
	for(i=0;i<m;i++)
	{
		scanf("%lld%lld",&x,&y);
		x--;
		y--;
		vt[x].push_back(y);
		vt[y].push_back(x);
	}
	dfs(0,-1);
	printf("%lld\n",(ll)bri.size());
	return 0;
}

Measured memory_bytes: 6124
use strict;
use warnings;

my $n = <>;
my $s = <>;
my $k = <>;
chomp $s;

my $c = substr($s, $k - 1, 1);

for(my $i = 0; $i < length $s; $i++){
    if(substr($s, $i, 1) ne $c){
        substr($s, $i, 1) = '*';
    }
}
print $s;


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

#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

using namespace std;
/**************************************************************************/
int main()
{
	fastIO;
	string s;
	ll t,n,i,j,k,up=1,cnt=1;
	vector < pair < ll , ll > > v;
	cin>>s;
	n = s.length();
	if(s[n-1]=='1' or s[0]=='0' or s[n-2]=='0'){cout<<-1;return(0);}
	Fo(i,1,n){if(s[i-1]!=s[n-i-1]){cout<<-1;return(0);}}
	for(i=1;i<n-1;i++)
	{
		if(s[i]=='0'){cnt++;continue;}
		k = up + cnt;
		j = up;
		while(cnt>0){v.pb({k,j});j++;cnt--;}
		up = j;cnt=1;
	}
	v.pb({up,n});
	for(auto x:v)cout<<x.F<<" "<<x.S<<endl;
}

/*************************************************************************/

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

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

vector<vector<int> > to;
vector<int> cnt;
bool visited[200200];

void dfs(int v, int pcnt) {
    if (visited[v]) return;
    visited[v] = true;

    cnt[v] += pcnt;
    for (auto u : to[v]) {
        dfs(u, cnt[v]);
    }
    return;
}

int main() {
    int N, Q;
    cin >> N >> Q;
    to.resize(N);
    cnt.resize(N);
    rep(i,N-1) {
        int a,b;
        cin >> a >> b;
        --a; --b;
        to[a].pb(b);
        to[b].pb(a);
    }
    vector<int> p(Q);
    vector<int> x(Q);
    rep(i,Q) {
        cin >> p[i] >> x[i];
        --p[i];
    }
    rep(i,Q) {
        cnt[p[i]] += x[i];
    }
    dfs(0,0);
    rep(i,N) {
        cout << cnt[i] << " ";
    }
    cout << endl;
    return 0;
}
































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

int main()
{
    int k,a,b;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++)
    if(i%k==0){
        puts("OK");
        return 0;
    }
    puts("NG");
    return 0;
}


Measured memory_bytes: 3636
import scala.io.StdIn._
object Main extends App {

  val n = readInt
  val Array(t, a) = readLine.trim.split(' ').map(_.toInt)
  val heights = readLine.trim.split(' ').map(_.toInt)
  println(heights.indices.minBy{i ⇒ math.abs(a - t + heights(i) * 0.006)} + 1)
}

Measured memory_bytes: 27336
l,r=map(int,input().split())
ll=[]
mod=2019
if r-l+1>=2019:
    print(0)
    import sys
    sys.exit()
ans=10**100
import itertools
for i,j in itertools.combinations(range(l,r+1),2):
    ans=min(ans,(i*j)%mod)
print(ans)



Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int used[26] = {};
    int used2[26] = {};
    if(SZ(S) != 26)
    {
        REP(i,SZ(S)) used[S[i]-'a'] = 1;
        cout << S;
        REP(i,26) if(used[i] != 1)
        {
            cout << char(i+'a') << endl;
            break;
        }

    }
    else
    {
        int tmp = -1;
        int flag = 0;
        int record;
        for(int i = SZ(S)-1; i>= 0; i--)
        {
            if(tmp < (S[i]-'a'))
            {
                tmp = S[i] - 'a';
                used2[S[i]-'a'] = 1;
            }
            else
            {
                cout << S.substr(0,i);
                flag = 1;
                record = S[i] - 'a';

                break;
            }
        }
        if(flag == 0)
        {
            cout << -1 << endl;
            return 0;
        }
        FOR(i,record+1,26) if(used2[i] == 1)
        {
            cout << char(i+'a') << endl;
            break;
        }

    }



}

Measured memory_bytes: 256
#include<stdio.h>

typedef struct {
  char c;
  int n;
}Card;


int number;
Card card1[36],card2[36];

void bubble(Card card[]){
  int j=0;
  int i;

  
  int flag=1,kae,count=0;
  char kae2;
    while (flag==1){
    flag=0;
    for(j=number-1;j>0;j--){
      
      if(card[j].n<card[j-1].n){
	kae=card[j-1].n;
	kae2=card[j-1].c;
	card[j-1].n=card[j].n;
	card[j-1].c=card[j].c;
	card[j].n=kae;
	card[j].c=kae2;
	
	count++;
	flag=1;
      }
    }
    }
    

    for(i=0;i<number;i++){
      if(i!=number-1){
      printf("%c%d ",card[i].c,card[i].n);
      }

      else{printf("%c%d",card[i].c,card[i].n);}
    }
    printf("\nStable\n");
}



void selection(Card card[]){
int i,j,kae,minj;
 char kae2;

 
    for(i=0;i<number;i++){
      minj=i;
      
      for(j=i;j<number;j++){
	if(card[j].n<card[minj].n){minj=j;}}


      kae=card[i].n;
      kae2=card[i].c;
      
      card[i].n=card[minj].n;
      card[i].c=card[minj].c;

      card[minj].n=kae;
      card[minj].c=kae2;
      
       
	
      }
     
    

  
  
  for(j=0;j<number;j++){

    if(j==number-1) printf("%c%d",card[j].c,card[j].n);
    else if (j!=number){printf("%c%d ",card[j].c,card[j].n);}

  }
  printf("\n");
  
  



}


int stablekakunin(Card a[],Card b[]){

  int i;
  for(i=0;i<number;i++){
    if(a[i].c !=b[i].c)return 0;
  }
  return 1;}


int main(){
  
  int i;
  char str;
  int n;

  scanf("%d",&number);



  for(i=0;i<number;i++){
    scanf(" %c%d",&card1[i].c,&card1[i].n);
    card2[i].c=card1[i].c;
    card2[i].n=card1[i].n;
    //printf("%c%d\n",card[i].c,card[i].n);
    
  }
 
  
  
  bubble(card1);
  selection(card2);
  
  if(stablekakunin(card1,card2)==1){
    printf("Stable\n");
  }
  else {printf("Not stable\n");}
  
   return 0;
}



Measured memory_bytes: 2112
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
    int n, k; cin>>n>>k;
    if(n==1){
        cout<<1<<endl; return 0;
    }
    int d=0;
    while(d*d<=n) d++;
  d--;
    ll dp[100000]={};
    dp[1]=1;
    for(int i=0; i<k; i++){
        ll dp2[100000]={};
        for(int j=1; j<=2*d; j++){
            (dp2[2*d+1-j]+=dp[j])%=MOD;
        }
        for(int j=2*d-1; j>=1; j--){
            (dp2[j]+=dp2[j+1])%=MOD;
        }
        for(int j=1; j<=2*d; j++){
            if(j<=d) dp[j]=dp2[j];
            else{
                ll c;
                if(j==d+1) c=n/d-d;
                else c=n/(2*d+1-j)-n/(2*d+2-j);
                dp[j]=dp2[j]*c%MOD;
            }
        }
    }
     ll ans=0;
     for(int i=1; i<=2*d; i++) (ans+=dp[i])%=MOD;
     cout<<ans<<endl;
    return 0;
}

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

ll mod = 998244353;
class SegmentTree {
private:
    int n;
    vector<ll> node, lazy;
    vector<bool> flag_lazy;
public:
    SegmentTree(int N) {
        n = 1;
        while (n < N) n *= 2;
        node.resize(2 * n - 1, 0);
        lazy.resize(2 * n - 1, 0);
        flag_lazy.resize(2 * n - 1, false);
    }

    void update(int i, int l, int r) {
        if (!flag_lazy[i]) return;
        node[i] += lazy[i];
        node[i] %= mod;
        if (r - l > 1) {
            lazy[2 * i + 1] += lazy[i] / 2;
            lazy[2 * i + 2] += lazy[i] / 2;
            flag_lazy[2 * i + 1] = true;
            flag_lazy[2 * i + 2] = true;
        }
        flag_lazy[i] = false;
        lazy[i] = 0;
    }

    void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        update(k, l, r);
        if (b <= l || r <= a) return;
        
        if (a <= l && r <= b) {
            lazy[k] += ((r - l) * (x));
            flag_lazy[k] = true;
            update(k, l, r);
        } else {
            add(a, b, x, 2 * k + 1, l, (l + r) / 2);
            add(a, b, x, 2 * k + 2, (l + r) / 2, r);
            node[k] = (node[2 * k + 1] + node[2 * k + 2]) % mod;
        }
    }

    ll query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        update(k, l, r);
        if (b <= l || r <= a) return 0;        
        if (a <= l && r <= b) return node[k] % mod;

        ll sum_l = query(a, b, 2 * k + 1, l, (l + r) / 2);
        ll sum_r = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return (sum_l + sum_r) % mod;
    }

    void disp() {
        for (int i : node) {
            cout << i << " ";
        }
        cout << "\n";
    }

};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int L[K], R[K];
    for (int i = 0; i < K; i++) {
        cin >> L[i] >> R[i];
    }

    SegmentTree st(N + 1);
    st.add(1, 2, 1);
    
    for (int i = 1; i < N; i++) {
        ll x = st.query(i, i + 1);
        for (int j = 0; j < K; j++) {
            int l = i + L[j];
            int r = i + R[j] + 1;
            
            st.add(min(l, N + 1), min(r, N + 1), x);
            //st.add(l, r, x);
        }
        //cout << x << "\n";
    }

    cout << st.query(N, N + 1) << "\n";

    return 0;
}

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

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

    int P[N];
    rep(i, N) cin >> P[i];

    int ans = 0;
    rep(i, N-1) {
        if (P[i] == i+1) {
            swap(P[i], P[i+1]);
            ans++;
        }
    } 
    if (P[N-1] == N) ans++;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 768
m,n=map(int,input().split())
my_min=-float("INF")
my_max=float("INF")
for i in range(n):
    a,b=map(int,input().split())
    if a>my_min:
        my_min=a
    if b<my_max:
        my_max=b
if my_max-my_min<0:
    print(0)
else:
    print(my_max-my_min+1)

Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.stream.IntStream;

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

        String ans = "Yes";
        int[] h  = IntStream.range(0, sc.nextInt())
            .map(i -> sc.nextInt())
            .toArray();
        
        for (int i = 1; i < h.length - 1; i++ ) {
            if (h[i] > h[i - 1]) {
                h[i]--;
            }
            if (!(h[i] <= h[i + 1])) {
                ans = "No";
                break;
            }
        }
        System.out.println(ans);

        sc.close();
    }
}

Measured memory_bytes: 53364
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		int a=cin.nextInt(),b=cin.nextInt(),c=cin.nextInt();
		
		if(a<b && b<c)System.out.println("Yes");
		else System.out.println("No");
	}

}



Measured memory_bytes: 26376