akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace ABC164
{
    public class Solve
    {
        public static void Main(string[] args)
        {
            new ABC_B();
        }
    }
    public class ABC_A
    {
        public ABC_A()
        {
            var l = Ex.ReadIntArray();
            var s = l[0];
            var w = l[1];
            var str = (s <= w) ? "unsafe" : "safe";
            str.Cw();
        }
    }
    public class ABC_B
    {
        public ABC_B()
        {
            var l = Ex.ReadIntArray();
            var a = l[0];
            var b = l[1];
            var c = l[2];
            var d = l[3];

            int i = 0;
            while (a > 0 && c > 0)
            {
                if (i % 2 == 0)
                {
                    c -= b;
                }
                else
                {
                    a -= d;
                }
                i++;
            }
            var res = (a > 0) ? "Yes" : "No";
            res.Cw();
        }
    }
    public class ABC_C
    {
        public ABC_C()
        {
        }
    }
    public class ABC_D
    {
        public ABC_D()
        {
        }
    }
    public class ABC_E
    {
        public ABC_E()
        {
        }
    }
    public class ABC_F
    {
        public ABC_F()
        {
        }
    }
    public static class Ex
    {
        public static void Cw(this object s) { Console.WriteLine(s); }

        public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.Ordinal); return s.ToList(); }
        public static string yesno(this bool b) { return b ? "yes" : "no"; }
        public static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        public static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        public static string Read { get { return Console.ReadLine().Trim(); } }
        public static int ReadInt { get { return int.Parse(Read); } }
        public static long ReadLong { get { return long.Parse(Read); } }
        public static double ReadDouble { get { return double.Parse(Read); } }
        public static string[] ReadArray() { return Read.Split(' '); }
        public static int[] ReadIntArray() { return Read.Split(' ').Select(int.Parse).ToArray(); }
        public static long[] ReadLongArray() { return Read.Split(' ').Select(long.Parse).ToArray(); }
        public static string[] ReadArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public static int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public static long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 18988
// AtCoder Beginner Contest 159 D.cpp

#include <iostream>
#include <vector>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;

typedef unsigned long long ULL;
typedef mp::cpp_int A;

ULL nCr(ULL n, ULL r) {
	if (n == 1)
		return 0;
	if (n == 2)
		return 1;
	A re = 1;
	for (int i = 0; i < r; i++, n--) {
		re *= n;
	}
	for (int i = 0; i < r; i++) {
		re /= (r - i);
	}
	return static_cast<ULL>(re);
}

int main()
{
	ULL n, number;
	A answer = 0;
	cin >> n;
	vector<ULL>a(n);
	vector<ULL>list;//使われてる数を用意
	list.reserve(n);
	vector<bool>z(n, false);//listのためのやつ
	vector<ULL>d1(n, 0);//それぞれの数の個数を計測
	vector<ULL>d2(n, 0);//それぞれの数の取り出し方の数を記録
	vector<ULL>d3(n, 0);//それぞれの数の取り出し方の数を記録
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (!z[a[i] - 1]) {
			list.push_back(a[i]);
			z[a[i] - 1] = true;
		}
		d1[a[i] - 1]++;
	}
	for (int i = 0; i < list.size(); i++) {
		number = list[i] - 1;
		d2[number] = nCr(d1[number], 2);
		d3[number] = d2[number] - nCr(d1[number] - 1, 2);
		answer += d2[number];
	}
	for (int i = 0; i < n; i++) {
		cout << answer - d3[a[i] - 1] << endl;
	}
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <typeinfo>
using namespace std;

