akhauriyash/Code-Regression huggingface dataset:
#include<vector>
#include<map>
#include<algorithm>
#include<set>
#include<iostream>
#include<string>
#include<set>
#include<queue>
#include<random>
//#include<unordered_set>

using namespace std;

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> st;*/

#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#define pb push_back
#define ld long double

mt19937 rnd(51);

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    int n, m, k, x1, y1, x2, y2;
    cin >> n >> m >> k >> x1 >> y1 >> x2 >> y2;
    x1--, y1--, x2--, y2--;
    vector<vector<char>> v(n, vector<char>(m));
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            cin >> v[i][j];
        }
    }
    vector<vector<int>> d(n, vector<int>(m, 1e9));
    queue<pair<int,int>> q;
    q.push({x1, y1});
    d[x1][y1] = 0;
    while(!q.empty()){
        int i = q.front().first, j = q.front().second;
        q.pop();
        for (int l = 1; l <= k && i + l < n; l++){
            if (v[i + l][j] == '@' || d[i + l][j] < d[i][j] + 1){
                break;
            }
            if (d[i + l][j] > d[i][j] + 1){
                d[i + l][j] = d[i][j] + 1;
                q.push({i + l, j});
            }
        }
        for (int l = 1; l <= k && i - l >= 0; l++){
            if (v[i - l][j] == '@' || d[i - l][j] < d[i][j] + 1){
                break;
            }
            if (d[i - l][j] > d[i][j] + 1){
                d[i - l][j] = d[i][j] + 1;
                q.push({i - l, j});
            }
        }
        for (int l = 1; l <= k && j + l < m; l++){
            if (v[i][j + l] == '@' || d[i][j + l] < d[i][j] + 1){
                break;
            }
            if (d[i][j + l] > d[i][j] + 1){
                d[i][j + l] = d[i][j] + 1;
                q.push({i, j + l});
            }
        }
        for (int l = 1; l <= k && j - l >= 0; l++){
            if (v[i][j - l] == '@' || d[i][j - l] < d[i][j] + 1){
                break;
            }
            if (d[i][j - l] > d[i][j] + 1){
                d[i][j - l] = d[i][j] + 1;
                q.push({i, j - l});
            }
        }
    }
    if (d[x2][y2] == 1e9){
        cout << -1;
    }
    else{
        cout << d[x2][y2] << endl;
    }
	return 0;
}


Measured memory_bytes: 12008
N,A,B=map(int,input().split())
if abs(A-B)%2==0:
    print(abs(A-B)//2)
else:
    if A-1<=N-B:
        ans=A+(B-A-1)//2
        f=1
    else:
        ans=N-B+1+(N-A-(N-B+1))//2
        f=0
    print(ans)

Measured memory_bytes: 3060
import math
a,b,h,m = list(map(int, input().split())) 

short_deg = (((h*60*60+m*60) / (12*60*60)  * 360)+90) % 360
long_deg = (((h*60*60+m*60) / (60*60)  * 360)+90) % 360

short_x = math.cos(short_deg * (math.pi / 180) )*a
short_y = math.sin(short_deg * (math.pi / 180) )*a

long_x = math.cos(long_deg * (math.pi / 180) )*b
long_y = math.sin(long_deg * (math.pi / 180) )*b

l = ((short_x-long_x)**2 + (short_y-long_y)**2 )**0.5
print(l)

Measured memory_bytes: 9396
import numpy as np

d = int(input())
c = list(map(int, input().split()))
c_sum = sum(c)
s = [[] for _ in range(d)]
for i in range(d):
  s[i] = list(map(int, input().split()))
  
last = [0 for _ in range(26)]
plan = [-1 for _ in range(d)]

def loss(today):
  sum = 0
  for i in range(26):
    sum += c[i-1] * (today - last[i-1])
  return sum
  
  
v = 0
for today in range(1, d+1):
  t = np.argmax([s[today-1][i] - c_sum + c[i] for i in range(26)])
  t += 1
  last[t-1] = today
  plan[today-1] = t
  print(t)

Measured memory_bytes: 27616
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define llINF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,ans=llINF;
signed main(){
	cin>>n;
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			ans=min(ans,i+(n/i));
		}
	}
	cout<<ans-2<<endl;
	return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [a, b] <- getIntList
    print $ solve a b

solve a b | b == 1 = 0
          | a == 2 = b - 1
          | otherwise = div b (a - 1) + f (mod b (a - 1))
    where f n | n <= 1 = 0
              | otherwise = 1

Measured memory_bytes: 380
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
#define NUM 1000000007
typedef long long int lli;

