akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main(){
  int n; cin >> n;
  ll a[n];
  rep(i, n) cin >> a[i];
  ll mx = -1, ans = 0;
  rep(i, n){
    mx = max(mx, a[i]);
    ans += max(mx - a[i], (ll)0);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;




int main() 
{

 fast();
  
  // #ifndef ONLINE_JUDGE
  //   freopen("input.txt", "r", stdin);
  //   freopen("output.txt","w",stdout);
  // #endif
  
ll a,l;
cin>>a>>l;
vec q(a);

	f(i,0,a)
	{
		q[i]=l+i;
		// cout<<q[i]<<" ";
	}
	ll q1=accumulate(all(q),0);
	// cout<<q1;
	
	ll mi=1222222211;
	if(l<0)
	{
		sort(all(q));
	f(i,0,a)
	{
		mi=min(mi,abs(q[i]-q1));
	}
	if(count(all(q),0)!=0)
	cout<<q1;
	else
	cout<<q1-q[a-1];	
	}
	else if(l>-1)
	{


	cout<<q1-q[0];
}
	
	

  


    




    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;


} 

Measured memory_bytes: 256
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	ll n, a, b;
	cin >> n >> a >> b;
	if (a > b)cout << 0 << endl;
	else if (n == 1 && a != b)cout << 0 << endl;
	else
	{
		ll mn = b + a * (n - 1);
		ll mx = a + b * (n - 1);
		cout << mx - mn + 1 << endl;
	}
}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  long long int a=0,b=0,c=0,d=0,k=0,m=0,n=0,h=0,count=0,ans=0;
  string s;
  bool flag=true;
  cin>>n>>k;
  vector<int> v(k);
  rep(i,k) cin>>v[i];
  while(flag){
    int nn=n;
    vector<int> w;
    while(nn!=0){
      w.push_back(nn%10);
      nn/=10;
    }
    
    bool hata=true;
    
    for(auto x:v){
      for(auto y:w){
        if(x==y){
          hata=false;
          break;
        }
        
      }
      if(!hata) break;
    }
    if(hata) flag=false;
    else n++;
  }
  cout<<n<<endl;
}
///////////////////////////



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

struct UnionFind{
    vector<int> parent;

    UnionFind(int n) : parent(n){
        for (int i = 0; i < n; i++)parent[i] = i;
    }
    int find(int e){
        if (parent[e] == e) return e;
        else return parent[e] = find(parent[e]);
    }

    void unite (int a, int b) {
        a = find(a);
        b = find(b);
        if (a == b) return;
        parent[a] = b;
    }
    bool same(int a, int b){
        return find(a) == find(b);
    }
};

int main() {
    int n, q, c, x, y;
    cin >> n >> q;
    UnionFind uf(n);
    for (int i = 0; i < q; i++){
        cin >> c >> x >> y;
        if(c){
            cout << (uf.same(x, y) ? "1" : "0") << endl;
        } else {
            uf.unite(x, y);
        }
    }
}


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