#define ll long long 

 
int main()
{
    int N;
    cin >> N;
    ll arr[N];
    ll dp[N+1][N+1]; 
    fill(*dp, *dp + ((N+1)*(N+1)), 0);
    for (int i =0; i<N; ++i){
        cin >> arr[i];
    }
    ll ans;
    for (int i=N-1; i>=0; --i){
        for (int j=i; j<=N; ++j){
            if (j < 0)
                continue;
            dp[i][j] = max(arr[i] - dp[i+1][j], arr[j] - dp[i][j-1]);
        }
    }
    cout <<dp[0][N-1];
    return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  int l,r;
  cin >> a >> b >> c >> d;
  l = a + b;
  r = c + d;
  if(l == r){
    cout << "Balanced" << endl;
  }
  else if(l > r){
   cout << "Left" << endl;
  }
  else if(l < r){
  cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long W,H;
  long long x,y;
  cin>>W>>H>>x>>y;
  int mark=0;
  if(W%2==0&&H%2==0){
    if(x==W/2&&y==H/2){
      mark=1;
    }
  }
  double T=W*H;
  cout<<fixed<<setprecision(10)<<double(T/2)<<" "<<mark<<endl;
}

Measured memory_bytes: 256
# C - Dice and Coin

n, k = map(int, input().split())

ans = 0
for i in range(1, n+1):
    if i >= k:
        ans += 1/n
    else:
        j = i
        c = 0
        while j<k:
            j <<= 1
            c += 1
        ans += (1/n)*pow(0.5, c)

print(ans)

Measured memory_bytes: 3060
N,M,R = gets.chomp.split(" ").map(&:to_i)
r = gets.chomp.split(" ").map{|i|i.to_i-1}
edge = Array.new(N).map{Array.new}
path = Array.new(R).map{Array.new(N,)}
ans = 10**8
M.times do
  a,b,c = gets.chomp.split(" ").map(&:to_i)
  edge[a-1] << [b-1,c]
  edge[b-1] << [a-1,c]
end
R.times do |i|
  path[i][r[i]] = 0
  fro = r[i]
  temp = Hash.new(10**8)
  temp[fro] = 0
  N.times do
    edge[fro].each do |j,k|
      if temp[j] > path[i][fro]+k && path[i][j].nil?
        temp[j] = path[i][fro]+k
      end
    end
    min = temp.min_by{|k,v|v}
    temp.delete(min[0])
    path[i][min[0]] = min[1]
    fro = min[0]
  end
end
r.permutation(R) do |arr|
  temp = 0
  for i in 0..R-2
    temp += path[r.index(arr[i])][arr[i+1]]
  end
  ans = [ans,temp].min
end
puts ans

Measured memory_bytes: 6652
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = readInts()
q = I()
sumA = sum(A)
C = Counter(A)
for i in range(q):
    b,c = readInts()
    sumA -= b * C[b]
    sumA += c * C[b]
    C[c] += C[b]
    C[b] = 0
    print(sumA)


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

int main() {
  int A, B;
  cin >> A >> B;

  if ((A % 2 == 0 && B % 2 == 0) || (A % 2 == 1 && B % 2 == 1)) {
    cout << (A + B) / 2 << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N, K; cin >> N >> K;

    vector<intmax_t> x(N);
    for (auto &xi: x) cin >> xi;

    intmax_t minv = LINF;
    for (size_t left = 0; left + K - 1 < N; ++left) {
        size_t right = left + K - 1;

        if (x[right] < 0) {
            chmin(minv, abs(x[left]));
        } else if (x[left] <= 0 && 0 <= x[right]) {
            chmin(minv, min(abs(x[left]) + abs(x[right] - x[left]), abs(x[right] + abs(x[left] - x[right]))));
        } else if (0 < x[left]) {
            chmin(minv, x[right]);
        }
    }

    cout << minv << "\n";

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
  int a[3];
  int n;

  while(cin>>n){
    while(n--){
      for(int i = 0; i < 3; ++i){ cin >> a[i]; a[i] *= a[i];}
      sort(a, a+3);

      if(a[0]+a[1] == a[2]) cout << "YES" << endl;
      else cout << "NO" << endl;
    }
  }


  return 0;
}

Measured memory_bytes: 1172
import sys
from collections import *
from heapq import *
from fractions import gcd

sys.setrecursionlimit(10**6)

N, M = map(int, input().split(' '))
A = [0]*N

for i in range(N):
    a, b = map(int, input().split(' '))
    A[i] = [a, b]

res = 0
for a in sorted(A):
    if(a[1] < M):
        M -= a[1]
        res += a[0] * a[1]
    else:
        res += a[0] * M
        M = 0
    if(M == 0):
        break
print(res)

exit()


Measured memory_bytes: 22964
#include <iostream>
#include <cassert>
#include <vector>

long long MOD = 1000000007;

int main()
{
  int n;
  std::cin >> n;
  std::vector<char> c(n + 1);
  for (int i = 1; i <= n; ++i)
    std::cin >> c[i];

  // dp[i][j] = 割り当ての二部グラフにおいて
  //            上から i 行までみて
  //            左右ともに j 個保留している場合の総数

  std::vector<std::vector<long long>> dp(n + 1);
  for (int i = 0; i <= n; ++i)
    dp[i].assign(n + 1, 0);

  dp[0][0] = 1;

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= i; ++j) {
      if (c[i + 1] == '-') {
        (dp[i + 1][j] += dp[i][j]) %= MOD;
      } else if (c[i + 1] == 'U') {
        (dp[i + 1][j + 1] += dp[i][j]) %= MOD;
        (dp[i + 1][j] += dp[i][j] * j) %= MOD;
      } else {
        (dp[i + 1][j] += dp[i][j] * j) %= MOD;
        if (j >= 1)
          (dp[i + 1][j - 1] += dp[i][j] * j * j) %= MOD;
      }
    }
  }

  std::cout << dp[n][0] << std::endl;

  return 0;
}



