akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

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



Measured memory_bytes: 256
import java.text.DecimalFormat;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.math.BigDecimal;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        long a = sc.nextLong(), b = sc.nextLong(), c = sc.nextLong();
        
        out.println((c - a - b) > 0 && 4 * a * b < (c - a - b) * (c - a - b) ? "Yes" : "No");

        out.flush();
    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21332
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
int main()
{
	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;
	if(s == u)
	{
		printf("%d %d\n", --a, b);
	}
	else
	{
		printf("%d %d\n", a, --b);
	}
}

Measured memory_bytes: 256
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))

ans = []

for i in range(len(a)):
    ans = ans + [i+1]*a[i]
for i in range(h):
    if i%2 == 0:
        c = ans[w*i:w*(i+1)]
        print(" ".join(map(str, c)))
    else:
        c = ans[w*i:w*(i+1)]
        c1 = c[::-1]
        print(" ".join(map(str, c1)))

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 998244353;
const int MAXN = 100010, LOG=20;

ll n, m, k, u, v, x, y, t, a, b, ans;
ll sum[3][MAXN], tav[MAXN];
int mark[MAXN];
int g[MAXN];
vector<int> G[MAXN];

void Solve(int id){
	memset(mark, 0, sizeof(mark));
	memset(g, 0, sizeof(g));
	memset(G, 0, sizeof(G));
	cin>>m;
	while (m--){
		cin>>u>>v;
		if (u>v) swap(u, v);
		G[u].pb(v);
	}
	
	for (int i=n-1; i; i--){
		for (int v:G[i]) mark[g[v]]=i;
		while (mark[g[i]]==i) g[i]++;
	}
	for (int i=1; i<=n; i++) sum[id][g[i]]=(sum[id][g[i]] + tav[i])%mod;
	
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	tav[0]=1;
	tav[1]=1000000000000000000ll%mod;
	for (int i=2; i<MAXN; i++) tav[i]=tav[i-1]*tav[1]%mod;
	cin>>n;
	Solve(0);
	Solve(1);
	Solve(2);
	for (int i=0; sum[0][i]; i++)
		for (int j=0; sum[1][j]; j++)
			ans=(ans + sum[0][i]*sum[1][j]%mod*sum[2][i^j])%mod;
	
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 11776
#include <stdio.h>
#include <string.h>

int main(){
    int i,k,n;
    char a[53];
    
    scanf("%d %d",&n,&k);
    scanf("%s",a);
    
    a[k-1]=a[k-1]+32;
    
    printf("%s\n",a);
    
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const int MOD = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  int a, b;
  cin >> a >> b;
  if (b == 1)	cout << 0;
  else if (a >= b)	cout << 1;
  else
  {
	for (int i = 2; i < 100; i++)
	{
		int x = (a - 1) * i + 1;
		if (x >= b)
		{
			cout << i;
			break;
		}
	}
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n; cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  vector<int> c(n+1);
  c[0] = 3;
  ll ans = 1;
  REP(i,n) {
    ans*=c[a[i]];
    ans%=MOD;
    c[a[i]]--;
    c[a[i]+1]++;
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
#define cina(a, n) for (int i = 0; i < n; ++i){ cin >> a[i]; }
#define ll long long
#define ld long double

using namespace std;

int main () {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, d, c = 0;
	cin >> n >> d;
	double x[n], y[n];
	for (int i = 0; i < n; ++i) {
		cin >> x[i] >> y[i];
		if (sqrt(pow(x[i],2)+pow(y[i],2)) <= d) {
			c++;
		}
	}
	cout << c;
	return 0;
}


Measured memory_bytes: 6812
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

int main()
{
    int n, a, b;
    cin >> n >> a >>b;

    int ans = 0;
    rep(i,n+1) {
        int tmp = 0;
        int j = i;
        while(j > 0) {
            tmp += j % 10;
            j /= 10;
        }
        if (tmp >= a && tmp <= b)
            ans += i;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int W,a,b;
  cin>>W>>a>>b;
  if(min(a,b)+W>=max(a,b)) {
    cout<<"0"<<endl;
  }
  else {
    cout<<max(a,b)-(min(a,b)+W)<<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <algorithm>

using namespace std;

struct Shop
{
  int score;
  int index;
  string city;
};

bool compare(const Shop& a, const Shop& b) {
  return a.city == b.city ? a.score > b.score : a.city < b.city;
}

int main()
{
  int N;
  cin >> N;
  vector<Shop> shops(N);
  for (int i=0;i<N;i++) {
    shops[i].index = i+1;
    cin >> shops[i].city >> shops[i].score;
  }
  sort(shops.begin(), shops.end(), compare);
  for (int i=0;i<N;i++) {
    cout << shops[i].index << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int i,n,t[50],m,sum=0;
    char s[50][101],x[101];

    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%s %d",s[i],&t[i]);
    }
    scanf("%s",x);
    for(i=0;i<n;i++)
    {
        if(strcmp(s[i],x)==0)
        {
             m=i;
             break;
        }
    }
    for(i=m+1;i<n;i++)
    {
        sum+=t[i];
    }
    printf("%d",sum);

    return 0;
}


Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

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


class CTrainTicket {
public:
    string a;
    string vs;

    bool dfs(int v, string s) {
      if (v == 3) {
        int ans = a[0] - '0';
        REP(i, 3) {
          if (s[i] == '+') {
            ans += a[i + 1] - '0';
          } else {
            ans -= a[i + 1] - '0';
          }
        }
        if (ans == 7) {
          vs = s;
          return true;
        } else {
          return false;
        }
      }
      if (dfs(v + 1, s + "+")) return true;
      if (dfs(v + 1, s + "-")) return true;
      return false;
    }

    void solve(std::istream &in, std::ostream &out) {
      REP(i, 4) in >> a[i];
      dfs(0, "");
      string ret = to_string(a[0] - '0');
      REP(i, 3) {
        ret += vs[i];
        ret += a[i + 1];
      }
      out << ret + "=7" << endl;
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  CTrainTicket solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


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


int main() {
	int X, Y, Z;
	int K;
	cin >> X >> Y >> Z;
	cin >> K;
	vector<long long> A(X), B(Y), C(Z);

	for (int i = 0; i < X; i++) cin >> A[i];
	for (int i = 0; i < Y; i++) cin >> B[i];
	for (int i = 0; i < Z; i++) cin >> C[i];

	vector<long long> AB;
	for (int i = 0; i < X; i++)
	{
		for (int j = 0; j < Y; j++)
		{
			AB.push_back(A[i] + B[j]);
		}
	}
	sort(AB.begin(), AB.end());
	reverse(AB.begin(), AB.end());

	vector<long long> ABC;

	for (int i = 0; i < min(K, (int)AB.size()); i++)
	{
		for (int j = 0; j < Z; j++)
		{
			ABC.push_back(AB[i] + C[j]);
		}
	}

	sort(ABC.begin(), ABC.end());
	reverse(ABC.begin(), ABC.end());

	for (int i = 0; i < K; i++)
	{
		cout << ABC[i] << endl;
	}

}



Measured memory_bytes: 43368
import Control.Applicative
import Data.Array.IArray

type CompBinTree = Array Int Int

main = do
        n <- readLn
        list <- map read.words<$>getLine
        let cbt = listArray (1,n) list :: CompBinTree
        mapM_ (\i -> printIDInfo i cbt) [1..n]

idInfo nid cbt = [key nid cbt, parentKey nid cbt, leftKey nid cbt, rightKey nid cbt]
key :: Int -> CompBinTree -> Maybe Int
key nid cbt = Just $ cbt ! nid

parentKey :: Int -> CompBinTree -> Maybe Int
parentKey nid cbt
    | pid <= 0 = Nothing
    | otherwise = Just $ cbt ! pid
    where pid = nid `div` 2

leftKey :: Int -> CompBinTree -> Maybe Int
leftKey nid cbt
    | not (inBounds lid cbt) = Nothing
    | otherwise              = Just $ cbt ! lid
        where lid = nid * 2

rightKey nid cbt
    | not (inBounds rid cbt) = Nothing
    | otherwise              = Just $ cbt ! rid
    where rid = nid * 2  + 1

inBounds :: (Ix i) => i -> Array i e -> Bool
inBounds i arr = i >= l && i <= r
    where (l,r) = bounds arr

printIDInfo nid cbt = do
        putStr $ "node " ++ show nid ++ ": "
        sequence_ $ zipWith (\f a -> f a) [printKey, printPKey, printLKey, printRKey] (idInfo nid cbt)
        putStrLn ""
printInfo :: (Show a) => String -> Maybe a -> IO ()
printInfo str Nothing = putStr ""
printInfo str (Just x) = putStr $ str ++ show x ++ ", "
printKey :: (Show a) => Maybe a -> IO ()
printKey = printInfo "key = "
printLKey :: (Show a) => Maybe a -> IO ()
printLKey = printInfo "left key = "
printRKey :: (Show a) => Maybe a -> IO ()
printRKey = printInfo "right key = "
printPKey :: (Show a) => Maybe a -> IO ()
printPKey = printInfo "parent key = "

Measured memory_bytes: 4140
#include <iostream>
#include <vector>
#include <cmath>

#define LMIN 0
#define RMAX 1000
#define REPNUM 80
using namespace std;

typedef struct P
{
  double x, y;
}P;

inline double dist(P a, P b)
{
  double dx = a.x - b.x;
  double dy = a.y - b.y;
  return (dx * dx + dy * dy);
}

double f(vector<P>& p, double x, double y)
{
  double res = 0;
  for(int i = 0; i < p.size(); ++i)
  {
    res = max(res, dist((P){x, y}, p[i]));
  }
  return sqrt(res);
}

double g(vector<P>& p, double x)
{
  double l = LMIN, r = RMAX;
  //for(int i = 0; i < REPNUM; ++i)
  while(abs(l-r) > 1e-7)
  {
    double c1 = (l * 2 + r) / 3;
    double c2 = (l + r * 2) / 3;
    if(f(p, x, c1) > f(p, x, c2))
      l = c1;
    else
      r = c2;
  }
  return f(p, x, l);
}

int main()
{
  int n;
  cin >> n;
  vector<P> p(n);
  for(int i = 0; i < n; ++i)
    cin >> p[i].x >> p[i].y;

  double l = LMIN, r = RMAX;
  //for(int i = 0; i < REPNUM; ++i)
  while(abs(l-r) > 1e-7)
  {
    double c1 = (l * 2 + r) / 3;
    double c2 = (l + r * 2) / 3;
    if(g(p, c1) > g(p, c2))
      l = c1;
    else
      r = c2;
  }
  printf("%.10f\n", g(p, l));
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define maxn 20
using namespace std;
ll mp[maxn][maxn], val[maxn], mx, cnt, used[maxn], ch[maxn];
void get_mx(int dep, int n, ll x)
{
	if (dep > n) mx = max(mx, x);
	else
	for (int i = 1; i <= n; i++)
		if (used[i] == 0)
		{
			ch[dep] = i;
			used[i] = 1;
			if (dep == 1) get_mx(dep + 1, n, x);
			else get_mx(dep + 1, n, mp[ch[dep - 1]][i] + x);
			used[i] = 0;
		}
}
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= 1000; i++)
	{
		int flag = 1;
		for (int j = 1; j <= cnt; j++)
			for (int k = j + 1; k <= cnt; k++)
			{
				if (j == k) continue;
				if (val[j] + val[k] == i) flag = 0;
				for (int l = 1; l <= cnt; l++)
					if (val[j] + val[k] == i + val[l]) flag = 0;
			}
		if (flag)
		{
			val[++cnt] = i;
			if (cnt == n) break;
		}
	}
	mp[1][2] = mp[2][1] = 1;
	for (int i = 3; i <= n; i++)
	{
		mx = 0;
		get_mx(1, i - 1, 0);
		for (int j = 1; j <= i - 1; j++)
			mp[j][i] = mp[i][j] = (mx + 1) * val[j];
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
			cout << mp[i][j] << " ";
		cout << endl;
	}
}

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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C& _a4, C _b4) { _a4 = min(_a4, _b4); }
template<class C> void maxi(C& _a4, C _b4) { _a4 = max(_a4, _b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream& operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto& vv : V) os << vv << ","; os << "]";
  return os;
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAX = 100001;
int n,m,il[MAX];
bool cz[MAX];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n;
  R(i,n)il[i] = 1;
  cz[0] = 1;
  cin >> m;
  while(m--){
    int a,b;
    cin >> a >> b;
    a--;b--;
    il[b] ++;
    cz[b] |= cz[a];
    il[a] --;
    if(il[a] == 0)cz[a] = 0;
  }
  int res = 0;
  R(i,n){
    if(cz[i])res++;
  }
  cout << res << "\n";
}


Measured memory_bytes: 1152
#include<stdio.h>
int main(){
    int i,n;
    long long int sum=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0)
        sum=sum+i;
    }
    printf("%lld",sum);
    return 0;
}

Measured memory_bytes: 1736
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
ll MOD=1000000007;
class DIJ{
	public:
	struct edge{
		int to,cost;
	};
	vector<vector<edge> >G;
	int n;
	vi d,co;//distance
	DIJ(int size){
		n=size;
		G=vector<vector<edge> >(n);
	}
	void add_edge(int a,int b,int c){
		edge e={b,c},ee={a,c};
		G[a].pb(e);
		G[b].pb(ee);
	}
	void dij(int s){
		d=vi(n,inf);
		co=vi(n);
		d[s]=0;
		co[s]=1;
		priority_queue<pii>q;
		q.push(pii(0,s));
		while(!q.empty()){
			pii p=q.top();
			q.pop();
			int pos=p.second,cost=-p.first;
			if(cost>d[pos])continue;
			rep(i,G[pos].size()){
				edge e=G[pos][i];
				int to=e.to;
				int nowcost=cost+e.cost;
				if(nowcost<d[to]){
					d[to]=nowcost;
					co[to]=co[pos];
					q.push(pii(-d[to],to));
				}else if(nowcost==d[to])
					(co[to]+=co[pos])%=MOD;
			}
		}
	}
};
signed main(){
	int n,m,s,t;
	cin>>n>>m>>s>>t;s--;t--;
	DIJ dij(n);
	while(m--){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		dij.add_edge(a,b,c);
	}
	dij.dij(s);
	vi sd=dij.d,sco=dij.co;
	dij.dij(t);
	vi td=dij.d,tco=dij.co;
	
	int out=sco[t]*sco[t]%MOD;
	rep(i,n){
		if(sd[i]+td[i]==sd[t]&&sd[i]==td[i])(out+=MOD-(sco[i]*tco[i]%MOD)*(sco[i]*tco[i]%MOD)%MOD)%=MOD;
		rep(j,dij.G[i].size())if(
			sd[i]+dij.G[i][j].cost+td[dij.G[i][j].to]==sd[t]&&
			sd[i]*2<sd[t]&&td[dij.G[i][j].to]*2<sd[t]
		)(out+=MOD-(sco[i]*tco[dij.G[i][j].to]%MOD)*(sco[i]*tco[dij.G[i][j].to]%MOD)%MOD)%=MOD;
	}
	cout<<out<<endl;
}

















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

int main() {
  ll n;
  cin >> n;
  ll s[n];  // a_0 ~ a_i の累積和
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    ll a;
    cin >> a;
    if (i == 0) {
      s[0] = a;
    } else {
      s[i] = s[i - 1] + a;
    }
    sum += a;
  }

  ll ans = 1e18;
  for (int i = 0; i < n; i++) {
    ans = min(ans, abs(sum - 2 * s[i]));
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int P=1e9+7;
const int M=2e5+5;
int n,m;
int a[M],col[M];
int id[M],pre[M];
ll ss[M],sum[M];
void solve(){
	sum[0]=1;
	for(int i=1;i<=m;i++){
		(sum[i]+=sum[i-1])%=P;
		if(!pre[i])continue;
		int s=sum[pre[i]-1];
		(ss[a[i]]+=s)%=P;
		(sum[i]+=ss[a[i]])%=P;
	}
	printf("%d\n",sum[m]);
}
void Init(){
	for(int i=1;i<=m;i++){
		if(id[a[i]])pre[i]=id[a[i]];
		id[a[i]]=i;
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",col+i);
	for(int i=1;i<=n;i++)if(col[i]!=col[i-1])a[++m]=col[i];
	Init();solve();
	return 0;
}

Measured memory_bytes: 6528
#include <cstdio>
#include <bitset>

using namespace std;

const int maxn=1e5+5, maxk=105;

bitset < maxn > dp;
int a[maxk];

int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	int x;
	bool p;
	for(int i=0; i<=k; i++){
		p=1;
		for(int j=0; j<n; j++){
			x=i-a[j];
			if(x>=0){
				p&=dp[x];
			}
		}
		dp[i]=p^1;
	}
	if(dp[k]){
		printf("First\n");
	}
	else{
		printf("Second\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const bool debug = true;
 
int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i=1;i<=n;i++){
        ll x = n/i;
        ans += i * x * (x+1) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  vector<string> s(3);
  rep(i,3){
    cin >> s.at(i);
  }
  int c=0;
  vector<int> a(3,0);
  while(1){
    int cp=c;
    a.at(c)++;
    for(int i=0;i<3;i++){
      if(a.at(i)>s.at(i).size()){
        char d='A'+i;
        cout << d;
        return 0;
      }
    }
    c=s.at(cp).at(a.at(cp)-1)-'a';
  }
}
    

Measured memory_bytes: 3524
N, M, X, Y = map(int, input().split())
x = sorted(list(map(int, input().split())))
y = sorted(list(map(int, input().split())))
maxx = max(x)
miny = min(y)
for z in range(1, Y - X + 1):
  if X + z > maxx and X + z <= miny:
    print("No War")
    exit(0)
print("War")

Measured memory_bytes: 38384
/*
   Created by Rahul Goel.
*/

#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1e9;
const ll LINF = 1e18;

#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(c) (c).begin(), (c).end()
#define pii pair < ll, ll >
#define vi vector < ll >
#define vb vector < bool >
#define vvi vector < vector < ll > >
#define vvb vector < vector < bool > >
#define vpii vector < pair < ll, ll > >
#define vvpii vector < vector < pair < ll, ll > > >
#define pb push_back
#define f first
#define s second
#define mp make_pair

ll solve(){
    int s, w;
    cin >> s >> w;
    if(w>=s)
        cout << "unsafe" << endl;
    else
        cout << "safe" << endl;
    return 0;
}

int main(){
    fastio;

    ll t = 1;
    while(t--)
        solve();

    return 0;
}


Measured memory_bytes: 3692
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
int top,S[1000];
 
void push(int x){
    S[++top]=x;
}
 
int pop(){
    top--;
    return S[top+1];
}
 
int main(){
    int a,b;
    char s[100];
    top=0;
    while(scanf("%s",s)!=EOF){
        if(s[0]=='+'){
            a=pop();
            b=pop();
            push(a+b);
        }else if(s[0]=='-'){
            b=pop();
            a=pop();
            push(a-b);
        }else if(s[0]=='*'){
            a=pop();
            b=pop();
            push(a*b);
        }else{
            push(atoi(s));
        }
    }
     
    printf("%d\n",pop());
     
    return 0;
}
 

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

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

char opr[3] = { '+','-','*' };

int calc(int a, int b, int c) {
	if (c == 0) return a + b;
	if (c == 1) return a - b;
	return a * b;
}

void permutations(int a, int b, int c, int d) {
	int per[4] = {0};
	REP(i, 4) { REP(j, 4) { REP(k, 4) { REP(l, 4) {
		if (k == i || k == j || i == j || 
			l == i || l == j || l == k) continue;
						
		per[i] = a;
		per[j] = b;
		per[k] = c;
		per[l] = d;

		REP(f, 3) { REP(g, 3) { REP(h, 3) {
			if (calc(calc(per[0], per[1], f), calc(per[2], per[3], h), g) == 10) {
				printf("((%d %c %d) %c (%d %c %d))\n",per[0], opr[f], per[1], opr[g], per[2], opr[h], per[3]);
				return;
			}

			if (calc(calc(calc(per[0], per[1], f), per[2], g), per[3], h) == 10) {
				printf("(((%d %c %d) %c %d) %c %d)\n", per[0], opr[f], per[1], opr[g], per[2], opr[h], per[3]);
				return;
			}
		} } }
	} } } }
	cout << 0 << endl;
}

int main() {
	int a, b, c, d;

	while (cin >> a >> b >> c >> d) {
		if (a == 0 && b == 0 && c == 0 && d == 0) break;

		permutations(a, b, c, d);
	}
	return 0;
}

Measured memory_bytes: 3140
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define int long long
#define endl "\n"
const double PI = 3.14159265358979323846;
int n;


signed main()
{
    FAST;
    
    int i=0,j=0,k=0,nn=0,m=0,count=0,temp=0;
    int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
    int left=0,up=0,down=0,start=0,end=0,r=0,q=0,total=0;
    int maxx=0,minn=0,curr=0,anss=0,places=0,zeroes=0,low=0,high=0;
    int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
    
    cin>>n>>m;
    
    vector<int> adj[n+1];
    vector<int> ans(n+1);
    bool visited[n+1];
    
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    
    for(i=0;i<=n;i++)
    {
        ans[i]=0;
        visited[i]=0;
    }
    
    queue<int> que;
    
    que.push(1);
    visited[1]=true;
    while(!que.empty())
    {
        temp = que.front();
        que.pop();
        
        for(auto it: adj[temp])
        {
            if(visited[it]==false)
            {
                visited[it]=true;
                que.push(it);
                ans[it]=temp;
            }
        }
    }
    
    for(i=1;i<=n;i++)
    {
        if(visited[i]==false)
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    
    cout<<"Yes"<<endl;
    
    for(i=2;i<=n;i++)
    {
        cout<<ans[i]<<endl;
    }
    
    
    
    
    
    
}

Measured memory_bytes: 13016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define double long double
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()



signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  string s;
  ll n;
  
  cin >> n;
  
  ll a = n / 500;
  ll b = n % 500;
  
  cout << a*1000 + (b/5)*5 << "\n";
  
}


Measured memory_bytes: 256
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def merge_sort(A):
    N = len(A)
    if N < 2:
        return A, 0
    mid = N//2
    left, left_count = merge_sort(A[:mid])
    right, right_count = merge_sort(A[mid:])
    total_count = left_count+right_count
    lowers = 0
    answer = []
    for l in left:
        while lowers < len(right) and right[lowers] < l:
            answer.append(right[lowers])
            lowers += 1
        total_count += lowers
        answer.append(l)
    while lowers < len(right):
        answer.append(right[lowers])
        lowers += 1
    return answer, total_count


def solve():
    N, K = read_ints()
    A = read_ints()
    _, left_greater = merge_sort(A)
    _, right_greater = merge_sort(A[::-1])
    modulo = 10**9+7
    return (K*(K+1)//2*left_greater+K*(K-1)//2*right_greater)%modulo


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 75860
#include<bits/stdc++.h>
#define ll long long
#define sz size
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define fst first
#define scd second
#define pb push_back
#define ne '\n'
#define ne1 endl
#define MOD(x)  x%int(1e9+7)
//::== dana_paani
//====================================================================================================================================//
 
using namespace std;
 
void solve()
{
} 


int main()
{
//   int t;
//   cin>>t;
//   while(t--)
int a, b;
cin>>a>>b;
cout<<a*b<<endl;

return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = 1001002003004005006ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, h;
	cin >> a >> b >> h;
	cout << (a + b) * h / 2 << endl;
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <cstring>
#define ll long long
#define pa pair<int,int>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(abs(a - b) <= 1)
    {
        cout<<"Yay!"<<endl;
    }
    else
    {
        cout<<":("<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
	int n, k;
	cin >> n>> k;
	int a[n] = {0};
	for (int i=0;i< k;i++) {
		int d;
		cin >>d;
		int temp;
		for(int j=0;j< d;j++){
			
			cin >> temp;
			a[temp-1]++;
		}
	}
	int res=0;
	for (int i=0;i< n;i++) {
		if(a[i]==0){
			res++;
		}
	}
	cout << res<< "\n";
}

Measured memory_bytes: 3640
#include<bits/stdc++.h> 
using namespace std;
int solve(int N, vector<int>& heights, vector<int>& dp, int K){
	if (N<=1 or K==0) return 0;
	if (N==2 and K>=1) return dp[N]=abs(heights[0]-heights[1]);
	if (dp[N]!=-1) return dp[N];
	int ans=INT_MAX;
	for (int i=1;i<=K;i++){
		if (N-i-1<0) break;
		ans=min(ans,solve(N-i,heights,dp,K)+abs(heights[N-1]-heights[N-i-1]));
	}
	return dp[N]=ans;
}
int main() {
	int N,K;
    cin>>N>>K;
    vector<int> heights(N);
    vector<int> dp(N+1,-1);
    for (int i=0;i<N;i++){
    	cin>>heights[i];
    }
    if (N==1) cout<<heights[0];
    else
	    cout<< solve(N,heights,dp,K)<<endl;
    return 0; 
}


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

int main() {
  int N;
  cin >> N;
  vector<int> number(N);
  for(int i = 0; i < N; i++){
    cin >> number.at(i);
  }
  int count = 0;

  for(int i = 0; i  < N; i++){
    if(number.at(i) != i + 1){
      count++;
    }
  }
  if(count == 2 || count == 0){
    cout << "YES" <<endl;
  }
  else{
    cout << "NO" <<endl;
  }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    string S;
    int n;
    cin >> n >> S;
    int ans = 0;
    S += "#";
    for(int i = 0;i < n;i++){
        if(S[i] != S[i+1])ans++;
        else continue;
    }
    cout << ans << endl;
    //cin >> n;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int n,m;
double l;
int t[101];
double pp[101][55];
double psum[101][55];
double p[101],v[101];
double tt[101][55];
double win[101];
double comb[101][101];

int main(void){
	comb[0][0]=1;
	for(int i=1;i<=100;i++){
		comb[i][0]=1;
		comb[i][i]=1;
		for(int j=1;j<i;j++){
			comb[i][j]=comb[i-1][j]+comb[i-1][j-1];
		}
	}
	scanf("%d %d %lf",&n,&m,&l);
	for(int i=0;i<n;i++){
		scanf("%lf %d %lf",&p[i],&t[i],&v[i]);
		p[i]=p[i]/100.0;
	}
	for(int j=0;j<n;j++){
		for(int k=0;k<=m;k++){
			pp[j][k]=comb[m][k];
			for(int l=0;l<k;l++){
				pp[j][k]*=p[j];
			}
			for(int l=0;l<m-k;l++){
				pp[j][k]*=(1.0-p[j]);
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<=m;j++){
			psum[i][j+1]=psum[i][j]+pp[i][j];
		}
	}
	for(int i=0;i<n;i++){
		if(v[i]==0.0){
			for(int j=0;j<=m+1;j++){
				tt[i][j]=1000000000.0;
			}
			continue;
		}
		tt[i][0]=l/v[i];
		for(int j=1;j<=m;j++){
			tt[i][j]=tt[i][j-1]+t[i];
		}
		tt[i][m+1]=1000000000.0;
	}
	for(int i=0;i<n;i++){
		if(v[i]==0.0)continue;
		for(int l=0;l<=m;l++){
			double wp=pp[i][l];
			for(int k=0;k<n;k++){
				if(k==i)continue;
				if(v[k]==0.0)continue;
				int uk=upper_bound(tt[k],tt[k]+m+2,tt[i][l])-tt[k];
				wp*=(1.0-psum[k][uk]);
				//printf("%lf %lf %f\n",tt[i][l],tt[k][uk],psum[k][uk]);
			}
			win[i]+=wp;
		}
	}
	for(int i=0;i<n;i++){
		printf("%.8f\n",win[i]);
	}
	return 0;
}

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

#define lld long long

int main(){
    unsigned long long N,K;
    cin >> N >> K;
    cout << min(N%K,-1*(N%K-K)) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int n, m, A, B;
int main() {
	int i, j;
	scanf("%d%d%d%d", &n, &m,&A,&B);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			if ((j < A) == (i < B))printf("0");
			else printf("1");
		}
		puts("");
	}
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#define llint long long
#define mod 1000000007

using namespace std;

llint x, y;

const int FACT_MAX = 3000005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}

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

  cin >> x >> y;
  make_fact();
  if((x+y)%3){
    cout << 0 << endl;
    return 0;
  }

  if(x > y) swap(x, y);
  llint d = (x+y)/3, p = y-x;
  if((d+p) % 2 || d < p){
    cout << 0 << endl;
    return 0;
  }

  llint r = (d+p)/2;
  cout << comb(d, r) << endl;
  return 0;
}


Measured memory_bytes: 47232
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()
    cnt = collections.Counter(A)

    start = 1 if N % 2 == 0 else 0
    m = 0
    for n in range(start, N, 2):
        if n == 0 and cnt[n] == 1:
            continue
        elif cnt[n] == 2:
            m += 1
            continue
        else:
            print(0)
            exit()
    print((2**m)%MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20204
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

const int maxn = 303;
int f[maxn][maxn][maxn] , l , k;
char s[maxn];
int main(){
	cin >> s + 1 >> k;
	l = strlen(s + 1);
	int ans = 1;
	for(int c = 0 ; c <= k ; ++ c){
		for(int i = 1 ; i < l ; ++ i){
			for(int j = l ; j > i ; -- j){
				if(s[i] == s[j])
					f[i][j][c] = max(f[i][j][c] , f[i - 1][j + 1][c] + 1);
				else if(c > 0)
					f[i][j][c] = max(f[i][j][c] , f[i - 1][j + 1][c - 1] + 1);
				f[i][j][c] = max(f[i][j][c] , f[i - 1][j][c]);
				f[i][j][c] = max(f[i][j][c] , f[i][j + 1][c]);
				f[i][j][c] = max(f[i][j][c - 1] , f[i][j][c]);
			}
			ans = max(ans , f[i][i + 1][c] * 2);
			if(i < l - 1)
				ans = max(ans , f[i][i + 2][c] * 2 + 1);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 108416
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
  
/*------------------------------------------------------------------*/
int main(){
    ll n, a, b; cin >> n >> a >> b;
    cout <<  n / (a + b) * a + min(n % (a + b), a) << endl;
}


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

#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vpii        vector< pii >
#define vi          vector<ll>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			1'010'000'000'000'000'017LL
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define sz(x)       (ll)x.size()
#define rep(i,a,b)	for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )

using namespace std;

template<class T>
bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>
bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
ll DivisorCount(ll x) {
	ll ans = 1;
	for (int i = 2; i <= sqrt(x); i++) {
		int cnt = 0;
		while (x % i == 0) {
			cnt++;
			x /= i;
		}
		ans *= (cnt + 1);
		if (x == 1) break;
	}
	if (x != 1) ans *= 2;
	return ans;
}

void Main() {
	ll N, K;
	cin >> N >> K;
	vi A(N, 0);
	rep(i, 0, N) cin >> A[i];

	rep(i, 0, N - K) {
		cout << ((A[i] < A[i + K]) ? "Yes" : "No") << endl;
	}
}




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

	Main();
	return 0;
}


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


const ll MOD = 1000000007;

ll mypow(ll x, ll n){
  if(n == 0)
    return 1;
 
  if(n % 2 == 0)
    return mypow(x * x, n / 2);
  else
    return x * mypow(x, n - 1);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> dp(k + 1, 0);
  ll ans = 0;
  for (ll i = k; i > 0; i--){
    ll num = k / i;
    ll tmp = modpow(num, n, MOD);
    dp[i] = tmp;
    ll i_i = i * 2;
    while(i_i <= k){
      dp[i] -= dp[i_i];
      i_i += i;
    }
  }
  for (ll i = 1; i <= k; i++){
    ans += dp[i] * i % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3944
#include <stdio.h>
#include <stdlib.h>

int main(void){
    long long int n, ans=0, i;
    scanf("%lld", &n);
    long long int t, a, anstmp, tmp;
    long long int h[n];
    scanf("%lld %lld", &t, &a);
    for(i=0; i<n; i++){
        scanf("%lld", &h[i]);
    }
    for(i=0; i<n; i++){
        tmp = abs((t*1000 - h[i]*6) - a*1000);
//        printf("%lld\n", tmp);
        if(i==0){
            anstmp = tmp;
        }else if(tmp<anstmp){
            anstmp = tmp;
            ans = i;
        }
    }
    printf("%lld", ans+1);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
        int N,X;cin >> N >> X;
        if(N == 0 && X == 0) return 0;
        int sum = 0;N++;
        REPP(i,1,N) REPP(j,i+1,N) REPP(k,j+1,N){
                    if(i + j + k == X) sum++;
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 3180
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.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;
 
const ll inf = 1e9 + 7;
const ll Mod = 998244353;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

int main(){
  ll N; cin >> N;
  string S; cin >> S;

  vector <ll> R, G, B;
  for (int i = 0; i < N; i++){
    if (S[i] == 'R') R.push_back(i);
    if (S[i] == 'G') G.push_back(i);
    if (S[i] == 'B') B.push_back(i);
  }

  ll ans = 0;
  for (int i = 0; i < N; i++){
    for (int j = i + 1; j < N; j++){
      if (S[i] == S[j]) continue;

      int k = 2 * j - i;
      if (S[i] != 'R' && S[j] != 'R'){
        auto iter = upper_bound(R.begin(), R.end(), j);
        ans += R.end() - iter;
        if (k < S.length() && S[k] == 'R') ans--;
      }
      if (S[i] != 'G' && S[j] != 'G'){ 
        auto iter = upper_bound(G.begin(), G.end(), j);
        ans += G.end() - iter;
        if (k < S.length() && S[k] == 'G') ans--;
      }
      if (S[i] != 'B' && S[j] != 'B'){
        auto iter = upper_bound(B.begin(), B.end(), j);
        ans += B.end() - iter;

        if (k < S.length() && S[k] == 'B') ans--;
      }
    }
  }
  cout << ans << endl;
  


  return 0;
}


Measured memory_bytes: 3636
while True :
	m, f, r = map(int, input().split())
	if m == -1 and f == -1 and r ==-1 :
		break
	if m == -1 or f == -1 :
		print("F")
	elif m + f >= 80 :
		print("A")
	elif 65 <= m + f < 80 :
		print("B")
	elif 50 <= m + f < 65 :
		print("C")
	elif 30 <= m + f < 50 :
		if r >= 50 :
			print("C")
		else :
			print("D")
	else :
		print("F")



Measured memory_bytes: 5592
#include <iostream>
#include <string>
#include <stdlib.h>

using namespace std;

string s;

int main(void)
{
	cin >> s;
	int ans = 1e9;
	for(int i = 0; i < (int)s.size()-2; i++){
		ans = min(ans, abs(atoi(s.substr(i, 3).c_str()) - 753));
	}
	cout << ans << endl;
}

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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

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

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int K, S;
  cin >> K >> S;
  int cnt = 0;
  rep(x, K+1)
    rep(y, K+1)
      if(S - K <= x + y && x + y <= S) cnt++;
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 256