akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

template<typename T> struct BIT{
	vector<T> dat;
	ll sz;
	//all 1-indexed
	BIT(ll sz) : sz(sz){
		dat.assign(++sz, 0);
	}

	T sum(ll k){
		T ret = 0;
		for(++k; k > 0; k -= k & -k) ret += dat[k];
		return (ret);
	}

	void add(ll k, T x){
		for(++k; k < dat.size(); k += k & -k) dat[k] += x;
	}
	
	ll get(T k){
		if(k <= 0) return 0; 
		ll ret = 0;
		int n = 1; while(n < sz) n *= 2;
		for(int i=n/2; i>0; i/=2){
			if(ret+i < sz && dat[ret+i] < k){
				k -= dat[ret+i];
				ret += i;
			}
		}
		return ret;
	}
};

int main(){
	ll n,q; cin >> n >> q;
	vl a(n); rep(i,n) cin >> a[i], a[i]--;
	vector<tapu> query(q);
	rep(i,q){
		int l,r; scanf("%d%d",&l,&r);
		l--; r--;
		query[i] = tie(r,l,i);
	}
	sort(all(query));
	BIT<int> bit(n);
	vl last(n,-1);
	ll L = 0, R = 0;
	vl ans(q);
	rep(i,q){
		ll l,r,id;
		tie(r,l,id) = query[i];
		while(R <= r){
			if(last[a[R]] != -1) bit.add(last[a[R]], -1);
			last[a[R]] = R;
			bit.add(last[a[R]], 1);
			R++;
		}
		ans[id] = bit.sum(r) - bit.sum(l-1);
	}
	rep(i,q) cout << ans[i] << "\n";
}


Measured memory_bytes: 29200
a, b, c, d = list(input())
for q in range(1, 3):
    ao = ("+" if q % 2 else "-")
    for w in range(1, 3):
        bo = ("+" if w % 2 else "-")
        for e in range(1, 3):
            if eval(a + ao + b + bo + c + ("+" if e % 2 else "-") + d) == 7:
                print(a + ao + b + bo + c + ("+" if e%2else"-") + d + "=7")
                exit(0)

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

int main(){

    int X,A,B,ans;
    cin >> X;
    A = X/500;
    B = ( X - (500*A) ) / 5;
    ans = 1000 * A + ( 5 * B );
    cout << ans << endl;
	return 0;
}

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

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

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string pass;
    cin >> pass;
    bool okflag = true;
    FOR(i, 0, 2) {
        if (pass[i] == pass[i + 1]) {
            okflag = false;
            break;
        }
    }
    cout << (okflag ? "Good" : "Bad") << ln;

    return 0;
}


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


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

  int64_t N;
  cin >> N;
  int64_t A[N], sum[N];
  cin >> A[0];
  sum[0] = A[0];
  for(int i=1;i<N;i++){
    cin >> A[i];
    sum[i] = sum[i-1] + A[i];
  }

  int64_t ans = INF;
  for(int i=0;i<N;i++){
    ans = min(ans, abs((sum[N-1] - sum[i])- sum[i] ));
  }

  cout << ans << endl;

}

Measured memory_bytes: 3328
#include<stdio.h>
#include<iostream>
using namespace std;
string s1,s2;
int main(){
    getline(cin,s1);getline(cin,s2);
    cout<<s1[0];
    for(int i=0;i<s1.size()+s2.size()-1;i++)
        if(i%2)cout<<s1[i/2+1];
        else cout<<s2[i/2];
    return 0;
}

Measured memory_bytes: 764
N,M = map(int, input().split())
if N==1 and M==1:
    print(1)
elif N<3 and M<3:
    print(0)
elif N==1 or M==1:
    print(max(N-2,M-2))
elif N==2 or M==2:
    print(0)
else:
    print(max(N-2,1)*max(M-2,1))

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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

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

ll gcd(ll a, ll b) {
    return !b ? a : gcd(b, a % b);
}

ll maximum(ll offset, ll base, ll start) {
    ll G = gcd(offset, base);
    ll K = base - start;
    return start + (((K + G - 1) / G) - 1) * G;
}

int main() {
    ios_base::sync_with_stdio(false);

    int t;
    cin >> t;
    while(t--) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        if(b > d or b > a) {
            cout << "No" << '\n';
        }
        else if(b <= c + 1 or maximum((d - b) % b, b, a % b) <= c) {
            cout << "Yes" << '\n';
        }
        else {
            cout << "No" << '\n';
        }
    }

    return 0;
}


Measured memory_bytes: 256
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
tot = 0
cur = -1
cnt = 0
for i in range(N):
    tot += A[i]
    if tot<=K:
        cur = i
        cnt += 1
    else:
        tot -= A[i]
        break
