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

typedef long long ll;
typedef long double ld;


#define CLOCK			 cerr << "\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
#define debug(a)         cerr<<#a<<": "<<a<<endl;
#define pb               push_back
#define all(x)           (x).begin(),(x).end()
#define rall(x)          (x).rbegin(),(x).rend()
#define ps               " "
#define nln              "\n"
#define ff               first
#define ss               second
#define vi               vector<int>
#define vll              vector<ll>
#define vstr             vector<string>
#define vc               vector<char>
#define PII              pair<int,int>
#define PLL              pair<ll,ll>
#define PI               acos(-1)
#define sq(x)            x*x
#define forr(i,a,b)      for(int i=(int)a;i<(int)b;i++)
#define forn(i,a,b)      for(int i=(int)a;i>(int)b;i--)
#define mod              1000000007
#define inf              9223372036854775807

///knight moves:
///int dx[]= {-2,-1,1,2,2,1,-1,-2};
///int dy[]= {1,2,2,1,-1,-2,-2,-1};

void fileio()
{
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

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

bool is_prime(ll n)
{
	if(n<2) return false;
	if(n==2) return true;
	
	if(n%2==0) return false;
	
	for(int i=3;i<sqrt(n+1)+1;i+=2)
	{
		if(n%i==0) return false;
	}
	return true;
}


int solve()
{
	ll a,b;
	cin>>a>>b;
	ll ans=__gcd(a,b);

	vll v;
	
	forr(i,1,sqrt(ans+1)+1)
	{
		if(ans%i==0)
		{
			v.pb((ll)i);
			if(i*i!=ans) v.pb(ans/i);
		}
	}
	
	/*forr(i,0,v.size()) cout<<v[i]<<ps;
	cout<<nln; */
	
	int tot=1;
	
	forr(i,0,v.size())
	{
		if(is_prime(v[i])) tot++;
	}
	
	cout<<tot;

	
	
	return 0;
}
	

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


Measured memory_bytes: 384
import sys
import operator

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

a = [int(x) for x in sys.stdin.readline().rstrip().split()]
a.sort()

cards = [[int(x) for x in sys.stdin.readline().rstrip().split()] for _ in range(m)]
cards.sort(key=operator.itemgetter(1), reverse=True)

a_idx = 0
a_len = len(a)

for b, c in cards:
    if a_idx == a_len:
        break
    for b_idx in range(b):
        if a_idx == a_len or c <= a[a_idx]:
            break
        else:
            a[a_idx] = c
            a_idx += 1

print(sum(a))


Measured memory_bytes: 27000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll N;
    cin>>N;
    ll A[N],B[N],C[N];
    rep(0,i,N)cin>>A[i];
    rep(0,i,N)cin>>B[i];
    rep(0,i,N-1)cin>>C[i];
    ll ans=0;
    rep(0,i,N){
        ans+=B[A[i]-1];
        if(i!=N-1 && A[i]+1==A[i+1])ans+=C[A[i]-1];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 764
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()

    println(abc152a(n, m))
}

fun abc152a(n: Int, m: Int): String {
    if (n == m) return "Yes"
    return "No"
}


Measured memory_bytes: 29724
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<chrono>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define vint(a,n) vint a(n); rep(i, n) cin >> a[i];
#define vll(a,n) vll a(n); rep(i, n) cin >> a[i];
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
// #define MOD (998244353)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    string s; cin >> s;
    int n = s.size();
    vint a(2019);
    vint md(n);
    md[0] = 1;
    FOR(i, 1, n){
        md[i] = md[i-1]*10;
        md[i] %= 2019;
    }
    a[0]++;
    // prvec(md);
    reverse(ALL(s));

    ll t = 0;
    rep(i, n){
        // pr(t);
        t += (s[i]-'0') * md[i];
        t %= 2019;
        a[t]++;
    }

    ll ans = 0;
    rep(i, 2019){
        ans += a[i]*(a[i]-1)/2;
    }
    pr(ans);
    return 0;}

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

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < 19; i++){
    if(s.at(i) == ','){
     s.at(i) = ' '; 
    }
  }
  cout << s << endl;
}


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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
int n;
ll mod = 998244353;
VLL a(300), sum(300);