Measured memory_bytes: 3216
//
//  main.cpp
//  ABC139B
//
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int A,B;
    int ans=0;
    int p=0;
    cin >> A >> B;
    if (B>1) {
        while (p<B) {
            ans++;//差込口が足りないなら、電源タップを増やす
            p=A*ans-ans+1;//差込口の数を計算する
        }
        cout << ans<<endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N,K = list(map(int,input().split()))
p = list(map(int,input().split()))

def expec(n):
    return ((1/2 * n * (n+1) )/ n)

def maxSum(arr, n, k): 
    res = 0
    for i in range(k): 
        res += expec(arr[i])
    curr_sum = res 
    for i in range(k, n):       
        curr_sum += expec(arr[i]) - expec(arr[i-k])
        res = max(res, curr_sum) 
    return res 
  
print(maxSum(p, N, K)) 
  


Measured memory_bytes: 71792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll mod = 1e9+7;
typedef pair<int,int> P;
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,m,N) for(int i=m;i<N;i++)
#define mm(n,m) memset(n,m,sizeof(n))


vector<ll>tr[200001];
ll ans[200001];

void dfs(ll cu , ll pa = -1){
    for(auto to : tr[cu]){
        if(pa!=to){
            ans[to] += ans[cu];
            dfs(to,cu); 
        }
    }
}

int main(){
    ll n,q;
    cin>>n>>q;
    ll a[n],b[n];
    ll p[q],x[q];
    mm(a,0);
    mm(b,0);
    mm(p,0);
    mm(x,0);
    rep(i,n-1){
        cin>>a[i]>>b[i];
        tr[a[i]].push_back(b[i]);
        tr[b[i]].push_back(a[i]);
    }
    mm(ans,0);
    rep(i,q){
        cin>>p[i]>>x[i];
        ans[p[i]]+=x[i];
    }
    // for(int i=1;i<n;i++){
    //     ll d = tr[i].size();
    //     for(int j=0;j<d;j++){
    //         ans[tr[i][j]] += ans[i];
    //         cout<<tr[i][j]<<endl;
    //     }
    // }
    dfs(1);
    for(int i=1;i<=n;i++)cout<<ans[i]<<" ";
    cout<<endl;
}

Measured memory_bytes: 30464
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(N: int, p: "List[int]"):
    
    q = sorted(p)
    x = [ p[i] == q[i] for i in range(N)]
    if(x.count(False) in (0,2)):
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  int R, N;
  while(cin >> R >> N, R){
	VVI hs(50, VI(50, 0));
	REP(i,N){
	  int l, r, h; cin >> l >> r >> h;
	  for(int x=l;x<r;++x)
		hs[x+20][x+20+1] = max(hs[x+20][x+20+1], h);
	}
	
	double ans = 0.;
	for(;1;){
	  bool ok = true;
	  double y = ans - R;
	  for(int x=-20;x<=20;++x){
		int h = hs[x+20][x+20+1];
		if(x*x + (h-y)*(h-y) < R*R || (x+1)*(x+1)+(h-y)*(h-y)<R*R)
		  ok = false;
	  }
	  if(!ok) break;
	  ans += 0.0001;
	}ans -= 0.0001;
	cout << fixed << setprecision(9) << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1292
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n, k;
llong  T[MAX];

int countCheck(llong p) {
    int i = 0;
    for (int j = 0; j < k; j++) {
        llong s = 0;
        while(s + T[i] <= p) {
            s += T[i];
            i++;
            if (i == n) return n;
        }
    }
    return i;
}

int result() {
    llong left = 0;
    llong right = 100000 * 10000;
    llong mid;
    while (right - left > 1) {
        mid = (left + right) / 2;
        int v = countCheck(mid);
        if (v >= n) right = mid;
        else left = mid;
    }
    return right;
}

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> T[i];
    llong ans = result();
    cout << ans << endl;
    return 0;
}


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

