akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int n;
    cin >> n;
    llint minv = +1000001, maxv = -1000001, sumv = 0;
    while (n--) {
        llint i;
        cin >> i;
        minv = min(minv, i);
        maxv = max(maxv, i);
        sumv += i;
    }
    cout << minv << " " << maxv << " " << sumv << endl;
}




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

using namespace std;

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();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#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 range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define x first
#define y second

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
    double res;
    for(int r, n; cin >> r >> n, r; cout << res << endl){
        res = 0.;
        map<int, map<int, int> > shadows;
        rep(i, n){
            int left, right, h; cin >> left >> right >> h;
            range(x, left, right){
                shadows[x][x + 1] = max(shadows[x][x + 1], h);
            }
        }

        bool ok = false;
        for(; !ok; res += 0.0001){
            pair<double, double> o = mp(0., -r + res);

            range(x, -r, r){
                rep(i, 2){
                    double d = sqr(x + i - o.x) + sqr(shadows[x][x + 1] - o.y);

                    if(d <= (double)sqr(r)){
                        ok = true;
                        break;
                    }
                }
            }
        }
    }

	return 0;
}

Measured memory_bytes: 1272
class priorityQueue {
  constructor() {
    this.keys = [];
    Number.prototype.parentIdx = function() { return Math.ceil(this/2 - 1); };
    Number.prototype.leftIdx = function() { return this * 2 + 1; };
    Number.prototype.rightIdx = function() { return this * 2 + 2; };
  }

  insert(key) { this.heapIncrease(this.keys.push(key) - 1); }

  heapIncrease(idx) {
    const keys = this.keys;
    for (let i=idx, p=idx.parentIdx(); i > 0 && keys[i] > keys[p]; i=p, p=i.parentIdx()) {
      keys[p] = [keys[i], keys[i] = keys[p]][0];
    }
  }

  extract() {
    const keys = this.keys;
    const res = keys[0];
    keys[0] = keys.pop();
    this.maxHeapify(0);
    return res;
  }

  maxHeapify(idx) {
    const keys = this.keys;
    const n = keys.length;
    const innerMaxHeapify = (i) => {
      let left, right, largest = i;
      left = i.leftIdx();
      right = i.rightIdx();
      if (left < n && Number(keys[left]) > Number(keys[largest])) largest = left;
      if (right < n && Number(keys[right]) > Number(keys[largest])) largest = right;
      if (largest != i) {
        keys[largest] = [keys[i], keys[i] = keys[largest]][0];
        innerMaxHeapify(largest);
      }
    };
    innerMaxHeapify(idx);
  }
}

(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  lines.pop();
  const queue = new priorityQueue();
  let str = '';
  lines.forEach(function(cmd) {
    switch(cmd.charAt(0)) {
      case 'i': queue.insert(Number(cmd.split(' ')[1])); break;
      case 'e': str += `${queue.extract()}\n`;
    }
  });
  process.stdout.write(str);
})();



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

namespace AtCoderTemplate
{
    class Program
    {
        static int N = 0, M = 0;
        static long K = 0;
        static int ans = 0;
        static long[] A;
        static long[] B;

        static void Main (string[] args)
        {
            string[] str;
            str = Console.ReadLine ().Split (' ');

            N = int.Parse (str[0]);
            M = int.Parse (str[1]);
            K = long.Parse (str[2]);

            A = new long[N];
            B = new long[M];

            List<long> a = new List<long> ();
            List<long> b = new List<long> ();

            a.Add (0);
            b.Add (0);

            str = Console.ReadLine ().Split (' ');
            for (int i = 0; i < N; i++)
            {
                A[i] = int.Parse (str[i]);
                a.Add (a[i] + A[i]);
            }

            str = Console.ReadLine ().Split (' ');
            for (int i = 0; i < M; i++)
            {
                B[i] = int.Parse (str[i]);
                b.Add (b[i] + B[i]);
            }

            int ans = 0;
            int j = M;
            for (int i = 0; i < N + 1; i++)
            {
                if (a[i] > K) break;
                while (b[j] > K - a[i])
                {
                    j -= 1;
                }
                ans = Max (ans, i + j);
            }

            Console.WriteLine (ans);
        }
    }
}

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

#define ll long long int
#define str string

ll MOD = 1000000007, INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Max = INF, Min = -1;
ll a = 0, b = 0, c = 0, n = 0, m = 0, kiroku = 0, sum = 0, MASK = 0;
ll A[50000][3] = {}, B[500000] = {}, dp1[200000][3], rui[500000] = {}, dp2[1 << 12] = {};
int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
vector <ll> v;
str S, T;
bool check = true, check2 = false;

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

int main() {
	//Code Line
	cin >> a >> b;

	vector<ll> v;
	c = gcd(a, b);

	for (int i = 2; i <= sqrt(c); i++) {
		if (c % i == 0) {
				while (c % i == 0) c /= i;
				sum++;
			}
		}
	if (c != 1) sum++;
cout << sum + 1 << endl;
	return 0;
}


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