ll dp1[301][90010];
ll dp2[301][90010];
int main(){

  cin >> n;
  rep(i,n){
    cin >> a[i];
    sum[i] = a[i];
  }

  rep(i,n-1) sum[i+1] += sum[i];

  //A
  dp1[0][0] = 1;
  dp2[0][0] = 1;
  rep(i,n){
    rep(j,90010){
      //とる
      if(j+a[i] < 90010){
        (dp1[i+1][j+a[i]] += dp1[i][j]) %= mod;
        (dp2[i+1][j+a[i]] += dp2[i][j]) %= mod;

      }
      //取らない
      (dp1[i+1][j] += dp1[i][j]*2) %= mod;
      (dp2[i+1][j] += dp2[i][j]) %= mod;
    }
  }
  ll ans = 1;
  //all
  rep(i,n) ans = ans * 3 % mod;
  //minus 3*A
  rep(i,90010){
    if( i * 2 >= sum[n-1]) (ans -= 3*dp1[n][i]) %= mod;
  }
  // add A^B
  if(sum[n-1] % 2 == 0){
    (ans += 3 * dp2[n][sum[n-1]/2]) %= mod;
  }
  if(ans < 0 ) ans += mod;

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


Measured memory_bytes: 422912
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using Graph = vector< vector<int> >;

ll f(ll n){
	if(n%2 == 0) return (n/2)%2 xor n;
	else return ((n+1)/2)%2;
}

int main(){
	ll A,B; cin >> A >> B;
	ll ans = f(A-1) xor f(B);
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Pair[] array = new Pair[m];
        for(int i = 0; i < m; i++) {
            array[i] = new Pair(sc.nextInt(), sc.nextInt());
        }
        Arrays.sort(array, (p1, p2) -> p1.b - p2.b);
        int count = 0;
        for(int i = 0; i < m; i++) {
            int b = array[i].b;
            int j = i;
            while(j < m && b > array[j].a) j++;
            count++;
            i = j - 1;
        }
        System.out.println(count);
    }

    private static class Pair{
        int a;
        int b;
        Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }
    }
}


Measured memory_bytes: 94708
#include<bits/stdc++.h>
#define inf 1<<29
#define MAX 200010
using namespace std;

int n;
double dp[21][MAX],a[21];

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

  for(int i=0;i<n;i++)for(int j=0;j<MAX;j++)dp[i][j]=inf;
  for(int i=1;i<MAX;i++)dp[0][i]=abs(a[0]-i)/a[0];

  for(int i=1;i<n;i++){
    for(int j=1;j<MAX;j++){
      for(int k=j;k<MAX;k+=j){
	dp[i][k]=min(dp[i][k],max(dp[i-1][j],abs(a[i]-k)/a[i]));
      }
    }
  }
  double ans=inf;
  for(int i=1;i<MAX;i++)ans=min(ans,dp[n-1][i]);
  printf("%.10f\n",ans);
  return 0;
}

Measured memory_bytes: 34000
#include<iostream>
#include<vector>
using namespace std;
int n,a,b,q,k,x,y,j,visit[100010]={},cnt[100010]={};
long c,dis[100010];
vector<vector<int>> v(100010);
vector<vector<int>> d(100010);

int dfs(int p){
  visit[p]=1;
  int i;
  for(i=0;i<cnt[p];i++){
    //cout<<p<<" "<<cnt[p]<<endl;
    if(visit[v[p][i]]==0){
      dis[v[p][i]]=dis[p]+d[p][i];
      dfs(v[p][i]);
    }
  }   
}

int main(){
  int i;
  cin >> n;
  for(i=0;i<n-1;i++){
    cin >> a >> b >> c;
    v[a].push_back(b);
    v[b].push_back(a);
    cnt[a]++;
    cnt[b]++;
    d[a].push_back(c);
    d[b].push_back(c);
  }
  cin >> q >> k;
  dis[k]=0;
  dfs(k);
  for(i=0;i<q;i++){
    cin >> x >> y;
    cout <<dis[x]+dis[y]<<endl;
  }
}

Measured memory_bytes: 18944
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int n,z;
  cin >>n>>z;
 
  int gu=0;
  vector<int> p(n);
  rep(i,n){
  cin>>p[i]; 
    if(p[i]%2==0) gu++;
  }
    
  int ki=n-gu; 
    
  ll ans=1;
  if(ki>=1) {
    rep(i,ki-1){
    ans*=2;
    }
  }
  if(ki==0 && z==0) ans=1;
  if(ki==0 && z==1) ans=0;
  
  rep(i,gu){
  ans*=2;
  }
  
  cout << ans << endl;
  
}

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

