akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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() {
  int n;
  cin >> n;
  map<string, int> mp;
  REP(i, n) {
    string s;
    cin>>s;
    mp[s]++;
  }
  printf("AC x %d\n", mp["AC"]);
  printf("WA x %d\n", mp["WA"]);
  printf("TLE x %d\n", mp["TLE"]);
  printf("RE x %d\n", mp["RE"]);

  return 0;
}

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

int main(void) {
    int D, N;
    cin >> D >> N;
    if (N == 100) N++;
    cout << N;
    for (int i=0; i<D; i++) cout << "00";
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
a, b, c = map(int, input().split())

if a<=b<=c:
    print(a,b,c)
elif a<=c<=b:
    print(a,c,b)
elif b<=a<=c:
    print(b,a,c)
elif b<=c<=a:
    print(b,c,a)
elif c<=a<=b:
    print(c,a,b)
else:
    print(c,b,a)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int n, sum = 0;
int a[N], f[N];

int32_t main()
{
	IOS;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		f[a[i]]++;
		sum += a[i];
	}
	int q;
	cin >> q;
	while(q--)
	{
		int b, c;
		cin >> b >> c;
		sum -= f[b] * b;
		sum += f[b] * c;
		f[c] += f[b];
		f[b] = 0;
		cout << sum << endl;
	}
	return 0;
}


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

const int INF = 2e9;

