akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<cstring>

using namespace std;

#ifdef LDEBUG
#define debug(x) cout << #x << ":" << x << endl
#else
#define debug(...)
#endif

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

typedef unsigned long long u64;
typedef long long i64;

int n;
int h[100];

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

        cin >> n;

        REP(i,n)
                cin >>  h[i];

        int r = 0;

        int m = 0;
        REP(i,n) {
                if (m <= h[i]){
                        m = h[i];
                        r++;
                }
        }

        cout << r << endl;


        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string a;
  cin >> a;
  for(int i=0;i<2;i++)
  {
    for(int j=0;j<2;j++)
    {
      for(int k=0;k<2;k++)
      {
        int ans=(a[0]-48);
        if(i==0)
          ans+=a[1]-48;
        else ans-=a[1]-48;
        if(j==0)
          ans+=a[2]-48;
        else ans-=a[2]-48;
        if(k==0)
          ans+=a[3]-48;
        else ans-=a[3]-48;
        if(ans==7)
        {
          printf("%c",a[0]);
          if(i==0)
            printf("+");
          else printf("-");
          printf("%c",a[1]);
          if(j==0)
            printf("+");
          else printf("-");
          printf("%c",a[2]);
          if(k==0)
            printf("+");
          else printf("-");
          printf("%c=7",a[3]);
          return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
 
typedef long long ll;
 
 
int main(){
	string s;
	int n;
	cin >> n;
	cin >> s;
	
	int res = 0;
	for(int i=0;i<n;++i){
		if(i == 0 || s[i-1] != s[i]) res++;
	}
	cout << res <<endl;
	
	return 0;
}



Measured memory_bytes: 512
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
 
using namespace std; 


int main(){

	int n,k;
	cin>>n>>k;

	vector<int> d(10);
	for(int i=0;i<k;i++){
		int x;
		cin>>x;
		d[x]++;
	}

	for(int i=n;;i++){
		string s=to_string(i);
		bool ok=true;
		for(int j=0;j<s.size();j++){
			if( d[s[j]-'0'] ) ok=false;
		}
		if(ok){
			cout<<i<<endl;
			break;
		}
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

constexpr long double pi = acos(-1.0L);

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  long double a, b, x; cin >> a >> b >> x;
  x /= a;
  auto chk = [&](long double th) -> bool {
    if (th < atan2(b, a)) {
      return a * b - a * a * tan(th) / 2 > x;
    } else {
      return b * b / tan(th) / 2 > x;
    }
  };
  long double ok = 0, ng = 90;
  for (int _ = 0; _ < 100; ++_) {
    long double mid = (ok + ng) / 2;
    (chk(mid * pi / 180) ? ok : ng) = mid;
  }
  cout << fixed << setprecision(15) << ok << '\n';
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline
n, q = [int(w) for w in input().split()]

s = input()
c_ac = [0]*(len(s)+1)

is_p_c = False
for i in range(len(s)-1, -1, -1):
    if s[i] == "A"and is_p_c:
        c_ac[i] = c_ac[i+1]+1
    else:
        c_ac[i] = c_ac[i+1]
    if s[i] == "C":
        is_p_c = True
    else:
        is_p_c = False


for i in range(q):
    l, r = [int(w)-1 for w in input().split()]
    print(c_ac[l]-c_ac[r])


Measured memory_bytes: 11516
#include <iostream>

using namespace std;

int main () {
    int a, b;
    cin >> a >> b;

    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
        cout << "Possible" << endl;
    }
    else {
        cout << "Impossible" << endl;
    }
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif

static void C_task();

int main()
{
	C_task();
	
	fflush(stdout);
	return 0;
}


static int C_dfs(int *pVal, int *swStates, int nowSw, int swCnt, std::vector<std::vector<int>>& switches, int lightCnt) {
	int ans = 0;

	if (nowSw == swCnt) {
		ans = 1;

		for (int i = 0; i < lightCnt; i++) {
			int onCount = 0;
			for (auto lIt = switches[i].begin(); lIt != switches[i].end(); lIt++) {
				onCount += swStates[*lIt];
			}

			if ((onCount % 2) != pVal[i]) {
				ans = 0;
				break;
			}
		}
		return ans;
	}

	swStates[nowSw] = 1;
	ans += C_dfs(pVal, swStates, nowSw + 1, swCnt, switches, lightCnt);
	
	swStates[nowSw] = 0;
	ans += C_dfs(pVal, swStates, nowSw + 1, swCnt, switches, lightCnt);

	return ans;
}

static void C_task() {
	int N, M;
	scanf(" %d %d", &N, &M);

	std::vector<std::vector<int>> switches(M);

	for (int i = 0; i < M; i++) {
		int Ki;
		scanf(" %d", &Ki);
		for (int j = 0; j < Ki; j++) {
			int s;
			scanf(" %d", &s);
			switches[i].push_back(s - 1);
		}
	}

	int pVal[11] = { 0 };
	for (int i = 0; i < M; i++) {
		scanf(" %d", &pVal[i]);
	}
	int swStates[11] = { 0 };
	printf("%d\n", C_dfs(pVal, swStates, 0, N, switches, M));
}


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

int main(){
    int N; cin >> N;
    vector <string> S(N);
    map <string,int> mp;
    
    rep(i,N){
        cin >> S[i];
        mp[S[i]]++;
    }
    sort(S.begin(),S.end());
    
    int num=0;
    rep(i,N){
        num=max(num,mp[S[i]]);
    }
    
    rep(i,N){
        if (mp[S[i]]==num){
            cout << S[i] << endl;
            mp[S[i]]=-1;
        }
    }
}

Measured memory_bytes: 26752
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
using std::cout;
using std::cin;
using std::endl;
using std::fixed;
using std::setprecision;

double getArea(double sidea, double sideb, double angle)
{
	return sidea * sideb * (sin(angle * M_PI / 180)) / 2;
}

double getPerimeter(double sidea, double sideb, double angle)
{
	return sidea + sideb + sqrt(pow(sidea, 2) + pow(sideb, 2) - 2 * sidea * sideb * cos(angle * M_PI / 180));
}

int main()
{
	double a, b, c;
	cin >> a >> b >> c;
	cout << fixed << setprecision(8);
	cout << getArea(a, b, c) << endl;
	cout << getPerimeter(a, b, c) << endl;
	cout << getArea(a, b, c) * 2 / a << endl;
	return 0;
}

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

#define INF INT_MAX

using namespace std;

int main(void){
	int a,b,c;
	cin >> a >> b >> c;
	int flag = false;
	for(int i = 1;i <= b;i++){
		if(a*i % b == c){
			flag = true;
			break;
		}
	}
	if(flag){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
//if(strcmp(s[i],"AC")==0)
//if(s[l]=='#')
/*小文字判定
if((moji>= 'a') && (moji<='z')){
    printf("a\n");
    return 0;
  }
  */

int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

void swap(int *a, int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}
//swap(&a, &b)

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

int cmp( const void *p, const void *q ) {
    return *(int*)p - *(int*)q;
}//ちいさい順
//qsort(a,n,sizeof(int),cmp);
//char s[n][11]

int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);


int main (void)
{
	long long int a[210000],b,c,j,n,k,i,check[210000]={0},flag=0,count=1;
  char s[200005];

scanf("%lld%lld",&n,&k);
	for(i=1;i<=n;i++){
scanf("%lld",&a[i]);
	}
  i=1;
    check[1]=1;
  while(k>0){
    i=a[i];
    check[i]++;
//    printf("%lld,k=%lld\n",i,k);
    k--;
    
    if(check[i]==3){
      flag=1;
      for(j=1;j<=n;j++){
      if(check[j]==2){
      count++;
      }
      }
            break;
      
    }
  }
  k=k%count;
    while(k>0){
    i=a[i];
//      printf("2=%lld,k=%lld\n",i,k);
    check[i]++;
    k--;
    }
  
  printf("%lld",i);
  return 0;
}


Measured memory_bytes: 4940
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define For(i,a,b) for(ll i=a;i<b;i++)
#define rFor(i,a,b) for(ll i=a;i>b;i--)
#define wFor(i,a,b) for(ll i=a;i<b;i+=2)
#define wrFor(i,a,b) for(ll i=a;i>b;i-=2)
#define sort(a,b) sort(a.begin(),b.end())
#define reverse(a,b) reverse(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//(char-'0') 数字に変換
//vector<vector<int>> data(a,vector<int>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数
//ceil(log10(a)) aの10進法での桁数

int main() {
  ll a;
  ci(a);
  vec b(a);
  For(i,0,a)
    ci(b[i]);
  sort(b,b);
  ll c=0,d=0;
  For(i,1,a)
    if(b[i-1]==b[i]){
      d=c;
      c=b[i];
      i++;
    }
  co(c*d);
}

Measured memory_bytes: 1152
#include <stdio.h>

int main()
{
    char s[4];
    scanf("%c%c%c%c", s+0, s+1, s+2, s+3);
    if ((s[0] == s[1]) && (s[1] == s[2])) printf("Yes\n");
    else if ((s[1] == s[2]) && (s[2] == s[3])) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
/*
 * atcoder/abc130/a.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

ll X, A;

void input() {
  cin >> X >> A;
}

void solve() {
  if (X < A) cout << 0 << endl;
  else cout << 10 << endl;
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
# N = int(input())
N, A, B = map(int, input().split())
students = list(input())
through = 0
abroad_rank = 0
for student in students:
    if through >= A+B:
        print('No')
        continue
    if student == 'a':
        print('Yes')
        through += 1
    elif student == 'b':
        if abroad_rank+1<=B:
            print('Yes')
            through += 1
            abroad_rank += 1
        else:
            print('No')
    else:
        print('No')



Measured memory_bytes: 4708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    while(true){
        ll m, f, r;
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1) break;

        if(m==-1 or f==-1)
            cout << 'F' << endl;
        else if(m+f>=80)
            cout << 'A' << endl;
        else if(m+f>=65)
            cout << 'B' << endl;
        else if(m+f>=50 or (m+f>=30 and r>=50))
            cout << 'C' << endl;
        else if(m+f>=30)
            cout << 'D' << endl;
        else
            cout << 'F' << endl;
    }
}   


Measured memory_bytes: 3200
import sys
from bisect import bisect_right

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N, *A = map(int, read().split())

    dp = [A.pop()]
    for a in reversed(A):
        if a >= dp[-1]:
            dp.append(a)
        else:
            dp[bisect_right(dp, a)] = a

    print(len(dp))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 71228
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int X,A;
  cin>>X>>A;
  if(X<A){
    cout<<0<<endl;
  }else cout<<10<<endl;

  return 0;
}


Measured memory_bytes: 384
#include<algorithm>
#include<vector>
#include<iostream>
using namespace std;
typedef long long ll;
vector<ll> lunlun;
ll q[int(1e7)];
int main(){
	int r=0,l=1;
	for(int i=1;i<10;++i)q[++r]=i;
	while(r>l){
		ll x=q[l++];
		lunlun.push_back(x);
		if(x>1e10)break;
		ll k=x%10;
		q[++r]=x*10ll+k;
		if(k!=0)q[++r]=x*10ll+k-1;
		if(k!=9)q[++r]=x*10ll+k+1;
	}
	sort(lunlun.begin(),lunlun.end());
	int k;
	cin>>k;
	cout<<lunlun[k-1]<<endl;
	return 0;
}


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

#define MAX_N 101

int main() {
	int N;
	int a[MAX_N] = {0};
	int result = 10000;
	double sum = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		sum += a[i];
	}
	double avg = sum / N;
	double s = abs(avg-a[0]);
	result = 0;
	for (int i = 1; i < N; i++) {
		if (abs(avg-a[i]) < s) {
			s = abs(avg-a[i]);
			result = i;
		}
	}
	cout << result << endl;
}


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

int keta_sum(int num){
  int l_sum=0;
  while(num>0){
    l_sum += num%10;
    num /= 10;
  }
  return l_sum;
}

int main(){
  int N,A,B;
  int sum;
  int counter=0;
  cin>>N>>A>>B;
  for(int i=1;i<=N;++i){
    sum = keta_sum(i);
    if(sum>=A&&sum<=B) counter+=i;
  }
  cout<<counter<<endl;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;

public class Main {
    int n;
    Edges[] g;
    long[] counter;

    void run() {
        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        int q = sc.nextInt();
        g = new Edges[n];
        counter = new long[n];

        for (int i = 0; i < n; i++) {
            g[i] = new Edges();
        }

        for (int i = 0; i < n - 1; i++) {
            int a = sc.nextInt() - 1, b = sc.nextInt() - 1;
            g[a].add(b);
            g[b].add(a);
        }

        for (int i = 0; i < q; i++) {
            int p = sc.nextInt() - 1, x = sc.nextInt();
            counter[p] += x;
        }

        dfs(0, 0, new boolean[n]);

        PrintWriter out = new PrintWriter(System.out);
        out.print(counter[0]);
        for (int i = 1; i < n; i++) {
            out.print(" " + counter[i]);
        }
        out.println();
        out.flush();


    }

    void dfs(int idx, long cnt, boolean[] visited) {
        counter[idx] += cnt;
        visited[idx] = true;

        for (int next: g[idx]) if (!visited[next]) {
            dfs(next, counter[idx], visited);
        }
    }

    class Edges extends ArrayList<Integer> {}

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }

}


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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define ll long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n;
    cin >> n;
    vector<int> v(n+1, 0);
    for(int i=1;i<n;i++)
    {
    	int tmp;
    	cin >> tmp;
    	v[tmp]++;
    }
    for(int i=1;i<=n;i++)
    	cout << v[i] << " ";
    return 0;
}



Measured memory_bytes: 4780
#include <stdio.h>
#include <string.h>
#include <ctype.h>
 
void roll_N(void);
void roll_E(void);
void spin(void);
int dice[2][6],dice_spin[6],temp;
 
 
int main(void)
{
    int i,j;
    int now[6];
 
    for(i = 0; i < 2; i++)
    {
        scanf("%d %d %d %d %d %d", &dice[i][0],&dice[i][1],&dice[i][2],&dice[i][3],&dice[i][4],&dice[i][5]);
    }
    for(i = 0; i < 6; i++)
    {
        dice_spin[i] = dice[1][i];
        now[i] = dice[0][i];
    }
 
    for(i = 0; i < 6; i++)
    {
     
 
        for(j = 0; j < 4; j++)
        {
            roll_N();   
 
            if (dice_spin[i] == now[0] )
            {
                break;
            }
        }   
 
        if (dice_spin[i] != now[0])
        {
            for(j = 0; j < 4; j++)
            {
                roll_E();   
 
                if (dice_spin[i] == now[0])
                {
                    break;
                }
            }
        }   
     
 
        for(j = 0; j < 4; j++)
        {
            spin();
            if (dice_spin[(i+1) % 6] == now[1])
            {
                break;
            }
        }   
     
 
        if (dice_spin[(i+2)%6] == now[2] && dice_spin[(i+3)%6] == now[3] && dice_spin[(i+4)%6] == now[4] && dice_spin[(i+5)%6] == now[5])
        {
            printf("Yes\n");
            return 0;
        }   
 
        }
 
    printf("No\n");
 
    return 0;
}
 
 
void roll_N(void)
{
    temp = dice_spin[4];
    dice_spin[4] = dice_spin[0];
    dice_spin[0] = dice_spin[1];
    dice_spin[1] = dice_spin[5];
    dice_spin[5] = temp;
 
}
 
void roll_E(void)
{
    temp = dice_spin[2];
    dice_spin[2] = dice_spin[0];
    dice_spin[0] = dice_spin[3];
    dice_spin[3] = dice_spin[5];
    dice_spin[5] = temp;
}
 
 
void spin(void)
{
    temp = dice_spin[3];
    dice_spin[3] = dice_spin[1];
    dice_spin[1] = dice_spin[2];
    dice_spin[2] = dice_spin[4];
    dice_spin[4] = temp;
 
}

Measured memory_bytes: 580
def ceil(n, m):
  return n / m + 2 if n % m != 0 else n / m + 1

def gram(l):
  return 200 * l[0] + 300 * l[1] + 500 * l[2]

def price(l):
  def c(n, m, p, r):
    d = (n / m) * m
    return ((n - d) + d * r) * p

  return int(c(l[0], 5, 380, 0.80) + c(l[1], 4, 550, 0.85) + c(l[2], 3, 850, 0.88))

t = []
for amount in range(500, 5500, 100):
  for a in range(ceil(amount, 200)):
    for b in range(ceil(amount, 300)):
      for c in range(ceil(amount, 500)):
        if gram([a, b, c]) == amount:
          t.append([gram([a, b, c]), [a, b, c]])

while True:
  data = input()
  if data == 0:
    break
  s = []
  for x in t:
    if x[0] == data:
      s.append(price(x[1]))
  print sorted(s)[0]

Measured memory_bytes: 4508
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
using ii = pair<int, int>;
 
void solve();
 
clock_t start_time;
double get_current_time() {
	return (double)(clock() - start_time) / CLOCKS_PER_SEC;
}
 
int main() {
	// freopen("input.txt", "r", stdin);
	// freopen();

	ios_base::sync_with_stdio(false);
	solve();
}
 
/* ========== actual code starts here ========== */
 
#define fi first
#define re return
#define se second
#define in insert
#define pb push_back
#define eb emplace_back
#define y1 y123123123123
#define all(x) x.begin(), x.end()
 
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repx(i, x, n) for (int i = x; i < (n); i++)
#define repd(i, n, d) for (int i = 0; i < (n); i += d)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepd(i, n, d) for (int i = (n) - 1; i >= 0; i -= d)
 
#ifdef artem
	#define debug(x) x
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define debug(x)
#endif

const int iinf = (int)1e9 + 123123;
const ll linf = (ll)1e17 + 123123;
// const int limit = 10050;
// const int k = 15;
// int st[ limit ][ k ];

// int get_min(int l, int r) {
// 	int j = log2(r - l + 1);
// 	re min(st[ l ][ j ], st[ r - (1 << j) + 1 ][ j ]);
// }

void solve() {
	int n, x;
	cin >> n >> x;
	vector<int> a(n + n);
	for(int i = 0; i < n + n; i++) {
		if(i < n) {
			cin >> a[ i ];
		} else {
			a[ i ] = a[ i - n ];
		}
	}

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

	// for(int j = 1; j < k; j++) {
	// 	for(int i = 0; i + (1 << j) <= n + n; i++) {
	// 		st[ i ][ j ] = min(st[ i ][ j - 1 ], st[ i + (1 << (j - 1)) ][ j - 1 ]);
	// 	}
	// }

	// ll ans = linf;
	// for(int i = 0; i < n; i++) {
	// 	ll may = x * i;
	// 	for(int j = n - 1; j < n + n - 1; j++) {
	// 		may += get_min(j - i, j);
	// 	}
	// 	ans = min(ans, may);
	// }
	// cout << ans << endl;

	ll ans = linf;
	vector<int> mn(n + n, iinf);
	for(int i = 0; i < n; i++) {
		ll may = x * (ll)i;
		for(int j = n - 1; j < n + n - 1; j++) {
			mn[ j ] = min(mn[ j ], a[ j - i ]);
			// cout << "we have a[ j ] = " << mn[ j ] << endl;
			may += mn[ j ];
		}
		// cout << "look at i = " << i << ", ans = " << may << endl;
		ans = min(ans, may);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3676
N, M, X = [int(i) for i in input().split()]

CA = []
for i in range(N):
    CA.append([int(j) for j in input().split()])

min_money = 100000 ** N + 1
for i in range(2**N):
    money = 0
    result = [0] * M
    for j in range(N):
        if ((i >> j) & 1):
            money += CA[j][0]
            for n in range(1, M+1):
                result[n-1] += CA[j][n]
    if money < min_money and min(result) >= X:
        min_money = money

print(min_money if min_money != 100000 ** N + 1 else -1)

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


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

typedef struct{
	int x;
	int y;
}t_swap;

int main(){
	int m, n;
	char c;

	cin >> m;
	cin >> n;
	int* w = new int[ m + 1 ];
	t_swap* swap = new t_swap[ n ];

	for ( int i = 0; i < n; ++i ){
		cin >> swap[ i ].x >> c >> swap[ i ].y;
	}

	for ( int i = 0; i < m + 1; ++i ){
		w[ i ] = i;
	}

	for ( int i = 0; i < n; ++i ){
		int t = w[ swap[ i ].x ];
		w[ swap[ i ].x ] = w[ swap[ i ].y ];
		w[ swap[ i ].y ] = t;
	}

	for ( int i = 1; i < m + 1; ++i ){
		cout << w[ i ] << endl;
	}


	delete[] swap;
	delete[] w;

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstring>
using namespace std;
const int maxn = 50 + 5;
int a, b;
int n, m;
int sum[maxn];
int main()
{
	while (cin >> n >> m)
	{
		memset(sum, 0, sizeof(sum));
		for (int i = 0; i < m; i++)
		{
			cin >> a >> b;
			sum[a]++;
			sum[b]++;
		}
		for (int i = 1; i <= n; i++)
			cout << sum[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
using namespace std;
int gyaku(int n)
{
    int a=0;
    while(n>0){
        a+=n%10;
        n/=10;
        a*=10;        
    }
    a/=10;

    return a;
}
int main(void)
{
    int a,b,i,cnt=0;
    cin>>a>>b;
    for(i=a;i<=b;i++){
        if(gyaku(i)==i)
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n;scanf("%d",&n);
    char str[300000];
    int r[300000],l[300000];
    scanf("%s",str);
    int i;
    int cnt=0;
    for(i=0;i<=n;i++){
        if(str[i]=='W')
            cnt++;
        r[i]=cnt;
    }
    cnt=0;
    for(i=n;i>=0;i--){
       if(str[i]=='E')
           cnt++;
        l[i]=cnt;
    }
    //k  r[k-1]+l[k+1]
    int min=r[n];
    for(i=0;i<=n;i++){
        int a;
        if(i==0)
            a=l[1];
        else if(i==n)
            a=r[n];
        else
            a=r[i-1]+l[i+1];
        if(min>a)
            min=a;
    }
    
    
    
    
    printf("%d",min);
    
    
}


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

int main() {
  int n, k, ans=0;
  cin >> n >> k;
  vector<int> v(n);

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

  sort(v.begin(), v.end(), greater<int>());

  for (int i=0; i<k; i++) {
    ans+=v[i];
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
        String s = in.next();
        int n = s.length();
        boolean x = true;
        for (int i=0; i<n-1; i++) {
            if (s.charAt(i) != s.charAt(i+1)) {
                x = false;
            }
        }
        if (x) {
            out.println(0);
            return;
        }
        int max = 0;
        int idx = -1;
        int ans = Integer.MAX_VALUE;
        for (int k=0; k<26; k++) {
            boolean ok = true;
            int p = 1;

            String t1 = s, t2 = "";
            int m = n;
            outer:
            for (int i=0; i<m; i++) {
                boolean f = true;
                for (int j=0; j<m-1; j++) {
                    if (t1.charAt(j) - 'a' == k || t1.charAt(j+1) - 'a' == k) {
                        t2 += String.valueOf((char)(k + 'a'));
                        f = false;
                    } else {
                        t2 += "X";
                    }
                }
                if (f) {
                    ok = false;
                    break outer;
                }
                boolean ff = true;
                for (int j=0; j<m-1; j++) {
                    if (t2.charAt(j) - 'a' != k) {
                        ff = false;
                    }
                }
                if (ff) {
                    break outer;
                }
                p++;
                t1 = t2;
                t2 = "";
                m--;
            }
            if (ok) {
                ans = Math.min(ans, p);
            }
        }
        out.println(ans);
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 41172
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
S = s()

x = 0
max_x = 0
for c in S:
    if c == 'I':
        x += 1
        if x > max_x:
            max_x = x
    else:
        x -= 1

print(max_x)


Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include <iomanip>
using namespace std;
int main(){
    double a,b,C,S,d,L,h,pi=3.141592653589;
    cin>>a>>b>>C;
    S = 0.5*a*b*sin(C*pi/180);
    d = a*a+b*b-2*a*b*cos(C*pi/180);
    L = a+b+sqrt(d);
    h = 2*S/a;
    cout<<fixed<<setprecision(10)<<S<<endl<<fixed<<setprecision(10)<<L<<endl<<fixed<<setprecision(10)<<h<<endl;
}




Measured memory_bytes: 3508
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <list>

using namespace std;


int main() {
    int n;scanf("%d",&n);
    long long m=0;
    long long a=0;
    long long r=0;
    long long c=0;
    long long h=0;
    string str;
    for(int i=0;i<n;i++){
        cin>>str;
        if(str[0]=='M'){
            m++;
        }
        if(str[0]=='A'){
            a++;
        }
        if(str[0]=='R'){
            r++;
        }
        if(str[0]=='C'){
            c++;
        }
        if(str[0]=='H'){
            h++;
        }
    }

    unsigned long long sum=0;

    sum += m * a * r;
    sum += m * a * c;
    sum += m * a * h;
    sum += m * r * c;
    sum += m * r * h;
    sum += m * c * h;
    sum += a * r * c;
    sum += a * r * h;
    sum += a * c * h;
    sum += r * c * h;

    printf("%llu",sum);

    return 0;

}

Measured memory_bytes: 256
/*
No i'm not down, No I'm not out
*/
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll  long long
#define f(i,a,b) for(int i=a; i<b; i++)
#define pb push_back
#define MP make_pair
#define vi vector<int>
#define vll vector<long long>
#define M map<int,int>
#define F     first
#define S    second
#define nl "\n"
#define lb lower_bound
#define ub upper_bound
#define max(a, b) (a < b ? b : a)
#define min(a, b) (a > b ? b : a)
#define mem(a,n)  memset(a, n, sizeof(a))
#define all(v) v.begin(), v.end()
int dx[8] ={0, 0, 1, 1, 1, -1, -1, -1};
int dy[8] ={1, -1, -1, 0, 1, -1, 0, 1};
#define mod 1000000007
#define N 100005

int add(int a, int b)
{
    return ((a % mod) + (b % mod)) % mod;
}

using namespace std;

int main()
{
    fast();
    int n, m;
    cin >> n >> m;
    string s[n];
    int a[n][m];
    f(i, 0, n)
    {
        cin >> s[i];
        f(j, 0, m)
        {
            a[i][j] = 0;
            if(s[i][j] == '.'){if(!i && !j)a[i][j] = 1;
            if(i > 0)a[i][j] = add(a[i][j], a[i-1][j]);
            if(j > 0)a[i][j] = add(a[i][j], a[i][j-1]);}
        }
    }
    cout << a[n-1][m-1];
}

Measured memory_bytes: 5248
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
	string s;
	cin >> s;
	string ans = "";
	for( auto c : s )
	{
		if( c == '0' ) ans += '0';
		else if( c == '1' ) ans += '1';
		else if( c == 'B' && ! ans.empty() ) ans = ans.substr( 0, ans.length() - 1 );
	}
	cout << ans << endl;
	return 0;
}


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

main()
{
   int n,m;
   cin>>n>>m;
   int l=1,r=m+1;
   while(l<r) cout<<l++<<" "<<r--<<endl;
   l=m+2,r=2*m+1;
   while(l<r) cout<<l++<<" "<<r--<<endl;
    return 0;
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    int n;cin>>n;
    vector<pair<pair<string,int>,int>>sp(n);

    rep(i,n){
        string s;cin>>s;
        int p;cin>>p;
        sp[i]=make_pair(make_pair(s,-p),i+1);
    }

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

    rep(i,n){
        cout<<sp[i].second<<endl;
    }

}


Measured memory_bytes: 256
from collections import deque
N, K = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(N)]
L.sort(key = lambda x: x[0])
L = deque(L)
while K>L[0][1]:
  K -= L[0][1]
  L.popleft()
print(L[0][0])

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

int main() {
	int n;
	cin>>n;
	vector<int> v(n);
	for(int i=0; i<n; i++){
		cin>>v[i];
	}
	long long ans=0;
	for(int i=1; i<n; i++){
		if(v[i]<v[i-1]){
			ans+=v[i-1]-v[i];
			v[i]=v[i-1];
		}
	}
	cout<<ans;
	return 0;
}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    ll n,m,ans=0,cnt=0;
    cin >> n >> m;
    vector<ll> x(m);
    rep(i,m) cin >> x[i];
    sort(all(x));
    vector<ll> diff(m-1);
    rep(i,m-1){
        diff[i] = x[i+1] - x[i];
    }
    sort(all(diff));
    reverse(all(diff));
    rep(i,m-1){
        cnt++;
        if(cnt<=n-1) continue;
        else ans += diff[i];
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		if(a < b){
			if(b < c){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 17356
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

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

	int N;
	cin >> N;
	vector<int> H, T;
	int ans = 0;
	for(int i=0; i<N; i++){
		int h;
		cin >> h;
		H.push_back(h);
		if(i == 0){
			T.push_back(H[0]);
		}
		else{
			if(H[i] > T[i-1]){
				T[i] = H[i];
			}
			else{
				T[i] = T[i-1];
			}
		}
		if(H[i] >= T[i]){
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}



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

typedef pair<int,int> P;

char maze[50][51];
int H,W;

const int INF = 100000000;
int d[50][50];

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

int bfs(){
	queue<P> que;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			d[i][j] = INF;
		}
	}
	que.push(P(0,0));
	d[0][0] = 0;

	while(que.size()){
		P p = que.front();
		que.pop();
		if(p.first == H - 1 && p.second == W - 1) break;
		for(int i=0;i<4;i++){
			int nx = p.first + dx[i], ny = p.second + dy[i];

			if(0 <= nx && nx < H && 0 <= ny && ny < W && maze[nx][ny] != '#' && d[nx][ny] == INF) {
				que.push(P(nx,ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[H-1][W-1];

}

int main(){
	cin >> H >> W;
	int count = 0;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin >> maze[i][j];
			if(maze[i][j] == '#') count++; 
		}
	}
	int res = bfs();
	if(res == INF) cout << -1 << endl;
	else cout << (H * W) - res - 1 - count << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Solver {

    private final String S;

    Solver(Scanner in){
        S = in.next();
    }

    void solve() {
        String[] strings = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
        for (int i = 0; i < strings.length; i++) {
            String s = strings[i];
            if (s.equals(S)) {
                System.out.println(7 - i);
                return;
            }
        }
    }
}

class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);

        new Solver(in).solve();

        in.close();
    }
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loope(i,a,b) for(ll i=a;i<=b;i++)
#define test() ull t;cin>>t;while(t--)
#define puu pair<ull,ull>
#define f first
#define s second
#define pb push_back
#define mkp make_pair
#define ins insert
#define Vint vector<int>
#define Vull vector<ull>
#define nl cout<<endl
#define sp cout<<" "
#define MOD 1000000007
#define all(x) x.begin(),x.end()

int main() 
{
	 // #ifndef ONLINE_JUDGE
  //       freopen("input.txt", "r", stdin);
  //       freopen("output.txt", "w", stdout);
  //   #endif
  //   fastio();
    ll n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    s[k-1] = tolower(s[k-1]);
    cout<<s;
}

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

public class Main {

    public Main() {
        Scanner scanner = new Scanner(System.in);
        Long N = scanner.nextLong();

        HashMap<Long, Integer> HM = new HashMap();

        for (long i = 2; i*i <= N; i++) {
            if (N % i != 0) continue;

            int num = 0;
            while(N % i == 0){
                num++;
                N /= i;
            }
            HM.put(i, num);
        }

        if(N != 1){
            HM.put(N, 1);
        }

        long R = 0;
        for (Long key : HM.keySet()){
            int i = 1;
            while(true) {
                if (HM.get(key) >= i) {
                    R++;
                    HM.put(key, HM.get(key)-i);
                    i++;
                } else {
                    break;
                }
            }
        }

        System.out.println(R);
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 35964
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            const int INFTY = int.MaxValue;

            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int m = int.Parse(input[1]);

            int[] C = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            int[] dp = Enumerable.Repeat(INFTY, n + 1).ToArray();
            dp[0] = 0;

            for (int i = 0; i < m; i++)
            {
                for (int j = 0; j + C[i] <= n; j++)
                {
                    dp[j + C[i]] = Math.Min(dp[j + C[i]], dp[j] + 1);
                }
            }

            Console.WriteLine(dp[n]);
        }
    }
}

Measured memory_bytes: 10220
import fractions
a,b,c,d = map(int,input().split())
e = fractions.gcd(c,d)
k = int(c*d/e)
if a%c == 0:
    if a%d == 0:
        f = (b//c) - (a//c) + 1
        g = (b//d) - (a//d) + 1
        h = (b//k) - (a//k) + 1
    else:
        f = (b//c) - (a//c) + 1
        g = (b//d) - (a//d)
        h = (b//k) - (a//k)
else:
    if a%d == 0:
        f = (b//c) - (a//c)
        g = (b//d) - (a//d) + 1
        h = (b//k) - (a//k)
    else:
        f = (b//c) - (a//c)
        g = (b//d) - (a//d)
        h = (b//k) - (a//k)
print(b-a+1-f-g+h)

Measured memory_bytes: 5688
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define fi first
#define se second
#define length(X) (int)X.size()
using namespace std;
typedef pair <int, int> ii;

const ll siz = 1e3 + 10;
const ll SIZ = 1e6 + 10;
const ll mod = 1e9;
const ll maxx = 2e9;
const ll MAXX = 1e18;

int n, k;
int a[siz];
int ans;

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    freopen ("IN_4.INP", "r", stdin);
//    freopen ("OUT_4.OUT", "w", stdout);
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    sort (a + 1, a + 1 + n);
    for (int i = 1; i <= k; i++)
        ans += a[i];
    cout << ans;
    return 0;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    set<li> st;
    rep(i,3){
        li x;
        cin>>x;
        st.insert(x);
    }
    cout<<(sz(st)==2 ? "Yes" : "No")<<endl;


    return 0;
}

Measured memory_bytes: 3644
#define TST 0
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cctype>
#include <bits/stdc++.h>
#include <queue>

using namespace std;
// for loop
#define F(i, L, R) for(long i = L; i < R; i++)
#define FE(i, L, R) for(long i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(long i = L; i > R; i--)
#define FRE(i, L, R) for(long i = L; i >= R; i--)

// data types
#define Int long
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back
#define InputV(a, n) F(i,0,n){long l; cin >> l; a.pb(l);}

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

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

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

void printM(vector<vector<int> > &vec, long height, long width){
    F(i, 0, height){
        F(j, 0, width){
            cout << vec[i][j] << space;
        }
        cout << endl;
    }
}

vector<int> seen;
vector<int> done;
int timestamp;

// Graph: グラフを表した隣接リスト
// v: 何番目のノードを訪問するのか
void dfs(vector<vector<int> > &Graph, int v){
    timestamp++;
    seen[v] = timestamp; //訪問済みにする

    // 隣接するノードを再帰的に訪問
    for(int next_v = 0; next_v < Graph[v].size();next_v++) {
        if(seen[Graph[v][next_v]] != -1) continue;
        dfs(Graph, Graph[v][next_v]);
    }
    // 出るときの時間が増える
    timestamp++;
    done[v] = timestamp; // 隣接ノードを全て調べ終えた
}

int main() {
#if TST==1
    ifstream in ("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    long n;
    cin >> n;
    vl A,B,C;
    A.resize(n);
    B.resize(n);
    C.resize(n);
    vl result;
    result.resize(n);
    F(j, 0, n){

        cin >> A[j];
    }
    F(i, 0, n){
        cin >> B[i];

    }
    F(i, 0, n){
        cin >> C[i];
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    vl::iterator it = A.begin();
    F(i, 0, n){
        it = lower_bound(it, A.end(), B[i]);
        size_t dist = distance(A.begin(), it);
        if(i == 0)result[i] = dist;
        else result[i] = result[i-1] + dist;
    }
    ll ans = 0;
    it = B.begin();
    F(i, 0, n){
        it = lower_bound(it, B.end(), C[i]);
        long dist = distance(B.begin(), it);
        if(dist > 0)ans += result[dist-1];
    }
    cout << ans << endl;


#if TST==1
#endif
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    for(int i=0;i<s.size();i++)
    {
    	if(s[i]!=t[i])
    	{
    		cout<<"No";
    		return 0;
		}
	}
	cout<<"Yes";
    return 0;
}

Measured memory_bytes: 3592