akhauriyash/Code-Regression huggingface dataset:
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=2e5+4;

int main()
{
	string s;

	cin>>s;

	int n=(int)s.size();

	int flag=1;

	rep(i,0,n/2)
	{
		if(s[i]!=s[n-i-1] or s[i]!=s[(n/2)-1-i] or s[i]!=s[(n/2)+1+i])
		flag=0;
	}

	if(flag)
	printf("Yes");
	else
	printf("No");


    return 0;
}

Measured memory_bytes: 256
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define F first
#define S second


int main()
{

#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
//ios_base& scientific (ios_base& str);

    string s;
    cin >> s;
    cout << s[0];
    if (s[1] == 'R')
        cout << "B";
    else
        cout << "R";
    cout << "C\n";

    return 0;
}

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

// --- DEBUG begin --- cut here ---
template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

template <class Head>
void dbgLog(Head&& head) {
  cerr << head << endl;
}

template <class Head, class... Tail>
void dbgLog(Head&& head, Tail&&... tail)
{
  cerr << head << " ";
  dbgLog(forward<Tail>(tail)...);
}

#if DEBUG
  #define DLOG(...)        dbgLog(__VA_ARGS__)
  #define DFMT(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DFMT(...)
  #define DCALL(func, ...)
#endif

// operator<< definitions for some classes

template <typename T1, typename T2>
ostream& operator<< (ostream& os, const pair<T1,T2>& p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}

template <typename T>
ostream& operator<< (ostream& os, const vector<T>& v) {
  os << '[';
  for (auto it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  os << ']';

  return os;
}

template <typename T, typename T2, typename T3>
ostream& operator<< (ostream& os, const priority_queue<T, T2, T3>& orig) {
  priority_queue<T, T2, T3> pq(orig);
  bool first = true;
  os << '[';
  while (!pq.empty()) {
    T x = pq.top(); pq.pop();
    if (!first) os << ", ";
    os << x;
    first = false;
  }
  return os << ']';
}
// --- DEBUG end --- cut here ---


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, M, V, P; cin >> N >> M >> V >> P;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end(), greater<ll>());
  vector<ll> s(N);
  s.at(P-1) = 0;
  for (int i = P; i < N; i++) s.at(i) = s.at(i-1) + A.at(i-1);
  DLOG("s", s);
  ll cnt = P;
  for (int i = P; i < N; i++) {
    if (A.at(i) + M < A.at(P-1)) break;
    if ((A.at(i) + M) * (i - P + 1) - s.at(i) < M * (V - (N - i + P - 1))) {
      break;
    }
    cnt++;
  }
  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;
string s;
int x;
int main(){
	cin>>x;
	cin>>s;
	//65 A
	for(int i=0;i<s.length();++i){
		printf("%c",((s[i]-65+x)%26)+65);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define vvb vector<vb>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

const int mod = 998244353;

void solve(){
	int n, k;
	cin >> n >> k;
	
	vll dp(n+1, 0);
	dp[1] = 1;
	vll pre = dp;
	
	vpll p(k);
	for(int i=0 ; i<k ; ++i){
		cin >> p[i].F >> p[i].S;
	}
	
	for(ll i=2 ; i<=n ; ++i){
		for(ll j=0 ; j<k ; ++j){
			if(i >= p[j].F){
				int r = i - p[j].F;
				int l = max(i - p[j].S, 1LL);
				dp[i] += (pre[r] - pre[l-1] + mod);
				dp[i] %= mod;
			}
		}
		pre[i] = pre[i-1] + dp[i];
		pre[i] %= mod;
	}
//	printArr(pre, 0, n+1);
	cout << dp[n];
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << fixed << setprecision(10);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


Measured memory_bytes: 6372
from collections import deque


def nextj(n):
    while S[n] == '0':
        n += 1
        if n == N:
            return N
    q.appendleft(n)
    while S[n] == '1':
        n += 1
        if n == N:
            return N
    return n


def init(n):
    while S[n] == '1':
        n += 1
        if n == N:
            return N
    return n


def calc():
    q.appendleft(0)
    ans = 0
    j = init(0)
    if j == N:
        return N
    for _ in range(K - 1):
        j = nextj(j)
        if j == N:
            return N
    while True:
        j = nextj(j)
        ans = max(ans, j - q.pop())
        if j == N:
            return ans


N, K = map(int, input().split())
S = input()
q = deque()
print(calc())


Measured memory_bytes: 4460
n, m = map(int, input().split())
info = [list(map(int, input().split())) for i in range(m)]

graph = [[] for i in range(n)]
for i in range(m):
    a, b = info[i]
    a -= 1
    b -= 1
    graph[a].append(b)

def dfs(pos):
    if dp[pos] != -1:
        return dp[pos]
    p = len(graph[pos])
    dp[pos] = 0
    if p == 0:
        return dp[pos]
    for next_pos in graph[pos]:
        dp[pos] += dfs(next_pos) / p
    dp[pos] += 1
    return dp[pos]

dp = [-1]*n
dfs(0)
ans = dp[0]

def dfs_1(pos):
    if dq[pos] != -1:
        return dq[pos]
    p = len(graph[pos])
    if pos == i:
        p -= 1
    dq[pos] = 0
    if p == 0:
        return dq[pos]
    for next_pos in graph[pos]:
        if pos == i and next_pos == ind:
            continue
        dq[pos] += dfs_1(next_pos) / p
    dq[pos] += 1
    return dq[pos]

for i in range(n):
    num = 0
    ind = 0
    if len(graph[i]) <= 1:
        continue
    for j in graph[i]:
        if num < dp[j]:
            num = dp[j]
            ind = j
    dq = [-1]*n
    dfs_1(0)
    ans = min(dq[0], ans)
print(ans)

Measured memory_bytes: 103032
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String a = sc.nextLine();

		if (a.equals("AAA") || a.equals("BBB")) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}

	}
}