int main() { 
    string s;
    cin >> s;
    
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == '1') {
            ans++;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            int[,,] dp = new int[11, 331, 1 << 10];

            MakeDP(dp);

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                string[] temp = input.Split(' ');
                int n = int.Parse(temp[0]);
                int s = int.Parse(temp[1]);

                if (s > 330)
                {
                    sb.AppendLine("0");
                    continue;
                }

                int sum = 0;

                for (int i = 0; i < 1 << 10; i++)
                {
                    sum += dp[n, s, i];
                }
                sb.AppendLine(sum.ToString());
            }
            Console.Write(sb);
        }

        static void MakeDP(int[,,] dp)
        {
            dp[0, 0, 0] = 1;

            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 331; j++)
                {
                    for (int k = 0; k < 1 << 10; k++)
                    {
                        if (dp[i, j, k] == 0) continue;

                        for (int l = 0; l < 10; l++)
                        {
                            if ((~k & (1 << l)) == 0) continue;

                            dp[i + 1, j + (i + 1) * l, k | (1 << l)] += dp[i, j, k];
                        }
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 23848
N = int(input())
lst = list(map(int, input().split()))
bs = [0]*N
stock = 0
money = 1000

for i in range(1, N):
    if lst[i-1] < lst[i]:
        bs[i-1] = 1
        if i > 1 and bs[i-2] != 0:
            bs[i-1] = -1

for i in range(N):
    if bs[i] == 1:
        stock = money // lst[i]
        money = money % lst[i]
    elif bs[i] == 0 and stock > 0:
        money += stock * lst[i]
        stock = 0
    elif bs[i] == -1 and i == N-1 and stock > 0:
        money += stock * lst[i]
        stock = 0

print(money)

Measured memory_bytes: 9236
import Data.List
main=do
 getLine
 xd<-sortOn(negate.fst).map((\[x,d]->(x,d)).map read.words).lines<$>getContents
 print$f 1[10^10][1]xd
f r ws vs[]=r
f r(w:ws)(v:vs)((x,d):xd)
 |w<x+d=f r ws vs((x,d):xd)
 |otherwise=f nr(x:w:ws)(nr:v:vs)xd where nr=(r+v)`mod`998244353

Measured memory_bytes: 197188
#include <cstdio>
#include <algorithm>
using namespace std;

int main()  {

    double w, h;
    int id;
    while(scanf("%d,%lf,%lf", &id, &w, &h) != EOF) {
        if (w/(h*h) >= 25) printf("%d\n", id);
    }
    return 0;
}



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

int main(){

  int n,a,d,m,k;
  cin >> n;
  cin >> a >> d;
  cin >> m;
  vector<int> x(m),y(m),z(m);
  for(int i=0; i<m; i++){
    cin >> x[i] >> y[i] >> z[i];
    y[i]--;
    z[i]--;
  }
  cin >> k;
  k--;
  vector<int> com;
  for(int i=m-1; i>=0; i--){
    if(x[i]==0 && (y[i]<=k && k<=z[i])){
      k = y[i]+z[i]-k;
      //cout << "1 " << i << endl;;
    }else{
      if(y[i]<=k && k<=z[i]){
        com.push_back(x[i]);
      }
    }
  }
  //cout << k << endl;
  int num = a+d*k;
  //cout << com.size() << endl;
  for(int i=com.size()-1;i>=0;i--){
      if(com[i]==1){
          num++;
      }else if(com[i]==2){
          num/=2;
      }
  }
  
  cout << num << endl;

  return 0;
}

Measured memory_bytes: 5236
import numpy as np

N, K = map(int, input().split())
A = tuple(map(int, input().split()))

MOD = 10 ** 9 + 7

dp = np.zeros(K + 1, dtype=np.int64)
dp[0] = 1
for i in range(1, N + 1):
    S = np.cumsum(dp) % MOD
    dp[:A[i - 1] + 1] = S[:A[i - 1] + 1] % MOD
    dp[A[i - 1] + 1:K + 1] = (S[A[i - 1] + 1:K + 1] - S[:K - A[i - 1]]) % MOD
print(dp[K])


Measured memory_bytes: 21024
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n;
  string s;
  int k;
  cin>>n>>s>>k;
  k--;
  char c=s[k];
  rep(i,n){
    if(s[i]==c) cout<<c;
    else cout<<'*';
  }
  cout<<endl;


}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
      
		Scanner sc = new Scanner (System.in);
		int monster = sc.nextInt();
		int times = sc.nextInt();
		long physical[] = new long[monster];
		long sumPhysical = 0;

		for(int i=0 ; i<monster ; i++) {
			physical[i] = sc.nextInt();
		}

		Arrays.sort(physical);

		for(int i=0 ; i<monster-times ; i++) {
			sumPhysical += physical[i];
		}

		System.out.println(sumPhysical);
		sc.close();
	}
}