int main(){
    int n;
    cin >> n;
    vector<int> appearNum(100000, 0);
    vector<int> v;
    for(int i = 0; i < n; i++){
        int q;
        cin >> q;
        v.push_back(q);
        appearNum[q]++;
    }

    int ans = 0;
    for(int i = 0; i < 100000; i++){
        if(i == 0){
            ans = max(ans, appearNum[0] + appearNum[1]);
        }else if(i < 100000 - 1){
            ans = max(ans, appearNum[i - 1] + appearNum[i] + appearNum[i + 1]);
        }else{
            ans = max(ans, appearNum[100000 - 2] + appearNum[100000 - 1]);
        }
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;

struct tree_distance{
    int n;
    vector<vector<int>> g;
    vector<int> d;
    int s;
    tree_distance(int _n,int _s){
        n = _n;
        g.resize(n);
        d.resize(n);
        for (int i = 0; i < n; ++i)
        {
            d[i] = -1;
        }
        s = _s;
    }
    void add(int a,int b){
        g[a].push_back(b);
    }
    void init(){
        dfs(s,0);
    }
    void dfs(int x,int dis){
        d[x] = dis;
        for(int i : g[x]){
            if(d[i] < 0){
                dfs(i,dis+1);
            }
        }
    }
};

int main(int argc, char const *argv[])
{
    cin.tie(0);ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    int n;cin >> n;
    tree_distance A(n,0),B(n,n-1);
    for (int i = 0; i < n-1; ++i)
    {
        int a,b;cin >> a >> b;
        a--,b--;
        A.add(a,b);A.add(b,a);
        B.add(a,b);B.add(b,a);
    }
    A.init();B.init();
    int cnt = 0;
    for (int i = 0; i < n; ++i)
    {
        if(A.d[i] <= B.d[i])cnt++;
    }

    if(cnt > n - cnt){
        cout << "Fennec" << endl;
    }else{
        cout << "Snuke" << endl;
    }
    return 0;
}


Measured memory_bytes: 14208
from itertools import accumulate


def solve(n, rev):
    def existence_right(rev_c):
        n2 = n * 2
        acc = [[0] * n2]
        row = [0] * n2
        for x in rev_c:
            row[n2 - x - 1] += 1
            acc.append(list(reversed(list(accumulate(row)))))
        return acc

    # How many white/black ball lower than 'k' righter than index x? (0<=x<=2N-1)
    # cost[color][k][x]
    cost_w, cost_b = list(map(existence_right, rev))

    dp = [0] + list(accumulate(c[y] for y, c in zip(rev[1], cost_b)))
    for w, x in enumerate(rev[0]):
        ndp = [0] * (n + 1)
        cwx = cost_w[w][x]
        ndp[0] = prev = dp[0] + cwx
        for b, y in enumerate(rev[1]):
            ndp[b + 1] = prev = min(dp[b + 1] + cwx + cost_b[b + 1][x],
                                    prev + cost_w[w + 1][y] + cost_b[b][y])
        dp = ndp
    return dp[n]


n = int(input())
# White/Black 'k' ball is what-th in whole row?
rev = [[0] * n, [0] * n]
for i in range(n * 2):
    c, a = input().split()
    a = int(a) - 1
    rev[int(c == 'B')][a] = i
print(solve(n, rev))


Measured memory_bytes: 165124
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int N;

    scanf("%d", &N);

    int i;

    int *H = (int *) malloc(sizeof(int) * N);

    for(i = 0; i < N; i ++){
        scanf("%d", H + i);
    }
    int count = 0;
    int count_max = 0;

    for(i = 1; i < N; i ++){
        if(H[i] <= H[i - 1]){
            count ++;
        }else{
            count = 0;
        }
        if(count > count_max){
            count_max = count;
        }
    }
    printf("%d\n", count_max);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

bool query(const vecint& v) {
  cout<<"?";
  for(auto&& e:v) cout<<" "<<e+1;
  cout<<endl;
  string s;
  cin>>s;
  if (s == "-1") exit(-1);
  return s == "Red";
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin>>n;
  vecint v(n);
  iota(ALL(v), 0);
  bool isred = query(v);
  int lt = 0;
  int gt = n;
  while (gt - lt > 1) {
    int mid = (gt + lt) / 2;
    iota(ALL(v), mid);
    if (query(v) == isred) {
      lt = mid;
    } else {
      gt = mid;
    }
  }
  auto clr = [] (bool isred) {
    return isred ? 'R' : 'B';
  };
  string ans(2*n, '.');
  ans[lt] = clr(isred);
  ans[lt+n] = clr(!isred);
  iota(ALL(v), lt);
  REP(i,lt) {
    v[0] = i;
    ans[i] = clr(query(v));
  }
  FOR(i, lt+n+1, 2*n) {
    v[0] = i;
    ans[i] = clr(query(v));
  }
  iota(ALL(v), -1);
  FOR(i,lt+1, n) v[i] += n + 1;
  FOR(i,lt+1, lt+n) {
    v[0] = i;
    ans[i] = clr(query(v));
  }
  cout<<"! "<<ans<<endl;
  return 0;
}


Measured memory_bytes: 724
#include <bits/stdc++.h>
using namespace std;
const int MOD=998244353;
int main(){
  int N,S,ans=0,dp[3001][3001];
  cin>>N>>S;
  vector<int> A(N);
  for(int i=0;i<N;++i){
    cin>>A.at(i);
  }
  dp[0][0]=1;
  for(int i=1;i<=N;++i){
    for(int j=0;j<=S;++j){
      dp[i][j]=dp[i-1][j];
      if(j-A.at(i-1)>=0)dp[i][j]+=dp[i-1][j-A.at(i-1)];
      dp[i][j]%=MOD;
    }
    dp[i][0]++;
    ans+=dp[i][S];
    ans%=MOD;
  }
  cout<<ans<<endl;
}


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



int main(){
    string s;cin>>s;
    if(s=="ABC")cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}
    









Measured memory_bytes: 3592
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))

