akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int x1,y1,x2,y2,i;
    int a,b;
    scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
    a=abs(y2-y1);
    b=abs(x2-x1);
    for(i=0;i<a;i++)
        printf("U");
    for(i=0;i<b;i++)
        printf("R");
    for(i=0;i<a;i++)
        printf("D");
    for(i=0;i<b+1;i++)
       printf("L");
    for(i=0;i<a+1;i++)
        printf("U");
    for(i=0;i<b+1;i++)
        printf("R");
        printf("D");
        printf("R");
    for(i=0;i<a+1;i++)
        printf("D");
        for(i=0;i<b+1;i++)
    printf("L");
    printf("U");
   printf("\n");
    return 0;
}

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

int main(void){
    int n;
    cin>>n;
    map<string,int> result;
    result["AC"]=0;
    result["WA"]=0;
    result["TLE"]=0;
    result["RE"]=0;
    rep(i,n){
        string s;
        cin>>s;
        result[s]++;
    }
    printf("AC x %d\n",result["AC"]);
    printf("WA x %d\n",result["WA"]);
    printf("TLE x %d\n",result["TLE"]);
    printf("RE x %d\n",result["RE"]);
    return 0;
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
int main(int argc, char const *argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    int h,w,k;
    cin>>h>>w>>k;
    string grid[h];
    for(int i=0;i<h;i++) cin>>grid[i];
    int res=0;
    for(int mask=0;mask<(1<<(h+w));mask++) {
        int cnt=0;
        for(int col=0;col<w;col++) {
            for(int row=0;row<h;row++) {
                if(grid[row][col]!='#') continue;
                if((mask&((1<<col)|(1<<(w+row))))!=0) continue;
                cnt++;
            }
        }
        if(cnt==k) res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3604
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N, M; cin >> N >> M;
  vector<int>  v(N, 0);
  vector<bool> used(N, false);

  for (int i = 0; i < M; ++i) {
    int s, c; cin >> s >> c;
    --s;

    if (used[s] && v[s] != c) {
      cout << -1 << endl;
      return 0;
    }

    v[s] = c;
    used[s] = true;
  }

  if (N == 1) {
    cout << v[0] << endl;
    return 0;
  }

  if (used[0] && v[0] == 0) {
    cout << -1 << endl;
    return 0;
  }

  if (used[0]) cout << v[0];
  else         cout << 1;

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


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        
        ArrayList<Integer> l = new ArrayList<Integer>();
        for(int i=0; i<N; i++){
            l.add(Integer.parseInt(sc.next()));
        }
        
        Collections.sort(l, Comparator.reverseOrder());
        
        int ans = 0;
        for(int i=0; i<K; i++){
            ans += l.get(i);
        }
        
        System.out.println(ans);
    }
}

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

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

    int n;
    cin >> n;
    int ans = 0;
    for(int i = 11; i <= n; i += 2){
        int cnt = 0;
        for(int j = 1; j <= i; j++){
            if(i % j == 0) cnt++;
        }
        if(cnt == 8) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
l=[]
r=[]
m=[]
for i in range(n):
  a,b=map(int,input().split())
  l.append(a)
  r.append(b)
l.sort()
r.sort()
if n%2==1:
  print(r[(n-1)//2]-l[(n-1)//2]+1)
else:
  print(r[(n//2-1)]+r[n//2]-l[n//2]-l[n//2-1]+1)

Measured memory_bytes: 99008
# include<stdio.h>
int main()
{
	int a,n,b;
	scanf("%d%d",&a,&n);
	while(n--)
	{
		scanf("%d",&b);
		a=a-b;
	}
	if(a>0)
		printf("No");
	else
		printf("Yes");

	return 0;
}


Measured memory_bytes: 128
N=int(input())
A=[int(i) for i in input().split()]
#len(A)=N+1
ak=1-A[0]
if ak<0:
    print(-1)
    exit()
a=[ak]
k=0
while(ak>=0 and k<N):
    ak=2*ak-A[k+1]
    a.append(ak)
    if ak<0:
        print(-1)
        exit()
    if ak>=10**14:
        #以降に関わらず構成可能
        break
    k+=1
#print(a)
M=len(a)
for k in range(N,0,-1):
    if k<=M:
        A[k-1]+=min(A[k],a[k-1])
    else:
        A[k-1]+=A[k]
        continue
print(sum(A))
#print(A)


Measured memory_bytes: 20060
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int a,b,c,d;
        a=sc.nextInt();
        b=sc.nextInt();
        c=sc.nextInt();
        if(a>b){
        	d=a;
        	a=b;
        	b=d;
        }
        if(b>c){
        	d=b;
        	b=c;
        	c=d;
        }
        if(a>b){
        	d=a;
        	a=b;
        	b=d;
        }
        System.out.println(a+" "+b+" "+c);
        sc.close();
        }
}


Measured memory_bytes: 26212
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    S = input()
    l = len(S)-1
    for i in range(2**l):
        fs = S[0]
        for j in range(l):
            if (i>>j & 1) == 1:
                fs += '+'
            else:
                fs += '-'
            fs += S[j+1]
        if eval(fs)==7:
            ret = fs + '=7'
            break
    print(ret)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
from collections import Counter
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
c = Counter(readline().decode().rstrip())
for i in range(1, n):
    c2 = Counter(readline().decode().rstrip())
    for k, v in c.items():
        c[k] = min(c[k], c2[k])
l = sorted(c.items())
ans = ''
for k, v in l:
    ans += k * v
print(ans)

Measured memory_bytes: 9520
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }

void main() {
  auto K = readln.chomp.to!int;
  auto numbers = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];

  int solve() {
    return numbers[K-1];
  }

  solve().writeln;
}


Measured memory_bytes: 256
n, q = map(int, raw_input().split())
s = raw_input()
td = [raw_input().split() for _ in range(q)];
left, right = 0, n
for t, d in reversed(td):
    if d == 'L':
        if left < n and s[left] == t:
            left += 1
        if right < n and s[right] == t:
            right += 1
    elif d == 'R':
        if left > 0 and s[left - 1] == t:
            left -= 1
        if right > 0 and s[right - 1] == t:
            right -= 1
print max(0, right - left)

Measured memory_bytes: 46852
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vpll> vvpll;
typedef unordered_map<ll, ll> um;
typedef unordered_set<ll> us;

#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ts ll t; in(t) while (t--) solve();
#define ks ll t; in(t) FOR(i, 1, t+1) out("Case #" << i << ": " << solve());
#define endl '\n'
#define ln cout << endl;
#define in(x) cin >> x;
#define out(x) cout << x << endl;
#define flush cout << flush;
#define reset(a, b) memset(a, b, sizeof(a));
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define FORI(i, a, b, c) for (ll i = a; i < b; i += c)
#define FORD(i, a, b) for (ll i = a; i > b; --i)
#define FOREACH(it, v, r) for (auto it = v.begin() + r; it != v.end(); it++)
#define FORALL(it, v) for (auto it : v)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define vin(v, x) vll v(x); FOR(i, 0, x) in(v[i])
#define all(v) v.begin(), v.end()
#define allr(v, r) v.begin(), v.begin() + r
#define showv(v) FORALL(it, v) cout << it << ' '; ln
#define printv(v) FORALL(it, v) out(it)
#define show2d(v) FORALL(it, v) { FORALL(j, it) cout << j << ' '; ln}
#define showm(v) FORALL(it, v) cout << it.F << ": " << it.S << ' '; ln
#define sortv(v) sort(all(v));
#define revv(v) reverse(all(v));
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define gcd __gcd
#define checkbit(n, i) (n >> i) & 1               // check ith bit
#define bitcount __builtin_popcount               // count set bits
#define firstbitindex __builtin_ctz               // count trailing zeros
#define lastbitindex __builtin_clz                // count leading zeros
#define bitparity __builtin_parity                // check set bits are even or odd
#define findv(v, x) (find(all(v), x) != v.end())  // find in a vector
#define findsm(u, x) (u.find(x) != u.end())       // find in a set / map
#define findstr(s, x) (s.find(x) != string::npos) // find in a string
#define sz(a) a.size()
#define precise(x) cout << fixed << setprecision(x);

const ll MAXN = 1e5, MOD = 998244353, SIZE = 2e7;//, INF = 0x7f7f7f7f7f7f7f7f;
const double EPS = 1e-9, PI = acos(-1);
const int INFi = 0x7f7f7f7f;

//<<------Declare Variables Here----->>//
ll n;
char c[26] = {'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'};
string s;

//<<-----Implement Functions Here---->>//
void solve()
{
    in(n)
    while (n)
        n--, s = c[n % 26] + s, n /= 26;
    out(s)
}

//<<----------Start of Main---------->>//
int main()
{
    fastio
    //ts
    solve();
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<cstdlib>

#include<cmath>
#include<map>
#include<string>
#include<vector>
#include<algorithm> 

using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) std::cout << (j ? s1 : s2) << endl;
# define YES(j) std::cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define rep(n,i) for(i = 0 ; i < n ; i++)

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

    int set[100001]={},a[100001]={};

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

    int tmp = set[0];
    int count=1;
    for(int i=0; i<n ; i++){
        if(tmp==2) break;        
        count++;
        if(a[tmp-1]>0){
            p(-1)
            return 0;
        }
        a[tmp-1]++;
        tmp = set[tmp-1];
    }
    p(count)
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int H,W;
  cin>>H>>W;
  int DP[H+1][W+1];
  char S[H+1][W+1];
  REP(i,H+1){
    REP(j,W+1){
      DP[i][j]=MAX;
      if(0<i && 0<j) cin>>S[i][j];
      else S[i][j]='?';
    }
  }
  
  if(S[1][1]=='#') DP[1][1]=1;
  else DP[1][1]=0;
  
  for(int i=1; i<=H; ++i){
    for(int j=1; j<=W; ++j){
      if(S[i-1][j]=='#' && S[i][j]=='#') chmin(DP[i][j],DP[i-1][j]);
      else if(S[i-1][j]=='#' && S[i][j]=='.') chmin(DP[i][j],DP[i-1][j]);
      else if(S[i-1][j]=='.' && S[i][j]=='#') chmin(DP[i][j],DP[i-1][j]+1);
      else if(S[i-1][j]=='.' && S[i][j]=='.') chmin(DP[i][j],DP[i-1][j]);
      else chmin(DP[i][j],DP[i][j]);
      
      if(S[i][j-1]=='#' && S[i][j]=='#') chmin(DP[i][j],DP[i][j-1]);
      else if(S[i][j-1]=='#' && S[i][j]=='.') chmin(DP[i][j],DP[i][j-1]);
      else if(S[i][j-1]=='.' && S[i][j]=='#') chmin(DP[i][j],DP[i][j-1]+1);
      else if(S[i][j-1]=='.' && S[i][j]=='.') chmin(DP[i][j],DP[i][j-1]);
      else chmin(DP[i][j],DP[i][j]);
    }
  }
  
  co(DP[H][W]);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    map<string,int> mp;
    string s,t;
    int n;
    cin >> n;
    cin >> t;
    mp[t]++;
    int flag=0;
    for(int i=1;i<n;i++){
        cin >> s;
        if(s[0]!=t[t.length()-1] || mp[s]>0)flag++;
        mp[s]++;
        t=s;
    }
    if(flag>0)cout << "No" << endl;
    else cout << "Yes" << endl;
}

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

// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4765
const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};

mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
mint f2(int n, int k) {
  return comb(n+k-1,k-1);
}
mint f(int n, int k) {
  if (n < k) return 0;
  if (n == 0 && k == 0) return 1;
  if (k < 1) return 0;
  return f2(n-k,k);
}

int main() {
  init();
  int n, k;
  cin >> n >> k;

  for (int i = 1; i <= k; i++) {
    mint blue = f(k,i);
    mint red = 0;
    {
      red += f(n-k,i-1);
      red += f(n-k,i);
      red += f(n-k,i);
      red += f(n-k,i+1);
    }
    mint ans = blue*red;
    printf("%lld\n", ans.x);
  }
  return 0;
}

Measured memory_bytes: 125568
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

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

    int n; cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];

    int ans=0;
    while(true){
        bool there=false;
        rep(i,n)if(a[i]>=n){
            int tmp=a[i]/n;
            a[i]-=tmp*n;
            ans+=tmp;
            there=true;
            rep(j,n)if(i!=j)a[j]+=tmp;
        }
        if(!there){
            cout<<ans<<endl;
            return 0;
        }
    }

}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