Measured memory_bytes: 91360
#include<bits/stdc++.h>
using namespace std;
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forp(i,a,b) for (int i = (a); i <(b); i++)
#define forn(i,a,b) for (int i = (a); i >(b); i--)
#define mod 1000000007
#define multiple_testcases_t int t;cin>>t;while(t--){solve();}
#define single_testcase_t solve();
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;


// <----- Actual solve() function to print output -----> //

void solve()
{
   ll n,m,k=0,w;
   string s;
   cin>>s;
   forp(i,0,(int)s.size())
   {
     k+=s[i]-48;
   }
   if(k%9==0)
   cout<<"Yes";
   else 
   cout<<"No";

   //cout<<m*w<<" ";
   //cout<<"\n";      //if t>1 uncomment this
}

// MAIN function --------------------------------------------------------------------------//
int main()
{
    fast_io
//  if taking input from input.txt then uncomment below line
//    freopen("input.txt", "r", stdin);
//  if writing output to output.txt then uncomment below line
//    freopen("output.txt", "w", stdout);

    single_testcase_t   //Uncomment this if only single testcase & single answer to print
  //multiple_testcases_t  //Uncomment this if t>1(t is given in question)(multiple testcases)
return 0;
}





Measured memory_bytes: 3740
open System
open System.Collections.Generic

module InputUtility =
    let InputTokens = new Queue<string>()

    let EnsureInput () =
        if InputTokens.Count = 0 then
            let input = Console.ReadLine ()
            let s = input.Split ([|' '|], StringSplitOptions.RemoveEmptyEntries)
            if s.Length > 0 then
                for x in s do InputTokens.Enqueue(x)
                true
            else false
        else true

    let rec ReadNext () =
        if EnsureInput () then InputTokens.Dequeue ()
        else ReadNext ()

    let ReadNextInt () = ReadNext () |> int

    let Read2Int () = ReadNextInt (), ReadNextInt ()

    let ReadListOf f n =
        let rec loop acc = function
            | 0 -> List.rev acc
            | c -> loop ((ReadNext () |> f) :: acc) (c-1)
        loop [] n

    let MultipleCaseWithId f =
        let caseNum = ReadNextInt ()
        let rec loop index =
            if index = caseNum then ()
            else
                f index
                loop (index + 1)
        loop 0

    let MultipleCase f = MultipleCaseWithId (fun _ -> f ())

    let ReadList n =
        let rec loop acc = function
            | 0 -> List.rev acc
            | c -> loop (ReadNext () :: acc) (c-1)
        loop [] n

open InputUtility

module ABC064 =
    let private ``Traveling AtCoDeer Problem`` () = 
        ReadNextInt ()
        |> ReadListOf int
        |> Seq.fold (fun (ur, dr) c -> max ur c, min dr c) (0, 1000)
        |> (fun (u, d) -> u - d |> printfn "%d")

    let Entry = ``Traveling AtCoDeer Problem``

ABC064.Entry ()

Measured memory_bytes: 12120
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long X = sc.nextInt();
		long M = sc.nextInt();
		List<Integer> list = new ArrayList<Integer> ();
		int m[] = new int[(int)M];
		long sum=0;
		long i=0;
		for (i=0;i<N;i++) {
			m[(int)X] = (int)i+1;
			list.add((int)X);
			sum =sum +X;
			X = (X*X)%M;
			if (m[(int)X]>0 &&i<N-1) {
				break;
			}
		}
		if (i==N) {
			System.out.println(sum);
			return ;
		}
		long temp =0;
		int t = m[(int)X];
		for (t =t-1;t<list.size();t++) {
			temp += list.get(t);
		}
		sum = ((N-list.size())/(list.size()-m[(int)X]+1))*temp+sum ;
		for (int j=0;j<((N-list.size())%(list.size()-m[(int)X]+1));j++) {
			sum +=list.get(j+m[(int)X]-1);
		}
		System.out.println(sum );
	}
}

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

typedef long long ll;
typedef pair<ll, ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;

const ll MX = 1005;
const ll MOD = 1000000007;

#define F0R(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define sz(x) (ll)x.size()
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define f first
#define s second

void setIO(string name) {
	ios_base::sync_with_stdio(0); cin.tie(0);
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}

ll N, M;
char grid[MX][MX];
ll dp[MX][MX];