j = 0
while j<M and tot+B[j]<=K:
    tot += B[j]
    j += 1
    cnt += 1
cmax = cnt
for i in range(cur,-1,-1):
    tot -= A[i]
    cnt -= 1
    while j<M and tot+B[j]<=K:
        tot += B[j]
        j += 1
        cnt += 1
    cmax = max(cmax,cnt)
print(cmax)

Measured memory_bytes: 118004
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int dp[] = new int[n];
		int h[] = new int[n];
		final int INF = 1000000000;
		dp[0] = 0;

		for(int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
			if(i > 0)dp[i] = INF;
		}

		for(int i = 1; i < n; i++) {
			dp[i] = chmin(dp[i], dp[i-1] + Math.abs(h[i] - h[i-1]));
			if(i > 1) {dp[i] = chmin(dp[i], dp[i-2] + Math.abs(h[i] - h[i-2]));}
		}

		System.out.println(dp[n-1]);
		sc.close();
	}

	public static int chmin(int a, int b) {
		if(a > b) {
			return b;
		}else {return a;}
	}
}


Measured memory_bytes: 55948
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;

signed main(){
    ll a,b,x;
    cin>>a>>b>>x;
    double d;
    double e1=1.0;
    if(x*2>a*a*b){
        ll bx=2*(a*b*a-x);
        d =(180*(atan2(bx*e1,a*a*a*e1)))/M_PI;
    }else{
        ll bx=2*x;
        d =(180*(atan2(b*b*a*e1,bx*e1)))/M_PI;
    }
    cout<<setprecision(12)<<d<<endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, M, X, Y;
  cin >> N >> M >> X >> Y;
  ll x_max=-100, y_min=100;
  ll x, y;
  REP(i, N){
    cin >> x;
    x_max = max(x, x_max);
  }
  REP(i, M){
    cin >> y;
    y_min = min(y, y_min);
  }

  if(x_max<Y && X<y_min && x_max<y_min){
    cout << "No War\n";
  }else{
    cout << "War\n";
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int h, a, n, s=0;
    cin>>h>>n;
    for(int i=0; i<n; ++i){
        cin>>a;
        s+=a;
    }
    if(s>=h) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if(x >= r && y >= r && (H - r) >= y && (W - r) >= x) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 2120
using System;
using System.Linq;

namespace AtCoder_165
{
    class Program
    {
        static void Main(string[] args)
        {
            var K = int.Parse(Console.ReadLine());
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
            int a = input[0];
            int b = input[1];

            int cnt = 0;
            bool isOK = false;
            while (true) 
            {
                int i = K * cnt;
                cnt++;

                if (a <= i && i <= b)
                {
                    isOK = true;
                    break;
                }

                if (i > b) break;
            }

            if(isOK) Console.WriteLine("OK");
            else Console.WriteLine("NG");
        }
    }
}


Measured memory_bytes: 18976
S = input()

one = S[0]
two = S[1]
three = S[2]
four = S[3]

count = 0
index = 0

judge = False


for i in range(len(S)):
    if i == 0:
        continue
    if one == S[i]:
        index = i
        count += 1

# print(count)
# print(index)

if index == 1:
    if S[2] == S[3]:
        judge = True

elif index == 2:
    if S[1] == S[3]:
        judge = True

elif index == 3:
    if S[1] == S[2]:
        judge = True

else:
    judge = False


if not(count == 1):
    judge = False

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



Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
  int i,j,n,m,c,sum,ans=0;
  scanf("%d %d %d",&n,&m,&c);
  int b[m];
  int a[n][m];
  for(i=0;i<m;i++) scanf("%d",&b[i]);
  for(i=0;i<n;i++){
    sum=0;
    for(j=0;j<m;j++){
      scanf("%d",&a[i][j]);
      sum+=a[i][j]*b[j];
    }
    if(sum+c>0) ans++;
  }
  printf("%d\n",ans);
  return 0;
}

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

using namespace std;

set<long long> pf(long long n) {
    set<long long> pf = {1};
    for (int i = 2 ;i * 1ll * i <= n ;i++) {
        while (n % i == 0) {
            pf.insert(i);
            n /= i;
        }
    }
    pf.insert(n);
    return pf;
}

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

    long long a , b;
    cin >> a >> b;

    set<long long> aa = pf(a) ;
    set<long long> bb = pf(b);

    int res = 0;
    for (long long f : aa)
        if (bb.count(f))
            res++;

    cout << res;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
using namespace std;
int isPrime[1000001];
int main(){

  fill(isPrime,isPrime+1000001,1);
  isPrime[0]=isPrime[1]=0;
  for(int i = 2 ; i*i < 1000001 ; i++ ){
    if(isPrime[i])for(int j=i*2 ; j < 1000001 ; j+=i)isPrime[j]=0;
  }
  int n;
  while(cin >> n){
    int cnt = 0;
    for(int i = 2 ; i <= n ; i++ ){
      if(isPrime[i])cnt++;
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 5064
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int y, m, d;
char c;

int main(){
    INIT;
    cin >> y >> c >> m >> c >> d;
    if(m >= 5){
        cout << "TBD" << endl;
    }else {
        cout << "Heisei" << endl;
    }
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
a_list = list(map(int, input().split()))

num_array = np.zeros(max(a_list)+1)
for a in a_list:
    num_array[a::a] += 1
    
count = 0
for a in a_list:
  if num_array[a] == 1:
    count += 1
print(count)

Measured memory_bytes: 51176
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
class dsu
{
public:
    vector<int> par;
    vector<int> comp;
    dsu(int n)
    {
        par.resize(n+1);
        comp.resize(n+1);
        for(int i=1;i<=n;i++)
        {
            par[i]=i;
            comp[i]=1;
        }
    }
    int getp(int n)
    {
        if(n==par[n])
            return n;
        return par[n]=getp(par[n]);
    }
    void unite(int a,int b)
    {
        int ap=getp(a);
        int bp=getp(b);
        if(ap!=bp)
        {
            if(comp[ap]<comp[bp])
            {
                comp[bp]+=comp[ap];
                comp[ap]=0;
                par[ap]=bp;
            }
            else
            {
                comp[ap]+=comp[bp];
                comp[bp]=0;
                par[bp]=ap;
            }
        }
    }
};
int main()
{
  int n,m,i,j;
  cin>>n>>m;
  int x,y;
  dsu g(n);
  for(i=0;i<m;i++)
  {
      cin>>x>>y;
      g.unite(x,y);
  }
  vector<int> arr;
  for(i=1;i<=n;i++)
  {
      if(g.comp[i]>0)
        arr.push_back(g.comp[i]);
  }
  sort(arr.begin(),arr.end());
  ll ans=0;
  for(i=0;i<arr.size();i++)
      ans+=(arr[i]-ans);
  cout<<ans;
  return 0;
}


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

int main(){
  int a,b;cin>>a>>b;
  if(a<=0&&b>=0){
    cout<<"Zero"<<endl;
    return 0;
  }else if(b<0&&(b-a+1)&1){
    cout<<"Negative"<<endl;
    return 0;
  }else{
    cout<<"Positive"<<endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    string S;
    cin >> S;
    bool s1 = false;
    bool s2 = false;
    bool s3 =false;
    for (int i = 0 ; i <= S.size(); i++) {
        if (S[i] == 'a') {
             s1 = true;
        }
        if (S[i] == 'b') {
             s2 = true;
        }
        if (S[i] == 'c') {
             s3 = true;
        }
    }
    if ( s1 == true && s2 == true && s3 == true) {
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int w,d;
  cin >> w >> d;
  while(w!=0){
    vector<int> ws;
    vector<int> ds;
    int b,i,j,sum=0;
    for(i=0;i<w;i++) {
      cin >> b;ws.push_back(b);
    }
    for(i=0;i<d;i++) {
      cin >> b;ds.push_back(b);
    }
    for(i=0;i<ws.size();i++) {
      for(j=0;j<ds.size();j++){
	if(ws[i]==ds[j]){
	  sum+=ws[i];
	  //cout << sum;
	  ws.erase(ws.begin()+i);
	  ds.erase(ds.begin()+j);
	  i=-1;
	  j=-1;
	}
      }
    }
    for(i=0;i<ws.size();i++) {
      for(j=0;j<ds.size();j++){
	if(ws[i]==ds[j]){
	  sum+=ws[i];
	  //cout << sum;
	  ws.erase(ws.begin()+i);
	  ds.erase(ds.begin()+j);
	  i=-1;
	  j=-1;
	}
      }
    }
    //cout << sum << endl;
    for(i=0;i<ws.size();i++) {
      sum+=ws[i];
      //cout << ws[i] << endl;
    }
    //cout << sum << endl;
    for(i=0;i<ds.size();i++) {
      sum+=ds[i];
      //cout << ds[i] << endl;
    }
    cout << sum << endl;
    //cout << w << d << endl;;
    cin >> w >> d;
  }

}

Measured memory_bytes: 1216
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a[101],b[101];
	scanf("%s",a);
	scanf("%s",b);
	int l=strlen(a),l1=strlen(b);	
	int ma=-1,mi=200;
	for(int i=0;i<l;i++){
		mi=min(mi,(int)a[i]);
	}
	for(int i=0;i<l1;i++){
		ma=max(ma,(int)b[i]);
	}
	if(ma>mi){
		cout<<"Yes";
		return 0;
	}
	if(ma==mi){
		int j=0;
	for(;a[j]&&b[j]&&a[j]==b[j];j++);
	if(a[j]||b[j]=='\0'){
		cout<<"No";
		return 0;
	}else{
		cout<<"Yes";
		return 0;
	}
	}
	cout<<"No";
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int x,a;
    int happy=0;

    scanf("%d",&x);

    a=x/500;
    happy=happy+a*1000;
    x=x-a*500;

    a=x/5;
    happy=happy+a*5;

    printf("%d\n",happy);
    
    return 0;
}

Measured memory_bytes: 256
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

s = input()

cs = 0
for i in range(len(s)):
    if i == 0:
        if s[i] != 'A':
            print('WA')
            exit()
    elif 2 <= i <= len(s) - 2:
        if s[i] == 'C':
            cs += 1
            if cs > 1:
                print('WA')
                exit()
        else:
            if not s[i].islower():
                print('WA')
                exit()
    else:
        if not s[i].islower():
            print('WA')
            exit()

if cs == 0:
    print('WA')
else:
    print('AC')


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

def three(p1x, p1y, p2x, p2y):
    dx = (p2x - p1x)
    dy = (p2y - p1y)
    sx = dx / 3 + p1x
    sy = dy / 3 + p1y
    tx = p2x - (dx / 3)
    ty = p2y - (dy / 3)

    mtx = tx - sx
    mty = ty - sy

    rad = math.radians(60)
    mux = mtx * math.cos(rad) - (mty * math.sin(rad))
    muy = mtx * math.sin(rad) + (mty * math.cos(rad))

    ux = mux + sx
    uy = muy + sy

    return [sx, sy, ux, uy, tx, ty]

def koch(p1x, p1y, p2x, p2y, n):
    if 0 == n:
        print('{:.8f} {:.8f}'.format(p1x, p1y))
    if 0 < n:
        sx, sy, ux, uy, tx, ty = three(p1x, p1y, p2x, p2y)
        koch(p1x, p1y, sx, sy, n - 1)
        koch(sx, sy, ux, uy, n - 1)
        koch(ux, uy, tx, ty, n - 1)
        koch(tx, ty, p2x, p2y, n - 1)

koch(0.00000000, 0.00000000, 100.00000000, 0.00000000, n)
print('{:.8f} {:.8f}'.format(100.00000000, 0.00000000))

Measured memory_bytes: 8044
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();	
	int M, K;
	cin >> M >> K;
	if (K >= (1 << M)) {
		cout << -1 << endl;
	}
	else if (M == 1) {
		if (K == 0) {
			for (int i = 0; i <= 1; i++) {
				cout << i << " " << i << " ";
			}
			cout << endl;
		}
		else {
			cout << -1 << endl;
		}
	}
	else {
		vector<int> ans;
		vector<int> rans;
		for (int i = 0; i < (1 << M); i++) {
			if (i == K)  continue;
			ans.push_back(i);
		}
		rans = ans;
		reverse(rans.begin(), rans.end());
		cout << K << " ";
		for (int num : ans) cout << num << " ";
		cout << K << " ";
		for (int num : rans) cout << num << " ";
		cout << endl;
	}
}

Measured memory_bytes: 5288
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(void){
	while(1){
		ll n;
		cin >> n;
		if(!n) break;
		ll p[n], j[n - 1];
		ll sum = 0;
		for(int i = 0; i < n; i++){
			cin >> p[i];
			sum += p[i];
		}
		for(int i = 0; i < n - 1; i++) cin >> j[i];
		sort(p, p + n);
		sort(j, j + n - 1, greater<int>());
		ll c = n;
		for(int i = 0; i < n - 1; i++){
			if(sum * c < (sum + j[i]) * (c - 1)){
				sum += j[i]; c--;
			}
		}
		cout << sum * c << endl;
	}
	return 0;
}


Measured memory_bytes: 4132
(N,C),*D=$<.map{|s|s.split.map &:to_i}
a=[],[],[]
N.times{|i|N.times{|j|a[(i+j)%3]<<D[C+i][j]}}
s,t,u=a.map{|e|(0...C).map{|t|s=0;e.map{|f|s+=D[f-1][t]};s}}
p [*0...C].permutation(3).map{|x,y,z|s[x]+t[y]+u[z]}.min

Measured memory_bytes: 50708
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int maxn=1e5+10;
const int inf=1e9+10;
const ll mod=1e9+7;

ll reach[maxn][2],pos[maxn][2],dp[maxn][2],n,s[maxn],dif[2],add[maxn][2];

int main(){
	scanf("%lld%lld%lld",&n,&dif[0],&dif[1]);
	for(int i=0;i<n;i++) scanf("%lld",&s[i]);
	ll p[2]={0,0};
	for(int i=0;i<n;i++) for(int k=0;k<2;k++){
		p[k]=max(p[k],ll(i));
		while(p[k]+1<n&&s[p[k]+1]-s[p[k]]>=dif[k]) ++p[k];
		reach[i][k]=p[k];
	}
//	for(int i=0;i<n;i++) printf("%d ",reach[i][0]); printf("\n");
//	for(int i=0;i<n;i++) printf("%d ",reach[i][1]); printf("\n"); 
	p[0]=p[1]=0;
	for(int i=0;i<n;i++) for(int k=0;k<2;k++){
		p[k]=max(ll(i),p[k]);
		while(p[k]<n&&s[p[k]]-s[i]<dif[k]) ++p[k];
		pos[i][k]=p[k];
	}
//	for(int i=0;i<n;i++) printf("%d ",pos[i][0]); printf("\n");
//	for(int i=0;i<n;i++) printf("%d ",pos[i][1]); printf("\n");
	dp[0][0]=dp[0][1]=1;
	for(int i=1;i<n;i++) for(int k=0;k<2;k++) if(reach[0][k]>=i) dp[i][k]=1;
//	for(int i=0;i<n;i++) printf("%d ",dp[i][0]); printf("\n");
//	for(int i=0;i<n;i++) printf("%d ",dp[i][1]); printf("\n");
	for(int i=0;i<n;i++) for(int k=0;k<2;k++){
		if(i>0) add[i][k]+=add[i-1][k],add[i][k]%=mod;
		dp[i][k]+=add[i][k]; dp[i][k]%=mod;
		int l=max(ll(i+1),pos[i][k]-1),r=min(ll(n-1),reach[i+1][k^1]);
	//	cout<<i<<" "<<k<<":"<<l<<" "<<r<<endl;
		if(r<l) continue;
		add[l][k^1]+=dp[i][k]; add[l][k^1]%=mod;
		add[r+1][k^1]+=-dp[i][k]+mod; add[r+1][k^1]%=mod;
	}
//	for(int i=0;i<n;i++) printf("%d ",dp[i][0]); printf("\n");
//	for(int i=0;i<n;i++) printf("%d ",dp[i][1]); printf("\n"); 
	int ans=dp[n-1][0]+dp[n-1][1]; ans%=mod;
	printf("%d\n",ans);
	return 0;
}

/*
5 3 7
1 3 6 9 12
*/

Measured memory_bytes: 10832
if __name__=="__main__":
    a,b,k=input().split()
    a,b,k=int(a),int(b),int(k)
    if k<=a:
        print(a-k,b)
    else:
        if k<=a+b:
            print(0,a+b-k)
        else:
            print(0,0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  string S;
  cin >> S;
  ll N;
  cin >> N;

  map<string, ll> m;
  rep(i, S.size()) {
    rep(j, N + 1) {
      if (j == 0) {
        continue;
      }
      if (i + j < (ll)S.size() + 1) {
        string sub = S.substr(i, j);
        m[sub]++;
      }
    }
  }

  ll index = 0;
  for (auto a : m) {
    if (index == N - 1) {
      COUT(a.first);
      return 0;
    }
    index++;
  }

  return 0;
}

Measured memory_bytes: 1920
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        String[] weeks = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
        List<String> weekList = Arrays.asList(weeks);

        int result = 7 - weekList.indexOf(s);

        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 22228
use proconio::marker::Chars;
use proconio::{fastout, input};
use std::cmp;

#[fastout]
fn main() {
    input! {
        s: Chars,
    }

    let mut count = 0;
    let mut max = 0;
    let mut flag = false;
    for c in s {
        if flag == false {
            count = 0;
        }

        if c == 'R' {
            flag = true;
            count += 1;
        } else {
            flag = false;
        }

        max = cmp::max(max, count);
    }

    println!("{}", max);
}


Measured memory_bytes: 2148
/*input
10000000
4

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n;
  cin >> n;
  vector<int> cnt(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i)
      cnt[j]++;
  }
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += i * 1ll * cnt[i];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 42268
#include <iostream>
#include <cstdio>

using namespace std;

#define print(a) printf("%d\n", a)

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

#define MAX(a,b) ((a)>(b)?(a):(b))


int main(){
	int co, mod, ch;
	
	while (cin >> co , co != 0){
		ch = 0;
		
		mod = 1000 - co;
	
		ch += mod/500;
		mod = mod%500;
	
		ch += mod/100;
		mod = mod%100;
	
		ch += mod/50;
		mod = mod%50;
	
		ch += mod/10;
		mod = mod%10;
	
		ch += mod/5;
		mod = mod%5;
	
		ch += mod;
	
		cout << ch << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3036
/*
配るDP
*/


# include <iostream>
# include <algorithm>

using namespace std;

int N;
long long height[100010], dp[100010];
const long long INF = 1LL << 60;

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> height[i];
  
  // dp初期化
  for (int i = 0; i < N; i++) dp[i] = INF;
  
  dp[0] = 0;
  for (int i = 0; i < N; i++) {
    if (i == N - 2) {
      dp[i + 1] = min(dp[i + 1], dp[i] + abs(height[i] - height[i + 1]));
      break;
    }
    
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(height[i] - height[i + 1]));
    dp[i + 2] = min(dp[i + 2], dp[i] + abs(height[i] - height[i + 2]));
  }
  
  cout << dp[N - 1] << endl;
  
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    auto len_s = static_cast<int>(s.length());
    vector<int> cnt(len_s,1);
    rep(i,len_s){
        if(i+2<len_s&&s[i]=='R'&&s[i+1]=='R'){
            cnt[i+2]+=cnt[i];
            cnt[i]=0;
        }
    }
    rep(i,len_s){
        auto ri=len_s-1-i;
        if(ri-2>=0&&s[ri]=='L'&&s[ri-1]=='L'){
            cnt[ri-2]+=cnt[ri];
            cnt[ri]=0;
        }
    }
    rep(i,len_s){
        cout << cnt[i] << ((i==len_s-1)?"":" ");
    }
    cout << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = (1 << 30);
constexpr ll L_INF = (1ll << 62);

//==================================

template <typename _Ty>
struct Edge {
    int src, to;
    _Ty cost;

    constexpr Edge(int _to, _Ty _cost) noexcept
        : src(-1), to(_to), cost(_cost) {}
    constexpr Edge(int _src, int _to, _Ty _cost) noexcept
        : src(_src), to(_to), cost(_cost) {}
};
template <typename _Ty>
using WeightedGraph = std::vector<std::vector<Edge<_Ty>>>;

template <typename _Ty>
void dijkstra(std::vector<_Ty>& dist, std::vector<int>& prev,
              const WeightedGraph<_Ty>& g, int s) {
    constexpr _Ty inf = std::numeric_limits<_Ty>::max();
    dist.assign(g.size(), inf);
    prev.assign(g.size(), -1);

    using Pi = std::pair<_Ty, int>;
    std::priority_queue<Pi, std::vector<Pi>, std::greater<Pi>> q;
    dist[s] = 0;
    q.emplace(dist[s], s);
    while (!q.empty()) {
        _Ty cost;
        int idx;
        tie(cost, idx) = q.top();
        q.pop();
        if (dist[idx] < cost) continue;
        for (const auto& edge : g[idx]) {
            _Ty next_cost = cost + edge.cost;
            if (next_cost >= dist[edge.to]) continue;
            dist[edge.to] = next_cost;
            prev[edge.to] = idx;
            q.emplace(next_cost, edge.to);
        }
    }
}

Vi dist, prev_idx;
WeightedGraph<int> g;
Vi checked;
Vi tami;

int dfs(int u) {
    int tmp = dist[u];
    for (const auto& to : g[u]) {
        if (checked[to.to] != 0) continue;
        checked[to.to] = 1;
        tmp = max(tmp, dfs(to.to));
    }
    tami[u] = tmp;
    return tmp;
}

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

    int N, U, V;
    cin >> N >> U >> V;
    --U;
    --V;

    g.resize(N);
    for (int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a].emplace_back(b, 1);
        g[b].emplace_back(a, 1);
    }

    dijkstra(dist, prev_idx, g, V);

    tami.resize(N);
    checked.resize(N);
    checked[V] = 1;
    dfs(V);

    int ad = (dist[U] - 1) / 2;

    int max_tami = tami[U];
    int tmpU = U;
    for (int i = 0; i < ad; ++i) {
        tmpU = prev_idx[tmpU];
        max_tami = max(max_tami, tami[tmpU]);
    }

    cout << max_tami - 1 << endl;

    return 0;
}

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

constexpr int64_t INF = 1e18;
constexpr int D = 365;
constexpr int N = 26;
int c[N];
int s[D + 1][N];
int last[D + 1][N];
int64_t score[D + 1];
int t[D + 1];

constexpr int64_t CYCLES_PER_SEC = 2800000000;
constexpr double TIMELIMIT = 1.95;
struct Timer {
	int64_t start;
	Timer() { reset(); }
	void reset() { start = getCycle(); }
	void plus(double a) { start -= (a * CYCLES_PER_SEC); }
	inline double get() { return (double)(getCycle() - start) / CYCLES_PER_SEC; }
	inline int64_t getCycle() {
		uint32_t low, high;
		__asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));
		return ((int64_t)low) | ((int64_t)high << 32);
	}
};
mt19937 mt{random_device{}()};
uniform_int_distribution<int> rnd_contest(0, N - 1);
uniform_int_distribution<int> rnd_day(1, D);

