akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <utility>
#include <cmath>
#include <string>
#include <bitset>
#include <queue>
#include <cstdio>
#include <cstring>
#include <deque>
#include <unordered_map>
#include <climits>
#include <map>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <ctime>


#define ci(t) cin>>t
#define co(t) cout<<t
#define LL long long
#define fa(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>b;--i)
#define setp pair<pair<int,int>,int>
#define setl pair<LL,LL>
#define micro 0.000001
using namespace std;

int gcd(int a, int b) { return a % b ? gcd(b, a % b) : b; }
pair <int, int> vu[4] = { {0,1}, {0,-1} , {1,0},{-1,0} }; // EWSN

const int max_v = 1e3 + 7;
const int INF = 1e9 + 7;

int arr[max_v];
int sum;
int ans;
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, m; ci(n >> m);

	fa(i, 0, n) ci(arr[i]);
	fa(i, 0, n) sum += arr[i];
	
	fa(i, 0, n)
	{
		if (arr[i]*4*m >= sum) ++ans;
	}
	if (ans >= m)
	{	
		co("Yes");
	}
	else co("No");
	return 0;
}

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

using namespace std;

#define fori(x) for(int i=0;i<x;++i)
#define forj(x) for(int j=0;j<x;++j)

constexpr int maximum = 110000;

struct review {
	string s;
	int p;
	int n;
	bool operator> (const review& a) const {
		if (s == a.s) {
			return p > a.p;
		}
		else {
			return s < a.s;
		}
	}
};



int main() {
	int n;
	cin >> n;
	review r[100];
	fori(n) { cin >> r[i].s >> r[i].p; r[i].n = i + 1; }
	sort(r, r + n, greater <review>());
	fori(n) { cout << r[i].n << endl; }
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Created by kazuki on 2014/07/12.
 */
public class Main{
    static Scanner s = new Scanner(System.in);

    public static void main(String[] args) {
        int m;

        m = s.nextInt();

        while (m-- != 0) {
            int firstMoney = s.nextInt();
            int year = s.nextInt();
            int type = s.nextInt();
            int money;
            int maxMoney = 0;

            for (int i = 0; i < type; i++) {
                int rateType = s.nextInt();
                double rate = s.nextDouble();
                int charge = s.nextInt();


                if (rateType == 0)
                    money = singleCulc(firstMoney, rate, charge, year);
                else
                    money = doubleCulc(firstMoney, rate, charge, year);

                maxMoney = Math.max(maxMoney, money);
            }
            System.out.println(maxMoney);
        }
    }

    static int singleCulc(int firstMoney, double rate, int change, int year) {
        int interest = 0, money = firstMoney;
        for (int i = 0; i < year; i++) {
            interest += money * rate;
            money -= change;
        }
        return money + interest;
    }

    static int doubleCulc(int firstMoney, double rate, int change, int year) {
        int money = firstMoney;
        for (int i = 0; i < year; i++) {
            money = money + (int) (money * rate) - change;
        }
        return money;
    }
}

Measured memory_bytes: 42100
#include<bits/stdc++.h>
 // #include <ext/pb_ds/tree_policy.hpp>
 // #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
  using namespace std;
   using namespace std::chrono;      
  // using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        1e18
 #define sm         -2e18
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;
#define MEM(x,val) memset(x,val,sizeof(x))

 // typedef tree<pii, null_type, less<pii>, rb_tree_tag,  
 //            tree_order_statistics_node_update>  odst; 


void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
   
    #endif
}


const int Mxn = 1e6+1;
int mp[Mxn] , prim[Mxn] , ar[Mxn];

void solve()
{
  
  int n;
  cin >> n;
  
  int GCD = 0;
  forf(i,0,n) 
  {
    cin >> ar[i];
    if(GCD == 0 ) GCD = ar[i];
    else GCD = __gcd(GCD,ar[i]);
  }
  

  forf(i,0,n)
  {
    mp[ar[i]]++;
  }
  
  int is = 0;

  for(int i=2;i<Mxn;i++)
  if(prim[i]==0)
  {
      int c = 0;
      for(int j=1;j*i<Mxn;j++)
      {
        c+=mp[i*j];
        prim[i*j]=1;
      }
      if(c>1)
      {
        is=1;
        break;
      }
  }
  
  if(GCD != 1)
  {
    cout<<"not coprime";
    return ;
  }
  if(is==0)
  {
    cout<<"pairwise coprime";
    return ;
  }
  
  cout<<"setwise coprime";


}

int32_t main()
{
  pr_init();
  fastio;
  auto start = high_resolution_clock::now(); 
  solve(); 
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    // cout << "Time taken by function: "
    //      << duration.count() << " microseconds" << endl; 

  return 0;
}

Measured memory_bytes: 26924
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const double EPS = 1E-10;

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