rs, ls = [0], [0]
for i in range(n-1):
  rs.append(gcd(rs[i], a[i]))
  ls.append(gcd(ls[i], a[-i-1]))

gcd_list = [gcd(r,l) for r, l in zip(rs, ls[::-1])]
print(max(gcd_list))


Measured memory_bytes: 16108
c = 3.times.map { gets.split.map(&:to_i) }

heIsRight = false
a = Array.new(3)
b = Array.new(3)
(0..100).each do |n|
  isOut = false
  a[0] = n
  (0...3).each do |i|
    b[i] = c[0][i] - a[0]
  end

  a[1] = c[1][0]-b[0]
  (0...3).each do |j|
    if c[1][j] != a[1]+b[j]
      isOut = true
      break
    end
  end

  next if isOut

  a[2] = c[2][0]-b[0]
  (0...3).each do |k|
    if c[2][k] != a[2]+b[k]
      isOut = true
      break
    end
  end

  unless isOut
    heIsRight = true
    break
  end
end

if heIsRight
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
  #define DUMP(i) 
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());

using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

struct Edge{
public:
  int from,to,cost;
  Edge(){}
  Edge(int _from,int _to,int _cost){
    from = _from;
    to = _to;
    cost = _cost;
  }
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;


const int EPS = 1e-9;
const int MOD = 1e9+7;



int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  int n;
  cin >> n >> s;
  int ans = 0;
  int cnt = 0;
  REP(i,n){
    if(s[i] == 'I'){
      DUMP(cnt);
      cnt++;
      ans = max(ans,cnt);
    }
    else cnt--;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N, A, B;
  cin >> N >> A >> B;
  
  if ((B - A) % 2 == 0) {
    cout << (A + B) / 2 - A << endl;
  } else /*if ((B - A) % 2 == 1) */ {
    if (A - 1 <= N - B) {
      cout << (A - 1) + 1 + (1 + B - A) / 2 - 1 << endl;
    } else /* if (A - 1 > N - B) */ { 
      cout << (N - B) + 1  + (A + N - B + 1 + N) / 2 - (A + N - B + 1) << endl;
    }
  }

}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve{
public:
    void input(){

    }
    void solve(){
        input();

        int a,b;
        cin >> a >> b;
        cout << a + b / 2 << endl;

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include <stdio.h>

int main(void)
{
    char c;
    int r, b;

    r = b = 0;
    while((c = getchar()) != '\n'){
        if(c == '0'){
            r++;
        }else{
            b++;
        }
    }
    printf("%d\n", r < b ? r * 2 : b * 2);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#define SIZE 201

int que[SIZE];
int head, tail;

int init() { head = tail = 0; }
int empty() { return head == tail; }
int push(int elm) { que[tail] = elm; tail = (tail+1)%SIZE; }
int front() { return que[head]; }
void pop() { head = (head+1)%SIZE; }

int bfs(int n, int G[][101], int *cost) {
  int i;
  init();
  push(1);
  cost[1] = 0;
  while(!empty()) {
    int p = front();
    pop();
    for(i = 1; i <= n; ++i) {
      if(!G[p][i]) continue;
      if(cost[i] != -1) continue;
      cost[i] = cost[p] + G[p][i];
      push(i);
    }
  }
}


int main() {
  int n;
  int i,j,k;
  int G[101][101];
  int src, dst;
  int cost[101];
  for(i = 0; i < 101; ++i)  {
    cost[i] = -1;
    for(j = 0; j < 101; ++j) {
      if(i == 0) G[i][j] = 1;
      else G[i][j] = 0;
    }
  }
  scanf("%d", &n);
  for(i = 1; i <= n; ++i) {
    scanf("%d %d", &src, &k);
    while(k--) {
      scanf("%d", &dst);
      G[src][dst] = 1;
    }
  }
  bfs(n,G,cost);
  for(i = 1; i <= n; ++i) {
    printf("%d %d\n", i, cost[i]);
  }
  return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int N;
double A[100];

signed main()
{
	cin >> N;
	REP(i, N) cin >> A[i];

	double sum = 0.0;

	REP(i, N) sum += 1 / A[i];

	cout << fixed << setprecision(10) << (1 / sum) << endl;
}




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

bool f_comp(pair<string, pair<int, int>> p1, pair<string, pair<int, int>> p2)
{
  if (p1.first < p2.first)
    return (true);
  else if(p1.first > p2.first)
    return (false);
  else
  {
    if (p1.second.first > p2.second.first)
      return (true);
    else
      return (false);
  }
  
}

int main()
{ 
  string s;
  int p, n;
  
  cin >> n;
  vector<pair<string, pair<int, int>>> sp(n);
  for (int i = 0; i < n; i++)
  {
    cin >> s >> p;
    sp[i] = make_pair(s, make_pair(p, i + 1));
  }
  sort(sp.begin(), sp.end(), f_comp);
  for (int i = 0; i < n; i++)
    cout << sp[i].second.second << endl;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

const string YES = "Yes";
const string NO = "No";

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (1) {
        c -= b;
        if (c <= 0) {
            cout << YES << endl;
            return 0;
        }
        a -= d;
        if (a <= 0) {
            cout << NO << endl;
            return 0;
        }
    }
    return 0;
}


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

int main() {
	int n;
	cin>>n;
	if (n>=1800){
		cout<<1;
	}
	else if (n>=1600){
		cout<<2;
	}
	else if (n>=1400){
		cout<<3;
	}
	else if (n>=1200){
		cout<<4;
	}
	else if (n>=1000){
		cout<<5;
	}
	else if (n>=800){
		cout<<6;
	}
	else if (n>=600){
		cout<<7;
	}
	else if (n>=400){
		cout<<8;
	}
	return 0;
}

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

int main(){
    ll a,b,c,m,n,sm=0,i,j,k,mx=-1,y,ar[200010];
    string s1,s2;
    cin>>s1>>s2;
    for(i=0;i<=s1.size()-s2.size();i++){
        c=0;
        k=i;
        for(j=0;j<s2.size();j++){
            if(s1[k]==s2[j]) c++;
            k++;
        }
        mx=max(mx,c);
    }
    printf("%lld\n",s2.size()-mx);

    return 0;
}


Measured memory_bytes: 3728
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

struct UnionFind
{
    UnionFind(int n)
        : v(n)
    {
        for (int i = 0; i < n; ++i)
        {
            v[i] = i;
            m[i] = 1;
        }
    }

    ll unite(int x, int y)
    {
        x = findRoot(x);
        y = findRoot(y);

        if (same(x, y))
            return 0;
        
        ll ret = m[x] * m[y];
        m[x] += m[y];
        m[y] = 0;
        v[y] = x;

        return ret;
    }

    bool same(int x, int y)
    {
        return v[x] == v[y];
    }

    int findRoot(int x)
    {
        if (v[x] == x)
        {
            return x;
        }
        else
        {
            return v[x] = findRoot(v[x]);
        }
    }

    vec<int> v;
    std::map<int, ll> m;
};

int main()
{
    using namespace std;

    int n, m;
    cin >> n >> m;
    vec<int> a(m), b(m);
    for (int i = m - 1; i >= 0; --i)
    {
        cin >> a[i] >> b[i];
        --a[i];
        --b[i];
    }

    vec<ll> ans(m + 1);
    UnionFind uf(n);

    for (int i = 0; i < m; ++i)
    {
        auto u = uf.unite(a[i], b[i]);
        ans[i + 1] = ans[i] + u;
        //cout << u << endl;
    }

    for (int i = m - 1; i >= 0; --i)
    {
        cout << ans[m] - ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 9472
#include<stdio.h>
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if((a+b)%2==1){
        printf("%d\n",((a+b)/2)+1);
    }else{
        printf("%d\n",(a+b)/2);
    }
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
    int A[100][100],b[100],sum[100]={0,};
    int k,i,j;
    int n,m;
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&A[i][j]);
        }
    }
    for(i=0;i<m;i++){
        scanf("%d",&b[i]);
    }
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            sum[i] += A[i][j]*b[j];
        }
        printf("%d\n",sum[i]);
    }
    return 0;
}


Measured memory_bytes: 2104
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int H, W;
	cin >> H >> W;
	static int A[80][80];
	static int B[80][80];
	REP(i, H) {
		REP(j, W) {
			cin >> A[i][j];
		}
	}
	REP(i, H) {
		REP(j, W) {
			cin >> B[i][j];
		}
	}
	
