akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int dp[110][100010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, W;
    cin >> N >> W;
    int w[110], v[110];
    rep(i, N) cin >> w[i] >> v[i];
    int ans = 0;
    rep(i, N) {
        RREP(j, W, 0) {
            dp[i + 1][j] = dp[i][j];
            if(j - w[i] >= 0) {
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
            }
        }
    }
    rep(i, N + 1) {
        rep(j, W + 1) {
            ans = max(ans, dp[i][j]);
            //cout << dp[i][j] << " ";
        }
        //cout << endl;
    }
    cout << ans << endl;


    return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

using Mint = modint998244353;



struct value {
  Mint a, b;
  value() {}
  value(Mint a, Mint b) : a(a), b(b) {}
};
struct monoid {
public:
	  static value op(const value a, const value b) {
	    return value(a.a + b.a, a.b + b.b);
	  }
	  static value e() { return value(0, 1); }
	  static value mapping(value a, value b) {
	    return value(a.a * b.a + a.b * b.b, b.b);
	  }
	  static value composition(value a, value b) {
	    return value(a.a * b.a, a.a * b.b + a.b);
	  }
	  static value id() { return value(1, 0); }
	};

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

  int64 N, Q;
  cin >> N >> Q;
  vector<value> A(N);
  REP(i, N) {
    int64 a;
    cin >> a; A[i] = value(a, 1);
  }
  lazy_segtree<value, monoid::op, monoid::e, value, monoid::mapping, monoid::composition, monoid::id> lsg(A);

  REP(_, Q) {
    int64 t, l, r;
    cin >> t >> l >> r;
    if (t == 0) {
      int64 b, c;
      cin >> b >> c;
      lsg.apply(l, r, value(b, c));
    } else {
      cout << lsg.prod(l, r).a.val() << endl;
    }
  }
}



Measured memory_bytes: 19280
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
const int INF = 1e9 + 5;
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (auto &x : h) {
        cin >> x;
    }

    vector<int> dp(n, INF);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= k; j++) {
            if (i + j < n) {
                dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
            }
        } 
    }
    cout << dp[n - 1] << endl;

    return 0;
}



Measured memory_bytes: 4024
#import math
from functools import reduce

N, X = [int(c) for c in input().split()]
x = [int(c) for c in input().split()]

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

if N == 1:
    print(abs(x[0] - X))
else:
    x.append(X)
    x.sort()
    x = [n - x[0] for n in x]
    D = reduce(gcd, x)
    print(D)

Measured memory_bytes: 14724
using System;
using System.Linq;
using System.Collections.Generic;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string n=Console.ReadLine();
    for(int i=0;i<3;i++){
      if(n.Substring(i,1)=="1"){
        Console.Write(9);
      }else if(n.Substring(i,1)=="9"){
        
        Console.Write(1);
      }
    }
      Console.Write("\n");
    }
    
  }

}


Measured memory_bytes: 25960
#include<stdio.h>
#include<string.h>
int ab (int a,int i);
int main(void)
{
    int number,ans[10000],i,j=0;
    double kg,m;
    while(scanf("%d,%lf,%lf",&number,&kg,&m)!=EOF){
        if(kg/(m*m)>=25){
            ans[j]=number;
            j++;
        }
    }
    for(i=0;i<=j;i++){
        if(ans[i]==0)break;
        printf("%d\n",ans[i]);
    }
    return 0;
}

Measured memory_bytes: 632
import java.util.* ;
class Main {
  public static void main(String[] args) {
    
    Scanner scan = new Scanner(System.in);
  int a = scan.nextInt();
    int b =scan.nextInt();
 	if(a>b){
      System.out.println(a-1);
    }else{
      System.out.println(a);
    }
  }
}


Measured memory_bytes: 22740
import Control.Monad
import Data.Array.IArray
import Data.Char
import System.IO

type Figure     = (FigName,FigPattern)
type FigPattern = (Int,Int) -> [(Int,Int)]
type FigName    = Char

a :: Figure
a = ('A', \(x,y) -> [(i,j) | i <- [x,x+1], j <- [y,y+1]])
b :: Figure
b = ('B', \(x,y) ->[(i,j) | i <- [x..x+3], j <- [y]])
c :: Figure
c = ('C', \(x,y) -> [(i,j) | i <- [x], j <- [y..y+3]])
d :: Figure
d = ('D', \(x,y) -> [(x,y), (x+1,y-1),(x+1,y),(x+2,y-1)])
e :: Figure
e = ('E', \(x,y) -> [(x,y),(x,y+1),(x+1,y+1),(x+1,y+2)])
f :: Figure
f = ('F', \(x,y) -> [(x,y),(x+1,y),(x+1,y+1),(x+2,y+1)])
g :: Figure
g = ('G', \(x,y) -> [(x,y), (x,y+1), (x+1,y-1), (x+1,y)])