int main(void){
    int n;
    cin >> n;
    vector<int> v(3);
    for(int i=0; i<n; i++){
        int a, b = 0;
        cin >> a;
        for(int j=0; j<2; j++){
            if(a%2 == 0){
                a /= 2;
                b++;
            }
        }
        v.at(b)++;
    }
    if(v.at(2) >= v.at(0) - 1 + (v.at(1) & 1)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define pii pair <int,int>
#define vpii vector< pair<int,int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	string s;
	int n, i;
	cin >> n;
	cin >> s;
	int cnt = 0;
	fo(i, 0, n - 2){
		if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
		cnt++;
	}
	cout << cnt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  string s;
  cin>>s;
  cout<<(s[0]-'0')+(s[1]-'0')+(s[2]-'0')<<endl;
}

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

int main() {
    int n,k;cin>>n>>k;
    int a[n];
    int i,j;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    if(n==1)
    {
        cout<<"0"<<endl;
        return 0;
    }
    else if(n==2)
    {
        cout<<abs(a[1]-a[0])<<endl;
        return 0;
    }
    int dp[n];
    for(i=0;i<n;i++)
    {
        dp[i] = INT_MAX;
    }
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    int count = 1;
    for(i=2;i<n;i++)
    {
        j = 1;
        while(j<=k && i-j>=0)
        {
            
            dp[i] = min(dp[i],abs(a[i]-a[i-j])+dp[i-j]);
          
            j++;
        }
        
    }
   
 
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
  int a, b, n;
  string ans = "No";
  cin >> a >> b;
  if (b < 10) n = 10 * a + b;
  if (b >= 10 && b < 100) n = 100 * a + b;
  if (b == 100) n = 1000 * a + b;
  for (int i = 1; i <= 317; i++){
    if(n == i*i) ans = "Yes";
  }
  cout << ans;
}

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


int main(){
    string S;
   cin>>S;
   bool allA=true,allB=true;
   for(int i=0;i<3;i++){
       if(S.at(i)=='A'){
           allB=false;
       }
       if(S.at(i)=='B'){
           allA=false;
       }
   }
   if(allA||allB){
       cout<<"No"<<endl;
   }
   else{
       cout<<"Yes"<<endl;
   }
}


Measured memory_bytes: 256
A, B, C = map(int, input().split())
K = int(input())

for i in range(K):
    if B <= A:
       
        B = B*2
        
    elif C <= B:
       
        C = C*2
        
    else:
       
        C = C*2
        
if A < B and B < C:
    print('Yes')
    
else:
    print('No')
        

Measured memory_bytes: 9172
#include<iostream>
using namespace std;
typedef long long int ll;
ll max(ll a,ll b)
{
  if(a>b)
    return a;
  else if(b>a)
    return b;
  else
  return a;
}  
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll a,b,c,d;
  ll x,y;
  cin>>a>>b>>c>>d;
  ll m,n;
  x=max(a,b);
  m=min(a,b);
  y=max(c,d);
  n=min(c,d);
  ll q,w,e,r;
  q=x*y;
  w=x*n;
  e=m*y;
  r=m*n;
  cout<<max(max(q,w),max(e,r))<<"\n";
  return 0;
}

Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define forit(it,cont) for(auto it=cont.begin();it!=cont.end();it++)
#define forv(v,cont) for(auto v:cont)
#define for0(i,n) for(i=0;i<n;i++)
#define for1(i,n) for(i=1;i<=n;i++)
#define for0r(i,n) for(i=n-1;i>=0;i--)
#define for1r(i,n) for(i=n;i>=1;i--)
#define ll long long 
const ll inf=1e16;
const ll _inf=-1e16;
ll dx[]={1,-1,0,0};
ll dy[]={0,0,1,-1};
#define mod 1000000007
void  addmod(ll& a,ll b)
{
	a+=b;
	if(a>=mod)
		a-=mod;
}
void submod(ll& a,ll b)
{
	a-=b;
	if(a<0)
		a+=mod;
}
ll dp[105][100005];
ll a[100005];
ll pre[105][100005];
int main()
{
	ll n,k,i,j,can;
	cin>>n>>can;
	for1(i,n)
	cin>>a[i];
	dp[0][0]=1;pre[0][0]=1;
	for(i=1;i<=can;i++)
		dp[0][i]=0;
	for(i=1;i<=can;i++)
		pre[0][i]+=pre[0][i-1];
	for(i=1;i<=n;i++)
		dp[i][0]=1,pre[i][0]=1;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=can;j++)
		{
			if(j-a[i]>0)
			{
				dp[i][j]=pre[i-1][j]-pre[i-1][j-a[i]-1];
				if(dp[i][j]<0)
					dp[i][j]+=mod;
			}
			else 
				dp[i][j]=pre[i-1][j];
			pre[i][j]=(pre[i][j-1]+dp[i][j])%mod;
		}
	}
/*	for(i=0;i<=n;i++)
	{
		for(j=0;j<=can;j++)
			cout<<pre[i][j]<<" ";
		cout<<endl;
	}
	cout<<endl;
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=can;j++)
			cout<<dp[i][j]<<" ";
		cout<<endl;
	}*/
//	cout<<endl;
	cout<<dp[n][can]<<endl;
	return 0;	
}