int main(){
    int R; std::cin >> R;
    std::cout << std::fixed << std::setprecision(10) << 2 * R * M_PI << std::endl;
    return 0;
}


Measured memory_bytes: 3776
N = input()

ans = 0

dp = [0,2]

for i in range(len(N)):

    ndp = [float("inf"),float("inf")]

    num = int(N[-1-i])

    ndp[0] = min( dp[0] + num , dp[1] + num )
    ndp[1] = min( dp[0] + 2 + 9 - num , dp[1] + 9 - num)

    dp = ndp

    #print (dp)

print (min(dp))


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

int main(){
  int N, T;
  cin >> N >> T;
  int cost=1001;
  for(int i=0; i<N; i++){
    int c, t;
    cin >> c >> t;
    if(t<=T && cost>c) cost=c;
  }
  if(cost==1001){
    cout << "TLE" << endl;
    return 0;
  }
  cout << cost << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    char s[1001];
    scanf("%s",s);
    for(int i=0;s[i]!='\0';i++){
        if(s[i+1]=='\0'){
            if(s[i]=='s'){
                printf("%ses\n",s);
            }else{
                printf("%ss\n",s);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 1732
#include<iostream>
#include<algorithm>
#include<vector>
#include <numeric>
using namespace std;
int main(int argc, char const *argv[]) {
    int N,tmp;
    double x;
    string u;
   
    std::cin >> N;


    double ans=0;
    for (size_t i = 0; i < N; i++) {
        std::cin >> x >>u;
        if(u=="JPY"){ans = ans+x;}
      else{ans = ans+(x*380000.0);}
    }
    std::cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a, b, i, j;
    while(1){
        scanf("%d %d", &a, &b);
        if(a == 0 && b == 0) break;
        
        for(i = 1; i <= a; i++){
            for(j = 1; j <= b; j++){
                if(i > 1 && i < a && j < b && j > 1)printf(".");
                else printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


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

using namespace std;
using P = pair<int, int>;
using ll = long long;
constexpr int mod = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;

int h, w;
vector<string> s;

int main() {
  cin >> h >> w;
  s.resize(h);
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }

  int l[h][w] = {}, r[h][w] = {}, u[h][w] = {}, d[h][w] = {};
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') {
        l[i][j] = 0;
      } else {
        l[i][j] = j > 0 ? l[i][j - 1] + 1 : 1;
      }
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = w - 1; j >= 0; j--) {
      if (s[i][j] == '#') {
        r[i][j] = 0;
      } else {
        r[i][j] = j < w - 1 ? r[i][j + 1] + 1 : 1;
      }
    }
  }

  for (int j = 0; j < w; j++) {
    for (int i = 0; i < h; i++) {
      if (s[i][j] == '#') {
        u[i][j] = 0;
      } else {
        u[i][j] = i > 0 ? u[i - 1][j] + 1 : 1;
      }
    }
  }

  for (int j = 0; j < w; j++) {
    for (int i = h - 1; i >= 0; i--) {
      if (s[i][j] == '#') {
        d[i][j] = 0;
      } else {
        d[i][j] = i < h - 1 ? d[i + 1][j] + 1 : 1;
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int total = l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3;
      // printf("l: %d, r: %d, u: %d, d: %d\n", l[i][j], r[i][j], u[i][j],
      //        d[i][j]);
      ans = max(ans, total);
    }
    cout << endl;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 66816
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

signed main() {
	int n;
	cin >> n;
	P p[100005];
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		p[i].first = a - b;
		p[i].second = a + b;
	}
	sort(p, p + n);
	int ans = n;
	int be = 0, af = 1;
	while (af < n) {
		if (p[be].second > p[af].first) {
			ans--;
			if (p[af].second >= p[be].second) {
				af++;
			}
			else {
				be = af;
				af++;
			}
		}
		else {
			be = af;
			af++;
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
typedef long long LL;
typedef long double Lf;
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define N 100009
#define MOD 1000000007
int acs(const void* a, const void* b) { return *(int*)a - *(int*)b; }//1,2,3,4
int des(const void* a, const void* b) { return *(int*)b - *(int*)a; }//8,7,6,5
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; }//a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); }//aaa,aab
//temmie_のsnippet

int main() {
	int a[27],n;char s[N];LL ans=1;
	rep(i,26)a[i]=1;
	scanf("%d%s",&n,s);
	rep(i,n)a[s[i]-97]++;
	rep(i,26){ans*=a[i];ans%=MOD;}
	printf("%lld",ans-1);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
using namespace std;


#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

int main() {
	double n;
	cin >> n;
	double pi = 3.14;
	cout << n * 2 * pi << endl;
}


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

using namespace std;

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  int n, m;
  scanf("%d %d", &n, &m);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  sort(a.begin(), a.end());
  int answer = 0;
  for (auto x : a) {
    if (m >= x) {
      m -= x;
      ++answer;
    }
  }
  if (answer == n && m) {
    --answer;
  }
  printf("%d\n", answer);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n,k,i;
    char c;
    char str[20];
    cin>>n;
    scanf("%s",str);
    cin>>k;
    c=str[k-1];
    for(i=0;i<=n-1;i++) if(str[i]!=c) str[i]='*';
    printf("%s",str);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;

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

	int eat;
	int ans = 0;
	for( int i = l; i < l + n; i++ )
	{
		ans += i;
	}

	if( l > 0 ) eat = l;
	else if( l + n-1 < 0 ) eat = l + n - 1;
	else eat = 0;

	cout << ans - eat << endl;

}


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

int	main()
{
	vector<int>	vec_b(3);
	int	a;
	int	c;
	for (int i = 0; i < 3; ++i)
		cin >> vec_b.at(i);
	bool	is_correct = true;
	for (int j = 0; j < 2; ++j) {
		for (int i = 0; i < 3; ++i) {
			cin >> c;
			if (i == 0)
				a = c - vec_b.at(i);
			else if (c != a + vec_b.at(i)) {
				is_correct = false;
				break;
			}
		}
	}
	if (is_correct)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

#define LL long long
const int maxn = 100 + 100;
int l, r;
LL ans;

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

    while(scanf("%d%d", &l, &r) != EOF) {
        if(r - l > 3000) {
            printf("0\n");
            continue;
        }
        ans = 2019;
        for(LL i = l; i <= r; ++i) {
            for(LL j = i + 1; j <= r; ++j) {
                ans = min(ans, i * j % 2019);
            }
        }
        printf("%lld\n", ans);
    }

    return 0;
}

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

#define SZ(x) ((int(x.size())))

typedef long long ll;
typedef long double ld;

using namespace std;

ll A, B, C;

int main()
{
	cin >> A >> B >> C;
	if (!(A & 1) || !(B & 1) || !(C & 1))
		cout << 0;
	else
		cout << min (min (A * B, B * C), A * C);
	return 0;
}

Measured memory_bytes: 256
p,r=input,range
A=sum([list(map(int,p().split()))for _ in r(3)],[])
b=[int(p())for _ in r(int(p()))]
print('Yes'if[v for v in[7,56,73,84,146,273,292,448]if sum(1<<i for i in r(9)if A[i]in b)&v==v]else'No')

Measured memory_bytes: 9200
import java.util.Scanner;

public class Main {
	static String str;
	static int[] A = new int[3];
	static int[] banboo;

	public static void main(String[] args) {
		readInput();

		solve();
	}

	static void solve() {
		int ans = 1000;
		
		for(int i = 0; i<str.length()-2; i++) {
			int num = Integer.parseInt(str.substring(i, i+3));
			int diff = Math.abs(753 - num);
			if(ans > diff) {
				ans = diff;
			}
		}
		
		System.out.println(ans);
	}
	

	static void readInput() {
		try (Scanner sc = new Scanner(System.in)) {
			str = sc.nextLine();
		}
	}
}


Measured memory_bytes: 21460
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u * v / gcd(u, v);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    int N;
    cin >> N;
    map<int, int> m;
    REP(i, N) {
        int tmp;
        cin >> tmp;
        m[tmp]++;
    }

    int ans = 0;
    for (auto&& a : m) {
        if (a.first == a.second)continue;
        if (a.second > a.first)ans += a.second - a.first;
        else ans += a.second;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <iomanip>
#include <climits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <unordered_map>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <random>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

using namespace std;

#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e15
#define _INFLL (long long)-1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

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

int main() {
  string s; cin >> s;
  int x, y; cin >> x >> y;
  vi a, b;
  int mode = 0;
  int buf = 0;
  Loop(i, s.length()) {
    if (mode == 0) {
      if (s[i] == 'F') {
        buf++;
      }
      else {
        a.push_back(buf);
        buf = 0;
        mode = 1;
      }
    }
    else {
      if (s[i] == 'F') {
        buf++;
      }
      else {
        b.push_back(buf);
        buf = 0;
        mode = 0;
      }
    }
  }
  if (mode == 0) a.push_back(buf);
  if (mode == 1) b.push_back(buf);
  vector<bool> dpx(16001, false), dpx2 = dpx;
  dpx[8000] = true;
  vector<bool> dpy(16001, false), dpy2 = dpy;
  dpy[8000] = true;
  Loop(i, a.size()) {
    Loop(j, dpx.size()) {
      if (dpx[j]) {
        dpx2[j + a[i]] = true;
        if (i != 0) dpx2[j - a[i]] = true;
      }
    }
    dpx = dpx2;
    dpx2 = vector<bool>(16001, false);
  }
  Loop(i, b.size()) {
    Loop(j, dpy.size()) {
      if (dpy[j]) {
        dpy2[j + b[i]] = true;
        dpy2[j - b[i]] = true;
      }
    }
    dpy = dpy2;
    dpy2 = vector<bool>(16001, false);
  }
  if (dpx[8000 + x] && dpy[8000 + y]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define ll long long
#define no {cout<<"UNRESTORABLE";return 0;}
il int in(){
	int s=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')return -in();c=getchar();}
	while(c>='0'&&c<='9'){s=(s<<1)+(s<<3)+(c^48);c=getchar();}
	return s;
}
int main(){
	string s,t;cin>>s>>t;
	if(t.size()>s.size())no;
	string ans="";
	for(int _=0;_<=s.size()-t.size();++_){
		bool f=1;
		for(int __=0;__<t.size();++__){
//			cout<<s[__+_]<<' '<<t[__]<<endl;??p
			if(s[__+_]!='?'&&s[__+_]!=t[__]){f=0;break;}
		}
		if(f){
			string ss="";
			int __=0;
			for(;__<_;++__)ss+=(s[__]=='?'?'a':s[__]);
			for(;__<t.size()+_;++__)ss+=(t[__-_]);
			for(;__<s.size();++__)ss+=(s[__]=='?'?'a':s[__]);
			if(ans=="")ans=ss;
			else ans=min(ans,ss);
		}
//		cout<<endl;
	}
	if(ans!=""){cout<<ans<<endl;return 0;}
	no;
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;

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


template <class T0, class T1>
class LazySegmentTree{
private:
    void eval(int k, int len){
        node[k] = g(node[k], lazy[k]);

        if(len > 1){
            lazy[2 * k + 1] = f1(lazy[2 * k + 1], lazy[k]);
            lazy[2 * k + 2] = f1(lazy[2 * k + 2], lazy[k]);
        }
        lazy[k] = u1;
    }

    void update(int a, int b, T1 x, int k, int l, int r){
        eval(k, r - l);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b){
            lazy[k] = f1(lazy[k], x);
            eval(k, r - l);
        }
        else{
            update(a, b, x, 2 * k + 1, l, (l + r) / 2);
            update(a, b, x, 2 * k + 2, (l + r) / 2, r);
            node[k] = f0(node[2 * k + 1], node[2 * k + 2]);
        }
    }

    T0 query(int a, int b, int k, int l, int r){
        if (r <= a || b <= l){
            return u0;
        }
        eval(k, r - l);
        if (a <= l && r <= b){
            return node[k];
        }
        T0 vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        T0 vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return f0(vl, vr);
    }


public:
    int sz;  // 元の配列サイズ
    int n;
    vector<T0> node;
    vector<T1> lazy;
    using F0 = function<T0(T0, T0)>; F0 f0; T0 u0;
    using F1 = function<T1(T1, T1)>; F1 f1; T1 u1;
    using G = function<T0(T0, T1)>;  G g;

    LazySegmentTree(vector<ll> v, F0 f0, T0 u0, F1 f1, T1 u1, G g):
            sz(v.size()), f0(f0), u0(u0), f1(f1), u1(u1), g(g){
        int sz = v.size();
        n = 1;
        while(n < sz) n *= 2;
        node.resize(2*n-1, u0);
        lazy.resize(2*n-1, u1);

        for(int i = 0; i < sz; i++){
            node[i+n-1] = v[i];
        }
        for(int i = n-2; i >= 0; i--){
            node[i] = f0(node[i*2+1], node[i*2+2]);
        }
    }

    void update(int a, int b, T1 x){
        update(a, b, x, 0, 0, n);
    }

    void update(int a, T1 x){
        update(a, a+1, x);
    }

    T0 query(int a, int b){
        return query(a, b, 0, 0, n);
    }

    T0 query(int a){
        return query(a, a+1);
    }
};


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

    LazySegmentTree<ll, ll> seg(
            vector<ll>(n, (1LL << 31) - 1),
            [](ll x, ll y) { return min(x, y); }, (1LL << 31) - 1,
            [](ll x, ll y) { return y == (1LL << 31) - 1 ? x : y; }, (1LL << 31) - 1,
            [](ll x, ll y) { return y == (1LL << 31) - 1 ? x : y; }
    );
    for(int i = 0; i < q; i++){
        int ty, s, t, x;
        cin >> ty >> s >> t;
        if(ty == 0){
            cin >> x;
            seg.update(s, t+1, x);
        }
        else{
            cout << seg.query(s, t+1) << endl;
        }
    }



    return 0;
}



Measured memory_bytes: 7596
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>

using namespace std;

#define MAXN 3005

long double dp[MAXN];

long double eps = 1e-9;

int main(){

    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);
    cout<<setprecision(10);
    int n;cin>>n;
    long double cur;
    
    
    dp[0]=1; 
    for(int i=0;i<n;i++){

        cin>>cur;

        for(int c = i+1;c>=0;c--){

            dp[c] = (c==0?0:dp[c-1] * cur) + dp[c] * (1-cur); 

        }

    }
    long double ans=0,sum=0;
    for(int i=0;i<=n;i++){
        if(i>=(n+1)/2) ans+=dp[i];
        sum+=dp[i];    
    }
    //cerr<<"sum "<<sum<<endl;
    assert(abs(1-sum)<eps);

    cout<<ans<<endl;

}


Measured memory_bytes: 256
import collections

h, w = map(int, input().split())
cs = [list(map(int, input().split())) for _ in range(10)]
counter = collections.Counter()
for _ in range(h):
    for x in map(int, input().split()):
        if x != -1:
            counter[x] += 1

for k in range(10):
    for i in range(10):
        for j in range(10):
            d = cs[i][k] + cs[k][j]
            if cs[i][j] > d:
                cs[i][j] = d

res = 0
for k, v in counter.items():
    res += cs[k][1] * v
print(res)

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

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

k = int(input())

g = [[] for _ in range(k)]
for i in range(k):
    g[i].append(((i+1)%k,1))
    if i: g[i].append((10*i%k,0))

#print(g)
"""
from collections import deque
q = deque([1])
INF = float("inf")
res = [INF]*k
res[1] = 1
while q and res[0] == INF:
#    print(q)
    v = q.popleft()
    for c,d in g[v]:
        if res[c] <= res[v] + d: continue
        res[c] = res[v] + d
        if d: q.append(c)
        else: q.appendleft(c)

#print(res)
#print(used)
print(res[0])
"""

from heapq import *
def dijkstra(g,start):
    n = len(g)
    dist = [float("inf")]*(n) #startからの最短距離
    pending = n-1 #未確定の点の個数
    dist[start] = 0
    q = [(0,start)] #(そこまでの距離、点)
    while q and pending:
        c,v = heappop(q)
        if dist[v] < c: continue
        pending -= 1
        for to, cost in g[v]:
            if dist[v] + cost < dist[to]:
                dist[to] = dist[v] + cost
                heappush(q, (dist[to], to))
    return dist

dist = dijkstra(g,1)
print(dist[0]+1)






Measured memory_bytes: 38272
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        abc: [u32; 3],
    }
    let mut abc = abc;

    abc.sort();

    let answer = abc[2] * 10 + abc[1] + abc[0];

    println!("{}", answer);
}


Measured memory_bytes: 4352
S = input()
a = [0] * (len(S) + 1)
for i in range(len(S)):
    if S[i] == "<":
        a[i + 1] = a[i] + 1
 
for i in list(range(len(S)))[::-1]:
    if S[i] == ">" and a[i + 1] >= a[i]:
        a[i] = a[i + 1] + 1
 
print(sum(a))

Measured memory_bytes: 52940
n, x = map(int, input().split())
a = list(map(int, input().split()))

cnt = 0
for i in range(n-1):
    diff = (a[i] + a[i+1]) - x
    if diff <= 0:
        continue
    if diff <= a[i+1]:
        a[i+1] -= diff
    else:
        a[i] -= (diff - a[i+1])
        a[i+1] = 0
    cnt += diff
print(cnt)

Measured memory_bytes: 14132
function Main(input) {
	
    input = input.split(" ");
    var a = parseInt(input[0],10);
    var p = parseInt(input[1],10);
    var p = a * 3 + p
    var res = Math.floor(p / 2)
    console.log(res);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
const int md=1e9+7;
int n,k,m;
int ans;
int dp[25010][410];
int ndp[25010][410];
int a[25010];
int cnt;
int s[25010];
bool f;
void add(int &x,int y)
{
	x+=y;
	if(x>=md)x-=md;
}
int qmul(int x,int p)
{
	int res=1;
	for(;p;x=1LL*x*x%md,p>>=1)if(p&1)res=1LL*res*x%md;
	return res;
}
int solve2()
{
	ndp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		int nsum,sum;
		nsum=sum=0;
		for(int j=k-1;j>=1;j--)
		{
			add(nsum,ndp[i-1][j]);
			add(ndp[i][j],1LL*(k-j+1)*ndp[i-1][j-1]%md);
			add(ndp[i][j],nsum);
			add(sum,dp[i-1][j]);
			add(dp[i][j],1LL*(k-j+1)*dp[i-1][j-1]%md);
			add(dp[i][j],sum);
			if(j>=m)add(dp[i][j],ndp[i][j]);
		}
	}
	int res=0;
	for(int i=1;i<=k;i++)add(res,dp[n][i]);
	int tmp=1;
	for(int i=k;i>=k-m+1;i--)tmp=1LL*tmp*i%md;
	res=1LL*res*qmul(tmp,md-2)%md;
	return res;
}
int solve3()
{
	memset(s,0,sizeof(s));
	int h=0;
	while(h+1<=m && !s[a[h+1]])s[a[h+1]]++,h++;
	memset(s,0,sizeof(s));
	int t=m+1;
	while(t-1>=1 && !s[a[t-1]])s[a[t-1]]++,t--;
	dp[0][h]=ndp[0][m+1-t]=1;
	for(int i=1;i<=n-m;i++)
	{
		int sum,nsum;
		sum=nsum=0;
		for(int j=k-1;j>=1;j--)
		{
			add(nsum,ndp[i-1][j]);
			add(ndp[i][j],1LL*(k-j+1)*ndp[i-1][j-1]%md);
			add(ndp[i][j],nsum);
			add(sum,dp[i-1][j]);
			add(dp[i][j],1LL*(k-j+1)*dp[i-1][j-1]%md);
			add(dp[i][j],sum);
		}
	}
	int res=0;
	for(int i=0;i<=n-m;i++)
	{
		int s1=0,s2=0;
		for(int j=1;j<k;j++)add(s1,dp[i][j]),add(s2,ndp[n-m-i][j]);
		add(res,1LL*s1*s2%md);
	}
	return res;
}
int main()
{
	scanf("%d%d%d",&n,&k,&m);
	for(int i=1;i<=m;i++)scanf("%d",a+i);
	ans=n+1-m;
	for(int i=1;i<=n-m;i++)ans=1LL*ans*k%md;
	for(int i=1;i<=m;i++)
	{
		s[a[i]]++;
		if(s[a[i]]==1)cnt++;else if(s[a[i]]==2)cnt--;
		if(i>k)
		{
			s[a[i-k]]--;
			if(s[a[i-k]]==1)cnt++;else if(s[a[i-k]]==0)cnt--;
		}
		if(cnt==k)
		{
			f=true;
			break;
		}
	}
	if(!f)
	{
		if(cnt==m)add(ans,md-solve2());
		else add(ans,md-solve3());
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 80384
package main

import (
	"fmt"
	"os"
)

func run() int {
	var a, b, c int
	fmt.Scanf("%d %d %d\n", &a, &b, &c)

	if a == b && b == c {
		fmt.Println("No")
		return 0
	}

	if a != b && b != c && a != c {
		fmt.Println("No")
		return 0
	}

	fmt.Println("Yes")

	return 0
}

func main() {
	os.Exit(run())
}


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

using namespace std;
int a[100005],dp[100005];
vector<int>g[100005];
void dfs(int a){
	if(g[a].size()==0)return;
	for(int i=0;i<g[a].size();i++){
		dfs(g[a][i]);
	} 
	vector<int>top;
	for(int i=0;i<g[a].size();i++){
		top.push_back(dp[g[a][i]]);
	}
	sort(top.begin(),top.end());
	int mx=0,len=top.size();
	for(int i=0;i<top.size();i++){
		mx=max(mx,top[i]+len-i);
	}
	dp[a]=mx;
}
int main(){
	int n;
	cin>>n;
	for(int i=2;i<=n;i++){
		cin>>a[i];
		g[a[i]].push_back(i);
	}
	dfs(1);
	cout<<dp[1]<<endl;
	return 0;
}

Measured memory_bytes: 14336
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def rec(s, n):
    c = 0
    if s == '':
        s = '0'
    if int(s) > n:
        return 0
    if len(set(s)) == 4:
        # print(s)
        c += 1
    for i in '357':
        w = s + i
        c += rec(w, n)
    return c

def main():
    n = int(input().strip())
    print(rec('', n))

if __name__ == '__main__':
    main()


Measured memory_bytes: 47964
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int a,b,c; cin >> a >> b >> c;
    cout << max(c+b-a,0) << endl; return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC123
{
    class Program
    {
        static void Main(string[] args)
        {
            // FiveAntennas(); // 25min 掛けたが解けず
            // FiveDishes(); // 35min

            FiveTransportation();
        }

        public static void FiveTransportation()
        {
            long n = ReadLong();
            long[] time = new long[5];
            for (int i = 0; i < 5; i++)
            {
                time[i] = ReadLong();
            }

            long min = time.Min();

            long ans = (long)Math.Ceiling(n * 1.0m / min) + 4;

            Console.WriteLine(ans);
        }

        public static void FiveDishes()
        {
            int[] dishes = new int[5];
            for(int i = 0; i < 5; i++)
            {
                dishes[i] = ReadInt();
            }

            dishes = dishes.OrderByDescending(i => i % 10 == 0 ? 10 : i % 10).ToArray();

            int ans = 0;
            for(int i = 0; i < 4; i++)
            {
                ans += (int)Math.Ceiling(dishes[i] / 10m) * 10;
            }

            ans += dishes[4];

            Console.WriteLine(ans);
        }

        public static void FiveAntennas()
        {
            int[] antennas = new int[5];
            for(int i = 0; i < 5; i++)
            {
                antennas[i] = ReadInt();
            }

            int k = ReadInt();

            string ans = "Yey!";
            if (antennas[0] + k < antennas[4])
            {
                ans = ":(";
            }

            Console.WriteLine(ans);
        }

        public static int[] ReadBinaryString()
        {
            return Console.ReadLine().Select(c => int.Parse(c.ToString())).ToArray();
        }

        public static bool[] ReadBoolArray()
        {
            return Console.ReadLine().Select(c => c == '1').ToArray();
        }

        public static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        public static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
    }
}


Measured memory_bytes: 13268
n,k=map(int,input().split())
d=list(map(int,input().split()))
while 1<2:
  nn=list(map(int,list(str(n))))
  if len(set(nn+d))<len(set(nn))+len(set(d)):
    n+=1
  else:
    print(n)
    break

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
int H,W;
int i,j;
int h,w;
for(;;)
{
 scanf("%d %d",&H,&W);
 h=H-2;
 w=W-2;
 if(H!=0&&W!=0)
 { 
  for(i=1;i<=H;i++)
  {
   if(i==1||i==H)
   {
    for(j=1;j<=W;j++)
    {
     printf("#");
    }
    printf("\n");
   }
   else if(i!=1&&i!=H)
   {
    printf("#");
    for(j=1;j<=w;j++)
    {
     printf(".");
    }
    printf("#\n");
   }
  }
  printf("\n");
 }
 else
 {
  break;
 }
}
return 0;
}  
   

Measured memory_bytes: 1020
#include<iostream>
using namespace std;
int main(){
  int n,r,p,c,a[100],b[100];
  while(cin>>n>>r){
    if(n==0 && r==0)break;
    for(int i=0;i<n;i++)
      a[i]=n-i;
    for(int i=0;i<r;i++){
      cin>>p>>c;
      for(int i=0;i<n;i++)
	b[i]=a[i];
      for(int i=0;i<c;i++)
	a[i]=b[p-1+i];
      for(int i=0;i<p-1;i++)
	a[c+i]=b[i];
    }
    cout<<a[0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   char c;
   cin >> c;

   const string vowel = "aeiou";
   cout << (vowel.find(c) == string::npos? "consonant": "vowel") << endl;

   return 0;
}

Measured memory_bytes: 256
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let s: Vec<char> = read_as_string().chars().collect::<Vec<char>>();

    if s.iter().all(|x| *x == 'R') {
        println!("3");
    } else if (s[0] == s[1] || s[1] == s[2]) && s[1] == 'R' {
        println!("2");
    } else if s.iter().all(|x| *x == 'S') {
        println!("0");
    } else {
        println!("1");
    }
}


Measured memory_bytes: 2172
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int k, n, a[200010];
int ma;

signed main() {
	cin >> k >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i)ma = max(ma, a[i] - a[i - 1]);
	}
	ma = max(ma, k + a[0] - a[n - 1]);
	cout << k - ma << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

int q(const int *a,const int *b)
{
    return *a-*b;
}

int main(void)
{
    int n,i,j,s=0,t;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        if(i%2==0)continue;
        t=0;
        for(j=1;j<=i;j++){
            if(i%j==0)t++;
        }
        if(t==8)s++;
    }
    printf("%d",s);
    return 0;
}

Measured memory_bytes: 128
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro buffered-read-line (&optional (buffer-size 30) (in '*standard-input*) (terminate-char #\Space))
  "Note that the returned string will be reused."
  (let ((buffer (gensym))
        (character (gensym))
        (idx (gensym)))
    `(let ((,buffer (load-time-value (make-string ,buffer-size
                                                  :element-type 'base-char))))
       (declare (simple-base-string ,buffer))
       (loop for ,character of-type base-char =
                #-swank (code-char (read-byte ,in nil #\Newline))
                #+swank (read-char ,in nil #\Newline)
             for ,idx from 0
             until (char= ,character #\Newline)
             do (setf (schar ,buffer ,idx) ,character)
             finally (setf (schar ,buffer ,idx) ,terminate-char)
                     (return (values ,buffer ,idx))))))

(declaim (inline split-integers-into-array))
(defun split-integers-into-array (string dest-array row &key (offset 0))
  (declare (string string)
           ((simple-array * (* *)) dest-array)
           ((integer 0 #.most-positive-fixnum) row offset))
  (loop for idx from offset below (array-dimension dest-array 1)
        for pos1 = 0 then (1+ pos2)
        for pos2 = (position #\space string :start pos1 :test #'char=)
        do (setf (aref dest-array row idx)
                 (parse-integer string :start pos1 :end pos2))
        finally (return dest-array)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

;; Hauptteil

(defun main ()
  (let* ((h (read))
         (w (read))
         (costs (make-array '(10 10) :element-type 'uint16))
         (wall (make-array (list h w) :element-type 'int16)))
    (dotimes (i 10)
      (split-integers-into-array (buffered-read-line 80) costs i))
    (dotimes (i h)
      (split-integers-into-array (buffered-read-line 800) wall i))
    (dotimes (k 10)
      (dotimes (i 10)
        (dotimes (j 10)
          (when (> (aref costs i j) (+ (aref costs i k) (aref costs k j)))
            (setf (aref costs i j) (+ (aref costs i k) (aref costs k j)))))))
    (println
     (loop for i below h
           sum (loop for j below w
                     sum (if (= -1 (aref wall i j))
                             0
                             (aref costs (aref wall i j) 1)))))))

#-swank(main)


Measured memory_bytes: 21348
#include<cstdio>
int map[51][51];
int dx[9]={0,0,0,-1,1,1,-1,1,-1};
int dy[9]={0,1,-1,0,0,1,-1,-1,1};
int ans[51][51];
inline int check(int x,int y,int n,int m)
{
	int ret=0;
	for(int i=1;i<=8;i++){
		int nx=x+dx[i];
		int ny=y+dy[i];
		if(nx>=1&&nx<=n&&ny>=1&&ny<=m&&map[nx][ny]=='#'){
			ret++;
		}
	}
	return ret;
}
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("\n");
		for(int j=1;j<=m;j++){
			scanf("%c",&map[i][j]);
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(map[i][j]=='.'){
				ans[i][j]=check(i,j,n,m);
			}else{
				ans[i][j]=-1;
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(ans[i][j]!=-1){
				printf("%d",ans[i][j]);
			}else{
				printf("%c",'#');
			}
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int a,b;
    cin>>a>>b;

    vector<int> C;
    int x=4;
    while(x*x<=100100){
        C.push_back(x*x);
        x++;
    }

    int ketaA,ketaB;
    ketaA=to_string(a).size();
    ketaB=to_string(b).size();

    string ans="No";
    for(auto c:C){
        if(a*pow(10,ketaB)+b==c || b*pow(10,ketaA)+a==c) ans="Yes";
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 512
import Data.Maybe
import Data.List
import Text.Printf
import qualified Data.ByteString.Char8 as C

getInts :: IO [Int]
getInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  [x, k, d] <- getInts
  let f a = abs $ abs x - a * d
      t = min k $ (\a -> if odd a /= odd k then (if a == 0 then 1 else a - 1) else a) $ abs x `div` d
      ans = minimum $ map f $ nub [t, if t + 2 <= k then t + 2 else t]
  printf "%d\n" ans


Measured memory_bytes: 4020
import sys
n,m = map(int,input().split())
s = [0] * m
c = [0] * m
for i in range(m):
    s[i],c[i] = map(int,input().split())

for i in range(1000):
    flag = True
    if len(str(i)) == n:
        for j in range(m):
            if str(i)[s[j]-1] != str(c[j]):
                flag = False

        if flag:
            print(i)
            sys.exit()
print(-1)

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

#define int long long
int n;
int p[128], q[128], r[128], b[128];

int m[128];

int re(int i)
{
  if (m[i] != -1) return m[i];
  if (i == 0) {
    return 1;
  }

  int x = re(r[i]);
  int y = re(b[i]);

  int red = x * p[i];
  int blu = y * q[i];

  int gcd = __gcd(red, blu);
  int lcm = red * blu / gcd;

  m[i] = (lcm / p[i]) + (lcm / q[i]);
  return m[i];
}

signed main()
{
  while (cin >> n, n){
    for (int i = 1; i <= n; i++){
      cin >> p[i] >> q[i] >> r[i] >> b[i];
    }

    memset(m, -1, sizeof(m));

    int max_ = -1;
    for (int i = 1; i <= n; i++){
      max_ = max(max_, re(i));
    }

    cout << max_ << endl;
  }
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

void find_divisor(ll N, vector<ll>& divisor) {
  for(int i=1; i<=sqrt(N); i++) {
    if(N % i == 0)
      divisor.push_back(i);
  }
  int n = divisor.size();
  for(int i=n-1; i>=0; i--) {
    if(N != (ll)pow(divisor[i], 2))
      divisor.push_back(N / divisor[i]);
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<ll> A(N);
  set<ll> se;
  map<ll, int> mp;
  rep(i, N) {
    cin >> A[i];
    se.insert(A[i]);
    mp[A[i]]++;
  }
  int cnt = 0;
  rep(i, N) {
    vector<ll> div;
    find_divisor(A[i], div);
    bool ok = true;
    for(ll d: div) {
      if(d == A[i]) continue;
      if(se.count(d)) {
        ok = false;
        break;
      }
    }
    if(ok && mp[A[i]] == 1) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 26700