akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
const int inf = 1e9;
const int mod = 1e9+7;

typedef pair<pii,int> tri;
set<tri> s;

int N, R, C;
bool b[100000];
map<int, int> m;
stack<int> st;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> R >> C >> N;
  FOR(i, 0, N){
    int x, y, z, w;
    cin >> x >> y >> z >> w;
    if((x == 0 || x == R || y == 0 || y == C)&&(z == 0 || z == R || w == 0 || w == C)){
      if(x == 0){
        m[y] = i;
      }else if(x == R){
        m[2*C + R + 10 - y] = i;
      }else if(y == 0){
        m[2*C + 2*R + 15 - x] = i;
      }else{
        m[C + 5 + x] = i;
      };
      x = z;
      y = w;
      if(x == 0){
        m[y] = i;
      }else if(x == R){
        m[2*C + R + 10 - y] = i;
      }else if(y == 0){
        m[2*C + 2*R + 15 - x] = i;
      }else{
        m[C + 5 + x] = i;
      };
    }
  }
  for(map<int, int>::iterator itr = m.begin(); itr != m.end(); itr++){
    if(st.empty() || st.top() != itr->second){
      st.push(itr->second);
    }else{
      st.pop();
    }
  }
  cout << (st.empty() ? "YES" : "NO") << "\n";
}

Measured memory_bytes: 9984
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
using Ps=pair<string,string>;
    string s;
  map<Ps,ll> mp;
    int n;
    ll ans=0;
  void make(int now,string &a,string &b){
    if(now==n){
      reverse(all(b));
      mp[Ps(a,b)]++;
      reverse(all(b));
      return;
    }
    a.push_back(s[now]);
    make(now+1,a,b);
    a.pop_back();
    b.push_back(s[now]);
    make(now+1,a,b);
    b.pop_back();
  }
   void solve(int now,string &a,string &b){
    if(now==2*n){
      reverse(all(a));
      if(mp.count(Ps(a,b)))ans+=mp[Ps(a,b)];
      reverse(all(a));
      return;
    }
    a.push_back(s[now]);
    solve(now+1,a,b);
    a.pop_back();
    b.push_back(s[now]);
    solve(now+1,a,b);
    b.pop_back();
  }
int main(){
  cin>>n;
  cin>>s;
  string a={},b={};
  make(0,a,b);
  a={};b={};
  solve(n,a,b);
  cout<<ans<<"\n";
} 


Measured memory_bytes: 42368
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
  double A,B,H,M,as,al,a,ans;
  cin>>A>>B>>H>>M;
  
  al=6*M;
  as=30*(H+M/60);
  
  a=(al-as)*3.14159265358/180;
  
  ans=sqrt(A*A+B*B-2*A*B*cos(a));
  
  cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 4228
from collections import deque

N=int(input())
G=[[] for _ in range(N+1)]

for i in range(N-1):
  a,b=map(int,input().split())
  G[a].append(b)
  G[b].append(a)
  
def bfs(s):
    seen = [0 for i in range(N+1)]
    d = [0 for i in range(N+1)]
    todo = deque()
    seen[s]=1
    todo.append(s)
    while 1:
      if len(todo)==0:break
      a = todo.popleft()
      for b in G[a]:
        if seen[b] == 0:
          seen[b] = 1
          todo.append(b)
          d[b] += d[a] + 1
    return d
  
d_f = bfs(1)
d_s = bfs(N)

count_f,count_s=0,0
for i in range(1,N+1):
  if d_f[i] <= d_s[i]:count_f +=1
  else: count_s += 1
    
if count_f>count_s:print('Fennec')
else:print('Snuke')

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

const int MAXN = 105;

struct point {
	int x, y, id;
	friend point operator + (const point &a, const point &b)
	{ return (point) {a.x+b.x, a.y+b.y}; }
	friend point operator - (const point &a, const point &b)
	{ return (point) {a.x-b.x, a.y-b.y}; }
	friend long long operator * (const point &a, const point &b)
	{ return 1ll*a.x*b.y-1ll*a.y*b.x; }
	friend bool operator < (const point &a, const point &b)
	{ return a.x != b.x ? a.x < b.x : a.y < b.y; }
	friend bool operator == (const point &a, const point &b)
	{ return a.x == b.x && a.y == b.y; }
	inline long long len()
	{ return 1ll*x*x+1ll*y*y; }
	inline long long dot(point &a)
	{ return 1ll*x*a.x + 1ll*y*a.y; }
} left_most, pt[MAXN];
point stk[MAXN];
int stk_top = 0, n;
int vis[MAXN];

void get_hull()
{
	stk[++stk_top] = left_most;
	vis[left_most.id] = 1;
	while (1) {
		point cur = stk[stk_top], nxt;
		int flag = -1;
		for (int i = 1; i <= n; i++) {
			if (pt[i] == cur) continue;
			if (flag == -1) nxt = pt[i], flag = 0;
			else {
				long long x = (pt[i]-cur)*(nxt-cur);
				// cerr << pt[i].x << " " << pt[i].y << " " << nxt.x << " " << nxt.y << " " << x << endl;
				if (x > 0) nxt = pt[i];
				if (x == 0 && !vis[pt[i].id] && (pt[i]-cur).len() <= (nxt-cur).len()) nxt = pt[i];
			}
		}
		// cerr << nxt.x << " " << nxt.y << endl;
		if (vis[nxt.id]) break;
		stk[++stk_top] = nxt;
		vis[nxt.id] = 1;
	}
	stk[0] = stk[stk_top], stk[stk_top+1] = stk[1];
}

