akhauriyash/Code-Regression huggingface dataset:
<?php 
$n = trim(fgets(STDIN));
$ac = 0;
$tle = 0;
$wa = 0;
$re = 0;

for($i = 0; $i < $n; $i++){
  $r[] = trim(fgets(STDIN));
}
foreach($r as $value){
  if($value == 'AC'){
    $ac += 1;
  }elseif($value == 'TLE'){
    $tle += 1;
  }elseif($value == 'WA'){
    $wa += 1;
  }else{
    $re += 1;
  }
}
echo 'AC x '.$ac;
echo "\n";
echo 'WA x '.$wa;
echo "\n";
echo 'TLE x '.$tle;
echo "\n";
echo 'RE x '.$re;

Measured memory_bytes: 22660
def ni(): 
    return int(input())
def li():
    return map(int, input().split())

xyh = [tuple(li()) for _ in range(ni())]
xmax, ymax, hmax = max(xyh, key=lambda _: _[-1])

for x_cent in range(101):
    for y_cent in range(101):
        h_cent = hmax + abs(xmax-x_cent) + abs(ymax-y_cent)
        
        for x, y, h in xyh:
            if h != max(0, h_cent - abs(x-x_cent) - abs(y-y_cent)):
                break
        else:
            print(x_cent, y_cent, h_cent)

Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CModuloSummation solver = new CModuloSummation();
        solver.solve(1, in, out);
        out.close();
    }

    static class CModuloSummation {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            long answer = 0;
            for (int i = 0; i < n; i++) {
                long a = in.nextInt();
                answer += a - 1;
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23380
#include<stdio.h>
int main(){
  int a,n[100],j,i=0;
  double b,c;
  while(scanf("%d,%lf,%lf",&a,&b,&c)!=EOF){
    c=c*c;
    if(b/c>=25){
      n[i]=a;
      i++;
    }
  }
  for(j=0;j<i;j++){
    printf("%d\n",n[j]);
  }
  return (0);
}

Measured memory_bytes: 628
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};

const int N=303,OO=1e18;
int a[N];
int dp[N][N][N];
int mn[N][N][N];
int kp[N][N][N];
int32_t main(){
    int n,k;
    cin>>n>>k;
    vector<int> al;
    for(int i=1;i<=n;++i){cin>>a[i];al.pb(a[i]);}
    al.pb(0);
    sort(al.begin(), al.end());
    al.resize(unique(al.begin(), al.end())-al.begin());
    forn(i,N)forn(j,N)forn(v,N)dp[i][j][v]=mn[i][j][v]=kp[i][j][v]=OO;
    dp[0][0][0]=mn[0][0][0]=0;
    forn(v,N)kp[0][0][v]=0;
    for(int i=1;i<=n;++i){
        for(int j=0;j<=k;++j){
            for(int v=0;v<sz(al);++v){
                int val=al[v];
                int ch=val!=a[i];
                if(j||!ch)dp[i][j][v]=min(mn[i-1][j-ch][v],kp[i-1][j-ch][v]+val);
                mn[i][j][v]=dp[i][j][v];
                kp[i][j][v]=dp[i][j][v]-val;
                if(v)upn(kp[i][j][v],kp[i][j][v-1]);

            }
            for(int v=sz(al)-2;v>=0;--v)upn(mn[i][j][v],mn[i][j][v+1]);
        }
    }
    int ans=OO;
    forn(j,k+1)forn(v,sz(al))upn(ans,dp[n][j][v]);
    cout<<ans<<'\n';

    return 0;
}

Measured memory_bytes: 652288
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
    ll N, K;
    cin >> N >> K;
    ll a[N];
    ll s[N + 1];
    s[0] = 0;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        s[i + 1] = s[i] + a[i];
    }

    for(int i = 0; i <= N; i++){
        s[i] -= i;
        s[i] %= K;
    }

    ll ans = 0;
    multiset<ll> st;
    map<ll, int> mp;
    for(int i = 0; i <= N; i++){
        if(st.size() >= K){
            mp[s[i - K]]--;
            auto itr = st.find(s[i - K]);
            st.erase(itr);
            //cout << "erase " << s[i - K] << endl;
        }

        ans += mp[s[i]];

        st.insert(s[i]);
        mp[s[i]]++;

        //cout << "insert " << s[i] << endl;
    }

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

Measured memory_bytes: 25216
#include<iostream>
#include<random>
using namespace std;
main() {
  int d;
  cin >> d;
  switch(d) {
    case 22:
      cout << "Christmas Eve Eve Eve";
      break;
    case 23:
      cout << "Christmas Eve Eve";
      break;
    case 24:
      cout << "Christmas Eve";
      break;
    case 25:
      cout << "Christmas";
      break;
    default:
      random_device rnd;
      while(true) {
        cout << rnd();
      }
      break;
  }
  return 0;
}
        

Measured memory_bytes: 256
import heapq

