akhauriyash/Code-Regression huggingface dataset:
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

template<typename T> std::vector<T> divisor(T n) {
  std::vector<T> res;
  for (T i = 1; i * i <= n; ++i) {
    if (n % i == 0){
      res.emplace_back(i);
      if (i * i != n){
        res.emplace_back(n / i);
      }
    }
  }
  std::sort(res.rbegin(), res.rend());

  return res;
}

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

  int n, k; cin >> n >> k;
  
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));

  int sum = accumulate(all(a), int());
  vector<int> v = divisor(sum);

  for (size_t i = 0; i < v.size(); ++i) {
    vector<int> b = a;
    for (int j = 0; j < n; ++j) {
      b[j] %= v[i];
    }

    sort(all(b));

    int sum2 = accumulate(all(b), int());
    int div = sum2 / v[i];
    int cost = 0;
    for (int j = 0; j < div; ++j) {
      cost += (v[i] - b[n - 1 - j]);
    }
    if (cost <= k) {
      print(v[i]); return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end(),greater<int>())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000000000000003 //1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

int ct1,ct2;
struct edge{ll to;}; //edgeパラメータ
struct graph{
  ll N; //ノードの個数
  vector<vector<edge> > G; //G[辺の元]((.to辺の先,.costコスト),...)
  vector<ll> parent;
  vector<ll> depth; // d[ノード] ノードの深さ

  graph(ll n){ //グラフ生成時
    N = n;
    G.resize(N); //Edge情報
    parent.resize(N); //Node情報,親
    depth.resize(N); //Node情報,深さ
    rep(i,N){depth[i]= -1; parent[i]= -1;}
  }
  void add_edge(ll s, ll t){
    G[s].emplace_back((edge){t});
  }

  void dfs(ll v=0, ll p=0, ll d=0){
    parent[v] = p;
    depth[v] = d;
    for(auto&& E : G[v]){ // E つなぐエッジ
      if(E.to != p) dfs(E.to , v , d+1); //まだ行ってないなら
    }
  }
};


void Main(){

  int N;
  cin>>N;

  graph g(N);
  graph g2(N);

  rep(i,N-1){
    int a,b;
    cin>>a>>b;
    g.add_edge(a-1,b-1);
    g.add_edge(b-1,a-1);
    g2.add_edge(a-1,b-1);
    g2.add_edge(b-1,a-1);
  }

  g.dfs();
  g2.dfs(N-1,N-1);

  rep(i,N){
    if(g.depth[i]<=g2.depth[i])ct1++;
    else ct2++;
  }

  cout<< ( ct1>ct2 ? "Fennec" : "Snuke" )<<"\n";
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


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

void dfs(string s, char c)
{
  if (s.size() == N)
  {
    cout << s << endl;
  }
  else
  {
    for (char i = 'a'; i <= c; i++)
    {
      if (i != c)
        dfs(s + i, c);
      else
        dfs(s + i, c + 1);
    }
  }
}

int main()
{
  cin >> N;
  dfs("", 'a');
}


Measured memory_bytes: 1536
#include<iostream>
#include<iomanip>
#include<cmath>
#include<vector>
#include<map>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<deque>
#include<queue>
#include<climits>
#include<list>
#include<stack>
#include<complex>
#define all(n) n.begin(),n.end()
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define INF (1<<27)
#define EPS 1e-10
#define RANGE(a) (0<= a && a <= 5000)

using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef unsigned long long ull;
typedef long long ll;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
int N;
vector<P> vec;
bool exist[5001][5001];

int is_rectangle(int,int);

int main(){

  while(true){
    int mex = 0;

    cin >> N;
    if(N == 0)break;
    rep(i,5001)rep(j,5001)exist[i][j] = false;
    vec.clear();
    
    rep(i,N){
      int a,b; 
      cin >> a >> b;
      
      vec.pb(P(a,b));
      exist[a][b] = true;
    }
    
    rep(i,N){
      rep(j,N){
	
	if(i == j)continue;
	int vol = is_rectangle(i,j);
	if(vol){
	 	  mex = max(mex,vol);
	}

      }
    }
 
    cout << mex << endl;
  }

return 0;
}

int is_rectangle(int i,int j){

  P p,q;
  int vlm,dif_x,dif_y;
  
  dif_x = vec[j].F - vec[i].F,dif_y = vec[j].S - vec[i].S;
  p.F = vec[i].F - dif_y;
  p.S = vec[i].S + dif_x;
  q.F = p.F + dif_x;
  q.S = p.S + dif_y;

  if((RANGE(p.F) && RANGE(p.S) && RANGE(q.F) && RANGE(q.S)) && exist[p.F][p.S] && exist[q.F][q.S]){
       int x,y;
    x = vec[i].F-vec[j].F,y = vec[i].S-vec[j].S;

    return x*x+y*y;
  }
  p.F = vec[i].F + dif_y;
  p.S = vec[i].S - dif_x;
  q.F = p.F - dif_x;
  q.S = p.S - dif_y;
  if( (RANGE(p.F) && RANGE(p.S) && RANGE(q.F) && RANGE(q.S)) && exist[p.F][p.S] && exist[q.F][q.S] ){
    int x,y; 
    x = vec[i].F-vec[j].F,y = vec[i].S-vec[j].S;

    return x*x+y*y;
  }
  return -1;
}

Measured memory_bytes: 25676
#include<iostream>
using namespace std;
 
int main(){
    int n,b,f,r,v; 
    int house[4][3][10];
     
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++){
                house[i][j][k] = 0;
            }
        }
    }
     
    cin >> n;
    for (int x = 0 ; x < n; x++) {
        cin >> b >> f >> r >> v;
         
        house[b-1][f-1][r-1] += v;
         
    }  
     
    for (int i = 0; i < 4; i++) {
        if(i > 0) cout << "####################\n";
        for (int b = 0; b < 3; b++) {
            for (int r = 0; r < 10; r++){
                cout << " " << house[i][b][r];
            }
            cout << endl;
        }
         
    }
     
    
    return 0;
}