int main(){
int h,w,i,j,ans=0;
cin>>h>>w;
string s[h];
for(i=0;i<h;i++)cin>>s[i];
int l[h][w],r[h][w],t[h][w],b[h][w];
for(i=0;i<h;i++)
{
for(j=0;j<w;j++)
{
if(s[i][j]=='#'){l[i][j]=0;t[i][j]=0;}
else {l[i][j]=1;t[i][j]=1;if(j-1>=0)l[i][j]+=l[i][j-1];if(i-1>=0)t[i][j]+=t[i-1][j];}
}
}

for(i=h-1;i>=0;i--)
{
for(j=w-1;j>=0;j--)
{
if(s[i][j]=='#'){r[i][j]=0;b[i][j]=0;}
else{r[i][j]=1;b[i][j]=1;if(j+1<w)r[i][j]+=r[i][j+1];if(i+1<h)b[i][j]+=b[i+1][j];}
}
}

for(i=0;i<h;i++)
for(j=0;j<w;j++)
{
if(s[i][j]=='.')
{
ans=max(ans,l[i][j]+r[i][j]+t[i][j]+b[i][j]-3);
}
}
cout<<ans;
}

Measured memory_bytes: 68864
#include<bits/stdc++.h>
using namespace std;
int n,m;
int vis[100000+5],ans[100000+5];
int main() {
    cin>>n>>m;
    vector<int> adj[n+2];
    for(int i=0;i<m;++i) {
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);

    }
    queue<int> q;
    q.push(1);
    while(!q.empty()) {
        int u = q.front();
        q.pop();
        vis[u] = 1;
        for(int i=0;i<adj[u].size();++i) {
            if(!vis[adj[u][i]]) {
                ans[adj[u][i]] = u;
                vis[adj[u][i]] = 1;
                q.push(adj[u][i]);

            }

        }

    }
    int flag = 0;
    for(int i=1;i<=n;++i) {
        if(!vis[i]) {
            flag = 1;
            break;

        }

    }
    if(flag) {
        cout<<"No";

    } else {
        cout<<"Yes\n";
        for(int i=2;i<=n;++i) {
            cout<<ans[i]<<"\n";

        }

    }
    return 0;

}


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

