akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000
using namespace std;
bool isPrime(int x){
    if(x < 2) return false;
    if(x == 2) return true;
    if(x % 2 == 0) return false;
    for(int i=3; i*i<=x; i+=2){
        if(x % i == 0) return false;
    }
    return true;
}
int main(){
    int n;
    while(cin >> n,n){
        int ans = 0;
        for(int i=2; i<n/2+1; i++){
            if(!isPrime(i)) continue;
            int j = n-i;
            if(isPrime(j)) {
                //cout << j << endl;
                ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 2984
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClassLibrary1
{
    public class ListNode
    {
        public int val;
        public ListNode next;
        public ListNode(int x) { val = x; }
    }


    public class Class1
    {
        static Dictionary<Tuple<long, long>, long> dic = new Dictionary<Tuple<long, long>, long>();


        static void Main(string[] args)
        {
            var c = ReadString().ToCharArray();
            int mid = c.Length / 2;
            var cnt = 0;
            for( int i=0; i<mid; i++)
            {
                if(c[i] != c[c.Length-1-i])
                {
                    cnt++;
                }
            }
            Console.WriteLine(cnt);

        }


        public static int Digit(long num)
        {
            // Mathf.Log10(0)はNegativeInfinityを返すため、別途処理する。
            return (num == 0) ? 1 : ((int)Math.Log10(num) + 1);
        }

        public static long nCm(long n, long m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            var a = n * nCm(n - 1, m - 1) / m;
            return a % 1000000007;
        }

        private static string ReadString()
        {
            return Console.ReadLine();
        }
        private static string[] ReadStringArr()
        {
            return Console.ReadLine().Split(' ');
        }
        private static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadLongArr()
        {
            string[] s = ReadStringArr();
            long[] l = new long[s.Length];
            for(int i=0; i<l.Length; i++)
            {
                l[i] = long.Parse(s[i]);
            }

            return l;
        }
    }

}


Measured memory_bytes: 11220
using System;
using static System.Console;

namespace AtCorder
{
	public class Program
	{
		public static void Main()
		{
			var n = int.Parse(ReadLine());

			int answer = int.MaxValue;
			int count = 0;

			for(int i = 0; n>= i * 6; i ++)
			{
				var sumA = i * 6;
				int a = 6;
				count = 0;
				while(a >= 6)
				{
					while(sumA >= a * 6)
					{
						a *= 6;
					}
					while(sumA >= a)
					{
						sumA -= a;
						// 6円の乗数の引き出し
						count++;
					}
					a /= 6;
				}

				var sumB = n - i * 6;
				int b = 9;
				while(b >= 9)
				{
					while(sumB >= b * 9)
					{
						b *= 9;
					}
					while(sumB >= b)
					{
						sumB -= b;
						// 9円の累乗の引き出し
						count++;
					}
					b /= 9;
				}

				// 1円の引き出し
				count += sumB;

				answer = Math.Min(count, answer);
			}

			WriteLine(answer);
		}
	}
}


Measured memory_bytes: 11092
s = list(input())
count_head = 0
count_tail = 0
for i in range(len(s)):
    if s[i] == "A":
        count_head = i
        break

for j in range(len(s)-1, count_head-1, -1):
    if s[j] == "Z":
        count_tail = j
        break

print(count_tail - count_head + 1)

Measured memory_bytes: 4840
c = 3.times.map { gets.split.map(&:to_i) }
d = c[0][1] - c[0][0]
e = c[0][2] - c[0][0]
if c[1][1] - c[1][0] == d &&
  c[1][2] - c[1][0] == e &&
  c[2][1] - c[2][0] == d &&
  c[2][2] - c[2][0] == e
  puts "Yes"
else
  puts "No"
end


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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int[] a = sc.IntArray();

        if (a.Length == 1)
        {
            Console.WriteLine(1);
            return;
        }

        int answer = 1;

        int before = a[0];
        int current = a[1];

        int incrementMode = 0;
        if (before < current)
        {
            incrementMode = 1;
        }
        else if (current > before)
        {
            incrementMode = 2;
        }

        for (int i = 1; i < n; i++)
        {
            before = a[i - 1];
            current = a[i];
            if (incrementMode == 0)
            {
                if (before < current)
                {
                    incrementMode = 1;
                }
                else if (before > current)
                {
                    incrementMode = 2;
                }
            }
            else if (incrementMode == 1)
            {
                if (before > current)
                {
                    answer++;
                    incrementMode = 0;
                }
            }
            else if (incrementMode == 2)
            {
                if (before < current)
                {
                    answer++;
                    incrementMode = 0;
                }
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 21728
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n+1);
    rep(i, 1, n + 1)
        cin >> v[i];
    vector<bool> vis(n+1, false);
    int sum = 0;
    int i = 1;
    // cout << "a";
    while(true)
    {
        sum++;
        if (v[i] == 2)
            return cout << sum, 0;
        if (vis[i] == true)
            break;
        vis[i] = true;
        i = v[i];
        // cout << i << " ";
    }
    cout << -1;
    return 0;
}

Measured memory_bytes: 768
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))


typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
int cell[20][20];
int w, h;
int sx, sy, gx, gy;
int ans;
void dfs(int x,int y,int count){
	if (count == 10)
		return;
	REP(i,4){
		if (0 <= x + dx[i] && x + dx[i] < w && 0 <= y + dy[i] && y + dy[i] < h&&cell[y + dy[i]][x + dx[i]] == 0){
			int x2 = x;
			int y2 = y;
			int stop = false;
			while (1){
				x2 += dx[i];
				y2 += dy[i];
				if (x2 == gx&&y2 == gy){
					ans = min(ans, count + 1);
					break;
				}
				if (0 <= x2 + dx[i] && x2 + dx[i] < w && 0 <= y2 + dy[i] && y2 + dy[i] < h){
					if (cell[y2 + dy[i]][x2 + dx[i]] == 1){
						stop = true;
						break;
					}
				}
				else
					break;
			}
			if (stop){
				cell[y2 + dy[i]][x2 + dx[i]] = 0;
				dfs(x2, y2, count + 1);
				cell[y2 + dy[i]][x2 + dx[i]] = 1;
			}
		}
	}
}
int main() {
	while (cin >> w >> h, w){
		REP(i, h){
			REP(j, w){
				cin>>cell[i][j];
				if (cell[i][j] == 2){
					sx = j;
					sy = i;
					cell[i][j] = 0;
				}
				if (cell[i][j] == 3){
					gx = j;
					gy = i;
					cell[i][j] = 0;
				}
			}
		}
		ans = 11;
		dfs(sx,sy,0);
		if (ans == 11)
			ans = -1;
		cout << ans << endl;
	}
}

Measured memory_bytes: 3060
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>

using namespace std;

#define sz			size()
#define lgt			length()
#define rep(i,n)	for (int i = 0; i < n; i++)
#define ALL(X)		(X).begin(),(X).end()
#define RALL(X)		(X).rbegin(),(X).rend()
#define pb			push_back
#define SORT(a)		sort(ALL(a));
#define RSORT(a)	sort(RALL(a));
#define mp			make_pair
#define dump(x)		cerr<<#x<<" = "<<(x)<<endl;
#define fir			first
#define sec			second

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<string> vs;

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();}
vs form(string a,char s){vs v;string b;rep(i,a.lgt){if(a[i]==s){v.pb(b);b="";}else b+=a[i];}v.pb(b);return v;}
vi formint(string a,char s){vi v;string b;rep(i,a.lgt){if(a[i]==s){v.pb(toInt(b));b="";}else b+=a[i];}v.pb(toInt(b));return v;}

const double EPS=1e-10,PI=acos(-1.0);
const int INF=2100000000;

int main(void)
{
	string a, b;
	while (cin >> a >> b){
		int res = 0;
		
		for (int i = 0; i < a.sz; i++){
			int tmp = 0;
			int cnt = i;
			for (int j = 0; j < b.sz && cnt < a.sz; j++){
				if (a[cnt] == b[j]) tmp++;
				else {
					res = max(res, tmp);
					tmp = 0;
				}
				cnt++;
			}
		}
		
		for (int i = 0; i < b.sz; i++){
			int tmp = 0;
			int cnt = i;
			for (int j = 0; j < a.sz && cnt < b.sz; j++){
				if (b[cnt] == a[j]) tmp++;
				else {
					res = max(res, tmp);
					tmp = 0;
				}
				cnt++;
			}
			res = max(res, tmp);
		}
		
		cout << res << endl;
		a.clear();
		b.clear();
	}
	
	return 0;
}

Measured memory_bytes: 944
/* ----------------------------
 * ABC 91 C
 * ---------------------------- */
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<pair<int, int>> a;
	vector<pair<int, int>> b;
	for(int i = 0; i < n; i++){
		int x, y;
		cin >> x >> y;
		a.push_back({x, y});
	}
	for(int i = 0; i < n; i++){
		int x, y;
		cin >> x >> y;
		b.push_back({x, y});
	}
	int ans = 0;
	auto x_sorter = [](pair<int, int> a, pair<int, int> b) -> bool {
		return a.first < b.first;
	};
//	auto y_sorter = [](pair<int, int> a, pair<int, int> b) -> bool {
//		return a.second < b.second;
//	};
	// a, b を x座標で昇順にソート
	sort(a.begin(), a.end(), x_sorter);
	sort(b.begin(), b.end(), x_sorter);
	
	for(auto p: b){
		int target = -1;
		int max_y = -1;
		for(int i = 0; i < a.size(); i++){
			if(a[i].first >= p.first) break;
			if(a[i].second >= p.second) continue;
			int before = max_y;
			max_y = max(max_y, a[i].second);
			if(before != max_y) target = i;
		}
		if(target == -1) continue;
		a.erase(a.begin() + target);
		++ans;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring> 
#define MAXN 5050
#define ll long long
using namespace std;
int a[MAXN], dp[MAXN][MAXN];
int n, k;
/*  
	dp[i][j]表示从前i个元素中是否可以选择一些数使得它们的和为j
				  一般情况：dp[i,j] = dp[i-1][j];
	状态转移方程：当j大于ai时：dp[i,j] = dp[i-1,j]|dp[i-1,j-ai] 
	1、排序 
	2、如果ai是不必要的元素，那么ai之前的元素都是不必要的，因此二分查找ai出现的位置 
    3、使用check函数判断当前元素x是不是必要的 ,是则返回true 不是返回false
		如果x是有用的元素，那么一定可以从n个元素中选择一些元素之和在[k-a[s], k)之间，遍历dp[n][(k-a[i], k)]即可 
		使用dp判断出所有的存在于这个区间的元素，如果能找到，说明x是有用的元素，返回true 
*/ 
bool check(int x) { 
	memset(dp, 0, sizeof(dp));
	if(x==1) {
		dp[2][0] = 1;
        dp[2][a[2]] = 1;
        for(int i = 3; i <= n; i++) 
            for(int j = 0; j <= k; j++) {
                dp[i][j] = dp[i-1][j];
                if(j >= a[i])
                    dp[i][j] = dp[i-1][j] | dp[i-1][j-a[i]];    
            }
	} 
	else {
		dp[1][0] = 1;
		dp[1][a[1]] = 1;
		for(int i = 2; i <= n; i++) 
			for(int j = 0; j <= k; j++) {
				dp[i][j] = dp[i-1][j];
				if(j >= a[i] && x != i) 
					dp[i][j] = dp[i-1][j] | dp[i-1][j-a[i]];
			}
	}
	for(int i = k-a[x]; i < k; i++)
		if(dp[n][i])
			return true;
	return false;	 
}
int main() {

	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		if(a[i] > k) a[i] = k;
	}
	if(n==1) {
		if(a[1] >= k) printf("0\n");
		else printf("1\n");
		return 0;
	}
	sort(a+1, a+1+n);
	int l = 0, r = n+1;
	while(l+1 < r) {
		int mid = (l+r) / 2;
		if(check(mid)) r = mid;
		else l = mid;
	}
	printf("%d\n", l);
	return 0;
}

Measured memory_bytes: 99840
#include <iostream>
long long l[100]={};
long long lucas(int n){
for(int i=0;i!=n+1;++i){
if(i==0)l[i]=2;
if(i==1)l[i]=1;
if(l[i]==0)l[i] = l[i-1]+l[i-2];
}
return l[n];
}
int main(){int n;long long a;std::cin>>n;a=lucas(n);std::cout<<a<<"\n";}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int h,w,a[80][80],b[80][80],p=80*80*2,mini=1000000000;
bool dp[80][80][80*80*4];

int main(){
    memset(dp,false,sizeof dp);
    cin >> h >> w;
    for(int i = 0 ; i < h ; i += 1){
        for(int j = 0 ; j < w ; j += 1){
            cin >> a[i][j];
        }
    }
    for(int i = 0 ; i < h ; i += 1){
        for(int j = 0 ; j < w ; j += 1){
            cin >> b[i][j];
        }
    }
    dp[0][0][a[0][0]-b[0][0]+p] = 1;
    dp[0][0][b[0][0]-a[0][0]+p] = 1;
    for(int i = 0 ; i < h ; i += 1){
        for(int j = 0 ; j < w ; j += 1){
            if(i+j == 0){
                continue;
            }
            if(i){
                for(int k = 0 ; k < 80*80*4 ; k += 1){
                    if(dp[i-1][j][k]){
                        dp[i][j][k+a[i][j]-b[i][j]] = true;
                        dp[i][j][k+b[i][j]-a[i][j]] = true;
                    }
                }
            }
            if(j){
                for(int k = 0 ; k < 80*80*4 ; k += 1){
                    if(dp[i][j-1][k]){
                        dp[i][j][k+a[i][j]-b[i][j]] = true;
                        dp[i][j][k+b[i][j]-a[i][j]] = true;
                    }
                }
            }
        }
    }
    for(int i = 0 ; i < 80*80*4 ; i += 1){
        if(dp[h-1][w-1][i]){
            mini = min(mini,abs(i-80*80*2));
        }
    }
    cout << mini;
}

Measured memory_bytes: 160256
N = int(input())
red = [tuple(map(int,input().split())) for _ in range(N)]
blue = [tuple(map(int,input().split())) for _ in range(N)]
 
red.sort(key=lambda x:x[0], reverse=True)
blue.sort(key=lambda x:x[1])
 
ans = 0
for i in range(N):
    a,b = red[i]
    for j in range(len(blue)):
        c,d = blue[j]
        if a < c and b < d:
            blue.pop(j)
            ans += 1
            break
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string>

using namespace std;

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    string ans;

    for (int i = 0; i < tx - sx; i++){
        ans += 'R';
    }
    for (int i = 0; i < ty - sy; i++){
        ans += 'U';
    }
    for (int i = 0; i < tx - sx; i++){
        ans += 'L';
    }
    for (int i = 0; i < ty - sy; i++){
        ans += 'D';
    }
    
    ans += 'D';

    for (int i = 0; i < tx - sx + 1; i++){
        ans += 'R';
    }
    for (int i = 0; i < ty - sy + 1; i++){
        ans += 'U';
    }
    ans += 'L';
    ans += 'U';
    for (int i = 0; i < tx - sx + 1; i++){
        ans += 'L';
    }
    for (int i = 0; i < ty - sy + 1; i++){
        ans += 'D';
    }
    ans += 'R';

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
/* package whatever; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args)/* throws java.lang.Exception*/
	{
		for( int x = 1; x <= 9; x++ )
		{
			for( int y = 1; y <= 9; y++ )
			{
				System.out.println( x + "x" + y + "=" + x*y );
			}
		}
	}
}