string s;

int main() {
    fastio();

    forn(i, 3) {
        cin >> s;
        cout << s[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

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

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  // startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j,N,H,W,ans;
  cin>>N;
  rep(i,N){
	  cin>>H;
	  if(H%2==0){
		  if(H%3&&H%5){
			  cout<<"DENIED"<<endl;
			  return 0;
		  }
	  }
  }
  print("APPROVED");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const unsigned int M = 1000000007;
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a,b,c;
    while(cin>>a>>b>>c){
       cout<<(a+b)*(c/2)<<endl;
    }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n):
    res = [None] * n
    for i in range(n):
        res[i] = II()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI()
    return res
def FR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR_(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI_()
    return res
def SR(n):
    res = [None] * n
    for i in range(n):
        res[i] = S()
    return res
def LSR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LS()
    return res
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n, k = LI()
    a = LI()
    for i in range(n - k):
        if a[i] >= a[i + k]:
            print("No")
        else:
            print("Yes")
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 91896
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n;
llong a[100005];

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

    llong ans = __gcd(a[0], a[1]);
    for (int i = 2; i < n; i++) {
        ans = __gcd(ans, a[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string T;
  cin >> T;
  rep(i, T.size()) {
    if(T[i] == '?') T[i] = 'D';
  }
  cout << T << endl;
  return 0;
}


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

long long a[100007];

int main(){
	int n;
	long long sum = 0,ans1 = 0,ans2 = 0;
	
	cin >> n;
	for(int i = 0; i < n;i++){
		cin >> a[i];
	}
	int sign = 1;
	int signt;
	for(int i = 0;i < n;i++){
		sum+=a[i];
		if(sum > 0) signt = 1;
		else if(sum < 0) signt = 0;
		else{
			if(sign) signt = 1;
			else signt = 0;
		}
		if(sign==signt){
			ans1+=(abs(sum)+1);
			if(sum < 0) sum = 1;
			else if(sum > 0) sum = -1;
			else{
				if(sign) sum = -1;
				else sum = 1;
			}
		}
		if(sign) sign = 0;
		else sign = 1;
	}
	sign = sum = 0;
	for(int i = 0;i < n;i++){
		sum+=a[i];
		if(sum > 0) signt = 1;
		else if(sum < 0) signt = 0;
		else{
			if(sign) signt = 1;
			else signt = 0;
		}
		if(sign==signt){
			ans2+=(abs(sum)+1);
			if(sum < 0) sum = 1;
			else if(sum > 0) sum = -1;
			else{
				if(sign) sum = -1;
				else sum = 1;
			}
		}
		if(sign) sign = 0;
		else sign = 1;
	}
	cout << min(ans1,ans2) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

ll N;
ll f[10000010];

signed main(){
    cin >> N;
    ll ans = 0;
    for(ll i = 1; i <= N; i++){
        for(ll j = 1; i * j <= N; j++){
            f[i * j]++;
        }
        ans += i * f[i];
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 81756
#include <bits/stdc++.h>
using namespace std;
int main() {
	int cnt = 0;
    unsigned long int x,c = 100;
	cin >> x;
	while (c <= x) {
		cnt++;
		c *= 1.01;
		if (c >= x) {
			break;
		}
	}
	cout << cnt << endl;
}

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

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

	int x, y, r;
	cin>>x>>y>>r;

	if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)
	cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
	}


Measured memory_bytes: 3120
import java.io.*;
import java.util.*;
class Main{
 public static void main(String[] args) throws IOException {
        // TODO code application logic here
         BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
       
              int n = Integer.parseInt(bf.readLine()); 
  
 if(n%1000==0){
   System.out.println(0);
   
 }
   else{
     System.out.println(1000-(n%1000));
   }
   
  
        
 }
  
  
  
}

Measured memory_bytes: 32560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
vector<ll>g[N];
ll n,u,v,color[N],c[N],son[N],res[N]={0};
ll f(ll n) {return n*(n+1)/2;}
void dfs(ll u,ll fa){
    auto tmp=c[color[u]];
    for(auto v:g[u]){
        if(v==fa) continue;
        c[color[u]]=0;
        dfs(v,u);
        son[u]+=son[v];
        res[color[u]]+=f(son[v]-c[color[u]]);
    }
    c[color[u]]=tmp+son[u];
}

int main(){
    cin>>n;
    for(ll i=1;i<=n;i++){
        son[i]=1;
        cin>>color[i];
    }
    for(ll i=1;i<n;i++){
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1,-1);
    for(int i=1;i<=n;i++){
        cout<<f(n)-f(n-c[i])-res[i]<<endl;
    }
    return 0;
}



Measured memory_bytes: 39468
# coding: utf-8

n = int(input())

A = [int(input()) for _ in range(n)]

s_A = sorted(A, reverse=True)

max_a, second_a = s_A[0], s_A[1]

for i in range(n):
    if A[i] == max_a:
        print(second_a)
    else:
        print(max_a)

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

double ev(double p){
  double sum=0;
  for(int i =1 ; i <=p; i++){
    sum += i/p;
  }
  return sum;
}

int main(){
  int n,k;
  cin >> n >> k;
  vector<double> e(n);
  rep(i,n) {
    double temp;
    cin >> temp;
    e.at(i) = ev(temp);
  }
  
  double ev_sum = 0;
  rep(i,k) ev_sum += e.at(i);
  
  vector<double> ans(n-k+1);
  ans.at(0) = ev_sum;
  for(int i = 0; i < n-k; i++){
    ev_sum += (-e.at(i)+e.at(i+k));
    ans.at(i+1) = ev_sum;
  }
  sort(ans.begin(),ans.end());
  printf("%5.7f\n", ans.at(n-k));
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;
int main() {
	int x;
	cin >> x;
	int a;
	cin >> a;
	if (x > a * 2) {
		cout << x - a * 2;
	}
	else
		cout << 0;
}

Measured memory_bytes: 768
#include<stdio.h>
typedef long long int LL;
LL x,y;

LL f(LL x,LL z){
  y+=x+z;
  for(LL n=10;n<x;n*=10){
    f(x/n,x%n+z);}
  return y;}

signed main(){
  scanf("%lld",&x);
  printf("%lld\n",f(x,0));
  return 0;}

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

int n,u,k,v;
int g[102][102];
int d[102],f[102];
int sn[102];
int cnt=1;

void dfs(int x);

int main(){
  memset(d,0,sizeof(d));
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>u>>k;
    sn[i]=0;
    for(int j=1;j<=k;j++){
      cin>>v;
      g[u][v]=1;
    }
  }
  
  for(int i=1;i<=n;i++){
    if(sn[i]==0){
      dfs(i);
    }
  }


  for(int i=1;i<=n;i++){
    cout<<i<<" "<<d[i]<<" "<<f[i]<<endl;
  }

  return(0);
}

void dfs(int x){
  
  sn[x]=1;
  d[x]=cnt;
  cnt++;
  
  for(int i=1;i<=n;i++){
    if(g[x][i]==1 && sn[i]==0){
      dfs(i);
    }
  }

  f[x]=cnt;
  cnt++;

}

Measured memory_bytes: 1200
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty())return out;
    constexpr bool is_vector_v = is_vector<T>::value;
    if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr),out << ((++itr != v.end()) ? "\n" : "");
    else for (auto itr = v.begin(); itr != v.end();)out << (*itr),out << ((++itr != v.end()) ? " " : "");
    return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first; printf("\n"); }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first; printf(" "); put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first; printf("\n"); putn(rest...); }

bool proc(vector<ll>& sum,int k,int s){
    int n = sum.size();
    REP(i,n-k){
        ll temp = sum[i+k]-sum[i];
        if(temp>=s)return true;
    }
    return false;
}

int main(){
    int n,s;
    cin >> n >> s;
    vector<int> a(n);
    vector<ll> sum(n+1);
    sum[0] = 0;
    REP(i,n){
        cin >> a[i];
        sum[i+1] = sum[i]+a[i];
    }
    int lb = -1,ub = n+1;
    while(ub-lb>1){
        int mid = (lb+ub)/2;
        if(proc(sum,mid,s)){
            ub = mid;
        }else{
            lb = mid;
        }
    }
    if(ub>n){
        put(0);
    }else{
        put(ub);
    }
    return 0;
}



Measured memory_bytes: 3888
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    seika s;
    cin >> s;
    int ans = 0, n = s.size();
    for (int i = 0; 2 * i < n; i++)
    {
        if (s[i] != s[n - i - 1])
        {
            ans++;
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <stdio.h>
int A[2000],m[2000],n;
int solve(int,int);
int main(){
  int i,q;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++) scanf("%d",&m[i]);

  for(i=0;i<q;i++){
    if(solve(0,m[i])==1) printf("yes\n");
    if(solve(0,m[i])==0) printf("no\n");
  }
  
  return 0;
}

int solve(int i,int m){
  int res;
  if(m==0) return 1;
  if(i>=n) return 0;
  res=solve(i+1,m) || solve(i+1,m-A[i]);
  return res;
}



Measured memory_bytes: 2048
n, d = map(int, input().split())
x_list = [[int(x) for x in input().split()] for _ in range(n)]
power_list = [i**2 for i in range(200)]
ans = 0

for l in range(~-n):
  for r in range(-~l, n):
    if int(sum([(y-z)**2 for y, z in zip(x_list[l], x_list[r])])) in power_list:
      ans += 1

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[100];

        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
        }
        for(int i=0; i<n; i++){
            System.out.print(a[n-1-i]);
            if(i != n-1) System.out.print(" ");
            else System.out.print("\n");
        }
        sc.close();
    }
}