N, M = map(int, input().split())
P_list = []
ans = []

for i in range(N+1):
    P_list.append([])

for i in range(M):
    P, Y = map(int, input().split())
    Y = Y * 10 ** 6 + i
    P_list[P].append(Y)

for i in range(N+1):
    P_list[i].sort()
    for j, k in enumerate(P_list[i]):
        tmp = (k % 10**6 + 1) * 10**12 + i * 10**6 + j + 1
        ans.append(tmp)

heapq.heapify(ans)

for i in range(M):
    pr = heapq.heappop(ans)
    ans_pr = str(pr % 10**12)
    print(ans_pr.zfill(12))

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

int main() {
  int N, L;
  cin >> N >> L;
  
  int ans = 0;
  if (L >= 0) {
    for (int i = 1; i < N; i++) {
      ans += L + i;
    }
  }
  else if (L+N-1 <= 0) {
    for (int i = 0; i < N-1; i++) {
      ans += L + i;
    }
  }
  else {
    for (int i = 0; i < N; i++) {
      ans += L + i;
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 10000

int linearSearch(int A[], int aLength, int key) {
  int i;
  for (i = 0; i < aLength; i++) {
    if(A[i] == key) return 1;
  }
  return 0;
}

int main() {
  int i, length, tLength;
  int count = 0;
  int S[N], T[N];
  scanf("%d", &length);
  for (i = 0; i < length; i++) {
    scanf("%d", &S[i]);
  }
  scanf("%d", &tLength);
  for (i = 0; i < tLength; i++) {
    scanf("%d", &T[i]);
    if (linearSearch(S, length, T[i]) == 1) {
      count++;
    }
}
  printf("%d\n", count);
return 0;
}

Measured memory_bytes: 644
import bisect
n,q=map(int,input().split())
s=input()
data=[]
for i in range(n-1):
    if s[i]=='A' and s[i+1]=='C':
        data.append(i)
query = [tuple(map(int,input().split())) for i in range(q)]
for qe in query:
    l=bisect.bisect_left(data,qe[0]-1)
    r=bisect.bisect_right(data,qe[1]-2)
    print(r-l)






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

#define pb push_back
#define fst first
#define snd second
#define ALL(s) s.begin(),s.end()
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define SZ(x) ((int)(x).size())
#define PI 3.1415926535897932384626433832795
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
using namespace std;

int main() {FIN;
    int d; ll g; cin>>d>>g;
    ll mn = 1e18;
    vector<pair<ll,ll>> v;
    fore(i,0,d){
        ll p,c; cin>>p>>c;
        v.pb({p,c});
    }
    fore(i,0,(1<<d)){
        ll sum = 0;
        ll cnt = 0;
        for(int j = d-1; j >=0; j--){
            if(i&(1<<j)){
               ll p = v[j].fst;
               fore(k,0,p){
                    sum += (j+1)*100;
                    cnt++;
                    if(k == p-1) sum += v[j].snd;
                    if(sum >= g) break;
               }
               if(sum >=g){
                    mn = min(mn,cnt);
                    break;
               }
            }
        }
    }
    cout<<mn<<"\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s[0]=='9' or s[1]=='9')cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
      
      Scanner sc = new Scanner(System.in);
      
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int x = sc.nextInt();
      
      int res=0;
      
      for(int h=0; h<=a ; h++ ){
      	for(int i=0; i<=b; i++){
        	int j = (x-500*h-100*i)/50;
        	if(j >= 0 && j <= c)
        	  res++;
      	}
      }
    System.out.println(res);
    }
}


Measured memory_bytes: 21844
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cout << (#x) << ": " << (x) << endl
#define DEBUG_VEC(v)            \
    cerr << #v << ": ";         \
    REP(__i, (v).size())        \
    cerr << ((v)[__i]) << ", "; \
    cerr << endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main()
{
    ios::sync_with_stdio(false);
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vl a(x);
    vl b(y);
    vl c(z);
    REP(i, x) cin >> a[i];
    REP(i, y) cin >> b[i];
    REP(i, z) cin >> c[i];

    priority_queue<ll> q;
    for (auto aa: a) {
        for (auto bb: b) {
            q.push(aa + bb);
        }
    }

    priority_queue<ll> q2;
    int cnt = 0;
    while (!q.empty() and cnt < k) {
        ll ab = q.top();
        q.pop();
        cnt++;
        for (auto cc: c) {
            q2.push(ab + cc);
        }
    }

    REP(i, k) {
        ll ans = q2.top();
        q2.pop();
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 43240
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

n,m = gi
x = gi
y = gi

xx = 0
rep n do |i|
  xx += i*x[i] - (n - 1 - i)*x[i]
end
yy = 0
rep m do |i|
  yy += i*y[i] - (m - 1 - i)*y[i]
end
puts xx*yy % (10**9+7)


Measured memory_bytes: 15940
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }

long long  dig(long long  n) {
    if(n == 0)return 1;
    long long  res = 0;
    while(n > 0) {
        res ++;
        n /= 10;
    }
    return res;
}

int main() {
    int n,m;
    cin >> n >> m;
    vector<P> v(m);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        v.at(i) = {a,b};
    }
    rep(i,1000){
        string s = to_string(i);
        if(s.length() != n)continue;
        bool can = true;
        for(auto a : v){
            if(s[a.first-1]-'0' != a.second){
                can = false;
                break;
            }
        }
        if(can){
            cout << s << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <iostream>
#include <string>

#define MAX_N 1000
#define MAX_M 1000

int n, m;
std::string s, t;

int dp[MAX_N+1][MAX_M+1];

void solve() {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (s[i] == t[j]) {
        dp[i+1][j+1] = dp[i][j] + 1;
      }
      else {
        dp[i+1][j+1] = std::max(dp[i][j+1], dp[i+1][j]);
      }
    }
  }
}

int main() {
  int q;
  std::cin >> q;
  for (int i = 0; i < q; ++i) {
    std::cin >> s >> t;
    n = s.size();
    m = t.size();
    solve();
    std::cout << dp[n][m] << std::endl;
  }
}

Measured memory_bytes: 7076
N, K = map(int, input().split())
ans = 0
for i in range(K, N+2):
    shou = (i - 1) * i // 2
    dai = (i * N) - ((i - 1) * i // 2)
    #print(shou, dai)
    ans += len(range(shou, dai+1))
print(ans % (10**9 + 7))

Measured memory_bytes: 9192
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String readStr;
      long n = Integer.parseInt(reader.readLine());
      for (long i = n - 1; i > 1; i--) {
        n *= i;
      }
      System.out.println(n);
  }

}

Measured memory_bytes: 16852
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), sum = 0;
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
            sum += arr[i];
        }
        
        double avg = (double)sum / n, minDiff = Double.MAX_VALUE;
        int minIndex = 0;
        for (int i = 0; i < n; i++) {
            double diff = Math.abs(avg - arr[i]);
            if (diff < minDiff - 1e-4) {
                minDiff = diff;
                minIndex = i;
            }
        }
        
        System.out.println(minIndex);
    }
}


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