	static int masAbs[80][80];
	REP(i, H) {
		REP(j, W) {
			masAbs[i][j] = abs(A[i][j] - B[i][j]);
		}
	}

#define MAX_ABS_VAL		(80 * 160 + 1)
	static bool dp[80 + 1][80 + 1][MAX_ABS_VAL];
	dp[0][0][masAbs[0][0]] = true;
	REP(i, H) {
		REP(j, W) {
			REP(k, MAX_ABS_VAL) {
				if (dp[i][j][k]) {
					dp[i][j + 1][abs(k + masAbs[i][j + 1])] = true;
					dp[i][j + 1][abs(k - masAbs[i][j + 1])] = true;
					dp[i + 1][j][abs(k + masAbs[i + 1][j])] = true;
					dp[i + 1][j][abs(k - masAbs[i + 1][j])] = true;
				}
			}
		}
	}
	
	int ans = (int)INF;
	REP(k, MAX_ABS_VAL) {
		if (dp[H - 1][W - 1][k]) {
			ans = min(ans, k);
		}
	}
	cout << ans << endl;
	return 0;
}



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

int main(){
	int a, b;
	char c;
	while(1){
		cin >> a >> c >> b;
		if(c == '?')
			break;
		else if(c == '+')
			cout << a+b << endl;
		else if(c == '-')
			cout << a-b << endl;
		else if(c == '*')
			cout << a*b << endl;
		else if(c == '/')
			cout << a/b << endl;
	}
}


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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (auto &i : a) cin >> i;

	double s = 0;
	for (int i = 0; i < k; ++i)
		s += (a[i] + 1) / 2.0;

	auto ans = s;
	for (int i = k; i < n; ++i)
	{
		s += (a[i] + 1) / 2.0;
		s -= (a[i-k] + 1) / 2.0;
		ans = max(ans, s);
	}

	cout << setprecision(20) << fixed << ans << "\n";

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int A[200010], a[200010], b[200010];
ll N, K, d[200010][71];


