akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unistd.h>
#define ll long long
#define inf 1000000007
#define inf16 0x3f3f3f3f
#define INF 1000000000000000007LL
#define VI vector<int>
#define VPII vector<pair<int, int> >
#define VLL vector<ll>
#define PII pair<int, int>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
using namespace std;

#define int ll
const int mod = 1e9+7;
const int N = 307;

int n, m;

int dp[N][N][N];

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	cin >> n >> m;

	dp[0][1][0] = 1;

	for(int d = 0; d < m; ++d)
	{
		for(int z = 1; z <= n; ++z)
		{
			for(int nz = 0; z+nz <= n; ++nz)
			{
				dp[d+1][z+nz][0] += dp[d][z][nz]*z%mod;
				dp[d+1][z+nz][0] %= mod;

				dp[d+1][z][nz+1] += dp[d][z][nz]*(n-z-nz)%mod;
				dp[d+1][z][nz+1] %= mod;

				dp[d+1][z][nz] += dp[d][z][nz]*nz%mod;
				dp[d+1][z][nz] %= mod;
			}
		}
	}

	cout << dp[m][n][0];
}

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

typedef long long ll;
const ll INF = (ll)(1e18);
const int MAX_N = 1e5+5;

ll a[MAX_N];

int main() {

    int n; cin >> n;
    ll ans = 1LL;
    bool zero = false;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] == 0) zero = true;
    }

    if (zero) {
        cout << 0;
        return 0;
    }

    for (int i = 0; i < n; i++) {
        ll x; x = a[i];

        ll tmp = INF / ans;
        //cout << "D: " << ans << " " << tmp << "\n";
        if (x > tmp) {
            cout << "-1";
            return 0;
        }

        ans *= x;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 4328
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define dump(x) cerr << #x << " : " << x << '\n'
#define MOD(x, y) (((y) + (x) % (y)) % (y))

int N;
int C[500];
int S[500];
int F[500];

int main(int argc, char* argv[])
{
	scanf("%d", &N);
	for (int i = 1; i <= N - 1; i++) {
		scanf("%d%d%d", &C[i], &S[i], &F[i]);
	}

	for (int i = 1; i <= N; i++) {
		int t = 0;
		for (int j = i; j <= N - 1; j++) {
			t = max((t % F[j] == 0) ? t : t + (F[j] - t % F[j]), S[j]);
			t += C[j];
		}
		printf("%d\n", t);
	}

	return 0;
}


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

int p[5005], c[5005], n, k;
long long ans = -2e15;

int main() {
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        cin >> p[i];
    for(int i = 1; i <= n; i++)
        cin >> c[i];

    for(int i = 1; i <= n; i++) {
        int cycleSize = 0;
        long long cycleSum = 0;
        int v = i;
        while(true) {
            cycleSize++;
            cycleSum += c[v];
            v = p[v];
            if(v == i) break;
        }

        int cnt = 0;
        long long sum = 0;
        while(true) {
            cnt++;
            sum += c[v];

            if(cnt > k) break;
            int completeCycles = (k-cnt)/cycleSize;
            long long score = sum + max(0LL, cycleSum)*completeCycles;
            ans = max(ans, score);

            v = p[v];
            if(v == i) break;
        }
    }

    cout << ans;
}


Measured memory_bytes: 3684
#include <iostream>
int main(){
//  int i = 1;

  int x = 1;
  int y = 1;

  int tmp;
  while(1){
    std::cin >> x >> y;
    if(x == 0 && y == 0){
      break;
    }
    if(x>y){
      tmp = x;
      x = y;
      y = tmp;
    }
    std::cout << x << " " << y <<std::endl;
//    i++;
  }
}



Measured memory_bytes: 3080
def main():
    N = int(input())
    X = [int(i) for i in input().split()]
    ans = 10**9
    for i in range(1, 101):
        p = i
        cur = 0
        for j in range(N):
            cur += (X[j] - p)**2
        ans = min(ans, cur)
    print(ans)


if __name__ == '__main__':
    main()


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int h, w, d; cin >> h >> w >> d;
    map<int, P> co;
    
    rep(i, h){
        rep(j, w){
            int a; cin >> a; a--;
            co[a] = P(i, j);
        }
    }

    auto dist = [&](int i, int j){
        return abs(co[i].fi - co[j].fi) + abs(co[i].se - co[j].se); 
    };
    
    vvi ruiseki(d, {0});
    rep(i, d){
        int now = i;
        int next = i + d;
        int tot = 0;
        while(next < h * w){
            tot += dist(now, next);       
            ruiseki[i].pb(tot);
            now += d;
            next += d;
        }
    }
    
    int q; cin >> q;
    while(q--){
        int l, r; cin >> l >> r; l--; r--;
        int rem = l % d;
        cout << ruiseki[rem][r/d] - ruiseki[rem][l/d] << endl;
    }
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 13572
/*
[keyence2019] C - Exam and Wizard
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 1e5;

int N;
int A[MAX_N], B[MAX_N];

ll solve() {
    int d[MAX_N];
    for (int i = 0; i < N; i++) {
        d[i] = A[i] - B[i];
    }
    sort(d, d + N);

    ll s = 0;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (d[i] >= 0) {
            break;
        }
        s += -d[i];
        ans++;
    }
    for (int i = N - 1; i >= 0; i--) {
        if (d[i] <= 0 || s <= 0) {
            break;
        }
        s -= d[i];
        ans++;
    }

    return s <= 0 ? ans : -1;
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 1408
import math
N = int(input())
cnt = [[0] * 10 for _ in range(10)]
for i in range(1, N+1):
    d = int(math.log(i, 10))
    cnt[i//(10**d)][i % 10] += 1
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += cnt[i][j] * cnt[j][i]

print(ans)



Measured memory_bytes: 40300
#include <iostream>
#include <string>
#include <cstdlib>
#include <queue>
using namespace std;


int main() {
    queue<char> q;
    string s;
    int i, j, h, num;

    cin >> s;

    while(s!="-"){

    for(i=0;i<s.size();i++){
        q.push(s[i]);
    }

    cin >> num;

    for(i=0;i<num;i++){
        cin >> h;
        for(j=0;j<h;j++){
            q.push(q.front());
            q.pop();
        }
    }

    for(i=0;i<s.size();i++){
        cout << q.front();
        q.pop();
    }
    cout << endl;

    cin >> s;
    }

    return 0;
}


Measured memory_bytes: 3224
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
using namespace std;

int INF = 1e9 + 7;

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

int main() {
	int n;
	cin >> n;
	vector<ll> a(n + 2), sum1(n + 2, 0), sum2(n + 2, 0);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sum1[i] = sum1[i - 1] + a[i];
		sum2[i] = sum1[i];
	}

	ll ans1 = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 2 == 1) {
			if (sum1[i] <= 0) {
				ans1 += -sum1[i] + 1;
				sum1[i] = 1;
			    sum1[i + 1] = sum1[i] + a[i + 1];

			}
		}
		else {
			if (sum1[i] >= 0) {
				ans1 += sum1[i] + 1;
				sum1[i] = -1;
 				sum1[i + 1] = sum1[i] + a[i + 1];
			}
		}
		sum1[i + 1] = sum1[i] + a[i + 1];
	}

	ll ans2 = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 2 == 0) {
			if (sum2[i] <= 0) {
				ans2 += -sum2[i] + 1;
				sum2[i] = 1;
				sum2[i + 1] = sum2[i] + a[i + 1];

			}
		}
		else {
			if (sum2[i] >= 0) { 
				ans2 += sum2[i] + 1;
				sum2[i] = -1;
				sum2[i + 1] = sum2[i] + a[i + 1];
			}
		}
		sum2[i + 1] = sum2[i] + a[i + 1];
	}
	cout << min(ans1, ans2) << endl;
}

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

#define ll long long

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

	if((a+b)%2 == 0){
		ll k = (ll) (a+b)/2LL;
		cout << k << endl;
	}

	else{
		cout << "IMPOSSIBLE" << endl;
	}
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){

  int n;
  cin >> n;
  ll dp[n+10];
  dp[0] = 0;
  const ll INF = 1e15; 
  FOR(i,1,n+10) dp[i] = INF;
  ll h[n+2];
  rep(i,n) cin >> h[i];
  rep(i,n){
    dp[i+1] = min<ll>(dp[i] + abs(h[i+1]-h[i]),dp[i+1]);
    dp[i+2] = min<ll>(dp[i] + abs(h[i+2]-h[i]),dp[i+2]);
  }
  cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<map>
#include<iomanip>
#include<limits>
#include<queue>
#include<set>
#include<cstdio>
#include<climits>
#include<cstring>

using namespace std;

int main(){

    int a[3] = {};
    int s = 0;
    cin >> a[0] >> a[1] >> a[2];

    while(1){
    	sort(a,a+3);
    	if(a[0] == a[1] && a[1] == a[2]){
    		break;
    	}
    	if(a[0] == a[1]){
    		a[0] += 1;
    		a[1] += 1;
    	}else{
    		a[0] += 2;
    	}
    	s++;
    }


	cout << s << endl;

	return 0;

}


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

typedef long long int ll;

int main()
  
{
	ll n;cin>>n;
  	map<string,ll> mp;
  for(int i=0;i<n;i++)
  {
  	string a;cin>>a;
    mp [a]+=1;
  } 
 
  ll max=0;
  
  for(auto v: mp)
  {
  		if(max<v.second)
          max=v.second;
  }
  for(auto v: mp)
  {
  		if(v.second==max)
          cout<<v.first<<endl;
  }
}

Measured memory_bytes: 25216
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}

int main(){
    int a,b; cin >> a >> b;
    
    cout << max(a+b,max(a-b,a*b)) << endl;
}







Measured memory_bytes: 256
def main():
    N = int(input())
    S = input()
    S = S.lower()
    ans = []
    A = [
        "a",
        "b",
        "c",
        "d",
        "e",
        "f",
        "g",
        "h",
        "i",
        "j",
        "k",
        "l",
        "m",
        "n",
        "o",
        "p",
        "q",
        "r",
        "s",
        "t",
        "u",
        "v",
        "w",
        "x",
        "y",
        "z",
    ]

    for I in range(len(S)):
        X = A.index(S[I])
        if X + N >= 26:
            X = X - 26
        ans.append(A[X + N])

    answer = "".join(ans)
    answer = answer.upper()

    print(answer)


if __name__ == "__main__":
    main()


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

int main(){
	// ios_base::sync_with_stdio(false); 
 //    cin.tie(NULL); 
    ll n,k;
    cin >> n >> k;
    vector <ll> arr(n);
    vector <ll> num(64,0);
    for (int z=0;z<n;z++) cin >> arr[z];
   	for (int z=0;z<n;z++){
   		string temp = bitset<64>(arr[z]).to_string();
   		for (int x=0;x<64;x++){
   			if (temp[x] == '1'){
   				num[x]++;
   			}
   		}
   	}
   	string answer;
   	for (int z=0;z<64;z++){
   		if (num[z] >= ceil(double(n)/2)) answer += '0';
   		else answer += '1';
   	}
   	long long temp = 0;
   	for (int z=0;z<64;z++){
   		if (answer[z] == '1' && temp+pow(2,63-z) <= k) {
   			temp += pow(2,63-z);
   		}
   	}
   	long long answera =0;
   	for (int z=0;z<n;z++){
   		answera += arr[z]^temp;
   	}
   	cout << answera << endl;
   	cin >> n;
}


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

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

int main(void)
{
    string s,t; cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if(s<t) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
N,K=list(map(int,input().split()))
A=list(map(int,input().split()))
dp=[0]*(N)
dp[0]=0
dp[1]=abs(A[1]-A[0])

for i in range(2,N):
    mina=10**9
    for j in range(1,K+1):
        if(i-j>=0):
            mina=min(dp[i-j]+abs(A[i]-A[i-j]),mina)
    dp[i]=mina
# print(dp)
print(dp[N-1])

Measured memory_bytes: 84776
#include <string.h>
#include <stdio.h>
#define REP(a) for(i = 0; i < a; i++)

int main(void) {
    int i,j;
    char a[105],b[105],tmp;
    scanf("%s",a);
    scanf("%s",b);
    REP(strlen(a)) {
        for (j = i + 1; j < strlen(a); j++) {
            if (a[i] > a[j]) {
                tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
            }
        }
    }
    REP(strlen(b)) {
        for (j = i + 1; j < strlen(b); j++) {
            if (b[i] < b[j]) {
                tmp = b[i];
                b[i] = b[j];
                b[j] = tmp;
            }
        }
    }
    if (strcmp(a, b) < 0) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
def main():
    import sys
    from bisect import bisect
    from operator import itemgetter
    b=sys.stdin.buffer
    n,d,a=map(int,b.readline().split())
    m=map(int,b.read().split())
    c=[0]*(n+1)
    z=sorted(zip(m,m),key=itemgetter(0))
    y=[x for x,_ in z]
    s=0
    for i,(x,h)in enumerate(z):
        c[i]+=c[i-1]
        h-=c[i]
        t=-h//a
        if t>0:t=0
        c[i]-=t*a
        c[bisect(y,x+d+d)]+=t*a
        s-=t
    print(s)
main()

Measured memory_bytes: 55768
n,m = map(int,input().split())
S = [list(map(int,input().split()))[1:] for i in range(m)]
P = list(map(int,input().split()))
ans = 0
#bit全探索
for bit in range(1<<n):
    on = []
    ok = True #全部の電球が光る
    for i in range(n):
        if (bit & (1<<i)):
            on.append(i+1)
    for i in range(m):
        p = P[i]
        c = 0
        for s in S[i]:
            if s in on: c+=1
        if c%2!=p: ok=False
    if ok:ans+=1
print(ans)

Measured memory_bytes: 42096
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int res = 0, n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int l, r;
        cin >> l >> r;
        res += r - l + 1;
    }
    cout << res << endl;
}


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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using ll = long long;
using namespace std;

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

    int n, d, sum = 0, ans = 0, t; cin >> n >> d;
    int a[n][d]; REPI(i, n)REPJ(j, d){ int x; cin >> x; a[i][j] = x; }
    REPI(i, n)
        for(int j = i; j < n - 1; j++){
            for(int k = 0; k < d; k++){
                sum += pow(a[i][k] - a[j + 1][k], 2);
            }
            t = sqrt(sum);

            //cout << sum << ' ' << pow(t, 2) << endl;
            if(sum == pow(t, 2)) ans++;
            sum = 0;
        }
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;
using ll = long long;
const int N = 85;
int a[N];

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

	for (int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);

	ll m = 1000;
	ll now = 0;
	for (int i = 1; i <= n; ++i)
	{
		if (a[i + 1] == a[i]) continue;
		if (a[i + 1] > a[i])
		{
			now += m / a[i];
			m %= a[i];
		}
		else
		{
			m += now * a[i];
			now = 0;
		}
	}

	printf("%lld\n", m);


	return 0;
}

Measured memory_bytes: 3752
import itertools
import numpy as np
n,m,x=map(int,input().split())
li=np.array([list(map(int,input().split())) for i in range(n)])
ln=[j for j in range(n)]
ans=[]
for j in range(1,n+1):
    la=list(itertools.combinations(ln, j))
    for k in la:
      ls=np.zeros(m+1, dtype = int) 
      for l in range(len(k)):
        ls=ls+li[k[l]]
      lsp=[i for i in ls[1:] if i>=x]  
      if len(lsp)==m:
        ans.append(ls[0])
if ans==[]:
  print(-1)
else:
  print(min(ans))

Measured memory_bytes: 27300
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

enum Type{
	ALL_SAME,
	ALL_DIFFERENT,
	SAME_01,
	SAME_02,
	SAME_12,
};


int LEN,LIMIT;
int count_table[5],rest[3],tmp[3];
char buf[3][SIZE];
Type type[SIZE];


bool isOK(){

	int plus_count = 0;
	int plus_index = -1;

	int num_0 = max(0,count_table[ALL_DIFFERENT]-(rest[0]-count_table[SAME_12]));
	int num_1 = max(0,count_table[ALL_DIFFERENT]-(rest[1]-count_table[SAME_02]));
	int num_2 = max(0,count_table[ALL_DIFFERENT]-(rest[2]-count_table[SAME_01]));

	if(num_0 > 0){
		plus_count++;
		plus_index = 0;
	}
	if(num_1 > 0){
		plus_count++;
		plus_index = 1;
	}
	if(num_2 > 0){
		plus_count++;
		plus_index = 2;
	}

	if(num_0+num_1+num_2 <= count_table[ALL_DIFFERENT])return true;
	if(plus_count >= 2)return false;

	int minus;

	switch(plus_index){
	case 0:

		minus = min(count_table[SAME_12],min(rest[1]-(count_table[ALL_DIFFERENT]+count_table[SAME_02]),
				rest[2]-(count_table[ALL_DIFFERENT]+count_table[SAME_01])));
		break;
	case 1:
		minus = min(count_table[SAME_02],min(rest[0]-(count_table[ALL_DIFFERENT]+count_table[SAME_12]),
						rest[2]-(count_table[ALL_DIFFERENT]+count_table[SAME_01])));
		break;
	case 2:
		minus = min(count_table[SAME_01],min(rest[0]-(count_table[ALL_DIFFERENT]+count_table[SAME_12]),
								rest[1]-(count_table[ALL_DIFFERENT]+count_table[SAME_02])));
		break;
	}

	return num_0+num_1+num_2-minus <= count_table[ALL_DIFFERENT];
}


void func(){

	for(int i = 0; i < 3; i++){

		scanf("%s",buf[i]);
	}

	for(int i = 0; i < 5; i++){

		count_table[i] = 0;
	}

	for(int i = 0; i < 3; i++){

		rest[i] = LIMIT;
	}

	for(int i = 0; i < LEN; i++){

		if(buf[0][i] == buf[1][i] && buf[0][i] == buf[2][i]){

			count_table[ALL_SAME] += 1;
			type[i] = ALL_SAME;

		}else if(buf[0][i] == buf[1][i]){

			count_table[SAME_01] += 1;
			type[i] = SAME_01;

		}else if(buf[0][i] == buf[2][i]){

			count_table[SAME_02] += 1;
			type[i] = SAME_02;

		}else if(buf[1][i] == buf[2][i]){

			count_table[SAME_12] += 1;
			type[i] = SAME_12;

		}else{

			count_table[ALL_DIFFERENT] += 1;
			type[i] = ALL_DIFFERENT;
		}
	}

	if(!isOK()){

		printf("-1\n");
		return;
	}


	vector<char> ANS,work;

	for(int i = 0; i < LEN; i++){

		work.clear();

		work.push_back('A');
		for(int k = 0; k < 3; k++){

			work.push_back(buf[k][i]);
		}
		sort(work.begin(),work.end());
		work.erase(unique(work.begin(),work.end()),work.end());

		count_table[type[i]] -= 1;

		for(int k = 0; k < work.size(); k++){

			for(int p = 0; p < 3; p++){

				tmp[p] = rest[p];
				if(buf[p][i] != work[k]){

					rest[p] -= 1;
				}
			}

			if(isOK()){

				ANS.push_back(work[k]);
				break;
			}

			for(int p = 0; p < 3; p++){

				rest[p] = tmp[p];
			}
		}
	}

	for(int i = 0; i < ANS.size(); i++){

		printf("%c",ANS[i]);
	}
	printf("\n");
}

int main(){

	while(true){

		scanf("%d %d",&LEN,&LIMIT);
		if(LEN == 0 && LIMIT == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 3952
r, c = [int(i) for i in input().split()]
 
data = []
sum_row = [0] * (c + 1)
 
for ri in range(r):
    data.append([int(i) for i in input().split()])
    data[ri].append(sum(data[ri]))
    print(" ".join([str(d) for d in data[ri]]))
    for ci in range(c + 1):
        sum_row[ci] += data[ri][ci]
 
print(" ".join([str(s) for s in sum_row]))

Measured memory_bytes: 7740
from heapq import heappop, heappush

import sys
def input():return sys.stdin.readline().strip()

def main():
    N, M, S = map(int, input().split())
    to = [{} for _  in range(N)]
    for _ in range(M):
        u, v, a, b = map(int, input().split())
        u -= 1
        v -= 1
        to[u][v] = (a, b)
        to[v][u] = (a, b)
    info = tuple(tuple(map(int, input().split())) for _ in range(N))

    MAX_SILVER = 50 * (N-1)
    INF = 10 ** 18
    # dijkstra (time, vertex, money)
    visited = [[False]*(MAX_SILVER+1) for _ in range(N)]
    cost = [[INF]*(MAX_SILVER+1) for _ in range(N)]
    q = []
    S = min(S, MAX_SILVER)
    heappush(q, (0, 0, S)) # (time, vertex, silver)

    while q:
        t, now, s = heappop(q)
        if visited[now][s]:continue
        visited[now][s] = True
        cost[now][s] = t

        # next node
        for nv, (a, b) in to[now].items():
            nt = t + b
            rest = s - a
            if rest >= 0:
                if cost[nv][rest] <= nt : continue 
                heappush(q, (nt, nv, rest))
        
        # exchange gold with silver
        rate, time = info[now]
        nt = t + time
        ns = min(s+rate, MAX_SILVER)
        heappush(q, (nt, now, ns))
        
    
    for i in range(1, N):
        print(min(cost[i]))

if __name__ == "__main__":
    main()

Measured memory_bytes: 39268
local n,m=io.read("n","n")
local t={}
for i=1,m do
	local a,b=io.read("n","n")
	t[a]=((t[a] or 0)+1)%2
	t[b]=((t[b] or 0)+1)%2
end
local checker=0
for i=1,n do
	checker=checker+(t[i] or 0)
end
print(checker>0 and "NO" or "YES")

Measured memory_bytes: 6420
n=int(input())
A=list(map(int,input().split()))

s1=0
now=0
for i in range(n):
    now+=A[i]
    if i%2==1 and now<=0:
        s1+= (1-now)
        now=1
    if i%2==0 and now>=0:
        s1+= now+1
        now=-1

s2=0
now=0
for i in range(n):
    now+=A[i]
    if i%2==0 and now<=0:
        s2+= (1-now)
        now=1
    if i%2==1 and now>=0:
        s2+= now+1
        now=-1
print(min(s1,s2))

Measured memory_bytes: 20308
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, m, s, t, u, v, A, B;
    vector<pii> g[100005] = {}, h[100005] = {};
    ll d[100005] = {}, e[100005] = {}, d2[100005] = {}, e2[100005] = {};
    bool b[100005] = {}, c[100005] = {}, b2[100005] = {}, c2[100005] = {};
    cin >> n >> m >> s >> t;
    fr1(n) d[i] = e[i] = d2[i] = e2[i] = (ll)mod * mod; d[s] = e[s] = d2[t] = e2[t] = 0;
    fr(m) cin >> u >> v >> A >> B, g[u].push_back({v, A}), g[v].push_back({u, A}), h[u].push_back({v, B}), h[v].push_back({u, B});
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> q;
    q.push({0, s});
    while (!q.empty()) {
        int p = q.top().second;
        q.pop();
        if (b[p]) continue;
        b[p] = 1;
        for (pii i : g[p]) {
            if (d[i.first] > d[p] + i.second) {
                d[i.first] = d[p] + i.second;
                q.push({d[i.first], i.first});
            }
        }
    }
    q.push({0, s});
    while (!q.empty()) {
        int p = q.top().second;
        q.pop();
        if (c[p]) continue;
        c[p] = 1;
        for (pii i : h[p]) {
            if (e[i.first] > e[p] + i.second) {
                e[i.first] = e[p] + i.second;
                q.push({e[i.first], i.first});
            }
        }
    }
    q.push({0, t});
    while (!q.empty()) {
        int p = q.top().second;
        q.pop();
        if (b2[p]) continue;
        b2[p] = 1;
        for (pii i : g[p]) {
            if (d2[i.first] > d2[p] + i.second) {
                d2[i.first] = d2[p] + i.second;
                q.push({d2[i.first], i.first});
            }
        }
    }
    q.push({0, t});
    while (!q.empty()) {
        int p = q.top().second;
        q.pop();
        if (c2[p]) continue;
        c2[p] = 1;
        for (pii i : h[p]) {
            if (e2[i.first] > e2[p] + i.second) {
                e2[i.first] = e2[p] + i.second;
                q.push({e2[i.first], i.first});
            }
        }
    }
    //fr1(n) cout << d[i] << ' ' << e[i] << ' ' << d2[i] << ' ' << e2[i] << '\n';
    vector<ll> z;
    for (int i = n; i; i--) {
        z.push_back(d[i] + e2[i]);
    }
    fr1(z.size() - 1) z[i] = min(z[i], z[i - 1]);
    reverse(z.begin(), z.end());
    fr(n) cout << 1000000000000000ll - z[i] << '\n';
}


Measured memory_bytes: 18804
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, cnt = 0;
  bool used[100000] = {};
  cin >> n;
  vector<int> a(n+1);
  for(int i=1;i<=n;i++){
	cin >> a[i];    
  }
  for(int i=1;i<=n;i++){
    if(used[i]) continue;
	if(i == a[a[i]]){
      cnt++;
      used[a[i]] = true;
    }
  }
  cout << cnt << endl;
}

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

int main(){

  int A,B,C,D;
  int t,b;

  cin>>A>>B>>C>>D;

  if(A<B){
    t=A;
  }
  else{
    t=B;
  }

  if(C<D){
  b=C;
}
 else{
   b=D;
 }

cout<<t+b<<endl;
}

Measured memory_bytes: 256
X = list(map(int, input().split()))
sx = X[0]
sy = X[1]
tx = X[2]
ty = X[3]
x = tx - sx
y = ty - sy
l1 = "U" * y + "R" * x
l2 = "D" * y + "L" * x
l3 = "L" + "U" * (y + 1) + "R" * (x + 1) + "D"
l4 = "R" + "D" * (y + 1) + "L" * (x + 1) + "U"
print(l1 + l2 + l3 + l4)

Measured memory_bytes: 3064
import sys

N = int(input())
d = {}
for i in range(N):
    d[i+1] = int(input())

x = 1
n = 0
while x != 2:
    x = d[x]
    n += 1
    if n > N:
        x = -1
        n = -1
        break

print(n)

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

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

  int n,a;cin>>n>>a;

  if(n%500<=a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;

  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e9;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> A;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j <= M; j++) {
            int val;
            cin >> val;
            A.push_back(val);
        }
    }

    ll sum = 0, bestsum = INF;
    for(int mask = 0; mask < (1<<N); mask++) {
        vector<int> subset, algos(M, X);
        for(int i = 0; i < N; i++) {
            if(mask&(1<<i)) {
                for(int j = i*(M+1); j < (i+1)*(M+1); j++) {
                    subset.push_back(A[j]);
                }
            }
        }

        sum = 0;
        for(int i = 0; i < subset.size()/(M+1); i++) {
            sum += subset[i*(M+1)];
            int z = 0;
            for(int j = i*(M+1)+1; j < (i+1)*(M+1); j++) {
                algos[z] -= subset[j];
                z++;
                //cout << subset[j] << " ";
            }
            //cout << "\n";
        }

        bool isgood = 1;
        for(int i = 0; i < M; i++) {
            if(algos[i] > 0) {
                isgood = 0;
                break;
            }
        }

        if(isgood) bestsum = min(bestsum, sum);
    }

    bestsum == INF ? cout << "-1" : cout << bestsum;
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define Vecpr vector<pair<lli,lli>>
int main() {
  lli N,D,X,B=0;
  cin >>N>>D>>X;
  if(N+X-1>D){
    for(int i=N;i<D+1;i++)Out(i);
  }
  else for(int i=N;i<N+X;i++)Out(i);
  if(N+X-1<D-X+1){
    for(int i=D-X+1;i<D+1;i++)Out(i);
  }
  else for(int i=N+X;i<D+1;i++)Out(i);
}

Measured memory_bytes: 256
class Union:
  # コンストラクタ
  def __init__(self, num):
    self.T = [-1 for i in range(num)]

  # 親を探すメソッド
  def root(self, x):
    if self.T[x] < 0: return x
    self.T[x] = self.root(self.T[x])
    return self.T[x]

  # サイズを返すメソッド
  def size(self, x):
    return -self.T[self.root(x)]

  # くっつけるメソッド
  def merge(self, x, y):
    a = self.root(x)
    b = self.root(y)
    if a == b: return False
    if self.size(a) < self.size(b): a, b = b, a
    self.T[a] += self.T[b]
    self.T[b] = a
    return True

N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(M)]
 
AB.reverse()
 
uni = Union(N + 1)
L = []
Ans = N * (N - 1) // 2
for i in AB:
  L.append(Ans)
  a = uni.root(i[0])
  b = uni.root(i[1])
  if a != b:
    Ans -= uni.size(a) * uni.size(b)
    uni.merge(i[0], i[1])
 
for i in L[::-1]:
  print(i)


Measured memory_bytes: 34220
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
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; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int w[1000];
int v[1000];
ll dp[101][100001];

int main() {
  int n,W;
  while(input(n,W)) {
    REP(i,n) {
      input(w[i],v[i]);
    }
    memset(dp,0,sizeof(dp));
    REP(i,n) {
      REP(j,W+1) {
        chmax(dp[i+1][j], dp[i][j]);
        if (j+w[i]<=W)
          chmax(dp[i+1][j+w[i]], dp[i][j] + v[i]);
      }
    }
    cout << dp[n][W] << endl;
  }
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int a, b, c, d; scanf("%d%d%d%d", &a, &b, &c, &d);
	
	printf("%d\n", std::min(a, b) + std::min(c, d));
	return 0;
}


Measured memory_bytes: 256
from sys import stdin
#import numpy as np


def merge_sort(lst, low, high):
    if low >= high:
        return
    mid = int((low+high)/2)
    merge_sort(lst, low, mid)
    merge_sort(lst, mid+1, high)
    for i in range(low, mid+1):
        tmp_array[i] = lst[i]
    j = high
    for i in range(mid+1, high+1):
        tmp_array[i] = lst[j]
        j -= 1
    i = low
    j = high
    for k in range(low, high+1):
        if tmp_array[i] <= tmp_array[j]:
            lst[k] = tmp_array[i]
            i += 1
        else:
            lst[k] = tmp_array[j]
            j -= 1


S = stdin.readline().rstrip()
N = len(S)
Sp = S

res_map = [0 for _ in range(N)]

aa_list2 = [1]
for i in range(1,N):
    aa_list2.append((aa_list2[i-1]*10)%2019)

tmp_array = [None for _ in range(N)]
res_map[N-1] = int(S[N-1])
index=1
for i in range(N-2,-1,-1):
    res_map[i] = (int(S[i])*aa_list2[index] + res_map[i+1])%2019
    index+=1

res_map.sort()
temp_num=int(res_map[0])
index=1
tot = 0

aa_table = [0 for i in range(2019)]
aa_table2 = [0 for i in range(2019)]
for i in range(len(res_map)):
    aa_table2[res_map[i]]+=1

aa_table2[0]+=1

#sort check
for i in range(1,N):
    if res_map[i]<res_map[i-1]:
        aa = 2/0

for i in range(1,len(res_map)):
    if temp_num==int(res_map[i]):
        index+=1
        if i==len(res_map)-1:
            aa_table[temp_num]=index
        continue
    else:
        aa_table[temp_num] = index
        index=1
        temp_num=int(res_map[i])
        if i==len(res_map)-1:
            aa_table[temp_num]=1

aa_table[0] += 1 


tot = 0
for i in range(2019):
    tot+=int((aa_table[i]-1)*aa_table[i]/2)



#for i in range(2018):
#    num = np.sum(np.array(res_map)==i)
#    if i ==0:
#        num+=1
#    tot += int(num*(num-1)/2)
    

print(tot)



Measured memory_bytes: 25768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
typedef vector<string> vs;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
ll n;
string s;
vl Zalgo(string &t){
    ll m=sz(t);
    int i=1,j=0;
    vl a(m,0);
    while(i<m){
        while(i+j<m&&t[i+j]==t[j])j++;
        a[i]=j;
        if(j==0){
            i++;
            continue;
        }
        int k=1;
        while(i+k<m&&a[k]<j-k){
            a[i+k]=a[k];
            k++;
        }
        i+=k;
        j-=k;
    }
    a[0]=m;
    return a;
}
int main(){
    cin>>n>>s;
    ll ans=0;
    for(int i=0;i<n;i++){
        string t=s.substr(i);
        auto a=Zalgo(t);
        for(ll j=0;j<sz(t);j++){
            ll len=min(a[j],j);
            chmax(ans,len);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<int,int>
#define endl "\n"
#define MAXN 100005
using namespace std;
int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
	// cout.tie(NULL);
    ll n,k;
    cin>>k>>n;
    ll a[n];
    ll a1 = 0;
    ll a2 = 0;
    for(ll i=0; i<n; i++)
    {
        cin>>a[i];
    }
    ll ans = min(a[n-1] - a[0], k - a[1] + a[0]);
    for (ll i = 1; i < (n-1); i++)
    {
        /* code */
        // cout<<k + a[i] - a[i+1]<<'\n';
        ans = min(ans, k + a[i] - a[i+1]);
        ans = min(ans, k + a[i-1] - a[i]);
    }
    ans =  min(ans, k - a[n-1] + a[n-2]);
    cout<<ans<<'\n';
}

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