int main(){
  int n;
  cin >> n;
  int odd = (n+2-1)/2;
  double ans = double(odd)/n;
  printf("%.10f",ans);
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main() {
	int A, B;
	cin >> A >> B;
	if (B%A == 0) {
		cout << A + B << endl;
	}
	else {
		cout << B - A << endl;
	}
	return 0;
}

Measured memory_bytes: 256
(defn input []
  (-> (read-line) Integer/parseInt))

(defn countd [n]
  (->> (range 1 (inc n))
    (filter #(zero? (rem n %)))
    count))

(defn b105 [N]
  (count
    (filter #(= 8 (countd %)) (range 105 (inc N) 2))))

(-> (input)
  b105
  println)

Measured memory_bytes: 65640
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define N 1000000007
int main() {
  int64_t n, k, pos = 0, neg = 0, zero = 0, flag = 0, negct = 0,
                posct = 0, zeroct = 0;
  cin >> n >> k;
  boost::multiprecision::cpp_int ans=1;
  int64_t a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > 0)
      pos++;
    else if (a[i] < 0)
      neg++;
    else
      zero++;
  }
  sort(a, a + n);
  if (k % 2 == 1 && pos + zero == 0)
    flag = 1;

  if (flag == 1) {
    while (k > 0) {
      ans *= a[neg - 1 - negct];
      ans%=N;
      negct++;
      k--;
    }
    ans%=N;
    while(ans<0){
      ans+=N;
    }
    cout << ans;
    return 0;
  }
  
  while (k >= 2) {
    if (a[0 + negct] * a[1 + negct] >= a[n - 1 - posct] * a[n - 2 - posct]) {
      ans *= a[0 + negct];
      ans*=a[1 + negct];
      ans%=N;
      negct += 2;
      k -= 2;
    } else {
      ans *= a[n - 1 - posct];
      ans*=a[n - 2 - posct];
      ans%=N;
      posct += 2;
      k -= 2;
    }
  }
  if (k == 1) {
    ans *= a[n - 1 - posct];
  }
  ans%=N;
  while(ans<0){
    ans+=N;
  }
  cout << ans;
  return 0;
}

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

using namespace std;

typedef long long ll;

void cldflm()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);

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

int main()
{

	cldflm();

	int t;
	cin >> t;

	if (t >= 30)
		cout << "Yes";
	else
		cout << "No";



	return 0;
}



Measured memory_bytes: 3596
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <unordered_map>
#define maxn 100005
#define mod 998244353
using namespace std;
typedef long long LL;
int main()
{
    LL x,y;
    scanf("%lld%lld",&x,&y);
    LL ans=x-x/y*y;
    x=y-ans;
    printf("%lld",min(x,ans));
    return 0;
}


Measured memory_bytes: 760
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	week := []string{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"}
	index := -1
	for i, v := range week {
		if v == s {
			index = i
			break
		}
	}
	fmt.Println(7 - index)
}


Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
using namespace std;
#define rep(i,n)for(int i=0;i<n;i++)
int n,m,a,b,cost,time,k,p,q,r;
int c[100][100];
int t[100][100];
int main() {
	while(scanf("%d %d",&n,&m),n) {
		fill(c[0],c[0]+100*100,1<<27);
		fill(t[0],t[0]+100*100,1<<27);
		rep(i,n) {
			scanf("%d %d %d %d",&a,&b,&cost,&time);
			a--;b--;
			c[a][b]=c[b][a]=cost;
			t[a][b]=t[b][a]=time;
		}
		rep(k,m)rep(i,m)rep(j,m) {
			c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
			t[i][j]=min(t[i][j],t[i][k]+t[k][j]);
		}
		scanf("%d",&k);
		rep(i,k) {
			scanf("%d %d %d",&p,&q,&r);
			p--;q--;
			if(r)printf("%d\n",t[p][q]);
			else printf("%d\n",c[p][q]);
		}
	}
}

Measured memory_bytes: 1104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
struct edge { int to, cost; };
typedef pair<int, int>P;
#define PI 3.14159265359
#define MOD 1000000007
const int MAX =510000;

int main(){
  	ll N,K;
  	cin >>N>>K;
  	ll ans=0;
  for(int i=K;i<=N+1;i++){
  	ans=ans+i*(N-i+1)+1;
  	ans%=MOD;
  }
  cout<<ans;
}


Measured memory_bytes: 3656
from collections import Counter

N = int(input())
S = []
for _ in range(N):
    S.append(input())

mycounter = Counter(S).most_common()[::1]
result = []
maxcount = mycounter[0][1]
for i in range(len(mycounter)):
    if maxcount == mycounter[i][1]:
        result.append(mycounter[i][0])

result.sort()
for j in range(len(result)):
    print(result[j])

Measured memory_bytes: 45040
#include <stdio.h>

int main(void)
{
	int i;
	int j;
	
	for (i = 1; i <= 9; i++){
		j = 0;
		for (j = 1; j <= 9; j++){
			printf("%dx%d=%d\n", i, j, i * j);
		}
	}
	return (0);
}

Measured memory_bytes: 520
#include<iostream>	// 入出力
#include<stdio.h>	// prllf()が使える 小数は%fで
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか

using namespace std;

using ll = long long;


int main()
{

	ll N;
	cin >> N;

	vector<ll> a(N);

	ll maxi = 0;
	ll mini = 0;

	for (ll i = 0; i < N; ++i)
	{
		ll c;
		cin >> c;

		a[i] = c;

		if (c > a[maxi])
		{
			maxi = i;
		}
		if (c < a[mini])
		{
			mini = i;
		}

	}
	
	vector<string> ans;

	if (abs(a[maxi]) > abs(a[mini]))
	{
		for (ll i = 0; i < N - 1; ++i)
		{
			for (int j=0; a[i] > a[i + 1]; ++j)
			{
				a[i + 1] += a[maxi];
				string str = "" + to_string(maxi + 1) + " " + to_string(i + 1 + 1);

				ans.emplace_back(str);

			}

			if (a[i + 1] > a[maxi])
			{
				maxi = i + 1;
			}
		}

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

		for(string s:ans)
		{
			cout << s << endl;
		}
	}
	else
	{
		for (ll i = N-1; i > 0; --i)
		{
			for (int j = 0; a[i-1] > a[i]; ++j)
			{

				a[i-1] += a[mini];
				string str = "" + to_string(mini + 1) + " " + to_string(i);

				ans.emplace_back(str);

			}
			if (a[i - 1] < a[mini])
			{
				mini = i - 1;
			}
		}
		cout << ans.size() << endl;

		for (string s : ans)
		{
			cout << s << endl;
		}
	}


	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 58;
const int MOD = 1000000007;
const int MAX_N = 200100;

int dp[110][2][5]; //桁数、この桁までの数字がピッタリかより小さいか（桁DP恒例smallerの考え方）、0でない数字の個数
signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    string N;
    int K;
    cin >> N >> K;
    REP(i, 110)
    {
        REP(j, 2)
        {
            REP(k, 5)
            {
                dp[i][j][k] = 0;
            }
        }
    }

    dp[0][0][0] = 0;
    dp[0][1][0] = 1; //初期値

    REP(i, N.size())
    {
        int c = N[i] - '0';

        REP(j, 4)
        {
            dp[i + 1][0][j] += dp[i][0][j];         //smallerから0を追加->smaller
            dp[i + 1][0][j + 1] += dp[i][0][j] * 9; //smallerから1~9を追加->smaller
            if (c == 0)                             //c=0かどうかで、notsmallerからの挙動が若干異なる
            {
                dp[i + 1][1][j] += dp[i][1][j]; //notsmallerからc==0を追加->notsmaller
            }
            else
            {
                dp[i + 1][0][j] += dp[i][1][j];               //notsmallerから0を追加->smaller
                dp[i + 1][0][j + 1] += dp[i][1][j] * (c - 1); //notsmallerから1~cの数字を追加できる->smaller
                dp[i + 1][1][j + 1] += dp[i][1][j];           //notsmallerからc!=0を追加->notsmaller
            }
        }
        dp[i + 1][0][0] = 1; //この桁まで全部ゼロパターン
    }
    // REP(i, N.size() + 1)
    // {
    //     REP(j, 2)
    //     {
    //         REP(k, 4)
    //         {
    //             cout << dp[i][j][k] << " ";
    //         }
    //         cout << endl;
    //     }
    //     cout << endl;
    // }

    cout << dp[N.size()][0][K] + dp[N.size()][1][K] << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] height = new int[N];
    int[] beauty = new int[N];
    for (int i = 0; i < N; ++i) {
      height[i] = sc.nextInt();
    }
    for (int i = 0; i < N; ++i) {
      beauty[i] = sc.nextInt();
    }

    long maxBeauty = solve(height, beauty);
    System.out.println(maxBeauty);
  }

  private static long solve(int[] height, int[] beauty) {
    int base = 1;
    int n = height.length;
    while (base <= n) {
      base *= 2;
    }
    long[] tree = new long[2 * base];
    long[] dp = new long[n + 1];
    for (int flower = 0; flower < n; ++flower) {
      int x = height[flower] + base;
      long best = 0;
      while (x > 1) {
        if (x % 2 == 1) {
          best = Math.max(best, tree[x - 1]);
        }
        x /= 2;
      }
      dp[height[flower]] = best + beauty[flower];
      for (int i = base + height[flower]; i >= 1; i /= 2) {
        tree[i] = Math.max(tree[i], dp[height[flower]]);
      }
    }

    long answer = Integer.MIN_VALUE;
    for (int i = 0; i <= n; i++) {
      answer = Math.max(answer, dp[i]);
    }
    return answer;
  }
}