long double ans[MAXN];

const long double PI = acos(-1);

int main()
{
	cin >> n;
	left_most = (point) {100000000, 100000000, 0};
	for (int i = 1; i <= n; i++) {
		cin >> pt[i].x >> pt[i].y;
		pt[i].id = i;
		left_most = min(left_most, pt[i]);
	}
	get_hull();
	for (int i = 1; i <= stk_top; i++) {
		point x = stk[i-1]-stk[i], y = stk[i+1]-stk[i];
		long double ang_cos = x.dot(y)/sqrt(x.len())/sqrt(y.len());
		long double ang = acos(ang_cos);
		ans[stk[i].id] = (PI-ang)/PI/2;
	}
	for (int i = 1; i <= n; i++)
		printf("%.10Lf\n", ans[i]);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int x,p,n,ans=0;
  cin>>x>>n;
  map<int,int> m;
  rep(i,0,n){
    cin>>p;
    m[p]=1;
  }
  if(n==0 || m.find(x)==m.end()){
    cout<<x<<endl;
    return;
  }
  rep(i,1,105){
    if(m.find(x-i)==m.end()) {cout<<x-i<<endl; return;}
    else if(m.find(x+i)==m.end()) {cout<<x+i<<endl; return;}
  }
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3528
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const ll MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}


int main(){
  int n;
  cin >> n;
  map<int,int>A;
  bool flag = true;
  ll ans = 1;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    A[a]++;
  }
  if(n%2==0){
    for(int i=1;i<n;i+=2){
      if(A[i]!=2){
        flag = false;
        break;
      }
      ans *= 2,ans %=MOD;
    }
  }
  else{
    if(A[0]!=1) flag = false;
    for(int i=2;i<n;i+=2){
      if(A[i]!=2){
        flag = false;
        break;
      }
      ans *= 2,ans %=MOD;
    }
  }
  if(flag) cout<< ans <<endl;
  else cout<< 0 <<endl;

}


Measured memory_bytes: 3200
NUM = 1000000007

N = int(input())

all_colab = pow(10, N)
except_0or9_colab = pow(9, N)
except_0and9_colab = pow(8, N)

include_0and9_colab = all_colab - (2*except_0or9_colab - except_0and9_colab)

print(include_0and9_colab % NUM)

Measured memory_bytes: 11188
#include<bits//stdc++.h>
using namespace std;
int main(){
	int a[51];
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++) a[i]=0;
	for(int i=0;i<m;i++){
		int b,c;
		cin>>b>>c;
		a[b]++;
		a[c]++;
	}
	for(int i=1;i<=n;i++)
		cout<<a[i]<<endl;
}


Measured memory_bytes: 256
K, S = map(int, input().split())

c = 0
for x in range(S//3 + 1):
    for y in range(x, (S-x)//2 + 1):
        z = S - (x + y)
        if z <= K:
            l = len(set((x,y,z)))
            if l == 1: c += 1
            elif l == 2: c += 3
            else: c += 6
print(c)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <map>
#include <cmath>

using namespace std;

int main() {
    int n;
    scanf("%d", &n);

    int keta;
    keta = log10(n)+1;

    int fn=0;
    int a=1,b=10;

    for (int i=0; i<keta; i++) {
        int tmp = n % b;
        tmp = tmp /a;
        fn += tmp;
        a *= 10;
        b *= 10;
    }

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

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
const int MAXN = 0;

int c[3];
int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        c[s[i]- 'a']++;
    }

    sort(c, c + 3);

    if (c[2] - c[0] <= 1)
        cout << "YES";
    else
        cout << "NO";
	return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a,b;
    cin>>a>>b;
    int n= a.length();
    int m= b.length();
    vector<vector<int>>v(n+1,vector<int>(m+1,0));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(a[i-1]==b[j-1]){
                v[i][j]=1+v[i-1][j-1];
            }else{
                v[i][j]=max(v[i][j-1],v[i-1][j]);
            }
        }
    }
    string s="";

    int i=n,j=m;
    while(i>0 && j>0){
            if(v[i-1][j-1]+1 == v[i][j] && v[i-1][j]+1 == v[i][j] && v[i][j-1]+1 ==v[i][j]){
                i--;
                j--;
                s=a[i]+s;
            }
            else if(v[i][j-1]>v[i-1][j]){j--;}
            else{i--;}
    }
    cout<<s;
    return 0;
}

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