int main(){
  string s;
  int i;
  cin>>s;
  for(i=s.size()-1;i>=0;i--){
    if(i%2==1){
      continue;
    }else{
    for(int j=0;j<i;j++){
      if(s[j]!=s[j+i/2]){
         break;
      }
      if(j==i/2-1){
        cout<<i<<endl;
        return 0;
      }
    }
    }
  }
}

Measured memory_bytes: 256
N=int(input())

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return (lower_divisors + upper_divisors[::-1])[1:]

F = make_divisors(N)
count = 0
for f in F:
  n = N
  while 1:
    if n % f != 0:
      n = n % f
    else:
      n = n // f
    if n < f:
      break
  if n == 1: count += 1
print(count + len(make_divisors(N-1)))

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

static const int NIL = -1;

struct Node {
    int parent, left, right;
};

Node T[26];

void pre_parse(int u) {
    if (u == NIL) return;
    cout << " " << u;
    pre_parse(T[u].left);
    pre_parse(T[u].right);
}

void in_parse(int u) {
    if (u == NIL) return;
    in_parse(T[u].left);
    cout << " " << u;
    in_parse(T[u].right);
}

void post_parse(int u) {
    if (u == NIL) return;
    post_parse(T[u].left);
    post_parse(T[u].right);
    cout << " " << u;
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        T[i].parent = T[i].left = T[i].right = NIL;

    for (int i = 0; i < n; i++) {
        int u, l, r;
        cin >> u >> l >> r;
        T[u].left = l;
        T[u].right = r;
        if (l != NIL) T[l].parent = u;
        if (r != NIL) T[r].parent = u;
    }

    int root;
    for (int i = 0; i < n; i++) {
        if (T[i].parent == NIL) root = i;
    }

    cout << "Preorder" << endl;
    pre_parse(root);
    cout << endl;
    cout << "Inorder" << endl;
    in_parse(root);
    cout << endl;
    cout << "Postorder" << endl;
    post_parse(root);
    cout << endl;

    return 0;
}


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