int main() {
	cin >> N >> K;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	for (int i = N - 1; i >= 0; --i) {
		a[i] = b[A[i]];
		b[A[i]] = i;
	}
	for (int i = N - 1; i >= 0; --i) {
		a[i] = b[A[i]];
		b[A[i]] = i;
	}
	for (int i = 0; i < N; ++i) {
		if (a[i] <= i) {
			a[i] += N;
		}
		d[i][0] = a[i] - i + 1;
	}
	for (int i = 0; i < 59; ++i) {
		for (int j = 0; j < N; ++j) {
			d[j][i + 1] = d[j][i] + d[(j + d[j][i]) % N][i];
			d[j][i + 1] = min(d[j][i + 1], N*K + 1);
		}
	}
	ll t = 0;
	vector<int>v;
	while (t < N*K) {
		for (int i = 59; i >= 0; --i) {
			if (t + d[t%N][i] <= N*K) {
				t += d[t%N][i];
			}
		}
		if (t == N*K)break;
		v.push_back(A[t%N]);
		++t;
	}
	for (int i : v) {
		cout << i << sp;
	}
	cout << endl;
}

Measured memory_bytes: 115700
using System;
class Program
{
    static void Main(string[] args)
    {
        string ball = "A";
        while (true)
        {
            string gh = Console.ReadLine();

            if (gh == null)
            {
                break;
            }
            string[] a = gh.Split(',');
            if (a[0] == ball)
            {
                ball = a[1];
            }
            else if (a[1] == ball)
            {
                ball = a[0];
            }
        }
        Console.WriteLine(ball);
        Console.ReadLine();
    }

}

Measured memory_bytes: 8708
#include <iostream>

using namespace std;

int main() {
  int x, y;
  for ( ; ; ) {
    cin >> x >> y;
    if ((0 == x) && (0 == y)) break;
    if (y < x) swap(x, y);
    cout << x << ' ' << y << endl;
  }
  return 0;
} 