int main() {
  int N;
  cin>> N;
  string S;
  cin >> S;
  int Rcount = 0;
  int Bcount = 0;
  for(int i = 0;i < N;i++) {
    if(S.at(i) == 'R') {
      Rcount++;
    }
    else {
      Bcount++;
    }
  }
  if(Rcount > Bcount) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long Int;

Int n, a[400000], m, b[400000], c[400000];
Int s[400000];

int main() {
    cin >> n;
    rep (i, n) cin >> a[i];
    sort(a, a+n);
    a[n] = 1<<30;
    rep (i, n) s[i+1] = s[i] + a[i];
    int m;
    cin >> m;
    rep (i, m) cin >> b[i];
    rep (i, m) cin >> c[i];
    rep (i, m) {
        int k = upper_bound(a, a+n, b[i]) - a;
        puts(c[i] <= s[k] ? "Yes" : "No");
    }
    return 0;
}

Measured memory_bytes: 13424
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const int INF = 1e9;
inline int read(){
	int X = 0,w = 0 ;
	char ch = 0;
	while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
	while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
	return w ? -X : X;
}
int main()
{
    int n;
    cin>>n;
    vector<int> a(n), b(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>b[i];
    }
    vector<int> c,d;
    int ans=0;
    int pow_2=1;
    for(int i=0;i<=28;i++)
    {
        c=a;
        d=b;
        for(int j=0;j<n;j++)
        {
            c[j]%=2*pow_2;
            d[j]%=2*pow_2;
        }
        sort(c.begin(),c.end());
        sort(d.begin(),d.end());
        int l,r;
        int sum=0;
        for(int j=0;j<n;j++)
        {
            l=lower_bound(d.begin(),d.end(),pow_2-c[j])-d.begin();
            r=lower_bound(d.begin(),d.end(),2*pow_2-c[j])-d.begin()-1;
            sum+=(r-l+1);
            l=lower_bound(d.begin(),d.end(),3*pow_2-c[j])-d.begin();
            r=lower_bound(d.begin(),d.end(),4*pow_2-c[j])-d.begin()-1;
            sum+=(r-l+1);
        }
        if(sum&1)
        {
            ans+=pow_2;
        }
        pow_2*=2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3328
import           Control.Monad
import           Text.Printf
import           Data.List

getLines :: Int -> IO [String]
getLines n = replicateM n getLine

getLinesInt :: Int -> IO [Int]
getLinesInt n = fmap read <$> getLines n

getInts :: IO [Int]
getInts = map (read :: String -> Int) . words <$> getLine

getDoubles :: IO [Double]
getDoubles = map (read :: String -> Double) . words <$> getLine

splitOn :: (Char -> Bool) -> String -> [String]
splitOn p s = case dropWhile p s of
    "" -> []
    s' -> w : splitOn p s'' where (w, s'') = break p s'

toInt :: [String] -> [Int]
toInt = map ((read :: String -> Int) . dropZero)

dropZero :: String -> String
dropZero s = if head s == '0' then drop 1 s else s

main :: IO ()
main = do
    [k, x] <- getInts
    putStr $ unwords $ map show $ take (k * 2 - 1) $ iterate (+ 1) (x - k + 1)

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


string S, T;
int dp[3010][3010];
pii nxt[3010][3010];

void update(int &res, int val, int i1, int j1, int i2, int j2){
    if(res <= val){
        res = val;
        nxt[i1][j1] = pii(i2, j2);
    }
}

int main(){

    cin >> S;
    cin >> T;
    
    for(int i = (int)S.size(); i >= 0; i--){
        for(int j = (int)T.size(); j >= 0; j--){
            int res = 0;
            if(i != (int)S.size() && j != (int)T.size()){
                if(S[i] == T[j]){
                    update(res, dp[i+1][j+1] + 1, i, j, i+1, j+1);
                }
                update(res, dp[i][j+1], i, j, i, j+1);
                update(res, dp[i+1][j], i, j, i+1, j);
            }
            dp[i][j] = res;
        }
    }

    // cout << dp[0][0] << endl;

    if(dp[0][0] == 0){
        cout << "" << endl;
    }
    else{
        string s;
        pii p = pii(0, 0);
        while(p.first != (int)S.size() && p.second != (int)T.size()){
            pii p2 = nxt[p.first][p.second];
            if(p.first + 1 == p2.first && p.second + 1 == p2.second){
                s += S[p.first];
            }
            p = p2;
        }
        cout << s << endl;
        
    }

    


    return 0;
}


Measured memory_bytes: 106368
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	if (n % 2 == 1) {
		cout << 0 << endl; return 0;
	}
	int ans = 0;
	int now = 1;
	int now2 = 1;
	rep(i, 25) {
		now *= 10;
		now2 *= 5;
		ans +=(n / (2 * now2));
		
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> x(n),y(n),h(n);
    rep(i,n){
      cin>>x[i]>>y[i]>>h[i];
    }
    ll hei;
    rep(i,101){//cx
      rep(j,101){//cy
        ll cnt=0;
        while(true){
          if(h[cnt]==0){
            cnt++;
          }else{
            hei=h[cnt]+abs(x[cnt]-i)+abs(y[cnt]-j);
            break;
          }
          if(cnt==n-1){
            cnt++;
            break;
          }
        }
        vector<ll> check;
        rep(l,n){
          ll c=h[l]+abs(x[l]-i)+abs(y[l]-j);
          if(h[l]==0){
            check.push_back(l);
          }
          if(h[l]>0 && c!=hei){
            break;
          }
          if(l==n-1){
            if(check.empty()){
              cout<<i<<' '<<j<<' '<<hei<<endl;
              return 0;
            }
            for(auto itr:check){
              if(hei-abs(x[itr]-i)-abs(y[itr]-j)>0){
                break;
              }
              if(itr==check.back()){
                cout<<i<<' '<<j<<' '<<hei<<endl;
                return 0;
              }
            }
          }
        }
      }
    }
    //cout<<cx<<' '<<cy<<' '<<hei<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

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

int main() {
	
	string a, b;
	cin >> a >> b;
	
	if(a[0] == 'H' && b[0] == 'H') cout << "H" << endl;
	else if(a[0] == 'D' && b[0] == 'D') cout << "H" << endl;
	else cout << "D" << endl;
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
ans = 10**10
# wCnt = s.count('W')
# eCnt = len(s) - wCnt
rightW = s.count('W')
rightE = len(s) - rightW
leftW = 0
leftE = 0


for i in range(len(s)):
    # right = s[i+1:]
    # left = s[:i]

    if s[i] == 'W':
        rightW -= 1
    else:
        rightE -= 1

    if i > 0:
        if s[i-1] == 'W':
            leftW += 1
        else:
            leftE += 1
    temp = rightE + leftW
    ans = min(ans, temp)

print(ans)

Measured memory_bytes: 42712
using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine();
            var l = a.Split(' ');
            var b = int.Parse(l[0]);
            var c = int.Parse(l[1]);
            if (b<10)
            {

                var d = (c + 100 * (10 - b));
                Console.WriteLine(d);
                
            }
            else
            {
                Console.WriteLine(c);
            }
        }
    }
}


Measured memory_bytes: 11092
n = int(input())
p = list(map(int,input().split()))
min1= 10**6
count = 0
for i in range(1,n):
	if min1 > p[i-1]:
		min1 = p[i-1]
	if min1 >= p[i]:
		#print("max=",min1,"p[i]=",p[i])
		count+=1

print(count+1)

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

#define int long long
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; }

signed main(){
	int h, w;
	cin >> h >> w;
	string top(w+2, '#');
	cout << top << endl;

	for(int i = 0;i < h;i++){
		string s;
		cin >> s;
		cout << '#' << s << '#' << endl; 
	}

	cout << top << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	static int w,h,ax,ay,bx,by;
	static int[][] field,already;
	static int[] v1={1,0,-1,0};
	static int[] v2={0,-1,0,1};
	static int[] vv1={0,0,1,0,0,0,0,0,-1};
	static int[] vv2={0,0,0,0,-1,0,1,0,0};
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		while(true){
			h=cin.nextInt();
			w=cin.nextInt();
			field=new int[h][w];
			already=new int[h][w];
			if(h+w==0)break;
			Queue<int[]> q=new LinkedList<int[]>();
			for(int i=0;i<h;i++){
				String s=cin.next();
				for(int j=0;j<w;j++){
					if(s.charAt(j)=='.'){
						field[i][j]=-1;
					}
					else if(s.charAt(j)=='#'){
						field[i][j]=1000;
					}
					else if(s.charAt(j)=='A'){
						ax=i;
						ay=j;
						field[i][j]=-1;
						q.add(new int[]{ax,ay});
					}
					else if(s.charAt(j)=='B'){
						field[i][j]=-1;
						bx=i;
						by=j;
					}
				}
			}
			String pat=cin.next();
			int cnt=-1;
			while(!q.isEmpty()){
				int size=q.size();
				cnt++;
				for(int sss=0;sss<size;sss++){
					int[] a=q.poll();
					int x=a[0];
					int y=a[1];
					field[x][y]=cnt;
					for(int i=0;i<4;i++){
						int xx=x+v1[i];
						int yy=y+v2[i];
						if(xx<0||xx>=h||yy<0||yy>=w||field[xx][yy]!=-1)continue;
						field[xx][yy]=cnt+1;
						q.add(new int[]{xx,yy});
					}
					
				}
			}cnt=0;
//			output();
			int nowx=bx,nowy=by,ans=10000,ansx=-1,ansy=-1;
			while(true){
				int p=pat.charAt(cnt%pat.length())-'0';
				nowx+=vv1[p];
				nowy+=vv2[p];
				if(nowx<0)nowx=0;
				if(nowy<0)nowy=0;
				if(nowx>=h)nowx=h-1;
				if(nowy>=w)nowy=w-1;
				cnt++;
				if(field[nowx][nowy]!=-1&&field[nowx][nowy]<=cnt){
//					ans=Math.min(ans, cnt);
					if(ans>cnt){
						ans=cnt;
						ansx=nowx;
						ansy=nowy;
					}
				}
				int x=cnt%pat.length();
				if((already[nowx][nowy]>>x)%2==1){
					if(cnt>=h*w)
					break;
				}
				already[nowx][nowy]=already[nowx][nowy]|(1<<x);
			}
			if(ans==10000){
				System.out.println("impossible");
			}
			else{
				System.out.println(ans+" "+ansx+" "+ansy);
			}
		}
	}
	static void output(){
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				System.out.print(field[i][j]+" ");
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 25172
#include <iostream>
#include <vector>

using namespace std;

int main()
{ 
	int N;
	cin >> N;
	vector<int>tortitas(N);
	
	for(int i=0;i<N;i++)
	{
		int c;
		cin >>c;
		tortitas[i]=c;			
	}
	
	for(int i=1;i<N;i++)
	{
		int j=i;
		while(j!=0 && tortitas[j-1]<tortitas[j])
		{
			swap(tortitas[j],tortitas[j-1]);
			j--;
		}
	}
	
	int longmax=1;
	
	for(int i=0;i<N-1;i++) 
	{
		if(tortitas[i]!=tortitas[i+1])
		{
			longmax++;
			
		}
	}
	cout << longmax << endl;
	
}


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

int main(){
    ll N,K,Q;
    cin >> N >> K >> Q;

    vector<ll> pnt(N,K-Q);

    for(int i=0;i<Q;i++){
        ll A;
        cin >> A;
        pnt[--A]++;
    }

    for(int i=0;i<N;i++){
        if(pnt[i]>0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }

}

Measured memory_bytes: 1408
#include <stdio.h>
int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	if (a < b)
	    printf("a < b\n");
	else if (a == b)
		printf("a == b\n");
    else
		printf("a > b\n");
	return 0;
}


Measured memory_bytes: 2088
import sys
input = sys.stdin.buffer.readline
import numpy as np

def main():
    N = int(input())
    a = list(map(int,input().split()))
    a.sort()
    a = np.array(a)
    MOD = 10**9+7
    
    base = np.array([N-i+1 for i in range(N)])
    
    l = (np.sum((a*base)%MOD))%MOD
    f = pow(4,N-1,MOD)
    print(f*l%MOD)

if __name__ == "__main__":
    main()


Measured memory_bytes: 30976
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};

void solve(ll N, vector<ll> a) {
  ll sum = accumulate(ALL(a), 0LL);
  ll x = 0, res = 1e18;
  REP(i,N-1) {
    x += a[i];
    const ll y = sum - x;
    chmin(res, abs(x - y));
  }
  cout << res << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	scanf("%lld", &N);
	vector<ll> a(N-1+1);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &a[i]);
	}
	solve(N, a);
	return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,mod=1e9+7;