Measured memory_bytes: 26268
import java.util.Scanner;


public class Main {
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		int w = scanner.nextInt();
		int h = scanner.nextInt();
		
		int x = scanner.nextInt();
		int y = scanner.nextInt();
		int r = scanner.nextInt();
		
		String judge = "No";
		
		if((r<=x && x<=w-r) && (r<=y && y<=h-r))
		{
			judge = "Yes";
		}
		
		System.out.println(judge);
	}
}

Measured memory_bytes: 26172
#include <stdio.h>
    #include <string.h>
    #include <queue>
    #include <iostream>
    #include <algorithm>
    using namespace std;
    const int maxn=10050;
    const int maxe=2005000;
    const int INF=1e9;
    struct note
    {
        int to;
        int w;
        int c;
        int next;
    };
    note edge[maxe];
    int head[maxn];
    int ip;
    void init()
    {
        memset(head,-1,sizeof(head));
        ip=0;
    }
    void addedge(int u,int v,int w,int c)
    {
        edge[ip].to=v;
        edge[ip].c=c;
        edge[ip].w=w;
        edge[ip].next=head[u];
        head[u]=ip++;
    }
    int cost[maxn];
    int dis[maxn];
    bool vis[maxn];
    queue<int>q;
    void spfa(int s,int n)
    {
        while(!q.empty())q.pop();
        for(int i=1;i<=n;i++)
            cost[i]=dis[i]=INF;
        memset(vis,false,sizeof(vis));
        dis[s]=0;
        cost[s]=0;
        vis[s]=true;
        q.push(s);
        while(!q.empty())
        {
            int u=q.front();
            q.pop();
            vis[u]=false;
            for(int i=head[u];i!=-1;i=edge[i].next)
            {
                int to=edge[i].to;
                int val=edge[i].w;
                if(dis[to]>dis[u]+val||(dis[to]==dis[u]+val&&cost[to]>edge[i].c))//有多条最短路时，取花费最小的
                {
                    dis[to]=dis[u]+val;
                    cost[to]=edge[i].c;
                    if(!vis[to])
                    {
                        q.push(to);
                        vis[to]=true;
                    }
                }
            }
        }
    }
    int main()
    {
        int n,m;
        int u,v,w,c;
        while(~scanf("%d%d",&n,&m))
        {
            if(n==0&&m==0) break;
            init();
            for(int i=0;i<m;i++)
            {
                scanf("%d%d%d%d",&u,&v,&c,&w);
                addedge(u,v,c,w);
                addedge(v,u,c,w);
            }
            spfa(1,n);
            int ans=0;
            for(int i=1;i<=n;i++)
                ans+=cost[i];
            printf("%d\n",ans);
        }
        return 0;
    }