int main() {
	// your code goes here
	int x, y, z;
	cin >> x >> y >> z;
	int tmp=x;
	x=y;
	y=tmp;
	tmp=x;
	x=z;
	z=tmp;
	cout << x << " " << y << " " << z << endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: i32,
        k: i32,
    }
    if k % 2 == 1 {
        let mut cnt = 0i64;
        for i in 1..n+1 {
            if i % k == 0 {
                cnt += 1;
            }
        }
        println!("{}", cnt.pow(3));
    } else {
        let mut half_k = 0i64;
        let mut k_cnt = 0i64;
        for i in 1..n+1 {
            if i % k == 0 {
                k_cnt += 1;
            } else if i % k == k/2 {
                half_k += 1;
            }
        }
        println!("{}", half_k.pow(3) + k_cnt.pow(3));
    }
}


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

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

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

const ll mod = 1e9 + 7;
const ll IMF = 1LL<<29;
const double PI = 3.14159265358979323846;


// ******************************CODE**********************************//





int main()
{
        int A,B,C;
        cin >> A >> B >> C;
        int maxval = max({A,B,C});

        int ans = 0;
        if(maxval%2 != (A+B+C)%2)
        {
                maxval++;
                int a = maxval-A;
                int b = maxval-B;
                int c = maxval-C;

                ans += a/2 + b/2 + c/2;

                int cnt = 0;
                if(a%2 != 0) cnt += a%2;
                if(b%2 != 0) cnt += b%2;
                if(c%2 != 0) cnt += c%2;

                ans += cnt/2;
        }
        else{
                int a = maxval-A;
                int b = maxval-B;
                int c = maxval-C;

                ans += a/2 + b/2 + c/2;

                int cnt = 0;
                if(a%2 != 0) cnt += a%2;
                if(b%2 != 0) cnt += b%2;
                if(c%2 != 0) cnt += c%2;

                ans += cnt/2;
        }

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


Measured memory_bytes: 256
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
A = sorted(A, reverse=True)
L, R = A[0], A[0]
A.pop(0)
num = 0
for i in range(N - 1):
    k1 = A[-1]
    k2 = A[0]
    tmp = []
    tmp.append(abs(L - k1))
    tmp.append(abs(L - k2))
    tmp.append(abs(R - k1))
    tmp.append(abs(R - k2))
    ma = max(tmp)
    if ma == abs(L - k1):
        num += abs(L - k1)
        A.pop(-1)
        L = k1
    elif ma == abs(L - k2):
        num += abs(L - k2)
        A.pop(0)
        L = k2
    elif ma == abs(R - k1):
        num += abs(R - k1)
        A.pop(-1)
        R = k1
    else:
        num += abs(R - k2)
        A.pop(0)
        R = k2

print(num)


Measured memory_bytes: 8300
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

const int mxn=2e5+1;

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

  int t=1;
  //cin>>t;
  int tt=1;
  while(t--){
    int n,m,i;
    cin>>n>>m;
    multiset<ll> s;
    ll ans=0,x;
    fr(i,0,n)
    {
      cin>>x;
      s.insert(x);
      
       //cout<<"Case #"<<tt<<": ";
       //tt++;
    }
    pair<ll,ll> arr[m];
    fr(i,0,m)
    {
      ll b,c;
      cin>>b>>c;
      arr[i]={c,b};
    }
    sort(arr,arr+m);
    for(i=m-1;i>=0;i--)
    {
      while(*s.begin()<arr[i].fi and arr[i].se)
      {
        s.erase(s.begin());
        s.insert(arr[i].fi);
        arr[i].se--;
      }
    }
    for(auto v:s)
      ans+=v;
    cout<<ans;
    }
  return 0;
}



Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define INF 10000000000000001
#define DIM 200001
#define mod 1000000007
#define PI 3.1415926535897932384626433
#define se second
#define fi first
#define pb push_back
#define T true
#define F false
#define endl "\n"
typedef char ch;
typedef bool boll;
typedef string st;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef set < string > sst;
typedef set < long long > sl;
typedef queue < long long > que;
typedef vector < long long > vec;
typedef map < long long, long long > mll;
typedef pair < long long, long long > pll;
typedef vector < pair < long long, long long > > vpl;
typedef pair < long long, unsigned long long > pul;
ll  a[5][5],b[11],c[5][5],n,z,x,s;
int main()
{
    for(int i=1; i<=3; i++)
        for(int j=1; j<=3; j++)cin>>a[i][j];
    cin>>n;
    for(int v=1; v<=n; v++)
    {
        cin>>b[v];
        for(int i=1; i<=3; i++)
            for(int j=1; j<=3; j++)
                if(a[i][j]==b[v])c[i][j]=1;
    }
    if(c[1][1]==1 && c[2][2]==1 && c[3][3]==1)return cout<<"Yes"<<endl,0;
    if(c[1][3]==1 && c[2][2]==1 && c[3][1]==1)return cout<<"Yes"<<endl,0;
    for(int i=1;i<=3;i++){
        int f=0;
        for(int j=1;j<=3;j++){
            if(c[i][j]==0){
                f=1;
                break;
            }
        }
        if(f==0)return cout<<"Yes"<<endl,0;
    }
    for(int j=1;j<=3;j++){
        int f=0;
        for(int i=1;i<=3;i++){
            if(c[i][j]==0){
                f=1;
                break;
            }
        }
        if(f==0)return cout<<"Yes"<<endl,0;
    }
    cout<<"No"<<endl;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n;
ll h[MAX_N];

ll h_no[MAX_N];

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    scanf("%d", &(h[i]));
  }

  for (int i = n - 2; i >= 0; --i) {
    if (h[i + 1] < h[i]) {
      h[i] -= 1;
    }

    if (h[i + 1] < h[i]) {
      printf("No\n");
      return 0;
    }
  }

  printf("Yes\n");

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long a[2002];
int main()
{
    long long t,i,k,n,x,y=1,z=1,s=1,j;
    cin>>n;

    a[0]=1;
    for(i=3;i<=n;i++)
    {
          for(j=3;j<=i;j++)
          {
              a[i]+=a[i-j];
              a[i]%=1000000007;
          }
    }

    cout<<a[n]<<endl;

    return 0;
}

