akhauriyash/Code-Regression huggingface dataset:
S = input()
NS = set()
EW = set()
for s in S:
  if s in ["N", "S"]:
    NS.add(s)
  if s in ["E", "W"]:
    EW.add(s)
if len(NS) == 1 or len(EW) == 1:
  print("No")
else:
  print("Yes")

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

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

    int d[110];
    for(int i = 0; i < N;i++) cin >> d[i];

    int num[110] = {0};

    for(int i = 0; i < N;i++) {
        num[d[i]]++;
    }

    int res = 0;
    for(int i = 1; i <= 100;i++) {
        if(num[i] > 0) res++;
    }

    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#define INF 1000000000000
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int p[300000];
int r[300000];

void init(int n){
  REP(i, n){
    p[i] = i;
    r[i] = 0;
  }
}

int find(int n){
  if(p[n] == n) return n;
  p[n] = find(p[n]);
  return p[n];
}

void unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x == y) return;
  if(r[x] < r[y]) p[x] = y;
  else{
    p[y] = x;
    if(r[x] == r[y]) r[x]++;
  }
}

void same(int x, int y){
  if(find(x) == find(y)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return;
}

int main(){
  int n, m;
  cin >> n >> m;
  init(n+m);
  vector<int> v[m];
  REP(i, n){
    int k;
    cin >> k;
    REP(j, k){
      int l;
      cin >> l;
      l--;
      v[l].pb(i);
    }
  }
  REP(i, m){
    for(int x : v[i]){
      unite(n+i, x);
    }
  }
  map<int, int> mp;
  REP(i, n){
    mp[find(i)]++;
  }
  if(mp.size() == 1) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?9e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int n,m,r;
pii f(int a,int b){
	if(a==0)return {b,1};
	if(b==m)return {a,2};
	if(a==n)return {n-b,3};
	if(b==0)return {m-a,4};
	return {0,0};
}
int main(){
	cin>>n>>m>>r;
	vvp F(4);
	while(r--){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		pii t1=f(a,b);
		pii t2=f(c,d);
		if(!t1.second||!t2.second)continue;
		F[t1.second-1].pb({t1.first,r});
		F[t2.second-1].pb({t2.first,r});
	}
	stack<int>st;
	rep(i,4)sort(all(F[i]));
	rep(w,4)rep(i,F[w].size()){
		if(st.size()&&st.top()==F[w][i].second)st.pop();
		else st.push(F[w][i].second);
	}
	if(st.size())cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
}











Measured memory_bytes: 4840
#include<stdio.h>
#include<stdlib.h>
#define df 0
#define d_flag 0

int  d_count=10000000;
#define MOD 1000000007

typedef long int li;
li waru(li a,li b);
li kake(li a,li b);
li inv(li a);


int main(){
  int n,k;
  scanf("%d%d",&n,&k);
  li R=n-k,B=k,i;
  li bb,rr,ans;
  bb=1;
  rr=R+1;
  ans=rr;
  printf("%ld\n",ans);
  
  for(i=2;i<=k;i++){
    bb=waru(kake(bb,B-i+1),i-1);
    rr=waru(kake(rr,R-i+2),i);
    ans=kake(bb,rr);
    printf("%ld\n",ans);
  }
    
  

  return 0;
}
li inv(li a){
  li x0,y0,x1,y1,z0,z1,q,x2,y2,z2;
  x0=0;y0=1;z0=MOD;
  x1=1;y1=0;z1=a;
  if(d_flag)printf("\n");
  if(d_flag)printf("%10ld %10ld %10ld\n",x0,y0,z0);
  if(d_flag)printf("%10ld %10ld %10ld\n",x1,y1,z1);
  while(z1!=1){
    d_count-=d_flag; if(d_count<0){printf("err:inv\n");break;}
    q=z0/z1;
    x2=x0-x1*q;
    y2=y0-y1*q;
    z2=z0-z1*q;
    x0=x1;y0=y1;z0=z1;
    x1=x2;y1=y2;z1=z2;
  if(d_flag)printf("%10ld %10ld %10ld\n",x1,y1,z1);
  }
  return (MOD+x1)%MOD;
}
li waru(li a,li b){
  if(d_flag)printf("calc:%ld/%ld",a,b);
  if(a%b==0){
    if(d_flag) printf("->%ld\n",a/b);
    return a/b;
  }
  else{
    li c=inv(b);
    c=kake(a,c);
    if(d_flag) printf("->%ld\n",c);
    return(c);
  }
}

li kake(li a,li b){
  //  if(d_flag)printf("%ld*%ld\n",a%MOD,b%MOD);
  a%=MOD;
  b%=MOD;
  return a*b%MOD;
}

/// confirm df==0 ///


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

int h, w;
vector<string> s, red, blue;

int main() {
  cin >> h >> w;
  s.resize(h);
  for (auto &t : s) cin >> t;
  red = blue = s;
  {  // red
    for (int i = 0; i < h; ++i) {
      if (i & 1)
        red[i][0] = '#';
      else
        for (int j = 0; j < w - 1; ++j) red[i][j] = '#';
    }
  }
  {  // blue
    for (int i = 0; i < h; ++i) {
      if (i & 1)
        for (int j = 1; j < w; ++j) blue[i][j] = '#';
      else
        blue[i][w - 1] = '#';
    }
  }
  for (auto &t : red) cout << t << endl;
  cout << endl;
  for (auto &t : blue) cout << t << endl;
  return 0;
}


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

int n, k;

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

    sort(array, array + n, greater<int>());
    int length = 0;
    for (int i=0; i<k; i++){
        length += array[i];
    }

    cout << length;

    return 0;
}

Measured memory_bytes: 256
# AOJ 1078: SAT-EN-3
# Python3 2018.7.10 bal4u

def clause(e):
	f = True
	dic = {}
	f = e.split('&')
	for x in f:
		pm, t = 1, x[0]
		if t == '~':
			pm, t = -1, x[1]
		if t in dic and dic[t] + pm == 0: f = False
		dic[t] = pm
	return f

while True:
	p = input()
	if p == '#': break
	exp = list(p.split('|'))
	ans = False
	for e in exp:
		if clause(e[1:-1]):
			ans = True
			break
	print("yes" if ans else "no")


Measured memory_bytes: 5580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
    int d,n;
    cin >> d >>n;
    if(n!=100) cout << pow(100,d)*n <<endl;
    else if(n==100&&d==2) cout <<"1010000"<<endl;
    else cout <<pow(100,d)*101 <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
ll A[5000001],bin[5000001];
vector<ll>v;
map<int,int>myMap;
set<int>mySet;
vector<pair<ll,ll> >vp;
/* Precode Start Here *\



     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
 string s;
 cin>>s;
 if(s=="SUN")
 {
     cout<<7<<endl;
 }
 if(s=="MON")
 {
     cout<<6<<endl;
 }
 if(s=="TUE")
 {
     cout<<5<<endl;
 }
 if(s=="WED")
 {
     cout<<4<<endl;
 }
 if(s=="THU")
 {
     cout<<3<<endl;
 }
 if(s=="FRI")
 {
     cout<<2<<endl;
 }
 if(s=="SAT")
 {
     cout<<1<<endl;
 }
return 0;
}



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

using namespace std;

int main() {
  int n;
  cin >> n;
  set<string> s;
  for(int i = 0; i < n; i++) {
    string x;
    cin >> x;
    s.insert(x);
  }
  
  cout << s.size() << endl;
  return 0;
}

Measured memory_bytes: 19276
h,w=map(int,input().split())
n=int(input())
lists=list(map(int,input().split()))

uselists=[]
anslist=[]
for i in range(n):
    uselists.extend([i+1]*lists[i])

for i in range(0,h):
    if i%2==0:
        anslist.append(uselists[w*i:w*(i+1)])

    if i%2!=0:
        anslist.append(uselists[w*(i+1)-1:w*i-1:-1])
for some in anslist:
    print(*some)

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,k;
  cin >> a >> b >> k;
  
  vector<int> v(1000,0);
  
  for(int i=1;i<101;i++){
    if(a%i == 0 && b%i == 0) v[i] = i;
  }
  
  sort(v.begin(),v.end());
  cout << v[1000-k] << endl;
  
}


Measured memory_bytes: 256
//这无比风骚的操作真是令人震惊和赞叹啊。
#include <cstdio>
#include <algorithm>
const int mod = 924844033, MAXN = 2005;
int f[MAXN * 2][MAXN];
int fac[MAXN];
bool limited[MAXN * 2];
int n, k;
inline int addmod(int a, int b) { return (a + b) % mod; }
inline int mulmod(long long a, int b) { return (a * b) % mod; }
int main() {
	scanf("%d%d", &n, &k);
	for(int cur = 1, i = 1; i <= k; i++) {
		int len = (n - i) / k;
		cur += len + 1;
		limited[cur] = true;
		cur += len + 1;
		limited[cur] = true;
	}
	f[0][0] = f[1][0] = 1;
	for(int i = 2; i <= 2 * n; i++) {
		for(int j = 0; j <= n; j++) {
			f[i][j] = f[i - 1][j];
			if(j >= 1 && !limited[i]) f[i][j] = addmod(f[i][j], f[i - 2][j - 1]);
		}
	}
	fac[0] = 1;
	for(int i = 1; i <= n; i++) fac[i] = ((long long)fac[i - 1] * i) % mod;
	int ans = 0;
	for(int i = 1, sign = 1; i <= n; i++, sign *= -1) {
		if(sign == 1) ans = addmod(ans, mulmod(fac[n - i], f[2 * n][i]));
		else ans = addmod(ans, mod - mulmod(fac[n - i], f[2 * n][i]));
	}
	ans = addmod(fac[n], mod - ans);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 31488
#include <iostream>
using namespace std;
#define S 0
#define H 1
#define C 2
#define D 3
 
int main() {
	int cards[4][13],n,num;
	char type;
 
	for(int a=0;a<4;a++){
		for(int b=0;b<13;b++){
			cards[a][b]=0;	
		}
	}
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>type>>num;
		switch(type){
			case 'S':{
				cards[S][num-1]=1;
				break;
			}
			case 'H':{
				cards[H][num-1]=1;
				break;
			}
			case 'C':{
				cards[C][num-1]=1;
				break;
			}
			case 'D':{
				cards[D][num-1]=1;
				break;
			}
		}
	}
 
	for(int i=0;i<4;i++){
		for(int j=0;j<13;j++){
			if(cards[i][j]==0){
				if(i==S){
					cout<<"S "<<j+1<<endl;
				}
				else if(i==H){
					cout<<"H "<<j+1<<endl;
				}
				else if(i==C){
					cout<<"C "<<j+1<<endl;
				}
				else{
					cout<<"D "<<j+1<<endl;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int ll;
int main()
{
	ll n,m;
	cin >> n >> m;
	
	ll ans=0;
	if(2*n <= m){
		ans+=n;
		m -= 2*n;
		ans+= m/4;
	}else{
		ans = m/2;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

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

int main() {
    long long X, Y;
    cin >> X >> Y;
    long long count = 0;

    while (X <= Y) {
        count++;
        X *= 2;
    }

    cout << count << endl;

    return 0;
}

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

using namespace std;

int main(){
    char x,y;
    cin>>x>>y;

    if(x-'A'>y-'A'){
        cout<<">"<<endl;
    }else if(x==y){
        cout<<"="<<endl;
    }else{
        cout<<"<"<<endl;
    }

}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int K=stdIn.nextInt();
		int A[]=new int[N];
		int ans=0;
		for(int i=0;i<N;i++){
			A[i]=stdIn.nextInt();
		}
		ans++;N-=K;K--;
		if(N==0){
			System.out.println(1);
			System.exit(0);
		}
		if(N%K==0){
			System.out.println(ans+(N/K));
		}
		else
			System.out.println(ans+(N/K)+1);
	}
}


Measured memory_bytes: 49720
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Ord 

main :: IO ()
main = getLine >> readContents 2 >>= print . solve

solve :: [[Int]] -> Int
solve [vs, cs] = count 0 . sortOn Down . map mf $ zip vs cs
    where
        count acc (x : xs)
            | x > 0 = count (acc + x) xs
            | otherwise = acc
        count acc _ = acc 

        mf (v, c) = v - c

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 508
// **** WHEN THE GOING GETS TOUGH, THE TOUGH GETS GOING. ****

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]
typedef vector< int > vi;
typedef vector< ll > lvi;
typedef vector< vi > vvi;
typedef vector< lvi > lvvi;
typedef pair< int,int > ii;
typedef pair< ll,ll > lii;
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define ld long double
#define ull unsigned long long int
#define mod 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
	ll k,T;
	cin>>k>>T;
	lvi d(k);
	for (int i = 0; i < k; ++i)
	{
		cin>>d[i];
	}
	while(T--)
	{
		ll n,x,m;
		cin>>n>>x>>m;
		x=x%m;
		lvi dd(k);
		ll M,q,sum1=0,v1=0;
		for (int i = 0; i < k; ++i)
		{
			dd[i]=d[i]%m;
			sum1+=dd[i];
			v1+=(dd[i]==0);
		}
		q=sum1/m;
		M=sum1%m;
		ll nc=(n-1)/k;
		ll ans=q*nc+((x+M*nc)/m)+v1*nc;
		ll curr_pos=(x+M*nc)%m;
		ll left=(n-1)%k;
		for(int i=0;i<left;i++)
		{
			ll pos=(curr_pos + dd[i])%m;
			if(pos<=curr_pos) ans++;
			curr_pos=pos;
		}
		cout<<n-ans-1<<endl;
	}
	return 0;
}

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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)

int a,b,c;
int main()
{

    cin>>a>>b>>c;
    a=(a+b)*(c/2);
    cout<<a;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
ll int gcd (ll int a,ll int b) { return b ? gcd (b, a % b) : a; }

int main()
{
	string a,b;
	cin>>a;	cin>>b;
	int n = a.size(),m=b.size();
	int dp[n+1][m+1];	//n rows, m columns
	for (int i = 0; i <= n; ++i)
	{
		dp[i][0] = 0;
	}
	for (int i = 0; i <= m; ++i)
	{
		dp[0][i] = 0;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(a[i-1]==b[j-1])
			{
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else
			{
				dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			}
			//cout<<i<<" "<<j<<" : "<<dp[i][j]<<"\n";
		}
	}
	int len = dp[n][m];
	//cout<<dp[n][m]<<"\n";
	string ans;
	int i = n,j=m;
	while(i>0 && j>0)
	{
		if(a[i-1]==b[j-1])
		{
			ans.push_back(a[i-1]);
			i--;j--;
		}
		else if(dp[i-1][j]>dp[i][j-1])
			i--;
		else
			j--;
	}
	//cout<<ans.size()<<"\n";
	reverse(ans.begin(), ans.end());
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 38772
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var s = Console.ReadLine();
            Console.WriteLine($"{s[0]}{s.Length - 2}{s[s.Length - 1]}");
        }
    }
}


Measured memory_bytes: 25824
S = input()

N = len(S)
T = ''
i = 0
while i < N:
    j = N - 1 - i
    if S[j] == 'm':
        T = 'dream' + T
        i += 5
    elif S[j] == 'e':
        T = 'erase' + T
        i += 5
    elif S[j - 2:j + 1] == 'mer':
        T = 'dreamer' + T
        i += 7
    elif S[j - 2:j + 1] == 'ser':
        T = 'eraser' + T
        i += 6
    else:
        break

if S == T:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3440
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main (final String[] args) {
        final Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
        String s = sc.next();
      	String t = sc.next();
      
      	String[] sa = s.split("", 0);
      	String[] ta = t.split("", 0);
      	
      	for (int i = 0; i < n; i++) {
          	System.out.print(sa[i] + ta[i]);
        }
      	System.out.println();
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
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; }
class ModInt {
  static int MOD;
  long long x;

 public:
  static void mod(int m) { MOD = m; }

  ModInt(long long v = 0) : x(v % MOD) {
    if (x < 0) x += MOD;
  }

  ModInt& operator+=(const ModInt& r) {
    x += r.x;
    if (x >= MOD) x -= MOD;
    return *this;
  }

  ModInt& operator-=(const ModInt& r) {
    x -= r.x;
    if (x < 0) x += MOD;
    return *this;
  }
  ModInt& operator*=(const ModInt& r) {
    x = (x * r.x) % MOD;
    return *this;
  }
  ModInt& operator/=(const ModInt& r) {
    *this *= r.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt& r) const { return ModInt(*this) += r; }
  ModInt operator-(const ModInt& r) const { return ModInt(*this) -= r; }
  ModInt operator*(const ModInt& r) const { return ModInt(*this) *= r; }
  ModInt operator/(const ModInt& r) const { return ModInt(*this) /= r; }
  bool operator==(const ModInt& r) const { return x == r.x; }
  bool operator!=(const ModInt& r) const { return x != r.x; }

  ModInt inverse() const {
    long long a = x, b = MOD, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(long long n) const {
    ModInt ret(1), mul(x);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream& operator<<(ostream& os, const ModInt& x) { return os << x.x; }

  friend istream& operator>>(istream& is, ModInt& x) { return is >> x.x; }

  int getMod() { return MOD; }

  long long val() { return x; }
};
int ModInt::MOD = 1000000007;

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

  vector<int> a;
  for (ll m = N; m != 0; m /= 2) {
    a.push_back(m % 2);
  }
  reverse((a).begin(), (a).end());

  unordered_map<ll, unordered_map<ll, ModInt>> memo;

  function<ModInt(ll, ll)> rec = [&](ll s, ll x) {
    if (memo[s].find(x) != memo[s].end()) return memo[s][x];
    if (s == 0) return ModInt(1);
    if (s == 1) {
      if (x == 0) return ModInt(1);
      return ModInt(2);
    }

    return memo[s][x] = rec(s / 2, x / 2) + rec((s - 1) / 2, (x - 1) / 2) +
                        rec((s - 2) / 2, x / 2);
  };

  cout << rec(N, N) << endl;

  return 0;
}


Measured memory_bytes: 256
def li():
    return [int(x) for x in input().split()]


MOD = 998244353
N, K = li()
L, R = [], []
for _ in range(K):
    l, r = li()
    L.append(l)
    R.append(r)

#dp[i]: マスiにいく場合の数

dp = [0] * (2 * N + 1)
dp[1] = 1
dp[2] = -1

for i in range(1, N):
    dp[i+1] += dp[i]
    dp[i+1] %= MOD
    for k in range(K):
        l, r = L[k], R[k]
        dp[i+l] += dp[i]
        dp[i+l] %= MOD
        dp[i+r+1] -= dp[i]
        dp[i+r+1] %= MOD

print(dp[N])


Measured memory_bytes: 71644
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>

typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define rep_r(i,s,n)for(ll i = n-1;i>=s;i--)
using namespace std;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_N = 100001;

ll p[200000];
ll q[200000];
int main() {
	ll n; cin >> n;
	rep(i, 0, n)cin >> p[i];

	ll minV = INF;
	rep(i, 0, n) {
		minV = min(minV,p[i]);
		q[i] = minV;
	}

	ll ans = 0;
	rep(i, 0, n) {
		ans += p[i] <= q[i];
	}

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



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

int main(){
    int X,S=0;
    cin >> X;

    while(1){
        if(X>=500){
            X-=500;
            S+=1000;
        }
        else break;
    }

    while(1){
        if(X>=5){
            X-=5;
            S+=5;
        }
        else break;
    }
        
    cout << S << endl;
    
}

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

int main() {
    int n;
    cin >> n;
    for(int i = 0; i <= n; i++) {
        if(i * 108 / 100 == n) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define MSG(x) std::cout << #x << " : " << x << "\n";
using namespace std;
using lint = 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; }

int R, G, B, N;

int main()
{
    std::cin >> R >> G >> B >> N;

    int cnt = 0;

    for (int r = 0; r*R <= N; ++r)
    {
        for (int g = 0; g*G + r*R <= N; ++g)
        {
            if (g*G + r*R == N)
            {
                cnt++;
            }
            else
            {
                if ((N - g*G - r*R) % B == 0)
                {
                    cnt++;
                }
            }
        }
    }

    std::cout << cnt << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

int a, b, c, d;
int main(){
	scanf("%d%d%d%d", &a, &b, &c, &d);
	if((std::abs(a-b) <= d && std::abs(b-c) <= d) || std::abs(a-c) <= d){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
#define rep(i,l,r) for(int i=l;i<=r;++i)
 
const int N=3e5+5;
const ll inf=(ll)N*N;
ll dp[N];
 
int main()
{
	//freopen("1.in","r",stdin);
	int k,n;
	cin>>k>>n;
	if(k%2==0)
	{
		printf("%d ",k/2);
		rep(i,2,n)printf("%d ",k);
		puts("");
		return 0;
	}
	rep(i,1,n)dp[i]=min(inf,k*(dp[i-1]+1));
	int i=n,dis=0;
	while(dp[i]==inf)
	{
		printf("%d ",(k+1)/2);
		++dis;
		--i;
	}
	ll need=(dp[i]+1-dis)/2;
	for(;need;)
	{
		int j=(need-1)/(dp[i-1]+1);
		need-=j*(dp[i-1]+1);
		printf("%d ",j+1);
		--i;
		--need;
	}
	puts("");
}

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

int main() {
    int N;
    cin >> N;
    int C = 50;
    for(int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        int c=0;
        while(!(A%2)) {
            A/=2;
            ++c;
        }
        if(C>c) {
        C = c;
        }
    }
    cout << C << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=1e9+7;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int n;cin>>n;
    v a(n);in(a,n);
    v freq(1e5+1,0);
    int sum=0;
    f(i,n)
    {
        sum+=a[i];
        freq[a[i]]++;
    }
    int q;cin>>q;
    while(q--){
        int b,c;cin>>b>>c;  
        sum-=freq[b]*b;
        sum+=freq[b]*c;
        freq[c]+=freq[b];
        freq[b]=0;
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 4752
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll jo(ll a, ll b) {
  ll t = 1;
  for(int i = 0; i < b; i++) {
    t *= a;
  }
  
  return t;
}
ll sum(vector<ll> &num, ll x, ll y) {
  if(y == 0) {
    ll t = 0;
    t = num.at(0) * jo(2, x);
    //cout << num.at(0) << ":num0 " << jo(2, x) << "jo2x " << y << ":y " << t << endl;
    return t;
  }
  ll s = 0;
  for(int i = 0; i < y; i++) {
    s += (jo(2, (x - 1 - i)) * jo(10, i));
  }
  
  s += (jo(2, (x - y)) * jo(10, y));
  s *= num.at(y);
  //cout << y << ":y " << s << endl;
  return (s + sum(num, x, (y - 1)));
}
  



int main() {
  string S;
  cin >> S;
  vector<char> box(S.size());
  for(int i = 0; i < box.size(); i++) {
    box.at(i) = S.at(i);
    //cout << box.at(i) << "box" << endl;
  }
  
  vector<ll> num(box.size());
  for(int i = 0; i < box.size(); i++) {
    if(box.at(i) == '0') {
      num.at(i) = 0;
    }
    
    if(box.at(i) == '1') {
      num.at(i) = 1;
    }
    
    if(box.at(i) == '2') {
      num.at(i) = 2;
    }
    
    if(box.at(i) == '3') {
      num.at(i) = 3;
    }
    
    if(box.at(i) == '4') {
      num.at(i) = 4;
    }
    
    if(box.at(i) == '5') {
      num.at(i) = 5;
    }
    
    if(box.at(i) == '6') {
      num.at(i) = 6;
    }
    
    if(box.at(i) == '7') {
      num.at(i) = 7;
    }
    
    if(box.at(i) == '8') {
      num.at(i) = 8;
    }
    
    if(box.at(i) == '9') {
      num.at(i) = 9;
    }
    
  }
  for(int i = 0; i < num.size(); i++) {
  //cout << num.at(i) << "num" << endl;
  }
  ll x = (num.size() - 1);
  //cout << x << endl;
  reverse(num.begin(), num.end());
  ll y = x;
  cout << sum(num, x, y) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string.h>
#include <math.h>
typedef long long ll;
#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REP(i,x,y)	for (int (i)=(x);(i)<(y);(i)++)
#define REP_(i,x,y)	for ((i)=(x);(i)<(y);(i)++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
typedef pair<int, int> Point;
typedef vector<vector<Point>> Graph;

int N,ymax,jmax,ans;

int main() {
	cin >> N;

	vector<Point> rp(N);
	vector<Point> bp(N);

	REP(i, 0, N) cin >> rp[i].first >> rp[i].second;
	REP(i, 0, N) cin >> bp[i].first >> bp[i].second;
	
	sort(rp.begin(), rp.end());
	sort(bp.begin(), bp.end());

	REP(i,0,N) {
		ymax = -1;
		jmax = -1;
		REP(j,0,rp.size()) {
			if (rp[j].first < bp[i].first) {
				if ( rp[j].second < bp[i].second)
					if (ymax < rp[j].second) {
						ymax = rp[j].second;
						jmax = j;
					}
			} else break;
		}
		if (ymax >= 0) {
			ans++;
			rp.erase(rp.begin()+jmax);
		}
	}
	
	cout << ans;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//const long long INF = 1LL << 60;
vector <int>  par(100010);
vector <int> ranc(100010);
void init(int n){
    for(int i=0;i<100010;i++){
        par[i]=i;
        ranc[i]=0;
    }
}
int root(int x){
    return par[x] == x ? x : par[x]= root(par[x]);
}
bool same(int x, int y){
    return root(x)==root(y);
}
void unite(int x, int y){
    x = root(x);
    y = root(y);
   if(x==y) return;
    if(ranc[x]<ranc[y]){
        par[x]=y;
    }else{
        par[y] = x;
        if(ranc[x]==ranc[y]) ranc[x]++;
    }
    
}
int main(void){
    int n,m; cin>>n>>m;
    init(n);
    for(int i=0;i<m;i++){
        int a,b,c; scanf("%d %d %d",&a,&b,&c);
            unite(a,b);
    }
    vector <bool>  data(100010,false) ;
    for(int i=1;i<=n;i++){
        //cout<<root(i)<<endl;
        int x=root(i);
        //if(data[x]==true) 
        //cout<<x<<endl;
        data[x]=true;
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        ans+=data[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
fileprivate struct Scanner {
    private var elements = [String]()
    private var index = 0
    
    mutating func peek() -> String {
        while elements.count == index {
            elements = readLine()!.split(separator: " ").map(String.init)
            index = 0
        }
        return elements[index]
    }
    
    mutating func next() -> String {
        let value = peek()
        index += 1
        return value
    }
    
    mutating func nextInt() -> Int {
        return Int(next())!
    }
    
    mutating func nextDouble() -> Double {
        return Double(next())!
    }
}

func main() {
    var scanner = Scanner()
    let N = scanner.nextInt()
    let A = (0 ..< N).map { _ in scanner.nextInt() }
    
    var dp = [Int](repeating: Int.min, count: N + 1)
    dp[0] = 1000
    for i in 0 ..< N {
        for j in i + 1 ..< N {
            dp[j] = max(dp[j], dp[i] % A[i] + dp[i] / A[i] * A[j])
        }
        dp[i + 1] = max(dp[i + 1], dp[i])
    }
    print(dp[N])
}

main()


Measured memory_bytes: 7952
#include "bits/stdc++.h"
using namespace std;

int main() {
	int r, g, b;
	cin >> r >> g >> b;
	int n = r * 100 + g * 10 + b;
	if (n % 4 == 0)cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define cc(a) cout << a << endl;
#define msg(a,b) cout << a << " : " << b << endl;
#define msg2(a,b,c) cout << a << " : " << b << " : " << c << endl;
#define msg3(a,b,c,d) cout << a << " : " << b << " : " << c << " : " << d << endl;
int main(){
    long long int a,b;
    cin >> a >> b;
    cout << a+ b/2 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
 
	  String a = sc.next();
      String b = sc.next();
      
		if(a.equals(b)){
        	 System.out.println("H");
    	}else{
         	System.out.println("D");
    	}
    }
}

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

using namespace std;
#define REP(i,a,b)for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main() {
  int a, b, c, d;
  int e, f, g, h;
  int Tc;
  while(cin >> Tc&&Tc){
  rep(_, Tc) {
  scanf("%d%d%d%d %d%d%d%d",&a,&b,&c,&d,&e,&f,&g,&h);
  int t[4][4];
  t[0][0] = a*e, t[0][1] = a*f, t[0][2] = a*g, t[0][3] = a*h;
  t[1][0] = b*e, t[1][1] = b*f, t[1][2] = b*g, t[1][3] = b*h;
  t[2][0] = c*e, t[2][1] = c*f, t[2][2] = c*g, t[2][3] = c*h;
  t[3][0] = d*e, t[3][1] = d*f, t[3][2] = d*g, t[3][3] = d*h;
  int ans[4] = {};
  ans[0] = t[0][0] - t[1][1] - t[2][2] - t[3][3];
  ans[1] = t[0][1] + t[1][0] + t[2][3] - t[3][2];
  ans[2] = t[0][2] + t[2][0] - t[1][3] + t[3][1];
  ans[3] = t[0][3] + t[1][2] - t[2][1] + t[3][0];
  rep(i, 4) { if(i) cout << " "; cout << ans[i]; }
  cout << endl;
  }}
  return 0;
}

Measured memory_bytes: 1248
#include <stdio.h>
int main() {
	int S, h, m, s;
	scanf("%d", &S);
	h = S / 3600;
	m = (S - h*3600) / 60;
	s = S - h*3600 - m*60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    int D, T, S;
    cin >> D >> T >> S;

    int sum = T * S;
    if (sum >= D) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3628
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    A, B, K = map(int, input().split())
    ans = set()
    for i in range(A, min(B + 1, A + K)):
        ans.add(i)
    for i in range(B, max(A - 1, B - K), -1):
        ans.add(i)
    for x in sorted(list(ans)):
        print(x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3952
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <bitset>
#include <map>
#include <climits>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<long> v(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> v[i];
    }

    int cnt = 0;
    enum State
    {
        even,
        increase,
        decrease,
    };
    State s = even;

    for (int i = 0; i < N - 1; ++i)
    {
        auto diff = v[i + 1] - v[i];
        auto next_s = diff == 0 ? even : (diff > 0 ? increase : decrease);
        switch (s)
        {
        case even:
            s = next_s;
            break;
        case increase:
            if (next_s == decrease)
            {
                //cout << i << endl;
                ++cnt;
                s = even;
            }
            break;
        case decrease:
            if (next_s == increase)
            {
                //cout << i << endl;
                ++cnt;
                s = even;
            }
            break;
        }
    }
    cout << (cnt + 1) << endl;
    return 0;
}

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

const int N_MAX = 100;
int N;
const int M_MAX = 100;
int M;

vector<int> T(N_MAX);
vector<int> P(M_MAX);
vector<int> X(N_MAX);



int main()
{
	cin >> N;
	for(int i =0;i < N;i++)
	{
		cin >> T[i];
	}
	cin >> M;
	for(int i = 0;i < M;i++)
	{
		cin >> P[i] >> X[i];
		P[i]--;
	}

	for(int i = 0;i < M;i++)
	{
		int ans = 0;
		for(int j =0;j < N;j++)
		{
			if(j == P[i]) ans += X[i];
			else ans += T[j];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")
#define mins(a,b) a = min(a,(decltype(a))(b))
#define maxs(a,b) a = max(a,(decltype(a))(b))

double inf = 1e10;
struct D {
	double l[3] = { inf,inf,inf };
	double r[3] = { -inf,-inf,-inf };
	double get(double t) {
		double ml = l[0] - t;
		mins(ml, l[1]);
		mins(ml, l[2] + t);
		double mr = r[0] - t;
		maxs(mr, r[1]);
		maxs(mr, r[2] + t);
		return mr - ml;
	}
	void add(double v, int d) {
		++d;
		mins(l[d], v);
		maxs(r[d], v);
	}
	vector<double> e() {
		vector<double> ret;
		REP(i, 0, 3)REP(j, 0, i) {
			double t = (r[j] - r[i]) / (double)(i - j);
			if(t > 0.0) ret.push_back(t);
		}
		REP(i, 0, 3)REP(j, 0, i) {
			double t = (l[j] - l[i]) / (double)(i - j);
			if (t > 0.0) ret.push_back(t);
		}
		return ret;
	}
};

int main() {
	ll N;
	cin >> N;
	D dx, dy;
	REP(i, 0, N) {
		double x, y;
		char d;
		cin >> x >> y >> d;
		if (d == 'U') {
			dy.add(y, 1);
			dx.add(x, 0);
		}
		if (d == 'D') {
			dy.add(y, -1);
			dx.add(x, 0);
		}
		if (d == 'L') {
			dy.add(y, 0);
			dx.add(x, -1);
		}
		if (d == 'R') {
			dy.add(y, 0);
			dx.add(x, 1);
		}
	}
	double ans = dx.get(0) * dy.get(0);
	auto ex = dx.e();
	auto ey = dy.e();
	for (double t : ex)mins(ans, dx.get(t) * dy.get(t));
	for (double t : ey)mins(ans, dx.get(t) * dy.get(t));
	printf("%.11f\n", ans);
	return 0;
}




Measured memory_bytes: 3824
s = input()
MOD = 10 ** 9 + 7
n = len(s)
dp1 = [0] * (n + 1)
dp2 = [0] * (n + 1)
dp1[0] = 1
for i in range(n):
    if s[i] == '1':
        dp1[i + 1] += dp1[i] * 2
        dp1[i + 1] %= MOD
        dp2[i + 1] += dp1[i] + dp2[i] * 3
        dp2[i + 1] %= MOD
    else:
        dp1[i + 1] += dp1[i]
        dp1[i + 1] %= MOD
        dp2[i + 1] += dp2[i] * 3
        dp2[i + 1] %= MOD

print((dp1[n] + dp2[n]) % MOD)


Measured memory_bytes: 41456
/**
 *    Creator :  bizarre
 *    Date : 4/2020
 *    Problem Number : 424
**/
#include <bits/stdc++.h>
using namespace std;
#define bizarre     ios_base::sync_with_stdio( false ), cin.tie( nullptr ), cout.tie( nullptr );
/*
vector<int> prime_Numbers;
int primes[1000005];
void prime(int n)
{
    primes[1]=primes[0]=0;
    for(int i=2; i<=n; i++)
        primes[i]=true;
    for(int i=2; i<=n; i++)
    {
        if(primes[i]==true)
        {
            prime_Numbers.push_back(i);
            for(int j=i+i; j<=n; j+=i)
                primes[j]=false;
        }
    }
    for(int i=2; i<=n; i++)
        primes[i]+=primes[i-1];
}

void move1step(long long& a, long long& b, long long q)
{
    long long c= a-q*b;
    a=b;
    b=c;
}
long long egcd(long long r0,long long r1,long long& x0,long long& y0)
{
    long long x1=0,y1=1;
    x0=1;
    y0=0;
    while(r1)
    {
        long long q=r0/r1;
        move1step(r0,r1,q);
        move1step(x0,x1,q);
        move1step(y0,y1,q);
    }
    return r0;
}
bool  solve (long long a, long long b, long long c,long long&x, long long& y)
{
    long long g=egcd(a,b,x,y);
    int m=c/g;
    x*=m;
    y*=m;
    return c%g==0;
}



int npr(long long n, long long r)
{
    return (fact[n] * inv[n - r]) % mod;
}

int gcd(int a, int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
void PrimeFactorization(int n)
{
    for(int i=2; i*i<=n; i++)
    {
        int c=0;
        if(n%i==0)
        {
            while(n%i==0)
            {
                n/=i;
            }

        }
    }

}
const int inf = 2e9, mod = 1e9 + 7,N=1e5+5;
long long fact[N], inv[N];
long long fp(long long base, long long exp)
{
    if (exp == 0)
        return 1;
    long long ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}
void pre(long long n)
{
    fact[0] = 1;
    inv[0] = 1;
    for (long long i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}
int ncr(long long n, long long r)
{
    return (((fact[n] * inv[n - r]) % mod) * inv[r]) % mod;
}
long long ncrtane(long long n, long long r)
{
    long long ans=1,cntr=1;
    for(int i=n;i>n-r;i--)
    {
        ans*=i;
        ans/=cntr;
        cntr++;
    }
    return ans;
}
*/
int main()
{
    bizarre
     int n;
     cin>>n;
     long long a[n],b[n],c[n],aa[n],bb[n],cc[n];
     for(int i=0;i<n;i++)
     {
         cin>>a[i]>>b[i]>>c[i];
         if(i==0)
         {
             aa[i]=a[i];
             bb[i]=b[i];
             cc[i]=c[i];
         }
         else
         {
             aa[i]=max(cc[i-1],bb[i-1])+a[i];
             bb[i]=max(cc[i-1],aa[i-1])+b[i];
             cc[i]=max(aa[i-1],bb[i-1])+c[i];
         }
     }
     cout << max(aa[n-1],max(bb[n-1],cc[n-1]));
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const unordered_map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,K;
vector<int> A;
unordered_map<int,int> cnt;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> N >> K;
    for (int i = 0; i < N; i++)
    {
        int a; cin >> a;
        A.push_back(a);
        cnt[a]++;
    }
    
}

int solve(){
    DBG(cnt)
    DBG(cnt.size())
    if(cnt.size()<=K) {cout << 0 << endl; return 0;} 
    vector<int> tmp;
    for(auto c:cnt) tmp.push_back(c.second);
    sort(tmp.begin(),tmp.end());
    int L = tmp.size()-K;
    DBG(tmp)
    DBG(L)
    int ans=0;
    for (int i = 0; i < L; i++)
    {
        ans+=tmp[i];
    }
    cout << ans << endl;
    
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


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

int gcd(int a, int b, int c){
    int gcd=1,count=1;
    int frag=min({a,b,c});
    while(count <= frag){
        if(a%count==0 and b%count==0 and c%count==0){
            gcd=count;
            count++;
        }else{
            count++;
        }
    }
    return gcd;
}


int main(){
    int N,ans=0;
    cin >> N;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            for(int k=1;k<=N;k++){
                ans=ans+gcd(i,j,k);
            }
        }
    }
    cout <<ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
#include<math.h>
int main(){
double a,b,c,d;
scanf("%lf %lf %lf %lf",&a,&b,&c,&d);
printf("%lf\n",sqrt(pow(c-a,2.0)+pow(d-b,2.0)));
return 0; }


Measured memory_bytes: 2052
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;




int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  vector<ll> B(N);
  REP(i,N-1) { cin >> B[i]; }


  ll ans = B[0] + B[N-2];
  REP(i,N-2){
      ans += min(B[i],B[i+1]);
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256