Measured memory_bytes: 3076
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
        int first = num / 100;
        int second = num - (first * 100);
        if((first < 1 || first > 12) && (second >= 1 && second <= 12)) System.out.println("YYMM");
        else if((second < 1 || second > 12) && (first >= 1 && first <= 12)) System.out.println("MMYY");
        else if((first >= 1 && first <= 12) && (second >= 1 && second <= 12)) System.out.println("AMBIGUOUS");
        else System.out.println("NA");
	}
}

Measured memory_bytes: 21844
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
double pi=3.1415926535898;
//double pi=acos(-1.0);
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define r0         return 0;
#define CC         continue;
#define bb(x)      cerr<< x <<endl;
#define pii        pair<int,int>
#define pis        pair<int,string>
#define vi         vector<int>
#define F          first
#define S          second
//#define max(a,b) a<b?b:a  __builtin_popcount;
//#define min(a,b) a<b?a:b
//freopen("output.txt","w",stdout),freopen("input.txt","r",stdin);
const ll M  = 1e9+7 ;
const int N = 50500;
const int inf = INT_MAX;
const double eps = 1e-6;
//////////////////////    Hi    ^_^  hack me if you can :P


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

    ll ans = 0 ;

    ans += min(m,n/2);

    m-= ans;
    n-=ans*2;

    ans += n / 4LL;
    cout << ans ;
}

/*



https://ideone.com/goT6Vy//http:
codeforces.com/problemset/problem/466/D

, vector < pair <int,int > >, greater <pair <int, int> >
http://codeforces.com/contest/295/submission/17929453
freopen("output.txt","w",stdout);
freopen("input.txt","r",stdin);

ll pwmod(ll a, ll n, ll mod)
{
    ll ret = 1;
    while (n)
    {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}

for (int i=0; i<n; i++)            Hi    ^_^  hack me if you can :P

int mx[]= {0,0,1,-1, 1,1,-1,-1};
int my[]= {1,-1,0,0, 1,-1,1,-1};
bool inside (int i,int j){return (i>=0 && i<n && j>=0 && j<m);}

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void gcd(LL n,LL m,LL &d,LL &xx,LL &yy)
{
    if(!m)
    {
        d=n;
        xx=1;
        yy=0;
    }
    else
    {
        gcd(m,n%m,d,yy,xx);
        yy-=xx*(n/m);
    }
}

int getm(int l,int r)
{
    if(l>r)
        return N;
    if(l==r)
        return 0;
    if(l==r-1)
        return s[l] != s[r];
    if(s[l]==s[r])
        return getm(l+1,r-1);
    else
        return 1+min(getm(l+1,r),getm(l,r-1));
}

int BIT[si], a[si], n;
void update(int x, int delta)
{
    for(; x <= N; x += x&-x)
        BIT[x] += delta;
}
int query(int x)
{
    int sum = 0;
    for(; x > 0; x -= x&-x)
        sum += BIT[x];
    return sum;
}

#define sc(x)      scanf("%d",&x)
#define scl(x)     scanf("%lld",&x)
#define pr(x)      printf("%d ",x)
#define prl(x)     printf("%lld ",x)
#define prln(x)    printf("%d\n",x)
#define prlln(x)   printf("%lld\n",x)
#define scd(x)     scanf("%lf",&x)
#define prd(x)     printf("%.10f\n",x)


*/


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