int n,a[N];
ll f[N],sum[N];
ll inv(ll x){return x<=1?x:(mod-mod/x)*inv(mod%x)%mod;}
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
int main()
{
    f[0]=1;
    for(int i=1;i<N;i++) f[i]=f[i-1]*i%mod;
    scanf("%d",&n);
    for(int i=1;i<N;i++) sum[i]=(sum[i-1]+f[n-1]*inv((ll)i*(i+1)%mod)%mod)%mod;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    ll ans=0;
    /*//400分
    for(int i=1;i<n;i++)
        for(int j=i+1;j<=n;j++)
        if(j==n)
        ans=(ans+(a[j]-a[i])*f[n-1]%mod*inv(j-i)%mod)%mod;
        else ans=(ans+(a[j]-a[i])*f[n-1]%mod*inv((ll)(j-i)*(j-i+1)%mod)%mod)%mod;
    */
    for(int i=1;i<n;i++)
    {
        ans=(ans-a[i]*(sum[n-1-i])%mod)%mod;
        ans=(ans-a[i]*f[n-1]%mod*inv(n-i)%mod)%mod;
    }
    ans=(ans+mod)%mod;
    for(int i=2;i<n;i++)
        ans=(ans+a[i]*sum[i-1]%mod)%mod;;
    for(int i=1;i<n;i++)
        ans=(ans+a[n]*f[n-1]%mod*inv(n-i)%mod)%mod;
    printf("%lld\n",ans);
}



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