int main(){
    int n;
    cin >> n;
    vector<pii> x(n);
    rep(i,n){
        int a,b;
        cin >> a >> b;
        x[i].first = b;
        x[i].second = a;
    }
    sort(x.begin(),x.end());
    ll now = 0;
    bool ok = true;
    rep(i,n){
        now += x[i].second;
        if(now > x[i].first){
            ok = false;
            break;
        }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 4820
s = int(input())

a = [s]
i = 0

while 1:
    tmp = a[i]
    if tmp % 2 == 0:
        a.append(tmp // 2)
    else:
        a.append(3 * tmp + 1)

    if a[i+1] in a[:i+1]:
        print(i+2)
        break

    i += 1


Measured memory_bytes: 2940
n = int(input())

ac = 0
wa = 0
tle = 0
re = 0

for i in range (n):
    tmp = str(input())
    if tmp == 'AC':
        ac += 1
    elif tmp == 'WA':
        wa += 1
    elif tmp == 'TLE':
        tle += 1
    elif tmp == 'RE':
        re += 1

print ('AC x ', ac)
print ('WA x ', wa)
print ('TLE x ', tle)
print ('RE x ', re)

Measured memory_bytes: 9204
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <numeric>
#include <string>
#include <ctype.h>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <deque>
#include <stdlib.h>
#include<cmath>
#define N 1003
using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[111];
    int i;
    a[0] = 1;
    for (i=1; i<100 ;i++)
    {
        a[i] = a[i-1]*2;
        if (a[i] > 100)
        {
            i++;
            break;
        }
    }
    int ans = 0;
    for (int j=1; j<=n; j++)
    {
        if (binary_search(a,a+i,j))  ans = j;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  string divide[4] = {"erase", "eraser", "dream", "dreamer"};
  string str; cin >> str;
  vector<bool> dp(1000010);
  dp[0] = true;
  for (int i = 0; i < str.size(); i++){
    if (!dp[i]) continue;
    for (string s : divide){
      if (str.substr(i, s.size()) == s) dp[i + s.size()] = true;
    }
  }
  cout << (dp[str.size()] ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 512
H,W = map(int,input().split())
a = [input() for _ in range(H)]
dp = [[0 for _ in range(W+1)] for __ in range(H+1)]
dp[1][0]=1
mod_numb = 1000000007
for h in range(1,H+1):
    for w in range(1,W+1):
        if a[h-1][w-1]=='#':
            continue
        else:
            dp[h][w] = (dp[h-1][w] + dp[h][w-1])%mod_numb
print(dp[H][W])

Measured memory_bytes: 53852
S = input()

ki = 1
gu = 1

j = 1
count = 0
for s in S:
    count = 0
    if j == 1 and count == 0:
        count = 1
        j = 0
        if s == "R":
            pass
        elif s == "U":
            pass
        elif s == "D":
            pass
        else:
            ki = 0


    if j == 0 and count == 0:
        count =1
        j = 1
        if s == "L":
            pass
        elif s == "U":
            pass
        elif s == "D":
            pass
        else:
            gu = 0


    if ki == 0:
        break
    if gu == 0:
        break

if ki + gu == 2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

int N;
int A;
int num[3];

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

    int N;
    cin >> N;

    u64 ans = 1;
    rep (i, N)
    {
        cin >> A;
        int temp = 0;
        bool first = true;
        rep (j, 3)
        {
            if (num[j] == A)
            {
                ++temp;
                if (first)
                {
                    ++num[j];
                }
                first = false;
            }
        }
        ans *= temp;
        ans %= MOD;
    }


    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)

ll d4[]={0,1,0,-1,0};

int main(){
	ll n;
	while(scanf("%lld",&n),n){
		ll a[25][25]={};
		rep(i,0,n){
			ll x,y;
			scanf("%lld%lld",&x,&y);
			a[x][y]=1;
		}
		ll m;
		scanf("%lld",&m);
		ll px=10,py=10;
		if(a[px][py]){
			a[px][py]=0;
			n--;
		}
		rep(i,0,m){
			char c;
			ll d,q;
			scanf(" %c %lld",&c,&q);
			if(c=='N')d=0;
			else if(c=='E')d=1;
			else if(c=='S')d=2;
			else d=3;
			while(q--){
				px+=d4[d];
				py+=d4[d+1];
				if(a[px][py]){
					a[px][py]=0;
					n--;
				}
			}
		}
		puts(n?"No":"Yes");
	}
}


Measured memory_bytes: 2044
/*input
32
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5
*/

#include <bits/stdc++.h>
#define ll long long

using namespace std;

void run() {
	int n, i;
	ll ret = 0, x;
	cin >> n;
	map<ll, ll> mp;
	for(i=1; i<=n; i++) {
		cin >> x;
		ret += mp[i - x];
		mp[x + i]++;
	}
	cout << ret << endl;
}

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


Measured memory_bytes: 26252
#include <iostream>
#include <climits>
#include <math.h>

using namespace std;

int main() {
    long long N, a, b, c, d, e, x;
    cin >> N >> a >> b >> c >> d >> e;

    x = min(a, b);
    x = min(x, c);
    x = min(x, d);
    x = min(x, e);
   
    long long ans = N / x + (N % x == 0 ? 0 : 1) + 4;

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


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

using namespace std;

int main(){
  int N,K;
  vector<int> A;
  cin >> N >> K;
  for(int i=0;i<N;i++){
    int tmp;
    cin >> tmp;
    A.push_back(tmp);
  }

  int counter = 0;
  // auto oneItr = find(A.begin(),A.end(),1);
  // int one = (int)(oneItr - A.begin());

  counter = (N-1 + K-2)/(K-1);
  cout << counter << endl;
  return 0;
}

Measured memory_bytes: 892
(n,m) = map(int,input().split())
a,A,b,me,d,w,s = [0]*m,[0]*m,[-1]*n,[1]*n,[0]*n,[0]*m,(n*(n-1))//2
for i in range(m):
    (a[i], A[i]) = map(int,input().split())
    a[i] -= 1
    A[i] -= 1
w[m-1] = s
 
def se(i, b):
     m = 0
     while b[i] >= 0:
          i = b[i]
          m += 1
     return i,m
 
for j in range(m-1):
     i = m-j-1
     i1,i2 = a[i],A[i]
     p1,m1 = se(i1, b)
     p2,m2 = se(i2, b)
     if p1 != p2:
          if d[m1] < d[m2]:
               (p1,p2) = (p2,p1)
          b[p2] = p1
          s -= me[p1]*me[p2]
          me[p1] += me[p2]
          me[p2] = 0
          d[p1] = max(d[p1],d[p2]+1)
     w[i-1] = s
         
for i in range(m):
     print(w[i])

Measured memory_bytes: 62680
n, T = map(int, input().split())
c = [0] * n
t = [0] * n
for i in range(n):
    c[i], t[i] = map(int, input().split())

ans = 1000000
for i in range(n):
    if t[i] <= T:
        ans = min(ans, c[i])

if ans != 1000000:
    print(ans)
else:
    print("TLE")


Measured memory_bytes: 3060
#include <iostream>
#include <cstdlib>
#include<vector>
#include<string>
#include<cmath>
#include <algorithm>
#include<complex>

using namespace std;
typedef long long LL;


int main() {
	LL n,total=0;
	int l[10000],r[10000];
	
	cin >> n;

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

	for (int j = 0; j < n; j++)
	{
		total+=(r[j] - l[j]) + 1;
	}

	cout << total<<endl;

	return 0;
}


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

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

    int N = n % 10;

    if (N==2||N==4||N==5||N==7||N==9) {
        cout << "hon" << endl;
    }
    else if (N==3) {
        cout << "bon" << endl;
    }
    else {
        cout << "pon" << endl;
    }

    
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
int bp(int pow, int n){
    int d = 1;
    while(n)
    {
        if(n%2==1)d=(d*pow)%mod;
        pow=(pow*pow)%mod;
        n/=2;
    }
    return d;
}
void solve(){
    int n;
    cin>>n;
    map<int , int>u;
    for(int i = 0; i < n-1; i++){
        int x;
        cin>>x;
        u[x]++;
    }   
    for(int i = 1; i <= n; i++)cout<<u[i]<<"\n";
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 16124
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

// author:Swastik Banerjee

using namespace std;

typedef long long ll;
#define MOD 1000000007

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


  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  ll t = ceil((long double)(c) / (long double)(b));
  ll ak = ceil((long double)(a) / (long double)(d));

  //cout << ak << " " << t << endl;

  if (ak < t)
    cout << "No\n";
  else
    cout << "Yes\n";
}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 100000007
typedef long long ll;
using namespace std;

int main(){
	string a,b;
	cin>>a>>b;
	bool ok=true;
	lol(i,3)if(a[i]!=b[2-i])ok=false;
	cout<<(ok?"YES":"NO")<<endl;
	return 0;
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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;}
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}

int main(){

  ll n,k;
  cin>>n>>k;
  vector<ll> p(n),c(n);
  cin>>p>>c;
  for(auto& pi:p)pi--;

  ll ans = -INF;
  rep(i,n){
    int cur = i;
    int _k = k;
    ll tmp = 0;
    vector<int> ord(n,-1);
    int od = 1;
    while(_k--){
      tmp += c[p[cur]];
      chmax(ans,tmp);
      ord[p[cur]] = od++;
      cur = p[cur];
      if(ord[p[cur]]!=-1)break;
    }
    if(_k==-1)continue;
    int loop_s = p[cur];
    ll loop_len = ord[cur]-ord[loop_s]+1;
    ll loop_num = (k-ord[cur])/loop_len;
    ll nokori = (k-ord[cur])%loop_len;
    ll ritoku = c[p[loop_s]];
    int v = p[loop_s];
    while(v!=loop_s){
      ritoku += c[p[v]];
      v = p[v];
    }
    if(ritoku>0)tmp += ritoku*loop_num;
    ll tmp2 = tmp-ritoku;
    chmax(ans,tmp);
    while(nokori--){
      tmp += c[p[cur]];
      cur = p[cur];
      chmax(ans,tmp);
    }
    v = loop_s;
    rep(_,loop_len){
      tmp2 += c[v];
      chmax(ans,tmp2);
      v = p[v];
    }
  }
  cout<<(ans)<<endl;

}

Measured memory_bytes: 3732
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		Set<Integer> T = new TreeSet<Integer>();
		
		for(int i=0;i<n;i++){
			T.add(sc.nextInt());
		}
		int p = sc.nextInt();
		int cnt=0;
		for(int i=0;i<p;i++){
			int t= sc.nextInt();
			if(T.contains(t)){
				cnt++;
			}
		}
		System.out.println(cnt);
		
	}
}

Measured memory_bytes: 80604
#include <bits/stdc++.h>
using namespace std;
void alert(vector<int> vec){
  for(int i=0; i<vec.size(); i++) cout << vec.at(i) << " ";
  cout << vec.at(vec.size()-1) << endl;
}


int main(){
  int64_t H, W;
  cin >> H >> W;
  int64_t ans;
  if(H==1 || W==1) ans = 1;
  else{
    ans = (H/2)*(W/2)*2;
    ans += (H%2)*(W/2+W%2)+(W%2)*(H/2);
  }
  cout << ans << endl;
}



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

int main() {
    uint64_t N, A, B, C, D, E;
    std::cin >> N >> A >> B >> C >> D >> E;

    uint64_t min = std::min({A, B, C, D, E});
    
    if (N % min == 0) {
        std::printf("%lu\n", N / min + 4);
    } else {
        std::printf("%lu\n", (N / min + 1) + 4);
    }

    return 0;
}


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

int n;
std::vector<int> h;

void input(){
    std::cin>>n;
    h.resize(n);
    for(int i=0;i<n;i++)std::cin>>h[i];
}

int main(){
    input();
    bool ans = true;
    for(int i=n-2;i>=0;i--){
        if(h[i+1]<h[i]){
            if(h[i]==h[i+1]+1)h[i]--;
            else ans = false;
        }
    }
    std::string res;
    if(ans)res = "Yes";
    else res = "No";
    std::cout<<res<<std::endl;
}

Measured memory_bytes: 640
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long val = 0;
        if(n < 9){System.out.println(n);return;}
        else{
            Deque<Long> l = new ArrayDeque<>();
            for(long i = 1; i <= 9; i++){
                l.add(i);
            }
            for(int i = 0; i < n; i++){
                val = l.poll();
                if(val%10!=0){l.add(val*10 + val%10-1);}
                l.add(val*10+val%10);
                if(val%10!=9){l.add(val*10+val%10+1);}
            }
        }
        System.out.println(val);
    }
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    string S,T; cin >> S >> T;
    cout << T << S << endl;
}