Measured memory_bytes: 3648
#include <algorithm>

#include <bitset>

#include <tuple>

#include <cstdint>

#include <cstdio>

#include <cctype>

#include <assert.h>

#include <stdlib.h>

#include <stdio.h>

#include <cassert>

#include <cfloat>

#include <climits>

#include <cmath>

#include <complex>

#include <ctime>

#include <deque>

#include <fstream>

#include <functional>

#include <iomanip>

#include <iostream>

#include <iterator>

#include <list>

#include <limits>

#include <map>

#include <memory>

#include <queue>

#include <random>

#include <set>

#include <stack>

#include <string>

#include <unordered_map>

#include <unordered_set>

#include <utility>

#include <vector>

#include <math.h>
using namespace std;
int main() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	cout << 15 - (a + b + c + d + e) << endl;
}


Measured memory_bytes: 3640
N,M = gets.split.map(&:to_i)
C = Array.new(M){gets.split.map(&:to_i)}

City = Struct.new(:p, :y, :i, :j)
cities = C.map.with_index do |c, i|
    City.new(*c, i)
end

j = 0
pre = nil
cities.sort_by{|c| c.p * 10 ** 9 + c.y}.each do |c|
    if pre != c.p
        j = 0
    end

    j += 1
    pre = c.p
    c.j = j
