akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<stdio.h>
#include<string>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define sz(x) int(x.size())
#define INF 1e5

int dp[5005][5005];
int main(){
	int r;
	cin>>r;
	cout<<3*r*r<<endl;
}

Measured memory_bytes: 256
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n, m = MI()
    if n == 2 or m == 2:
        print(0)
        sys.exit()
    h = max(n-2, 1)
    w = max(m-2, 1)
    print(h*w)

if __name__ == '__main__':
    main()

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

typedef long long ll;

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout << i << endl;
#define AS(i) cout << i << " ";

const int INF = 1001001001;

const double PI = 3.14159;

using namespace std;

//vector<ll> memo(1000007, INF);

int main() {

    int k, x;
    cin >> k >> x;

    string ans = "No";
    if (500 * k >= x)
        ans = "Yes";

    AA(ans);
}

Measured memory_bytes: 3592
N,K = map(int,input().split())
A = list(map(int,input().split()))
cnt = 0
while cnt<K:
    B = [0 for _ in range(N+1)]
    for i in range(N):
        a = A[i]
        B[max(i-a,0)] += 1
        B[min(i+a,N-1)+1] -= 1
    for i in range(1,N+1):
        B[i] += B[i-1]
    A = B[:N]
    flag = 0
    for i in range(N):
        if A[i]<N:
            flag = 1
            break
    if flag==0:break
    cnt += 1
print(*A)

Measured memory_bytes: 219240
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//↑templete
int main() {
	int N,M;
	cin>>N>>M;
	vint node[SIZE],back[SIZE];
	bool edge[SIZE][SIZE]={};
	for(int i=0;i<M;i++){
		int a,b;
		cin>>a>>b;
		a--,b--;
		node[a].pb(b);
		back[b].pb(a);
		edge[a][b]=1;
	}

	vint ans;
	int minLen=INF;

	//最小のサイクルを求める
	for(int s=0;s<N;s++){	//全部のノードを始点にしてBFS
		int dist[SIZE]={};
		for(int i=0;i<N;i++)
			dist[i]=-1;
		dist[s]=0;
		queue<pint> que;
		que.push(mp(s,0));
		while(que.size()){
			int now,cost;
			tie(now,cost)=que.front();
			que.pop();
			for(int next:node[now]){
				if(dist[next]!=-1)
					continue;

				dist[next]=cost+1;
				que.push(mp(next,cost+1));
			}
		}

		//x→sの辺をもつノードxの中でsから一番近いものを探す
		for(int x=0;x<N;x++){
			if(edge[x][s] && dist[x]<minLen && dist[x]!=-1){
				//見つけたら経路復元する
				int now=x;
				ans.clear();
				ans.pb(x);
				while(now!=s){
					for(int prev:back[now]){
						if(dist[prev]==dist[now]-1){
							ans.pb(prev);
							now=prev;
							break;
						}
					}
				}
				minLen=dist[x];
			}
		}
	}
	if(ans.empty()){
		cout<<-1<<endl;
		return 0;
	}
	cout<<ans.size()<<endl;
	for(int n:ans)
		cout<<n+1<<endl;

	return 0;
}

Measured memory_bytes: 1408
// https://atcoder.jp/contests/abc078/tasks/abc078_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, y, z;
    cin >> x >> y >> z;
    cout << (x - z) / (y + z) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long
#define ld long double
#define zeros(x) x^(x-1)&x
#define pii pair<ll,ll>
#define cd complex<double>
#define dbg(x) cerr<<x<<endl;
#define Nmax 200005
using namespace std;

ll n, m, x, y, uz[Nmax], nr, U, A, B;
vector<ll> v[Nmax];

bool bipartit(int nod, int nr){
    bool bip = 1;
    uz[nod] = nr;
    for (auto it : v[nod]){
        if (uz[it] && uz[it]%2 == nr%2) bip = 0;
        if (uz[it]) continue;
        bip &= bipartit(it, nr+1);
    }
    return bip;
}

int main()
{
    cin >> n >> m;
    for (int i=1;i<=m;i++){
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }

    for (int i=1;i<=n;i++){
        if (uz[i]) continue;
        if (v[i].size()==0) U++;
        else if (bipartit(i,1)) A++;
        else B++;
    }

    ll ans = U * (n-U) * 2 + U * U;
    ans += A * A * 2;
    ans += A * B * 2 + B * B;
    cout << ans << '\n';

    return 0;
}


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


int main(int argc, char const *argv[])
{   

    int N=3;
    
    
    //list<int> data(N);
    
    int data[N];
    char a;

    for(int i=0;i<N;i++){
        if (i==1){
            cin>>a;

        }
        else{
            
       cin>>data[i];
    

        }
        
    }
    int sum=0;

    if (a == '-'){
        sum=data[0]-data[2];
    }
    if(a == '+'){
        sum=data[0]+data[2];

    }

   

    cout<<sum;

    return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    if ( a < b ) cout << "a < b" << endl;
    else if ( a > b ) cout << "a > b" << endl;
    else if ( a == b )cout << "a == b" << endl;
    
    return 0;
}


Measured memory_bytes: 3104
# -*- coding: utf-8 -*-