void input() {
	int _d; cin >> _d;
	for(int i = 0; i < N; ++i) {
		cin >> c[i];
	}
	for(int i = 1; i <= D; ++i) {
		for(int j = 0; j < N; ++j) {
			cin >> s[i][j];
		}
	}
}

void greedy(int day) {
	for(int i = day; i <= D; ++i) {
		for(int j = 0; j < N; ++j) {
			last[i][j] = last[i - 1][j];
		}
		int64_t loss = 0;
		for(int j = 0; j < N; ++j) {
			loss += c[j] * (i - last[i][j]);
		}
		int64_t maxi = -INF;
		int midx = 0;
		for(int j = 0; j < N; ++j) {
			int64_t los = loss - c[j] * (i - last[i][j]);
			if(s[i][j] - los > maxi) {
				maxi = s[i][j] - los;
				midx = j;
			}
		}
		last[i][midx] = i;
		t[i] = midx;
	}
}

int64_t calc(int day) {
	int64_t ans = score[day - 1];
	for(int i = day; i <= D; ++i) {
		for(int j = 0; j < N; ++j) {
			last[i][j] = last[i - 1][j];
		}
		last[i][t[i]] = i;
		ans += s[i][t[i]];
		for(int j = 0; j < N; ++j) {
			int64_t loss = c[j] * (i - last[i][j]);
			ans -= loss;
		}
		score[i] = ans;
	}
	return ans;
}