Measured memory_bytes: 110152
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define show(...) cerr << "[" << #__VA_ARGS__ << "] :", debug_out(__VA_ARGS__)
#else
#define show(...) 42
#endif


#define f first
#define s second
#define endl "\n"
#define pb push_back
#define  oo 0x3f3f3f3f
#define limit 1000000007
#define two pair<int,int>
#define int long long int
#define mod(x,m) ((x%m+m)%m)
#define all(v) v.begin(),v.end()
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define fori(x,n) for(int i = x; i < n; i++)
#define forj(y,m) for(int j = y; j < m; j++)
#define fork(z,p) for(int k = z; k < p; k++)
#define fastio std::ios::sync_with_stdio(false)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define input_from_file  freopen("input.txt", "r", stdin);

signed main(){
  //input_from_file;
  int r; cin>>r;
  cout<<r*r<<endl;
}


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

int main(){
  int r,D,x;
  cin>>r>>D>>x;
  vector<int> xx(100000);
  xx[2000]=x;
  for(int i=2000; i<=2010; i++){
    xx[i+1]=r*xx[i]-D;
  }
  for(int i=2001; i<=2010; i++){
    cout<<xx[i]<<endl;
  }
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
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; }



int main(int argc, char const *argv[]) {
  int h, w, n;
  cin >> h >> w >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> rec;
  rep(i,n){
    rep(j,a[i]) rec.pb(i+1);
  }
  bool r = false;
  for (int i = 0; i < h * w; i += w) {
    //printf("i is %d\n", i);
    vector<int> tmp;
    for (int j = i; j < i + w; j++) tmp.pb(rec[j]);
    if (r) reverse(all(tmp));
    r = !r;
    rep(j,sz(tmp)) cout << tmp[j] << " ";
    cout  << endl;
  }
  return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
// Binary Indexed Tree 2D
template <class Abel> struct BIT2D {
    const Abel UNITY_SUM = 0; // to be set
    vector<vector<Abel>> dat;

    BIT2D(int n = 1, int m = 1) : dat(n + 1, vector<Abel>(m + 1, UNITY_SUM)) {}
    void init(int n, int m) {
        dat.assign(n + 1, vector<Abel>(m + 1, UNITY_SUM));
    }

    /* add x on the point (a, b) */
    inline void add(int a, int b, Abel x) {
        for (int i = a; i < (int)dat.size(); i += i & -i)
            for (int j = b; j < (int)dat[0].size(); j += j & -j)
                dat[i][j] = dat[i][j] + x;
    }

    inline Abel sum(int p, int q) {
        Abel res = UNITY_SUM;
        for (int i = p; i > 0; i -= i & -i)
            for (int j = q; j > 0; j -= j & -j)
                res = res + dat[i][j];
        return res;
    }

    /* a1 <= x < b1, a2 <= y < b2, 1-indexd */
    inline Abel sum(int a1, int a2, int b1, int b2) {
        return sum(b1 - 1, b2 - 1) - sum(a1 - 1, b2 - 1) - sum(b1 - 1, a2 - 1) +
               sum(a1 - 1, a2 - 1);
    }

    /* debug */
    void print() {
        for (int i = 1; i < (int)dat.size(); ++i) {
            for (int j = 1; j < (int)dat[0].size(); ++j)
                cout << sum(i, j, i + 1, j + 1) << ",";
            cout << "¥n";
        }
    }
};

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

    int N, M, Q;
    cin >> N >> M >> Q;
    BIT2D<int> bt(N, N);
    REP(i, M) {
        int l, r;
        cin >> l >> r;
        bt.add(l, r, 1);
    }
    REP(i, Q) {
        int p, q;
        cin >> p >> q;
        cout << bt.sum(p, p, q + 1, q + 1) << "\n";
    }

    return 0;
}


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

const int N=200100;
int ch[N][2],mn1[N],fa[N],mn2[N],a[N],sz[N],n,rt;
bool gs(int x){return ch[fa[x]][1]==x;}
void ps(int x){
	int lc=ch[x][0],rc=ch[x][1];
	sz[x]=sz[lc]+sz[rc]+1;
	mn1[x]=mn1[lc];mn2[x]=mn2[lc];
	if(sz[lc]&1){
		mn1[x]=min(mn1[x],mn1[rc]);
		mn2[x]=min(mn2[x],min(mn2[rc],a[x]));
	}else{
		mn1[x]=min(mn1[x],min(mn2[rc],a[x]));
		mn2[x]=min(mn2[x],mn1[rc]);
	}
}