Measured memory_bytes: 16852
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define pb push_back

typedef long long ll;
using namespace std;
int MOD = 1000000007;
int N, L, Q;
map<int, int> m;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> N;
  int tree[18][N], X[N];
  FOR(i, 0, N){
    int x;
    cin >> x;
    m[~x] = i;
    X[i] = ~x;
  }
  cin >> L >> Q;

  FOR(i, 0, N) tree[0][i] = m.lower_bound(X[i] - L) -> second;
  FOR(i, 1, 18) FOR(j, 0, N) tree[i][j] = tree[i-1][tree[i-1][j]];

  FOR(i, 0, Q){
    int a, b, s = 0;
    cin >> a >> b;
    if(a > b) swap(a, b);
    a -= 1;
    b -= 1;
    FORR(j, 18, 0){
      if(tree[j][a] < b){
        s += (1 << j);
        a = tree[j][a];
      }
    }
    cout << s+1 << "\n";
  }
}


Measured memory_bytes: 12928
/*
 
*/ 
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define LSOne(S) (S & (-S))
#define EPS 1e-9
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pd;
typedef tree<pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0); // FOR QUERY PROBLEM DON'T FORGET TO UNCOMMENT THIS
    int n;
    cin >> n;
    int mx; ll ans = 0;
    cin >> mx;
    for(int i = 1; i < n; ++i)
    {
        int x;
        cin >> x;
        ans += max(0, mx-x);
        mx = max(mx, x);
    }
    cout << ans << "\n";
    return 0;
}
 