const int MOD = 1000000007;

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

    vector<ll> a(n);
    rep (i, n)
        cin >> a[i];

    sort(a.begin(), a.end());

    vector<ll> sum(n + 1, 0);
    rep (i, n)
        sum[i + 1] = sum[i] + a[i];

    ll ans = 0;
    for (int i = 0; i < n - 1; i++)
        ans = (ans + (a[i] * ((sum[n] - sum[i + 1]) % MOD) % MOD)) % MOD;

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


Measured memory_bytes: 6416
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';
int mod = 1e9 + 7;
ll inf = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << 180 * n - 360 << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define MAX 50010;	//マクロは条件式内では使えない？
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct process {
	char name[10];
	int time;
};


int max = MAX
struct process Q[50010];
int head, tail;

void initialize() {
	head = tail = 0;
}

int isEmpty() {
	return head == tail;
}
int isFull() {
	return head == (tail + 1) % MAX;	//MAX = 7のときhead =4、tail=3となる。head = tailではないのは、配列の要素を全て使うわけではないことが原因。
}										//（入る容量は要素-1。つまりMAX）

void enqueue(struct process x) {
	if (isFull()) {
		printf("これ以上入りません\n");
		return;
	}
	
	Q[tail] = x;
	if (tail + 1 == max) {
		tail = 0;
	}
	else {
		tail++;
	}
}

struct process dequeue() {
	struct process x;
	if (isEmpty()) {
		printf("これ以上取り除けません\n");

	}
	x = Q[head];
	if (head + 1 == max) {
		head = 0;
	}
	else {
		head++;
	}
	return x;
}


int main() {
	int i, n, q, total = 0;
	char nameAndTime[20], nq[15], *cn;
	struct process p[50000];

	initialize();

	fgets(nq, sizeof(nq), stdin);
	cn = strtok(nq, " ");
	n = atoi(cn);
	cn = strtok(NULL, " ");
	q = atoi(cn);

	for (i = 0; i < n; i++) {
		fgets(nameAndTime, sizeof(nameAndTime), stdin);
		cn = strtok(nameAndTime, " ");
		strcpy(p[i].name, cn);
		cn = strtok(NULL, " ");
		p[i].time = atoi(cn);
		total += p[i].time;
		if (total > 1000000) {
			return 0;
		}
		enqueue(p[i]);
	}

	struct process x;
	int	cnt = 0, k = 0, sec = 0;

	while (cnt < n) {
		x = dequeue();
		if (x.time <= 0) {
			enqueue(x);
		}
		else {
			if (x.time - q <= 0) {
				sec += x.time;
				printf("%s %d\n", x.name, sec);
				x.time -= q;
				cnt++;
			}
			else {
				x.time -= q;
				sec += q;
				enqueue(x);
			}
			
		}
	}

}


Measured memory_bytes: 3208
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>

#define INF_LL 9000000000000000000
#define INF 2000000000

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

using namespace std;

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