end

cities.each do |c|
    printf("%06d%06d\n", c.p, c.j)
end


Measured memory_bytes: 23800
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,k;string s;
int l,r,p,q,a1,a2;
int v[100005];
priority_queue<int> pql,pqr;
int turn(int r,int l){
   // cout<<"l="<<l<<" "<<r;
    int ans=2;
    if(l==0) ans--;
    if(r==n-1) ans--;
    //cout<<" "<<ans<<endl;
    return ans;
}
int main(){
    cin>>n>>k;
    cin>>s;
    l=0,r=0;
    for(int i=0;i<=n;i++){
        if(i==n){
            if(s[l]=='L') pql.push(turn(r,l));
            else pqr.push(turn(r,l));
            break;
        }
        if(i>=1&&s[i]==s[i-1]){
            if(s[i]=='L') a1++;
            else a2++;
        }
        if(s[l]==s[i]){
            r=i;
        }else{
            if(s[l]=='L') pql.push(turn(r,l));
            else pqr.push(turn(r,l));
            l=r=i;
        }
    }
    int t=a2;
    a2+=a1;
    a1+=t;
    //cout<<a1<<" "<<a2<<endl;
    for(int i=1;i<=k&&!pqr.empty();i++){
        int x=pqr.top();
        a1+=x; pqr.pop();
    //cout<<x<<" ";
    }
    //cout<<endl;
    for(int i=1;i<=k&&!pql.empty();i++){
        int x=pql.top();
        a2+=x; pql.pop();
        //cout<<x<<" ";
    }
    cout<<max(a1,a2);
}


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

#define f(i,a,b) for (int i = a; i < b; i++)

int main() {
  	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
  
  int n,m; cin>>n>>m;
  int a[2*n];
  f(i,0,2*n) cin>>a[i];
  sort(a,a+2*n);
  int lo = 0, hi = n-1;
  auto check = [&](int x) {
  	//f(i,0,2*x) if (a[i]+a[2*x-1-i] >= m) 
    // 	return 0;
    f(i,2*x,2*n) if (a[i]+a[2*n-1-(i-2*x)] < m)
      return 0;
    return 1;
  };
  while (lo<=hi) {
    int mid = (lo+hi)/2;
  	if (check(mid)) hi = mid-1;
    else lo = mid+1;
  }
  // lo is now the breakpoint
  int ans = 0;
  f(i,0,2*lo) ans = max(ans,(a[i]+a[2*lo-1-i])%m);
  f(i,2*lo,2*n) ans = max(ans,(a[i]+a[2*n-1-(i-2*lo)])%m);
  cout << ans << endl;
  	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//SOLVE
void solve(void)
{
  int H,W;
  cin>>H>>W;
  vector<vector<char> > data (H,vector<char>(W,0));  
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      cin>>data[i][j];
    }
    
  }
  vector<vector<int> > DP (H,vector<int>(W,0));
  DP[H-1][W-1] = 1;
  queue<pair<int,int> > que;
  que.push(make_pair(H-1,W-1));
  vector<vector<int> > visited(H,vector<int>(W,0));

  while(!que.empty())
  {
    pair<int,int> V = que.front();
    que.pop();
    // DEBUG(V.first,V.second,que.size(),"\n");
    if(visited[V.first][V.second] == 1)continue;
    visited[V.first][V.second] = 1;
    pair<int,int> nV = V;
    nV.first--;
    if(nV.first >= 0 && nV.second >= 0)
    if(data[nV.first][nV.second] == '.')
    {
      DP[nV.first][nV.second] += DP[V.first][V.second];
      DP[nV.first][nV.second]%=MOD;
      que.push(nV);
    }
    nV.first++;nV.second--;
    if( nV.first >= 0 && nV.second >= 0)
    if(data[nV.first][nV.second] == '.' )
    {
      DP[nV.first][nV.second] += DP[V.first][V.second];
      DP[nV.first][nV.second] %= MOD;
      que.push(nV);
    }
  }
  cout<<DP[0][0]<<endl;

  
  
  return;
}


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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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

using namespace std;

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

const double PI=3.14159265358979323846;

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

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

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

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

class UnionFind
{
public:
    vector<int> p;
    int num;

    UnionFind() {}
    UnionFind(int size)
    : p(vector<int>(size, -1)), num(size)
    {}

    bool same(int x, int y)
    {
        return findSet(x) == findSet(y);
    }

    void unite(int x, int y)
    {
        x = findSet(x); y = findSet(y);
        if (x == y) return;

        if (p[x] > p[y]) swap(x, y);
        p[x] += p[y];
        p[y] = x;
        --num;
    }