Measured memory_bytes: 256
import sys

x, y = map(int, sys.stdin.readline().rstrip().split())
count = 0
if abs(x) < abs(y):
    if x < 0:
        count += 1
        x = -x
    if y < 0:
        count += 1
        y = -y
    count += abs(y - x)
    print(count)
else:
    if x > 0:
        count += 1
        x = -x
    if y > 0:
        count += 1
        y = -y
    count += abs(y - x)
    print(count)

Measured memory_bytes: 3064
import sys
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    H, W = map(int, readline().split())
    L = list(list(map(int, readline().split())) for _ in range(10))
    path = dijkstra(csr_matrix(L))
    ans = 0
    for i in range(H):
        A = list(map(int, readline().split()))
        for j in range(W):
            a = A[j]
            if a!=-1:
                ans += path[a][1]
    print(int(ans))

if __name__ == '__main__':
    main()

Measured memory_bytes: 17060
import math
n = int(input())
p1 = (0, 0)
p2 = (100, 0)

def kock(n, p1, p2):
    if n == 0:
        return
    
    sx = 2 / 3 * p1[0] + 1 / 3 * p2[0]
    sy = 2 / 3 * p1[1] + 1 / 3 * p2[1]
    s = (sx, sy)
    
    tx = 1 / 3 * p1[0] + 2 / 3 * p2[0]
    ty = 1 / 3 * p1[1] + 2 / 3 * p2[1]
    t = (tx, ty)
    
    ux = math.cos(math.radians(60)) * (tx-sx) - math.sin(math.radians(60)) * (ty-sy) + sx
    uy = math.sin(math.radians(60)) * (tx-sx) + math.cos(math.radians(60)) * (ty-sy) + sy
    u = (ux, uy)
    
    kock(n-1, p1, s)
    print (*s)
    kock(n-1, s, u)
    print (*u)
    kock(n-1, u, t)
    print (*t)
    kock(n-1, t, p2)
    
print(*p1)
kock(n, p1, p2)
print(*p2)


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

int main() {
  int N;
  cin >> N;
  int l,r;
  int x=0;
  
  for(int i = 0; i<N; i++){
    cin >> l >> r;
    x += r-l+1;
  }
  
  cout << x << endl;
}


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