void rot(int x){
	int o=fa[x],k=gs(x);
	fa[ch[o][k]=ch[x][!k]]=o;
	fa[x]=fa[o];
	if(fa[o])ch[fa[o]][gs(o)]=x;
	fa[ch[x][!k]=o]=x;ps(o);
}

void splay(int x,int y=0){
	for(;fa[x]!=y;rot(x))
		if(fa[fa[x]]!=y)rot(gs(x)^gs(fa[x])?x:fa[x]);
	ps(x);if(!y)rt=x;else ps(y);
}

int merge(int x,int y){
	if(!x||!y)return x+y;
	for(;ch[x][1];x=ch[x][1]);splay(x);
	ch[x][1]=y;fa[y]=x;ps(x);return x;
}
set<int>S;
int b[N];
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	mn1[0]=mn2[0]=n+1;
	for(int i=1;i<=n;++i){
		cin>>a[i];b[a[i]]=i;
		sz[i]=1;mn1[i]=a[i];mn2[i]=n+1;
		rt=merge(rt,i);
	}
	S.insert(mn1[rt]);
	for(int i=1;i<=n;i+=2){
		int x=b[*S.begin()];S.erase(S.begin());splay(x);
		int y=b[mn1[ch[x][1]]];splay(y,x);
		cout<<a[x]<<' '<<a[y]<<" \n"[i==n-1];
		int u=ch[x][0],v=ch[y][0],w=ch[y][1];
		fa[u]=fa[v]=fa[w]=0;
		if(u)S.insert(mn1[u]);
		if(v)S.insert(mn1[v]);
		if(w)S.insert(mn1[w]);
	}
	return 0;
}


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

int TasteOfApple(int N, int L){
    vector<int>a(N);
    int taste=0;
    for(int i=0;i<N;i++){
        a.at(i)=L+i-1+1;
        taste += a.at(i);
    }
    sort(a.begin(),a.end());
    if(a.at(N-1)<0){
        taste -= a.at(N-1);
    }
    else{
        for(int i=0;i<N;i++){
            if(a.at(i)>=0){
                taste -= a.at(i);
                break;
            }
        }
    }
    return taste;
}

int main(){
    int N,L; cin >> N >> L;
    cout << TasteOfApple(N,L) << endl;
    return 0;
}



Measured memory_bytes: 256
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    S = input().rstrip()
    T = input().rstrip()
    slen = len(S)
    tlen = len(T)
    if slen < tlen:
        print('UNRESTORABLE')
        return 0

    changable_idx = None
    for i in range(slen-tlen+1):
        for idx,t in enumerate(T):
            if S[i+idx] != '?' and S[i+idx] != t:
                break
        else:
            changable_idx = i

    if changable_idx != None:
        S = S[:changable_idx] + T + S[changable_idx+tlen:]
        print(S.replace('?','a'))
    else:
        print('UNRESTORABLE')
        return 0

if __name__ == '__main__':
    main()

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

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

ll A[1000000];

int main() {
    int n; cin >> n;
    ll MIN = 100010;
    ll MAX = 0;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
        MIN = min(MIN,a[i]-1);
        MAX = max(MAX,a[i]+1);
        A[a[i]]++;
        A[a[i]-1]++;
        A[a[i]+1]++;
    }
    

    ll ans = 0;
    for(int j = MIN; j <= MAX; j++){
        ans = max(ans,A[j]);
    }
    cout << ans << endl;
}

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

using namespace std;

int main(void)
{
	int n,m;
	cin>>n>>m;
	int a[m];
	for(int i = 0; i < m; i++){
		cin>>a[i];
	}
	
	int ans = n;
	for(int i = 0; i < m; i++){
		ans-=a[i];
	}
	if(ans < 0){
		cout<<-1<<endl;
		return 0;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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> inline void out(T a){ cout << a << '\n'; }
void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;}
//void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;}


const ll INF=1e18;
const int mx=200005;

bool dp1[35],dp2[3005];

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    dp1[0]=1;
    for(int i=0;i<=30;i++){
        if(dp1[i]){
            if(i+a<=30) dp1[i+a]=1;
            if(i+b<=30) dp1[i+b]=1;
        }
    }
    dp2[0]=1;
    for(int i=0;i<=3000;i++){
        if(dp2[i]){
            if(i+c<=3000) dp2[i+c]=1;
            if(i+d<=3000) dp2[i+d]=1;
        }
    }
    int sug,wat;
    int x=0,y=1;
    for(int i=100;i<=f;i+=100){
        if(!dp1[i/100]) continue;
        for(int j=0;j<=f-i;j++){
            if(j>e*(i/100)) break;
            if(!dp2[j]) continue;
            if(x*(i+j)<=100*j*y){
                x=100*j;
                y=i+j;
                sug=j;
                wat=i;
            }
        }
    }
    cout<<sug+wat<<' '<<sug<<endl;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//template end



int main(){
   int h,n; scanf("%d%d",&h,&n);
   ll sum=0;
   rep(i,0,n){int tmp; scanf("%d",&tmp); sum+=tmp;}
   printf(h-sum<=0?"Yes\n":"No\n");
   return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        double[] a = new double[n+1];
        for(int i = 1; i <= n; i++){
            double tmp = scanner.nextDouble();
            a[i] = tmp * (tmp + 1.0) / 2.0 /tmp + a[i-1];
        }
        double max = 0.0;
        for(int i = 0; i <= n-k; i++){
            double cur = a[i+k] - a[i];
            if(cur > max){max = cur;}
        }
        System.out.println(max);
    }
}



