akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 8/13/2018
 
 16:10-16:15 analysis
 16:35 RE
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
//const int MAX_N=1e5+1;
//int N;
string S;
//LL A[MAX_N];
int solve() {
  int N=SZ(S);
  vector<pair<char,int>> X={{'#',-1}};
  string t; REP(i,N)if(S[i]!='x') {
    t+=S[i];
    X.emplace_back(S[i],i);
  }
  X.emplace_back('#',N);
  string tt=t; reverse(tt.begin(),tt.end());
  if(tt!=t) return -1;
  int M=SZ(X);
  
//  REP(i,M) dump3(i,X[i].first,X[i].second);
  
  int l=(M-1)/2,r=M%2==0?l+1:l;
  --l,++r;
  int res=0;
  while(l>=0) {
    assert(X[l].first==X[r].first);
    
//    dump4(X[l].first,X[l].second,X[r].first,X[r].second);
    int d1=X[l+1].second-X[l].second,d2=X[r].second-X[r-1].second;
    res+=max(d1,d2)-min(d1,d2);
//    dump3(d1,d2,max(d1,d2)-min(d1,d2));
    --l,++r;
  }
  return res;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>S;
  cout<<solve()<<endl;
  return 0;
}


Measured memory_bytes: 1592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

vector<ll> inv,fact,invfact;
void Mod_build(int n=3010101){
	fact.resize(n+1);
	inv.resize(n+1);
	invfact.resize(n+1);
	fact[0]=inv[0]=invfact[0]=1;
	inv[1]=1;
	for(ll i=0;i<n;i++){
		fact[i+1]=fact[i]*(i+1)%mod;
		if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
		invfact[i+1]=invfact[i]*inv[i+1]%mod;
	}
}
ll perm(int n,int k){
	if(n<0||k<0||k>n)return 0;
	return fact[n]*invfact[n-k]%mod;
}
ll comb(int n,int k){
	if(n<0||k<0||k>n)return 0;
	return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod;
}
ll powmod(ll n,ll k){
	k%=mod-1;
	if(k<0)k+=mod-1;
	ll ret=1;
	while(k){
		if(k&1)ret=ret*n%mod;
		n=n*n%mod;
		k>>=1;
	}
	return ret;
}

ll cal(ll s,ll t){
    return comb(s+1+t+1,s+1)-1;;
}

int main(){
  int i,j;
  int r1,c1,r2,c2;
  cin>>r1>>c1>>r2>>c2;
  Mod_build();
  ll ans=mod+mod+cal(r2,c2)+cal(r1-1,c1-1)-cal(r1-1,c2)-cal(r2,c1-1);
  cout<<ans%mod<<endl;
  
}



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

int main() {
  int a, b;
  cin >> a >> b;
  if (a == 1 && b == 2)
    cout << 3 << endl;
  else if (a == 2 && b == 1)
    cout << 3 << endl;
  else if (a == 2 && b == 3)
    cout << 1 << endl;
  else if (a == 3 && b == 2)
    cout << 1 << endl;
  else if (a == 1 && b == 3)
    cout << 2 << endl;
  else if (a == 3 && b == 1)
    cout << 2 << endl;
}


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