int main(int argc, char const *argv[])
{
    int a, b;
    cin >> a >> b;

    int x = a * b;
    if (x % 2 == 0)
    {
        cout << "Even" << endl;
    }
    else
    {
        cout << "Odd" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX 2000000
#define VMAX 11000
int A[MAX],C[VMAX],B[MAX];
int n;
void countingSort(int *A,int *B,int vmax){
    for(int i=0;i<=vmax;i++){
        C[i]=0;
    }
    for(int i=0;i<n;i++){
        C[A[i]]++;
    }
    for(int i=1;i<=vmax;i++)
        C[i]=C[i]+C[i-1];
    for(int i=n-1;i>=0;i--){
        B[C[A[i]]-1]=A[i];
        C[A[i]]--;
    }
}
int main(){
    cin>>n;
    int vmax=-1;
    for(int i=0;i<n;i++){
         cin>>A[i];
         vmax=max(vmax,A[i]);
    }
    countingSort(A,B,vmax);
    for(int i=0;i<n;i++){
        if(i)
            cout<<" ";
        cout<<B[i];
    }
    cout<<endl;
    return 0; 
}


Measured memory_bytes: 18752
#include<iostream>
    #include<string>
     
    using namespace std;
     
    int main()
    {
        string a, b, c;
        cin>>a>>b>>c;
        a[0] -= 32;
        b[0] -= 32;
        c[0] -= 32;
        cout<<a[0]<<b[0]<<c[0]<<endl;
        return 0;
    }

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


int main() {
    int H, W;
    std::cin >> H >> W;

    std::vector<std::string> grid(H);
    std::vector<std::vector<int>> hist_h(H, std::vector<int>(W, 0));
    std::vector<std::vector<int>> hist_v(H, std::vector<int>(W, 0));

    for (int i = 0; i < H; i++) {
        std::cin >> grid[i];
    }

    for (int i = 0; i < H; i++) {
        int min = 0, cnt = 0;
        for (int j = 0; j < W; j++) {
            if (grid[i][j] == '.') {
                cnt++;
            } else {
                for (int k = min; k < j; k++) {
                    hist_h[i][k] = cnt;
                }
                hist_h[i][j] = 0;
                cnt = 0;
                min = j + 1;
            }
        }
        for (int k = min; k < W; k++) {
            hist_h[i][k] = cnt;
        }
    }

    for (int j = 0; j < W; j++) {
        int min = 0, cnt = 0;
        for (int i = 0; i < H; i++) {
            if (grid[i][j] == '.') {
                cnt++;
            } else {
                for (int k = min; k < i; k++) {
                    hist_v[k][j] = cnt;
                }
                hist_v[i][j] = 0;
                cnt = 0;
                min = i + 1;
            }
        }
        for (int k = min; k < H; k++) {
            hist_v[k][j] = cnt;
        }
    }

    int max = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            max = std::max(max, hist_h[i][j] + hist_v[i][j]);
        }
    }
    std::cout << max - 1 << std::endl;
}


Measured memory_bytes: 42584
#include <bits/stdc++.h>
#include <time.h>
#define l(x) 2*x
#define r(x) (2*x+1)
using namespace std;
typedef long long LL;
const int NMAX = 300505;
const LL llinf = 1e18;
const int dx[] = {0, 0, -1, 1};
const int dy[] = {1, -1, 0, 0};

int N, K;