    int findSet(int x)
    {
        if (p[x] < 0) return x;
        else p[x] = findSet(p[x]);
        return p[x];
    }
};

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

    int n, m;
    cin >> n >> m;
    int k, l;
    vector< vs32 > L(m);
    rep (i, n)
    {
        cin >> k;
        rep (j, k)
        {
            cin >> l;
            --l;
            L[l].push_back(i);
        }
    }

    UnionFind uf(n);
    rep (i, m)
    {
        rep (j, (int)L[i].size() - 1)
        {
            uf.unite(L[i][j], L[i][j + 1]);
        }
    }

    cout << (uf.num == 1 ? "YES\n" : "NO\n");

    return 0;
}



Measured memory_bytes: 4608
import java.util.Scanner;

public class Main {
	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);
		String[] s = sc.nextLine().split("");
		sc.close();
		String[] t = {"C","O","D","E","F","E","S","T","I","V","A","L","2","0","1","6"};
		int count = 0;
		for(int i = 0; i < 16; i ++) {
			if( !(s[i].equals(t[i])) ) {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21716
N = int(input())
F = []
for _ in range(N):
    f = input().split()
    fn = int("".join(f), 2)
    F.append(fn)
P = [list(map(int, input().split())) for _ in range(N)]

ans = -100000000000
for k in range(1, 2 ** 10):
    val = 0
    for i in range(N):
        c = bin(k & F[i]).count("1")
        val += P[i][c]
    ans = max(ans, val)
print(ans)


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
#define ll long long int


int main()
{
	ll n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++) {
		if(i%3==0||i%5==0) continue;
		sum+=i;
	}
	cout<<sum<<endl;
	return 0;
}

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

int main(){
	int n, k;
	cin >> n >> k;
	int num = 1;
	for(int i=0; i<n; i++){
		if(2*num < num + k){
			num += num;
		}
		else{
			num += k;
		}
	}

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


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

class SegTree_Delay {
public:
    int f;
    int INIT = INT_MAX;
    vector<int> dat, lazy;

    SegTree_Delay(int n) {
        f = 1;
        while (f < n) f *= 2;
        dat.assign(2 * f, INIT);
        lazy.assign(2 * f, INIT);
    }

    void eval(int k) {
        if (lazy[k] == INIT) return;
        if (k < f - 1) {
            lazy[2 * k + 1] = lazy[k];
            lazy[2 * k + 2] = lazy[k];
        }
        dat[k] = lazy[k];
        lazy[k] = INIT;
    }

    void update(int a, int b, int x, int k, int l, int r) {
        eval(k);
        if (a <= l && r <= b) {
            lazy[k] = x;
            eval(k);
        }
        else if (a < r && l < b) {
            update(a, b, x, k * 2 + 1, l, (l + r) / 2);
            update(a, b, x, k * 2 + 2, (l + r) / 2, r);
            dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }

    void update(int a, int b, int x) {
        update(a, b, x, 0, 0, f);
    }

    int query(int a, int b) {
        return query(a, b, 0, 0, f);
    }

    int query(int a, int b, int k, int l, int r) {
        eval(k);
        if (r <= a || b <= l) return INIT;
        if (a <= l && r <= b) return dat[k];
        else {
            int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }
};


int main() {
    int n, q;
    cin >> n >> q;
    SegTree_Delay st = SegTree_Delay(n);
    while (q--) {
        int m;
        cin >> m;
        if (m) {
            int i;  cin >> i;
            cout << st.query(i, i + 1) << endl;
        }
        else {
            int s, t, x;
            cin >> s >> t >> x;
            st.update(s, t + 1, x);
        }
    }
}



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

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

ll GCD(ll a,ll b){ll c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

ll factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

// ll dp[]

int main(){
  ll n, m, sum=0;
  ll a[10000];

  scanf("%lld%lld", &n, &m);

  for (int i = 0; i < m; i++)
  {
      scanf("%lld", a+i);
      sum += a[i];
  }

  if(sum > n ) printf("-1");
  else printf("%lld", n-sum);
  

  return 0;
}

Measured memory_bytes: 1756
local n = io.read("*n")
local divp = {}
for i = 2, n do
  for j = 2, i do
    if i % j == 0 then
      if not divp[j] then divp[j] = 0 end
      while i % j == 0 do
        divp[j] = divp[j] + 1
        i = i // j
      end
    end
  end
end
local t = {}
for k, v in pairs(divp) do
  table.insert(t, v)
end
table.sort(t, function(x, y) return x > y end)
local p3, p5, p15, p25, p75 = 0, 0, 0, 0, 0
for i = 1, #t do
  if 2 <= t[i] then p3 = i end
  if 4 <= t[i] then p5 = i end
  if 14 <= t[i] then p15 = i end
  if 24 <= t[i] then p25 = i end
  if 74 <= t[i] then p75 = i end
end
local ret = 0
-- 75
ret = ret + p75
-- 25 * 3
ret = ret + p25 * (p3 - 1)
-- 15 * 5
ret = ret + p15 * (p5 - 1)
-- 5 * 5 * 3
ret = ret + p5 * (p5 - 1) // 2 * (p3 - 2)
print(ret)


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

string get_prefix_chs(string s) {
    string ret = "";
    for (char c : s) {
        if (!('0' <= c && c <= '9')) {
            ret += c;
        } else {
            break;
        }
    }
    return ret;
}

string get_prefix_num(string s) {
    string ret = "";
    for (char c : s) {
        if ('0' <= c && c <= '9') {
            ret += c;
        } else {
            break;
        }
    }
    return ret;
}

bool is_num(char c) {
    return '0' <= c && c <= '9';
}

bool comp(const string& s, const string& t) {
    if (s.empty()) return true;
    if (t.empty()) return false;
    if (is_num(s.front()) && is_num(t.front())) {
        int sp = stoi(get_prefix_num(s));
        int tp = stoi(get_prefix_num(t));
        if (sp == tp) {
            int l = get_prefix_num(s).size();
            return comp(s.substr(l), t.substr(l));
        }
        return sp < tp;
    } else if (is_num(s.front())) {
        return true;
    } else if (is_num(t.front())) {
        return false;
    } else {
        string sp = get_prefix_chs(s);
        string tp = get_prefix_chs(t);
        if (sp == tp) {
            int l = sp.size();
            return comp(s.substr(l), t.substr(l));
        }
        return sp < tp;
    }
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    while (n--) {
        string t;
        cin >> t;
        cout << (comp(s, t) ? '+' : '-') << endl;
    }   
}


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

string s;
int cnt[5005];

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> s;
    int power = 1;
    int n = s.length();
    int num = 0;
    cnt[0] = 1;
    long long ans = 0;
    for(int i = n - 1;i >= 0;i--){
        num = num + power * (s[i] - '0'); 
        num %= 2019;
        ans += cnt[num];
        cnt[num]++;
        power = power * 10 % 2019;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3780
#include<iostream>
#include<algorithm>
#include<string>
#include<set>
using namespace std;
int main()
{
    string s;
    set<string> kinds;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        kinds.insert(s);
    }
    cout<<kinds.size()<<endl;
    return 0;
}


Measured memory_bytes: 19124
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。
vector<pair<long long,long long>> prime_factorize(long long p); // 素因数分解

// class
// ------------------------------------------------
class Combi {
  public:
    Combi();
    long long Combination(long long n, long long k);
    long long nPk_modp(long long n, long long k, long long p);
  private:
    map<long long, map<long long, long long>> memo;
    long long n_num;
    long long k_num;
};

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(long long(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(long long(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<long> vll;
// code
// ------------------------------------------------
int main() {

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

    if(a == b && b == c && c == a) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n) {
  int i = 1;
  while(1) {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n) {
  int s = 0;
  while(n) {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str) {
  for(auto itr = str.begin();itr != str.end() ; itr++) {
    if(97 <= *itr && *itr <= 122) {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str) {
  for(auto itr = str.begin();itr != str.end() ; itr++) {
    if(65 <= *itr && *itr <= 90) {
      *itr = *itr + 32;
    }
  }
  return str;
}


Combi::Combi() {
  n_num = -1;
  k_num = -1;
};

ll Combi::Combination(ll n, ll k) {

  ll ret;
  if(memo[n][k] != 0) {
    ret = memo[n][k];
  } else if(n == k || k == 0) {
    memo[n][k] = 1;
    ret = 1;
  } else {
    ret = Combination(n - 1, k - 1) + Combination(n - 1, k);
    memo[n][k] = ret;
  }
  return ret;
}

long long Combi::nPk_modp(long long n, long long k, long long p) {
  ll ans = 1;
  for(long long i = k; i <= n; i++) {
    ans = (ans * i) % p;
  }

  return ans;
};

vector<pair<long long,long long>> prime_factorize(long long p) {
    vector<pair<long long,long long>> ret;

    for(long long x = 2; x * x <= p; ++x) {
        if(p % x != 0) continue;
        long long num = 0;
        while(p % x == 0) {
            num++;
            p /= x;
        }
        ret.push_back(make_pair(x,num));
    }

    if(p != 1) ret.push_back(make_pair(p, 1));
    
    return ret;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

namespace {
	int cnt, m;
	vector<int> G;

	void InsertionSort(vector<int>& A, int n, int g)
	{
		for (int i = g; i < n; ++i)
		{
			int v = A[i];
			int j = i - g;

			while (j >= 0 && A[j] > v) {
				A[j + g] = A[j];
				j -= g;
				cnt++;
			}

			A[j + g] = v;
		}
	}

	void ShellSort(vector<int>& A, int n)
	{
		cnt = 0;
		G.push_back(1);
		for (int i = 1; i <= n; ++i)
		{
			int g = pow(4, i) + 3 * pow(2, i - 1) + 1;
			if (g <= n) G.push_back(g);
			else { m = i; break; }
		}

		for (int i = m - 1; i >= 0; --i)
			InsertionSort(A, n, G[i]);
	}
}

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

	int n;
	cin >> n;

	vector<int> A(n, 0);
	for (int i = 0; i < n; ++i)
		cin >> A[i];

	ShellSort(A, n);

	cout << m << endl;
	for (int i = m - 1; i >= 0; --i) {
		cout << G[i];
		i != 0 ? cout << " " : cout << endl;
	}
	cout << cnt << endl;
	for (int i = 0; i < n; ++i)
		cout << A[i] << endl;

	return 0;
}

Measured memory_bytes: 5160
#include<cstdio>
#include<cstdlib>

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

using namespace std;

typedef long long ll;

struct edge{ int u,v; };

const int N_MAX=101;

template<class T>
void mul(int n,const T A[N_MAX][N_MAX],const T B[N_MAX][N_MAX],T C[N_MAX][N_MAX]){
	static T tmp[N_MAX][N_MAX];
	rep(i,n) rep(j,n) {
		tmp[i][j]=0;
		rep(k,n) tmp[i][j]+=A[i][k]*B[k][j];
	}
	rep(i,n) rep(j,n) C[i][j]=tmp[i][j];
}

template<class T>
void pow(int n,const T A[N_MAX][N_MAX],ll m,T B[N_MAX][N_MAX]){
	static T tmp[N_MAX][N_MAX];
	rep(i,n) rep(j,n) {
		tmp[i][j]=A[i][j];
		B[i][j]=(i==j?1:0);
	}
	for(int t=0;m>0;t++){
		if(m&(1LL<<t)){
			mul(n,B,tmp,B);
			m-=1LL<<t;
		}
		mul(n,tmp,tmp,tmp);
	}
}

template<class T>
void mul(int n,const T A[N_MAX][N_MAX],const T x[N_MAX],T y[N_MAX]){
	static T z[N_MAX];
	rep(i,n){
		z[i]=0;
		rep(j,n) z[i]+=A[i][j]*x[j];
	}
	rep(i,n) y[i]=z[i];
}

int main(){
	for(int n,m,z;scanf("%d%d%d",&n,&m,&z),n;){
		edge e[100];
		rep(i,m){
			scanf("%d%d",&e[i].u,&e[i].v), e[i].u--, e[i].v--;
			e[m+i]=(edge){e[i].v,e[i].u};
		}
		m*=2;

		bool A[101][101]={};
		rep(i,m){
			rep(j,m) if(abs(i-j)!=m/2 && e[i].v==e[j].u) A[j][i]=true;
			if(e[i].u==0) A[i][m]=true;
		}
		pow(m+1,A,z,A);

		bool x[101]={}; x[m]=true;
		mul(m+1,A,x,x);

		bool ok=false;
		rep(i,m+1) if(e[i].v==n-1 && x[i]) ok=true;
		puts(ok?"yes":"no");
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n; cin >> n;
    string s = "";
    while(n){
        int r = n % 2;
        if(r < 0) r += 2;
        n = (n-r)/(-2); 
        s += r + '0';
    }
    reverse(ALL(s));
    if(s == "") s = "0";
    cout << s << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[])
{
  int num;
  int i;
  int a, b, c;

  scanf("%d", &num);

  for(i = 0; i < num; i++)
    {
      scanf("%d %d %d", &a, &b, &c);
      if(((a * a) + (b * b) == (c * c)) ||
	 ((b * b) + (c * c) == (a * a)) ||
	 ((c * c) + (a * a) == (b * b)))
	printf("YES\n");
      else
	printf("NO\n");
    }

  return 0;
}

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

const int maxn=2e5+10;
const int mo=1e9+7;
int n,pos[maxn],Dis,fac[maxn],inv[maxn];

int power(int x,int k)
{
	int res=1;
	while (k)
	{
		if (k&1) res=(LL)res*x%mo;
		x=(LL)x*x%mo;
		k>>=1;
	}
	return res;
}

int C(int n,int m)
{
	if (n<m) return 0;
	return (LL)fac[n]*inv[m]%mo*inv[n-m]%mo;
}

int main()
{
#ifdef h10
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
	int i,x;
	scanf("%d",&n);

	fac[0]=1;
	for (i=1;i<=n;i++)
		fac[i]=(LL)fac[i-1]*i%mo;
	for (i=0;i<=n;i++)
		inv[i]=power(fac[i],mo-2);
	for (i=1;i<=n+1;i++)
	{
		scanf("%d",&x);
		if (!pos[x]) pos[x]=i;
		else Dis=i-pos[x];
	}

	printf("%d\n",n);
	for (i=2;i<=n;i++)
	{
		int A=(2ll*C(n,i)+C(n-1,i-2))%mo;
		int B=(C(n-Dis,i-1)+C(n-1,i))%mo;
		printf("%d\n",(A+mo-B)%mo);
	}
	printf("1\n");
}


Measured memory_bytes: 2432