ll solve(ll i, ll j) {
	if (grid[i][j] == '#') return 0;
	if (i == N - 1 && j == M - 1) return 1;

	if (dp[i][j] != -1) return dp[i][j];  


	ll ret = 0;
	if (i + 1 < N) {
		ret = (ret % MOD + solve(i + 1, j) % MOD + MOD) % MOD;
	}
	if (j + 1 < M) {
		ret = (ret % MOD + solve(i, j + 1) % MOD + MOD) % MOD;
	}

	return dp[i][j] = ret;
} 

int main() {
	memset(dp, -1, sizeof dp);
	cin >> N >> M;
	F0R(i, N) F0R(j, M) cin >> grid[i][j];


	cout << (solve(0, 0) + MOD) % MOD << "\n";
}

// watch out for ll overflow

Measured memory_bytes: 9216
#include<stdio.h>
int w,h;
int R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int f(int a,int b){return (a==0||a==w||b==0||b==h)?1:0;}
int main(){
  int n,i,j,p[100010][4],r,d[200010],e[100010];
  scanf("%d %d %d",&w,&h,&n);
  for(i=0;i<n;i++){
    scanf("%d %d %d %d",&p[i][0],&p[i][1],&p[i][2],&p[i][3]);
    //printf("%d %d\n",f(p[i][0],p[i][1]),f(p[i][2],p[i][3]));
  }
  for(j=r=0;j<4;j++){
    for(i=0;i<n;i++){
      if(f(p[i][0],p[i][1])*f(p[i][2],p[i][3])==0)continue;
      if(j==0&&p[i][0]==0&&p[i][1]!=0)e[R]=i,hin(  p[i][1]);
      if(j==0&&p[i][2]==0&&p[i][3]!=0)e[R]=i,hin(  p[i][3]);
      if(j==1&&p[i][1]==h&&p[i][0]!=0)e[R]=i,hin(  p[i][0]);
      if(j==1&&p[i][3]==h&&p[i][2]!=0)e[R]=i,hin(  p[i][2]);
      if(j==2&&p[i][0]==w&&p[i][1]!=h)e[R]=i,hin(h-p[i][1]);
      if(j==2&&p[i][2]==w&&p[i][3]!=h)e[R]=i,hin(h-p[i][3]);
      if(j==3&&p[i][1]==0&&p[i][0]!=w)e[R]=i,hin(w-p[i][0]);
      if(j==3&&p[i][3]==0&&p[i][2]!=w)e[R]=i,hin(w-p[i][2]);
    }
    while(C-1){
      d[r++]=e[hout()];//printf("%d\n",d[r-1]);
      if(r>1&&d[r-1]==d[r-2])r-=2;
    }
    R=C=1;
  }
  printf("%s\n",r?"NO":"YES");
  return 0;
}
  
  


Measured memory_bytes: 5248
#include <iostream>
#include <vector>
#include <string>
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <deque>
#include <tuple>
#include <unordered_set>
#include <array>
#include <string>

using namespace std;
#define ll long long
#define ar array

int main()
{   
	int n, d;
	cin >> n >> d;
	int count=0;
	for (int i=0; i<n; i++) {
		ll a, b;
		cin >> a >> b;
		if (sqrt(a*a+b*b)<=d) {
			count++;
		}
	}
	cout << count;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int tmp = max(a,max(b,c));
    int ans = a+b+c-tmp;
    rep(i,k) tmp *= 2;
    cout << ans + tmp << endl;
}


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

int main(){
	int N;
	cin >> N;
	int x, y, count = 1;
	cin >> x;
	for (int i = 1 ; i < N ; i++){
		cin >> y;
		if (y >= x){
			count++;
			x = y;
		}
	}
	cout << count;
	return 0;
}



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

using namespace std;

typedef long long ll;

const int N = 100100;

vector<pair<int, int>> g[N];
int used[N], x[N];