int main() {
  int N;
  cin >> N;
  int n = N % 10;
  if ((n == 2) || (n == 4)|| (n == 5) || (n == 7) || (n ==9)) {
    cout << "hon" << endl;
  }
  if ((n == 0) || (n == 1) || (n == 6) || (n == 8)) {
    cout << "pon" << endl;
  }
  if (n == 3) {
    cout << "bon" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3596
#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 tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define MOD2 1494318097
#define SEED 131
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

#define MAXN 200005

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unordered_map<int,int> umii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

mt19937 g1(time(0));

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ll randlong(ll a,ll b){return uniform_int_distribution<long long>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int len,res=1;
char s[MAXN];

int main(){
	scanf("%s",s+1); len = (int)strlen(s+1);
	if(len == 1) return 0*printf("1\n");
	for(int i=2; i<=len; i++){
		if(s[i] != s[i-1]) res++;
		else{
			if(i == len) break;
			else if(i == len-1) res++,i++;
			else res+=2,i+=2;
		}
	}
	printf("%d\n",res);
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline
import bisect

sys.setrecursionlimit(10**7)
n = int(input())
l = list(map(int,input().split()))
e = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    e[a].append(b)
    e[b].append(a)


ans = [0]*n
ans[0] = 1
dp = [l[0]]

def dfs(now,bef):
    
    change = True
    if l[now] > dp[-1]:
        dp.append(l[now])
    else:
        index = bisect.bisect_left(dp,l[now])
        change = False
        s = dp[index]
        dp[index] = l[now] 
    ans[now] = len(dp)
    
    for nex in e[now]:
        if nex != bef:
            dfs(nex,now)
    if change:
        dp.pop()
    else:
        dp[index] = s 

for i in e[0]:
    dfs(i,0)

for i in ans:
    print(i)



Measured memory_bytes: 223296
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>

using namespace std;
 
#define  GODSPEED       ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define  f              first                 
#define  s              second
#define  newl           cout<<"\n";
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<"\n";
#define  deb2(a,b)      cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define  all(a)         a.begin(),a.end()           
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   N     =  1e6+5;
const ll   mod   =  1e9;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;

ll test = 1, k;

void solve(){
	int ans = 0;
	cin >> k;
	ll i = 1, j = 7%k;
	while(1){
		if(j == 0){
			deb1(i)
			return;
		}
		i++;
		j = (j*10+7)%k;
		if(i > k){
			deb1(-1)
			return;
		}
	}
}

int main(){
	GODSPEED;
	//cin>>test;
	for(int i = 1; i <= test; i++){
		solve();
	}
	#ifndef ONLINE_JUDGE
	cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif
}


Measured memory_bytes: 3648
s = {suits: list(range(1, 14)) for suits in ["S", "H", "C", "D"]}

n = int(input())
for i in range(n):
    pict, num = tuple(input().split())
    s[pict].remove(int(num))

for i in s:
    for j in s[i]:
        print(i + " " + str(j))


Measured memory_bytes: 5600
import collections

N = int(input())

words=[]

for i in range(N):
    words.append(input())

c = collections.Counter(words)

l=c.most_common()

max_num = l[0][1]

max_words =[]
    
for i in l:
    if i[1] == max_num:
        max_words.append(i[0])
    else:
        break
        
max_words.sort()

for word in max_words:
    print(word)
    
    


Measured memory_bytes: 47668
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cctype>
#include <algorithm>
#include <functional>
#include <utility>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
using ll = long long;
const ll ha = 1000000007;
const int maxs = 1 << 15 | 1;
const int N = 100000;
ll tpow[N + 5];
int n; int pcnt[maxs];
inline void process() {
  tpow[0] = 1;
  for(int i = 1; i <= N; i ++) {
    tpow[i] = (tpow[i - 1] << 1) % ha;
  }
  pcnt[0] = 0;
  for(int i = 1; i < (1 << n); i ++) {
    pcnt[i] = pcnt[i & (i - 1)] + 1;
  }
}

int G[20];
inline void add_edge(int u, int v) {
  G[u] |= (1 << (v - 1));
}
inline ll calc_xi(int s, int t) {
  ll ans = 1, ans_2 = 1;
  for(int i = 1; i <= n; i ++) {
    if((1 << (i - 1)) & s) {
      const ll th = tpow[pcnt[t & G[i]]] - 1;
      ans = (ans * th) % ha;
    }
    if((1 << (i - 1)) & t) {
      const ll th = tpow[pcnt[s & G[i]]];
      ans_2 = ans_2 * th % ha;
    }
  }
  return ans * ans_2 % ha;
}

ll f[maxs];
ll dp(int s) {
  if(!s) return 1;
  ll &ans = f[s];
  if(ans != -1LL) return ans;
  ans = 0;
  for(int t = s; t; t = (t - 1) & s) {
    const int y = s ^ t;
    if((t & 3) && (y & 3)) continue;
    const ll xi = calc_xi(y, t);
    ans = (ans + xi * dp(y)) % ha;
  }
#ifdef LOCAL
  printf("f[%d] : %lld\n", s, ans);
#endif
  return ans;
}

int main() {
  int m; scanf("%d%d", &n, &m);
  for(int i = 1; i <= m; i ++) {
    int u, v; scanf("%d%d", &u, &v);
    add_edge(u, v);
  }
  process();
  memset(f, 0xff, sizeof(f));
  printf("%lld\n", (tpow[m] - dp((1 << n) - 1) + ha) % ha);
  return 0;
}

Measured memory_bytes: 1280
from sys import stdin
from sys import setrecursionlimit

setrecursionlimit(10 ** 7)

n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))

dic = {}
point = 0

for i,j in enumerate(a):
    if i+j in dic:
        dic[i+j] += 1
    else:
        dic[i+j] = 1

for i,j in enumerate(a):
    if i-j in dic:
        point += dic[i-j]

print(point)

Measured memory_bytes: 112204
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase


def main():
    n,k=map(int,input().split())
    a=[True]*n
    for _ in range(k):
        _=input()
        for x in map(int,input().split()):
            a[x-1]=False
    print(sum(a))
# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

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

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class EPrefixFreeGame {
public:

    vector<P> graph;
    ll ret = 0;
    ll L;

    void dfs(string& str, int id, int pos) {
      if (str.size() == pos) return;
      if (str[pos] == '0') {
        if (graph[id].first == -1) {
          graph.emplace_back(-1, -1);
          graph[id].first = graph.size()-1;
        }
        dfs(str, graph[id].first, pos+1);
      } else {
        if (graph[id].second == -1) {
          graph.emplace_back(-1, -1);
          graph[id].second = graph.size()-1;
        }
        dfs(str, graph[id].second, pos+1);
      }
    }

    void dfs2(int v, int d) {
      if (graph[v].first != -1) {
        dfs2(graph[v].first, d+1);
      }
      if (graph[v].second != -1) {
        dfs2(graph[v].second, d+1);
      }
      if ((graph[v].first == -1) ^ (graph[v].second == -1)) {
        ll x = L-d;
        ll y = 1;
        while(x%2 == 0) {
          x /= 2;
          y *= 2;
        }
        ret ^= y;
      }
    }

    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      cin >> L;
      graph.emplace_back(-1, -1);
      rep(i, n) {
        string s; cin >> s;
        dfs(s, 0, 0);
      }
      dfs2(0, 0);

      if (ret == 0) {
        cout << "Bob" << endl;
      } else {
        cout << "Alice" << endl;
      }



    }
};

signed main() {
  EPrefixFreeGame solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 4188
n = int(input())
a = list(map(int, input().split()))

a.sort()
tn = 1
cnt = 0
suffix = 0
for i in range(n):
    for j in range(suffix, n-1):
        if a[j] == tn:
            cnt += 1
            suffix = j+1
        else:
            break
    print(cnt)
    cnt = 0
    tn += 1
        

Measured memory_bytes: 92364
# 整数の入力
A, B = map(int, input().split() )
## input_line = str(input())
## A, B = map(int, input_line.split() )


result = 0
if A == B:
    result = A + B
else:
    Big_num = max(A, B)
    result = Big_num*2 -1

print(str(result))

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define lson l,mid,p<<1
#define rson mid+1,r,p<<1|1
#define ll long long
using namespace std;
const int inf=1e9;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
int a[20][20],b[20];
int main(){
    
    cin>>n;
    for(int i=0;i<n;i++) 
    for(int j=0;j<n;j++) a[i][j]=-1;
    for(int i=0,x;i<n;i++){
        scanf("%d",&x);
        for(int j=0,k,l;j<x;j++){
            scanf("%d%d",&k,&l);
            a[i][k-1]=l;
        }
    }
    int ans=0;
    for(int i=0;i<(1<<n);i++){
        for(int j=0;j<n;j++) if((i>>j)&1){
            b[j]=1;
        }else b[j]=0;
        int flag=1;
        for(int j=0;j<n&&flag;j++) if((i>>j)&1){
            for(int k=0;k<n&&flag;k++){
                if(a[j][k]!=-1&&b[k]!=a[j][k]){
                    flag=0;
                }
            }
        }
        if(flag){
                ans=max(ans,__builtin_popcount(i));
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
A,B,C,D = list(map(int,input().split()))

count1 = 0
count2 = 0
while A > 0:
    A -= D
    count1 += 1
while C > 0:
    C -= B
    count2 += 1

if count1 < count2:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9116
#include "bits/stdc++.h"
#include<assert.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define MRE assert(0);
const int inf = 1e17;
const int mod = 1000000007;
const int maxN = 100005;
typedef pair<int, int> P;
typedef pair<int, P> PP;
int a[3][100006];
int p[100006], b[100006];
struct BIT {
	int N; vector<int> bit;
	void init(int n) {
		N = n;
		bit.resize(n + 1);
	}
	int sum(int i) {
		int s = 0;
		while (i > 0) {
			s += bit[i];
			i -= i&-i;
		}
		return s;
	}
	void add(int i, int x) {
		while (i <= N) {
			bit[i] += x; i += i&-i;
		}
	}
};

int flip(vector<int>V) {
	int ans = 0;
	BIT B;
	B.init(maxN);
	rep(j, V.size()) {
		ans += B.sum(maxN)-B.sum(V[j]);
		B.add(V[j], 1);
	}
	return ans;
}

signed main() {
	int n; cin >> n;
	rep(i, 3)rep(j, n)cin >> a[i][j];
	rep(i, n) {
		if (a[1][i] % 3 != 2) {
			puts("No"); return 0;		
		}
		if (abs(a[1][i] - a[0][i]) != 1 || abs(a[1][i] - a[2][i]) != 1) {
			puts("No"); return 0;
		}
		if (a[0][i] % 3 == 0) {
			p[i] = a[0][i] / 3; b[i] = 1;
		}
		else {
			p[i] = a[2][i] / 3;
		}
	}
	int co = 0, ce = 0;
	vector<int>V1, V2;
	rep(i, n) {
		if (i & 1) {
			if (p[i] & 1) {
				puts("No"); return 0;
			}
			ce += b[i];
			V2.push_back(p[i]);
		}
		else {
			if (p[i] % 2 == 0) {
				puts("No"); return 0;
			}
			co += b[i];
			V1.push_back(p[i]);
		}
	}
	int a1 = flip(V1), a2 = flip(V2);
//	cout << co << ' ' << ce << "  " << a1 << ' ' << a2 << endl;
	if (co == ce) {
		if (co % 2 == a1 % 2 && ce % 2 == a2 % 2) {
			puts("Yes");
		}
		else puts("No");
	}
	else {
		if (co % 2 == a2 % 2 && ce % 2 == a1 % 2)puts("Yes");
		else puts("No");
	}
}

Measured memory_bytes: 6260
#include <stdio.h>
#include <bits/stdc++.h>
 
using namespace std;
 
typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;
 
typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;
 
typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;
 
#define f first
#define s second
 
#define en end()
#define bg begin()
 
#define rev reverse
#define mp make_pair
#define pb push_back
 
#define y1 y1234567890
#define um unordered_map
 
#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)
 
#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))
 
#define forn(i, n) for (int i = 1; i <= n; i++)
 
const ll INF = (ll)1e18;
const ll mod = (ll)1e9 + 7;
const int inf = (int)2e9;
 
const db eps = (db)1e-9;
const db pi = acos(-1.0);
 
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};
 
const int N = 1500;

int n, m, A, B, a[N][N];
 
int main() {
	cin.tie(NULL);
	cout.tie(NULL);
	ios_base::sync_with_stdio(false);
 
	//cout << setprecision(10) << fixed;
	
	cin >> n >> m >> B >> A;


	bool ok = 0;
	if(n > m){
		swap(n, m);
		swap(A, B);
		ok = 1;
	}

	for(int i = 1; i <= B; ++i)
	for(int j = 1; j <= (n - A); ++j)
		a[j][i] = 1;
	for(int i = B + 1; i <= m; ++i)
	for(int j = (n - A) + 1; j <= n; ++j)
		a[j][i] = 1;

	if(ok){
		for(int i = 1; i <= m; ++i, cout << endl)
		for(int j = 1; j <= n; ++j){
			cout << a[j][i];
		}
	}else{
		for(int i = 1; i <= n; ++i, cout << endl)
		for(int j = 1; j <= m; ++j)
			cout << a[i][j];
	}

	return 0;
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;

int main() {
	int N, S;
	vector<int> v(10, 1);
	for (int i = 0; i < 10; i++) {
		int& p = v.at(i);
		for (int j = 0; j < i; j++) {
			p *= 2;
		}
		//cout << p << endl;
	}
	
	int n;
	while (cin >> n) {
		bitset<10> bs(n);
		int c = bs.count();

		for (int i = 0; i < 10; i++) {
			if (bs.test(i)) {
				cout << v.at(i);
				c--;

				if (!c) {
					cout << endl;
					break;
				}
				else {
					cout << ' ';
				}
			}
		}
	}
}


Measured memory_bytes: 3016
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()

def resolve():
    n=int(input())
    I=[tuple(map(int,input().split())) for _ in range(n)]
    I.sort(lambda x:x[1])
    forL=[0]*n
    forL[0]=I[0][0]
    backL=[0]*n
    backL[-1]=I[-1][0]
    for i in range(n-1):
        forL[i+1]=max(forL[i],I[i+1][0])
        backL[-i-2]=max(backL[-i-1],I[-i-2][0])

    def calc1(i): # i番目で分けるやり方
        score=0
        score+=max(I[0][1]-forL[i-1]+1,0)
        score+=max(I[i][1]-backL[i]+1,0)
        return score
    ans1=max(calc1(i) for i in range(1,n))

    def calc2(i): # iつだけ別のやり方
        score=I[i][1]-I[i][0]+1
        if(0<i<n-1):
            score+=max(I[0][1]-max(forL[i-1],backL[i+1])+1,0)
        elif(i==0):
            score+=max(I[1][1]-max(forL[i-1],backL[i+1])+1,0)
        else:
            score+=max(I[0][1]-forL[i-1]+1,0)
        return score
    ans2=max(calc2(i) for i in range(n))

    print(max(ans1,ans2))
resolve()

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

typedef long long ll;

int main() {
    ll D, T, S;
    cin >> D >> T >> S;
    if (S * T < D) cout << "No\n";
    else cout << "Yes\n";
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <math.h>
#include <stdlib.h>
#include <algorithm>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

const int INF = 1e9;

int need[10] = {6,2,5,5,4,5,6,3,7,6};

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

  vector<int> A(M);
  rep(i, M) cin >> A[i];

  sort(A.rbegin(), A.rend());
  // dp[i]はi本使って作れる桁数
  vector<int> dp(N+10, -INF);
  dp[0] = 0;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < M; j++){
      dp[i + need[A[j]]] = max(dp[i + need[A[j]]], dp[i] + 1);
    }
  }

  string ans = "";
  int rstMatch = N;
  
  while(rstMatch>0){
    for(int i = 0; i < M; i++){
      if(rstMatch - need[A[i]] < 0) continue;
      if(dp[rstMatch - need[A[i]]] == dp[rstMatch]-1){
        rstMatch -= need[A[i]];
        ans += ('0' + A[i]);
        break;
      }
    }
  }

  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if (d==1)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    
    
    
}




Measured memory_bytes: 256
from itertools import accumulate,chain
def bisect(ng, ok, judge):
    while abs(ng-ok) > 1:
        m = (ng+ok)//2
        if judge(m):
            ok = m
        else:
            ng = m
    return ok

N,Q = map(int,input().split())

if N % 2 == 1:
    A = list(chain((0,),map(int,input().split())))
    N += 1
else:
    A = list(map(int,input().split()))

X = [int(input()) for _ in range(Q)]

oacc = list(chain((0,),accumulate(A[1::2])))
acc = list(chain((0,),accumulate(A)))

check = lambda x: lambda i: x*2 < A[-i]+A[-2*i]
M = N//2
for x in X:
    c = check(x)
    if c(M):
        print(acc[-1]-acc[M])
    elif not c(1):
        print(oacc[-1])
    else:
        i = bisect(M, 1, c)
        if x*2 <= A[-i-1] + A[-2*i-1]:
            i += 1
        s = acc[N]-acc[-i-1]
        if 2*i < N:
            s += oacc[(N-2*i)//2]
        print(s)


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int>A(N);
  
  for(int i=0; i < M; i++){
    cin >> A[i];
  }
  
  for(int i=0; i <M; i++){ //区切る
    N -= A[i];
    if(N < 0){
      cout  << -1 << endl;
      return 0;
    }
  }
  cout << N <<endl;
}

Measured memory_bytes: 7220
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

printList [a] = print a
printList (a:as) = putStr ( show a ) >> putChar ' ' >> printList as

main = getLine >> readIntegers >>= print . solve

solve (a:as) = solve' a as

solve' _ [] = 0
solve' s (a:as) = ( s *% a ) +% solve' ( s +% a ) as

a +% b = ( a + b ) `mod` 1000000007
a *% b = a * b `mod` 1000000007

Measured memory_bytes: 44716
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
    string s;
    int n;
    cin >> n;
    cin >> s;
    if (n % 2 == 0) {
        int i = 0,j = s.length()/2,flag = 0;
        while(i < s.length() / 2 && j < s.length()) {
            if (s[i] != s[j]) {
                flag = 1;
                break;
            }
            j++;
            i++;
        }
        if (flag == 0){
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    } else {
        cout << "No\n";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

string s;

long long qexp(long long b,long long p,int m){
    long long res=1;
    while (p){
        if (p&1) res=(res*b)%m;
        b=(b*b)%m;
        p>>=1;
    }
    return res;
}

int arr[200005];
int cnt[2500];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>s;
	
	int val=0;
	int pow=1;
	
	rep(x,s.size(),0){
		val+=pow*(s[x]-'0');
		
		val%=2019;
		
		pow*=10;
		pow%=2019;
		
		cnt[val]++;
		arr[x]=val;
		
		//cout<<val<<endl;
	}
	
	ll ans=0;
	
	val=0;
	pow=1;
	rep(x,s.size(),0){
		//cout<<val<<endl;
		ans+=cnt[val];
		
		val+=pow*(s[x]-'0');
		val%=2019;
		
		pow*=10;
		pow%=2019;
		
		cnt[arr[x]]--;
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 4492
n = int(input())
a = [0]*n
b = list(map(int, input().split()))
a[0] = b[0]
a[-1] = b[-1]
for i in range(1,n-1):
    if b[i-1] >= b [i]:
        a[i] = b[i]
    else:
        a[i] = b[i-1]
print(sum(a))

Measured memory_bytes: 3064
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();

		// 計算
		String result = "No";
		if(4*a*b < (c-a-b)*(c-a-b) && c-a-b > 0) result = "Yes";
		
		// 出力
		System.out.println(result);
	}
}





Measured memory_bytes: 23124
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline bool read(ll &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&c^-1;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;

int cnt[10],n=read(),k=read();

vector<int> v,ans;

void dfs(int k,int num){
if (!k) return;
ans.push_back(num);
for (int i:v) dfs(k-1,num*10+i);
}

int main(){
int i;
for (;k--;) cnt[read()]++;
for (i=0;i<10;++i) if (!cnt[i]) v.push_back(i);
dfs(6,0);
sort(ans.begin(),ans.end());
write(*lower_bound(ans.begin(),ans.end(),n));
}

Measured memory_bytes: 892
// C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;

int gcd(int a, int b) {
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }

}
int main()
{
    int n;
    int ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            for (int k = 1; k <= n; k++) {
                ans += gcd(gcd(i, j), k);
            }
        }
    }

    cout << ans << endl;
    return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

string s;
map<char,int> m;

// int minus(int &i);
int number(int &i);
int facter(int &i);
int expr(int &i);

int number(int &i){
    int res;
    if(s[i] >= '0' && s[i] <= '2'){
        res = s[i] - '0';
        i++;
    }
    else if(s[i] >= 'P' && s[i] <= 'R'){
        res = m[s[i]];
        i++;
    }
    return res;
}

int facter(int &i){
    int res = 0;
    if(s[i] == '('){
        i++;
        res = expr(i);
        i++;
    }
    else if(s[i] == '-'){
        i++;
        res = 2 - facter(i);
    }
    else res = number(i);
    return res;
}

int expr(int &i){
    int res = facter(i);
    while(1){
        if(s[i] == '*'){
            i++;
            res = min(res,facter(i));
        }
        else if(s[i] == '+'){
            i++;
            res = max(res,facter(i));
        }
        else break;
    }
    return res;
}


int main(){
    while(cin >> s && s != "."){
        ll ans = 0;
        rep(i,3){
            rep(j,3){
                rep(k,3){
                    m['P'] = i;
                    m['Q'] = j;
                    m['R'] = k;
                    int pos = 0;
                    int num = expr(pos);
                    // if(num == 2){
                    //     cout << i << " " << j << " " << k << endl;
                    // }
                    ans += (num == 2);

                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3068
/** Bismillahir Rahmanir Rahim **/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define Fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main()
{
    Fastio;
    string s;
    cin >> s;
    int n = (int) s.size();
    vector<int> v(n + 1);

    for (int i = 0; i < n; i++) {
        if (s[i] == '<') {
            v[i + 1] = v[i] + 1;
        }
    }

    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == '>') {
            v[i] = max(v[i], v[i + 1] + 1); 
        }
    }

    ll ans = 0;
    for (int i = 0; i <= n; i++) ans += v[i];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2844
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

struct UnionFind{
  vector<int> parents;
  UnionFind(int n){
    parents.assign(n, -1);
  }

  int root(int x){
    if(parents[x] < 0) return x;
    else return parents[x] = root(parents[x]);
  }

  int size(int x){
    return -parents[root(x)];
  }

  bool same(int x, int y){
    return root(x) == root(y);
  }

  bool unite(int x, int y){
    x = root(x);
    y = root(y);
    if(x == y) return false;
    if(size(x) < size(y)) swap(x, y);
    parents[x] += parents[y];
    parents[y] = x;
    return true;
  }
};

int A[100000];
int B[100000];
ll diff;
ll ans[100000];

int main(){
  ll N, M;
  cin >> N >> M;
  rep(i, M){
    cin >> A[i];
    cin >> B[i];
    A[i]--;
    B[i]--;
  }

  UnionFind uni(N);

  rrep(i, M){
    if(i == M - 1){
      ans[i] = N * (N - 1) / 2;
    }else{
      ans[i] = ans[i + 1] - diff;
    }
    int a = A[i];
    int b = B[i];
    if(uni.same(a, b)){
      diff = 0;
    }else{
      int sizeA = uni.size(a);
      int sizeB = uni.size(b);
      uni.unite(a, b);
      diff = (long long)sizeA * sizeB;
    }
  }
  rep(i, M){
    cout << ans[i] << endl;
  }
  return 0;
}


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

int main(){
  ll a,b,c,n;
  string s;
  cin >> a >> b >> c;

  if(a*c<=b)cout << c <<endl;
  else cout << b/a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                          \
  cout << #v << "=(" << v[0];                              \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; } \
  cout << ")" << endl;
#define mdebug(m)                                                           \
  cout << #m << "=" << endl;                                                \
  REP(i_debug, m.size())                                                    \
  {                                                                         \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; } \
    cout << endl;                                                           \
  }
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T>
void readv(vector<T> &a)
{
  REP(i, a.size())
  cin >> a[i];
}
void readv_m1(vector<int> &a)
{
  REP(i, a.size())
  {
    cin >> a[i];
    a[i]--;
  }
}

ll mod = 1000000007;

int main()
{
  ll L, R;
  cin >> L >> R;
  ll d;
  cin >> d;
  ll ans = 0;
  FOR(i, L, R + 1)
  {
    if (i % d == 0)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h , w;
  
  while (1) {
    cin >>h >>w;
    if (h==0 && w==0)
      break;
    
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (i==0 || i==(h-1))
          cout << '#';
        else {
          if (j==0 || j==(w-1))
            cout << '#';
          else
            cout << '.';
        }
      }
      cout << endl;
    }
    cout << endl;
  }
}


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

#define ll       long long
#define LL       long long
#define ull      unsigned ll
#define pii      pair<int, int>
#define pll      pair<ll, ll>
#define mp       make_pair
#define ff       first
#define ss       second
#define sz(s)    (int) s.size()
#define all(s)   s.begin(), s.end()

template<typename T> inline void smin(T &a, T b) {
    a = a < b ? a : b;
}
template<typename T> inline void smax(T &a, T b) {
    a = a > b ? a : b;
}

template<typename T> inline void Int(T &n) {
    n = 0;
    int f = 1;
    register int ch = getchar();
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n *= f;
}
template<typename T, typename TT> inline void Int(T &n, TT &m) {
    Int(n), Int(m);
}
template<typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) {
    Int(n), Int(m, l);
}

#define error(args...) { string _s = #args; replace(all(_s), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {
    cout << endl;
}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}

const int mod = (int) 1e9 + 7;

int add(int a, int b) {
    a += b;
    if(a >= mod) a -= mod;
    return a;
}
int sub(int a, int b) {
    a -= b;
    if(a <= 0) a += mod;
    return a;
}
int mul(int a, int b) {
    return (ll) a * b % mod;
}

const int inf = (int) 1e9 + 5;
const ll  Inf = (ll) 2e18 + 5;
const int   N = (int) 3e3 + 5;




int solve() {
    string s, t;
    cin >> s >> t;
    int n = sz(s), m = sz(t);
    vector<vector<int>> dp(n + 1, vector<int> (m + 1, 0));
    vector<vector<pii>> par(n + 1, vector<pii> (m + 1));
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            if(s[i - 1] == t[j - 1]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
                par[i][j] = mp(i - 1, j - 1);
            } else {
                if(dp[i - 1][j] > dp[i][j - 1]) {
                    dp[i][j] = dp[i - 1][j];
                    par[i][j] = mp(i - 1, j);
                } else {
                    dp[i][j] = dp[i][j - 1];
                    par[i][j] = mp(i, j - 1);
                }
            }
        }
    }
    string ans = "";
    while(1) {
        if(n == 0 or m == 0) break;
        if(s[n - 1] == t[m - 1]) ans.push_back(s[n - 1]);
        int x = par[n][m].ff, y = par[n][m].ss;
        n = x, m = y;
    }
    reverse(all(ans));
    cout << ans << endl;
    return 0;
}

int main() {
    int test = 1, tc = 0;
    //Int(test);
    while(test--) {
        //printf("Case %d: ", ++tc);
        solve();
    }
    return 0;
}




Measured memory_bytes: 105984
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<climits>
#include<set>
#define ll long long
using namespace std;

int main() {
	ll n, k,c=0,sma=LLONG_MAX;
	cin >> n >> k;
	vector<ll>h(n),sa(n-1),sumsa(n-1,0);
	for (ll i = 0; i < n; i++) {
		cin >> h[i];
	}
	sort(h.begin(), h.end());
	for (ll i = 0; i < n-k+1; i++) {
		sma = min(sma, abs(h[i] - h[i + k - 1]));
	}
	
	cout << sma << endl;

	


}

Measured memory_bytes: 2560
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val st = sc.nextLine().split(" ")
    val a, b = sc.nextInt
    sc.nextLine()
    val u = sc.nextLine()

    if (u == st(0)) println((a - 1) + " " + b)
    else println(a + " " + (b - 1))
  }
}