Measured memory_bytes: 4024
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
req = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

t = [-1]*(N+1)
t[0] = 0
for a in A:
    q = req[a]
    for i in range(q, N+1):
        t[i] = max(t[i], t[i-q] * 10 + a)
print(t[-1])


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

int main() {
  long long A, B, N; cin >> A >> B >> N;
  if (A == 1 || B == 1) { cout << 0 << endl; return 0; }
  if (N < B) {
    cout << A * N / B - A * (N / B) << endl;
    return 0;
  }
  cout << A * (B-1) / B - A * ((B-1) / B) << endl;
}

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

int main(){
  vector<int> A = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout << A.at(K-1) << endl;
  
}

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

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

    for (int i = 0; i <= N; i++) {
        for (int j = 0; j + i <= N; j++) {
            int k = N - i - j;
            if (10000 * i + 5000 * j + 1000 * k == Y) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
    
}

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

const long long MOD = 1000000007;

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

    long long res = 1;
    vector<int> C(3);
    for (int i = 0; i < N; i++) {
        long long cnt = 0, id = -1;
        if (A[i] == C[0]) { cnt++; id = 0; }
        if (A[i] == C[1]) { cnt++; id = 1; }
        if (A[i] == C[2]) { cnt++; id = 2; }
        
        if (id == -1) {
            cout << "0" << endl;
            return 0;
        }

        res *= cnt;
        res %= MOD;
        C[id]++;
    }

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

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll x[110000],y[110000];
int main(){
    ll n,m,ans=0;
    cin>>n>>m;
    rep(i,0,m)cin>>x[i];
    sort(x,x+m);
    rep(i,0,m-1)y[i]=x[i+1]-x[i];
    sort(y,y+m-1);
    rep(i,0,m-n)ans+=y[i];
    cout<<ans;
}


Measured memory_bytes: 1792
#include<algorithm>
#include<cmath>
#include<cstring>
#include<iostream>
#include<list>
#include<queue>
#include<set>
#include<utility>
#include<vector>

#define INF 1000000007

using ll = long long;
using namespace std;

int main(void){

    int n;
    cin >> n;
    ll c, k;
    cin >> c >> k;

    ll t[n];
    for(int i=0;i<n;i++)cin >> t[i];
    sort(t, t+n);

    int bus_count = 1;
    int bus_start = t[0];
    int bus_people = 0;
    for(int i=0;i<n;i++){
        if(t[i]>bus_start+k || bus_people==c){
            bus_count++;
            bus_start = t[i];
            bus_people = 0;
            i--;
            continue;
        }
        bus_people++;
    }

    cout << bus_count << endl;

    return 0;
}


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

int D[6];
void spin(char c)
{
  if(c=='E'){
    swap(D[0],D[3]);swap(D[3],D[5]);swap(D[5],D[2]);
  }
  else if(c=='W'){
    swap(D[0],D[2]);swap(D[2],D[5]);swap(D[5],D[3]);
  }
  else if(c=='S'){
    swap(D[0],D[1]);swap(D[0],D[4]);swap(D[4],D[5]);
  } 
  else if(c=='N'){
    swap(D[0],D[1]);swap(D[1],D[5]);swap(D[5],D[4]);
  }
}
int main()
{
  int q,a,b;
  char SWS[10]={"SSSSWSSSS"};
  for(int i=0;i<6;i++)cin>>D[i];
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>a>>b;
    for(int i=0;i<10;i++){
      if(D[1]==b)break;
      spin(SWS[i]);
    }
    for(int i=0;i<4;i++){
      if(D[0]==a){
	cout<<D[2]<<endl;
	break;
      }
      spin('W');
    }
  } 
  return 0;
}

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