main = do
    eof <- isEOF
    if eof then return ()
           else do
               inputField >>= putStrLn.desideFig.searchFigPos
               main

desideFig pos = map fst $ filter (\(n,p) -> p (head pos) == pos) [a,b,c,d,e,f,g]

inputField :: IO (Array (Int, Int) Int)
inputField = do
    field <- replicateM 8 (fmap (map digitToInt) getLine)
    eof <- isEOF
    unless eof (getLine >> return ())
    return $ getField field

getField = listArray ((0,0),(7,7)).concat

searchFigPos field = [(x,y) | x <- [0..7], y <- [0..7], field ! (x,y) == 1]

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

using namespace std;

class union_find {
    protected :
        std::vector<int> par;
    public :
        union_find(int);
        int find(int);
        bool same(int, int);
        virtual void unite(int, int);
};

union_find::union_find(int n) {
    par.resize(n);
    for (int i=0; i<n; i++) {
        par.at(i) = i;
    }
}

int union_find::find(int x) {
    if (par.at(x) == x) return x;
    else return par.at(x) = find(par.at(x));
}

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

void union_find::unite(int x, int y) {
    int x_par = find(x);
    int y_par = find(y);
    if (x_par == y_par) return;

    par.at(x_par) = y_par;
}


int main() {
    int n = 0, m = 0;
    cin >> n >> m;
    vector<int> p(n);
    for (int i=0; i<n; i++) {
        cin >> p.at(i);
    }
    union_find uf(n);
    int x = 0, y = 0;
    for (int i=0; i<m; i++) {
        cin >> x >> y;
        uf.unite(x-1, y-1);
    }
    int cnt = 0;
    for (int i=0; i<n; i++) {
        if (uf.same(i, p.at(i)-1)) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n,m; cin >> n;
    vector<string> s(100),t(100);
    rep(i,n)cin >> s[i];
    cin >> m;
    rep(j,m)cin >> t[j];
    
    map<string,int> mp1,mp2;
    rep(i,n)mp1[s[i]]++;
    rep(j,m)mp2[t[j]]++;
    int res = 0;
    rep(i,n) res = max(res,mp1[s[i]]-mp2[s[i]]);
    cout << res << endl;
}


Measured memory_bytes: 256
while True :
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    
    
    if op == "?" :
        break
    
    
    def x(a, op, b) :
    
    
        if op == "+" :
            return a + b
    
    
        elif op == "-" :
            return a - b 
        
    
        elif op == "*" :
            return a * b
            
        
        else :
            return a // b
            
    
    print(x(a, op, b))


Measured memory_bytes: 5596
#include<iostream>
#include<algorithm>
using namespace std;
bool used[10];
int dp[11][10000];
void solve(int s,int d,int cnt)
{
	if(s<d)
	{
		dp[s][cnt]++;
		return;
	}

	for(int i = 0; i < 10; ++i)
	{
		if(!used[i])
		{
			used[i]=true;
			solve(s,d+1,cnt+i*d);
			used[i]=false;
		}
	}

	return;
}


int main()
{
	for(int i = 1; i < 11; ++i)
	{
		solve(i,1,0);
	}
	int n,s;
	while(cin>>n>>s)
	{
		cout<<dp[n][s]<<endl;
	}
  return 0;
}

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

int main() {

    int a, b;
    cin >> a >> b;

    cout << max({a+b, a-b, a*b}) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18
#define MOD 998244353

int main(){
	int N;
	cin>>N;
	vector<int> D(N);
	int max=0;
	REP(i,N){
		cin>>D[i];
		if(D[i]>max)max=D[i];
	}
	if(D[0]!=0){
		cout<<0;
		return 0;
	}
	vector<int> cnt(max+1,0);
	REP(i,N)cnt[D[i]]++;
	if(cnt[0]!=1){
		cout<<0;
		return 0;
	}
	ll ans=1;
	FOR(i,1,max+1){
		ll tmp=1;
		REP(j,cnt[i])tmp=(tmp*cnt[i-1])%MOD;
		ans=(ans*tmp)%MOD;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;                                                            
#define pb push_back                                                            
#define mp make_pair                                                                                                                                
#define sqr(a) ((a) * (a))                                                      
#define io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);   
#define co() cout.precision(10);                                                
#define F for(li i=0;i<n;i++)
#define fo(i,a,n) for(i=a;i<n;i++)
#define ne cout<<"\n"; 
#define test int t;cin>>t;while(t--)
//#define oj #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif

typedef long long li;
typedef long double ld;

const li mod = 1000000007;

int main() 
{
    io();
    li a,b;
    cin>>a>>b;
    cout<<1LL*a*b;
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long

int n,a,b;
vector<int> p;

int main(){
  cin>>n>>a>>b;
  int tmp;
  int low=0,mid=0,high=0;
  REP(i,n){
    cin>>tmp;
    p.push_back(tmp);
    if(tmp<=a)low++;
    if(tmp>a && tmp<=b)mid++;
    if(tmp>=b+1)high++;
  }
  cout<<min(low,min(mid,high))<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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 rep(i,b) FOR(i,0,b)
#define INF 1e9
#define dump(x) cerr<< #x << " = "<<(x)<<endl
#define int long long

using ll = long long;
const ll mod = LLONG_MAX;

typedef pair<int,int> P;


signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  int r=a*100+b*10+c;
  if(r%4==0){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }

}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll t[100][100];
int main(){
  cin>>n;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      cin>>t[i][j];
  ll ans=0;
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      ans+=min(t[i][j],t[j][i]);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1244
#include<iostream>
#include<cstdio>
#include<stdlib.h>
using namespace std;

char a[32] = {0};
int buf[100] = {0};
int sp = 0;

int main(void)
{
    while(true){
        if(scanf("%s",a)==EOF)break;
        //cout << a << endl;

        if(a[0] == '+'){
            buf[sp-2] = buf[sp-1] + buf[sp-2];
            sp--;
        }
        else if(a[0] == '-'){
            buf[sp-2] = buf[sp-2] - buf[sp-1];
            sp--;        
        }
        else if(a[0] == '*'){
            buf[sp-2] = buf[sp-1] * buf[sp-2];
            sp--;
        }
        else{
            buf[sp] = atoi(a);
            sp++;
        }
    }

    cout << buf[0] << endl;

    return 0;
}



Measured memory_bytes: 3252
#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> 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 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; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n;
    cin >> n;
    vi64 a(n);
    forn(i, n) cin >> a[i];
    i64 l = 2, r = 2;
    ford(i, n) {
//        cerr << l << ' ' << r << '\n';
        i64 x = a[i];
        r -= r % x;
        l += (x - l % x) % x;
        if (l > r) {    
            l = -1;
            break;
        }
        r += x - 1;
    }
    if (l == -1) cout << -1 << '\n';
    else cout << l << ' ' << r  << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

const long long MOD = 1000000007;
const long long MAX = 2000000;

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

int main()
{
    double A,B,H,M;
    cin>>A>>B>>H>>M;
    double tanshin=0;
    double choshin=0;
    tanshin=6*M;
    choshin=30*H+0.5*M;
    double kakudo=min(360-abs(tanshin-choshin),abs(tanshin-choshin));
    static const double pi = 3.141592653589793;
    cout<<setprecision(20)<<sqrt(A*A+B*B-2*A*B*cos((kakudo/180)*pi))<<endl;

}


Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

typedef long long ll;

#define vi std::vector<int>
#define vl std::vector<ll>
#define floop(n) for(int i = 0; i < n; ++i)
#define print(x) std::cout << x << std::endl;

const ll INF = 1e18;

int main()
{
    int N;
    std::string s;
    std::map<std::string, int> m;
    m["AC"] = 0;
    m["WA"] = 0;
    m["TLE"] = 0;
    m["RE"] = 0;

    std::cin >> N;

    floop(N)
    {
        std::cin >> s;
        m[s] += 1;
    }

    print("AC x " + std::to_string(m["AC"]));
    print("WA x " + std::to_string(m["WA"]));
    print("TLE x " + std::to_string(m["TLE"]));
    print("RE x " + std::to_string(m["RE"]));

    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e;
  string s,ss,sss;
  cin>>a>>s;
  for(int i=0;i<s.size();i++){
    cout<<(char)((s[i]-'A'+a)%26+'A');
  }
  cout<<endl;
  return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        var A = int.Parse(inputs[0]);
        var P = int.Parse(inputs[1]);

        var pieceCount = A * 3 + P;
        var answer = pieceCount / 2;
        Console.WriteLine(answer);
    }
}



Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int A, P;
  cin >> A >> P;
  cout << (3*A+P)/2 << endl;
  return 0;
}

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

int main()
{
    int n,u,v,d;
    int G[101][101];
    cin>>n;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            G[i][j]=0;
    for(int i=0;i<n;i++)
    {
        cin>>u>>d;
        for(int k=0;k<d;k++)
        {
            cin>>v;
            G[u][v]=1;
            //cout<<u<<' '<<v<<' '<<G[u][v]<<endl;
        }
    }
    for(int i=1;i<=n;i++)
    {
        int isn=0;
        for(int j=1;j<=n;j++)
        {
            if(isn++>0)cout<<' ';
            cout<<G[i][j];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3128
void main(){
	string n = readln().chomp();
	int cnt, ans;
	foreach(i; 0..n.length){
		if(cnt==0)cnt++;
		else if(n[i-1]==n[i])cnt++;
		else cnt=1;

		ans = max(cnt, ans);
	}
	( ans>=3?"Yes":"No" ).writeln();
}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;      
// 1要素のみの入力
T inelm(T= int)(){
	return to!(T)( readln().chomp() );
}
     
// 1行に同一型の複数入力
T[] inln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split())ln ~= elm.to!T();
	return ln;
}


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

int main(){
    int h, w, d;
    cin >> h >> w >> d;

    vector<P> v(h*w);

    rep(i, h){
        rep(j, w){
            P p = P(i, j);
            int a; cin >> a;
            v[--a] = p;
        }
    }

    // 累積和 ll?
    ll s[h*w*2+5];
    
    for (int i = 0; i < d; i++){
        s[i] = 0;
        int x = v[i].first;
        int y = v[i].second;
        for (int j = i+d; j < h*w; j+=d) {
            int xx = v[j].first;
            int yy = v[j].second;

            s[j] = s[j-d] + abs(x-xx)+abs(y-yy);
            x = xx;
            y = yy;
        }
    }
    
    int q; cin >> q;
    rep(i, q){
        int l, r;
        cin >> l >> r;
        // printf("%d %d\n", s[r-1], s[l-1]);
        cout << s[--r] - s[--l] << endl;
    }
    return 0;
}

Measured memory_bytes: 2560
# -*- coding: utf-8 -*-

import numpy as np
N, K, C=map(int, input().split())
s=list(input())

forward=np.zeros(K)
back=np.zeros(K)

day=0
count=0
while day <N and count<K:
    if s[day]=='o':
        forward[count]=day
        count+=1
        day+=C+1
    else:
        day+=1

day=N-1
count=0
while day<N and count<K:
    if s[day]=='o':
        back[count]=day
        count+=1
        day-=C+1
    else:
        day-=1

#print(forward)
#print(back[::-1])

for i in range(K):
    if forward[i]==back[K-1-i]:
        print(int(forward[i])+1)



Measured memory_bytes: 18544
<?php
//$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
list($H,$W) = array_map('intval',explode(" ",trim(fgets(STDIN))));
list($Ch,$Cw) = array_map('intval',explode(" ",trim(fgets(STDIN))));
list($Dh,$Dw) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

$Ch=$Ch-1;
$Cw=$Cw-1;
$Dh=$Dh-1;
$Dw=$Dw-1;
for($i=0;$i<$H;$i++) {
  $S[]=trim(fgets(STDIN));
}
$used = array();
$usedlist = array();
$goal = false;
$warp = 0;

$res = search($Ch,$Cw);
if ($res) {
  printf("%d\n",0);
  exit;
}
while(1) {
  $list = getUsedList($warp);
  if (count($list)==0) break;
  $warp++;
  foreach($list as $v) {
    //到達済み位置からワープ可能な位置を探す
    $p = canwarp($v[0],$v[1]);
    if (count($p)==0) continue;
    //ワープ可能地点があった場合はそこから探す
    foreach($p as $vv) {
      $res = search($vv[0],$vv[1]);
      if ($res) break;
    }
  }
  if ($goal) break;
}
if ($goal) printf("%d\n",$warp);
else printf("-1\n");

function search($row,$col) {
  global $S,$Dw,$Dh,$H,$W,$used,$goal,$warp,$usedlist;
  if (isset($used[$row][$col])) {
    return false;
  }
  if ($row<0 || $H<=$row || $col < 0 || $W <= $col || $S[$row][$col]=="#") {
    return false;
  }
  if (isset($used[$row][$col])) {
    return false;
  }
  $used[$row][$col]=$warp;
  $usedlist[$warp][]=array($row,$col);

  if ($row==$Dh && $col==$Dw) {
    $goal = true;
    return true;
  }
  search($row,$col+1);
  search($row,$col-1);
  search($row+1,$col);
  search($row-1,$col);

  return $goal;
}

function canwarp($row,$col) {
  global $S,$Dw,$Dh,$H,$W,$used,$goal;
  $warppos=array();
  for($i=$row-2;$i<=$row+2;$i++) {
    for($j=$col-2;$j<=$col+2;$j++) {
      $crow = $i;
      $ccol = $j;
      if ($crow>= 0 && $H>$crow && $ccol >= 0 && $W > $ccol && $S[$crow][$ccol]=="." && !isset($used[$crow][$ccol])) {
        $warppos[]=array($crow,$ccol);
      }
    }
  }
  return $warppos;
}

function getUsedList($depth)
{
  global $H,$W,$used,$usedlist;
  $ret=array();
  if (!isset($usedlist[$depth])) return $ret;
  foreach($usedlist[$depth] as $v) {
    $ret[]=array($v[0],$v[1]);
  }
  return $ret;
}



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

typedef long long ll;
typedef pair<int, int> pii; 
const int N = 2e5+10, mod = 1e9+7;

void solve() {
    int n; cin >> n;

    ll dp[n + 1];
    memset(dp, 0, sizeof(dp));

    dp[0] = 1;
    for (int i = 3; i <= n; ++i) {
        for (int j = 3; j <= i; ++j) {
            dp[i] = (dp[i] + dp[i - j]) % mod;
        }
    }
    
    cout << dp[n] << endl;
}   

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t = 1;
    while (t--) solve();
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    VI a(3); VIin(a);
    int k; cin >> k;
    SORT(a);
    rep(i,k) a[2] *= 2;
    OUT(a[0]+a[1]+a[2]);

    return 0;
}

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

int Count(string S)
{
    int ret = 0;
    rep(i, S.size() - 1)
    {
        if (S[i] == S[i + 1])
            ret++;
    }
    return ret;
}

string Decompressed(vector<pair<char, int>> S)
{

    string ret;
    rep(i, S.size())
    {
        ret += string(S[i].second, S[i].first);
    }
    return ret;
}

int main()
{
    int N, K;
    string S;
    cin >> N >> K >> S;
    vector<pair<char, int>> compressedS;
    compressedS.push_back(make_pair(S[0], 1));
    rep(i, N - 1)
    {
        if (compressedS.back().first == S[i + 1])
            compressedS.back().second++;
        else
            compressedS.push_back(make_pair(S[i + 1], 1));
    }
    int cnt = 0;

    vector<pair<char, int>> compressedS1 = compressedS;
    rep(i, compressedS.size() - 1)
    {
        if (cnt < K && compressedS[i].first == 'R' && compressedS[i + 1].first == 'L')
        {
            compressedS[i + 1].first = 'R';
            cnt++;
        }
    }

    if (cnt < K && compressedS[0].first == 'L')
    {
        compressedS[0].first = 'R';
    }

    int cnt1 = 0;
    reverse(compressedS1.begin(), compressedS1.end());
    rep(i, compressedS.size() - 1)
    {
        if (cnt1 < K && compressedS1[i].first == 'L' && compressedS1[i + 1].first == 'R')
        {
            compressedS1[i + 1].first = 'L';
            cnt1++;
        }
    }

    if (cnt1 < K && compressedS1[0].first == 'R')
    {
        compressedS1[0].first = 'L';
    }
    reverse(compressedS1.begin(), compressedS1.end());
    int ans = max(Count(Decompressed(compressedS)), Count(Decompressed(compressedS1)));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long gg;
const int maxn=2e5+9;
int n;
typedef pair < gg , gg > MON;/* x,hp */
MON a[maxn];
gg dmgend[maxn],dist,bomb;

void _input(){
    cin>>n>>dist>>bomb;
    for(int i=0;i<n;++i) cin>>a[i].first>>a[i].second;
}

gg solve(){
    dist*=2;
    sort(a,a+n);
    // queue < gg > q;/* +:monster mark -:bomb mark */
    int i=0,j=0;
    gg b=0,ans=0;
    while(j<n){
        /* target */
        // if(q.empty()){
        //     x=a[i].first;
        // }else{
        //     x=a[q.front()].first;
        // }
        gg x=a[j].first+dist;
        while(i<n){
            if(a[i].first <= x){
                // q.push(i);
                // printf("push %d(%d,%lld)\n",i,a[i].first,a[i].second);
                ++i;
            }else break;
        }

        /* fire */
        gg hp=a[j].second;
        gg newb=hp/bomb+!!(hp%bomb);
        ans+=newb-b;
        // q.push(b-newb);
        if(i<n) dmgend[i]+= newb-b;
        // printf("b=%d newb=%d\n",b,newb);
        b=newb;

        /* clear  */
        while(j<i){
            if(a[j].second <= bomb*b){
                ++j;
                b-= dmgend[j];
            }else break;
        }
        // while(!q.empty()){
        //     if(q.front()<0){
        //         b+=q.front();
        //         q.pop();
        //         continue;
        //     }
        //     if(a[q.front()].second <= bomb*b){
        //         // printf("pop %d\n",q.front());
        //         q.pop();
        //     }else break;
        // }
    }
    return ans;
}

void _solve(){
    cout<<solve()<<endl;
}

int main(){
    _input();
    _solve();
    return 0;
}


Measured memory_bytes: 4992
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};
 
 
void solve(){
    ll a,b,c;
    cin>>a>>b>>c;
    rep(i,2*b){
        if(a*i%b==c){
            cout<<"YES"<<endl;
            return ;
        }
    }
    cout<<"NO"<<endl;

}
 
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
     
    ll Q=1;
    // cin>>Q;
    rep(_,Q){
 
        solve();
 
    }
   
 
 
    return 0;
}

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

int n,a,b;
int s[1000];

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

  sort(s,s+n);

  for(int i=0;i<n;i++){
    if(i%2) a+=s[i];
    else b+=s[i];
  }

  cout<<abs(a-b)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

int main(void) {
	int h, w, num, i;
	cin >> num;
	if (num == 22)
		printf("Christmas Eve Eve Eve\n");
	if (num == 23)
		printf("Christmas Eve Eve\n");
	if (num == 24)
		printf("Christmas Eve\n");
	if (num == 25)
		printf("Christmas\n");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF 1e9+7
#define LLINF 1e18
// #define int ll
using namespace std;
const int MOD = 1e9 +7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    bool can=0;
    cin>>s;
    if(s=="AKIHABARA" ||s=="AKIHABAR" ||s=="AKIHABRA" ||s=="AKIHBARA"||s=="KIHABARA"||s=="AKIHABR"||s=="AKIHBAR"||s=="AKIHBRA"||s=="KIHABAR"||s=="KIHABRA"||s=="KIHBARA"||s=="KIHBRA"||s=="KIHBAR"||s=="KIHABR"||s=="AKIHBR"||s=="KIHBR") can=1;
    if(can) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

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

const int MAXN = 500000;

int f[MAXN + 5], g[MAXN + 5], lenw; char w[MAXN + 5];
bool checkf(int x) {return f[x] && (x % (x - f[x]) == 0);}
bool checkg(int x) {return g[x] && (x % (x - g[x]) == 0);}
int main() {
	scanf("%s", w), lenw = strlen(w);
	
	f[0] = -1, f[1] = 0;
	for(int i=2;i<=lenw;i++) {
		int j = f[i - 1];
		while( j != -1 && w[j] != w[i - 1] )
			j = f[j];
		f[i] = j + 1;
	}
	
	if( checkf(lenw) ) {
		int k = lenw / (lenw - f[lenw]);
		if( k == lenw ) printf("%d\n1\n", lenw);
		else {
			reverse(w, w + lenw), g[0] = -1, g[1] = 0;
			for(int i=2;i<=lenw;i++) {
				int j = g[i - 1];
				while( j != -1 && w[j] != w[i - 1] )
					j = g[j];
				g[i] = j + 1;
			}
			
			int ans = 0;
			for(int i=1;i<lenw;i++)
				ans += (!checkf(i) && !checkg(lenw - i));
			printf("2\n%d\n", ans);
		}
	} else printf("1\n1\n");
}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> list(n, vector<int>(n, INF)), cost(n, vector<int>(n, INF));
  for (int i = 0; i < m; i++) {
    int s, e, c;
    cin >> s >> e >> c; s--, e--;
    list[s][e] = c;
    list[e][s] = c;
    cost[s][e] = c;
    cost[e][s] = c;
  }

  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (list[i][j] != INF && cost[i][j] != list[i][j]) {
        cnt++;
      }
    }
  }

  cout << cnt / 2 << endl;
  return 0;
}


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

int n,k;
signed main(){
	cin>>n>>k;
	int ans=0;
	int cnt=0;
	for(int i=1;i<(n-2)%11+1;i++){
		for(int j=1;j<=5;j++){
			if((7*i+j+1)*9%11==k)ans++;
		}
	}
	for(int i=1;i<=11;i++){
		for(int j=1;j<=5;j++){
			if((7*i+j+1)*9%11==k)cnt++;
		}
	}
	cout<<(n-2)/11*cnt+ans<<endl;
	return 0;
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using f64 = double_t;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

void solve() {
    i64 n, d;
    cin >> n >> d;

    i64 ans = 0;
    for (i64 i = 0; i < n; i++) {
        i64 x, y;
        cin >> x >> y;
        if (x * x + y * y <= d * d) ans++;
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

const int MAX = 200000;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dp[101][256][101];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    COMinit();
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    dp[0][0][0] = 1;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= 255; j++)
        {
            for (int r = 0; r <= n; r++)
            {
                if (r + 1 <= n)
                {
                    (dp[i + 1][j ^ a[i]][r + 1] += dp[i][j][r]) %= MOD;
                }
                (dp[i + 1][j][r] += dp[i][j][r]) %= MOD;
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i <= n; i++)
    {
        (ans += dp[n][k][i] * fac[i] % MOD) %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 25216
#include<stdio.h>
int main(void)
{
	int n, i, a[100];
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	for(i=n-1; i>=0; i--){
		printf("%d", a[i]);
		if(i!=0){
			printf(" ");
		}
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
typedef vector<int > vecint;
typedef vector<string > vecstr;
int main()
{
  string a;
  cin >> a;
  map<char, int> m;
  REP(i,a.size()){
    m[a[i]] ++;
  }
  for(int i = 0;i < 26; i ++){
    char alph = 'a' + i;
    if(m.count(alph) == 0){
      cout << alph << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int N, M;
    cin >> N >> M;
    vi A(N);
    rep(i, N) cin >> A[i];
    map<int, int> m;
    rep(i, M) {
        int b, c;
        cin >> b >> c;
        m[c] += b;
    }

    sort(all(A));

    auto it = m.end();
    it--;
    rep(i, N) {
        auto p = *it;
        if (A[i] > p.first) break;
        A[i] = p.first;
        m[p.first] = p.second-1;
        if (m[p.first] <= 0) {
            if (it == m.begin()) {
                break;
            }
            else {
                it--;
            }
        }
    }

    lint res = 0;
    rep(i, N) res += A[i];
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


int main(){
  ll r, d, x;
  cin >> r >> d >> x;
  REP(i,10){
    x = r * x - d;
    cout << x << endl;
  }
  return 0;
}

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

int main() {
  int N,P;
  string S;
  cin >> N >> P >> S;

  map<int, int> M;
  ll ans = 0;
  
  if ((P==5) || (P==2)) {
    for (int i=0;i<N;++i) {
      if ( (S[i]-'0') % P == 0 ) ans += i+1;
    }
  } else {
    int pre = 0;
    int ten = 1;
    M[0] = 1;
    for (int i=N-1; i>=0; --i) {
      int mod = ((S[i]-'0') * ten) % P;
      mod = (mod + pre) % P;
      ans += M[mod];
      M[mod]++;
      pre = mod % P;
      ten = ten * 10 % P;
    }
//    for( auto m: M )
//      cout << m.first << " " << m.second << endl;
  }
  cout << ans << endl;
}

  

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,m;
  cin >> n >> m;
  vector<string>data_a(n);
  vector<string>data_b(m);
  for(int i=0;i<n;i++){
    cin >> data_a.at(i);
  }
  for(int i=0;i<m;i++){
    cin >> data_b.at(i);
  }
  bool exist=false;
  for(int li=0;li<n;li++){
    for(int lj=0;lj<n;lj++){
      if(li+m-1>=n||lj+m-1>=n){
        continue;
      }
      bool judge=true;
      for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
          if(data_a.at(li+i).at(lj+j)!=data_b.at(i).at(j)){
            judge=false;
          }
        }
      }
      if(judge){
        exist=true;
      }
    }
  }
  if(exist){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

void Main(){}

int main() {
	int a,b;char op;
	while(cin>>a>>op>>b,op!='?'){
		switch(op){
			case '+':cout<<a+b<<endl;break;
			case '-':cout<<a-b<<endl;break;
			case '*':cout<<a*b<<endl;break;
			case '/':cout<<a/b<<endl;break;
		}
	}
}


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


string s;

long int N, q;
char t[200010];
bool d[200010];
int se(long int n);
long int nibunl(long int l, long int r);
long int nibunr(long int l, long int r);
int main(){
	char d0;
	
	long int ansl=0,ansr=0;
	cin >> N>>q;
	cin >> s;
	for (int i = 0; i < q; i++) {
		cin >> t[i] >> d0;
		if (d0 == 'L')d[i] = true;
	}
	if (se(0) == N){cout << "0" << endl; return 0;}
	if (se(N - 1) == -1){cout << "0" << endl; return 0;}
	ansl = nibunl(0, N - 1);
	ansr = nibunr(0, N - 1);
	cout <<  - ansl + ansr-1 << endl;

return 0;
}
long int nibunl(long int l, long int r) {
  
	if (l == r)return l;
	if (se(l) == -1) {
		if (se(r) == -1)return nibunl(r, (3 * r - l + 1) / 2);
		else return nibunl(l, (r + l) / 2);
	}
	else return -1;
}
long int nibunr(long int l, long int r) {
    
	if (l == r)return l;
	if (se(r) == N) {
		if (se(l) == N)return nibunr((3 * l - r - 1)/ 2, l);
		else return nibunr((r + l + 1) / 2, r);
	}
	else return N;
}

int se(long int n) {
	for (long int i = 0; i < q; i++) {
		if (s[n] == t[i]) {
			if (d[i])n--;
			else n++;
			if (n == N)return N;
			if (n == -1)return -1;
	}
	}
	return 0;
}

Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
#define Sort(v) sort((v).begin(), (v).end())
#define pb push_back
using veci = vector<int>;
using ll = long long;
struct node{
  ll key=-2000000050;
  struct node *right = NULL;
  struct node *left = NULL;
  struct node *parent = NULL;
};
#define nl NULL
node* root = {nl};
void insert(ll key){
  node* n = new node();
  n->key = key;//新しいノードのポインタnからそのノードのメンバにアクセス
  node* x = root;
  node* y = {NULL};
  while (x != NULL){//見る箇所を移動
    y = x;
    if (x->key >= n->key){
      x = x->left;
    }
    else x = x->right;
  }
  if (y == NULL) root = n;
  else if (y->key >= n->key) y->left = n;
  else y->right = n;
}
void preorder(node* u){//根、左、右
    cout << " " << u->key;//アクセス先が構造体変数ならドット演算子を、構造体変数へのポインターならアロー演算子を使う
    if (u->left != NULL) preorder(u->left);
    if (u->right != NULL) preorder(u->right);
}
void inorder(node* u){//左、根、右
    if (u->left != nl) inorder(u->left);
    cout << " " << u->key;
    if (u->right != nl) inorder(u->right);
}
int main(){
  int n, i; cin >> n;
  ll x;
  string com;
  for ( i = 0; i < n; i++ ){
    cin >> com;
    if (com == "insert"){
      cin >> x;
      insert(x);
    }
    else if (com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
	}
  }
  return 0;
}


Measured memory_bytes: 26508
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
//#define INF 1100000000000000000LL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
int main() {
	string S;
	cin>>S;
	int ans=0;
	for(int i=0;i<3;i++)
		if(S[i]=='1')
			ans++;
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  string s;cin>>s;
  int k=s.size()/2+1;
  char bef=s[s.size()/2];
  while(true){
    if(s[k-1]!=bef||s[s.size()-k]!=bef)break;
    k++;
    if(k>s.size())break;
  }
  cout<<k-1<<endl;
  return 0;
}


Measured memory_bytes: 512
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String[] S = new String[s.length()];
    int a = -1;
    int length = 0;
    S = s.split("");
    for (int i = 0; i < s.length(); i++) {
      if (S[i].equals("A") && a == -1) {
        a = i;
      }
      if (S[i].equals("Z") && a != -1) {
        length = i - a + 1;
      }
    }
    System.out.println(length);
  }
}
    

Measured memory_bytes: 66940
import sys
def input():
	return sys.stdin.buffer.readline()[:-1]

class UnionFind():
	def __init__(self, size):
		self.table = [-1 for _ in range(size)]
		self.size = [1 for _ in range(size)]

	def find(self, x):
		while self.table[x] >= 0:
			if self.table[self.table[x]] >= 0:
				self.table[x] = self.table[self.table[x]]
			x = self.table[x]
		return x

	def unite(self, x, y):
		s1 = self.find(x)
		s2 = self.find(y)
		if s1 != s2:
			if self.table[s1] > self.table[s2]:
				self.table[s2] = s1
				self.table[s1] -= 1
				self.size[s1] += self.size[s2]
				self.size[s2] = 0
			else:
				self.table[s1] = s2
				self.table[s2] -= 1
				self.size[s2] += self.size[s1]
				self.size[s1] = 0
		return

n, m = map(int, input().split())
uf = UnionFind(n)
ans = n-1
for _ in range(m):
	a, b = map(int, input().split())
	if uf.find(a-1) != uf.find(b-1):
		ans -= 1
		uf.unite(a-1, b-1)

print(ans)

Measured memory_bytes: 85828
s = gets.chomp.split('').map(&:to_i)
s0 = (1..s.size).map { |x| (x+1) % 2 }
s1 = (1..s.size).map { |x| x % 2 }
d0 = 0
d1 = 0
(0..(s.size-1)).each do |i|
  d0 += s[i] ^ s0[i]
  d1 += s[i] ^ s1[i]
end
puts [d0, d1].min


Measured memory_bytes: 9340
import fractions

N = int(input())
A = list(map(int, input().split())) 

l = [0]
r = [0]

for i in range(N - 1):
    l += [fractions.gcd(l[i], A[i])]
    r += [fractions.gcd(r[i], A[-i-1])]

print(max(fractions.gcd(l[i], r[-i-1]) for i in range(N)))

Measured memory_bytes: 16144
n = int(input())
position = []

for i in range(n):
	x_in, l_in = map(int, input().split())
	position.append([x_in + l_in, x_in - l_in])

position.sort()
ans = 0
t = - (10 ** 9 + 1)

for i in range(n):
	if t <= position[i][1]:
		ans += 1
		t = position[i][0]

print(ans)

Measured memory_bytes: 58840
N = int(input())
S = [input() for _ in range(2)]

ans = 0
mod = 10 ** 9 + 7
prev = False
cur = False
for i in range(N):
    if cur:
        cur = False
        continue

    if S[0][i] == S[1][i]:
        if i == 0:
            ans = 3
        elif not prev:
            ans = ans * 2 % mod
        cur = False
        prev = False
    else:
        if i == 0:
            ans = 6
        elif prev:
            ans = ans * 3 % mod
        else:
            ans = ans * 2 % mod
        cur = True
        prev = True

print(ans)


Measured memory_bytes: 38384