int main() {
  string  S,T;
  int k =0;
  cin >> S >> T;
  for ( int i=0 ;i < S.size();i++){
    if (S.at(i) != T.at(i)){
      cout << "No" << endl;
      k++;
      break;
    }
  }
  if ( k==0){
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef long double ld;

#define rc(s) return cout << s, 0
#define fi first
#define se second
#define L (nod << 1)
#define R (L | 1)
#define smax(X, Y) ((X) > (Y) ? (X) : (Y))
#define smin(X, Y) ((X) < (Y) ? (X) : (Y))

const ll inf = (1LL<<62);
const int iinf = (1<<30);
//CLOCKS_PER_SEC



int main(){
    //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //ifstream cin ("test.in");
    //ofstream cout ("test.out");
    string s;
    int k;
    cin >> k >> s;
    if ((int) s.size() <= k)
        rc(s);
    else
        rc(s.substr(0, k) + "...");
    return 0;
}


Measured memory_bytes: 3556
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;



int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(true){
        c-=b;
        if(c<=0){
            cout<<"Yes"<<endl;
            return 0;
        }

        a-=d;
        if(a<=0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int h, w, ch, cw, dh, dw;
vector<string> vec;
using P = pair<pair<int, int>, int>;

int main()
{
  const int INF = 1e9;
  cin >> h >> w >> ch >> cw >> dh >> dw;
  ch--; cw--; dh--; dw--;
  rep(i, h) {
    string s;
    cin >> s;
    vec.push_back(s);
  }
  vector<vector<int>> dist(h, vector<int>(w, INF));

  int idx = 0;
  vector<int> dx = {1, -1, 0, 0};
  vector<int> dy = {0, 0, 1, -1};
  deque<P> dq;
  dq.emplace_front(make_pair(ch, cw), 0);
  while(!dq.empty()) {
    P v = dq.front(); dq.pop_front();
    int x = v.first.second;
    int y = v.first.first;

    if (dist.at(y).at(x) < v.second) continue;

    dist.at(y).at(x) = v.second;

    rep(i, 4) {
      int nx = x + dx.at(i);
      int ny = y + dy.at(i);

      if (nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
      if (vec.at(ny).at(nx) == '#') continue;
      if (dist.at(ny).at(nx) != INF) continue;
      dq.emplace_front(make_pair(ny, nx), v.second);
    }
    for (int ci = -2; ci <= 2; ci++) {
      for (int cj = -2; cj <= 2; cj++) {
        int cny = y + ci;
        int cnx = x + cj;
        if (cnx < 0 || cny < 0 || cnx >= w || cny >= h) continue;
        if (vec.at(cny).at(cnx) == '#') continue;
        if (dist.at(cny).at(cnx) < v.second+1) continue;
        dq.emplace_back(make_pair(cny, cnx), v.second+1);
      }
    }
  }
  if (dist.at(dh).at(dw) != INF) {
    cout << dist.at(dh).at(dw) << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}

Measured memory_bytes: 9272
# -*- coding: utf-8 -*-
k, n = map(int,input().split())
a = [int(i) for i in input().split()]
a.append(k + a[0])
l = 0
for i in range(n):
    l = max(l, a[i + 1] - a[i])
ans = k - l
print(ans)


Measured memory_bytes: 26444
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto X = readln.chomp.to!int;

    auto ns = new bool[](100004);
    foreach (i; 2..100004) {
        if (ns[i]) continue;
        if (i >= X) {
            writeln(i);
            return;
        }
        auto j = i*2;
        while (j < 100004) {
            ns[j] = true;
            j += i;
        }
    }
}

Measured memory_bytes: 2300
#include <iostream>

using namespace std;

int main()
{
    int n,m,sum=0;
    scanf("%d",&n);
    m=n;
    while (n!=0)
        {
            sum=sum+n%10;
            n=n/10;
        }
    if (m%sum==0) printf("Yes");else printf("No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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;}
int const INF = 1001001001;

// nのm乗
int mypow(int n, int m) {
    int S = 1;
    for(int i = 0; i < m; i++) S *= n;
    return S;
}


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

int D,N;
cin >> D >> N;
if(N == 100) N = 101;
cout << N * mypow(100, D) << endl;
return 0;
}

Measured memory_bytes: 384
N = int(input())
H = list(map(int, input().split()))

dp = [0] * N
dp[1] = abs(H[1] - H[0])

for i in range(2, N):
    dp[i] = min(dp[i-2] + abs(H[i] - H[i-2]), dp[i-1] + abs(H[i] - H[i-1]))

print(dp[N-1])

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

int main()
{
	int n,m;
	int a;
	int total_days;

	cin >> n >> m;
	total_days=0;
	for (int i=0;i<m;++i)
	{
		cin >> a;
		total_days+=a;
	}
	if (total_days<=n)
	{
		cout << n-total_days << endl;
	}
	else
	{
		cout << "-1" << endl;
	}


}



Measured memory_bytes: 3624
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <string>
#include <sstream>
#include <vector>

using namespace std;

double dp[1 << 12][12];
int n;
int c[12];

double d(int back, int next){
  return sqrt(pow(c[back]+c[next],2)-pow(c[back]-c[next],2));
}

double solve(int state, int back){
  if(dp[state][back] != -1) return dp[state][back];
  if(state == (1 << n) - 1) return dp[state][back]=c[back];

  double ret=1e+20;
  double dist;
  for(int i=0;i<n;i++){
    if(!((1 << i)&state)){
      if(state==0){
	dist = c[i];
      }else{
	dist = d(back,i);
      }
      ret = min(ret, solve(state|1<<i,i) + dist);
    }
  }
  return dp[state][back] = ret;
}

int main(void){
  string str;

  while(getline(cin, str)){
    istringstream iss(str);
    double l;
    double ret = 1e+20;
    fill((double *)dp, (double *)dp+(1<<12)*12, -1);
    memset(c, 0, sizeof(c));
    n = 0;
    iss >> l;
    while(iss >> c[n]) n++;
    ret = min(ret, solve(0, 0));

    if(ret <= l){
      cout << "OK" << endl;
    }else{
      cout << "NA" << endl;
    }
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define long long long
using namespace std;
long sum,arr[100005],n,summ;
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin>>n;
  for(int i=1;i<=n;i++)cin>>arr[i];
  arr[0]=0;
  arr[n+1]=0;
  for(int i=0;i<=n;i++)sum+=abs(arr[i]-arr[i+1]);
  for(int i=1;i<=n;i++)
  {
    summ=sum;
    summ-=abs(arr[i]-arr[i+1]);
    summ-=abs(arr[i]-arr[i-1]);
    summ+=abs(arr[i-1]-arr[i+1]);
    cout<<summ<<endl;
  }
  return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

// ランレングス圧縮(Run Length Encoding)
vector<pair<char,int>> RLE(string S){
  vector<pair<char,int>> p;
  int N = S.size();
  for (int i=0;i<N;i++) {
    if (S[i]==S[i+1]){
      int cnt = 1;
      char c = S[i];
      while (i+1<N && S[i]==S[i+1]) {
        i++;
        cnt++;
      }
      p.push_back({c,cnt});
    }
    else p.push_back({S[i],1});
  }

  return p;
}

int main(){
  int H, W; cin >> H >> W;
  string s[H];
  rep(i,H) cin >> s[i];
  int dp[H][W] = {};
  dp[0][0] = (s[0][0]=='#'? 1:0);

  for (int row=0;row<H;row++){
    for (int col=0;col<W;col++){
      if (row==0 && col==0) continue;

      if (col==0){
        dp[row][col] = dp[row-1][col]+(s[row-1][col]=='.' && s[row][col]=='#');
        // if(s[row-1][col]!=s[row][col]) dp[row][col] = dp[row-1][col]+1;
        // else dp[row][col] = dp[row-1][col];
      }
      else if (row==0){
        dp[row][col] = dp[row][col-1] + (s[row][col-1]=='.' && s[row][col]=='#');
        // if(s[row][col-1]!=s[row][col]) dp[row][col] = dp[row][col-1]+1;
        // else dp[row][col] = dp[row][col-1];
      }
      else {
        dp[row][col] = min(dp[row][col-1] + (s[row][col-1]=='.' && s[row][col]=='#'), \
        dp[row-1][col]+(s[row-1][col]=='.' && s[row][col]=='#'));
      } 
    }
  }
  // rep(i,H) {
    // rep(j,W) {
      // if (j>0) cout << " ";
      // cout << dp[i][j]; 
    // }
    // cout << endl;
  // }
  cout << dp[H-1][W-1] << endl;



  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3668
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
using namespace std;
int const MAXN=120000;
int g[MAXN];
bool vis[MAXN];
int res[MAXN];
map<int,pair<int,int>> memo;
pair<int,int> dp(int node){
	if(memo.find(node)!=memo.end())
		return memo[node];
	vis[node]=true;
	if(g[g[node]]==node){
		res[node]++;
		return memo[node]={node,g[node]};
	}
	else{
		auto dest=dp(g[node]);
		res[dest.second]++;
		return memo[node]={dest.second,dest.first};
	}
	
}
int main(){
	cin.tie(0),cin.sync_with_stdio(0),cout.tie(0),cout.sync_with_stdio(0);
	string s;
	cin>>s;
	int n=s.length();
	for(int i=0;i<n;i++)
		g[i]=(s[i]=='R'?i+1:i-1); 
	for(int i=0;i<n;i++){
		if(!vis[i]){
			dp(i);
		}
	}
	for(int i=0;i<n;i++)
		cout<<res[i]<<" ";
}

Measured memory_bytes: 15184
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(int argc, char*argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >>n;
	int jump[n];
	for (int i =0; i< n ; i++)
		cin >> jump[i];
	int dp [n][3];
	dp[0] [1] = abs(jump[0] - jump[1]);
	if(n>2)
		dp[0] [2] = abs(jump[0] - jump[2]);
	for (int i = 1 ; i< n-1; i++)
	{
		dp[i][1] = min( (dp[i-1][1] + abs(jump[i] - jump[i+1])), dp[i-1][2]   );
		if(i+2 < n)
			dp[i][2] = dp[i-1][1]+ abs(jump[i] - jump[i+2]);
	}
	cout << dp[n-2][1]<<endl;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef struct _store{
    int value;
    int num;
}Store;

bool comp(const Store& lh, const Store& rh) {
     
     return lh.value < rh.value;
}

int main(){

   int N,M; cin >> N >> M;
   ull ans = 0;
   Store S[N];
   
   for(int i=0;i<N;i++){
       cin >> S[i].value;
       cin >> S[i].num;
   }
   
   sort(S,S+N,comp);
   
   for(int i=0;i<N;i++){
       if(S[i].num < M){
           M -= S[i].num;
           ans += ((ull)S[i].num*S[i].value);
       }
       else{
           ans += ((ull)M * S[i].value);
           break;
       }
   }
   
   cout << ans << endl;
}

Measured memory_bytes: 4280
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 A=(int)'A';
        int a=(int)'a';
        int x=A-a;
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
            String str = reader.readLine();
            for(int i=0;i<str.length();i++){
                str.getChars(i,i+1,c,0);
                if('A'<=c[0]&&c[0]<='Z'){
                    System.out.print((char)(c[0]-x));
                }else if('a'<=c[0]&&c[0]<='z'){
                    System.out.print((char)(c[0]+x));
                }else System.out.print((char)c[0]);
            }
            System.out.println();
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}



Measured memory_bytes: 24936
<?php
$s = trim(fgets(STDIN));
$good = true;
for($i = 0; $i < strlen($s); $i++){
  if($i % 2 == 0){
    if(!in_array($s[$i], ['R','U','D']))$good = false;
  }else{
    if(!in_array($s[$i], ['L','U','D']))$good = false;
    }
}
echo $good ? "Yes" : "No";

Measured memory_bytes: 4604
#include<iostream>
#include<vector>
using namespace std;typedef pair<int,int>P;int main(){int n,R,p,x,y,s,t,v,w,i;for(;cin>>t>>n>>R,t;cout<<p<<endl){vector<P>A[252][252],*a;for(;t--;A[1+x/40][1+y/40].push_back(P(x,y)))cin>>x>>y;for(p=0;n--;)for(cin>>s>>t,v=3;v--;)for(w=0;w<3;w++)for(a=A[s/40+v]+t/40+w,i=a->size();i--;p+=x*x+y*y<=16*R*R)x=s-(*a)[i].first,y=t-(*a)[i].second;}}

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

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i < (int)vec.size(); ++i) {
        os << vec[i] << (i + 1 == (int)vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
void dump_func() {
    cerr << "\n";
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail) {
    cerr << head;
    if (sizeof...(Tail) == 0) {
        cerr << " ";
    } else {
        cerr << ", ";
    }
    dump_func(std::move(tail)...);
}
#define dump(...) cerr << "[" << to_string(__LINE__) << "]"        \
                       << "    " << string(#__VA_ARGS__) << " = ", \
                  dump_func(__VA_ARGS__)

using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<double>;
using VVI = vector<VI>;
using VVL = vector<VL>;
using PI = pair<int, int>;
using PL = pair<ll, ll>;
using VPI = vector<PI>;
using VPL = vector<PL>;
using VS = vector<string>;

#define ln '\n'
#define REP(t, n) for (int t = 0; t < (n); ++t)
#define FOR(t, a, b) for (int t = (a); t <= (b); ++t)
#define FORR(t, a, b) for (int t = (a); t >= (b); --t)
#define ALL(c) (c).begin(), (c).end()
#define CAUTO const auto&

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VI d(n);
    REP(i, n)
    cin >> d[i];
    sort(ALL(d));
    dump(d);
    cout << d[n / 2] - d[n / 2 - 1] << ln;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int t; cin >> t; cin.ignore(); while(t--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}
 
int main(){
    fast();
 
/* you get what you work for not what you wish for */
    
    ll x, y;
    cin >> x >> y;
    ll xx, yy;
    cin >> xx >> yy;
    ll a[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    x--;
    if(a[x]==y){
        cout << 1;
    }
    else{
        cout << 0;
    }
}

Measured memory_bytes: 256
import itertools
N, M = map(int, input().split())
k = []
s_list = []
for _ in range(M):
  tmp = list(map(int, input().split()))
  k.append(tmp[0])
  s_list.append(tmp[1:])
p = list(map(int, input().split()))
ans = 0
for bit in itertools.product([0, 1], repeat=N):
  flag = True
  for i in range(M):
    tmp = 0
    for j in range(k[i]):
      if bit[s_list[i][j]-1] == 1:
        tmp += 1
    if tmp%2 != p[i]:
      flag = False
      break
  if flag:
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000
char aa[20];
int b[6];
vector<int>c[17];
int a[(1 << 16)];

void init(void) {
	int x = 1;
	f(i, 6)b[i] = 0;
	f(i, 16) {
		if ((i % 2) >= 1)b[0] += x;
		if ((i % 4) >= 2)b[1] += x;
		if ((i % 8) >= 4)b[2] += x;
		if ((i % 16) >= 8)b[3] += x;
		b[5] += x;
		x *= 2;
	}
	return;
}

int score(int l, int r) {
	if (l + 1 == r) {
		if (aa[l] == 'a')return b[0];
		if (aa[l] == 'b')return b[1];
		if (aa[l] == 'c')return b[2];
		if (aa[l] == 'd')return b[3];
		if (aa[l] == '0')return b[4];
		if (aa[l] == '1')return b[5];
	}
	if (aa[l] == '-')return(b[5] ^ score(l + 1, r));
	int x = 0;
	for (int i = l + 1; i < r - 1; i++) {
		if (aa[i] == '^'&&x == 0)return(score(l + 1, i) ^ score(i + 1, r - 1));
		if (aa[i] == '*'&&x == 0)return(score(l + 1, i) & score(i + 1, r - 1));
		if (aa[i] == '(')x++;
		if (aa[i] == ')')x--;
	}
	return 0;
}



int main() {
	int n, x;
	init();
	f(i, (1 << 16))a[i] = -1;
	f(i, 6) {
		a[b[i]] = 1;
		c[1].push_back(b[i]);
	}
	for (int i = 2; i < 17; i++) {
		f(j, c[i - 1].size()) {
			if (a[(c[i - 1][j] ^ b[5])] == -1) {
				a[(c[i - 1][j] ^ b[5])] = i;
				c[i].push_back(c[i - 1][j] ^ b[5]);
			}
		}
		for (int j = 1; j < i - 3; j++) {
			f(ii, c[j].size()) {
				f(jj, c[i - j - 3].size()) {
					if (a[(c[j][ii] ^ c[i-j-3][jj])] == -1) {
						a[(c[j][ii] ^ c[i - j - 3][jj])] = i;
						c[i].push_back(c[j][ii] ^ c[i - j - 3][jj]);
					}
					if (a[(c[j][ii] & c[i - j - 3][jj])] == -1) {
						a[(c[j][ii] & c[i - j - 3][jj])] = i;
						c[i].push_back(c[j][ii] & c[i - j - 3][jj]);
					}
				}
			}
		}
	}

	while (true) {
		f(i, 20)aa[i] = 0;
		scanf("%s", aa);
		if (aa[0] == '.')return 0;
		n = strlen(aa);
		x = score(0, n);
		printf("%d\n", a[x]);
	}

	return 0;
}


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

int main(){
	ll N,M,V,P;
	cin >> N >> M >> V >> P;
	vector<ll> A(N);
	for(auto &x:A) cin >> x;
	sort(A.begin(), A.end());

	ll ok = N-1, ng = -1;
	while(ok-ng>1){
		ll mid = (ok+ng)/2;
		ll rest = V*M-M;
		ll morebig = 0;
		for(int i=N-1;i>=0;i--){
			if(i==mid)continue;
			if(A[i]>A[mid] && morebig<P-1){
				morebig++;
				rest -= M;
			}else if(A[i]>A[mid]+M){
				rest = 1;
				break;
			}else if(rest){
				rest -= min(M,A[mid]+M-A[i]);
			}
		}
		if(rest<=0){
			ok = mid;
		}else{
			ng = mid;
		}
	}
	cout << N-ok << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<stack>
using namespace std;

static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int>G[MAX];
int color[MAX];

void dfs(int r, int c){
  stack<int>S;
  S.push(r);
  color[r] = c;
  while ( !S.empty() ) {
    int u = S.top();
    S.pop();
    for ( int i = 0; i < G[u].size() ; ++i) {
      int v = G[u][i];
      if ( color[v] == NIL ) {
	color[v] = c;
	S.push(v);
      }
    }
  }
}

int main(){
  int s, t, m, q;
  cin >> n >> m;
  
  for ( int i = 0; i < m ; ++i) {
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }

  int id = 1;
  
  for ( int i = 0; i < n; ++i) {
    color[i] = NIL; //preset
  }
  
  for ( int u = 0; u < n; ++u) {
    if ( color[u] == NIL ) {
      dfs(u,id);
      id++;
    }
  }
  
  scanf("%d", &q);
  for ( int i = 0; i < q; ++i) {
    scanf("%d %d", &s, &t);
    if ( color[s] == color[t] ) {
      printf("yes\n");
    } else {
      printf("no\n");
    }
  }

  return (0);
}



Measured memory_bytes: 9000
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
    s.find_by_order(k) ---> returns iterator to the element at index(from 0) k
    s.order_of_key(val) ---> number of elements that are strictly smaller than the given value
*/
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int tc; cin >> tc; cin.ignore(); while(tc--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define HASH 18014398241046527
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}
template <typename T>
ll SIZEOF(T a){return (ll)a.size();}
ll xlcm(ll a, ll b){return (a/__gcd(a, b))*b;}

ll dx[] = {1, 0, -1, 0};
ll dy[] = {0, 1, 0, -1};


const int N = 1000005;




void SOLVE(){
    ll d, t, s;
    cin >> d >> t >> s;
    if(s*t>=d){
        cout << "Yes" << '\n';
    }
    else{
        cout << "No" << '\n';
    }
}

int main() {
	fastIO();
	// #ifndef ONLINE_JUDGE
    //     freopen("i.txt", "r", stdin);
    //     freopen("o.txt", "w", stdout);
	// #endif

    ll TC = 1;
    // cin >> TC;
    for(ll tc1=1; tc1<=TC; tc1++){
        // cout << "Case #" << tc1 << ": ";
        SOLVE();
    }
    printclock;
}

Measured memory_bytes: 3860
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]

edges = [set() for _ in range(N + 1)]
for a, b in AB:
	edges[a] |= {b}
	edges[b] |= {a}

count = 0
def dfs(current, visited):
	global count
	if N == len(visited):
		count += 1
		return
	for _next in edges[current]:
		if _next not in visited:
			dfs(_next, visited | {_next})

dfs(1, {1})

print(count)


Measured memory_bytes: 3064
from itertools import permutations

N, C = [int(elem) for elem in input().split(' ')]
D_matrix = [[int(elem) for elem in input().split(' ')] for _ in range(C)]
assert len(D_matrix) == C
assert len(D_matrix[0]) == C
c_matrix = [[int(elem) for elem in input().split(' ')] for _ in range(N)]
assert len(c_matrix) == N
assert len(c_matrix[0]) == N

# grouping
# O(N^2)
mod_list = [[] for _ in range(3)]
for i in range(N):
    for j in range(N):
        mod_list[(i + j) % 3].append((i, j))

# O(N^2)
mod_color_list = [[0] * C for _ in range(3)]
for k, mod in enumerate(mod_list):
    for i, j in mod:
        mod_color_list[k][c_matrix[i][j] - 1] += 1

# O(C^3 * N^2) -> O(C^4)
min_cost = float('inf')
for colors in permutations(range(C), 3):
    total_cost = 0
    for color, mod_color in zip(colors, mod_color_list):
        total_cost += sum([D_matrix[X][color] * mod_color[X] for X in range(C)])
    min_cost = min(min_cost, total_cost)

print(min_cost)


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

int main()
{
    int a,b,c,d,e,w;
    scanf("%d %d %d",&w,&a,&b);
    if(a==b)
    d=0;
    else
    {
        if(a<b)
    {
        c=a+w;
        if(c<b)
            d=b-c;
        else
            d=0;
    }
    else if(a>b)
    {
        e=b+w;
        if(e<a)
            d=a-e;
        else
            d=0;
    }
    }
    printf("%d\n",d);
    return 0;
}


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

int main(){
	int r,c;
	cin >> r>>c;
	while(r!=0){
		if(r %2 ==1 && c%2 ==1)cout << "no" << endl;
		else cout << "yes" << endl;
		cin >> r >> c;
	}
	return 0;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s[i];
  
  // {M,A,R,C,H} -> {0,1,2,3,4}
  vll c(5);
  rep(i,n) {
    if (s[i][0] == 'M') c[0]++;
    else if (s[i][0] == 'A') c[1]++;
    else if (s[i][0] == 'R') c[2]++;
    else if (s[i][0] == 'C') c[3]++;
    else if (s[i][0] == 'H') c[4]++;
  }

  ll ans = 0;
  for (int i = 0; i < 5; ++i) {
    for (int j = i+1; j < 5; ++j) {
      for (int k = j+1; k < 5; ++k) {
        ans += c[i]*c[j]*c[k];
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6144
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ull unsigned long long

int main(){
    ull x,sum=100,count=0;
    scanf("%lld",&x);
    while (x>sum) {
        sum+=sum/100;
        count++;
    }
    printf("%lld",count);
    return 0;
}



Measured memory_bytes: 1728
import math
n = int(input())

class Coordinate:
    def __init__(self,x,y):
        self.x = x
        self.y = y

def Koch(n,p1,p2):
    if n == 0:
        return
    else:
        s = Coordinate(2/3 * p1.x + 1/3 * p2.x, 2/3 * p1.y + 1/3 * p2.y)
        u = Coordinate(1/3 * p1.x + 2/3 * p2.x, 1/3 * p1.y + 2/3 * p2.y)
        t = Coordinate(1/2*(u.x-s.x) - math.sqrt(3)/2*(u.y-s.y) + s.x, math.sqrt(3)/2*(u.x-s.x) + 1/2*(u.y-s.y) + s.y)
        Koch(n-1,p1,s)
        print(str(s.x) +" "+str(s.y))
        Koch(n-1,s,t)
        print(str(t.x) +" "+str(t.y))
        Koch(n-1,t,u)
        print(str(u.x) +" "+str(u.y))
        Koch(n-1,u,p2)

p1 = Coordinate(0,0)
p2 = Coordinate(100,0)
print(str(p1.x) +" "+str(p1.y))
Koch(n,p1,p2)
print(str(p2.x) +" "+str(p2.y))



Measured memory_bytes: 5712
//
// Created by Harshit on 21-08-2020.
//

//
// Created by Harshit on 21-08-2020.
//
#include "bits/stdc++.h"
using namespace std;
const int modd=1e9+7;
int main(){
    int H,W;
    char x;
    cin>>H>>W;
    vector <vector <bool>> grid(H,vector <bool> (W,false));
    vector <int > dp(W,0);
    vector <int> new_dp(W,0);
    //dp[0]=1;
   // vector <vector <int> > dp(H,vector<int> (W,0));
    dp[0]=1;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>x;
            if(x=='#'){
                grid[i][j]=true;
            }
        }
    }

    for(int i=0;i<H;i++){
        new_dp.assign(W,0);
        for(int j=0;j<W;j++){
            if(grid[i][j])
                dp[j]=0;
            else {
                if(j+1<W)
                    dp[j + 1] =(dp[j+1]+ dp[j])%modd;
                if(i+1<H)
                    new_dp[j] =(new_dp[j]+ dp[j])%modd;
            }
        }
        if(i!=H-1)
            dp=new_dp;
    }
    cout<<dp[W-1]<<endl;

}



Measured memory_bytes: 3808
from collections import defaultdict
n = int(input())
S = input()
ans = S.count("R") * S.count("G") * S.count("B")
for i in range(n):
    for r in range(1,n):
        if i + r < n and 0 <= i - r:
            if S[i + r] != S[i - r] and S[i] != S[i - r]and S[i] != S[i + r]:
                ans -=1

print(ans)


Measured memory_bytes: 68720
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=2019
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,P=map(int,input().split())
    A=list(map(int,list(input())[::-1]))
    ans=0
    if P==2 or P==5:
        if P==2:
            s=set([i*2 for i in range(5)])
        else:
            s=set([i*5 for i in range(2)])
        for i,x in enumerate(A[::-1],1):
            if x in s:
                ans+=i
    else:
        S=[0]*(N+1)
        for i in range(N):
            S[i+1]=(S[i]+A[i]*pow(10,i,P))%P
        l=[0]*P
        for i in range(N+1):
            ans+=l[S[i]]
            l[S[i]]+=1
    print(ans)


if __name__ == '__main__':
    main()



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

using namespace std;

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

int main() {
    int x;
    cin >> x;
    while (sosuu(x) == false) {
        x++;
    }
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0)
      break;
    vector<long long> a(n);
    for (int i = 0; i < n; i++)
      cin >> a[i];
    int ans = 0;
    long long sum = 0;
    for (int i = 0; i < n; i++)
      sum += a[i];
    for (int i = 0; i < n; i++) {
      if (a[i] * n <= sum)
        ans++;
    }
    cout << ans << endl;
  }
  return 0;
}


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

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

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

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

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    string S; cin >> S;
    int N = S.length() + 1;  
    
    VL A(N,0);
    LL pre = 0;
    REP(i,N-1){
        if(S[i] == '<'){
            pre++;
            A[i+1] = pre;
        }else{
            pre = 0;
            A[i+1] = pre;
        }
    }
    pre = 0;
    for(int i = N-2; i >= 0; i--){
        if(S[i] == '>'){
            pre++;
            chmax(A[i], pre);
        }else{
            pre = 0;
            chmax(A[i],pre);
        }
    }
    LL ans = 0;
    REP(i,N){
        ans += A[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4764
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;

int main() {
    vector<int>a(3);
    for(int i=0;i<3;i++){
        cin>>a[i];
    } 
    sort(a.begin(), a.end());
    if(a[0]+a[1]==a[2]){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3572
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N = I()

    fact = []
    for i in range(1, int(N ** 0.5) + 1):
        if N % i == 0:
            fact.append((i, N // i))

    print(sum(fact[-1]) - 2)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9468
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <string.h>
#include <vector>
#include <math.h>
#include <queue>
#include <map>

const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(void) {
	bool flag=false;
    int n, k, i, a, b, ans=100000000000, m, tmp1, tmp2, tmp3, price=0, min_a=100000000, min_b=10000000;
    string s, s_tmp1, s_tmp2, s_tmp3;
    cin >> a >> b >> m;
    int a_arr[a], b_arr[b];
    for(i=0;i<a;i++) { cin >> a_arr[i]; min_a = min(min_a, a_arr[i]); }
    for(i=0;i<b;i++)  { cin >> b_arr[i]; min_b = min(min_b, b_arr[i]); } 

    for(i=0;i<m;i++) {
    	 price=0;
         cin >> tmp1 >> tmp2 >> tmp3;
         price = a_arr[tmp1-1] + b_arr[tmp2-1] - tmp3;
         ans = min(ans, price);
    }
    ans = min(ans, min_a+min_b);
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<math.h>
#include<vector>
using namespace std;
int main() {
  int n;cin>>n;
  vector<int> stones;
  vector<int> dp;// = new int[n];
  int tmp=0;
  for(int i=0;i<n;i++){cin>>tmp;stones.push_back(tmp);}
  dp.push_back(0);
  dp.push_back(abs(stones[1]-stones[0]));
  for(int i=2;i<n;i++) {
  	dp.push_back(min(dp[i-1]+abs(stones[i]-stones[i-1]),dp[i-2]+abs(stones[i-2]-stones[i])));
  }
  if(n>=1)cout<<dp[n-1]<<endl;
  else cout<<0<<endl;
  return 0;
}


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

#define dump(x) cout << (x) << endl
#define Int int64_t
#define fi first
#define se second

Int INF = 1e9;
Int mod = 1e9+7;

bool f[100][100];

int main() {
    Int a, b;
    cin >> a >> b;
    for (Int i = 0; i < 100; i++) {
        for (Int j = 0; j < 100; j++) {
            f[i][j] = (i >= 50);
        }
    }
    cout << 100 << " " << 100 << endl;
    a--;
    b--;
    Int cnt1 = 0;
    for (Int i = 1; i < 50; i+=2) {
        for (Int j = 1; j < 100; j+=2) {
            if (cnt1 == a) {
                i = 100;
                j = 100;
                break;
            }
            f[i][j] = true;
            cnt1++;
        }
    }
    Int cnt2 = 0;
    for (Int i = 51; i < 100; i+=2) {
        for (Int j = 1; j < 100; j+=2) {
            if (cnt2 == b) {
                i = 100;
                j = 100;
                break;
            }
            f[i][j] = false;
            cnt2++;
        }
    }
    for (Int i = 0; i < 100; i++) {
        for (Int j = 0; j < 100; j++) {
            cout << (f[i][j] ? '.' : '#');
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
while True:
    m,f,r= map(int,input().split())
    if m+f+r==-3:break
    if m==-1 or f==-1:s="F"
    elif m+f>=80:s="A"
    elif m+f>=65:s="B"
    elif m+f>=50:s="C"
    elif m+f>=30 and r>=50:s="C"
    elif m+f>=30:s="D"
    else:s="F"
    print(str(s))


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

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    }

    vector<int> vecb(3);
  int answer=0;

    for (int i = 0; i < N-2; i++) {
      vecb.at(0)=vec.at(i);
      vecb.at(1)=vec.at(i+1);
      vecb.at(2)=vec.at(i+2);
      
      sort(vecb.begin(),vecb.end());
      
      if(vecb.at(1)==vec.at(i+1)){
        answer++;
      }
    }
    
 cout<<answer<<endl;
 }


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

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


Measured memory_bytes: 256
if __name__ == '__main__':
    array = list(map(int, input().split()))
    N = array[0]
    K = array[1]

    if N == 0:
        print(0)
    elif N < K:
        print(1)
    elif N % K > 1:
        print(1)
    else:
        print(N % K)

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
ll INF = 1LL<<40;

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

    ll ans = 0;
    string S;
    cin >> S;
    for(int i = 0; i < (1 << S.size()-1); i++){
        int last = 0;
        int cnt = 0;
        //cout << "[" << i << "]" << endl;
        for(int j = 0; j < S.size(); j++){
            if(i & (1<<j)){
                //cout << "*" << j << "*";
                ans += stoi(S.substr(last, j - last + 1));
                //cout << S.substr(last, j - last + 1) << " ";
                last = j+1;
            }
        }
        //cout << S.substr(last, S.size() - last) << " ";
        ans += stol(S.substr(last, S.size() - last));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

//	final int MOD = 1000000007;

	public static int min = 3000000;

	public static void main(String[] args) {

		int ans = 0;
		Scanner sc = new Scanner(System.in);
		boolean f = false;

		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();

		int[] c = new int[n];

		int[][] a = new int[n][m];
		for (int i = 0; i < n; i++) {
			c[i] = sc.nextInt();
			for(int j = 0; j < m; j++) {
				a[i][j] = sc.nextInt();
			}
		}

//		String string = sc.next();
//		String[] s = string.split("");

//		int[] ans = new int[n];

//		ArrayList<Integer> list = new ArrayList<>();


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


		for(int i = 0; i < (1<<n); i++) {
			int[] xnum = new int[m];
			int maney = 0;
			f = true;
			for(int j = 0; j < n; j++) {
				if((1 & i>>j) == 1) {
					maney += c[j];
					for(int k = 0; k < m; k++) {
						xnum[k] += a[j][k];
					}
				}
			}
			for(int k = 0; k < m; k++) {
				if(xnum[k] < x) {
					f = false;
					break;
				}
			}
			if(f) {
				if(maney < min) {
					min = maney;
				}
			}
		}

		ans = min;
		if(min == 3000000) {
			ans = -1;
		}


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

//		for(int i = 0; i < n; i++) {
//			System.out.println(ans[i]);
//		}

//		if(f) {
//			System.out.println("Yes");
//		} else {
//			System.out.println("No");
//		}

		System.out.println(ans);

		sc.close();
	}

}

Measured memory_bytes: 37184