/*
 
*/  

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

int main(){
  ll X;
  cin >> X;
  int ans = 0;
  ll yokin = 100;
  while (yokin < X){
    yokin += yokin / 100;
    // 以下ではダメ
    // yokin += (ll) (yokin * 0.01);
    ans ++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
loop {
	n = gets.to_i
	break if n == 0
	squares = [[0, 0]]
	min_x = min_y = max_x = max_y = 0
	(n-1).times{
		i, d = gets.split.map &:to_i
		y, x = squares[i]
		case d
		when 0
			x -= 1
			min_x = x if x < min_x
		when 1
			y += 1
			max_y = y if y > max_y
		when 2
			x += 1
			max_x = x if x > max_x
		when 3
			y -= 1
			min_y = y if y < min_y
		end
		squares << [y, x]
	}
	puts "#{max_x - min_x + 1} #{max_y - min_y + 1}"
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  ll X; cin >> X;
  ll ans = (X / 11) * 2;
  X %= 11;

  if (1 <= X && X <= 6) ans++;
  else if (X > 6) ans += 2;
  cout << ans << endl;


  return 0;
}


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

int main() {
    int N;
    cin >> N;
    
    vector<int> vec(N);
    for (int i = 0; i < N; i++){
        int a;
        cin >> a;
        vec.at(i) = a;
    }
    
    int bottom;
    
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    
    bottom = vec.at(0);
    
    
    int times = 1;
    
    for (int i = 0; i < N; i++){
        if (vec.at(i) < bottom){
            bottom = vec.at(i);
            times++;
        }
    }
    
    cout << times << endl;
}


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

int main()
{
	int n;
	std::cin >> n;

	if (n <= 999)
	{
		std::cout << "ABC" << std::endl;
	}
	else
	{
		std::cout << "ABD" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
P = list(map(int, input().split()))

count = 0
for i in range(1, len(P)-1):
    if ((P[i] > P[i-1]) and (P[i] < P[i+1])) \
    or ((P[i] < P[i-1]) and (P[i] > P[i+1])):
        count += 1

print(count)

Measured memory_bytes: 3060
#include <algorithm>
#include <complex>
#include <vector>
using namespace std;
const double eps = 1e-10;
#define EQ(a, b) (abs((a) - (b)) < eps)
using P = complex<double>;      // position
struct L : vector<P> {
    L(const P &a = P(), const P &b = P()) {
        emplace_back(a); emplace_back(b);
    }
};
using Polygon = vector<P>;
ostream &operator<<(ostream &os, P p) { return os << real(p) << " " << imag(p); }
double dot(const P &a, const P &b) { return real(conj(a) * b); }
double cross(const P &a, const P &b) { return imag(conj(a) * b); }

double area(const Polygon &ps) {
    double sum = 0;
    for (int i = 0; i < ps.size(); i++) {
        sum += cross(ps[i], ps[(i + 1) % ps.size()]);
    }
    return abs(sum) / 2;
}

#include <iostream>
#include <iomanip>
int main() {
    cout << fixed << setprecision(1);
    int n; cin >> n;
    Polygon ps;
    for (int i = 0; i < n; i++) {
        int x, y; cin >> x >> y;
        ps.emplace_back(x, y);
    }
    double ans = area(ps);
    cout << ans << endl;
    return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

ll modmul(ll a,ll b,ll mod){
    return a%mod * (b%mod) %mod;
}

ll modpow(ll a,ll b,ll mod){
    if(b==0) return 1;
    else if(b%2==0) return modpow(modmul(a,a,mod),b/2,mod);
    else return modmul(modpow(a,b-1,mod),a,mod);
}

ll moddiv(ll a,ll b,ll mod){
    return a%mod * modpow(b,mod-2,mod) %mod;
}

int main(void)
{
    string a,b,c; cin>>a>>b>>c;
    cout<<'A'<<b[0]<<'C'<<endl;
    return 0;
}


Measured memory_bytes: 3612
function Main(input) {

  var input = input.split("\n");
  var s = input[0];

  var check = /([A-Za-z0-9])\1/;
  var result = check.test(s);
  if(result) {

    console.log("Bad");
  } else {

    console.log("Good");
  }


}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    a, b, c = map(int, input().split())

    print(len(set([a, b, c])))

if __name__ == '__main__':
    main()

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x, y;
  cin >> x >> y;

  ll ans = 1;
  while(x <= y) {
    x *= 2;
    ans += 1;
  } 
  cout << ans - 1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[200100];
int main(){
	scanf("%s",s);
	int sum = 0;
	for(int i = 0; i < strlen(s); i++)
		sum += s[i] - '0';
	if(sum%9)
		printf("No\n");
	else
		printf("Yes\n");
	return 0;
}

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

int main(){
	int a, b;
	cin >> a >> b;
	if(a == 1)
		if(b == 2) cout << 3;
		else cout << 2;
	else if(a == 2)
		if(b == 1) cout << 3;
		else cout << 1;
	else  if(a == 3)
		if(b == 1) cout << 2;
		else cout << 1;		 
	return 0;	
} 

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;

    vector<int> s(m), c(m);
    REP(i, m) cin >> s[i] >> c[i];

    REP(i, 1000) {
        int x = i / 10;
        vector<int> d(1, i % 10);
        while (x) {
            d.push_back(x % 10);
            x /= 10;
        }
        reverse(d.begin(), d.end());
        if (d.size() != n) continue ;

        bool ok = true;
        REP(i, m) if (d[s[i] - 1] != c[i]) ok = false;
        if (ok) {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}


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

const int INF = 1 << 29;

struct state {
    int pos;
    int time;

    state(int a, int b):
        pos(a), time(b) {}

    bool operator < (const state& o) const {
        return time == o.time ? pos > o.pos : time > o.time;
    }
};

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

    vector<int> p(N);
    vector<int> visited(N, INF);
    visited[0] = 0;

    for (int x = 0; x < N; ++x) {
        cin >> p[x];
    }

    priority_queue<state> que;

    que.push(state(0, 0));
    
    while (!que.empty()) {
        state s = que.top(); que.pop();

        if (s.time > visited[s.pos]) {
            continue;
        }

        if (s.pos >= N-1) {
            break;
        }

        if (p[s.pos] == 0) {
            for (int x = 1; x <= 6; ++x) {
                int nxt = min(s.pos + x, N-1);
                if (s.time + 1 < visited[nxt]) {
                    visited[nxt] = s.time + 1;
                    que.push(state(nxt, s.time + 1));
                }
            }
        } else {
            int nxt = s.pos + p[s.pos];
            if (s.time < visited[nxt]) {
                visited[nxt] = s.time;
                que.push(state(nxt, s.time));
            }
        }
    }

    cout << visited[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1788
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans =0
for i in range(A + 1):
  if i * 500 > X:
    break
  for j in range(B + 1):
    if i * 500 + j * 100 > X:
      break
    for k in range(C + 1):
      if i * 500 + j * 100 + k * 50 == X:
        ans += 1
        break
      if i * 500 + j * 100 + k * 50 > X:
        break
print(ans)


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

using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const LL INF = 1e18;




int main(){
	int N;
	vector<int>prime;
	FOR(i,2,51000){
		bool flag=true;
		for(int j=2;j*j<=i;j++)if(i%j==0)flag=false;
		if(flag)prime.PB(i);
	}
	while(cin>>N){
		vector<int>::iterator itr=upper_bound(ALL(prime),N);
		int res2=*itr;
		itr--;
		if(*itr==N)itr--;
		int res1=*itr;
		cout<<res1<<" "<<res2<<endl;
	}
	return 0;
}
/*

*/

Measured memory_bytes: 1276
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var nm = IO.RSInt;
            var s = new List<int[]>();
            for (int i = 0; i < nm[1]; i++)
            {
                var ks = IO.RSInt;
                var tmp = new int[ks.Length - 1];
                Array.Copy(ks, 1, tmp, 0, ks.Length - 1);
                s.Add(tmp);
            }
            var p = IO.RSInt;

            int cnt = 0;
            for (int i = 0; i < 1 << nm[0]; i++)
            {
                bool allRight = true;
                for (int j = 0; j < nm[1]; j++)
                {
                    int pushedCnt = 0;
                    foreach (var sw in s[j])
                    {
                        if ((i & 1 << sw - 1) > 0)
                        {
                            pushedCnt++;
                        }
                    }
                    if (pushedCnt % 2 != p[j])
                        allRight = false;
                }
                if (allRight) cnt++;
            }
            WriteLine(cnt);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 13396
n,m,k=map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a = [0]
b = [0]

for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])
    
ans,i = 0,n
for j in range (m + 1):
    if b[j] > k:
        break
    while a[i] > k - b[j]:
        i -= 1
    ans = max(ans,i+j)
print(ans)

Measured memory_bytes: 47312
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<int> C(8);
    int over=0;
    rep(i, n) {
        if (a[i] <= 399) {
            C[0]++;
        }
        else if (a[i] <= 799) {
            C[1]++;
        }
        else if (a[i] <= 1199) {
            C[2]++;
        }
        else if (a[i] <= 1599) {
            C[3]++;
        }
        else if (a[i] <= 1999) {
            C[4]++;
        }
        else if (a[i] <= 2399) {
            C[5]++;
        }
        else if (a[i] <= 2799) {
            C[6]++;
        }
        else if (a[i] <= 3199) {
            C[7]++;
        }
        else {
            over++;
        }
    }

    int res = 0;
    rep(i, C.size()) {
        if (C[i] > 0) {
            res += 1;
        }
    }

    int low = res;
    if (over >= 1) {
        low = max(res, 1);
    }
    int up = res + over;

    cout << low << " " << up  << endl;

    return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
    int N, D, ans = 0;
    cin >> N >> D;
    while (N > 0)
    {
        ans++;
        N -= 2 * D + 1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

    	/*Scanner = テキスト入力を扱うためのクラス
		 *キーボードからの入力を受けつける場合は
		 *System.inを使って下記のように記述
		 */
		Scanner scan = new Scanner(System.in);

		int i = scan.nextInt();

		/*long型でConstraintsの条件を記述してみました。
		 *maxに-1000000 minに1000000を設定。
		 *jがiの長さを変えるまでforループで回す。
		 *if文でmax、min内の値を入れ替える。
		 */
		long max = -1000000, min = 1000000, sum = 0;
		for(int j = 0; j < i; j++){
			long x = scan.nextLong();
			sum = sum + x;
			if(x > max){max = x;}
			if(x < min){min = x;}

		}
		/*条件を終えたらfor文を抜けmin max sumの順に表示
		 * 空白の指示が出てるので空白もはさむ。
		 */
		System.out.println(min +" "+ max +" "+sum);

    }
}

Measured memory_bytes: 31752
N = int(input())
A = [int(input()) for _ in range(N)]

if A[0] > 0:
    print(-1)
    exit()

tmp = 0
for i in range(1,N):
    if A[i] <= i and A[i] <= tmp+1:
        tmp = A[i]
    else:
        print(-1)
        exit()

tmp = 0
ans = 0
for i in range(1,N):
    if A[i] < tmp+1:
        ans += tmp
    tmp = A[i]

ans += tmp

print(ans)

Measured memory_bytes: 11052
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//ミョ(-ω- ?)
int main() {
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k <= a)cout << k << endl;
    else if(k <= a+b)cout << a << endl;
    else {
        ll d = k-a-b;
        cout << a - d << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
N,K = map(int,input().split())
A = list(map(int,input().split()))
s = sum(A)

divisors = []
for i in range(1,int(s**0.5)+1):
    if s%i==0:
        divisors.append(i)
        divisors.append(s//i)
divisors = list(set(divisors))
divisors.sort(reverse=True)

def possible(n):
    a = []
    for i in range(N):
        if A[i]%n != 0:
            a.append(A[i]%n)
    a.sort()
    k = 0
    while k <= K and a:
        m = a[0]
        M = a[-1]
        if m <= n-M:
            k += m
            a[-1] = (M+m)%n
            a[0] = 0
        else:
            k += n-M
            a[0] = (m-n+M)%n
            a[-1] = 0
        if a[0]==0:
            a = a[1:]
        if a[-1]==0:
            a = a[:-1]
        a.sort()
    return k<=K

for n in divisors:
    if possible(n):
        ans = n
        break

print(ans)

Measured memory_bytes: 42844
#include<stack>
#include<cstdio>
#include<vector>

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

using namespace std;

const int V_MAX=101;
const double INF=1e77;

int ord[V_MAX],low[V_MAX];
void dfs(int u,int &c,stack<int> &S,bool *inS,const vector<int> *G,int &scc_id,int *scc){
	ord[u]=low[u]=c++;
	S.push(u);
	inS[u]=true;

	rep(i,G[u].size()){
		int v=G[u][i];
		if(ord[v]==-1){
			dfs(v,c,S,inS,G,scc_id,scc);
			low[u]=min(low[u],low[v]);
		}
		else if(inS[v]){
			low[u]=min(low[u],ord[v]);
		}
	}

	if(ord[u]==low[u]){
		int v;
		do{
			v=S.top(); S.pop();
			inS[v]=false;
			scc[v]=scc_id;
		}while(v!=u);
		scc_id++;
	}
}

int SCC(int n,const vector<int> *G,int *scc){
	static bool inS[V_MAX];
	rep(u,n){
		ord[u]=-1;
		inS[u]=false;
	}
	stack<int> S;
	int c=0,n_scc=0;
	rep(u,n) if(ord[u]==-1) dfs(u,c,S,inS,G,n_scc,scc);
	return n_scc;
}

template<class T>
struct edge{
	int v;
	T cost;
};

template<class T>
T minimum_arborescence(int n,const vector< edge<T> > *G_in,int root){
	static vector< edge<T> > buf[V_MAX],buf2[V_MAX],*G=buf,*G2=buf2;
	rep(u,n) G[u].clear();
	rep(u,n) rep(i,G_in[u].size()) {
		const edge<T> &e=G_in[u][i];
		if(u!=e.v) G[u].push_back(e);
	}

	T ans=0;
	while(1){
		static int from[V_MAX];
		static T mini[V_MAX];
		rep(u,n) from[u]=-1;
		rep(u,n) rep(i,G[u].size()) {
			const edge<T> &e=G[u][i];
			if(from[e.v]==-1 || mini[e.v]>e.cost){
				from[e.v]=u;
				mini[e.v]=e.cost;
			}
		}

		rep(v,n) if(v!=root) {
			ans+=mini[v];
			if(from[v]==-1) return INF;
		}

		static vector<int> H[V_MAX];
		rep(v,n) H[v].clear();
		rep(v,n) if(v!=root) H[from[v]].push_back(v);

		static int scc[V_MAX];
		int N=SCC(n,H,scc);
		if(n==N) return ans;

		rep(i,N) G2[i].clear();
		rep(u,n) rep(i,G[u].size()) {
			const edge<T> &e=G[u][i];
			if(scc[u]!=scc[e.v]){
				G2[scc[u]].push_back((edge<T>){scc[e.v],e.cost-mini[e.v]});
			}
		}
		swap(G,G2);
		n=N;
		root=scc[root];
	}
}

int main(){
	int n,m; scanf("%d%d",&m,&n);
	double vec[101][100];
	rep(i,n) rep(j,m) scanf("%lf",vec[i]+j);
	rep(j,m) vec[n][j]=0;

	vector< edge<double> > G[V_MAX];
	rep(v,n){
		double cost=0;
		rep(k,m) cost+=vec[v][k]*vec[v][k];
		G[n].push_back((edge<double>){v,cost});
	}
	rep(u,n) rep(v,n+1) {
		double r1=0,r2=0;
		rep(k,m){
			r1+=vec[u][k]*vec[v][k];
			r2+=vec[u][k]*vec[u][k];
		}
		if(r2==0) continue;
		double r=r1/r2;

		double cost=0;
		rep(k,m) cost+=(vec[v][k]-r*vec[u][k])*(vec[v][k]-r*vec[u][k]);
		G[u].push_back((edge<double>){v,cost});
	}

	printf("%.9f",minimum_arborescence(n+1,G,n));

	return 0;
}

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

using namespace std;


int main(){
    string s, t;
    cin >> s >> t;

    vector<int> v[26];
    for(int i=0;i<s.length();i++){
        v[s[i]-'a'].push_back(i);
    }

    for(int i=0;i<26;i++){
        int len = v[i].size();
        for(int j=0;j<len;j++){
            v[i].push_back(v[i][j] + s.length());
        }
    }

    long long ans = 0;
    int p = -1;
    for(int i=0;i<t.length();i++){
        int idx = t[i] - 'a';
        if(v[idx].size() == 0){
            ans = -1;
            break;
        }

        auto it = upper_bound(v[idx].begin(), v[idx].end(), p);
        ans += *it - p;
        p = *it % s.length();
    }

    cout << ans << endl;
}


Measured memory_bytes: 1724
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int):
    sn = str(N)
    if sn[1:] == '9'*(len(sn)-1):
        print(int(sn[0])+9*(len(sn)-1))
    else:
        print(int(sn[0])+9*(len(sn)-1)-1)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
# python 3.8.2用
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
from math import gcd
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def lcm(a,b):return (a*b) // gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')
def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

R = iin()

print(2*R*math.pi)

Measured memory_bytes: 10620
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stack>
using namespace std;

int main() {
    stack<char> s;
    string x;
    cin >> x;
    for(int i = 0; i < x.size(); i++) {

        if(x[i] == 'T' && !s.empty() && s.top() == 'S') {
            s.pop();
        }
        else {
            s.push(x[i]);
        }
    }
    cout << s.size();
    return 0;
}


Measured memory_bytes: 644
#include <iostream>

using namespace std;

int main()
{
    int n;
    
    while (cin >> n) {
    
        if (n == 1){
            cout << "Hello World" << endl;
            fflush(stdout);
        }
        else if (n == 2) {
            int x, y;
            cin >> x >> y;
            cout << x+y << endl;
            fflush(stdout);
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
# coding:utf-8

import sys
import math
import time
import numpy as np
import collections
from collections import deque
import queue
import copy

# 最大公約数
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z

# 幅優先探索(BFS)でスタート座標(x, y)からの最大距離返す
def bfs(SS, x, y, H, W):#入力(座標系(迷路), x, y, xの端, yの端)
  x_next = [0, 0, -1, 1]
  y_next = [1, -1, 0, 0]
  tempx = x
  tempy = y
  mlength = 0
  q = deque()
  xytuple = (x, y, 0)
  q.append(xytuple)


  while q:
    xytuple = q.popleft()
    SS[xytuple[0]][xytuple[1]] = "x" #探索した場所は探索できないようにする
    for i in range(4): #このforで上下左右を調べてる
      tempx = xytuple[0] + x_next[i]
      tempy = xytuple[1] + y_next[i]
      #print(tempx, tempy, xytuple[2])
      #print(S)
      if(0 <= tempx and tempx < H and 0 <= tempy and tempy < W and SS[tempx][tempy] == "."):
        temptuple = (tempx, tempy, xytuple[2]+1)
        SS[temptuple[0]][temptuple[1]] = "x" #探索した場所は探索できないようにする
        mlength = max(mlength, xytuple[2] +1)
        q.append(temptuple)
      #print(q)
  return mlength


#X = str(input()).split()
S = str(input())
s = []
#a = int(A[0])
# S = [[0 for i in range(W)] for j in range(H)]
cont=0


if(len(S)%2 == 0):
  for i in range(int(len(S)/2)):
    s.append(S[i])
  for i in range(int(len(S)/2)):
    s.append(s[int(len(S)/2)-1-i])
else:
  for i in range(int((len(S)-1)/2)+1):
    s.append(S[i])
  for i in range(int((len(S)-1)/2)):
    s.append(s[int((len(S)-1)/2)-1-i])

for i in range(len(S)):
  if(S[i]==s[i]):
    cont += 0
  else:
    cont+= 1

#print(S)
#S[2] = "a"
print(cont)



#print(ans)



Measured memory_bytes: 12936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz 100005
#define all(x) x.begin(),x.end()
#define l_b lower_bound
#define u_b upper_bound
#define pb push_back
#define MOD 1000000007
void fastio(void);

int main(){
    fastio();
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ll n;   cin>>n;
    cout<<(1000-(n%1000))%1000<<endl;

    return 0;
}

void fastio(void){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

Measured memory_bytes: 3652
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
using namespace std;

int main()
{
int n,t,q,p,r,i,a[100000];
cin>>n;
t=0;p=0;
for(i=1;i<=n;i++)
{
     cin>>a[i];
    if(a[i]>t)
    {
        t=a[i];
    }
}
q=t;
for(i=1;i<=n;i++)
{
    r=abs(a[i]-t/2);
    if((r<q)&&a[i]!=t)
    {
        q=r;
        p=a[i];
    }
}

cout<<t<<" "<<p<<endl;
    return 0;
}


Measured memory_bytes: 640
h, w = gets.chomp.split.map(&:to_i)
map = Array.new(h + 2){"." * (w + 2)}
h.times{|i| map[i + 1][1, w] = gets.chomp}

for y in 1..h
    for x in 1..w
        if map[y][x] == "."
            sum  = 0
            for y2 in [-1, 0, 1]
                sum += map[y + y2][x - 1, 3].count("#")
            end
            map[y][x] = sum.to_s
        end
    end
end
h.times{|i| puts map[i + 1][1, w]}

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

using namespace std;
using vi = vector<int>;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<"\n"

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

  IN(N); IN(T);

  vi A(N);
  REP(i, N) {
    cin >> A[i];
  }
  vi max_price(N+1); // max_price[i] = [i, N)の範囲で最大のもの
  max_price[N] = 0;
  REP(i, N) {
    max_price[N-i-1] = max(max_price[N-i], A[N-i-1]);
  }
  int max_benefit = 0;
  int count = 0;
  REP(i, N) {
    int benefit = max_price[i] - A[i];
    if (max_benefit < benefit) {
      max_benefit = benefit;
      count = 1;
    } else if (max_benefit == benefit) {
      ++count;
    }
  }
  OUT(count);

  return 0;
}


Measured memory_bytes: 1024