def main():
    n = int(input())

    points = [tuple(map(int, input().split())) for i in range(n)]

    pre_t, pre_x, pre_y = 0, 0, 0
    flg = True
    for t, x, y in points:
        sabun_t = t - pre_t
        sabun_x = abs(x - pre_x)
        sabun_y = abs(y - pre_y)

        temp = sabun_t - (sabun_x + sabun_y)
        if temp < 0 or temp % 2 == 1:
            flg = False
            break

        pre_t, pre_x, pre_y = t, x, y

    if flg:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 17324
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
const ll inf = 1e18;
struct dinit_graph
{
	int n,s,t;
	struct flow_edge
	{
		int v,u;
		ll cap,flow=0ll;
		flow_edge(int v,int u,ll cap):v(v),u(u),cap(cap){}
	};
	vector<vi> graph;
	vector<flow_edge> edge;
	vi lv;
	dinit_graph(int n=0,int s=0,int t=0):n(n),s(s),t(t)
	{
		graph.assign(n+1,vi());
		edge.clear();
	}
	void add(int v,int u,ll w)
	{
		graph[v].push_back(edge.size());
		edge.emplace_back(v,u,w);
		graph[u].push_back(edge.size());
		edge.emplace_back(u,v,0ll);
	}
	bool bfs()
	{
		lv.assign(n+1,-1);
		lv[s]=0;
		queue<int> q;
		q.push(s);
		while(!q.empty())
		{
			int v=q.front();q.pop();
			for(auto id:graph[v])
			{
				int u = edge[id].u;
				if(edge[id].cap>edge[id].flow&&lv[u]==-1)
				{
					lv[u]=lv[v]+1;
					q.push(u);
				}
			}
		}
		if(lv[t]==-1)	return false;
		return true;
	}
	ll dfs(int v,ll push)
	{
		if(v==t)	return push;
		if(push==0ll)	return push;
		for(auto id:graph[v])
		{
			int u = edge[id].u;
			if(lv[u]==lv[v]+1&&edge[id].cap>edge[id].flow)
			{
				ll res = dfs(u,min(push,edge[id].cap-edge[id].flow));
				if(res!=0ll)
				{
					edge[id].flow += res;
					edge[id^1].flow -= res;
					return res;
				}
			}
		}
		return 0ll;
	}
	ll dinic()
	{
		ll mx = 0ll,push;
		while(1)
		{
			if(bfs()==false)	break;
			while((push=dfs(s,inf))!=0ll)
			{
				mx += push;
			}
		}
		return mx;
	}
}fg;
int main()
{
	int r,c,i,j;
	scanf("%d %d",&r,&c);
	vector<string> grid(r);
	for(i=0;i<r;i++)
	{
		cin>>grid[i];
	}
	fg = dinit_graph(r+c+2,0,r+c+1);
	for(i=0;i<r;i++)
	{
		for(j=0;j<c;j++)
		{
			if(grid[i][j]=='o')
			{
				fg.add(i+1,j+r+1,1ll);
				fg.add(j+r+1,i+1,1ll);
			}
			if(grid[i][j]=='S')
			{
				fg.add(0,i+1,inf);
				fg.add(0,j+r+1,inf);
			}
			if(grid[i][j]=='T')
			{
				fg.add(i+1,r+c+1,inf);
				fg.add(j+r+1,r+c+1,inf);
			}
		}
	}
	ll ans = fg.dinic();
	if(ans>=inf)	printf("-1");
	else	printf("%lld",ans);
}


Measured memory_bytes: 5088
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<vector>
#include<queue>
#define ll long long
ll read()
{
	ll tmp=0;char c=getchar(),f=1;
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9'){tmp=tmp*10+c-48;c=getchar();}
	return tmp*f;
}
using namespace std;
int main()
{
	ll n,a;
	n=read(); a=read();
	printf("%lld\n",n*n-a);
	return 0;
}

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

int main() {
    int e[12];
    for(int a = 0; a < 12; ++a) {
        cin >> e[a];
    }
    sort(e,e+12);

    if(e[0] == e[3] && e[4] == e[7] && e[8] == e[11]) {
        cout << "yes" << endl;
    }else {
        cout << "no" << endl;
    }
}

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

using namespace std;

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

#define sz(a) int((a).size())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define inin(a, n, i) memset(a, i, sizeof(a[0])*(n))
#define contains(c, i) ((c).find(i) != (c).end())
#define present(i, c) (find(all(c), i) != (c).end())

#define trav(x, c) for(auto &x : c)
#define rep(i, n) for(int i = 0; i < n; i++)
#define repa(i, b, e) for(int i = (b)-((b)>(e)); i != (e)-((b)>(e)); i += 1-2*((b)>(e)))
	
template<class T> bool chkmax(T &x, T y) { return x < y ? x = y, true : false; }
template<class T> bool chkmin(T &x, T y) { return x > y ? x = y, true : false; }
template<class A, class B> A cvt(B x) { stringstream s; s << x; A r; s >> r; return r; }

void read() {}
void print() {}
template<class T, class... Args> void read(T& a, Args&... args) { cin >> a; read(args...); }
template<class T, class... Args> void print(T a, Args... args) { cout << a << ' '; print(args...); }
template<class... Args> void println(Args... args) { print(args...); cout << endl; }

#define debug(args...) { string s_(#args); replace(all(s_), ',', ' '); stringstream ss_(s_); istream_iterator<string> it_(ss_); cerr_(it_, args); }
void cerr_(istream_iterator<string> it) { (void) it; }
template<class T, class... Args> void cerr_(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; cerr_(++it, args...); }

template<class T, class S>  ostream& operator<<(ostream& os, const pair<T, S>& p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<class T> ostream& operator<<(ostream &os, const set<T> &s) { os << '{'; string sep; for (const auto &x : s) os << sep << x, sep = ", "; return os << '}'; }
template<class T, class S> ostream& operator<<(ostream &os, const map<T, S> &m) { os << '{'; string sep; for (const auto &x : m) os << sep << x, sep = ", "; return os << '}'; }
template<class T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }

//=========================

void run_test() {
	int n, k; read(n, k);
    vector<ll> a(n); rep(i, n) read(a[i]);
    repa(i, k, n) {
        if(a[i] > a[i-k]) println("Yes");
        else println("No");
    }
}

//=========================

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//int t_ = 1, t__; cin >> t__; while(t_ <= t__) { cout << "Case #" << t_++ << ": "; run_test(); }
	// int t_; cin >> t_; while(t_--) run_test();
	run_test();
	return 0;	
}


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

//     MLE,TLE魔
//↓↓↓↓↓↓↓↓↓↓↓↓
#define int long long
//↑↑↑↑↑↑↑↑↑↑↑↑
//     MLE,TLE魔
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 5000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;


int n;
string s;
stack<int>st;
signed main() {
	cin>>n>>s;
	rep(i,n){
		if(st.empty()){
			st.push(s[i]);
		}else if(st.top()=='('&&s[i]==')'){
			st.pop();
		}else {
			st.push(s[i]);
		}
	}
	int ri=0,le=0;
	while(st.size()){
		if(st.top()=='(')le++;
		else ri++;
		st.pop();
	}
	rep(i,ri)cout<<"(";
	cout<<s;
	rep(i,le)cout<<")";
}


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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define REPC(var, start, end) for(int var = start; var <= (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cerr << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;
#define DBG(x) cerr << x << endl;

/*
	
*/

int n;
VL A;
unordered_map<LL, int> factors;
bool isPrime(LL num)
{
	if(num <= 1) return false;
    if(num <= 3) return true;
    if(num % 2 == 0 || num % 3 == 0)
        return false;
    
    for(int i = 5; i * i <= num; i += 6)
        if(num % i == 0 || num % (i + 2) == 0)
            return false;
	return true;
}

void factorization(LL num)
{
	if(isPrime(num))
		 factors[num] = 1;
	for(LL div = 2; num > 1; ++div)
	{
		int cnt = 0;
		while(num % div == 0 && num > 1)
		{
			++cnt;
			num /= div;
		}
		if(cnt > 0)
			factors[div] = max(factors[div], cnt);
	}
}
LL solve()
{
	for(auto i : A)
		factorization(i);

	LL ret = 1;
	for(auto it : factors)
	{
		LL div = it.first; int times = it.second;
		for(int i = 0; i < times; ++i)
			ret *= div;
	}
	return ret;
}

LL lcm(LL a, LL b) {
	LL G = __gcd(a, b);
	return (a / G) * b;
}


LL ans()
{
	LL ret = 1;
	for(auto i : A)
		ret = lcm(ret, i);
	return ret;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("tmp.in", "r", stdin);
	//freopen("tmp.out", "w", stderr);
#endif
	cin >> n;

	A.resize(n);
	REP(i, 0, n) cin >> A[i];

	cout << ans() << endl;

	return 0;
}

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

int main() {
	int a, b;
	char op = '/';
	
	while (op != '?') {
		cin >> a >> op >> b;
		if (op == '+')cout << a + b <<endl;
		if (op == '-')cout << a - b << endl;
		if (op == '*')cout << a*b << endl;
		if (op == '/')cout << a / b << endl;
	}
	return 0;
}

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

int main(){
	double x = 0.0;
	double y = 0.0;
	double r = M_PI*0.5;
	while(1){
		int a,b;
		char com;
		cin >> a >> com >> b;
		if(a==0 && b==0) break;
		x += double(a)*cos(r);
		y += double(a)*sin(r);
		r -= M_PI*b/180.0;
	}
	int c = int(x);
	int d = int(y);
	cout << c << endl;
	cout << d << endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

ll inf = 1000000000;
int main() {
  ll n,k,s;
  cin >> n>> k>>s;
  ll c = 0;
  if(s == inf) inf--;
  vl ans(n,inf);
  while(c!=k){
  ans[c] = s;
  c++;
  }
  rep(i,n){
    cout<<ans[i]<<" ";
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 2048
def is_753(n):
    n = str(n)
    return(n.count("7") >= 1 and n.count("3") >= 1 and n.count("5") >= 1)


n = int(input())


v = [7, 5, 3]
li = []
prev = [7, 5, 3]

for i in range(9):
    tmp = []
    for j in v:
        for k in prev:
            tmp.append(k * 10 + j)
    prev = tmp
    li = li + prev

li = [x for x in li if is_753(x) and x <= n]

print(len(li))

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

typedef long long ll;

const int N = 2e5 + 5;
int n, k, t;
int A[N];

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

    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    sort(A, A + N, greater<int>());
    ll sum = 0;
    for (int i = k; i < n; ++i) {
        sum += A[i];
    }
    cout << sum << endl;

    return 0;
}



Measured memory_bytes: 1024
#include <iostream>

#define ll long long

using namespace std;

long long Max(ll a,ll b)
{
	if(a<b)	return b;
	return a;
}

ll n,k,mod=998244353;
ll f[200010];
ll t[200010];
ll l[20],r[20],c[20],sum[20];

int lowbit(int x)
{
	return x&-x;
}

void update(ll x,ll y)
{
	while(x <= n)
	{
		t[x] += y;
		x += lowbit(x);
	} 
	return ;
}

ll qwerty(ll x)
{
	ll sum = 0;
	while(x)
	{
		sum += t[x];
		x 	-= lowbit(x);
	}
	return sum;
}

int main(void)
{
	cin >> n >> k;
	for(int i=1;i<=k;i++)
		cin >> l[i] >> r[i];

	f[0]=f[1]=1;
	update(1,1);
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<=k;j++)
		{
//			if(i-l[j]<1)
//				break;
//			else if(i-r[j]-1>=1)	
//			{
				f[i] = (((f[i]+ qwerty(max(0ll,i-l[j]))-qwerty(max(0ll,i-r[j]-1)))%mod)+mod)%mod;
				update(i,(((qwerty(max(0ll,i-l[j]))-qwerty(max(0ll,i-r[j]-1)))%mod)+mod)%mod); 
//			}
//			else if(i-l[j]>=1 && i-r[j]-1<1)
//			{
//				f[i] = (((f[i]+qwerty(max(0ll,i-l[j])))%mod)+mod)%mod;
//				update(i,(((max(0ll,qwerty(i-l[j])))%mod)+mod)%mod);
//			}
		}
		
	}
//	for(int i=1;i<n;i++)
//	{
//		cout << f[i]%998244353 << ' '; 
//	}
	cout << f[n]%998244353 << endl;
	return 0;
}

Measured memory_bytes: 6724
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  int N;
  cin >> N;
  int ans=0;
  for(int i=1;i<=N;i++){
    ans+=i;
  }
  cout << ans << endl;

  return 0;
}


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

int main(){
//srandom((unsigned long)time(NULL));

long long n;
cin>>n;
//3でも5でも割り切れない数の和
long long ans=0;
for(long long i=1;i<n+1;i++){
    if(i%3!=0 && i%5!=0)ans+=i;
}
cout<<ans<<endl;

return 0;
}

Measured memory_bytes: 3640
//ProblemA

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

//ProblemA

class Solve {
private:

	void solve() {
		int n;
		cin >> n;

		unordered_map<long long, int> m = { {0LL, 1} };
		long long sum = 0;

		long long rst = 0;
		for (int i = 0; i < n; i++) {
			long long a;
			cin >> a;
			sum += a;

			auto it = m.find(sum);
			if (it != m.end()) {
				rst += it->second;
			}

			m[sum] += 1;
		}

		cout << rst << endl;
	}

public:
	Solve() { solve(); }
};

int main(int argc, char* argv[]) {
	unique_ptr<Solve> solve = make_unique<Solve>();
	return 0;
}


Measured memory_bytes: 8520
from itertools import permutations
N,M = map(int,input().split())
cc = [list(map(int,input().split())) for i in range(M)]
count = 0
for i in permutations([i+1 for i in range(N)],N):
  bb = 0
  if i[0] == 1:
    for j in range(N-1):
      aa = [i[j],i[j+1]]
      if aa in cc or aa[::-1] in cc:
        bb += 1
        if bb == N-1:
          count += 1
        continue
      else:
        break
print(count)     

Measured memory_bytes: 9204
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define endl '\n'
#define loop(i, m, n) for (lli i = m; i < n; i++)
#define loope(i, m, n) for (lli i = m; i <= n; i++)
#define epool(i, m, n) for (lli i = m; i >= n; i--)
#define pool(i,m,n) for(lli i=m; i>n; i++)
#define maxe *max_element
#define mine *min_element
#define plli pair<lli, lli>
#define mod 1000000007
#define mod2 998244353
#define vt vector<lli>
#define fi first
#define se second
#define pb push_back
#define umap unordered_map
#define mmap multimap
#define mp make_pair
#define inp1(a) cin >> a
#define inp2(a, b) cin >> a >> b
#define inp3(a, b, c) cin >> a >> b >> c
#define inp4(a, b, c, d) cin >> a >> b >> c >> d
#define inp5(a, b, c, d, e) cin >> a >> b >> c >> d >> e
#define inp6(a, b, c, d, e, f) cin >> a >> b >> c >> d >> e >> f
#define pr0() cout << " "
#define pr1(a) cout << a << " "
#define pr2(a, b) cout << a << " " << b << " "
#define pr3(a, b, c) cout << a << " " << b << " " << c << " "
#define pr4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << " "
#define emp emplace //used to push a pair etc..
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x, 0;
#define all(v) v.begin(),v.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
//especially for deque both sides dynamic
#define pf push_front
//list doubly linked lists can insert at mid. splice fn can be used
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;
 
lli gcd(lli a, lli b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
 
lli lcm(lli a, lli b){
    return (a * b) / gcd(a, b);
}
 
lli modi(lli n,lli m=mod){ 
    if(n==0) return 0;
    n%=m;
    n+=m;
    n%=m;
    return n;
}
 
lli mpow(lli base, lli exp){
    base %= mod;
    lli result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((lli)result * base) % mod;
        base = ((lli)base * base) % mod;
        exp >>= 1;
    }
    return result;
}
const lli INF=1e18;
const lli N=2e5+5;
lli a[N]={0},b[N]={0};

int32_t main(){
    fast_io
    lli i = 0,j=0;
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    
    vt v,v1,v2;
    lli a,b,c,d,e,f;

    lli n;
    cin >> n;
    lli ans=0;
    loope(i,1,n){
        if(i%3==0 || i%5==0) continue;
        else ans+=i;
    }

    cout << ans << endl;

}

Measured memory_bytes: 3608
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] mm = new long[n];
        for(int i=0; i<n; i++){
            mm[i] = sc.nextLong();
        }
        int i=0;
        int j=n-1;
        long sum1 = mm[i];
        long sum2 = mm[j];
        i++;
        j--;
        for(;i<=j;){
            if(sum1 < sum2){
                sum1 += mm[i];
                i++;
            }else if(sum2 < sum1){
                sum2 += mm[j];
                j--;
            }else{
                sum1 += mm[i];
                // sum2 += mm[j];
                i++;
                // j--;
            }
        }
        // System.out.println(sum1+" "+sum2);
        System.out.println((long)Math.abs(sum1-sum2));
        sc.close();
    }
}