Measured memory_bytes: 160000
#include<bits/stdc++.h>
using namespace std;
int main(){
  string str;
  cin>>str;
if(str=="MON"){
  cout<<6<<endl;
}
else if(str=="TUE"){
  cout<<5<<endl;
}
else if(str=="WED"){
  cout<<4<<endl;
}
 else if(str=="THU"){
   cout<<3<<endl;
 }
  else if(str=="FRI"){
    cout<<2<<endl;
  }
  else if(str=="SAT"){
    cout<<1<<endl;
  }
  else if(str=="SUN"){
    cout<<7<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    field = list(map(int, input().split()))

    dpList = [0] * N
    dpList[1] = abs(field[0] - field[1])

    for i in range(2, N):
        dpList[i] = min([dpList[i - 1] + abs(field[i] - field[i - 1]), dpList[i - 2] + abs(field[i] - field[i - 2])])
        
    print(dpList[-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 13928
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;
const double eps=1e-10;
int main()
{
  int x;
  cin>>x;
  pair<double,double> pos={0,0};
  int ans=0;
  do
  {
    double theta=(90+ans*x)*M_PI/180;
    pos.first+=cos(theta);
    pos.second+=sin(theta);
    ans++;
  }while(abs(pos.first)>eps||abs(pos.second)>eps);
  cout<<ans<<endl;
}

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

typedef pair<int, int> P;

int main(void){
    int N; cin >> N;
    vector<P> R(N), B(N);

    for(int i=0; i<N; i++){
        cin >> R[i].second >> R[i].first;
    }
    for(int i=0; i<N; i++){
        cin >> B[i].first >> B[i].second;
    }

    sort(R.begin(), R.end());
    sort(B.begin(), B.end());

    int cupple=0;
    for(int i=0; i<N; i++){
        for(int j=R.size()-1; j>=0; j--){
            if(B[i].first>R[j].second && B[i].second>R[j].first){
                cupple++; R.erase(R.begin()+j); break;
            }  
        }
    }

    cout << cupple << endl;
}

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

using namespace std;

long int a[3005],dp[3005][3005][2];

long int brute(int i,int j,int k)
{
	//cout<<i<<" "<<j<<" "<<k<<endl;
	if(i == j)
	{
		if(k == 0)
		return a[i];
		return -a[i];
	}
	if(dp[i][j][k] == -1)
	{
		if(k == 0)
		dp[i][j][k] = max(brute(i+1,j,1)+a[i],brute(i,j-1,1)+a[j]);
		else 	
		dp[i][j][k] = min(brute(i+1,j,0)-a[i],brute(i,j-1,0)-a[j]);
	}
	return dp[i][j][k];
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;++i)
	scanf("%ld",a+i);
	/*for(int i=n;i>=0;--i)
	{
		for(int j=i;j<=n;++j)
		{
			if(i == n || j == 0)
			{
				dp[i][j][0] = 0;
				dp[i][j][1] = 0;
			}
			else if(i == j)
			{
				dp[i][j][0] = 0;
				dp[i][j][1] = 0;
			}
			else 
			{
				//0
				dp[i][j][0] = max(dp[i+1][j][1]+a[i],dp[i][j-1][1]+a[j]);
				dp[i][j][1] = min(dp[i+1][j][0]-a[i],dp[i][j-1][0]-a[j]);
			}
		}
	}*/
	memset(dp,-1,sizeof dp);
	printf("%ld\n",brute(0,n-1,0));
	return 0;
}


Measured memory_bytes: 141568
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=sys.stdin.readline
def resolve():
    n,k=map(int,input().split())
    X=tuple(map(int,input().split()))
    ans=INF
    for i in range(n-k+1):
        a,b=X[i],X[i+k-1]
        if a<0<b:
            ans=min(ans,b-a+min(-a,b))
        else:
            ans=min(ans,max(abs(a),abs(b)))
    print(ans)
resolve()

Measured memory_bytes: 58736
#include<bits/stdc++.h>
using namespace std;
#define P 1000000007
int main(){
  long long N,M;cin>>N>>M;
  vector<long long>S(N),T(M);
  for(long long i=0;i<N;i++)cin>>S[i];
  for(long long i=0;i<M;i++)cin>>T[i];
  
  vector<vector<long long> > DP(N,vector<long long>(M,0));
  for(long long s=0;s<N;s++){
    for(long long t=0;t<M;t++){
      if(s==0&&t==0){
        DP[s][t]=(S[s]==T[t])+1;
      }
      else if(s==0){
        DP[s][t]=((S[s]==T[t])+DP[s][t-1])%P;
      }
      else if(t==0){
        DP[s][t]=((S[s]==T[t])+DP[s-1][t])%P;
      }
      else{
        long long a=((S[s]==T[t])*(DP[s-1][t-1]))%P;
        long long b=((DP[s-1][t]-DP[s-1][t-1])%P+DP[s][t-1])%P;
        DP[s][t]=(a+b)%P;
      }
    }
  }
  while(DP[N-1][M-1]<0)DP[N-1][M-1]+=P;
  assert(DP[N-1][M-1]>=0);
  cout<<DP[N-1][M-1];
}

Measured memory_bytes: 31616
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

def main():
    N,K = cin.mapInt()
    ans = 0
    for i in range(1,N + 1):
        ans += (1.0 / Math.nearPow2(math.ceil(K / i)))
    ans /= N
    print(ans)
    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 41708
#include <iostream>
#include <list>
#include <algorithm>
#include <vector>
#include <memory>
#include <cmath>
#include <utility>


std::list<size_t> g_PRIMES;

size_t next_prime() {
    if (g_PRIMES.empty()) {
        g_PRIMES.push_back(2);
        return 2;
    }

    for (size_t i = g_PRIMES.back() + 1; ;i++) {
        for (auto p : g_PRIMES) {
            if (i % p == 0) {
                break;
            }
            if (p * p > i) {
                g_PRIMES.push_back(i);
                return i;
            }
        }
    }

}

void prepare_prime(size_t max) {
    while (next_prime() <= max);
}



int main()
{
    size_t n, p;
    std::cin >> n >> p;
    prepare_prime(std::sqrt(p) + 1);
    std::list<std::pair<size_t, size_t>> factors;
    for (auto prime : g_PRIMES) {
        size_t count = 0;
        if (p < prime) {
            break;
        }
        while (p % prime == 0) {
            p /= prime;
            count++;
        }
        if (count != 0) {
            factors.emplace_back(prime, count);
        }
    }
    if (p > 1) {
        factors.emplace_back(p, 1);
    }

    size_t gcd = 1;
    for (auto pair : factors) {
        size_t m = pair.second / n;
        gcd *= std::pow(pair.first, m);
    }
    std::cout << gcd << std::endl;
    return 0;
}


Measured memory_bytes: 2688
[N,M]=list(map(int,input().split(" ")))
L=[0]*M
R=[0]*M
for i in range(0,M):
    [L[i],R[i]]=list(map(int,input().split(" ")))
lmax=max(L)
rmin=min(R)
print(max(0,rmin-lmax+1))

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

#define loop(i,n) for(int i=1;i<=n;i++)
struct test {
	int i, j, k;
};

vector<test> t;
int p[302];

int main(){
	int a, b, c, n, i, j, k, r;
	while (cin >> a >> b >> c){
		cin >> n;
		t.clear();
		loop(i, a + b + c)p[i] = 2;
		loop(h, n){
			cin >> i >> j >> k >> r;
			if (r == 1){
				p[i] = p[j] = p[k] = 1;
			}
			else{
				t.push_back({ i, j, k });
			}
		}
		for (int h = 0; h < t.size(); h++){
			i = t[h].i; j= t[h].j; k = t[h].k;
			if (p[i] == 1 && p[j] == 1){
				p[k] = 0;
			}
			else if (p[j] == 1 && p[k] == 1){
				p[i] = 0;
			}
			else if (p[k] == 1 && p[i] == 1){
				p[j] = 0;
			}
		}
		loop(i, a + b + c)cout << p[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3008
#include <iostream>
#include <string.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <vector>
#include <map>

using namespace std;

#define cn cout << '\n'
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define ii pair < int, int >
#define iii pair < int, ii >
#define INF 987654321
#define LINF 987654321987654321

int main() {
    cio;
    int N; cin >> N;
    int ar[N];
    map<int, int> m;
    string ans = "YES";
    for (int i =0; i < N; ++i) {
        cin >> ar[i];
        m[ar[i]]++;
        if (m[ar[i]] > 1) {
            ans = "NO";
            break;
        }
    }

    cout << ans << endl;
}


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

int main() {
	// your code goes here
	int n , k ;
	cin>>n>>k;
	
	int a[n];
	for(int i=0;i<n;i++){
	    cin>>a[i];
	}
	
	long dp[n];
	dp[0]=0;
	dp[1]=abs(a[0]-a[1]);
	
	for(int i=2;i<n;i++){
	    dp[i]=INT_MAX;
	    for(int j=i-1;i-j<=k;j--){
	        if(j>=0)
	            dp[i]=min(dp[i],(abs(a[i]-a[j])+dp[j]));
	    }
	}
	
	cout<<dp[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 4768
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  string s; cin >> s;
  ll cnt = 0;
  REP(i, s.size()) if(s[i] == 'o') cnt++;
  cout << 700+100*cnt << endl;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <tuple>
#include <bitset>
#include <random>
#define REP(i,n) for(int i=0;i<n;i++)
#define INF 100000000000007
using namespace std;
using pii=pair<int,int>;

int main(){
    int n,q;
    cin>>n;
    vector<int> count(100000+5,0);
    REP(i,n){
        int a;
        cin>>a;
        count.at(a)++;
    }

    cin>>q;

    int64_t init_ans=0;

    for(int a=1;a<=100000;a++){
        init_ans+=a*count.at(a);
    }

    vector<int64_t> ans(q+1,0);
    ans.at(0)=init_ans;

    REP(i,q){
        int b,c;
        cin>>b>>c;
        ans.at(i+1)=ans.at(i)+(c-b)*count.at(b);
        count.at(c)+=count.at(b);
        count.at(b)=0;
    }
    
    REP(i,q){
        cout<<ans.at(i+1)<<endl;
    }
    

    return 0;
}

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

int debug = 1;

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

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

template <int mod>
struct ModInt {
  int x;
  ModInt(): x(0) {}
  ModInt(long long a) { x = a % mod; if (x < 0) x += mod; }
  ModInt &operator+=(ModInt that) { x = (x + that.x) % mod; return *this; }
  ModInt &operator-=(ModInt that) { x = (x + mod - that.x) % mod; return *this; }
  ModInt &operator*=(ModInt that) { x = (long long) x * that.x % mod; return *this; }
  ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
  ModInt inverse() {
    int a = x, b = mod, u = 1, v = 0;
    while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); }
    return ModInt(u);
  }
  #define op(o, p) ModInt operator o(ModInt that) { return ModInt(*this) p that; }
    op(+, +=) op(-, -=) op(*, *=) op(/, /=)
  #undef op
  friend ostream& operator<<(ostream &os, ModInt m) { return os << m.x; }
};

using mint = ModInt<998244353>;

void solve() {
  int n, s;
  cin >> n >> s;
  vi32 a(n);
  cin >> a;
  vector<mint> dp(s + 1);
  mint ans = 0;
  rep(i, n) {
    dp[0] += 1;
    rrepc(j, s) {
      if (j + a[i] <= s) dp[j + a[i]] += dp[j];
    }
    ans += dp[s];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	//final static long MOD = 1000000007;
	final static long MOD = 998244353;

	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solutionA(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solutionA(String[] args) throws Exception{

		int N = nextInt();
		long ans = 0;
		int bx =0;
		int xa =0;
		int ba =0;
		for(int i=0;i<N;i++) {
			String s = nextString();
			if(s.charAt(0)=='B' && s.charAt(s.length()-1)=='A') {
				ba++;
			}else if(s.charAt(0)=='B') {
				bx++;
			}else if(s.charAt(s.length()-1)=='A') {
				xa++;
			}
			ans+=(s.length()-s.replaceAll("AB","").length())/2;
		}
		//xa ba ba・・・ba bxが作れる場合
		boolean flg=false;
		if(xa!=0&&ba!=0) {
			xa--;
			ba--;
			ans++;
			flg=true;
		}
		if(ba!=0) {
			ans+=ba;
			if(!flg) {
				ans--;
			}
			flg=true;
		}
		if(flg) {
			bx--;
			ans++;
		}
		//xa bx xa bx ・・・を作る
		ans+=Math.min(xa,bx);
		pw.println(ans);

	}
	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



Measured memory_bytes: 32468
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#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 int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  ld PI = acos(-1);
  ld r;
  cin >> r;
  cout << fixed << setprecision(10) << (2.00*PI*r) << endl;


return 0;
}
///....


Measured memory_bytes: 3812
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        201005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}  
void solve(){
    int ans;
    FOR(i,0,5){
        int x;
        cin >> x;
        if(!x)ans = i+1;
    }
    cout << ans;
}

signed main()
{
    showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){   
        solve();
        cout << "\n";
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...
 

Measured memory_bytes: 3608
#include <iostream>

int main() {
    int r, g, b;
    std::cin >> r >> g >> b;
    int rgb = r * 100 + g * 10 + b;
    if (rgb % 4 == 0)   std::cout << "YES" << std::endl;
    else                std::cout << "NO" << std::endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int r = sc.nextInt();
		int d = sc.nextInt();
		int total = sc.nextInt();
		
		for (int i = 0; i < 10; i++) {
			total = (r * total - d);
			System.out.println(total);
		}
	}

		
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 20948
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n, k;
    std::cin >> n >> k;
    std::vector<i64> a(n);
    for (auto &e : a) std::cin >> e;

    std::vector<i64> s { 0 };
    for (auto e : a) s.push_back((s.back() + e + k - 1) % k);

    int j = std::min(k, n + 1);
    std::map<i64, i64> cnt;
    for (int i = 1; i < j; i++) cnt[s[i]]++;

    i64 ret = 0;
    for (int i = 0; i < n; i++) {
        ret += cnt[s[i]];
        cnt[s[i + 1]]--;
        if (j <= n) cnt[s[j++]]++;
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 15856
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int a,b,c,d,ans,f[105];
int main()
{
	scanf("%d%d%d%d",&a,&b,&c,&d);
	for(int i=a;i<=b;i++)f[i]++;
	for(int j=c;j<=d;j++)f[j]++;
	for(int i=0;i<=100;i++)
		if(f[i]==2)ans++;
	if(!ans)printf("0");
	else printf("%d",ans-1);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
 int d[35],i,j,n;
 for (i=0;i<35;i++) d[i]=0; d[0]=1;
 for (i=0;i<31;i++) for (j=1;j<4;j++) d[i+j]+=d[i];
 while(cin >> n) {
	 if (n==0) break;
	 cout << (d[n]/3650+1)-(d[n] % 3650 == 0)  << endl;
 }
 return 0;
 }

Measured memory_bytes: 1160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;


public class Main {
	static int count=0;
	public static void main(String[] args) throws NumberFormatException, IOException {
		//????????????????????????
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

		
		//?????????
		int n = Integer.parseInt(bf.readLine());
		ArrayList<Integer> array=new ArrayList<Integer>();
		String[] list=bf.readLine().split(" ");
		for(int i=0;i<n;i++){
			array.add(Integer.parseInt(list[i]));
		}
		
		
		int q=partition(array, 0, array.size()-1);
		
		for(int i=0;i<array.size();i++){
			if(i!=0){
				System.out.printf(" ");
			}
			if(i==q){
				System.out.printf("[");
			}
			System.out.printf("%d",array.get(i));
			if(i==q){
				System.out.printf("]");
			}

		}
		System.out.println("");
	}
	
	public static int partition(ArrayList<Integer> array,int p,int r){
		int x=array.get(r);
		int i=p-1;
		
		for(int j=p;j<r;j++){
			if(array.get(j)<=x){
				i++;
				int tmp=array.get(i);
				array.set(i, array.get(j));
				array.set(j, tmp);
			}
		}
		
		int tmp=array.get(i+1);
		array.set(i+1, array.get(r));
		array.set(r, tmp);
		
		return i+1;
		
	}

}

Measured memory_bytes: 137456
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <cstdio>

using namespace std;


int main() {
    int N;
    cin >> N;
    vector<int> A(N+1);
    // vector<int> B(N);
    int B;
    for (int i = 0; i < N+1; i++) {
        cin >> A[i];
    }
    uint64_t sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> B;
        if (A[i] < B) {
            sum += A[i];
            B -= A[i];
            A[i] = 0;
        } else {
            sum += B;
            A[i] -= B;
            B = 0;
        }

        if (A[i+1] < B) {
            sum += A[i+1];
            A[i+1] = 0;
        } else {
            sum += B;
            A[i+1] -= B;
        }
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 640
from collections import Counter
n=int(input())
lst=list(map(int,input().split()))
c=Counter(lst)
lst=list(c.values())
ans=0
tmp=0
for i in lst:
    if i%2==1:
        ans+=1
    else:
        tmp+=1
if tmp%2==0:
    ans+=tmp
else:
    ans+=tmp-1
print(ans)

Measured memory_bytes: 99288
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll INF = 1000000009;
ll MOD = 1000000007;

vector<ll> adj[100010];
bool visit[100010];
ll pointer[100010];

void solve(){

    ll n,m;
    cin >> n >> m;
    rep(i,m){
        ll a,b;
        cin >> a >> b;
        a--;
        b--;
        adj[a].eb(b);
        adj[b].eb(a);
    }


    rep(i,n){
        visit[i]=false;
        pointer[i]=-1;
    }

    ll s = 0;
    ll g = adj[0][0];
    visit[s]=true;
    visit[g]=true;
    pointer[s]=g;
    bool b = true;
    //始点か終点が条件を満たしていないならtrue
    while(b){
        b=false;

        //cout << "s:" << s << " g:" << g << endl;

        for(auto e:adj[s]){
            if(visit[e]==false){
                visit[e]=true;
                pointer[e]=s;
                s=e;
                break;
            }
        }

        for(auto e:adj[g]){
            if(visit[e]==false){
                visit[e]=true;
                pointer[g]=e;
                g=e;
                break;
            }
        }

        for(auto e:adj[s]){
            if(visit[e]==false) b=true;
        }
        for(auto e:adj[g]){
            if(visit[e]==false) b=true;
        }
    }

    ll count = 1;
    ll p = s;
    //cout << p+1 << " ";
    while(true){
        if(pointer[p]==-1) break;
        //cout << pointer[p]+1 << " ";
        p = pointer[p];
        count++;
    }

    cout << count << endl;
    p = s;
    cout << p+1 << " ";
    while(true){
        if(pointer[p]==-1) break;
        cout << pointer[p]+1 << " ";
        p = pointer[p];
        count++;
    }
    

}

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


Measured memory_bytes: 7168
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
typedef long long LL;

int main() {
  int h, w;
  cin >> h >> w;
  char a[h][w];
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      cin >> a[i][j];
    }
  }
  for (int i=0; i<h; i++) {
    bool flg=true;
    for (int j=0; j<w; j++) {
      if (a[i][j] == '.') flg = flg && true;
      else flg = flg && false;
    }
    if (flg) {
      for (int j=0; j<w; j++) {
        a[i][j] = '-';
      }
    }
  }

  for (int j=0; j<w; j++) {
    bool flg=true;
    for (int i=0; i<h; i++) {
      if (a[i][j] == '.' || a[i][j] == '-') flg = flg && true;
      else flg = flg && false;
    }
    if (flg) {
      for (int i=0; i<h; i++) {
        a[i][j] = '-';
      }
    }
  }

  for (int i=0; i<h; i++) {
    bool isout=false;
    for (int j=0; j<w; j++) {
      if (a[i][j] != '-') {
        cout << a[i][j];
        isout = true;
      }
    }
    if (isout) cout << endl;
  }

}


Measured memory_bytes: 256