Measured memory_bytes: 21972
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
using ulong = unsigned long;
using ll = long long;
const int M = 1e9 + 7;

struct Elem{
	ll a, sum, accLen;
	bool operator < (const Elem& e) const{
		return a < e.a;
	}
};

int main(){
	int n;
	cin >> n;
	vector<Elem> nums(n + 1);
	ll ans = 0;
	long vecEnd = 1;
	nums[0] = {0, 0, 0};
	for(int i=1;i<=n;i++){
		int a;
		cin >> a;
		long pos = lower_bound(nums.begin(), nums.begin() + vecEnd, Elem{a, 0, 0}) - nums.begin();
		nums[pos] = {a, nums[pos - 1].sum + a * (i - nums[pos - 1].accLen), i};
		vecEnd = pos + 1;
		ans += nums[pos].sum;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 4992
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N = 2e5 + 2;
long long a[N];
long long n, m;
typedef long long LL;
bool check(LL x)
{
	long long h1, h2, cnt = 0;
	for (int i = 1; i <= n; i++)
	{
		if (a[i])
		{
			h1 = h2 = x / a[i];
			if (x % a[i])
			{
				if ((x < 0 && a[i]>0) || (x > 0 && a[i] < 0)) --h1;//不能直接相乘判断正负，因为会 爆
				else ++h2;
			}
			if (a[i] < 0)  cnt += n + 1 - (upper_bound(a + 1, a + 1 + n, h1) - a);
			if (a[i] > 0) cnt += lower_bound(a + 1, a + 1 + n, h2) - a - 1;
			if (a[i] * a[i] < x) cnt--;
		}
		else if (x > 0) cnt += n - 1;
	}
	cnt>>=1;
	return cnt<m;
}

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

	while (cin >> n >> m)
	{
		for (int i = 1; i <= n; i++) cin >> a[i];
		sort(a + 1, a + 1 + n);
		LL r=1e18, l=-1e18;
		LL ans;
		while (l <= r)
		{
			LL mid = l + r >> 1;
			if (check(mid)) {
				ans = mid;
				l = mid + 1;
			}
			else
				r = mid - 1;
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    n = int(input())
    i = int(n**(1/2))
    while n % i != 0:
        i -= 1
    print(len(str(n//i)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
num = int(input())

list2 = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]

for i in range(num):
	#b棟 f階 r番目 v人
	b,f,r,v = map(int,input().split(" "))
	list2[b-1][f-1][r-1] += v

for i in range(4):
	for j in range(3):
		print(" ",end="")
		print(*list2[i][j])
	if i != 3:
		print("####################")



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

string banmen[310];
int N;

bool check(int k){
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(i>=j) continue;
      if(banmen[i][k+j]!=banmen[j][k+i])
        return false;
    }
  }
  return true;
}

int main(){
  cin>>N;
  string S;
  for(int i=0;i<N;i++){
    cin>>S;
    banmen[i]=S+S;
  }
  int ans=0;
  for(int i=0;i<N;i++){
    if(check(i))
      ans++;
  }
  cout<<ans*N<<endl;
}

Measured memory_bytes: 512
def get_price(name, prices, recipe):
    return min(prices[name],
               sum(get_price(_name, prices, recipe) for _name in recipe[name])
               if name in recipe else float("inf")
               )


while True:
    n = int(input())
    if not n:
        break
    prices, recipe = {}, {}
    for _ in [0]*n:
        s, p = input().split()
        prices[s] = int(p)
    for _ in [0]*int(input()):
        a = input().split()
        recipe[a[0]] = a[2:]

    print(get_price(input(), prices, recipe))



Measured memory_bytes: 5624
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<string>
#include<iostream>
#include<cmath>
#include<queue>
#include<bitset>
#define maxn 800010
#define ms(x,y) memset(x,y,sizeof x)
#define inf 0x3f3f3f3f
#define fir first
#define sec second
#define lb(x) (x&(-x))
const int mod=924844033;
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
ll fastpow(ll num,ll mi){
	ll res=1;
	while(mi){
		if(mi&1)res=res*num%mod;
		num=num*num%mod;
		mi>>=1;
	}
	return res;
}
namespace ntt{
	int n,m,r[800010];
	ll w[20],g=5;
	void init(int len){
		for(n=1,m=0;n<=len;n<<=1,m++);
		for(int i=1;i<n;i++)r[i]=(r[i>>1]>>1)|((i&1)<<m-1);
	}
	void initw(int f){
		w[0]=fastpow(g,(mod-1)/n);
		if(f<0)w[0]=fastpow(w[0],mod-2);
		for(int i=1;i<m;i++)w[i]=w[i-1]*w[i-1]%mod;
	}
	void ntt(ll *a,int f){
		for(int i=1;i<n;i++)if(i<r[i])swap(a[i],a[r[i]]);
		for(int i=1,x=m-1;i<n;i<<=1,x--){
			for(int j=0;j<n;j+=i<<1){
				ll wn=1;
				for(int k=0;k<i;k++){
					ll xi=a[j+k],yi=wn*a[i+j+k]%mod;
					a[j+k]=(xi+yi)%mod,a[j+k+i]=(xi-yi+mod)%mod;
					(wn*=w[x])%=mod;
				}
			}
		}
		ll inv=fastpow(n,mod-2);
		if(f<0)for(int i=0;i<n;i++)(a[i]*=inv)%=mod;
	}
}
int sz[maxn],fa[maxn],n;vector<int>graph[maxn];
ll fac[maxn],inv[maxn],b[800010],c[800010],res[maxn];
void dfs(int p,int f){
	sz[p]=1;fa[p]=f;
	for(int i=0;i<graph[p].size();i++){
		int e=graph[p][i];if(e==f)continue;
		dfs(e,p);sz[p]+=sz[e];
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1,u,v;i<n;i++){
		scanf("%d%d",&u,&v);
		graph[u].push_back(v);
		graph[v].push_back(u);
	}
	dfs(1,0);
	for(int i=1;i<=n;i++){
		b[n]++;
		for(int j=0;j<graph[i].size();j++){
			int e=graph[i][j];
			if(e==fa[i]){b[n-sz[i]]--;if(b[n-sz[i]]<0)b[n-sz[i]]+=mod;}
			else {b[sz[e]]--;if(b[sz[e]]<0)b[sz[e]]+=mod;}
		}
	}
	fac[0]=inv[0]=1;
	for(int i=1;i<=n;i++)fac[i]=i*fac[i-1]%mod,(b[i]*=fac[i])%=mod;
	inv[n]=fastpow(fac[n],mod-2);
	for(int i=n-1;i;i--)inv[i]=inv[i+1]*(i+1)%mod;
	for(int i=0;i<=n;i++)c[i]=inv[i];
	for(int i=0;i<=n/2;i++)swap(b[i],b[n-i]);
	ntt::init(n*2-1);ntt::initw(1);
	ntt::ntt(b,1);ntt::ntt(c,1);
	for(int i=0;i<ntt::n;i++)(b[i]*=c[i])%=mod;
	ntt::initw(-1);ntt::ntt(b,-1);
	for(int i=1;i<=n;i++)res[i]=b[n-i]*inv[i]%mod,printf("%lld\n",res[i]);
	return 0;
}


Measured memory_bytes: 67200
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
 
public class Main {
	private	static			BufferedReader	br = null;
	private	static	final	int				DN = 0;
	private	static	final	int				DR = 1;
	private	static	final	int				DK = 2;
	private	static	final	int				DM = 3;
	private	static	final	int[]			SV = { 1, -1, 0, 0  };
	private	static	final	int[]			SH = { 0, 0,  1, -1 };

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int[][] map = null;
		Task	tsk = new Task();

		while((map = parseMap()) != null) {
			int	cnt = 0;

			for (int i = 0; i < map.length; i++) {
				for (int j = 0; j < map[i].length; j++) {
					int	dst = map[i][j];
					if (dst != DN) {
						int[]	tmp = { i, j };
						tsk.add(tmp);
						while (!tsk.isEmpty()) {
							visit(map, tsk, dst);
						}
						cnt++;
					}
                }
            }

			System.out.println(cnt);
		}
	}

	public static void visit(int[][] map, Task tsk, int dst) {
		int[]	tmp = tsk.remove(0);

		if (map[tmp[0]][tmp[1]] == dst) {
			map[tmp[0]][tmp[1]] = DN;

			// next choices
			for (int i = 0; i < 4; i++) {
				int	y = tmp[0] +  SV[i];
				int	x = tmp[1] +  SH[i];

				if (0 <= y && y < map.length && 0 <= x && x < map[0].length) {
					if (map[y][x] == dst) {
						int[]	src = { y, x };
						tsk.add(src);
					}
				}
			}
		}
	}

	private static int[][] parseMap() {
		int[][]	map = null;
		int[]	len = parseLen();

		if (len != null) {
			map = new int[len[0]][len[1]];

			for (int y = 0; y < len[0]; y++) {
				String	strin = null;
				if ((strin = parseStdin()) != null) {
					for (int x = len[1]-1; x >= 0; x--) {
						switch(strin.charAt(x)) {
						case	'@':
							map[y][x] = DR;
							break;
						case	'#':
							map[y][x] = DK;
							break;
						case	'*':
							map[y][x] = DM;
							break;
						}
					}
				}
			}
		}

		return map;
	}

	private static int[] parseLen() {
		int[]	params = null;
		String	stdin  = null;

		if ((stdin = parseStdin()) != null) {
			if (!stdin.equals("0 0")) {
				String[]	lines = stdin.split(" ");

				params    = new int[2]; 
				params[0] = Integer.parseInt(lines[0]);
				params[1] = Integer.parseInt(lines[1]);
			}
		}

		return params;
	}

	private static String parseStdin() {
		String  stdin = null;

		try {
			String  tmp = br.readLine();
			if (!tmp.isEmpty()) stdin = tmp;
		}
		catch (IOException e) {}

		return stdin;
	}
}

class Task extends ArrayList<int[]> {
}

Measured memory_bytes: 23564
using System;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var P = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var cnt = 0;
            for (int i = 0; i < n - 2; i++)
            {
                if (Judge(P[i], P[i + 1], P[i + 2])) cnt++;
            }

            Console.WriteLine(cnt);
        }

        static bool Judge(int p1, int p2, int p3)
        {
            return Math.Max(p1, Math.Max(p2, p3)) != p2 && Math.Min(p1, Math.Min(p2, p3)) != p2;
        }
    }
}