class SegTree{
	int n;
	vector<ll> seg;
public:
	SegTree(int n_){
		n = 1;
		while(n < n_) n = n << 1;
		REP(i, 2*n-1){
			seg.push_back(((ll)1<<31)-1);
		}
	}

	void update(int i, int x){
		i = i + n - 1;
		seg[i] = x;
		while(i > 0){
			i = (i-1)/2;
			seg[i] = min(seg[i*2+1], seg[i*2+2]);
		}
	}

	ll a(int s, int t){
		return find(s, t, 0, 0, n);
	}

	ll find(int s, int t, int x, int l, int r){
		ll res = ((ll)1<<31)-1;

		if(r <= s || t <= l) return res;
		if(s <= l && r <= t) return seg[x];

		res = min(res, find(s, t, x*2+1, l, (l+r)/2));
		res = min(res, find(s, t, x*2+2, (l+r)/2, r));
		return res;
	}
};

int main(void){
	int n, q;
	cin >> n >> q;
	SegTree sg(n);
	REP(i, q){
		int com, x, y;
		cin >> com >> x >> y;
		if(com == 0){
			sg.update(x, y);
		}else{
			cout << sg.a(x, y+1) << endl;
		}
	}
}

Measured memory_bytes: 4896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%lld",&x);
int main(){
    ll n, m;
    sc(n) sc(m)
    if (n == 1 && m == 1) cout << 1 << endl;
    else if (n == 1 || m == 1) cout << n*m-2 << endl;
    else cout << n*m - 2*n - 2*m + 4 << endl;
    return 0;
}

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