void dfs(int v) {
    used[v] = 1;
    for (auto u : g[v]) {
        if (used[u.first]) {
            if (x[u.first] - x[v] != u.second) {
                cout << "No";
                exit(0);
            }
        } else {
            x[u.first] = x[v] + u.second;
            dfs(u.first);
        }
    }
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    while (m--) {
        int l, r, d;
        cin >> l >> r >> d;
        g[l].push_back({r, d});
        g[r].push_back({l, -d});
    }
    for (int i = 1; i <= n; ++i) {
        x[i] = LONG_MAX;
    }
    for (int i = 1; i <= n; ++i) {
        if (!used[i]) {
            x[i] = 0;
            dfs(i);
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 11520
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

int main()
{
    i64 n;
    scanf("%lld", &n);

    i64 h = 1;
    
    while (h * (h + 1) / 2 < n)
        h++;

    // 1~h로 n만들기

    vector<i64> solve;

    while (n > 0)
    {
        if (h > n)
            solve.push_back(n);
        else
            solve.push_back(h);

        n -= h;
        h--;
    }

    for (auto& s : solve)
        printf("%lld\n", s);

    return 0;
}

Measured memory_bytes: 384
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
ans=0
for i in b:
    he=-1
    ta=n
    while ta-he>1:
        mid=(he+ta)//2
        if i>a[mid]:
            he=mid
        else:
            ta=mid
    x=he+1

    he_=-1
    ta_=n
    while ta_-he_>1:
        mid_=(he_+ta_)//2
        if i>=c[mid_]:
            he_=mid_
        else:
            ta_=mid_
    y=n-ta_
    ans+=x*y
print(ans)

Measured memory_bytes: 24180
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[][] arr = new int[n][3];
		for (int i = 0; i < n; ++i) {
			arr[i][0] = scan.nextInt();
			arr[i][1] = scan.nextInt();
			arr[i][2] = scan.nextInt();
		}
		int[][] dp = new int[n][3];
		dp[0][0] = arr[0][0];
		dp[0][1] = arr[0][1];
		dp[0][2] = arr[0][2];

		for (int i = 1; i < n; ++i) {
			for (int j = 0; j < 3; ++j) {
				int max = 0;
				for (int k = 0; k < 3; ++k) {
					if (k != j) {
						max = Math.max(max, dp[i - 1][k] + arr[i][j]);
					}
				}
				dp[i][j] = max;
			}
		}
		int ans = 0;
		for (int i = 0; i < 3; i++) {
			ans = Math.max(ans, dp[n-1][i]);
		}
		System.out.println(ans);
	}
}


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

#define int long long

signed main(){
    int l, r;
    cin >> l >> r;

    if(r-l > 2019){
        cout << 0 << endl;
    }else{

        int ans = INT_MAX;
        for(int i = l;i <= r;i++){
            for(int j = i+1;j <= r;j++){
                ans = min(ans, ((i%2019) * (j%2019)) % 2019);
            }
        }
        cout << ans << endl;
    }

    return 0;
}




Measured memory_bytes: 256
/* いもす法 */
#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;
vector<int> s(100);

ll kaijo(int x) {
    if(x == 0) {
        return 1;
    } else {
        ll tmp = 1;
        REP(i, x) {
            tmp *= 2;
        }   
        return tmp;
    }
}

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

    if(n == 0) {
        cout << "0" << endl;
        return 0;
    }

    ll now = 0;

    REP(i, 100) {
        ll tmp = kaijo(i);
        //cout << tmp << endl;
        if((n - now) % (tmp*2) != 0) {
            s[i] = 1;
            //cout << "i = " << i << endl;
            if(i % 2 == 0) {
                now += tmp;
            } else {
                now -= tmp;
            }
        }
        if(now == n) break;
    }

    bool bHantei = false;

    REP_REV(i, 100) {
        if(s[i] == 1) {
            bHantei = true;
            cout << s[i];
        } else {
            if(bHantei) cout << s[i];
        }
    }

    return 0;
}


Measured memory_bytes: 256
# 4で1リットル
q, h, s, d = map(int, input().split())
n = int(input())
q = q * 4
h = h * 2