#define IO  ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define endl '\n'
#define f first
#define s second
#define ll long long
#define ld long double
#define mod 1000000007
#define INF 0x3f3f3f3f3f3f3f3f
using namespace std;
const int M=2e5+5;

int main() {
    IO
    int n,m,x,y;
    cin>>n>>m>>x;
    vector<int>v;
    int arr[n+5][m+5];
    for(int i=0;i<x;i++){
        cin>>y;
        v.push_back(y);
    }
    int t=0,ind=0;
    for(int i=0;i<n;i++){
        if(t%2==0) {
            for (int j = 0; j < m; j++) {
                arr[i][j]=ind+1;
                v[ind]--;
                if(v[ind]==0) ind++;
            }
            t++;
        }
        else{
            for (int j = m-1; j >=0; j--) {
                arr[i][j]=ind+1;
                v[ind]--;
                if(v[ind]==0) ind++;
            }
            t++;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cout<<arr[i][j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3756
n, a, b, c = gets.split.map(&:to_i)
l = []
n.times do
  l << gets.to_i
end

ans = 10000

(0..3).to_a.repeated_permutation(n) do |set|
  ll = [0, 0, 0]
  mp = 0
  n.times do |i|
    next if set[i] == 3

    mp += 10 if ll[set[i]] != 0
    ll[set[i]] += l[i]
  end
  next if ll.include?(0)

  mp += (ll[0] - a).abs + (ll[1] - b).abs + (ll[2] - c).abs
  ans = [ans, mp].min

end
puts ans

Measured memory_bytes: 1916
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    ll a, b;
    cin >> a >> b;

    ll r = b - a;
    ll tb = (1 + r) * r / 2;
    ll ta = tb - r;

    // cout << ta << " " << tb << endl;
    cout << ta - a << endl;

    return 0;
}

Measured memory_bytes: 3612
#include "bits/stdc++.h"

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll a, b, c;
string s, t, u;

int main(){
	cin >> s >> t;
	cin >> a >> b;
	cin >> u;
	if(s == u){
		p2(a-1, b);
	}else{
		p2(a, b-1);
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define ALL(V) V.begin(),V.end()
#define f1(a,b) for(int a=1;a<=b;a++)
#define f0(a,b) for(int a=0;a<b;a++)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define de(x) cerr<<#x<<": "<<x<<endl
using namespace std;
const LL N=1e6+69, base=1024*1024,mod=1e9+7;
int n,a,wynik;
priority_queue <int> q;
int32_t main(void) {
    boost;
    cin>>n;
    f0(i,n) {
        cin>>a;
        q.push(a);
    }
    f0(i,n) {
        a=q.top();
        q.pop();
        if(i%2==0) wynik+=a;
        if(i%2==1) wynik-=a;
    }
    cout<<wynik<<endl;
}



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

int main(){
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	
	if(b>0&&d>0){
		if(a*c>b*d)
		cout<<a*c;
		else
		cout<<b*d;
	}else{
		if(b<0&&c>0)
		cout<<b*c;
		else if(d<0 && a>0)
		cout<<a*d;
		else 
		cout<<a*c;
	}
}

Measured memory_bytes: 3628
import java.util.Scanner;
public class Main{ //class??????Main?????????(???
 
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(); //????????????Scanner???????????????????????????????????????
        int b = sc.nextInt(); 
         
        if(a<b)
            System.out.println("a < b"); //???????????¨?????????????????? "a < b" ??¨??????????????????????????\??????????§??????????????????????????????? println(2??????)
         
        else if(a>b)
            System.out.println("a > b");
         
        else
            System.out.println("a == b");
         
         
    }
}

Measured memory_bytes: 17224
#include<bits/stdc++.h>
using namespace std;
int a,b,c,x,s;
int main(){
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++)
		for(int j=0;j<=b;j++)
			for(int k=0;k<=c;k++)
				if(i*500+j*100+k*50==x) s++;
	cout<<s<<endl;	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <numeric>
#include <ctype.h>
#include <cstdlib>
#include <string.h>
#include <cmath>
#include <cstdio>





using namespace std;


int main()
{
	int count, money = 100000;

	cin >> count;

	for (int i = 0; i < count; i++)
	{
		money += money * 0.05;
		if (money % 1000 > 0)
		{
			int m = money / 1000;
			m++;
			money = 1000 * m;
		}
	}

	

	cout << money << endl;
}

Measured memory_bytes: 3000