Measured memory_bytes: 13652
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    public struct Pair<T> { public T x, y; public Pair(T x, T y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        int T = NextInt();
        int[] A = LineInt();
        int a = A[0];
        for (int i = 0; i < N; i++)
        {
            a = Math.Min(a, A[i]);
            A[i] -= a;
        }
        Array.Sort(A);
        Array.Reverse(A);
        Console.WriteLine(A.Count(x => x == A[0]));
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 21856
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include<functional>
#include<bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pI64d(x) printf("%I64d\n",x)
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
const ll INF=1e15;
const int MOD=1e9+7;
const int N=1e6+7;
const double eps=1e-8;
const double PI=acos(-1.0);
int main()
{
    ll a,b;
    char s[5];
    while(~scanf("%lld%s%lld",&a,s,&b))
    {
        if(s[0]=='+') printf("%lld\n",a+b);
        else printf("%lld\n",a-b);
    }
    return 0;
}

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

int main() {
  int N, L;
  cin >> N >> L;
  int total = 0;

  if(L>0) {
    for(int i=2;i<=N;i++) {
      total += L + i - 1;
    }
  } else if (L + N - 1 < 0) {
    for(int i=1;i<=N-1;i++) {
      total += L + i - 1;
    }
  } else {
    for(int i=1;i<=N;i++) {
      int azi = L + i - 1;
      if(azi == 0) {
        continue;
      }
      total += azi;
    }
  }

  cout << total << endl;

  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc134/tasks/abc134_d
# 偶奇だけが重要
# 後半は即座に決定できる(倍数が存在しないので)
# 後ろから決定できない？
# nの倍数の個数を更新していく

N = read_a_int()
A = read_ints()

ans = [0] * N
ans[N // 2:] = A[N // 2:]
for i in ra(N // 2 - 1, -1, -1):
    # (i+1)の倍数の個数の集計
    n = i + 1
    s = sum(ans[i::n]) % 2
    ans[i] = s ^ A[i]

print(sum(ans))
ans_pr = []
for i, v in enu(ans, start=1):
    if v:
        ans_pr.append(i)
print(*ans_pr)


Measured memory_bytes: 70876
L,R= map(int,input().split())
arr =[]
d = R - L
if d >= 2019 or L%2019 > R%2019:
  print(0)
else:
  for i in range(L,R):
    for j in range(i+1,R+1):
      arr.append((i*j)%2019)
  print(min(arr))

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

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

const int INF = 1e9 + 7;

using namespace std;

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

	int n, k;
	cin >> n >> k;

	ll res = 0;
	res += pow((n / k), 3);

	int count = 0;
	if (!(k & 1)) {
		for (int i = 0; i <= n; i += k) {
			if (i + (k / 2) <= n)
				count++;
		}
		res += pow(count, 3);
	}

	cout << res << endl;

	return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    int n, k, x, y;
    cin >> n >> k >> x >> y;

    cout << min(n, k) * x + max(0, n - k) * y << '\n';
    return 0;
}


Measured memory_bytes: 3592
N = int(input())
W = [input() for _ in range(N)]
used = set()
used.add(W[0])
prev = W[0][-1]
for w in W[1:]:
    if prev != w[0] or w in used:
        print('No')
        exit()
    prev = w[-1]
    used.add(w)
print('Yes')

Measured memory_bytes: 38384
// // If you want something you've never had, you must be willing to do
// // something you've never done

// //  When the going gets tough,  the tough get going

//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<pair<int,int>, null_type,less<pair<int, int> >,rb_tree_tag,tree_order_statistics_node_update > pbds;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define pb push_back
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
// #define int ll
ll power(ll a, ll b, ll mod) {
    ll res = 1;
    a %= mod;
    while(b) {
        if(b % 2) {
            res *= a;
            res %= mod;
        }
        a = a * a % mod;
        b >>= 1;
    }
    return res % mod;
}
const int INF = 2e9;

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

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

signed main() {
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    // int t;
    string s;
    cin >> s;
    map<int, ll> m;
    ll ans = 0;
    int n = s.length();
    ll pw[n + 1];
    memset(pw, 0LL, sizeof pw);
    pw[0] = 1;
    for(int i=1; i<=n; i++) {
        pw[i] = 10 * pw[i-1];
        pw[i] %= 2019;
    }
    int has = 0;
    m[0] = 1;
    for(int i=n-1; i>=0; i--) {
        has += (s[i]-'0') * pw[n-1-i];
        has %= 2019;
        //debug2(i, has);
        if(s[i] != '0')
            ans += m[has];
        m[has]++;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 5268
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define endl "\n"
#define all(x) (x).begin(),(x).end()
const int MOD = 1e9+7;
const int mxN = 2e5+3;

void solve(){
	int x,y;
	cin >> x >> y;
	if(y % 2 != 0){
		cout << "No" << endl;
		return;
	}
	y /= 2;
	int t = y - x;
	int c = x - t;
	if(t >= 0 and c >= 0){
		cout << "Yes" << endl;
	}else cout << "No" << endl;
}

int32_t main(){
	IO;

	int nT = 1;
	//cin >> nT;
	for(int i = 1; i <= nT; ++i)
		solve();
	return 0;
}


Measured memory_bytes: 3624
//ΔAGC026C
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 22;
int n;
string s;
LL ans;
int dp[N][N];
int solve(int x){
	string s1="",s2="";
	int i,j,l1=0,l2=0;
	for(i=n;i--;){
		if(x&(1<<i))
			s1+=s[i];
		else
			s2+=s[i];
	}
	l1=s1.length(),l2=s2.length();
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	for(i=0;i<=l1;i=i+1)
		for(j=0;j<=l2;j=j+1){
			if(i<l1&&s[n+i+j]==s1[i])
				dp[i+1][j]+=dp[i][j];
			if(j<l2&&s[n+i+j]==s2[j])
				dp[i][j+1]+=dp[i][j];
		}
	ans+=dp[l1][l2];
}
int main()
{
	int i;
	cin>>n>>s;
	for(i=0;i<(1<<n);i=i+1)
		solve(i);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#define print(n) std::cout << n << std::endl
using namespace std;


int main() {
    int k,x;
    cin >> k >> x;

    int n = 2 * k - 1;

    for (int i = 0; i < n; ++i) print((x - k + 1) + i);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  ll A,B,N;
  cin >> A >> B >> N;
  ll ng=-1,ok=N;
  while(ng+2<ok) {
    ll l=(ng*2+ok)/3;
    ll r=(ng+ok*2)/3;
    ll lv = (A*l)/B-A*(l/B);
    ll rv = (A*r)/B-A*(r/B);
    if(lv>rv) {
      ok=r;
    } else {
      ng=l;
    }
  }
  ll ans = -LINF;
  for(ll k=ng;k<=ok;k++) {
    chmax(ans,(A*k)/B-A*(k/B));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>

int insertionsort(int,int);

int main(void){
  int n;
  scanf("%d", &n);
  int a[n];
  for(int i=0; i<n; i++){
    scanf("%d", &a[i]);
  }

  for(int k=0; k<n-1; k++){
    printf("%d ",a[k]);
  }
  printf("%d",a[n-1]);
  printf("\n");

  insertionSort(a,n);

  return 0;
}

int insertionSort(int a[],int n){
  int j,v;

  for(int i=1; i<=n-1; i++){

    v = a[i];
    j = i-1;
    while((j>=0)&&(a[j]>v)){
      a[j+1]=a[j];
      j--;


    }
    a[j+1] = v;

    for(int k=0; k<n-1; k++){
      printf("%d ",a[k]);
    }
    printf("%d",a[n-1]);
    printf("\n");

  }



  return 0;


}



Measured memory_bytes: 2044
#include <stdio.h>

int main(void){

  int i, j;
  int n;

  /*data acquiring*/

  scanf("%d\n", &n);
  int a[n];
  for(i = 0; i < n; i++){
  scanf("%d", &a[i]);
  }

  /* outputting */

  for(j = n - 1; j >= 0; j--){
    if( j - (n-1)){  printf(" %d", a[j]);}
    else {printf("%d", a[j]);}
  }

  printf("\n");

  return 0;

}

Measured memory_bytes: 600
import sys
readline = sys.stdin.readline

N,M = map(int,readline().split())
X = list(map(int,readline().split()))
Y = list(map(int,readline().split()))
DIV = 10 ** 9 + 7

def f(V):
  vsum = 0
  for i in range(1, len(V)):
    vsum += (((V[i] - V[i - 1]) % DIV) * ((i * (len(V) - i)) % DIV)) % DIV
    vsum %= DIV
  return vsum
  
print((f(X) * f(Y)) % DIV)

Measured memory_bytes: 24580
function Main(input) {
    input = input.split("\n");
    var a = input[0].split(" ");
    a=a.map(e=>parseInt(e,10));
    var b = input[1].split(" ");
    b=b.map(e=>parseInt(e,10));
    
    console.log(
        b.reduce((prev,curr)=>{
            if(curr>=a[1]){
                return prev+1;
            }else{
                return prev;
            }
        },0)
    )
    


}

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



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

int main(){
  int c[9];
  int sum = 0;
  rep(i,9) {
    cin >>c[i];
    sum += c[i];
  }
  if(sum==3*(c[0]+c[4]+c[8])) cout << "Yes" << endl;
  else cout << "No" << endl; 
  return 0; 
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <string.h>
#include <limits.h>
#define oo INT_MAX

struct edge{int v,g,next;} a[400000];
int H[400],d[400],C[400],N,M,u,v,c,cnt,ans,S,T,k,i,j;

int min(int x,int y){
    return x<y?x:y;   
}

int add(int u,int v,int c){
    a[++cnt].v=v; a[cnt].g=c; a[cnt].next=H[u]; H[u]=cnt;
}

int build(int u,int v,int c){
    add(u,v,c);
    add(v,u,0);   
}

int sap(int u,int flow){
    int f=0,tt,delta;
    if (u==T) return flow;
    for (tt=H[u];tt;tt=a[tt].next){
        v=a[tt].v;
        if (a[tt].g && d[u]==d[v]+1){
           delta=sap(v,min(flow,a[tt].g));
           a[tt].g-=delta; a[tt+(tt&1?1:-1)].g+=delta; f+=delta; flow-=delta;
           if (!flow) break;             
        }
    }
    if (!f){
       --C[d[u]];
       if (!C[d[u]]) d[S]=N+2;
       ++C[++d[u]];      
    }
    return f;   
}

int main()
{
    while (~scanf("%d%d",&N,&M)){
        memset(H,0,sizeof(H));
        memset(d,0,sizeof(d));
        memset(C,0,sizeof(C)); 
        cnt=0; C[0]=N;
        for (i=1;i<=M;i++){
            scanf("%d%d",&u,&v);
            build(u,v,1); build(v,u,1);
        }
        scanf("%d%d",&S,&T);
        ans=0;
        while (d[S]<=N+1) ans+=sap(S,oo);
        printf("%d\n",ans);
        ans=0;
        for (i=1;i<=M;i++) ans+=a[4*i-3].g;
        printf("%d\n",ans);
        for (i=1;i<=M;i++)
            if (a[4*i-3].g) printf("%d\n",i);
    }
    return 0;
}

Measured memory_bytes: 1076
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws InterruptedException {
		FastScanner fs=new FastScanner();
		int x=fs.nextInt();
		x-=400;
		System.out.println(8-x/200);
	}
	
	void sort(int[] a) {
		ArrayList<Integer> list=new ArrayList<>();
		for (int i:a) list.add(i);
		Collections.sort(list);
		for (int i=0; i<a.length; i++) a[i]=list.get(i);
	}
	
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
		
		public long[] readLongArray(int n) {
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
	}

}


Measured memory_bytes: 25152
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int a, b; cin >> a >> b;
  if (a <= 5) {
    cout << 0 << endl;
  } else if (a <= 12) {
    cout << b / 2 << endl;
  } else {
    cout << b << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
char s[N];

int main()
{
    cin>>s;
    int len=strlen(s);
    for(int i=0;i<len;i++)
        cout<<'x';
    cout<<endl;
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
    string s;
    getline(cin, s);
    for(int i=0; i<(int)s.length(); i++){
        if('A' <= s[i] && s[i] <= 'Z'){
            s[i] = 'a' +s[i]-'A';
        }else if('a' <= s[i] && s[i] <= 'z'){
            s[i] = 'A' +s[i]-'a';
        }
    }
    cout << s << endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int q;
    cin >> q;
    while (q--) {
        int k;
        cin >> k;
        long long ans = 0;
        long long ds = 0, ms = 0, dms = 0;
        for (int i = 0; i < n; i++) {
            if (i >= k) {
                if (s[i - k] == 'D') ds--, dms -= ms;
                if (s[i - k] == 'M') ms--;
            }
            if (s[i] == 'D') ds++;
            if (s[i] == 'M') ms++, dms += ds;
            if (s[i] == 'C') ans += dms;
        }
        cout << ans << '\n';
    }
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S, std::string T){
    string left, right, SS;
    for(int i = 0; i < S.size(); ++i){
        left = S.substr(i, S.size());
        right = S.substr(0, i);
        SS = left + right;
        if(SS == T){
            cout << YES << endl;
            exit(0);
        }
    }
    cout << NO << endl;
}

int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m = LI()
    a = LI()
    ans = n-sum(a)
    if ans < 0:
        print(-1)
    else:
        print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 70068
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cassert>
#include <string>
#include <cstring>
#include <bitset>
#include <stack>
#include <iomanip>
 
#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define F0R(i, a) FOR (i, 0, a)
#define ROF(i, a, b) for(int i = a; i >= (int) b; i--)
#define R0F(i, a) ROF(i, a, 0)
#define GO(i, a) for (auto i : a)
 
#define rsz resize
#define eb emplace_back
#define pb push_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define f first
#define s second
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;
 
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};

const int N = 4e2 + 5;

int a [N];
i64 dp [N][N], prefix [N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  F0R (i, n) {
    cin >> a[i];
    prefix[i + 1] = a[i];
  }
  FOR (i, 1, n + 1) {
    prefix[i] += prefix[i - 1];
  }
  F0R (i, N) {
    F0R (j, N) {
      dp[i][j] = 1e18;
    }
    dp[i][i] = 0;
  }
  for (int tamanho = 1; tamanho < n; tamanho++) {
    for (int inicio = 0; inicio + tamanho < n; inicio++) {
      int fim = inicio + tamanho;
      for (int j = inicio; j < fim; j++) {
        dp[inicio][fim] = min (dp[inicio][fim], dp[inicio][j] + dp[j + 1][fim] + prefix [fim + 1] - prefix[inicio]);
      }
    } 
  }
  cout << dp[0][n - 1] << '\n';
  return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	int n;
	while (cin >> n, n) {
		double avr = 0; int p[11000];
		for (int i = 0; i < n; i++) {
			cin >> p[i];
			avr += p[i];
		}
		avr /= n;
		int ans = 0;
		for (int i = 0; i < n; i++)ans += (p[i] <= avr);
		cout << ans << endl;
	}
}


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

using namespace std;

const int MAX_N = 1e5 + 5;

int K, ans;

int par [MAX_N];
vector<int> adj [MAX_N];

int subh [MAX_N];
int del [MAX_N];

void dfs (int u) {
  subh[u] = 0;
  for (int nxt : adj[u]) {
    dfs(nxt);
    if (!del[nxt]) {
      subh[u] = max(subh[u], 1 + subh[nxt]);
    }
  }

  if (u != 1 && subh[u] == K - 1 && par[u] != 1) {
    del[u] = 1;
    ans++;
  }
}

int main () {
  ios::sync_with_stdio(false);

  int n;
  cin >> n >> K;

  for (int i = 1; i <= n; i++) {
    cin >> par[i];
  }

  if (par[1] != 1) ans++;
  for (int i = 2; i <= n; i++) {
    adj[par[i]].push_back(i);
  }

  dfs(1);

  cout << ans << endl;
}


Measured memory_bytes: 17996
N = int(input())
A = list(map(int,input().split()))
flg = 0

for i in range(N):
    if A[i] % 2 == 0:
        if A[i] % 3 != 0 and A[i] % 5 != 0 :
            flg = 1
            break
        elif A[i] % 3 == 0:
            flg = 0
        elif A[i] % 5 == 0:
            flg = 0
        else:
            flg = 1

if flg == 0:
    print('APPROVED')
else:
    print('DENIED')


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

namespace ARC094E {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            long min = 1000000000000;
            long ans = 0;
            bool ok = false;
            for(int i = 0; i < N; i++) {
                int[] input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                int A = input[0];
                int B = input[1];
                if(A != B) {
                    ok = true;
                }
                ans += A;
                if(A > B) {
                    if(B < min) {
                        min = B;
                    }
                }
            }
            if (ok) {
                Console.WriteLine(ans - min);
            } else {
                Console.WriteLine(0);
            }
        }
    }
}


Measured memory_bytes: 17484
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
    int a, b, c;
    cin >> a;
    cin >> b;
    cin >> c;
    if((a+b+c) == 17 && (a == 5 ||  a ==7) && (b == 5 || b ==7) && (c == 5 || c == 7))
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,a,b,ans=0,now=0;
    cin>>n>>a>>b;
    int start = 0,end = n - 1; 
    vector<int>x(n);
    rep(i,0,n){
        cin>>x[i];
    }
    while(start < end){
        if(now==start&&a*(x[start+1]-x[start])<=b){ans+=a*(x[start+1]-x[start]);start++;now++;}
        else if(now==end&&a*(x[end]-x[end-1])<=b){ans+=a*(x[end]-x[end-1]);end--;now--;}
        else if(now==end){ans+=b;now=start;end--;}
        else if(now==start){ans+=b;now=end;start++;}
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        final String S = sc.next();
        
        int n;
        if ("RRR".equals(S)) {
            n = 3;
        } else if ("RRS".equals(S) || "SRR".equals(S)) {
            n = 2;
        } else if (S.contains("R")) {
            n = 1;
        } else {
            n = 0;
        }
        System.out.println(n);
    }
}


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

int main(void)
{
    int H,W;
    while(true)
    {
        cin >> H >> W;
        if(H==0 && W==0)break;
        for(int i = 0; i < H ; i++)
        {
            if(i % 2 == 0)
            {
                for(int j = 0 ; j < W ; j++)
                {
                    if(j % 2 == 0)cout << "#";
                    else cout << ".";
                }
                cout << endl;
            }
            else
            {
                for(int j = 0 ; j < W ; j++)
                {
                    if(j % 2 == 0)cout << ".";
                    else cout << "#";
                }
                cout << endl;
            }
        }
      	cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>
#include <cstring>
using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
bool check1[14][8];
int check2[14][8];
int block[14][8];
void GetBlock(){
  memset(block,0,sizeof(block));
  memset(check1,0,sizeof(check1));
  for(int i=1; i<=12; i++){
    for(int j=1; j<=6; j++){
      block[i][j] = getchar();
    }
    getchar();
  }
}
void Makecheck2(int x, int y){
  REP(k,4){
    if(check2[x+dx[k]][y+dy[k]]==0&&
        block[x][y]==block[x+dx[k]][y+dy[k]]){
      check1[x+dx[k]][y+dy[k]] = true;
      check2[x+dx[k]][y+dy[k]] = 1;
      Makecheck2(x+dx[k], y+dy[k]);
    }
    if(check2[x+dx[k]][y+dy[k]]==0&&block[x+dx[k]][y+dy[k]]=='O')
      check2[x+dx[k]][y+dy[k]] = 100;
  }
}
int CheckNum(int x, int y){
  int count = 0;
  memset(check2,0,sizeof(check2));
  check2[x][y] = 1;
  Makecheck2(x,y);
  FOR(i,1,13)
    FOR(j,1,7)
      if(check2[i][j]==1) count++;
  return count;
}
void Break(){
  FOR(i,1,13)
    FOR(j,1,7)
      if(check2[i][j] == 1 || check2[i][j] == 100)
        block[i][j] = '.';
  memset(check2,0,sizeof(check2));
}

bool CheckIsR(){
  bool flag2 = false;
  FOR(i,1,13)
    FOR(j,1,7)
      if(check1[i][j]==false){
        if(block[i][j]!='.'&&block[i][j]!='O'){
          check1[i][j] = true;
          if(CheckNum(i,j)>=4){
            flag2 = true;
            Break();
          }
        }else{
          check1[i][j] = true;
        }
      }
  return flag2;
}
bool Down(){
  bool flag3;
  do{
    flag3 = false;
    FOR(i,1,13)
      FOR(j,1,7)
        if(block[i][j] != '.' && block[i+1][j] == '.'){
          swap(block[i][j],block[i+1][j]);
          flag3 = true;
        }
  }while(flag3);
  memset(check1,0,sizeof(check1));
}
void Out(){
  FOR(i,1,13){
    FOR(j,1,7)
      printf("%c",block[i][j]);
    putchar('\n');
  }
  putchar('\n');
}
int main(void){  
  int n;
  cin>>n;
  getchar();
  while(n--){
    GetBlock();
    int count=0;
    while(true){
      memset(check1,0,sizeof(check1));
      if(CheckIsR()) count++;
      else break;
      Down();
    }
    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 0