Measured memory_bytes: 162776
#include<stdio.h>
int main(){
  int length,data[10000],i,j,flag,count=0;


  //input
  scanf("%d",&length);

  for(i=0;i<length;i++){
    scanf("%d",&data[i]);
  }

for(i=0;i<length;i++){
	flag=1;
  for(j=2;j*j<=data[i];j++){
		if(data[i]%j==0){
			flag=0;
			break;
		}
	}
	if(flag)count++;
}

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



Measured memory_bytes: 2036
def comp(T,P):
    if T == P:
        return True
    else:
        return False

def main():
    T = input()
    P = input()
    n1,n2 = len(T),len(P)

    for i in range(n1-n2+1):
        if comp(T[i:i+n2],P):
            print(i)

if __name__ == "__main__":
    main()



Measured memory_bytes: 7512
#include <iostream>

using namespace std;

int main(){
    string s;
    cin >> s;
    int N = s.size();
    int cnt_g = 0, cnt_p = 0;
    for(int i = 0; i < N; i++){
        if(s[i] == 'g') cnt_g++;
        else cnt_p++;
    }
    cout << N/2 - cnt_p << endl;
}

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

using namespace std;

#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mmp make_pair
#define st first
#define nd second
#define rd third
#define ll long long
#define pii pair <int, int>
#define tri pair <pii, int>
#define itr pair <int, pii>
#define PQ priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define Rep(i, n) for (int (i) = 0; (i) <= (int)(n); i++)
#define For(i, a, n) for (int (i) = (a); (i) <= (int)(n); i++)
#define Forn(i, a, n) for (int (i) = (a); (i) >= (int)(n); i--)
#define FORD(i, n) for (int (i) = (int)(n) - 1; i>= 0; i--)
#define rep(i, n) for (int (i) = 1; (i) <= (int)(n); i++)
#define EACH(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define DEBUG(x) cout << #x << " = " << (x) << endl;
#define PR(a, n) {cout << #a << " = "; FOR(_, 1, n) cout << a[_] << ' '; puts(""); }
#define PRO(a, n) { cout << #a << " = "; REP(_, n) cout << a[_] << ' '; puts(""); }
#define pi 3.1415926535897932384626433832795028841971
//#define LOCAL

const int INF = 1 << 30;
const int N = 1005;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

inline ll read()
{
	ll x = 0; int f = 1, c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
	return x * f;
}

int n; 
int a[3][3]; 
map <int, bool> mp; 

int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	
	REP(i, 3) REP(j, 3) a[i][j] = read(); 
	n = read(); 
	REP(i, n) mp[read()] = true; 
	REP(i, 3) if (mp[a[i][0]] == 1 && mp[a[i][1]] == 1 && mp[a[i][2]] == 1)
	{
		puts("Yes"); 
		return 0; 
	}
	else if (mp[a[0][i]] == 1 && mp[a[1][i]] == 1 && mp[a[2][i]] == 1)
	{
		puts("Yes"); 
		return 0; 
	}
	if (mp[a[0][0]] == 1 && mp[a[1][1]] == 1 && mp[a[2][2]] == 1)
	{
		puts("Yes"); 
		return 0; 
	}
	if (mp[a[0][2]] == 1 && mp[a[1][1]] == 1 && mp[a[2][0]] == 1)
	{
		puts("Yes"); 
		return 0; 
	}
	puts("No"); 
	
	return 0;
}


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