void output() {
	for(int i = 1; i <= D; ++i) {
		cout << t[i] + 1 << '\n';
	}
}

int main() {
	Timer timer;
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	input();
	greedy(1);
	int64_t score = calc(1);
	int cnt = 0, update = 0;
	while(timer.get() < TIMELIMIT) {
		++cnt;
		int q = rnd_contest(mt);
		int d = rnd_day(mt);
		int pre = t[d];
		t[d] = q;
		int64_t nxt = calc(d);
		if(nxt > score) {
			score = nxt;
			update++;
		} else {
			t[d] = pre;
		}
	}
	// cerr << cnt << " " << update << '\n';
	output();
	// for(int i = 0; i < D; ++i) {
	// 	cin >> t[i];
	// }
	// cout << calc() << '\n';
	// int m; cin >> m;
	// while(m--) {
	// 	int d, q; cin >> d >> q;
	// 	--d, --q;
	// 	t[d] = q;
	// 	cout << calc() << '\n';
	// }
	return 0;
}


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

long long n, d[3] = {};
string res;
vector<string> s;

bool solve();

int main() {
  cin >> n;
  for (int i = 0; i < 3; ++i) cin >> d[i];
  s.resize(n);
  for (int i = 0; i < n; ++i) cin >> s[i];
  if (solve()) {
    cout << "Yes" << endl;
    for (int i = 0; i < n; ++i) cout << res[i] << endl;
  } else
    cout << "No" << endl;
  return 0;
}

