akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define loop(i,n) for(int i=1;i<=n;i++)
int a[100002];
int b[100002];

signed main(){
    int n;
    cin>>n;
    loop(i,n)cin>>a[i]>>b[i];
    int s=0;
    for(int i=n;i>=1;i--){
        int r=(a[i]+s)%b[i];
        s+=(b[i]-r)%b[i];
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main(void){
  int i,n,m,c,max=0,num=1;
  
  scanf("%d",&n);
  
  for(i=1;i<=n;i++){
    m=i;
    c=0;
    do{
      if(m%2==1)
        break;
      
      m=m/2;
      c++;
      
    }while(1);
    
    if(max<c){
      max=c;
    num=i;
    }
  }

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

Measured memory_bytes: 128
import heapq


def solve(N, M, a, b):
    q = []
    ret = 0
    conditions = sorted([(b[i], a[i]) for i in range(M)], key = lambda x: x[1])
    ci = 0
    for i in range(N+1):
        while ci < len(conditions) and i == conditions[ci][1]:
            heapq.heappush(q, conditions[ci])
            ci += 1
        if len(q) > 0 and i == q[0][0]-1:
            ret += 1
            q = []
    return ret





def main():
    N, M = list(map(int, input().split(' ')))
    a = []
    b = []
    for i in range(M):
        ai, bi = list(map(int, input().split(' ')))
        a.append(ai)
        b.append(bi)

    print(solve(N, M, a, b))



if __name__ == '__main__':
    main()


Measured memory_bytes: 20676
object Main extends App {

  val s = scala.io.StdIn.readLine()

  def solve(): Int = {
    val maxAndTmpMax = (0, 0)
    s.foldLeft(maxAndTmpMax) { case ((max, tmpMax), char) =>
      if(isValid(char)) (Math.max(max, tmpMax+1), tmpMax+1)
      else (max, 0)
    }._1
  }
  
  def isValid(char: Char): Boolean = {
    if (char == 'A' || char == 'C' || char == 'G' || char == 'T') true else false
  }


  println(solve)

}


Measured memory_bytes: 27320
#include<stdio.h>
int main(void){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a==b&&a==c){
    printf("No");
    return 0;
  }
  if(a!=b&&a!=c&&b!=c){
    printf("No");
    return 0;
  }
  printf("Yes");
  return 0;
}

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

int main(){
    int n; cin>>n;
    vector<int>v(n+1);
    rep(i,n)cin>>v[i+1];
    int ans=0;
    int _index=1;
    while(++ans){
        if(ans>n)return puts("-1")*0;
        if(v[_index]==2){cout<<ans<<endl; return 0;}
        _index=v[_index];
    }
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class I,class V=typename I::value_type>V sum_up(const I&l,const I&r){V v;for(I i=l;i!=r;i++)v=i==l?*i:v+*i;return v;}
template<class I,class T=iterator_traits<I>>I operator+(I it,int n){for(int i=0;i<n;i++)it++;return it;}
template<class I,class T=iterator_traits<I>>I operator-(I it,int n){for(int i=0;i<n;i++)it--;return it;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}
void R_YESNO(bool p){cout<<(p?"YES":"NO")<<endl;}
void R_YesNo(bool p){cout<<(p?"Yes":"No")<<endl;}
int main() {
    int N;
    cin >> N;
    i64 ans = 0;
    for(i64 i = 1; i <= N; i++) {
        if(i % 3 != 0 && i % 5 != 0) ans += i;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3624
n,*a=map(int,open(0).read().split())
pre1=0
pre2=0
ans1=0
ans2=0
for i in range(n):
    x=(-1)**(i%2)
    y=-x
    pre1+=a[i]
    pre2+=a[i]
    if x*pre1<=0:
        ans1+=abs(pre1-x)
        pre1=x
    if y*pre2<=0:
        ans2+=abs(pre2-y)
        pre2=y
print(min(ans1,ans2))

Measured memory_bytes: 14084
from collections import OrderedDict
result = OrderedDict()
N, K = map(int, input().split())
for i in range(N):
    a,b = map(int, input().split())
    if a in result:
        result[a] += b
    else:
        result[a] = b

result = sorted(result.items())
for k,v in result:
    if K > v:
        K -= v
    else:
        print(k)
        exit()

Measured memory_bytes: 27824
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int,input().split()))
bucket_l = [0] * (2*n)
bucket_r = [0] * (2*n)
for i,v in enumerate(a):
    if v > n:
        continue
    if i-v >= 0:
        bucket_l[i-v]+=1
    bucket_r[i+v]+=1

ret = 0
for i,j in zip(bucket_l,bucket_r):
    ret+=i*j
print(ret)

Measured memory_bytes: 32384
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

// #define FL fflush(stdout)

#define MOD 1000000007
#define INF 2000000000
#define MAXN 100050

int GLL(LL& x) {
  return scanf("%lld", &x);
}

int GI(int& x) {
  return scanf("%d", &x);
}

int n;
int counts[MAXN];
//int arr[MAXN];
int main() {
  memset(counts, 0, sizeof counts);

  GI(n);
  int a;
  FORN(i, n) {
    GI(a);
//    GI(arr[i]);
    if (a-1 >= 0)
      counts[a-1]++;
    if (a >= 0)
      counts[a]++;
    counts[a+1]++;
  }

  int ans = 0;
  FORN(i, MAXN) {
    ans = max(counts[i], ans);
  }

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

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

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

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<vector<Int> > G(n);
  for(Int i=1;i<n;i++){
    Int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  
  function<Int(Int, Int)> dfs=[&](Int v,Int p){
    Int one=0,two=0;
    for(Int u:G[v]){
      if(u==p) continue;
      Int tmp=dfs(u,v);
      two|=(one&tmp);
      one|=tmp;
    }
    Int res=1;
    while(res<=two||(one&res)) res<<=1;
    return (one&~(res-1))|res;
  };
  
  Int res=dfs(0,-1);
  Int ans=31-__builtin_clz(res);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 12544
#include <stdio.h>

int main(){
  int n, a[101] = {}, i;
  scanf("%d", &n);
  for(i = 0;i < n;i++) scanf("%d", a + i);
  for(i = n - 1;i >= 0;i--){
    if(i != n - 1) putchar(' ');
    printf("%d", a[i]);
  }
  puts("");
  return 0;
}

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

using namespace std;

int InputTime() {
	int h, m, s; cin >> h >> m >> s;
	return (h * 60 + m) * 60 + s;
}
void OutputTime(int sec) {
	int min = sec / 60; sec %= 60;
	int hour = min / 60; min %= 60;
	cout << hour << " " << min << " " << sec << endl;
}

int main() {
	for (int i = 0; i < 3; ++i) {
		int t1 = InputTime();
		int t2 = InputTime();
		OutputTime(t2 - t1);
	}
}

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

struct UnionFind {
    vector<int> parent;
    int set_num;

    UnionFind(int n) {
        parent.resize(n, -1);
        set_num = n;
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);

        if (x != y) {
            if (size(x) < size(y)) swap(x, y);
            parent[x] += parent[y];
            parent[y] = x;
            set_num--;
        }
    }

    bool is_same(int x, int y) {
        return find(x) == find(y);
    }

    int find(int x) {
        if (parent[x] < 0) {
            return x;
        }
        return parent[x] = find(parent[x]);
    }

    int size(int x) {
        return -parent[find(x)];
    }

    int size() {
        return set_num;
    }
};

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

    int N, M;
    cin >> N >> M;

    UnionFind uf(N + M);
    for (int i = 0; i < N; i++) {
        int K;
        cin >> K;
        for (int j = 0; j < K; j++) {
            int L;
            cin >> L;
            L--;
            uf.unite(i, N + L);
        }
    }

    bool yes = true;
    for (int i = 0; i < N; i++) yes = yes && uf.is_same(0, i);

    if (yes) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 1024
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);
        ACircle solver = new ACircle();
        solver.solve(1, in, out);
        out.close();
    }

    static class ACircle {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int r = in.nextInt();
            out.println(r * r);
        }

    }

    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: 21204
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

constexpr double pi = acos(-1);

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> x(n + 3), y(n + 3);
  for (int i = 2; i < n + 2; ++i) cin >> x[i] >> y[i];
  V<> idx(n + 3);
  iota(begin(idx) + 2, end(idx) - 1, 2);
  double res = 1e10;
  do {
    double curr = 0;
    for (int p = 1; p <= n + 1; ++p) {
      int i = idx[p - 1], j = idx[p], k = idx[p + 1];
      double th = 4 * pi + atan2(y[j] - y[i], x[j] - x[i]) - atan2(y[k] - y[j], x[k] - x[j]);
      th = fmod(th, 2 * pi);
      th = min(th, 2 * pi - th) / pi * 180;
      curr += th;
    }
    res = min(res, curr);
  } while (next_permutation(begin(idx) + 2, end(idx) - 1));
  cout << fixed << setprecision(15) << res << '\n';
}


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