int main()
{
    string S;
    cin>>S;
    if (S=="SUN")
        cout <<"7";
    if (S=="MON")
        cout <<"6";
        if (S=="TUE")
        cout <<"5";
        if (S=="WED")
        cout <<"4";
        if (S=="THU")
        cout <<"3";
        if (S=="FRI")
        cout <<"2";
        if (S=="SAT")
        cout <<"1";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
using namespace std;
bool find(vector<char>l, char c) { for (int i = 0; i < l.size(); i++)if (l[i] == c)return true; return false; }
int main() {
	vector<char>l;
	string s; cin >> s;
	for (int i = 0; i < s.size(); i++){
		if (find(l, s[i])) { cout << "no\n"; return 0; }
		else l.push_back(s[i]);
	}
	cout << "yes\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=200005;
const int mo=1000000007;
int n,m;
char s[N];
namespace solver1{
	int f[N][2][2];
	void solve(){
		f[1][0][0]=f[1][1][1]=1;
		For(i,2,n) For(j,0,1) For(k,0,1) For(l,0,1)
			if (k|l) f[i][j][l]=(f[i][j][l]+f[i-1][j][k])%mo;
		int ans=0;
		For(i,0,1) For(j,0,1)
			if (i|j) ans=(ans+f[n][i][j])%mo;
		printf("%d\n",ans);
	}
}
namespace solver2{
	int pre[N],mn;
	int g[N],h[N];
	void solve(){
		pre[1]=1;
		mn=1<<30;
		For(i,2,m)
			pre[i]=(s[i]==s[i-1]?pre[i-1]+1:1);
		For(i,2,m)
			if (s[i-1]=='R'&&s[i]!='R'){
				if (pre[i-1]==i-1){
					if ((i-1)%2==0) mn=min(mn,pre[i-1]+1);
					else mn=min(mn,pre[i-1]);
				}
				else if (pre[i-1]%2)
					mn=min(mn,pre[i-1]);
			}
		++mn;
		//printf("%d\n",mn);
		g[0]=h[0]=1;
		For(i,1,n){
			g[i]=((i>=2?h[i-2]:0)+mo-(i>=mn+2?h[i-mn-2]:0))%mo;
			h[i]=(g[i]+(i>=2?h[i-2]:0))%mo;
			//printf("%d %d\n",g[i],h[i]);
		}
		int ans=0;
		for (int i=2;i<=n&&i<=mn;i+=2)
			ans=(ans+1ll*i*g[n-i])%mo;
		printf("%d\n",ans);
	}
}
int main(){
	scanf("%d%d%s",&n,&m,s+1);
	if (s[1]=='B'){
		For(i,1,m)
			if (s[i]=='B') s[i]='R';
			else s[i]='B';
	}
	bool flag=0;
	For(i,1,m)
		if (s[i]!=s[1])
			flag=1;
	if (!flag)
		solver1::solve();
	else solver2::solve();
} 


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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}


/*FUNCs=================================================*/

vector<int> to[200005];
vector<int> counter;

void dfs(int now_v, int p = -1) {
    for(int next : to[now_v]) {
        if (next == p) continue;
        counter[next] += counter[now_v];
        dfs(next, now_v);
    }
}
/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    
    int n, q, a, b, p, x; cin >> n >> q;
    rep(i, n-1) {
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    counter.resize(n);
    rep(i,q) {
        cin >> p >> x;
        --p;
        counter[p] += x;
    }
    dfs(0);
    rep(i,n) cout << counter[i] << '\n';
}

Measured memory_bytes: 23552
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;

string reverseStr(string& str)
{
    int n = str.length();

    // Swap character starting from two
    // corners
    for (int i = 0; i < n / 2; i++)
        swap(str[i], str[n - i - 1]);
    return str;
}
int main(){
    string S;
    int Q;
    cin >> S >> Q;
    int T, F;
    string C;
    string beg="", end="";
    // false is normal
    bool flag = false, flag2;
    rep(i, Q) {
        cin >> T;
        if (T == 1)
            flag = !flag;
        else {
            cin >> F >> C;
            flag2 = ((!flag&& F == 1) || (flag&& F == 2));
            if (flag2) beg += C;
            else end += C;
        }
    }
    if (!flag) {
        if (beg != "") S = reverseStr(beg) + S;
        if (end != "") S = S + end;
    }
    else {
        if (end != "") S = reverseStr(end) + reverseStr(S);
        if (beg != "") S = S + beg;
    }
    cout << S << endl;



	return 0;
}


Measured memory_bytes: 1348
// AOJ 0544
#include<cstdio>
#define rep(i,a) for( int i = 0; i != (a); ++i )

int N, M;
int ins[1000], dice[1000];
int pos, ans;

int main()
{
	while( scanf( "%d%d", &N, &M ), N|M )
	{
		ans = 0;
		pos = 0;

		rep( i, N )
			scanf( "%d", ins+i );

		rep( j, M )
			scanf( "%d", dice+j );

		rep( j, M )
		{
			if( pos+dice[j] >= N-1 )
			{
				ans = j+1;
				break;
			}
			pos += dice[j];
			if( pos+ins[pos] >= N-1 )
			{
				ans = j+1;
				break;
			}
			pos += ins[pos];
		}

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

	return 0;
}

Measured memory_bytes: 1036
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n,k = I2()
    p = Intl()
    s = 0
    for i in range(k):
        s += (p[i] + 1)/2
    ans = s
    for i in range(k,n):
        s += (p[i] + 1)/2
        s -= (p[i-k] + 1)/2
        ans = max(ans,s)
    print(ans)

Measured memory_bytes: 33228
#include <stdio.h>

int main(void)
{
    int N, Btou, Fkai, Rban, Vnin;
    int array[5][4][11] = {0};
    int i, j, k;
    scanf("%d", &N);

    for (i = 0; i < N; ++i){
        scanf("%d %d %d %d", &Btou, &Fkai, &Rban, &Vnin);
        array[Btou][Fkai][Rban] += Vnin;
    }

    for (i = 1; i < 5; ++i){
        for (j = 1; j < 4; ++j){
            for (k = 1; k < 11; ++k){
                printf(" %d", array[i][j][k]);
            }
            puts("");
        }
        if (i != 4){
            puts("####################");
        }
    }
    return 0;
}

Measured memory_bytes: 608
#include <stdio.h>

int main(void){
    int n,x,y,h,w,sum,sum1,i;
    for(;sum=0,scanf("%d",&n),n;){
        for(i=0;i<n;i++){
            scanf("%d %d %d %d",&x,&y,&h,&w);
            sum1=x+y+h;
            if(sum1 <= 60 && w <= 2)
                sum+=600;
            else if(sum1 <= 80 && w <= 5)
                sum+=800;
            else if(sum1 <= 100 && w<= 10)
                sum+=1000;
            else if(sum1 <= 120 && w<= 15)
                sum+=1200;
            else if(sum1 <= 140 && w<=20)
                sum+=1400;
            else if(sum1 <= 160 && w<=25)
                sum+=1600;
        }
        printf("%d\n",sum);
    }
    return 0;
}

Measured memory_bytes: 600
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll x, n, ans = 0;
    cin >> x >> n;
    vector<ll> p(n), f(200);
    for (ll &e : p)
        cin >> e, f[e] = 1;
    for (ll i = 0; i < 200; i++)
        if (!f[i] && abs(i - x) < abs(ans - x))
            ans = i;
    cout << ans;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
//const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
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; }
using namespace std;
typedef pair<int64_t, int64_t> P;

int main(){
    int N, M;
    cin >> N >> M;
    if (N == M) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
def ary(r, c, v): return [[v for _ in range(c)] for _ in range(r)]
n, m = map(int, input().split())
e = ary(n, n, False)
for i in range(m):
    a, b = map(int, input().split())
    #頂点を0-indexedに変換
    a -= 1
    b -= 1
    e[a][b] = True
    e[b][a] = True
ps = set()
ps.add('0')

for cnt in range(1, n):
    t = set()
    for p in ps:
        for i in map(str, range(1, n)):
            if not(i in p):
                t.add(p + i)
    ps = t.copy()

ans = 0
for p in ps:
    flg = True
    for i in range(n - 1):
        a = int(p[i])
        b = int(p[i + 1])
        if not e[a][b]:
            flg = False
            break
    if flg:
        ans += 1

print(ans)

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

typedef pair<int,int> P;

// A[i] := i ツ氾板姪堋づ個姪「ツ妥ィツづーツ嘉ーツつュツづ個づ可つゥツつゥツづゥツ篠楪甘?
int A[16] = {0};
int ans = 0;

void solve(vector<P> v, int pos, int total, int AC){
	if( pos == v.size() ){
		ans = max( ans , AC );
		return ;
	}
	
	int time = v[pos].first;
	int i = v[pos].second;
	if( total + A[i] <= time ){
		solve( v , pos+1 , total + A[i] , AC+1 );
	}
	solve( v , pos+1 , total , AC );
}

int main(){
	int n;
	vector<P> v;
	
	cin >> n;
	for(int i=0 ; i < n ; i++ ){
		int a, b;
		cin >> a >> b;
		A[i] = a;
		v.push_back( P(b,i) );
	}
	sort( v.begin() , v.end() );
	solve( v , 0 , 0 , 0 );
	cout << ans << endl;
}

Measured memory_bytes: 0
import sys, math
from bisect import bisect_right
sys.setrecursionlimit(10**9)

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N, C, K = mi()
    T = [ii() for i in range(N)]
    T.sort()

    cnt = 0
    i = 0

    while i < N:
        t = T[i]+K
        b = bisect_right(T, t)
        i = min(i+C, b)
        cnt += 1

    print(cnt)



if __name__ == "__main__":
    main()

Measured memory_bytes: 13304
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define T int
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
 
ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}
 
int main(){
    IOS
    
	int r;
  	cin>>r;
  	cout<<3*r*r;
    
}

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

int main()
{
    int i,o,t,j,l,s,z;
    scanf("%d%d%d%d%d%d%d", &i, &o, &t, &j, &l, &s, &z);
    long long ans1 = 0, ans2 = 0;
    ans1 += o;
    ans2 += o;
    ans1 += (i / 2) * 2;
    ans1 += (j / 2) * 2;
    ans1 += (l / 2) * 2;
    if (i > 0 && j > 0 && l > 0)
        ans2 += 3;
    i--;
    j--;
    l--;
    ans2 += (i / 2) * 2;
    ans2 += (j / 2) * 2;
    ans2 += (l / 2) * 2;
    printf("%lld\n", max(ans1, ans2));
}

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

int main() {
	string s;
	stack<char> p;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (p.empty()) {
			p.push(s[i]);
		}
		else {
			if (p.top() == 'S' && s[i] == 'T')p.pop();
			else p.push(s[i]);
		}
	}
	cout << p.size() << endl;
}

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

using namespace std;
typedef long long int ll;
int main() {
    
    ll n, a[100001], q, i, b, c, sum=0, box[100001]={};
    cin>>n;
    for(i=1;i<=n;i++)
    {
        scanf("%lld", &a[i]);
        sum+=a[i];
        box[a[i]]++;
    }
    cin>>q;
    for(i=1;i<=q;i++)
    {
        scanf("%lld %lld", &b, &c);
        sum+=((c-b)*box[b]);
        box[c]+=box[b];
        box[b]=0;
        printf("%lld\n", sum);
    }
    
    
    return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int inn[100] = {0};

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

  int ans = 0;
  for (int i = 0 ; i  < N; i++)
  {
      int cansee = 1;
      for (int j = 0; j < i; j++)
      {
          if (inn[j]>inn[i])
            cansee = 0;
      }
      if (cansee)
        ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256