const int MOD=998244353;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll ppow(ll a,ll b){
	a%=MOD;
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}
class Fact{
	vector<ll>fact;
	vector<ll>inv;
public:
	Fact(){}
	Fact(int n){
		n=n*2+10;
		fact=inv=vector<ll>(n);
		fact[0]=inv[0]=1;
		for(int i=1;i<n;i++){
			fact[i]=(fact[i-1]*i)%MOD;
		}
		inv[n-1]=ppow(fact[n-1],MOD-2);
		for(int i=n-2;i>=0;i--){
			inv[i]=(inv[i+1]*(i+1))%MOD;
		}
	}
	ll get(int n){
		return fact[n];
	}
	ll get_inv(int n){
		return inv[n];
	}
	ll nPr(int n,int r){
		return fact[n]*inv[n-r]%MOD;
	}
	ll nCr(int n,int r){
		return nPr(n,r)*inv[r]%MOD;
	}
	ll nrP(int n,int r){
		return nPr(n+r,n);
	}
	ll nrC(int n,int r){
		return nCr(n+r,n);
	}
};
int main(){
	int n,m,K;cin>>n>>m>>K;
	Fact fac(n);
	ll ans=0;
	for(int i=n-K;i<=n;i++){
		ll d=fac.nCr(n-1,i-1);
		(d*=m*ppow(m-1,i-1)%MOD)%=MOD;
		(ans+=d)%=MOD;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 9544
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        int H,W;
        cin>>H>>W;
        if(H==0){
            return 0;
        }
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(i==0 || i==H-1){
                    cout<<"#";
                }else if(j==0 || j==W-1){
                    cout<<"#";
                }else{
                    cout<<".";
                }
            }
            cout<<endl;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3084
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define MAXN 210
#define MAXM 10000010
using namespace std;

struct edge{
	int to,next,w;
	edge(int _to=0,int _next=0,int _w=0):to(_to),next(_next),w(_w){}
}e[MAXM];

int n,m,S,T;
int g[MAXN],nume;
bool flag[MAXM];
int prime[MAXM],nump;
int p0[MAXN],p[MAXN],tag[MAXN];
int level[MAXN];

void addEdge(int u,int v,int w){
	e[nume]=edge(v,g[u],w);
	g[u]=nume++;
	e[nume]=edge(u,g[v],0);
	g[v]=nume++;
}

void init(){
	flag[1]=1;
	for(int i=2;i<MAXM;i++){
		if(!flag[i]) prime[++nump]=i;
		for(int j=1;j<=nump && i*prime[j]<MAXM;j++){
			flag[i*prime[j]]=1;
			if(i%prime[j]==0) break;
		}
	}
	flag[2]=1;
}

bool bfs(){
	memset(level,-1,sizeof level);
	static queue<int> Q;
	Q.push(S);
	level[S]=0;
	while(!Q.empty()){
		int x=Q.front();
		Q.pop();
		for(int i=g[x];~i;i=e[i].next)
			if(e[i].w && level[e[i].to]==-1){
				level[e[i].to]=level[x]+1;
				Q.push(e[i].to);
			}
	}
	return level[T]!=-1;
}

int dfs(int x,int delta){
	if(x==T) return delta;
	if(!delta) return 0;
	int res=0;
	for(int i=g[x];~i;i=e[i].next)
		if(e[i].w && level[e[i].to]==level[x]+1){
			int temp=dfs(e[i].to,min(delta,e[i].w));
			delta-=temp;
			res+=temp;
			e[i].w-=temp;
			e[i^1].w+=temp;
			if(!delta) return res;
		}
	return res;
}

int main(){
#ifdef DEBUG
	freopen("F.in","r",stdin);
#endif
	memset(g,-1,sizeof g);
	init();
	scanf("%d",&m);
	for(int i=1;i<=m;i++) scanf("%d",p0+i);
	p[++n]=p0[1]-1;
	for(int i=1;i<m;i++)
		if(p0[i]+1<p0[i+1]){
			p[++n]=p0[i];
			p[++n]=p0[i+1]-1;
		}
	p[++n]=p0[m];
	int c0=0,c1=0;
	for(int i=1;i<=n;i++)
		if(p[i]&1) tag[i]=1,c1++;
		else c0++;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(!tag[i] && tag[j] && !flag[abs(p[i]-p[j])])
				addEdge(i,j,1);
	S=n+1; T=n+2;
	for(int i=1;i<=n;i++)
		if(tag[i]) addEdge(i,T,1);
		else addEdge(S,i,1);
	int flow=0;
	while(bfs()) flow+=dfs(S,0x77777777);
	int ans=flow+((c0-flow)/2+(c1-flow)/2)*2+((c0-flow)%2)*3;
	printf("%d\n",ans);
}

Measured memory_bytes: 131456
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
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 main(){
    string S="MARCH";
    vector <ll> c(5,0);
    int N; cin >> N;
    rep(i,N){
        string T; cin >> T;
        rep(j,5){
            if (T[0]==S[j]) c[j]++;
        }
    }
    
    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;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
numbers_list = input().split(' ')
homework_sum = 0
for i in range(0, M):
  homework_sum = homework_sum + int(numbers_list[i])
play_day = N - homework_sum
if play_day >= 0:
  print(play_day)
else:
  print(-1)

Measured memory_bytes: 9592
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
 
#define NUM 100
 
static int *s;
static int N;
 
void STACK(int maxN);
void push(int x);
int pop(void);
 
int main(void){
    char x;
    int a,b;
    int e = 0;
    int i = 0, p = 0;
     
    STACK(NUM);
     
    while((x = getchar()) != EOF){        //???????????\???????????????
        if(isdigit(x)){        //??°?????????,???????????§??°????????????,?¬????????????§push
            i = i * 10 + (x - '0');             
            p = 1;
        }
        else{
        switch(x){        //??°?????§????????¨???switch?????§??´???????????????
        case '+':
            a = pop();    //????????????????????°?????????????????????,??????????????????????????????????????\
            b = pop();
            push(a + b);
            break;
             
        case '-':
            b = pop();
            a = pop();
            push(a - b);
            break;
             
        case '*':
            a = pop();
            b = pop();
            push(a * b);
            break;
             
        case '\n':        //Enter??§??????
            e = -1;
            break;
             
         
        case ' ':
            if(p != 0) {        //p??§??´????????°?????????????????????
                push(i);
                i = 0;
                p = 0;
            }
            break;
             
        default:
            break;
             
        }
        if (e == -1)break;
        }
    }
    printf("%d\n",pop());
     
    return 0;
}
     
    void STACK(int maxN){        //?????????????????????????????¢??°
        s = malloc(maxN * sizeof(int));
        N = 0;
    }
     
    void push(int x){        //push??¨??¢??°
        s[N++] = x;
    }
     
    int pop(void){        //pop??¨??¢??°
        if(N <= 0) {
            printf("stack pop error\n");
            return 0;
        }
        return s[--N];
    }

Measured memory_bytes: 1768
#include <bits/stdc++.h>
 
using namespace std;
 
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
const int mod = 1000 * 1000 * 1000 + 7;
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;
 
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;
 
int dx[6] = {-1,-1,0,0,1,1};
int dy[6] = {-1,0,-1,1,0,1};

vector<int>v;


int CeilIndex(std::vector<int>& v, int l, int r, int key) 
{ 
    while (r - l > 1) { 
        int m = l + (r - l) / 2; 
        if (v[m] >= key) 
            r = m; 
        else
            l = m; 
    } 
  
    return r; 
} 
  
int LIS(std::vector<int>& v) 
{ 
    if (v.size() == 0) 
        return 0; 
  
    std::vector<int> tail(v.size(), 0); 
    int length = 1;  
  
    tail[0] = v[0]; 
    for (size_t i = 1; i < v.size(); i++) { 
  
         
        if (v[i] < tail[0]) 
            tail[0] = v[i]; 
        else if (v[i] > tail[length - 1]) 
            tail[length++] = v[i]; 
        else
            tail[CeilIndex(tail, -1, length - 1, v[i])] = v[i]; 
    } 
  
    return length; 
} 

int main(){
   int n,k;
   cin>>n>>k;
   if(n<10){
      cout<<k+100*(10-n)<<endl;
   }
   else 
      cout<<k<<endl;
   return 0;
}

Measured memory_bytes: 256
def gcd(x,y):
  r=x%y
  return gcd(y,r) if r else y

def lcm(x, y):
    return (x * y) // gcd(x, y)

n=int(input())
A=list(map(int,input().split()))
k=1
for i in A:
  k=lcm(k,i)

def f(n):
  return sum(list(map(lambda x:n%x,A)))
print(f(k-1))

Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
vector<pair<string,string> > mem;
vector<int> num;
void Find(pair<string,string> c){
    for(int i=0;i<mem.size();i++){
        if(mem[i]==c){
            num[i]++;
            return;
        }
    }
    mem.push_back(c);
    num.push_back(1);
}
int main(){
    int n,m,f;
    cin>>n>>f;
    string s[10];
    for(int u=0;u<n;u++){
        cin>>m;
        for(int i=0;i<m;i++){
            cin>>s[i];
            for(int j=0;j<i;j++){
                pair<string,string> c;
                if(s[i]<s[j])c.first=s[i],c.second=s[j];
                else c.first=s[j],c.second=s[i];
                Find(c);
            }
        }
    }
    int i=0;
    while(i<mem.size()){
        if(num[i]<f){
            mem.erase(mem.begin()+i);
            num.erase(num.begin()+i);
            i--;
        }
        i++;
    }
    sort(mem.begin(),mem.begin()+mem.size());
    cout<<mem.size()<<endl;
    for(int i=0;i<mem.size();i++){cout<<mem[i].first<<" "<<mem[i].second<<endl;}
    return 0;
}

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

int main(){
    int n,l[10000000],k;
    cin>>n>>k;
    int DP[10000000];
    const int INF=10000000000;
    for (int i=0;i<n;i++){
        cin>>l[i];
        DP[i]=INF;
        // cout<<l[i];
    }
    for (int i=1;i<n;i++){
        DP[0]=0;
        for (int j=1;j<=k;j++){
            if(i-j>=0){
                DP[i]= min(DP[i],DP[i-j]+abs(abs(l[i]-l[i-j])));
               // cout<<"DP"<<i<<" "<<DP[i]<<endl;
            } 
            
        }
    }
    cout<<DP[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

typedef long long ll;
typedef long double ld;
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPR(i,a,b) for(int i = b; i >= a; i--)
#define all(a)              a.begin(), a.end()
#define alln(a, n)          (a, a+n)
#define sz(x) (int)(x).size()
#define MAX                 10000007
#define MIN                 -10000007
#define pi pair<int,int>
#define pl pair<ll,ll>
#define mii             map<int,int>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define inf 1e18
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 
typedef vector<vi> vvi; 
typedef vector<string> vs;
typedef set<int> si;
const int MOD=1e9+7;
ll lcm(ll a,ll b){return (a * b) / __gcd(a,b);}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll power(ll a,ll b,ll MOD){if(b == 0)return 1;if(b == 1)return a;ll ans = power(a,b/2,MOD) % MOD;ans *= ans;ans %= MOD;if(b % 2 == 1)ans *= a;return ans%MOD;}
ll inverse(ll x){x%=MOD;return power(x,MOD-2,MOD);}
ll fact[1],inv[1];
void factorial(ll n){
  fact[0]=1;
  for(ll i=1;i<=n;i++){
    fact[i]=fact[i-1]*i;
    if(fact[i]>=MOD)
      fact[i]%=MOD;
  }
}
ll ncr(ll n,ll r){
  if(n<r||n<0||r<0)
    return 0;
  ll b=inv[n-r];
  ll c=inv[r];
  ll a=fact[n]*b;
  if(a>=MOD)
    a%=MOD;
  a*=c;
  if(a>=MOD)
    a%=MOD;
  return a;
}
vector<char> is_prime(100001, true);
void sieve(ll n){
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i <= n; i++) {
        if (is_prime[i] && (long long)i * i <= n) {
            for (int j = i * i; j <= n; j += i)
                  is_prime[j] = false;
        }
  }    
}     
 
int main()
{
  ios::sync_with_stdio(0);
    cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
      
    int t;
    t=1;
    cout<<fixed<<setprecision(0);
     //  cin>>t;
    while(t--){
            ll n;cin>>n;
            if(n==1) return cout<<0,0;
            ll ans=power(10,n,MOD);
            ans-=2ll*power(9,n,MOD);
            ans+=power(8,n,MOD);
            ans%=MOD;
            if(ans<0) ans+=MOD;
            cout<<ans;

       


             }
             cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}


Measured memory_bytes: 3884
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
//#define LOCAL
using namespace std;
typedef long long ll;
const int mx=1e3+10;
vector<ll>num;

int main() {
#ifdef LOCAL
ifstream fin("1.txt");
streambuf*p;
p=cin.rdbuf(fin.rdbuf());
#endif // LOCAL
ll n;
cin>>n;
for(ll i=0;i<n;i++){
    ll value;
    cin>>value;
    num.push_back(value);
}
vector<ll>::iterator it1=num.begin(), it2=num.end(), it3;
it3=unique(it1, it2);
ll len=num.size();
for(vector<ll>::iterator t=num.begin();t!=it3;t++){
    if(num.begin()==t) printf("%lld", *t);
    else printf(" %lld", *t);
}
puts("");


#ifdef LOCAL
fin.close();
#endif // LOCAL
}




Measured memory_bytes: 3928
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
set<string> c;
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
int main(){
string s;
cin>>s;
int a=0,b=0;
int n=s.size();
for(int i=0;i<n;i++){
   if(i%2==0&&s[i]!='0')a++;
   else if(i%2==1&&s[i]!='1')a++;
}
for(int i=0;i<n;i++){
   if(i%2==1&&s[i]!='0')b++;
   else if(i%2==0&&s[i]!='1')b++;
}
cout<<min(a,b)<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long int
#define loop(s, n) for(int i=s; i<n; i++)
#define rloop(s, n) for(int j=s-1; i>=n; j--)
using namespace std;

int main() {
    int n,k;
    cin>>n>>k;
    int h[n], dp[n];
    loop(0,n)
        cin>>h[i];
    dp[0] = 0; dp[1] = abs(h[1] - h[0]);
    loop(2,n) {
        int dpi = dp[i - 1] + abs(h[i] - h[i - 1]);
        for(int j=2; j<=k && i-j>=0; j++)
            dpi = min(dpi ,dp[i - j] + abs(h[i] - h[i - j]));
        dp[i] = dpi;
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 4400