namespace ConsoleApp15
{
    class Class354
    {
        static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine().Select(x => int.Parse(x.ToString())).ToArray();

            int count = 0;
            for(int i = 0; i < 10; i++)
            {
                for(int j = 0; j < 10; j++)
                {
                    for(int k = 0; k < 10; k++)
                    {
                        bool[] frags = new bool[3];
                        for(int l = 0; l < S.Length; l++)
                        {
                            if (!frags[0])
                            {
                                if (S[l] == i) frags[0] = true;
                            }
                            else if (!frags[1])
                            {
                                if (S[l] == j) frags[1] = true;
                            }
                            else if (!frags[2])
                            {
                                if (S[l] == k) frags[2] = true;
                            }
                        }
                        if (frags.All(x => x == true)) count++;
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13664
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;

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

    cout << (N * N - A) << endl;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);

    map<ll,int> ans;

    char s[30];
    Rep(i,N){
        Scs(s);
        sort( s, s+10 );
        ll tmp = 0;
        Rep(i,10){
            tmp *= ('z'-'a'+2);
            tmp += s[i]-'a';
        }
        ans[tmp]++;
    }

    ll anse = 0;
    for( pair<ll,int> tt : ans ){
        // printf ("%lld %d\n", tt.first, tt.second );
        ll ttt = tt.second;
        anse += ttt*(ttt-1)/2;
    }

    printf ("%lld\n", anse );

    return 0;
}



Measured memory_bytes: 6528
// AOJ 2249: Road Construction
// 2017.11.15 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 20000
typedef struct { int t, node, c; } QUE;
QUE que[MAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && (que[l].t < que[i].t ||
		que[l].t == que[i].t && que[l].c < que[i].c)) min = l; else min = i;
	if (r < qsize && (que[r].t < que[min].t ||
		que[r].t == que[min].t && que[r].c < que[min].c)) min = r;
	if (min != i) {
		QUE t = que[i]; que[i] = que[min]; que[min] = t;
		min_heapify(min);
	}
}

int deq(int *n, int *t, int *c)
{
	if (qsize == 0) return 0;
	*n = que[0].node, *t = que[0].t, *c = que[0].c;
	que[0] = que[--qsize];
	min_heapify(0);
	return 1;
}

void enq(int n, int t, int c)
{
	int i, min;

	i = qsize++;
	que[i].node = n, que[i].t = t, que[i].c = c;
	while (i > 0 && (que[min = PARENT(i)].t > que[i].t ||
		   que[min].t == que[i].t && que[min].c > que[i].c)) {
		QUE tt = que[i]; que[i] = que[min]; que[min] = tt;
		i = min;
	}
}

#define INF 0x55555555
#define TOSIZE 250
typedef struct { int len, lim, *to, *d, *c; } TBL;
TBL *tbl; char *visited; int size;

int dijkstra(int start)
{
	int i, s, e, c, d, ans = 0;
	TBL *tp;

	qsize = 0;
	memset(visited, 0, sizeof(char)*size);
	enq(start, 0, 0);
	while(deq(&s, &d, &c)) {
//		if (s == goal) break;
		if (visited[s]) continue;
		visited[s] = 1;
		ans += c;
		tp = tbl + s;
		for (i = 0; i < tp->len; i++) {
			e = tp->to[i];
			if (visited[e]) continue;
			enq(e, d + tp->d[i], tp->c[i]);
		}
	}
	return ans;
}


char buf[40], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

void checkMem(TBL *p)
{
	int *to;
	if (p->len < p->lim) return;
	to = calloc(2 * p->lim + 2, sizeof(int));
	memcpy(to, p->to, p->lim * sizeof(int));
	p->lim *= 2;
	free(p->to);
	p->to = to;
}

int main()
{
	int n, m, i, k, u, v, d, c;
	TBL *tp;

	while (fgets(p=buf, 40, stdin) && *p != '0') {
		size = n = getint(), p++, m = getint();

		tbl = calloc(size+2, sizeof(TBL));
		visited = calloc(size+2, sizeof(char));
		for (i = 0; i < size; i++) {
			tbl[i].len = 0, tbl[i].lim = TOSIZE;
			tbl[i].to = calloc(TOSIZE+2, sizeof(int));
			tbl[i].c = calloc(TOSIZE+2, sizeof(int));
			tbl[i].d = calloc(TOSIZE+2, sizeof(int));
		}
		for (i = 0; i < m; i++) {
			fgets(p=buf, 40, stdin);
			u = getint()-1, p++, v = getint()-1, p++, d = getint(), p++, c = getint();
			tp = tbl+u, checkMem(tp);
			k = tp->len, tp->to[k] = v, tp->d[k] = d, tp->c[k] = c, tp->len++;
			tp = tbl+v, checkMem(tp);
			k = tp->len, tp->to[k] = u, tp->d[k] = d, tp->c[k] = c, tp->len++;
		}
		printf("%d\n", dijkstra(0));

		for (i = 0; i < size; i++) free(tbl[i].d), free(tbl[i].c), free(tbl[i].to);
		free(visited), free(tbl);
	}
	return 0;
}

Measured memory_bytes: 29184
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
      cin>>s;