bool solve() {
  if (d[0] + d[1] + d[2] == 0) return 0;
  for (int i = 0; i < n; ++i) {
    int x = s[i][0] - 'A', y = s[i][1] - 'A';
    if (d[x] > d[y])
      swap(x, y);
    else if (d[x] == d[y]) {
      if (d[x] == 0) return 0;
      if (i + 1 < n && s[i] != s[i + 1] &&
          (y == s[i + 1][0] - 'A' || y == s[i + 1][1] - 'A'))
        swap(x, y);
    }
    ++d[x];
    --d[y];
    res += x + 'A';
  }
  return 1;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
namespace LCY{
	#define double long double
	const double EPS=1e-10;
	inline int dcmp(double x){if(fabs(x)<EPS)return 0;return (x<0)?-1:1;}
	struct Point{double x,y;Point(double _x=0,double _y=0){x=_x;y=_y;}};
	struct Vector{double x,y;Vector(double _x=0,double _y=0){x=_x;y=_y;}};
	
	Vector operator - (Point a,Point b){return Vector(a.x-b.x,a.y-b.y);}
	Vector operator * (Vector a,double d){return Vector(a.x*d,a.y*d);}
	Point operator + (Point a,Vector b){return Point(a.x+b.x,a.y+b.y);}
	
	inline double dot(Vector a,Vector b){return a.x*b.x+a.y*b.y;}
	inline double cross(Vector a,Vector b){return a.x*b.y-a.y*b.x;}
	inline double norm(Vector a){return dot(a,a);}
	
	struct Line{
		Point p1,p2;
		Line(Point _p1=Point(0,0),Point _p2=Point(0,0)){p1=_p1;p2=_p2;}
	};
	inline bool is_parallel(Line l1,Line l2){
		return dcmp(cross(l2.p2-l2.p1,l1.p2-l1.p1))==0;
	}
	inline bool is_vertical(Line l1,Line l2){
		return dcmp(dot(l2.p2-l2.p1,l1.p2-l1.p1))==0;
	}
	
	Point project(Line l,Point p){
		Vector base=l.p2-l.p1;
		double r=dot(p-l.p1,base)/norm(base);
		return l.p1+base*r;
	}
	Point reflect(Line l,Point p){
		Point q=project(l,p);
		Vector v=p-q;v.x=-v.x;v.y=-v.y;
		return q+v;
	}
	int ccw(Vector v1,Vector v2){
		if(dcmp(cross(v1,v2))>0)return 1;//COUNTER_CLOCKWISE
		else if(dcmp(cross(v1,v2))<0)return 2;//CLOCKWISE
		else{
			if(dcmp(dot(v1,v2))<0)return 3;//ONLINE_BACK
			else{
				if(dcmp(norm(v1)-norm(v2))<0)return 4;//ONLINE_FRONT
				else return 5;//ON_SEGMENT
			}
		}
	}
}
using namespace LCY;
int main(){
	int n;cin>>n;while(n--){
		Point p1,p2;cin>>p1.x>>p1.y>>p2.x>>p2.y;
		Line l1=Line(p1,p2);
		cin>>p1.x>>p1.y>>p2.x>>p2.y;
		Line l2=Line(p1,p2);
		if(is_parallel(l1,l2))cout<<2<<endl;
		else if(is_vertical(l1,l2))cout<<1<<endl;
		else cout<<0<<endl;
	}
	return 0;
}


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

int main()
{
    string S;
    cin >> S;
    if (S[S.size() - 1] == 's') {
        S += "es";
    } else {
        S += "s";
    }
    cout << S;
    return 0;
}

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

int32_t main()
{
	int k,x;
	cin>>k>>x;
	if(k*500 >= x)
	{
		cout<<"Yes"<<endl;
	}
	else
		cout<<"No"<<endl;
	
	
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    string a, b, c; cin >> a >> b >> c;
    string ans = "A";
    ans += b[0];
    ans += "C";
    cout << ans << endl;
}

Measured memory_bytes: 3636
from heapq import heappush, heappop
from itertools import permutations, accumulate
import math
import bisect
from collections import defaultdict, deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(1000000)
# MOD = 10 ** 9 + 7
# INF = float("inf")

def main():
    n, m = map(int, input().split())
    print((n-1) * (m-1))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n, t;
    cin >> n >> t;
    vector<P> v;
    rep(i,n){
        P p;
        cin >> p.first >> p.second;
        v.push_back(p);
    }
    sort(v.begin(), v.end());
    int ans = 0;

    int dp[t] = {};
    rep(i,n){
        drep(j,t){
            ans = max(ans, dp[j] + v[i].second);
            if(v[i].first > j)break;
            else dp[j] = max(dp[j], dp[j-v[i].first] + v[i].second);
        }
    }

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


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

const int MAX = 100;
const int INF = 1 << 29;

int main()
{
	while (true) {
		int n, m, s, g1, g2;
		int cost[MAX][MAX];
		int ans = INF;

		cin >> n >> m >> s >> g1 >> g2;

		if (n == 0 && m == 0 && s == 0 && g1 == 0 && g2 == 0) {
			break;
		}

		rep(i, MAX) {
			rep(j, MAX) {
				if (i == j) {
					cost[i][j] = 0;
				}
				else {
					cost[i][j] = INF;
				}
			}
		}

		rep(i, m) {
			int b1, b2, c;

			cin >> b1 >> b2 >> c;

			cost[b1 - 1][b2 - 1] = c;
		}

		rep(k, n) {
			rep(i, n) {
				rep(j, n) {
					cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
				}
			}
		}

		rep(i, n) {
			ans = min(ans, cost[s - 1][i] + cost[i][g1 - 1] + cost[i][g2 - 1]);
		}
		
		cout << ans << endl;
	}

	return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0; i<n; i++)

const int INF = 1001001001;

bool IsPalindrome(string s){
  int sn = s.length();
  rep(i, (sn-1)/2+1){
    if(s[i]!=s[sn-i-1]) return false;
  }
  return true;
}

void solve(){
  string s; cin >> s;
  int sn = s.length();
  string sub1 = s.substr(0, (sn-1)/2);
  string sub2 = s.substr((sn+3)/2-1, (sn-1)/2);
  if(IsPalindrome(s) && IsPalindrome(sub1) && IsPalindrome(sub2)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

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

    int d, e;
    while (cin >> d >> e, d) {
        double ans = 1e9;
        for (int x = 0; x <= d; x++) {
            int y = d - x;
            ans = min(ans, abs(sqrt(x * x + y * y) - e));
        }
        printf("%.10f\n", ans);
    }
}

Measured memory_bytes: 3212