Measured memory_bytes: 87592
#include <bits/stdc++.h>
typedef long long ll;
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define rf(i,a,b) for(ll i=a; i>=b; i--)
typedef std::vector<long long > vi ;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define yesno(f) yes(f);no(f);
#define yes(f) if(f)cout<<"YES\n";
#define no(f) if(!f)cout<<"NO\n";
using  namespace std;
vi adj[200005];
ll mark[200005]={0},y;
void dfs(ll x)
{
    mark[x]=1;
    y++;
    fr(i,0,adj[x].size())
    {
        if(mark[adj[x][i]]==0)
        {
            dfs(adj[x][i]);
        }
    }
}
int main()
{
    fast;
   ll p=1;
   //std::cin >> t;
   while(p--)
   {
       ll n,m,u,v;
       std::cin >> n>>m;
       fr(i,0,m)
        {   std::cin >> u>>v;
           adj[u].PB(v);
           adj[v].PB(u);
        }
       ll x=0;
       fr(i,1,n+1)
       {
           y=0;
           if(mark[i]==0)
           {
               dfs(i);
           }
           x=max(x,y);
       }
       cout<<x<<"\n";
   }
}


Measured memory_bytes: 22388
from sys import stdin, setrecursionlimit
setrecursionlimit(100000)

s = stdin.readline().rstrip()
cand = ['eraser', 'erase', 'dreamer', 'dream']