Measured memory_bytes: 25780
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc133/tasks/abc133_b>
 問題文============================================================
 =================================================================
 解説=============================================================
 全組み合わせを試す
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N,D; cin >> N >> D;
    vector<vector<ll>> X(N,vector<ll>(D));
    for(auto& vec:X) for(auto& in:vec) cin >> in;
    
    ll ans = 0;
    for(int i = 0; i < N;i++){
        for(int j = i+1; j < N;j++){
            ll T = 0;
            
            for(int k = 0; k < D;k++){
                T += (X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
            }
            
            if(T == floor(sqrt(T))*floor(sqrt(T))) ans++;
        }
    }
    res = ans;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100
int main(void)
{
  char s[N][N]={0};
  int i,j,k,l,h,w,f1=0,f2=0,f3=0,f4=0;
  scanf("%d%d",&h,&w);
  for(i=0;i<h;i++)
  {
    scanf("%s",s[i]);
  }
  for(i=0;i<h;i++)
  {
    for(j=0;j<w;j++)
    {
      if(s[i][j]=='.')
      {
        s[i][j]='0';
        for(k=i-1;k<=i+1;k++)
        {
          for(l=j-1;l<=j+1;l++)
          {
            if(k>=0 && k<h)
            {
              if(l>=0 && l<w)
              {
                if(s[k][l]=='#')
                {
                  s[i][j]++;
                  if(k==i && l==j)
                  {
                    s[i][j]--;
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  for(i=0;i<h;i++)
  {
    printf("%s\n",s[i]);
  }
  return 0;
}


Measured memory_bytes: 128
X = int(input())

if X >= 400 and X < 600:
  print(8)
elif X>= 600 and X < 800:
  print(7)
elif X>= 800 and X < 1000:
  print(6)
elif X>= 1000 and X < 1200:
  print(5)
elif X>= 1200 and X < 1400:
  print(4)
elif X>= 1400 and X < 1600:
  print(3)
elif X>= 1600 and X < 1800:
  print(2)
elif X>= 1800 and X < 2000:
  print(1)

Measured memory_bytes: 9196
n = int(input())
datax = []
datau = []
lst = []
for i in range(n):
    x,u = input().split()
    x = float(x)
    datax.append(x)
    datau.append(u)
for j in range(n):
    if datau[j] == "JPY":
        lst.append(datax[j])
    if datau[j] == "BTC":
        lst.append(datax[j]*380000.0)
print(sum(lst))

Measured memory_bytes: 3064