#define ll long long

using namespace std;

void scan() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int maxn = 1e6 + 7;
int a[maxn];

int main() {
//    scan();
    int a;
    cin >> a;
    int now = a;
    if (a & 1) a++;
    printf("%.10f\n", (a) * 1.0 / 2 * 1.0 / now);
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;

int main() {
    fast();
    // ll t;
    // cin>>t;
    // while(t--)			
    // {
         
    // }
    double d,m,s;
    cin>>d>>m>>s;
    double t=d/s;
    if(t<=m)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}

Measured memory_bytes: 3732
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <utility>
#include <sstream>
#include <iterator>

using namespace std;
// #define int long long
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)


int main(int argc, const char * argv[]) {

    int N, X;
    cin >> N >> X ;
    int L[N];
    rep(i,N){
      cin >> L[i];
    }

    int sum = 0;
    // int count = 0;

    rep(i, N){
      sum += L[i];
      if (sum > X){
        cout << i+1 << endl;
        break;
      }
    }
    if (sum <= X){
      cout << N+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

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

    FOR(i, 1, 10) {
        if(n%i==0 && 1<=n/i && n/i<=9) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
long long int N, K;
 
int main(){
	cin >> N >> K;
	int i =1;
	while(true){
	  if(N < pow(K,i)){
	  	cout << i;
	  	break;
	  }
	  i++;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <tuple>
#include<map>

using namespace std;
int main() {
	int N;
	cin >> N;

	vector<int> X;

	for (int i=0; i < N; ++i) {
		int x;
		cin >> x;
		X.push_back(x);
	}

	long long ans = 0;
	int max_num = 0;

	for (int i = 0; i < N; ++i) {
		max_num = max(max_num, X.at(i));
		ans += max_num - X.at(i);
	}

	/*for (int i = 0; i < N; ++i) {
		cout << X.at(i) << endl;
	}*/

	cout << ans << endl;

}

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

int main() {
  int A, B, C ,D;
  cin >> A >> B >> C >> D;
  if (A+B>C+D){
    cout << "Left" << endl;
  }
  else if (A+B<C+D){
    cout << "Right" << endl;
  }  
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")

#include <bits/stdc++.h>

#define mod 104857601
#define pb push_back
#define ep emplace_back
#define fr first
#define sc second
#define linf  (((1ll << 62) - 1) << 1)
#define inf (((1 << 30) - 1) << 1)

const double eps = 0.000000001;
#define ll long long
#define leps 1e-18
#define mkp make_pair
#define mpi unordered_map<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) begin(v), end(v)
#define vi vector<int>
#define vvi vector<vi>

using namespace std;

// ==============================Utils=================================//
random_device rd;
mt19937 mt(rd());

const int N_ = 100001;
vector<int> primes;
int *least_prime;
void cieve() {
  least_prime = new int[N_];
  fill(least_prime, least_prime + N_, -1);

  for (int i = 2; i < N_; i++) {
    if (least_prime[i] == -1) {
      least_prime[i] = i;
      primes.pb(i);
    }
    for (auto &c: primes) {
      if (c * i >= N_ || c > least_prime[i]) break;
      least_prime[c * i] = c;
    }
  }
}

template<typename NType>
NType gcd(NType a, NType b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template<typename NType>
NType lcm(NType a, NType b) { return a / gcd(a, b) * b; }
template<typename NType>
NType phi(NType n_) {
  NType ans = n_;
  for (NType i = 2; i * i <= n_; i++) {
    if (n_ % i == 0) {
      while (n_ % i == 0) n_ /= i;
      ans -= ans / i;
    }
  }
  if (n_ > 1) ans -= ans / n_;
  return ans;
}

int binpow(ll a, int n, const int M = mod) {
  ll res = 1;
  while (n) {
    if (n & 1) {
      res = (a * res) % M;
      n--;
    } else {
      a = (a * a) % M;
      n >>= 1;
    }
  }
  ((res %= M) += M) %= M;
  return res;
}
// ==========================End of Utils==============================//

void solve(int _T) {
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  if (x / d <= k) {

    x %= (d * 2);
    (x += 2 * d) %= 2 * d;

    if (k & 1) {
      if (x >= d) x -= d;
      else x = d - x;
    } else {
      if(x >= d) x = 2 * d - x;
    }
  } else {
    x -= k * d;
  }
  cout << x << endl;
}

#define MULTIPLE_TEST 0
#define PRECALC_CIEVE 0
int main(int argc, char const *argv[]) {
//  freopen("traffic.in", "r", stdin);
//  freopen("traffic.out", "w", stdout);

  int t{1};
  if (MULTIPLE_TEST) scanf("%d\n", &t);
  if (PRECALC_CIEVE) cieve();

  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);

  int i{0};
  while (t-- > 0) {
    solve(++i);
  }
}
/*

3 1 2
1 2
1 1

 */

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;

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

void solve16(int a, int b) {
    vector<int> v;
    REP(i,a) {
        int j;
        cin >> j;
        v.push_back(j);
    }
    vector<long> vl;
    long s = 0;
    REP(i, b) {
        s += v[i];
    }
    vl.push_back(s);
    REP(i,a-b) {
        s -= v[i];
        s += v[b+i];
        vl.push_back(s);
    }
    sort(vl.begin(), vl.end(), greater<long>());
    cout << vl[0] << endl;
}

int main() {
    int a, b;
    while(cin >> a >> b, a+b) {
        solve16(a, b);
    }
    return 0;
}

Measured memory_bytes: 2128
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

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

using namespace std;
typedef long long ll;

int main() {

    ll N;
    cin >> N;
    string out = "No";
    rep(i,9){
        rep(j,9){
            if((i+1)*(j+1) == N){
                out = "Yes";
                break;
            }
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#define LL long long
#define rint register int
#define pii pair<int,int>
#define mid ((l+r)>>1)
#define MAXN 200005
#define INF 0x3f3f3f3f
using namespace std;


int h, w, n, sx, sy, nx, ny, r[MAXN], l[MAXN], u[MAXN], d[MAXN];
char s[MAXN], t[MAXN];

int main()
{
	scanf("%d%d%d%d%d", &h, &w, &n, &sx, &sy);
	scanf("%s%s", s+1, t+1);
	nx=sx, ny=sy;
	for(rint i=1; i<=n; ++i)
	{
		if(s[i]=='L') ny--;
		if(ny<=0) {printf("NO\n"); return 0;}
		if(t[i]=='R' && ny<w) ny++;
	}
	nx=sx, ny=sy;
	for(rint i=1; i<=n; ++i)
	{
		if(s[i]=='R') ny++;
		if(ny>w) {printf("NO\n"); return 0;}
		if(t[i]=='L' && ny>1) ny--;
	}
	nx=sx, ny=sy;
	for(rint i=1; i<=n; ++i)
	{
		if(s[i]=='D') nx++;
		if(nx>h) {printf("NO\n"); return 0;}
		if(t[i]=='U' && nx>1) nx--;
	}
	nx=sx, ny=sy;
	for(rint i=1; i<=n; ++i)
	{
		if(s[i]=='U') nx--;
		if(nx<=0) {printf("NO\n"); return 0;}
		if(t[i]=='D' && nx<h) nx++;
	}
	printf("YES\n");
}

Measured memory_bytes: 512