for t in cand:
  s = s.replace(t, '')

  
if len(s) == 0:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3188
<?php
$bingoCard[0] = explode(' ', trim(fgets(STDIN)));
$bingoCard[1] = explode(' ', trim(fgets(STDIN)));
$bingoCard[2] = explode(' ', trim(fgets(STDIN)));

$N = (int)trim(fgets(STDIN));
$selected = [];
for ($i = 0; $i < $N; $i++) {
    $selected[] = trim(fgets(STDIN));
}

$bingoLine = [
    $bingoCard[0],
    $bingoCard[1],
    $bingoCard[2],
    array_map(function($ary) { return $ary[0]; }, $bingoCard),
    array_map(function($ary) { return $ary[1]; }, $bingoCard),
    array_map(function($ary) { return $ary[2]; }, $bingoCard),
    [$bingoCard[0][0], $bingoCard[1][1], $bingoCard[2][2]],
    [$bingoCard[0][2], $bingoCard[1][1], $bingoCard[2][0]],
];

$result = array_filter($bingoLine, function($line) use ($selected) {
    return (count(array_intersect($line, $selected)) >= 3);
});
echo (!!$result ? 'Yes' : 'No');


Measured memory_bytes: 3700
#include <iostream>
using namespace std;
int p[53][53];

class point{
public:
	int x, y;
	point(int newx, int newy){
		x = newx;
		y = newy;
	}
};

void findisland(int i, int j){
	p[i][j] = 2;
	if (p[i - 1][j - 1] == 1)
		findisland(i - 1, j - 1);
	if (p[i][j - 1] == 1)
		findisland(i, j - 1);
	if (p[i + 1][j - 1] == 1)
		findisland(i + 1, j - 1);
	if (p[i - 1][j] == 1)
		findisland(i - 1, j);
	if (p[i + 1][j] == 1)
		findisland(i + 1, j);
	if (p[i - 1][j + 1] == 1)
		findisland(i - 1, j + 1);
	if (p[i][j + 1] == 1)
		findisland(i, j + 1);
	if (p[i + 1][j + 1] == 1)
		findisland(i + 1, j + 1);
}


int main()
{
	int w, h, count;
	while (cin >> w >> h, (w | h)){

		//初期化
		for (int i = 0; i < 53; i++){
			for (int j = 0; j < 53; j++){
				p[i][j] = 0;
			}
		}
		count = 0;

		//入力
		for (int i = 1; i < h + 1; i++){
			for (int j = 1; j < w + 1; j++){
				cin >> p[i][j];
			}
		}

		//探索
		for (int i = 1; i < h + 1; i++){
			for (int j = 1; j < w + 1; j++){
				if (p[i][j] == 1){
					findisland(i, j);
					count++;
				}
			}
		}
		cout << count << endl;



	}
	return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  string s;
  vector<string> a(0);
  for(int i=0; i<H; i++)
  {
    cin >> s;
    for(int j=0; j<W; j++)
      if(s[j]!='.'){
        a.push_back(s);
        break;
      }
  }
  for(int j=0; j<W; j++){
    int wi=0;
    for(int i=0; i<(int)a.size(); i++)
      if(a[i][j]=='.')
        wi++;
    if(wi==(int)a.size())
      for(int i=0; i<(int)a.size(); i++)
        a[i][j]=0;
  }
  for(auto i:a){
    for(auto j:i)
      if(j!=0) cout << j;
    cout << endl;
  }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

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; }
constexpr int INF = 1001001001;
constexpr long long INFL = (1LL<<60);
constexpr double eps = (1e-9);

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

  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i, n) cin >> p[i];

  sort(ALL(p));

  int ans = 0;
  rep(i, k) ans += p[i];

  cout << ans << endl;

  return 0;
}


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