       int freq[100]={0};

         for(int i=0;i<4;i++)
             freq[s[i]]++;

      int count=0;

        for(int i=65;i<=90;i++)
        {
            if(freq[i]==2)
            count++;
        }


         if(count==2)
         cout<<"Yes";

         else
         cout<<"No";

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

//素因数分解
template<typename T>
map<T, T>prime_fact(T n) {
	map<T, T>mp;
	for (unsigned long long i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			mp[i]++;
		}
	}
	if (n != 1) {//sqrt(n)を超えた素数を処理(あっても1つ)
		mp[n]++;
	}
	return mp;
}

int main(){
    ll n,p;
    cin>>n>>p;
    map<ll,ll>mp=prime_fact<ll>(p);
    ll maxv=1;
    for(auto x:mp){
        maxv*=(ll)pow(x.first,x.second/n);
    }
    cout<<maxv<<endl;
    return 0;
}

Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

int dtwo[1000005],N;

void d_init(){
    dtwo[0]=dtwo[1]=0;
    FOR(i,2,N+1){
        int now_i=i;
        int cnt=0;
        while(now_i%2==0){
            cnt++;
            now_i/=2;
        }
        dtwo[i]=dtwo[i-1]+cnt;
    }
}

int COM_2(int N,int i){
    int k=dtwo[N]-(dtwo[i]+dtwo[N-i]);
    if(k==0){
        return 1;
    }
    else{
        return 0;
    }
}

int main() {
    cin >> N;
    d_init();
    string S;
    cin >> S;
    bool b=true;
    rep(i,N){
        S[i]=S[i]-1;
        if(S[i]=='1'){
            b=false;
        }
    }
    ll ans=0;
    if(b){
        rep(i,N){
            if(S[i]=='2'){
                S[i]='1';
            }
        }
    }
    else{
        rep(i,N){
            if(S[i]=='2'){
                S[i]='0';
            }
        }
    }
    rep(i,N){
        if(S[i]=='1'){
            ans+=COM_2(N-1,i);
            ans%=2;
        }
    }
    if(b){
        ans*=2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 9252
#include<iostream>
using namespace std;
const int MAXN=3000+10;
const int mod=1000000007;
int dp[MAXN][MAXN];
long long n,ans;
string s;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	cin>>s;
	s=' '+s;
	s=' '+s;
	dp[1][1]=1;
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='<')
		{
			for(int k=2;k<=i;k++)
			{
				dp[i][k]=dp[i-1][k-1]+dp[i][k-1];
				dp[i][k]%=mod;
			}
		}
		if(s[i]=='>')
		{
			for(int k=i;k>=0;k--)
			{
				dp[i][k]=dp[i][k+1]+dp[i-1][k];
				dp[i][k]%=mod;
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		ans+=dp[n][i];
		ans%=mod;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 34304
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

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

const int MOD = 1000000007;

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int n,a,b;
    cin >> n >> a >> b;
    VI x(n);
    REP(i,n){
        cin >> x[i];
    }

    int ans = 0;
    FOR(i,1,n){
        ans += min((x[i]-x[i-1])*a,b);
    }

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


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

class Main {

    public static void main(String[] args) {
        char[] c=new char[1];
        int sum;
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
            String str = reader.readLine();
            while(true){
                sum=0;
                for(int i=0;i<str.length();i++){
                    str.getChars(i,i+1,c,0);
                    sum+=c[0]-'0';
                }
                System.out.println(sum);
                str=reader.readLine();
                if(str.equals("0"))break;
            }
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}



Measured memory_bytes: 24372
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  cin >> N;
  int a[100000];
  for (int i = 0; i < N; i++) cin >> a[i];

  int count = 0;

  map<int, int> mp;

  for (int i = 0; i < N; i++) mp[a[i]]++;

  for (auto p: mp){
    int x = p.first;
    int n = p.second;
    if (n < x) count += n;
    else count += n - x;
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define int long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repr(i,x,y) for(int i=x;i>=y;i--) 
using namespace std;

void Onigiri()
{
  int n,k;
  cin>>n>>k;
  cout<<min(n%k,k-n%k);
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifdef Zoro
   freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
   #endif  
 
   int t=1; 
   //cin>>t;
 
   while(t--)
   {Onigiri();cout<<"\n";}

   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;
   return 0;
}

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

int main()
{
	/* 代入 */

	long long int N;

	cin >> N;

	long long int A[N + 2];
	long long int B[N + 1];
	long long int A_origin[N + 2];
	long long int B_origin[N + 1];

	for (long long int i = 1; i <= N + 1; i++)
	{
		cin >> A[i];
		A_origin[i] = A[i];
	}

	for (long long int i = 1; i <= N; i++)
	{
		cin >> B[i];
		B_origin[i] = B[i];
	}

	/* 計算 */

	for (long long int i = 1; i <= N; i++)
	{
		if (A[i] >= B[i])
		{
			A[i] = A[i] - B[i];
		}
		else
		{
			if (A[i + 1] - (B[i] - A[i]) >= 0)
			{
				A[i + 1] = A[i + 1] - (B[i] - A[i]);
			}
			else
			{
				A[i + 1] = 0;
			}

			A[i] = 0;
		}
	}

	long long count = 0;

	for (long long int i = 1; i <= N + 1; i++)
	{
		count += A_origin[i] - A[i];
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
using namespace std;
typedef long long ll;
ll n,ans=0;
void f(ll a,ll b){
    cin>>n;
    if(a>n)return ;
    if(b==7)ans++;
    f(10*a+3,b|1);
    f(10*a+5,b|2);
    f(10*a+7,b|4);
}
int main(void){
    f(0,0);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
 
ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
	}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	int n,ans=0,b;
	vi l;
	cin >> n;
	rep(i,2*n){
		cin >> b;
		l.pb(b);
	}
	sort(l.begin(),l.end());
	for(int i=0;i<(2*n);i+=2) ans+=l[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
int n,q,k;
int a[100005] ;
long long sum=0;
int main(){
    priority_queue<int> q;
    cin >> n >> k ;
	int x;
	for(int i=0;i<n;i++) {
		cin >> x;
		q.push(x);
	}	
	while(k--) {
		int t=q.top();
		q.pop();
		t/=2;
		q.push(t) ;
	}
	while(!q.empty()){
		sum+=q.top();
		q.pop();
	}	
	cout << sum <<endl;
	return 0;
}


Measured memory_bytes: 892
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, tmp = 0, f = 1;
    
    cin >> n;
    int a[n];

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

    //for (int i = n - 1; i >= 0; i-- ) {
    while(n--,n) {
        cout << a[n] << " ";
    }
    cout << a[0] << endl;

}    



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

int main() {
  int a, b;
  cin >> a >> b;
  long long ans = 1LL * a * b;
  if (a < b) swap(a, b);
  int r = a % b;
  while (r) {
    a = b;
    b = r;
    r = a % b;
  }
  cout << ans / b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n, x, a[109];
int main() {
	cin >> n >> x;
	int s = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		s += a[i];
	}
	cout << n + (x - s) / *min_element(a, a + n) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
	int a =	sc.nextInt();
	int b =	sc.nextInt();
	int c =	sc.nextInt();
	if(a<=c && c<=b) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 23636
MOD = 10**9 + 7


class modint():
    def __init__(self, value):
        self.value = value % MOD

    def __int__(self):
        return int(self.value)

    def __float__(self):
        return float(self.value)

    def __str__(self):
        return str(self.value)

    def __repr__(self):
        return str(self.value)

    def __add__(self, other):
        return (modint(self.value + other.value) if isinstance(other, modint)
                else modint(self.value + other))

    def __sub__(self, other):
        return (modint(self.value - other.value) if isinstance(other, modint)
                else modint(self.value - other))

    def __mul__(self, other):
        return (modint(self.value * other.value) if isinstance(other, modint)
                else modint(self.value * other))

    def __truediv__(self, other):
        return (modint(self.value * pow(other.value, MOD - 2, MOD))
                if isinstance(other, modint)
                else modint(self.value * pow(other, MOD - 2, MOD)))

    def __pow__(self, other):
        return (modint(pow(self.value, other.value, MOD))
                if isinstance(other, modint)
                else modint(pow(self.value, other, MOD)))

    def __eq__(self, other):
        return (self.value == other.value if isinstance(other, modint)
                else self.value == (other % MOD))

    def __ne__(self, other):
        return (self.value == other.value if isinstance(other, modint)
                else self.value == (other % MOD))

    def __radd__(self, other):
        return (modint(other.value + self.value) if isinstance(other, modint)
                else modint(other + self.value))

    def __rsub__(self, other):
        return (modint(other.value - self.value) if isinstance(other, modint)
                else modint(other - self.value))

    def __rmul__(self, other):
        return (modint(other.value * self.value) if isinstance(other, modint)
                else modint(other * self.value))

    def __rtruediv__(self, other):
        return (modint(other.value * pow(self.value, MOD - 2, MOD))
                if isinstance(other, modint)
                else modint(other * pow(self.value, MOD - 2, MOD)))

    def __rpow__(self, other):
        return (modint(pow(other.value, self.value, MOD))
                if isinstance(other, modint)
                else modint(pow(other, self.value, MOD)))

    def modinv(self):
        return modint(pow(self.value, MOD - 2, MOD))


def main():
    _ = int(input())
    A = [int(i) for i in input().split()]
    from collections import defaultdict
    d = defaultdict(int)
    ans = modint(0)
    for a in A:
        d[a] += 1
        if (a != 0 and d[a-1] < d[a]) or 3 < d[a]:
            return print(0)
        if a == 0:
            if d[a] == 1:
                ans += 1
            elif d[a] == 2:
                ans *= 2
            continue
        if d[a] == 1:
            ans *= d[a-1]
        elif d[a] == 2:
            ans *= d[a-1] - 1

    print((ans*3))


if __name__ == '__main__':
    main()


Measured memory_bytes: 62188
#include <iostream>

using namespace std;
void compare(int a,int b){
 if(a>b){
    for(int i=0;i<a;i++){
        cout<<b;
    }
 }
else if(a<b){
  for(int i=0;i<b;i++){
    cout<<a;
 }}
 else if(a==b){
    for(int i=0;i<b;i++){
        cout<<a;
    }
 }
}

int main()
{  int a,b;
   cin>>a>>b;
   compare(a,b);
    return 0;
}


Measured memory_bytes: 256
#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def main():
    n = int(input())
    a = list(map(int, input().split()))

    # 山1 に降った雨を計算する
    m1 = a[0] * 2
    for i in range(1, n):
        if i % 2 == 1:
            m1 = m1 - a[i] * 2
        else:
            m1 = m1 + a[i] * 2
    m1 //= 2
    # print(m1)

    ans = [m1]
    for i in range(n-1):
        rest = a[i] - ans[-1] // 2
        ans.append(rest * 2)
    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 84452
#include<iostream>

using namespace std;

int main() {
	
	int A[5] = {};
	int B[5] = {};
	
	for(int i=0;i<4;i++) {
		
	cin >> A[i];
	A[4] += A[i];
	
}

	for(int i=0;i<4;i++) {
		
	cin >> B[i];
	B[4] += B[i];
	
}
	if( A[4] >= B[4] )
	cout << A[4] << "\n";
	
	else
	cout << B[4] << "\n";
	
	
	return 0;
}


Measured memory_bytes: 3092
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	bool f = false;
	rep(i, 100) {
		if ((n - i * 4) % 7 == 0 && i * 4 <= n)f = true;
	}
	printyn(f);

	Please AC;
}


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

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] x = new int[n][n];
        int[][] y = new int[n][n];

        for(int i=0; i<n; i++) {
            int a = sc.nextInt();
            Arrays.fill(x[i], -1);
            for(int j=0; j<a; j++) {
                x[i][j] = sc.nextInt() - 1;
                y[i][j] = sc.nextInt();
            }
        }
        int res = 0;
        A: for(int i=0; i<(1<<n); i++) {
            int c = Integer.bitCount(i);
            boolean[] b = new boolean[n];
            for(int j=0; j<n; j++) {
                b[j] = ((i>>j)%2) == 1;
            }
            for(int j=0; j<n; j++) {
                if(!b[j]) continue;
                for(int k=0; k<n; k++) {
                    if(x[j][k] == -1) continue;
                    if(y[j][k] == 1 && !b[x[j][k]]) continue A;
                    if(y[j][k] == 0 && b[x[j][k]]) continue A;
                }
            }
            res = Math.max(res, c);
        }
        System.out.println(res);


    }

}


Measured memory_bytes: 24532
n=int(input())
a=list(map(int,input().split()))
 
count=0
ans=a[0]
for i in range(n):
  count=0
  while(a[i]%2==0):
    a[i]=a[i]//2
    count+=1
  ans=min(ans,count)
  
print(ans)

Measured memory_bytes: 3060
a=tuple(input())
len_a=len(a)
b=tuple(input())
len_b=len(b)
c=tuple(input())
len_c=len(c)
flag_ab=[True]*(2*(len_b+len_c)+1)
for i in range(len_a):
  for j in range(len_b):
    if a[i]!=b[j] and a[i]!='?' and b[j]!='?':
      flag_ab[i-j]=False
flag_ac=[True]*(2*(len_b+len_c)+1)
for i in range(len_a):
  for j in range(len_c):
    if a[i]!=c[j] and a[i]!='?' and c[j]!='?':
      flag_ac[i-j]=False
flag_bc=[True]*(2*(len_b+len_c)+1)
for i in range(len_b):
  for j in range(len_c):
    if b[i]!=c[j] and b[i]!='?' and c[j]!='?':
      flag_bc[i-j]=False
ans=len_a+len_b+len_c
left_a=0
for left_b in range(-(len_b+len_c),len_b+len_c+1):
  for left_c in range(-(len_b+len_c),len_b+len_c+1):
    if flag_ab[left_b-left_a] and flag_ac[left_c-left_a] and flag_bc[left_c-left_b]:
      right_a=left_a+len_a
      right_b=left_b+len_b
      right_c=left_c+len_c
      left=min(left_a,left_b,left_c)
      right=max(right_a,right_b,right_c)
      ans=min(ans,right-left)
print(ans)

Measured memory_bytes: 55692
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int A = stdIn.nextInt();
		int B = stdIn.nextInt();
		
		if((Math.max(A,B)-Math.min(A,B))%2 == 0) {
			System.out.println((Math.max(A,B)+Math.min(A,B))/2);
		}
		else {
			System.out.println("IMPOSSIBLE");
		}

	}

}

Measured memory_bytes: 21972
#include<stdio.h>
#include<string.h>
int h,br;
char a[5];
char b[5];
int i,j;
int main(){
	while(1){
		h=0;
		br=0;
		scanf("%s %s",a,b);
		if(strlen(a)==1&&a[0]=='0')return 0;
		for(i=0;i<4;i++){
			for(j=0;j<4;j++){
				if(a[i]==b[j]){
					if(i==j)h++;
					else br++;
				}
			}
		}
		printf("%d %d\n",h,br);
	}
}

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

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; ll T; cin >> N >> T;
	vector<ll> t(N, 0LL);
	rep (i, N){
		cin >> t[i];
	} // end rep

	ll res = 0LL;
	rep (i, N - 1){
		ll curr = 0LL;
		if (t[i] + T <= t[i+1]){
			curr = T;
		}else{
			curr = t[i+1] - t[i];
		} // end if
//		cerr << "curr: " << curr << endl;
		res += curr;
	} // end rep
	res += T;

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    int n;
    while (cin >> n) {
        int ans = 0;
        FOR(a, 0, 10)FOR(b, 0, 10)FOR(c, 0, 10)FOR(d, 0, 10) {
            if (a + b + c + d == n)ans++;
        }
        cout << ans << "\n";
    }
}



Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

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


Measured memory_bytes: 3596
n=int(input())
a=[int(input()) for i in range(n)]
 
al= {}
ans=0
for ai in a:
  if ai - 1 in al.keys():
    al[ai]=al[ai-1]+1
    ans=max(ans,al[ai-1]+1)   
    del al[ai-1]
  else:
    al[ai]=0

print(n-ans-1)

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

void Main(){
    int N; cin >> N;
    string S; cin >> S;
    int l=0,r=N-1;
    int ans = 0;
    while(l<r){
        while(l<N && S[l]=='R') l++;
        while(r>=0 && S[r]=='W') r--;
        if(l<r){
            swap(S[l],S[r]);
            ans++;
        }
        l++; r--;
    }
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3764
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;


int main(void) {
	string s;

	cin >> s;

	if (s.find("AC") != -1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

a,b = m()

ppp = l()



dp = [0 for i in range(b)]

for i in range(b):
    if i != b-1:
        dp[i] = abs(ppp[i+1]-ppp[i])
    else:
        dp[i] = abs(a-ppp[-1]+ppp[0])

print(sum(dp)-max(dp))


Measured memory_bytes: 82124
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int main(){
	for (string a, b; cin >> a >> b; ) {
		reverse(all(a));
		reverse(all(b));
		if (a.size() < b.size() ) swap(a, b);
		int u = 0;
		rep(i, b.size()) u = (a[i] - '0' + b[i] - '0' + u) / 10;
		REP(i, b.size(), a.size() - 1) u = (a[i] - '0' + u) / 10;
		cout << a.size() + u << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#define MAX 200000

struct gNode{
  int parent;
  int left;
  int right;
};

void S_Depth(int, int);//深さを調べる
int S_Height(int);//高さを調べる
int S_Sibling(int);//兄弟がいるかどうか調べる
int r_search();//rootを調べる
void print();

int n;
int Depth[MAX];//深さの記録用
int Height[MAX];//高さの記録用
struct gNode Node[MAX];//ノードは配列で記録

int main(){
  int i;
  int id, left, right, root;

  scanf("%d",&n);
  //ここでノードの初期化をする
  for(i = 0; i < n; i++){
    Node[i].parent = -1;
    Node[i].left = -1;
    Node[i].right = -1;
  }

  for(i = 0; i < n; i++){
    scanf("%d%d%d", &id, &left, &right);
    Node[id].left = left;
    Node[id].right = right;

    //親を設定(left,rightが存在するとき、親は必ず存在する)
    if(left != -1) Node[left].parent = id;
    if(right != -1) Node[right].parent = id;
  }

  //rootを調べる
  root = r_search();

  S_Depth(root, 0);
  S_Height(root);

  //出力する〜
  print();

  return 0;
}

int r_search(){
  int i;

  for(i = 0; i < n; i++){
    if(Node[i].parent == -1) return i;
  }

  return 0;
}

void S_Depth(int id, int depth){
    if(id == -1) return;//親の接点が葉の場合

    Depth[id] = depth;
    S_Depth(Node[id].left, depth + 1);
    S_Depth(Node[id].right, depth + 1);
}

int S_Height(int id){
    int h1, h2;

    h1 = h2 = 0;
    if(Node[id].left != -1){
        h1 = S_Height(Node[id].left) + 1;
    }
    if(Node[id].right != -1){
        h2 = S_Height(Node[id].right) + 1;
    }
    return Height[id] = (h1 > h2) ? h1 : h2;
}

int S_Sibling(int id){
    if(Node[id].parent == -1) return -1;//rootの場合
    //自分が右の子どもだった場合
    if(Node[Node[id].parent].right != id && Node[Node[id].parent].right != -1){
        return Node[Node[id].parent].right;
    }
    //自分が左の子どもだった場合
    if(Node[Node[id].parent].left != id && Node[Node[id].parent].left != -1){
        return Node[Node[id].parent].left;
    }

    return -1;//親が一つに子供しか産んでない場合
}

void print() {
    int i;
    int degree;

    for(i = 0; i < n; i++){
        printf("node %d: parent = %d, sibling = %d, ", i, Node[i].parent, S_Sibling(i));//兄弟は関数でサーチ

        //兄弟の数を把握！
        degree = 0;
        if(Node[i].left != -1) degree++;
        if(Node[i].right != -1) degree++;

        printf("degree = %d, depth = %d, height = %d, ", degree, Depth[i], Height[i]);

        if(Node[i].parent == -1){
            printf("root\n");
        }else if(Node[i].left == -1 && Node[i].right == -1){
            printf("leaf\n");
        }else{
            printf("internal node\n");
        }
    }
}



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

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) 0
#endif
#define endl '\n'
#define pb push_back
#define mod 1000000007
typedef int integer;
#define int long long
using namespace std;

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

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

const integer NN = (int) 5e5 + 2;
int ar[NN];
int b[NN];
int n, m, k, x;
string s;

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

    for (int i = 0; i < 5; i++){
        int a;
        cin >> a;
        if (!a) cout << i+1 << endl;
    }

}


Measured memory_bytes: 3640
from math import floor
a,b,n = map(int,input().split())
ans = 0
if n <= b:
    for i in range(max(0,n-9),n+1):
        ans = max(ans,floor(a*i/b) - a*floor(i/b))
else:
    for i in range(max(0,b-10),min(n,b+10)):
        ans = max(ans,floor(a*i/b) - a*floor(i/b))
print(ans)

Measured memory_bytes: 9068