Measured memory_bytes: 3008
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
string s1, s2;
int main()
{
	cin >> s1 >> s2;
	loop(i, 0, s1.size())
	{
		if (s1[i] != s2[i])
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 3580
n=int(input())
import fractions
total=0
for A in range(1,n+1):
  for B in range(1,n+1):
    for C in range(1,n+1):
      a=[A,B,C]
     
      ans = a[0]
      for i in range(1,3):
        ans=fractions.math.gcd(ans,a[i])
       
      total=total+ans
print(total)  


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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define INF (1 << 30)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

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

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int main() {
	string s;
	cin >> s;
	char c = 'a';
	bool flag;
	for(int i = 0; c + i <= 'z'; ++i) {
		flag = false;
		rep(j, s.size()) {
			if(s[j] == c + i) {
				flag = true;
				break;
			}
		}
		if(!flag) {
			printf("%c\n", c + i);
			break;
		}
	}
	if(flag) printf("None\n");
	return 0;
}

Measured memory_bytes: 512
n=int(input())
mod = 10**9+7
dp = [{} for _ in range(n+1)]

moji = ['A','C','G','T']
for c1 in moji:
    for c2 in moji:
        for c3 in moji:
            mojis = c1+c2+c3
            if mojis in ['AGC','GAC','ACG']:continue
            if mojis in dp[3]:
                dp[3][mojis] += 1
            else:
                dp[3][mojis] = 1

for i in range(4,n+1):
    for c in moji:
        for c1 in moji:
            for c2 in moji:
                for c3 in moji:
                    mojis = c1+c2+c3
                    if mojis in ['AGC','GAC','ACG']:continue
                    nowmoji = c2+c3+c
                    if nowmoji in ['AGC','GAC','ACG']:continue
                    if c1 =='A' and c3 == 'G' and c == 'C':continue
                    if c1 =='A' and c2 == 'G' and c == 'C':continue
                    if nowmoji in dp[i]:
                        dp[i][nowmoji] += dp[i-1][mojis]%mod
                        dp[i][nowmoji] %=mod
                    else:
                        dp[i][nowmoji] =  dp[i-1][mojis]%mod
                        dp[i][nowmoji] %=mod

print(sum(dp[n].values())%mod)

Measured memory_bytes: 3748
n=int(input())
a=list(map(int,input().split()))
def cal(x):
    divisors = []
    for i in range(1, int(x**0.5)+1):
        if x % i == 0:
            divisors.append(i)
            if i != x // i:
                divisors.append(x//i)
    return divisors
num=[0 for _ in range(n+1)]
cnt=0
ans=[]
for k in range(n):
    if (num[n-k]+1)%2==a[-1-k]:
        ans.append(n-k)
        cnt+=1
        l=cal(n-k)
        for p in l:
            num[p]+=1
ans1=[]
for j in range(cnt):
    if j<cnt-1:
        ans1.append(str(ans[j]))
        ans1.append(" ")
    else:
        ans1.append(str(ans[j]))
print(cnt)
if len(ans1)>0:
    result=''.join(ans1)
    print(result)


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

using namespace std;

signed main() {
    int n, cnt = 0; cin >> n;
    vector<long long> a(n, 0);

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

    for (int i = 0; i < n - 2; ++i) {
        for (int j = i + 1; j < n - 1; ++j) {
            for (int k = j + 1; k < n; ++k) {
                if (a[i] + a[j] > a[k] &&
                    a[i] + a[k] > a[j] &&
                    a[j] + a[k] > a[i] &&
                    a[i] != a[j] && a[j] != a[k] && a[i] != a[k]) ++cnt;
            }
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>
#include <set>

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    string str1,str2;
    string al = "abcdefghijklmnopqrstuvwxyz";
    int ans = 0;
    rep(i,n){
        set<char> st1,st2;
        int tot = 0;
        str1 = s.substr(0,i);
        str2 = s.substr(i,n);
        rep(j,str1.length()){
            st1.insert(str1[j]);
        }
        rep(j,str2.length()){
            st2.insert(str2[j]);
        }
        rep(i,26){
            if(st1.count(al[i]) == 1 && st2.count(al[i]) == 1 ){
                tot++;
            } 
        }
        ans = max(ans,tot);
    }
    cout << ans << endl;

    return 0;
}

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

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

int main() {
  int N, count = 1;
  cin>>N;
  vector<int> a(N);
  rep(i, N) cin>>a[i];
  
  rep(i, N){
  	if(a[i] == count){
    	count ++;
    }
    else{
      a[i] = 0;
    }
    
  }
  if(count == 1){
  	cout<<-1<<endl;
  }
  else{
    cout<<N-(count-1)<<endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cout << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

using P = pair<int,int>;
random_device seed_gen; mt19937_64 mtrand(seed_gen());
//////////////////////////////////////////

int main(){
  ini(p); vi a(p); in(a);

  // 逆元の前計算
  vl inv(p , 1);
  for(int i = 2; i < p ; i++)
    inv[i] = p - inv[p % i] * (p / i) % p;

  vl ans(p,0);
  // k=0
  ans[0] = a[0];
  // k=1~p-2
  for(int l = 1; l <= p - 1; l++){
    ll cur = 1;
    for(int k = 1; k <= p - 2; k++){
      cur = cur * inv[l] % p;
      ans[k] += a[l] * cur;
    }
  }
  for(int k = 1; k <= p - 2; k++){
    ans[k] = ans[k] * inv[p-1] % p;
  }
  // k = p-1
  for(int l=1; l <= p - 1; l++){
    ans[p-1] = (ans[p-1] + a[l]) % p;
  }
  ans[p-1] = ans[p-1] * inv[p-1] % p;
  ans[p-1] = (ans[p-1] + p - a[0]) % p;

  out(ans);
}

Measured memory_bytes: 512
#include<cstdio>
int i,n;
int main()
{
	scanf("%d",&n);
	if(n==(n&-n))return 0*puts("No");
	else printf("Yes\n%d 3\n",1+n);
	if(~n&1)printf("%d %d\n%d %d\n",n,n^(n&-n),(n&-n)+n+1,n<<1);
	for(i=2;i<n;i+=2)printf("%d %d\n%d %d\n1 %d\n1 %d\n",i,i+1,i+n,i+n+1,i,i+n+1);
	return 0;
}

Measured memory_bytes: 2304
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    Scanner sc=new Scanner(System.in);
		int[][] a = new int[3][3];
		int[][] vis = new int[3][3];
		for(int i=0;i<3;i++)
		{
		    for(int j=0;j<3;j++)
		    {
		        a[i][j] =sc.nextInt();
		        vis[i][j] = 0;
		    }
		}
		int n=sc.nextInt();
		for(int k=0;k<n;k++)
		{
		    int x=sc.nextInt();
		    for(int i=0;i<3;i++)
		    {
		        for(int j=0;j<3;j++)
		        {
		            if(a[i][j] == x)
		            {
		                vis[i][j] = 1;
		            }
		        }
		    }
		}
		int flag=0;
		for(int i=0;i<3;i++)
		{
		if(vis[i][0] == 1 && vis[i][1] == 1 && vis[i][2] == 1)
		{
		    flag=1;
		}
		}
		for(int i=0;i<3;i++)
		{
		if(vis[0][i] == 1 && vis[1][i] == 1 && vis[2][i] == 1)
		{
		    flag=1;
		}
		}
		if(vis[0][0] == 1 && vis[1][1] == 1 && vis[2][2] == 1)
		{
		    flag=1;
		}
		if(vis[0][2] == 1 && vis[1][1] == 1 && vis[2][0] == 1)
		{
		    flag=1;
		}
		if(flag == 1)
		{
		    System.out.println("Yes");
		}
		else{
		    System.out.println("No");
		}
	}
}


Measured memory_bytes: 23764
/*input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll maxn=3e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll sub(ll a,ll b){
    ll x=a-b;
    while(x<0) x+=MOD;
    while(x>MOD) x-=MOD;
    return x;
}
ll mult(ll a,ll b){
    return a*b%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=(res*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
int cnt[maxn];
int main(){
    int n,m;
    cin>>n>>m;
    int ac=0,p=0;
    REP(i,m){
        int a;
        string b;
        cin>>a>>b;
        if(cnt[a]==INF) continue;
        if(b=="AC" and cnt[a]!=INF){
            p+=cnt[a];
            ++ac;
            cnt[a]=INF;
        }
        if(b=="WA"){
            cnt[a]++;
        }
    }
    cout<<ac<<' '<<p;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
  int a,b;
  cin >>a>>b;
  if(a>0){
   cout<<"Positive"; 
  }
  else if(b<0){
    if((b-a)%2==0){
      cout<<"Negative"; 
    }
    else{
      cout<<"Positive"; 
    }
  }
  else{
   cout<<"Zero" ;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	int n, m, a[1001], t, p, q, r;
	bool f;
	
	while(cin>>n>>m&&n&&m){
		vector<int> vec;
		for(int i = 1; i <= n; i++){
			cin >> a[i];
		}
		a[0] = 0;
		
		for(int i = 0; i <= n; i++){
			for(int j = 0; j <= n; j++){
				r = a[i]+a[j];
				f = true;
				for(int k = 0; k < vec.size(); k++){
					if(r == vec[i]){
						f = false;
						break;
					}
				}
				if(f){
					vec.push_back(r);
				}
			}
		}
		sort(vec.begin(), vec.end());
		
		t = 0;
		for(int i = 0; i < vec.size(); i++){
			p = 0;
			q = vec.size();
			while(q-p > 1){
				r = (p+q)/2;
				if(vec[i]+vec[r] >= m){
					q = r;
				} else {
					p = r;
				}
			}
			r = vec[i]+vec[p];
			if(t < r && r <= m){
				t = r;
			}
		}
		
		cout << t << endl;
	}
	
	return 0;
}

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

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

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

  cout << a + a*a + a*a*a;
}


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

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

int h, w, c, p[16][16], q[16][16];

int draw(int x, int y, int f, int t) {
    if(f==t || x<0 || x>=h || y<0 || y>=w) return 0;
    if(q[x][y]!=f) return 0;
    q[x][y] = t;
    int ans = 1;
    rep(i, 4) ans += draw(x+dx[i], y+dy[i], f, t);
    return ans;
}

int main() {
    for(;;) {
        scanf("%d%d%d", &h, &w, &c);
        if(h==0 && w==0 && c==0) return 0;
        rep(i, h) rep(j, w) scanf("%d", p[i]+j);
        int kk = 1;
        rep(i, 4) kk *= 6;
        int ans = 0;
        rep(b, kk) {
            rep(i, h) rep(j, w) q[i][j] = p[i][j];
            int t = b;
            rep(i, 4) {
                draw(0, 0, q[0][0], t%6+1);
                t /= 6;
            }
            draw(0, 0, q[0][0], c);
            ans = max(ans, draw(0, 0, q[0][0], 0));
        }
        printf("%d\n", ans);
    }
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    int n ;
    ll a, b ;
    cin >> n >> a >> b ;
    vll x(n) ;
    REP(i,n){
        cin >> x[i] ;
    }
    ll ans = 0 ;
    REP(i,n-1){
        ans += min(b,a*(x[i+1]-x[i])) ;
    }
    cout << ans <<endl;


    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int lim = 50;
int n, m;
bool graph[lim][lim];
bool visited[lim];
void dfs(int v)
{
    visited[v] = true;
    for (int V = 0; V < n; V++)
    {
        if (graph[v][V] == false)
            continue;
        if (visited[V] == true)
            continue;
        dfs(V);
    }
}
int main()
{
    int ans = 0;
    cin >> n >> m;
    vector<int> a(m), b(m);
    for (int i = 0; i < m; i++)
    {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }
    for (int i = 0; i < m; i++)
    {
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
        for (int j = 0; j < n; j++)
            visited[j] = false;
        dfs(0);
        bool bridge = 0;
        for (int j = 0; j < n; j++)
            if (!visited[j])
                bridge = true;
        if (bridge)
            ans++;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }
    cout << ans << endl;
}

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

using namespace std;

#define pb push_back

const int N = 1e5 + 5;
int n, m, dp[N], ans;
vector<int> par[N];

int solve (int u) {
    if (dp[u] != -1) return dp[u];
    dp[u] = 0;
    for (int v : par[u]) dp[u] = max(dp[u], solve(v) + 1);
    return dp[u];
}

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

    memset(dp, -1, sizeof dp);
    while (m --) {
        int x, y; scanf("%d %d", &x, &y);
        par[y].pb(x);
    }

    for (int i = 1; i <= n; ++i) solve(i), ans = max(ans, dp[i]);

    cout << ans;

    return 0;
}


Measured memory_bytes: 9088
#include<stdio.h>

int main(){
    int a, b, c, tmp;
    scanf("%d %d %d", &a, &b, &c);
    if (a > b){
        tmp = a;
        a = b;
        b = tmp;
    }
    if (b > c){
        tmp = b;
        b = c;
        c = tmp;
    }
    if (a > b){
        tmp = a;
        a = b;
        b = tmp;
    }
    printf("%d %d %d\n", a, b, c);
    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
int n;
const int MOD = 1000000007;
const int N = 300000;
int ai[N];
int powi(int a, int b)
{
    int c = 1;
    for (; b; b >>= 1, a = 1ll * a * a % MOD)
        if (b & 1) c = 1ll * c * a % MOD;
    return c;
}
int fac[N], inv[N], cnt[N];
int C(int a, int b)
{
    if (a < 0 || b < 0 || a - b < 0) return 0;
    return 1ll * fac[a] * inv[b] % MOD * inv[a - b] % MOD;
}
int main()
{
    cin >> n; n ++;
    for (int i = 1; i <= n; ++ i)
    {
        cin >> ai[i];
        cnt[ai[i]] ++;
    }
    int l;
    for (int i = 1; i < n; ++ i)
        if (cnt[i] == 2)
        {
            int s, e;
            for (int j = 1; j <= n; ++ j)
                if (ai[j] == i) {s = j; break;}
            for (int j = n; j >= 1; -- j)
                if (ai[j] == i) {e = j; break;}
            l = n - (e - s + 1);
        }
    fac[0] = 1; for (int i = 1; i <= n; ++ i) fac[i] = 1ll * fac[i - 1] * i % MOD;
    inv[n] = powi(fac[n], MOD - 2);
    for (int i = n - 1; ~i; -- i) inv[i] = 1ll * inv[i + 1] * (i + 1) % MOD;
    for (int i = 1; i <= n; ++ i)
    {
        cout << (C(n, i) - C(l, i - 1) + MOD) % MOD<< endl;
    }
}


Measured memory_bytes: 4096