string a,b,c;


int main(){
    cin>>a>>b>>c;
    a[0]=a[0]-'a'+'A';
    b[0]=b[0]-'a'+'A';
    c[0]=c[0]-'a'+'A';
    cout<<a[0]<<b[0]<<c[0];
}

Measured memory_bytes: 3608
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>

inline void read(int &T) {
	int x=0;bool f=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=!f;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	T=f?-x:x;
}

int main() {
	for(int i=1,x;i<=5;++i) {
		read(x);
		if(x==0) {
			std::cout<<i<<'\n';
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N,cnt=0,yaku=0;
  cin >> N;
  for(int i=1;i<=N;i+=2){
    yaku = 0;
    for(int j=1;j<=i;j++){
      if(i % j == 0)
        yaku++;
    }
    if(yaku == 8)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;

int main() {
  int N;
  string S;
  cin >> N >> S;
  int cnt = 0;
  REP(i, N - 2) {
    if(S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
      cnt++;
    }
  }
  cout << cnt << endl;
}


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

int main() {
  int a, b;
  cin >> a;
  cin >> b;
  int ans = a*b;
  if (ans%2==0) {
      cout << "Even" << endl;
  } else
  {
      cout << "Odd" << endl;
  }
  return 0;
}


Measured memory_bytes: 3616
def resolve():
    n = int(input())
    dp = [[0,0,0,0] for _ in range(n)]
    dp[0] = [8,1,1,0]
    mod = 10**9+7
    for i in range(1, n):
        dp[i][0] = (dp[i-1][0]*8)%mod
        dp[i][1] = (dp[i-1][1]*9 + dp[i-1][0])%mod
        dp[i][2] = (dp[i-1][2]*9 + dp[i-1][0])%mod
        dp[i][3] = (dp[i-1][3]*10 + dp[i-1][1] + dp[i-1][2])%mod
    print((dp[n-1][3])%mod)
resolve()

Measured memory_bytes: 198224
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long int lnt;
typedef pair<lnt,lnt> P;
string s;
int main()
{
	cin>>s;
	if(s.find("C")!=string::npos&&s.find("F")!=string::npos){
		if(s.find("C")<s.rfind("F")) puts("Yes");
		else puts("No");
	}
	else puts("No");
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]

for i in range(n):
  res = []
  ans = []
  for j in range(m):
    res.append(abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1]))
  ans = res.index(min(res))
  print(ans+1)

Measured memory_bytes: 9164
#include <iostream>
using namespace std;
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; }
const long long INF = 1LL<<60;



int main() {
    // 入力
    int N;
    long long W, weight[110], value[110]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に

    // DPテーブル
    long long dp[110][100100] = {0};
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

    // DPループ
    for (int i = 0; i < N; ++i) {
        for (int sum_w = 0; sum_w <= W; ++sum_w) {

            // i 番目の品物を選ぶ場合
            if (sum_w - weight[i] >= 0) {
                chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
            }

            // i 番目の品物を選ばない場合
            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }

    // 最適値の出力
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 86272
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {
	int n;
	cin>>n;
	int mul = 10,sol=0;
	while(1) {
		if(n>=mul)sol+=9*mul/10;
		else {
		//cerr<<mul<<" "<<n;
		if(n-(mul/10)+1>0)
			sol+=n-((mul/10)-1);
		break;
		}
		mul*=100;
	}
	cout<<sol;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int w, h, c; cin >> w >> h >> c;
	int g = __gcd(w, h);
	cout << c * (h / g) * (w / g) << endl;
	return 0;
}


Measured memory_bytes: 3208
N, P = map(int, input().split())
A = list(map(int, input().split()))

ch = [a for a in A if a%2 == 0]
if len(ch) == len(A):
    if P == 0:
        ans = 2**N
    else:
        ans = 0
else:
    ans = 2**(N-1)

print(ans)


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

int main(){
  int N;
  cin >> N;
  vector<int> digit(4);
  for(int i=0;i<4;i++){
    digit.at(i)=N % 10;
    N /= 10;
  }
  if(digit.at(0)==digit.at(1)&&digit.at(1)==digit.at(2)){
    cout << "Yes" << endl;
  }else if(digit.at(1)==digit.at(2)&&digit.at(2)==digit.at(3)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string.h>
using namespace std;
int main() {
  pair<int, int> c[3010];
  int dp[3010] = {};
  int n, t;
  cin >> n >> t;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    c[i] = make_pair(a, b);
  }
  sort(c, c + n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    //料理をギリギリの時間に頼んだ場合から0になるまでチェック。
    for (int j = t - 1; j >=0; j--) {
      if (ans < dp[j] + c[i].second) {
        //ansよりも大きかった場合設定。jは最大で頼んでもよい時間なので確実に入れる。
        ans = dp[j] + c[i].second;
      }
      if (j + c[i].first < t && dp[j + c[i].first] < dp[j] + c[i].second) {
        //料理を頼んでも時間内の場合かつ、
        //今の時間の美味しさより料理を頼んだときの美味しさが上回ったとき
        //頼んだものとして上書きする
        dp[j + c[i].first] = dp[j] + c[i].second;
      }
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    char s[100005];
    int num[100005];
    memset(num,0,sizeof(num));
    scanf("%s",s);
    int len=strlen(s);
    int ans=0;
    for(int i=0;i<len;i++)
    {
        if(s[i]=='R'&&s[i+1]!='L')
            ans++;
        if(s[i]=='L'&&s[i-1]!='L')
        {
            if(ans%2==1)
            {
                num[i]=2+ans/2;
                num[i-1]=1+ans/2;
            }
            else
            {
                num[i]=1+ans/2;
                num[i-1]=1+ans/2;
            }
            ans=0;
        }
    }
    ans=0;
    for(int i=len-1;i>=0;i--)
    {
        if(s[i]=='L'&&s[i-1]!='R')
            ans++;
        if(s[i]=='R'&&s[i+1]!='R'&&ans!=0)
        {
            if(ans%2==1)
            {
                num[i]+=1+ans/2;
                num[i+1]+=ans/2;
            }
            else
            {
                num[i]+=ans/2;
                num[i+1]+=ans/2;
            }
            ans=0;
        }
    }
    for(int i=0;i<len;i++)
        printf("%d ",num[i]);
    printf("\n");
    return 0;
}


Measured memory_bytes: 896
# abc160 C
k, n = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

aaa = a.each_cons(2).to_a.map { |x,y|
  y-x
} + [ a[0] + (k - a[-1]) ]


p aaa.inject(:+) - aaa.max




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

int main() {
    int x, n;
    int p[100];
    int i, j;
    int ans, mans, flag;
    scanf("%d %d", &x, &n);
    for (i=0;i<n;i++) scanf("%d", &p[i]);
    ans=1000;
    mans=1000;
    if (n==0) {
        printf("%d\n", x);
        return 0;
    }
    for (j=x;j<102;j++) {
        flag=1;
        for (i=0;i<n;i++) {
            if(p[i]==j) flag=0;
        }
        if (flag) {
            ans=j;
            break;
        }
    }
    for (j=x;j>-101;j--) {
        flag=1;
        for (i=0;i<n;i++) {
            if(p[i]==j) flag=0;
        }
        if (flag) {
            mans=j;
            break;
        }
    }
    if (abs(x-ans)>abs(x-mans)) {
        printf("%d\n", mans);
    } else if (abs(x-ans)==abs(x-mans)) {
        printf("%d\n", mans);
    } else {
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 1700
#include <iostream>

using ll = long long;
int main(int argc, char ** argv)
{
  //
  ll n, a, b;
  std::cin >> n >> a >> b;
  if (a == 0) {
    std::puts("0");

  } else if (n <= a) {
    std::printf("%lld\n", n);

  } else if (n < (a + b)) {
    std::printf("%lld\n", a);

  } else {
    // std::printf("%lld\n", n / (a + b) * a + n % (a + b));
    ll ans = n / (a + b) * a;
    std::printf("%lld\n", ans + (n % (a + b) < a ? n % (a + b) : a));
  }
  return 0;
}


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

#define l long long int

int main(){
   l a,b,c,d;
   cin>>a>>b>>c>>d;
   l k;
   /**if(b<a){
    k=b;
    b=a;
    a=k;
   }
   if(d<c){
    k=d;
    d=c;
    c=k;
   }
   k=a*c;
   l x;
   for(int i=a;i<=b;i++){
    for(int j=c;j<=d;j++){
        x=i*j;
       // cout<<x<<" ";
        if(x>k){
            k=x;
        }
    }
   }
   cout<<k;**/
   l m,n,o,p;
   m=a*c;
   n=a*d;
   o=b*c;
   p=b*d;
   if(m>=n && m>=o && m>=p){
    cout<<m;
   }else if(n>=m && n>=o && n>=p){
    cout<<n;
   }else if(o>=n && o>=m && o>=p){
       cout<<o;
   }else{
       cout<<p;
   }

}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
	int N;
	string S;
	vector<char> v;

	cin >> N >> S;

	for (int i = 0; i < S.size(); i++) {
		if (v.empty()) {
			v.push_back(S[i]);
		} else {
			if (v[v.size() - 1] != S[i]) {
				v.push_back(S[i]);
			}
		}
	}

	cout << v.size() << endl;

	return 0;
}

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

const int INF = 1e+9;

int N, M;
double L[32], A[32], B[32];
bool check[32];

double dfs(int n, int m){
	if(m >= M){
		double cal = 0;
		for(int i = 0; i < N; ++i){
			for(int j = i + 1; j < N; ++j){
				if(check[i] && check[j])
					cal += pow(fabs(L[j] - L[i]), 2.0) + pow(fabs(A[j] - A[i]), 2.0) + pow(fabs(B[j] - B[i]), 2.0);
			}
		}
		return cal;
	}
	if(n >= N)
		return -INF;
		
	double res = 0;
	res = max(res, dfs(n + 1, m));
	check[n] = true;
	res = max(res, dfs(n + 1, m + 1));
	check[n] = false;
	
	return res;
}

int main() {
	cin >> N >> M;
	for(int i = 0; i < N; ++i)
		cin >> L[i] >> A[i] >> B[i];
	
	printf("%f\n", dfs(0, 0));
	return 0;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

signed main() {
  int n, d;
  std::cin >> n >> d;
  print(ceil(n / (2.0 * d + 1.0)));
}


Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N;
	
	cin >> N;

	int r = N / 100;
	int m = r * 111;
	if ( N <= m)
	{
		cout << m << endl;
	}
	else
	{
		cout << m + 111 << endl;
	}

	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
using namespace std;
int main(void){
    int prime[300010]={};
    int b=0;
    for(int i=2;i<=200274;i++){
        if(prime[i]==0){
            prime[i]=1;
            b++;
            for(int j=2*i;j<=200274;j+=i){
                prime[j]=-1;
            }
        }
    }
    vector<int> p(b);
    int a=0;
    for(int i=0;i<200274;i++){
        if(prime[i]==1){
            p[a]=i;
            a++;
        }
    }
    int s[200275];
    while(1){
        int n,m;
        cin>>n>>m;
        if(n==-1&&m==-1)break;
        for(int i=0;i<200275;i++)s[i]=0;
        int c;
        for(int i=0;i<200275;i++){
            if(p[i]>n){
                c=i;
                break;
            }
        }
        for(int i=c;i<=c+m;i++){
            for(int j=i;j<=c+m;j++){
                int sum=p[i]+p[j];
                if(sum<=200274)s[sum]++;
            }
        }
        int t=0;
        for(int i=4;i<200275;i++){
            t+=s[i];
            if(t>=m){
                cout<<i<<endl;
                break;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 5068
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<(n);i++)
#define REP1(i,n) for(long long i=1;i<=(n);i++)

typedef long long ll;
ll a,b;

ll from0to(ll num){
	ll res=0;

	if(num<10){
		REP1(i,num) res^=i;
		return res;
	}
	
	ll id=(num+1)%4;
	REP(i,id) res^=num-id+i+1;
	return res;
}

int main(){
    cin>>a>>b;
		ll res=0;
		if(a==b){
			cout<<a<<endl;
			return 0;
		}
		cout<<(from0to(b)^from0to(a-1))<<endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int n;
  cin >> n;
  int ans = -n;
  for(int i=0; i<n; i++){
    int a;
    cin >> a;
    ans += a;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	long long n,k,c[1001][1001]={0},g=0,i,j,l;
	scanf("%lld %lld", &n, &k);
	for(i=0; i<k; i++)
	c[0][i]=1;
	for(i=1; i<n; i++)
	{
		for(j=0; j<k; j++)
		{
			for(l=0; l<k; l++)
			{
				if(j!=l)
				c[i][l]+=c[i-1][j];
			}
		}
	}
	for(i=0; i<k; i++)
	g+=c[n-1][i];
	printf("%lld\n", g);
	
	return 0;
}

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

int main(){
    string S;
    string T;
    int ans = 0;
    
    cin >> S >> T;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == T[i]){
            ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
#include <stack>
#include <queue>
#include <cassert>
#include <forward_list>
#include <chrono>
#include <deque>
#include <list>
#include <random>
#include <cstdio>
#include <sstream>

using namespace std;

//最大公約数
template<class T>
T GCD(T m, T n)
{
	T temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
template<class T>
T LCM(T m, T n)
{
	return m * n / GCD(m, n);
}



int main()
{
	int n, m; cin >> n >> m;
	vector<vector<int>> s(m);
	for (int i = 0; i < m; i++)
	{
		int l; cin >> l;
		for (int j = 0; j < l; j++)
		{
			int num; cin >> num; --num;
			s[i].emplace_back(num);
		}
	}

	vector<int> p(m);
	for (int i = 0; i < m; i++) { cin >> p[i]; }

	long long int ans = 0;
	for (int bit = 0; bit < (1 << n); ++bit)
	{
		bool frag = true;
		for (int i = 0; i < m; i++)
		{
			int con = 0;
			for (auto j : s[i])
			{
				if (bit & (1 << j)) { con++; }
			}
			if (con % 2 != p[i]) { frag = false; }
		}
		if (frag == true) { ans++; }
	}

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

Measured memory_bytes: 888
#include <cstdio>
#include <memory.h>
#include <cstring>
#include <vector>
#include <deque>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <functional>
#include <iostream>
#include <set>
#include <list>
#include <map>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef unsigned long long llu;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
const ll MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

priority_queue<int, vector<int>, greater<int> > pq;
vector<int> v;

struct node {
	int aa, bb, cc;
};

queue<node> q;
int dist[150][150][150];

int main() {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);

	memset(dist, -1, sizeof(dist));
	dist[a][b][c] = 0;
	q.push({ a, b, c });

	node tv, tt;
	while (!q.empty()) {
		tv = q.front();
		q.pop();

		int cnt = dist[tv.aa][tv.bb][tv.cc];
		if (tv.aa == tv.bb && tv.aa == tv.cc) return !printf("%d", dist[tv.aa][tv.bb][tv.cc]);

		tt = tv;
		tt.aa++; tt.bb++;

		if (dist[tt.aa][tt.bb][tt.cc] == -1 && tt.aa < 150 && tt.bb < 150 && tt.cc < 150) {
			dist[tt.aa][tt.bb][tt.cc] = cnt + 1;
			q.push({ tt.aa, tt.bb, tt.cc });
		}

		tt = tv;
		tt.aa++; tt.cc++;

		if (dist[tt.aa][tt.bb][tt.cc] == -1 && tt.aa < 150 && tt.bb < 150 && tt.cc < 150) {
			dist[tt.aa][tt.bb][tt.cc] = cnt + 1;
			q.push({ tt.aa, tt.bb, tt.cc });
		}

		tt = tv;
		tt.bb++; tt.cc++;

		if (dist[tt.aa][tt.bb][tt.cc] == -1 && tt.aa < 150 && tt.bb < 150 && tt.cc < 150) {
			dist[tt.aa][tt.bb][tt.cc] = cnt + 1;
			q.push({ tt.aa, tt.bb, tt.cc });
		}


		tt = tv;
		tt.aa += 2;

		if (dist[tt.aa][tt.bb][tt.cc] == -1 && tt.aa < 150 && tt.bb < 150 && tt.cc < 150) {
			dist[tt.aa][tt.bb][tt.cc] = cnt + 1;
			q.push({ tt.aa, tt.bb, tt.cc });
		}
		tt = tv;
		tt.bb += 2;

		if (dist[tt.aa][tt.bb][tt.cc] == -1 && tt.aa < 150 && tt.bb < 150 && tt.cc < 150) {
			dist[tt.aa][tt.bb][tt.cc] = cnt + 1;
			q.push({ tt.aa, tt.bb, tt.cc });
		}
		tt = tv;
		tt.cc += 2;

		if (dist[tt.aa][tt.bb][tt.cc] == -1 && tt.aa < 150 && tt.bb < 150 && tt.cc < 150) {
			dist[tt.aa][tt.bb][tt.cc] = cnt + 1;
			q.push({ tt.aa, tt.bb, tt.cc });
		}
	}
}

Measured memory_bytes: 13440
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N;
  double ans = 0.0;
  double sum = 0.0;

  cin >> N;

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

  for(int i = 0; i < N; i++){
    sum = sum + (double)(1.0/(double)A[i]);
  }

  ans = 1.0/sum;

  //小数点以下指定
  cout << fixed;
  cout << setprecision(5) << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
  
// Function to calculate distance 
double distance(double x1, double y1) 
{ 
    // Calculating distance 
    return sqrt(pow(x1 - 0, 2) +  
                pow(y1 -0, 2) * 1.0); 
} 
  
// Drivers Code 
int main() 
{ 
    //cout << distance(3, 4, 4, 3); 
    int n;int d;
    cin>>n;
    cin>>d;
    double x,y;
    int count=0;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        cin>>y;
        double t=distance(x,y);
        if(t<=d)
        count++;
        
    }
    cout<<count;
    return 0; 
}

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

int shellSort(int A[], int n);
int insertionSort(int A[], int n, int g);

int main(void) 
{
    int n, i, count;
    cin >> n;
    int *A = new int[n];
    for (i = 0; i < n; i++)
        cin >> A[i];
        
    count = shellSort(A, n);
    
    cout << count << endl;
    for (i = 0; i < n; i++)
        cout << A[i] << endl;
}

int shellSort(int A[], int n)
{
    int cnt = 0;
    int m = 0, i;
    int *g = new int[n];
    g[0] = 1;
    while (g[m] <= n) 
    {
        m++;
        g[m] = pow(2, m) * pow(3, m);
    }
    cout << m << endl;
    for (i = m - 1; i >= 0; i--)
    {
        cout << g[i];
        if (i != 0) 
            cout << " ";
        cnt += insertionSort(A, n, g[i]);
    }
    cout << endl;
    return cnt;
}

int insertionSort(int A[], int n, int g)
{
    int i, j, v, cnt = 0;
    for (i = g; i < n; i++)
    {
        v = A[i];
        for (j = i - g; j >= 0 && A[j] > v; j = j - g)
        {
            A[j + g] = A[j];
            cnt++;
        }
        A[j + g] = v;
    }
    return cnt;
}


Measured memory_bytes: 7168
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,m,c,ans=0; cin>>n>>m>>c;
    vector<int> b(m,0);
    rep(i,m) cin>>b[i];
    rep(i,n){
        int cnt=c;
        rep(j,m){
            int a; cin>>a;
            cnt+=a*b[j];
        }
        if(cnt>0) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define deba(a) cout << #a << " " << a << endl;
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("/home/kushagra/Desktop/Kushagra/input.txt", "r", stdin);
	freopen("/home/kushagra/Desktop/Kushagra/output.txt", "w", stdout);
#endif
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n, m, c;
		cin >> n >> m >> c;

		ll b[m];
		rep(i, 0, m)
		cin >> b[i];

		ll a[n][m];

		rep(i, 0, n)
		{
			rep(j, 0, m)
			{
				cin >> a[i][j];
			}
		}
		ll cnt = 0;
		rep(i, 0, n)
		{
			ll ans = 0;
			rep(j, 0, m)
			{
				ans += (a[i][j] * b[j]);
			}
			ans += c;
			if (ans > 0)
				cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3628
# coding: utf-8

def bubbleSort(C, N):
    for i in xrange(N):
        for j in xrange(N-1, i, -1):
            if C[j-1][1] > C[j][1]:
                C[j], C[j-1] = C[j-1], C[j]
    return C

def selectionSort(C, N):
    for i in xrange(N):
        minj = i
        for j in xrange(i, N):
            if C[minj][1] > C[j][1]:
                minj = j
        C[i], C[minj] = C[minj], C[i]
    return C

def isStable(in_, out_, N):
    for i in xrange(N):
        for j in xrange(i + 1, N):
            for a in xrange(N):
                for b in xrange(a + 1, N):
                    if in_[i][1] == in_[j][1] and in_[i] == out_[b] and in_[j] == out_[a]:
                        return False
    return True

def main():
    N = input()
    cards = raw_input().split()
    bubble = bubbleSort(cards[:], N)
    selection = selectionSort(cards[:], N)
    print ' '.join(bubble)
    print 'Stable' if isStable(cards, bubble, N) else 'Not stable'
    print ' '.join(selection)
    print 'Stable' if isStable(cards, selection, N) else 'Not stable'



if __name__ == '__main__':
    main()

Measured memory_bytes: 4300
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
int N, W, w[109], v[109]; vector<int> r[6];
int main() {
	cin >> N >> W;
	for (int i = 0; i < 4; i++) r[i].push_back(0);
	for (int i = 0; i < N; i++) {
		cin >> w[i] >> v[i];
		r[w[i] - w[0]].push_back(v[i]);
	}
	for (int i = 0; i < 4; i++) {
		sort(r[i].begin() + 1, r[i].end(), greater<int>());
		for (int j = 1; j < r[i].size(); j++) r[i][j] += r[i][j - 1];
	}
	int ret = 0;
	for (int i = 0; i < r[0].size(); i++) {
		for (int j = 0; j < r[1].size(); j++) {
			for (int k = 0; k < r[2].size(); k++) {
				for (int l = 0; l < r[3].size(); l++) {
					long long weight = 1LL * i * w[0] + 1LL * j * (w[0] + 1) + 1LL * k * (w[0] + 2) + 1LL * l * (w[0] + 3);
					if (weight <= W) ret = max(ret, r[0][i] + r[1][j] + r[2][k] + r[3][l]);
				}
			}
		}
	}
	cout << ret << endl;
	return 0;
}

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 n = b - a - 1;
        double x = (1 / 2.0) * n * (n + 1) - a;

        System.out.println((int) x);
    }
}

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

int main()
{
    while (true)
    {
        string a;
        int L;
        cin >> a >> L;
        if (a == "0" && L == 0)
            break;

        // 前に出た数を記録
        set<int> S;
        S.insert(stoi(a));
        string prev = a;
        int di = 1; // a_di = a_dj (di > dj)
        int na = stoi(a);
        while (true)
        {
            // L桁に調整
            while (prev.size() < L)
                prev += '0';
            // prev = 88..83000
            sort(prev.rbegin(), prev.rend());
            int Max = stoi(prev, nullptr, 10);
            // prev = 0000...3445
            sort(prev.begin(), prev.end());
            int Min = stoi(prev, nullptr, 10);
            // 8483740000
            // デバッグ
            na = Max - Min;
            //cout << "Min: " << Min << " Max: " << Max << " na: " << na << endl;
            if (S.find(na) != S.end())
                break;

            prev = to_string(na);
            S.insert(na);
            ++di;
        }

        // 重複する数naと、その番号diが見つかったから、djを見つける
        if (stoi(a) == na)
        {
            cout << 0 << " " << na << " " << di << endl;
            continue;
        }
        prev = a;
        int dj = 1;
        while (true)
        {

            while (prev.size() < L)
                prev += '0';
            // prev = 88..83000
            sort(prev.rbegin(), prev.rend());
            int Max = stoi(prev, nullptr, 10);
            // prev = 0000...3445
            sort(prev.begin(), prev.end());
            int Min = stoi(prev, nullptr, 10);
            // 8483740000
            // デバッグ
            int pa = Max - Min;
            if (pa == na)
                break;

            prev = to_string(pa);
            ++dj;
        }
        cout << dj << " " << na << " " << di - dj << endl;
    }
    return 0;
}


Measured memory_bytes: 3288
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

fn main() {
    let n = input!(usize);
    let mut lst: Vec<(i32, i32, i32)> = Vec::with_capacity(n);
    for _ in 0..n-1 {
        lst.push(input!(i32, i32, i32));
    }


    for i in 0..n {
        let mut t: i32 = 0;
        for &(c, s, f) in lst.iter().skip(i) {
            if t < s {
                t = s;
            } else if t % f == 0 {
                t += 0;
            } else {
                t = t + f - (t % f);
            }
            t += c;
        }
        println!("{}", t);
    }
}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;



int main() {
	//cout << fixed << setprecision(10);
	
	
	long long int n, m, a[100][100] = {}, b[100005], c, d, k, cou = 0, one = 0, zero = 0,in;
	string str;
	cin >> str;
	n = str.length();
	while (cou < n) {
		if (str.substr(cou, 11) == "dreameraser") {
			cou += 11;
		}else if (str.substr(cou, 10) == "dreamerase") {
			cou += 10;
		}
		else if (str.substr(cou, 7) == "dreamer") {
			cou += 7;
		}
		else if (str.substr(cou, 5) == "dream") {
			cou += 5;
		}
		else if (str.substr(cou, 6) == "eraser") {
			cou += 6;
		}
		else if (str.substr(cou, 5) == "erase") {
			cou += 5;
		}
		else{
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(a, n) rep(hoge, n) printf("%d%c", a[hoge], hoge == n - 1? '\n' : ' ');
#define all(a) (a).begin(), (a).end()
#define ln(a) cout << (a) << endl

using namespace std;
using P = pair<int, int>;
using ll = long long;

ll gcd(ll a, ll b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}

signed main() {
    ll a, b;
    cin >> a >> b;
    ln(a / gcd(a, b) * b);
}


Measured memory_bytes: 256