int main(){
    cin>>N>>K;
    if(K == 0){
        cout<<(1LL*N*N)<<"\n";
        return 0;
    }
    LL rs =0;
    for(int i=K+1; i<=N; ++i){
        int md = i;
        int chn = md - K;
        rs += chn * ((N+1)/md);
        int other = N+1 - md*((N+1)/md);
        rs += max(0, other-K);
        //cout<<md<<" "<<((N+1)/md)<<" "<<other<<"\n";
    }
    cout<<rs<<"\n";


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main(){
    string S;
    cin >> S;
    string ss = "";

    for(int i=S.size()-1; i>=0; i--) {
        ss += S[i];
        if(ss == "maerd") ss="";
        else if(ss=="remaerd") ss="";
        else if(ss=="esare") ss="";
        else if(ss=="resare") ss="";
    }
    if(ss == "") cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3720
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const n = +input[0];
const a = [];
for (let i = 0; i < n; i++) {
  const sp = input[i + 1].split(" ");
  a.push({ name: sp[0], score: +sp[1], id: i + 1 });
}

a.sort((x, y) => {
  if (x.name < y.name) return -1;
  if (x.name > y.name) return 1;
  return y.score - x.score;
});

for(const {id} of a){
  console.log(id);
}


Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
int main() {
	int64_t a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int64_t ans = 0;
	int64_t merged = min(x, y);
	if (2 * c < (a + b)) {
		ans += merged * 2 * c;
	}
	else {
		ans += merged * (a + b);
	}
	if (x == y) {}
	else if (x > y){
		if (2 * c < a) {
			ans += (x - y) * 2 * c;
		}
		else {
			ans += (x - y) * a;
		}
	}
	else{
		if (2 * c < b) {
			ans += (y - x) * 2 * c;
		}
		else {
			ans += (y - x) * b;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define Max(a,b) ((a)>(b)?(a):(b)) 
#define Min(a,b) ((a)<(b)?(a):(b)) 
 
//FILE *fp,*fp2;
//fp=fopen("input.txt","r");
//fp2=fopen("output.txt","w");
 
int main()
{
    LL int a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	a=100*a;
	b=100*b;
	LL int maxn=1,suger=0;
    for(int i=1;i*a<=f;i++)
        for(int j=0;i*a+j*b<=f;j++)
            for(int s=0;(i*a+j*b+s*c<=f)&&(s*c<=(i*a+j*b)*e/100);s++)
                for(int k=0;(i*a+j*b+s*c+k*d<=f)&&(s*c+k*d<=(i*a+j*b)*e/100);k++)
                {
                    if(maxn==1&&suger==0)
                    {
                        maxn=(i*a+j*b+s*c+k*d);
                        suger=s*c+k*d;
                    }
                    if((s*c+k*d)*maxn>(i*a+j*b+s*c+k*d)*suger)
                    {
                        maxn=(i*a+j*b+s*c+k*d);
                        suger=s*c+k*d;
                    }
                    
                }
    cout<<maxn<<" "<<suger;
    return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    a, b, c = get_li()
    if a < b < c:
        print("Yes")
    else:
        print("No")
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()



Measured memory_bytes: 6904
n, m = map(int, input().split())
h_array = [int(x) for x in input().split()]
higest = [True for x in range(n)]
res = 0
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if h_array[b] == h_array[a]:
        higest[b] = False
        higest[a] = False
    elif h_array[a] >= h_array[b]:
        higest[b] = False
    elif h_array[b] >= h_array[a]:
        higest[a] = False

print(higest.count(True))



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

#define MOD 1000000007
typedef unsigned long long ull;

int a, b;
int main() {
  cin >> a >> b;
  int ans = a - (b * 2);
  if (ans < 0)
    cout << "0" << endl;
  else
    cout << ans << endl;
}


Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <numeric>
#include <cmath>

#define rep(i,n) for (int i = 0; i < n; ++i)
#define repr(i,n) for (int i = n; i > 0; --i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MAX = 100;
const int INF = (1<<12);

int main() {
  int a;
  cin >> a;
  cout << a + pow(a,2) + pow(a,3) << endl;
  return 0;
}

Measured memory_bytes: 4284
import java.util.*;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner sc = new Scanner(System.in);

        // 整数の入力
        int n = sc.nextInt();
        ArrayList<String> list = new ArrayList<>();

        String s = sc.next();
        list.add(s);
        String lastWord = s.split("")[s.length() - 1];

        boolean ruled = true;

        // 文字列の入力
        for(int i = 1; i < n; i++) {
            String value = sc.next();
            if (list.contains(value)) {
                ruled = false;
                break;
            } else if (!value.substring(0, 1).equals(lastWord)) {
                ruled = false;
                break;
            }
            lastWord = value.split("")[value.length() - 1];
            list.add(value);
        }

        // 出力
        System.out.println(ruled ? "Yes" : "No");
    }
}

Measured memory_bytes: 23252
n,m = map(int,input().split())
a = list(map(int,input().split()))
sums = [0]
sum = 0
ans = 0

for i in range(n):
    sum += a[i]
    sums.append(sum)



dic = {}

for i in range(n+1):
    dic.setdefault(str(sums[i]%m),0)
    dic[str(sums[i]%m)] += 1

for key in dic.keys():
    k = dic[key]
    if k>1:
        ans += k*(k-1)//2

print(ans)


Measured memory_bytes: 19200
#include<bits/stdc++.h>
#define oo 1000000007
using namespace std;
long long dp[10005][105][2],d;
vector<long long>num;
string s;
long long solve(long long idx, long long sum, long long tight)
{
    if(idx==num.size())
        return(sum%d==0);
    if(dp[idx][sum][tight]!=-1)
        return dp[idx][sum][tight];
    long long k=(tight)?num[idx]:9;
    long long res=0;
    for(int i=0;i<=k;i++)
    {
        long long newtight=(num[idx]==i)?tight:0;
        res=(res+solve(idx+1,(sum+i)%d,newtight))%oo;
    }
    dp[idx][sum][tight]=res;
    return res;
}
long long khoitao(string s)
{
    num.clear();
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<=s.size()-1;i++)
        num.push_back(s[i]-'0');
    return solve(0,0,1);
}
main()
{
    cin>>s>>d;
    cout<<(khoitao(s)-1+oo)%oo;
}


Measured memory_bytes: 17664
# coding: utf-8
# Your code here!
A=[]
Bingo=[]
for i in range(3):
    row=list(map(int,input().split()))
    A.append(row)
    Bingo.append([0,0,0])

N=int(input())

for i in range(N):
    num=int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k]==num:
                Bingo[j][k]=1
flg=False
for i in range(3):
    if sum(Bingo[i])==3:
        flg=True

for i in range(3):
    if Bingo[0][i]+Bingo[1][i]+Bingo[2][i]==3:
        flg=True
if Bingo[0][0]+Bingo[1][1]+Bingo[2][2]==3:
    flg=True

if Bingo[0][2]+Bingo[1][1]+Bingo[2][0]==3:
    flg=True

if flg:
    print("Yes")
else:
    print("No")




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

int main()
{
    int N = 0;
    char S[200001];
    int w_num = 0;
    long ans = 0;

    int i = 1;
    while(cin >> S[i++]) {
        N++;
    }

    for(int i = N; i >= 1; i--) {
        if(S[i] == 'B') {
            ans += w_num;
        }
        if(S[i] == 'W') {
            w_num++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring> 
#include <cmath> 
#include <algorithm> 
using namespace std; 
const int MAX_N = 305;
int N, K, Mod; 
int C[MAX_N][MAX_N], f[MAX_N][MAX_N], sum[MAX_N][MAX_N]; 

int main () { 
	cin >> N >> K >> Mod; 
	for (int i = 0; i <= N; i++) { 
		C[i][0] = C[i][i] = 1; 
		for (int j = 1; j < i; j++) C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % Mod; 
	} 
	for (int i = 0; i <= K; i++) f[1][i] = 1, sum[1][i] = K - i + 1; 
	for (int i = 2; i <= N + 1; i++) { 
		for (int j = 0; j <= K; j++) 
			for (int k = 1; k < i; k++) 
				f[i][j] = (f[i][j] + 1ll * f[i - k][j] * sum[k][j + 1] % Mod * C[i - 2][k - 1]) % Mod; 
		for (int j = K; ~j; j--) sum[i][j] = (f[i][j] + sum[i][j + 1]) % Mod; 
	} 
	printf("%d\n", f[N + 1][0]); 
    return 0; 
} 

Measured memory_bytes: 1280
#coding: utf-8

N = int(input())
S = str(input())

line = []
E = 0
W = 0
error = 0

E = S.count('E')
W = S.count('W')

counter = 0

for i in range(N):
    if(i==0):
        if(S[i]=='E'):
            counter = E
            counter -= 1
        else:
            counter = E
    else:
        if(S[i]=='E'):
            counter -= 1
        if(S[i-1]=='W'):
            counter += 1

    line.append(counter)

print(min(line))

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





int main(){
    
 
    int n, m;      cin >> n >> m;
    vector<bool> seen(n);
    vector<vector<bool>> g(n, vector<bool>(n));
    for(int i=0; i<m; i++){
        int a, b;   cin >> a >> b;
        a--;    b--;
        g.at(a).at(b) = g.at(b).at(a) = true;
    }
    vector<int> route(n);
    for(int i=0; i<n; i++)  route.at(i)=i;

    int cnt=0;

    do{
        if(route[0]!=0) break;
        bool flag=true;
        for(int i=0; i<n-1; i++){
            int from = route.at(i);
            int to = route.at(i+1);
            if(!g[from][to]) flag = false;
        }
        if(flag) cnt += 1;

    }while(next_permutation(route.begin(), route.end()));

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
char c;
cin>>c;
if(c=='a'){
cout<<"vowel"<<endl;
}
else if(c=='i'){
cout<<"vowel"<<endl;
}
else if(c=='u'){
cout<<"vowel"<<endl;
}
else if(c=='e'){
cout<<"vowel"<<endl;
}
else if(c=='o'){
cout<<"vowel"<<endl;
}
else{
cout<<"consonant"<<endl;
}
}


Measured memory_bytes: 256
import java.util.*;
class Main{
    static long dp(int i, long sum, int flag,long a[]){
        long t[] = new long [a.length];
        for(int j = 0; j < a.length; j++){
            t[j] = a[j];
        }
        if(i != 0 && flag == 0) t[i] = t[i-1]*10 + t[i];
        if(i != 0 && flag == 1) sum += t[i - 1]; 
        if(a.length-1 == i) return sum += t[t.length - 1];
        return dp(i+1,sum, 0, t) + dp(i+1, sum, 1, t);
    }
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String s = stdIn.next();
        long a[] = new long[s.length()];
        for(int i = 0; i < a.length; i++){
            a[i] = s.charAt(i) - '0';     
        }
        long ans = dp(0, 0, 0, a);
        System.out.println(ans);
    }
}


Measured memory_bytes: 22612
#include <iostream>
#include <queue>
#include <string>
#include <map>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <vector>
#include <stack>
#include <algorithm>
#include <string.h>
#include <set>
#include <cstdlib>
#include <iostream>
#include <bits/stdc++.h>
#define sz(x)       x.size()
#define pii         pair<int,int> 
#define ll          long long int 
#define sl(n)       scanf("%lld",&n)
#define s(n)        scanf("%d",&n)
#define f(i,n)      for(int i=0;i<n;++i)
#define fo(i,n)     for(int i=1;i<=n;++i)
#define fnm(n,m)    for(ll i=n;i<m+1;++i)
#define pb          push_back
#define pf          printf
#define F           first
#define S           second
#define srt(v)      sort(v.begin(),v.end());
#define srtc(v,cmp) sort(v.begin(),v.end(),cmp);
#define srta(v,n)   sort(v,v+n);
const ll            LL_INF=0x3f3f3f3f3f3f;
const ll            MOD=1073741824;


using namespace std;


int T;
ll n,m,k;
ll inp;
int arr[100005];
set<int>st;
string str;


void gen(){
    
}

void solve(){
    sl(n);
    sl(m);
    sl(k);
    sl(inp);
    ll ans=min(n,inp);
    if(ans<inp)inp=max((ll)0,inp-m);
    if(ans<inp)ans-=(inp-ans);
    pf("%lld",ans);
}


int main(){
    // pf("\t\t\t***************************************************************************\n\n");
    // pf("\t\t\t***************************************************************************\n\n");
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // s(T);
    T=1;
    f(i,T)solve();
    pf("\n");

    return 0;
} 

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

int main() 
{
	long long a[6], n, mini = 1e16;
	cin >> n;
	for (int i = 1; i <= 5; i++)
	{
		cin >> a[i];
		mini = min(mini, a[i]);
	}
	
	if (n % mini) cout << n/mini + 5;
	else cout << n/mini + 4;
}

Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=((int)(x) - 1 * 100);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
using namespace std;
ll n;
int main() {
	cin >> n;
	string s;
	map<char, int> mp3;
	map<char, int> mp1;
	rep(i, n) {
		map<char, int> mp2;
		cin >> s;
		rep(j, s.size()) {
			mp2[s[j]]++;
		}
		for (auto kv : mp2) {
			if (!i) {
				mp3[kv.first] = mp2[kv.first];
			}
		
			else if (mp1[kv.first] > kv.second) {
				mp3[kv.first] = kv.second;
			}
			else  {
				mp3[kv.first] = mp1[kv.first];
			}
		}
		mp1.erase(mp1.begin(), mp1.end());
		for (auto kv : mp3) mp1[kv.first] = kv.second;
		mp3.erase(mp3.begin(), mp3.end());
	}
	for (auto kv : mp1) {
		rep(i, kv.second) {
			cout << kv.first;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
S="012 345 678 036 147 258 048 246 "
A=sum([input().split()for i in range(4)],[])
for b in [input()for i in range(int(A[9]))]:
  if b in A:
    S=S.replace(str(A.index(b)),"")
print("YNeos"[not"  "in S::2])

Measured memory_bytes: 3060
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, x) for(ll i = 0; i < x; i++)
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9+7;
const ll N = 5e5+5, inf = 1e9+5000;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n; cin >> n;
  vector<int> L(n);
  rep (i, n) cin >> L[i];

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      for (int k = j+1; k < n; k++) {
        if (L[i]!=L[j] && L[i]!=L[k] && L[j]!=L[k]) {
          vector<int> sides = {L[i], L[j], L[k]};
          sort(begin(sides), end(sides));
          if (sides[0] + sides[1] > sides[2]) {
            ans++;
          }
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3660
import math
def plot(x,y):
    print(f'{x:.8f} {y:.8f}')
def koch(n,x1,y1,x2,y2):
    if n==0:
        plot(x1,y1)
        return
    sx=(2*x1+x2)/3
    sy=(2*y1+y2)/3
    tx=(x1+2*x2)/3
    ty=(y1+2*y2)/3
    ux=(tx-sx)*(1/2)-(ty-sy)*(math.sqrt(3)/2)+sx
    uy=(tx-sx)*(math.sqrt(3)/2)+(ty-sy)*(1/2)+sy
    koch(n-1,x1,y1,sx,sy)
    koch(n-1,sx,sy,ux,uy)
    koch(n-1,ux,uy,tx,ty)
    koch(n-1,tx,ty,x2,y2)
    
n=int(input())
koch(n,0,0,100,0)
plot(100,0)


Measured memory_bytes: 5752
#include <iostream>

using namespace std;

int main()
{
	double h, max = 0.0, min = 3776.0;
	while (cin >> h)
	{
		if (h > max) max = h;
		if (h < min) min = h;
	}

	cout << max - min << endl;

	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main(void) {
    string S;
    string T;
    cin >> S;
    cin >> T;
    
    int N = S.size();
    
    for(int i = 0; i < N; i++) {
        int j = 0;
        while(S[(i+j)%N] == T[j]){
            j++;
            if(j == N-1) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;

}

Measured memory_bytes: 256
#include <cstdint>
#include <string>
#include <utility>

using namespace std;

#define MAX_LEN 1001
static size_t memo[MAX_LEN][MAX_LEN];

size_t lcs(string &a, string &b)
{
  for (uint32_t i = 0; i <= a.size(); i++) {
    memo[i][0] = 0;
  }

  for (uint32_t i = 0; i <= b.size(); i++) {
    memo[0][i] = 0;
  }

  for (uint32_t i = 1; i <= a.size(); i++) {
    for (uint32_t j = 1; j <= b.size(); j++) {
      if (a[i - 1] == b[j - 1]) {
        memo[i][j] = memo[i - 1][j - 1] + 1;
      } else {
        memo[i][j] = max(memo[i - 1][j], memo[i][j - 1]);
      }
    }
  }

  return memo[a.size()][b.size()];
}

#include <iostream>

int32_t main()
{
  uint32_t num;
  cin >> num;

  for (uint32_t i = 0; i < num; i++) {
    string a, b;
    cin >> a;
    cin >> b;
    cout << lcs(a, b) << endl;
  }

  return 0;
}

Measured memory_bytes: 10984
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
using namespace std;
#define LL long long
#define MAXN 200010
map<LL,int>G;
LL col[MAXN];
int vis[MAXN],n,a,b;
int Adj[MAXN],V[MAXN],nxt[MAXN],c;
void AddEdge(int u,int v)
{
	c++;V[c]=v,nxt[c]=Adj[u];
	Adj[u]=c;
}
void dfs1(int u)
{
	vis[u]=1;
	col[u]=col[0];
	for(int i=Adj[u];i;i=nxt[i])
		if(!vis[V[i]])
			dfs1(V[i]);
}
void dfs2(int u)
{
	vis[u]=0;
	col[u]=(col[u]<<20)+col[0];
	G[col[u]]++;
	for(int i=Adj[u];i;i=nxt[i])
		if(vis[V[i]])
			dfs2(V[i]);
}
int main()
{
	int u,v;
	scanf("%d%d%d",&n,&a,&b);
	for(int i=0;i<a;i++)
	{
		scanf("%d%d",&u,&v);
		AddEdge(u,v);
		AddEdge(v,u);
	}
	for(int i=1;i<=n;i++)
		if(!vis[i])
		{
			col[0]++;
			dfs1(i);
		}
	memset(Adj,0,sizeof Adj);
	col[0]=0,c=0;
	for(int i=0;i<b;i++)
	{
		scanf("%d%d",&u,&v);
		AddEdge(u,v);
		AddEdge(v,u);
	}
	for(int i=1;i<=n;i++)
		if(vis[i])
		{
			col[0]++;
			dfs2(i);
		}
	for(int i=1;i<=n;i++)
		printf("%d ",G[col[i]]);
}

Measured memory_bytes: 16896
#include<bits/stdc++.h>
using namespace std;
string print(int dp[][3001],int i,int j,string t,string s)
{ if(i==0||j==0)
return "";
    string ans;
    int vr=dp[i][j];
    if(vr==dp[i-1][j-1]+1&&s[i-1]==t[j-1])
    {ans=ans+t[j-1];
    ans=ans+print(dp,i-1,j-1,t,s);
    }
    else if(vr==dp[i-1][j])
    {
        ans=ans+print(dp,i-1,j,t,s);
    }
    else
        ans=ans+print(dp,i,j-1,t,s);
    return ans;
}

 int  main()
{ string s,t;
cin>>s>>t;
int n1,n2;
n1=s.length();
n2=t.length();
int dp[n1+1][3001]={0};
for(int i=0;i<=n1;i++)
{ for(int j=0;j<=n2;j++)
    {  if(i==0||j==0)
    { dp[i][j]=0;
        continue;
    }

        if(s[i-1]==t[j-1])
        dp[i][j]=1+dp[i-1][j-1];
        else
            dp[i][j]=0;

        dp[i][j]=max(dp[i][j],max(dp[i-1][j],dp[i][j-1]));

    }
}
//cout<<dp[n1][n2]<<endl;

string ans="";

ans=print(dp,n1,n2,t,s);

for(int i=ans.length()-1;i>=0;i--)
    cout<<ans[i];


}


Measured memory_bytes: 60672
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;

int main()
{
    int s[3];
    cin>>s[0]>>s[1]>>s[2];
    sort(s,s+3);
    if(s[0]+s[1]==s[2])
        cout<<"Yes"<<endl;
    else cout<<"No";

}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) throws java.io.IOException{
        Scanner scan = new Scanner(System.in);
        int w=scan.nextInt();
        int [] line =new int[w+1];
        for(int i=1;i<w+1;i++)
        	line[i]=i;
        int n=scan.nextInt();
        scan.useDelimiter(",|\\n");
        while(n!=0){
        	
        	int a=scan.nextInt();
        	int b=scan.nextInt();
        	line[a]=line[a]^line[b];
        	line[b]=line[a]^line[b];
        	line[a]=line[a]^line[b];
        n--;	
        }
        for(int i =1;i<w+1;i++)
        System.out.println(line[i]);
    }
}

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

using namespace std;

typedef long long ll; 
const int maxs = 2000001;

// int main(){

//    ll t, i, j, a, b, c, f, s, k, l, resa, resb, resc;

//    cin>>t;

//    while(t--){
//         cin>>a>>b>>c;
//         ll res = 1000000;
//         for(i = 1;i <= b;i++){
//             for(j = 1;j <= min(a, i);j++){
//                  s = i;
//                  f = j;
//                //  cout<<f<<" "<<s<<"\n";
//                  if(s%f!=0){
//                      continue;
//                  }
//                  else{
//                    k = s;
//                    while(k <= c){
//                        k += s;
//                    }
//                    if(k != c)
//                      k -= s;
//                    res = min(res, a-f+b-s+c-k);  
//                    //cout<<f<<" "<<s<<" "<<k<<"\n";
//                    resa = f;
//                    resb = s;
//                    resc = k;


//                  }
//             }
//         }
//         cout<<res<<"\n";
//         cout<<resa<<" "<<resb<<" "<<resc<<"\n";
//    }
// }


int main(){
   ll n, i, j;

   cin>>n;

     ll h[n];

     for(i =0 ;i < n;i++){
         cin>>h[i];
     }
   
    ll dp[n];

    memset(dp, 0, sizeof(dp));
    dp[0] = 0;

    for(i =1;i < n;i++){
        dp[i] = 10000000000;
    }

    for(i = 0;i < n;i++){
        if(i+1<n){
            if(dp[i]+abs(h[i+1]-h[i]) < dp[i+1]){
                dp[i+1] = dp[i]+abs(h[i+1]-h[i]);
            }
        }  
        if(i+2<n){
            if(dp[i]+abs(h[i+2]-h[i]) < dp[i+2]){
                dp[i+2] = dp[i]+abs(h[i+2]-h[i]);
            }
        }
    }
    cout<<dp[n-1]<<"\n";
}

Measured memory_bytes: 1792
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = list(map(int, input().split()))
    if 1 in n and 7 in n and 4 in n and 9 in n:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define Inf 1000000000
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int main() {
	ll N, M, V, P;
	cin >> N >> M >> V >> P;
	vl A(N);
	rep(i, N) {
		cin >> A[i];
	}
	sort(A.begin(), A.end(), greater<ll>());
	ll L = 0;
	ll R = N;
	while (1) {
		ll m = (L + R) / 2;
		if (L == m)
			break;
		bool can = true;
		if (m >= P) {
			ll inc_begin = P - 1;
			ll inc_end = m;
			if (A[inc_begin] - A[inc_end] > M)
				can = false;
			else {
				ll Asum = 0;
				for (int i = inc_begin; i < inc_end; i++) {
					Asum += (A[m] + M - A[i]);
				}
				if (Asum < (V + (inc_end - inc_begin) - N) * M) {
					can = false;
				}
			}
		}
		if (can)
			L = m;
		else
			R = m;
	}
	ll ans = L + 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
n, t = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]

min_rate = a[0]
max_diff = 0
for item in a[1:]:
    if item < min_rate:
        min_rate = item
    else:
        max_diff = max(max_diff, item-min_rate)

min_rate = a[0]
problems = []
to_solve = [0]
has_problem = False
for item in a[1:]:
    if item < min_rate:
        min_rate = item
        if has_problem:
            problems.append(to_solve)
        to_solve = [0]
        has_problem = False
    elif item == min_rate:
        to_solve.append(0)
    elif item == min_rate + max_diff:
        to_solve.append(1)
        has_problem = True 
if has_problem:
    problems.append(to_solve)
print(len(problems))

Measured memory_bytes: 14940
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
using namespace std;

const double PI=acos(-1);

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        int t = i, sum = 0;
        while(t != 0){
            sum += t % 10;
            t /= 10;
        }
        if(sum >= a && sum <= b) cnt += i;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
a = Array.new(4, 0)

10.times do
  a[3] = gets.chomp.to_i
  3.times do |i|
    if a[2-i] < a[3-i]
      a[2-i], a[3-i] = a[3-i], a[2-i]
    else
      break
    end
  end
end

print a[0], "\n",  a[1], "\n", a[2], "\n"



Measured memory_bytes: 6860
S = list(input())
n = len(S)
total = 0
for i in range(2**(n-1)):
    b = bin(i)[2:].zfill(n-1)
    t = S[:]
    for j in range(n):
        if j == 0:
            continue
        if b[j-1] == '1':
            t[j] = '+' + t[j]
    total += eval(''.join(t))
print(total)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{

	static final Scanner s=new Scanner(System.in);

	public static void main(String args[]){
		int a=s.nextInt(),b=s.nextInt();
		double d = Math.toRadians(s.nextInt());
		System.out.println(a*b*Math.sin(d)/2);
		System.out.println(
				a+b+
				Math.sqrt(
						a*a+b*b-2*a*b*Math.cos(d)
						)
				);
		System.out.println(b*Math.sin(d));
	}
}

Measured memory_bytes: 26324