if n >= 2:
  if n % 2 == 0:
    print(min(q * 2, h * 2, s * 2, d) * (n//2))
  else:
    print(min(q * 2, h * 2, s * 2, d) * (n//2) + min(q, h, s))
else:
  print(min(q, h, s))

Measured memory_bytes: 3064
N,M=list(map(int,input().split()))
src=list(map(int,input().split()))
w=[]
for e in range(N):
  w.append(1)
q=[]
for m in range(M):
  q.append(list(map(int,input().split())))
#q=list(set(q))
for a,b in q:
  if src[a-1]<src[b-1]:
    w[a-1] = 0
  elif src[b-1]<src[a-1]:
    w[b-1] = 0
  elif src[b-1]==src[a-1]:
    w[a-1]=0
    w[b-1]=0
ans = 0
for o in w:
  if o == 1:
    ans+=1
print(ans)

Measured memory_bytes: 31996
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

signed main() {
    int h,w;cin>>h>>w;
    if (h==1 || w==1) {
        cout << 1 << endl;
        return 0;
    }

    int v1 = divceil(w, 2);
    int v2 = w/2;
    dump(v1, v2);


    int y1 = divceil(h, 2);
    int y2 = h/2;
    int ans = 0;
    ans = y1*v1 + y2*v2;

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


Measured memory_bytes: 384
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter,mul
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left,bisect_right
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time
#from functools import lru_cache,reduce
#from math import factorial,hypot
#import sys
#from fractions import gcd
setrecursionlimit(10**6+1)
input=stdin.readline

k,n=map(int,input().split())
a=[int(i) for i in input().split()]
a=a+[k+a[0]]
absdis=[]
for i in range(n):
    absdis.append(a[i+1]-a[i])
#print(absdis)
print(sum(absdis)-max(absdis))

Measured memory_bytes: 24908
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }
        public void Solve(ConsoleInput cin)
        {
            var _S = cin.Read;
            var S = _S.ToCharArray();
            var n = S.Length;
            var i = 1;

            while (true)
            {
                if ((n - i) % 2 == 1)
                {
                    i++;
                    continue;
                }
                var s1 = S.Take((n - i) / 2).ToArray();
                var s2 = S.Skip((n - i) / 2).Take((n - i) / 2).ToArray();
                if (s1.SequenceEqual(s2))
                {
                    var ans = n - i;
                    WriteLine(ans);
                    return;
                }
                i++;
            }
        }

        public long C(long n, long r)
        {
            long[,] Pascal = new long[n + 1, n + 1];
            Pascal[0, 0] = 1;
            for (long i = 1; i <= n; i++)
            {
                Pascal[i, 0] = 1;
                Pascal[i, i] = 1;
                for (long j = 1; j < n; j++)
                {
                    Pascal[i, j] = Pascal[i - 1, j] + Pascal[i - 1, j - 1];
                }
            }
            return Pascal[n, r];
        }

        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 13280
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define F first
#define S second
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()
int tri(int n){
    return n*(n+1)/2;
}
int gcd2(int a,int b){
    if(a%b==0)return b;
    return gcd2(b,a%b);
}
int gcd3(int a,int b,int c){
    return gcd2(gcd2(a,b),c);
}
signed main(){
    int k;
    int ans=0;
    cin>>k;
    for(int a=1;a<=k;a++){
        for(int b=1;b<=a;b++){
            for(int c=1;c<=b;c++){
                int x=gcd3(a,b,c);
                if(a!=b&&b!=c&&c!=a)x*=6;
                else if(a==b&&b==c)x*=1;
                else x*=3;
                ans+=x;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include <cstdlib>

using namespace std;

int main(){
  int n;
  string s,t;
  cin >> n >> s>>t;
  for(int i=0;i<n;i++){
    cout<<s[i]<<t[i];
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define mod 1000000007
#define pb push_back
#define csl ios_base::sync_with_stdio(false); cin.tie(NULL)
#define reps(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) for(int i=0;i<int(b);i++)
#define first ff
#define second ss
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
typedef vector<int> vi;
typedef pair<ll,ll> pll;
#define M 998244353
int main()
{
    csl;
    int n;
    cin >> n;
    int a[n-1];
    map<int,int> m;
    rep(i,n-1)
    {
        cin >> a[i];
        m[a[i]]++;
    }

    reps(i,1,n+1)
    {
        cout << m[i] << endl;
    }

}



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

struct node{
  int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur = nil->next;
  while( cur != nil && cur->key != key ){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if ( t == nil ) return;
  deleteNode(t);
}

void delete(int key){
  NodePointer t = listSearch(key);
  if ( t == nil ) return;
  deleteNode(t);
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if(!( 0 <= key && key <= 2000000000)){printf("error") ;}
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
    if ( size > 1000000 ) { printf("error"); }
  }

  
  if(!( np+nd <= 2000000)){printf("error") ;}
  if(!( nd <= 20)){printf("error") ;}
  printList();


  return 0;
}

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

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	LL r, d, x; cin >> r >> d >> x;

	for (int i = 0; i < 10; i++) {
		x = r * x - d;
		cout << x << endl;
	}

	return 0;
}

Measured memory_bytes: 256
//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
//change less to less_equal for non distinct pbds, but erase will bug

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n,k;
int arr[300005];

struct node{
	int s,e,m;
	int val=0;
	node *l,*r;
	
	node (int _s,int _e){
		s=_s,e=_e,m=s+e>>1;
		
		if (s!=e){
			l=new node(s,m);
			r=new node(m+1,e);
		}
	}
	
	void update(int i,int j){
		val=max(val,j);
		
		if (s==e) return;
		else if (i<=m) l->update(i,j);
		else r->update(i,j);
	}
	
	int query(int i,int j){
		if (s==i && e==j) return val;
		else if (j<=m) return l->query(i,j);
		else if (m<i) return r->query(i,j);
		else return max(l->query(i,m),r->query(m+1,j));
	}
} *root=new node(0,300005);



int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin.exceptions(ios::badbit | ios::failbit);
	
	cin>>n>>k;
	rep(x,0,n) cin>>arr[x];
	
	
	rep(x,0,n){
		int val=root->query(max(0,arr[x]-k),min(300005,arr[x]+k));
		
		root->update(arr[x],val+1);
	}
	
	cout<<root->val<<endl;
}


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

int main() {
  int n, u, v;
  cin >> n >> u >> v;
  u--;
  v--;
  vector <vector <int> > edge(n);
  vector <int> dig(n, 0);
  for (int i = 0; i < n - 1; i++) {
	  int a, b;
	  cin >> a >> b;
	  a--;
	  b--;
	  edge[a].push_back(b);
	  edge[b].push_back(a);
	  dig[a]++;
	  dig[b]++;
	}
  vector <int> du(n, -1);
  vector <int> dv(n, -1);
  priority_queue <pair <int, int>, vector <pair <int, int> >, greater <pair <int, int> > > que;
  que.push(make_pair(0, u));
  while (!que.empty()) {
	  int s = que.top().second;
	  int d = que.top().first;
	  que.pop();
	  if (du[s] >= 0) {
		  continue;
		}
	  du[s] = d;
	  for (auto itr = edge[s].begin(); itr != edge[s].end(); itr++) {
		  if (du[*itr] == -1) {
			  que.push(make_pair(d + 1, *itr));
			}
		}
	}
  que.push(make_pair(0, v));
  while (!que.empty()) {
	  int s = que.top().second;
	  int d = que.top().first;
	  que.pop();
	  if (dv[s] >= 0) {
		  continue;
		}
	  dv[s] = d;
	  for (auto itr = edge[s].begin(); itr != edge[s].end(); itr++) {
		  if (dv[*itr] == -1) {
			  que.push(make_pair(d + 1, *itr));
			}
		}
	}
  int ans = 0;
  for (int i = 0; i < n; i++) {
	  if (dig[i] > 1) {
		  continue;
		}
	  if (du[i] > dv[i]) {
		  continue;
		}
	  ans = max(dv[i] - 1, ans);
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7296
//no one wants to die,yet death is the destination we all share 
// don't think you are,know you are!!

#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll fr[3*100002],fc[3*100002];
int main(){
	ll h,w,m;
	cin>>h>>w>>m;
	vector<pair<ll,ll>> v(m);
	forn(i,m){
		cin>>v[i].fi>>v[i].se;
		fr[v[i].fi]++;
		fc[v[i].se]++;
	}
	ll mr=0,frr=0,mc=0,fcc=0;
	for1(i,h){
		if(fr[i]>mr){
			mr=fr[i];
			frr=1;
		}
		else if(fr[i]==mr) frr++;
	}
	for1(i,w){
		if(fc[i]>mc){
			mc=fc[i];
			fcc=1;
		}
		else if(fc[i]==mc) fcc++;
	}
	ll cnt=0;
	forn(i,m){
		if((fr[v[i].fi]==mr)&&(fc[v[i].se]==mc)) cnt++;
	}
	//cout<<mr<<" "<<mc<<" "<<frr<<" "<<fcc<<" "<<cnt<<" ";
	if(cnt==fcc*frr) cout<<(mr+mc-1);
	else cout<<(mr+mc);
}

Measured memory_bytes: 12716
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




ll dp[3005][3005];

int main() {
    string s, t;
    cin >> s >> t;
    ll n = s.size(), m = t.size();
    for(ll i = 1; i <= n; i++){
        for(ll j = 1; j <= m; j++){
            if(s[i - 1] == t[j - 1]){
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            else{
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }
    
    ll x = n, y = m;
    string ans(dp[n][m] + 1, ' ');
    while(x > 0 && y > 0 && dp[x][y] > 0){
        while(dp[x - 1][y] == dp[x][y]) x--;
        while(dp[x][y - 1] == dp[x][y]) y--;
        ans[dp[x][y]] = s[x - 1];
        x--; y--;
    }
    cout << ans.substr(1, dp[n][m]) << endl;
}

Measured memory_bytes: 70656
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let n = read::<usize>();
    let mut p = vec![];
    for _ in 0..n {
        p.push(read::<u32>());
    }
    p.sort();
    let max = p.pop().unwrap();
    let ans = max / 2 + p.iter().sum::<u32>();
    println!("{}", ans);
}


Measured memory_bytes: 4352