int main(){
	int n,x;
	cin>>n>>x;
	vector<long long> boxes(n);
	for(int i=0;i<n;i++) cin>>boxes[i];
	long long res = 0;
	if(boxes[0]>x){
	 res += boxes[0]-x;
	 boxes[0]-=(boxes[0]-x);
	}
	for(int i=1;i<n;i++){
		if(boxes[i-1]+boxes[i] > x){
			res += (boxes[i-1]+boxes[i])-x;
			boxes[i]-=(boxes[i-1]+boxes[i]-x);
		}
	}
	cout<<res;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;

int pow(int a, int b) {
	int ans = 1;
	for (int i = 0; i < b; i++)ans *= a;
	return ans;
}

int main() {
	vector<int> A;
	A.push_back(1);
	for (int i = 2; i < 32; i++) {
		for (int j = 2; pow(i, j) <= 1000; j++) {
			A.push_back(pow(i, j));
		}
	}
	sort(A.begin(), A.end());
	int X;
	cin >> X;
	for (int i = 1; i < A.size(); i++) {
		if (A[i] > X) {
			cout << A[i - 1];
			return 0;
		}
	}
	cout << 1000;
	return 0;
}



Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_f

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define em emplace_back
#define test ll t;cin>>t;while(t--)
#define M 1000000007
#define input ll x;cin >> x
ll power(ll a, ll b)
{
	ll res = 1;
	a = a % M;
	while (b > 0)
	{
		if (b & 1)
		{
			res = (res * a) % M;
			b--;
		}
		a = (a * a) % M;
		b >>= 1;
	}
	return res;
}
ll gcd(ll a, ll b) { return (b == 0) ? a : gcd(b, a % b); }

int main () {
	ios_base::sync_with_stdio(false); 
    cin.tie(nullptr);
		string s1, s2;
		cin >> s1 >> s2;
		ll n1 = s1.length(), n2 = s2.length();
		ll dp[n1 + 1][n2 + 1];
		for (size_t i = 0; i <= n1; i++)
		{
			dp[i][0] = 0;
		}
		for (size_t i = 0; i <= n2; i++)
		{
			dp[0][i] = 0;
		}
		for (size_t i = 1; i <= n1; i++)
		{
			for (size_t j = 1; j <= n2; j++)
			{
				if(s2[j-1]==s1[i-1]){
					dp[i][j] = 1 + dp[i - 1][j - 1];
				}
				else {
					dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
				}
			}
		}
		ll index = dp[n1][n2];

		char lcs[index + 1];
		lcs[index] = '\0';

		ll i = n1, j = n2;
		while (i > 0 && j > 0)
		{
			if (s1[i - 1] == s2[j - 1])
			{
				lcs[index - 1] = s1[i - 1];
				i--;
				j--;
				index--;
			}
			else if (dp[i - 1][j] > dp[i][j - 1])
				i--;
			else
				j--;
		}
		cout << lcs << endl;
}

Measured memory_bytes: 73984
#include <bits/stdc++.h>
#define lli long long int
#define MAX(A,B) (A)>(B)?(A):(B)
#define MIN(A,B) (A)<(B)?(A):(B)
#define gcd(A,B) __gcd(A,B)
#define lcm(A,B) A/(__gcd(A,B))*B
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define ld long double
#define mod 1000000007LL
#define all(x) x.begin(), x.end()
#define usecppio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

typedef pair<int,int> pii;

vector <char> v;
string str;
int main()
{
	usecppio
	int n;
	cin >> n;
	cin >> str;
	for (auto it:str)
	{
		if (v.empty())
		{
			v.push_back(it);
		}
		else
		{
			if (v.back()==it) continue;
			else v.push_back(it);
		}
	}
	cout << v.size();
}


Measured memory_bytes: 592
import numpy as np
from scipy.sparse.csgraph import floyd_warshall

N,M,L=map(int,input().split())
INF = 1 << 31
dist=np.array([[INF for _ in range(N)] for _ in range(N)])

for i in range(N):
  dist[i][i]=0
  
for i in range(M):
  a,b,c=map(int,input().split())
  a-=1
  b-=1
  dist[a][b]=c
  dist[b][a]=c

dist = floyd_warshall(dist)

for i in range(N):
  for j in range(N):
    if dist[i][j]<=L:
      dist[i][j]=1
    else:
      dist[i][j]=INF

dist = floyd_warshall(dist)
dist[dist==INF]=0
#dist=dist.astype(int)
#print(dist)

Q=int(input())
ans=[0]*Q
for q in range(Q):
  s,t=map(int,input().split())
  s-=1
  t-=1
  ans[q]=int(dist[s][t]-1)

print(*ans,sep='\n')



Measured memory_bytes: 43804
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
#define pint pair<int,int>
#define vi(v) rep(i,v.size())cin >> v[i]
#define vc(v) rep(i,v.size())cout << v[i] << endl
#define ni(n) cin >> n
#define nc(n) cout << n << endl
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
int solve(){
  int a,b,c;
  cin >> a >> b >> c;
  int A = max(a,b),B = min(a,b);
  if(B <= c && c <= A)YY;
  else NN;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>

void sort(int *array, int size);
int parse();
int term();
int number();

char expression[10000+1];
int index;

void sort(int *array, int size) {
    int i, j;
    for(i = 0; i < size; i++) {
        for(j = 0; j < size - i - 1; j++) {
            if(array[j] < array[j + 1]) continue;
            array[j] ^= array[j + 1];
            array[j + 1] ^= array[j];
            array[j] ^= array[j + 1];
        }
    }
    return;
}

int parse() {
    int res = 0;
    int number[10000];
    int size = 0;
    int i;
    while(expression[index] == '[') {
        index++;
        number[size++] = term();
        index++;
    }
    sort(number, size);
    for(i = 0; i <= size / 2; i++) {
        res += number[i];
    }
    return res;
}

int term() {
    int res = 0;
    if(isdigit(expression[index])) {
        res = number();
    } else {
        res = parse();
    }
    return res;
}

int number() {
    int res = 0;
    while(isdigit(expression[index])) {
        res *= 10;
        res += expression[index] - '0';
        index++;
    }
    return (res + 1) / 2;
}

int main(void) {
    int n;
    scanf("%d\n", &n);
    while(n-- > 0) {
        gets(expression);
        index = 0;
        printf("%d\n", parse());
    }
    return 0;
}

Measured memory_bytes: 652
/*
   AUTHOR :- Gaurang_Kothiya
   
   Quote:-" Great things never come from comfort zones."                                                                                                                
*/
 
#include<bits/stdc++.h>
using namespace std;
 
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ld long double
#define f(i,x,n) for(ll i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(ll i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007
 

void solver()
{
	ll n;
	cin>>n;
	v(ll) vec(n);
	fe(x,vec) cin>>x;
	sort(all(vec));
	
	ll ans=maxy;
	
	f(i,vec[0],vec[n-1])
	{
		ll temp2=0;
		ll temp=i;
		f(j,0,n-1)
		{
			temp2 += abs(temp-vec[j])*abs(temp-vec[j]);
		}
		ans=min(ans,temp2);		
	}
	cout<< ans;
	
}

signed main() 
{
	speed;
	
	ll q=1;
	//cin>>q;
	
	while(q--)
		solver();
		
 	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll mn,n,k;
void recur(ll n,ll m)
{
    if(n==0)
    {
        mn=min(mn,m);
        return ;
    }
    recur(n-1,m*2);
    recur(n-1,m+k);
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    mn=INT_MAX;
    cin>>n>>k;
    recur(n,1);
    cout<<mn<<endl;

    return 0;
}


Measured memory_bytes: 3560
# -*- coding: utf-8 -*-

import sys
import os
import math

def is_overflow(v):
    s = str(v)
    if len(s) > 80:
        return True
    else:
        return False

N = int(input())
for i in range(N):
    v0 = int(input())
    v1 = int(input())
    if is_overflow(v0) or is_overflow(v1):
        print('overflow')
    elif is_overflow(v0 + v1):
        print('overflow')
    else:
        print(v0 + v1)

Measured memory_bytes: 7668
use std::io;
use std::cmp;

fn main() {
  let mut buf = String::new();
  io::stdin().read_line(&mut buf).unwrap();
  let s: Vec<&str> = buf.split_whitespace().collect();
  let n: usize = s[0].parse().unwrap();
  let w: i32 = s[2].parse().unwrap();

  let mut buf2 = String::new();
  io::stdin().read_line(&mut buf2).unwrap();
  let s2: Vec<&str> = buf2.split_whitespace().collect();
  if n == 1 {
    let last0: i32 = s2[n - 1].parse().unwrap();
    println!("{}", (last0 - w).abs());
  } else {
    let last1: i32 = s2[n - 2].parse().unwrap();
    let last0: i32 = s2[n - 1].parse().unwrap();
    let choice0 = (last0 - w).abs();
    let choice1 = (last1 - last0).abs();
    println!("{}", cmp::max(choice0, choice1));
  }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
 
class Cube{
public:
  int f[6];
  Cube(){}
  void roll_z(){ roll(1,2,4,3);}
  void roll_y(){ roll(0,2,5,3);}
  void roll_x(){ roll(0,1,5,4);}
  void roll(int i,int j,int k,int l){
    int t=f[i]; f[i]=f[j]; f[j]=f[k]; f[k]=f[l]; f[l]=t;
  }
};
 
int getRight( Cube c1,int f1,int f2 ){
  for(int i=0;i<6;i++){
    for(int j=0;j<4;j++){
      if( c1.f[0]==f1 && c1.f[1]==f2 ) return c1.f[2];
      c1.roll_z();
    }
    if( i%2 == 0 )c1.roll_y();
    else c1.roll_x();
  }
  return -1;
}
 
int main(){
  Cube c;
  int f1,f2;
  for(int i=0;i<6;i++)cin>>c.f[i];
  int q; cin>>q;
  for(int i=0;i<q;i++){
    cin>>f1>>f2;
    cout<<getRight(c,f1,f2)<<endl;
  }
  return 0;
}
   
  


Measured memory_bytes: 3092
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int [] in = new int [100000];
        long ans = 0;
        for(int i=0;i<n;i++){int a = sc.nextInt();
                             in[a-1]++;
                             ans+=a;
                            }
		
		int q = sc.nextInt();
        for(int i=0;i<q;i++){int b = sc.nextInt();
                             int c = sc.nextInt();
                             long d = (long)(c-b);
                             ans+=in[b-1]*(c-b);
                             in[c-1]+=in[b-1];
                             in[b-1]=0;
                             System.out.println(ans);
                            }		
	}
}

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

int main() {
	int reding;
	int inputreding;
	int exreding;
	cin >> inputreding >> exreding;
	reding = exreding + (100 * (10 - inputreding));
	if (inputreding > 10)
		cout << exreding;
	else
		cout << reding;

	return 0;
}

Measured memory_bytes: 256
import scala.collection.mutable

object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  val Array(r, c, ai, aj, bi, bj) = readLine.trim.split(' ').map(_.toInt)
  val state = Array.tabulate(r){_ ⇒ Array.tabulate(c){_ ⇒ Int.MaxValue}}.also{arr ⇒ arr(ai)(aj) = 0}
  val queue = mutable.Queue[(Coordinate, Int)]().also{q ⇒ q.enqueue((Coordinate(ai, aj), 0))}
  while (queue.nonEmpty){
    val (f, distance) = queue.dequeue()
    for (Coordinate(x, y) ← neighbors(f)) {
      if (state(x)(y) > distance + 1){
        state(x)(y) = distance + 1
        queue.enqueue((Coordinate(x, y), distance + 1))
      }
    }
  }
  val pattern = Array.tabulate(r){_ ⇒ Array.tabulate(c){_ ⇒ 0L}}.also{arr ⇒ arr(ai)(aj) = 1L}
  val isSearching = Array.tabulate(r){_ ⇒ Array.tabulate(c){_ ⇒ false}}.also{arr ⇒ arr(ai)(aj) = true}
  var stack:List[Coordinate] = List(Coordinate(ai, aj))
  while (stack.nonEmpty){
    stack = stack.flatMap{f ⇒
      val neighbor = neighbors(f)
      neighbor.foreach{t ⇒
        if (state(f.x)(f.y) + 1 == state(t.x)(t.y)) pattern(t.x)(t.y) = (pattern(f.x)(f.y) + pattern(t.x)(t.y)) % 1000000007L
      }
      neighbor.filter{
        case Coordinate(x, y) ⇒
          if (isSearching(x)(y)){
            false
          }else {
            isSearching(x)(y) = true
            true: Boolean
          }
      }
    }
  }
  println(s"${state(bi)(bj)} ${pattern(bi)(bj)}")

  def neighbors(coord: Coordinate): List[Coordinate] = {
    Coordinate(coord.x, 0)::Coordinate(coord.x, c - 1)::Coordinate(0, coord.y)::Coordinate(r - 1, coord.y)::List(Coordinate(1, 0), Coordinate(- 1, 0), Coordinate(0, 1), Coordinate(0, - 1)).map{_ + coord}.filter(p ⇒ (0 until r).contains(p.x) && (0 until c).contains(p.y))
  }
  case class Coordinate(x: Int, y: Int){
    def +(that: Coordinate): Coordinate = Coordinate(x + that.x, y + that.y)
  }
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


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

using lint = long long;

map<lint, lint> dp1[15][127];
map<lint, lint> dp2[15][2][127];

lint sum(const string& d){
    lint res = 0;
    for(auto c : d){
        res += c - '0';
    }
    return res;
}

lint prod(const string& d){
    lint res = 1;
    for(auto c : d){
        res *= c - '0' + 1LL;
    }
    return res;
}

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

    string d;
    cin >> d;

    const int n = (int)d.size();

    lint S = sum(d);
    lint P = prod(d);

    dp1[0][0][1] = 1;
    dp2[0][0][0][1] = 1;

    for(int i = 0 ; i < n ; ++i){
        for(int j = 0 ; j <= S ; ++j){
            for(int x = 0 ; x < 10 ; ++x){
                if(j + x <= S){
                    for(auto p : dp1[i][j]){
                        dp1[i + 1][j + x][p.first * (x + 1LL)] += p.second;
                    }
                }
            }
        }
        for(int j = 0 ; j < 2 ; ++j){
            int D = j ? 9 : d[i] - '0';
            for(int k = 0 ; k <= S ; ++k){
                for(int x = 0 ; x <= D ; ++x){
                    if(k + x <= S){
                        for(auto p : dp2[i][j][k]){
                            dp2[i + 1][j || x < D][k + x][p.first * (x + 1LL)] += p.second;
                        }
                    }
                }
            }
        }
    }

    lint ans = 0;

    for(int j = 0 ; j < S ; ++j){
        for(auto p : dp1[n][j]){
            ans += p.second;
        }
    }

    for(auto p : dp1[n][S]){
        if(p.first < P){
            ans += p.second;
        }
    }

    ans += dp2[n][1][S][P];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 75716
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first < y.first;});
#define FRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first > y.first;});
#define SSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second < y.second;});
#define SRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second > y.second;});
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define $(x) {cout << #x << " = " << (x) << endl;}


int main() {
    LL N;
    cin >> N;
    VVI dp(N + 1, VI(3, 0));
    VI abc(3);
    REP(i, N) {
        REP(j, 3) {
            cin >> abc[j];
        }
        REP(j, 3) {
            REP(k, 3) {
                if (j == k) continue;
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + abc[j]);
            }
        }
    }

    cout << *max_element(ALL(dp[N])) << endl;

    return 0;
}


Measured memory_bytes: 5760
/*
      author  : nishi5451
      created : 15.08.2020 13:03:41
*/

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


int main(){
    int n;
    string s;
    cin >> n >> s;
    if(s.size()%2!=0){
        cout << "No" << endl;
        return 0;
    }
    else{
        string t = s.substr(0,s.size()/2);
        string u = s.substr(s.size()/2,s.size()/2);
        if(t==u) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}   

Measured memory_bytes: 3636