akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#define N 110000
using namespace std;
inline char gc(){
	static char now[1<<16],*T,*S;
	if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
	return *S++;
}
inline int read(){
	int x=0;char ch=gc();
	while (ch<'0'||ch>'9') ch=gc();
	while (ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=gc();}
	return x;
}
struct node{
	int y,next;
}data[N<<1];
struct node1{
	int dep,id;
}vect[N];
int h[N],fa[N],n,in[N],a[N],num;
void dfs(int x){
	for (int i=h[x];i;i=data[i].next){
		int y=data[i].y;if (fa[x]==y) continue;fa[y]=x;
		vect[y].dep=vect[x].dep+1;vect[y].id=y;
		if (in[y]==1) vect[y].dep=0;dfs(y);
	}
}
inline bool cmp(node1 a,node1 b){return a.dep>b.dep;}
int main(){
	//freopen("cleaning.in","r",stdin);
	n=read();
	for (int i=1;i<=n;++i) a[i]=read();
	if (n==2){if (a[1]==a[2]) printf("YES");else printf("NO");return 0;}
	for (int i=1;i<n;++i){
		int x=read(),y=read();
		data[++num].y=y;data[num].next=h[x];h[x]=num;in[y]++;
		data[++num].y=x;data[num].next=h[y];h[y]=num;in[x]++;
	}int root=1;while (in[root]==1) ++root;
	vect[root].dep=1;vect[root].id=root;dfs(root);
	sort(vect+1,vect+n+1,cmp);int op=1;
	//for (int i=1;i<=n;++i) printf("%d %d\n",vect[i].dep,vect[i].id);
	while (vect[op].dep!=0){
		int x=vect[op++].id;long long ans1=0;int max1=0,child=0,childn=0;
		for (int i=h[x];i;i=data[i].next){
			int y=data[i].y;if (fa[x]==y) continue;
			ans1+=a[y];max1=max(max1,a[y]);child++;
		}if (a[x]>ans1){printf("NO");return 0;}
		if (child==1) if (ans1!=a[x]){printf("NO");return 0;}
		long long rest=ans1-max1;
		if (rest>=max1){
			if (ans1-a[x]>(ans1>>1)){printf("NO");return 0;}else a[x]-=ans1-a[x];
		}else{
			if (ans1-a[x]>rest){printf("NO");return 0;}else a[x]-=ans1-a[x];
		}
	}
	if (a[root]==0) printf("YES");else printf("NO");
	return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1ll;while(b){if(b&1)ans=ans*a%MOD;a=a*a%MOD;b>>=1;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/

int main()
{
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\in.txt.txt","r",stdin);
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\out.txt.txt","w",stdout);
	int a,b;
	cin>>a>>b;
	if(a==b)
	{
		cout<<"Draw"<<endl;
	}else
	{
		if(a==1)
		{
			cout<<"Alice"<<endl;
		}else if(b==1)
		{
			cout<<"Bob"<<endl;
		}else
		{
			if(a<b)
			{
				cout<<"Bob"<<endl;
			}else
			{
				cout<<"Alice"<<endl;
			}
		}
	}
	
	
    return 0;
}

inline void getInt(int* p) {char ch;do {ch = getchar();} 
while (ch == ' ' || ch == '\n');if (ch == '-') {*p = -(getchar() - '0');
while ((ch = getchar()) >= '0' && ch <= '9') {*p = *p * 10 - ch + '0';}}
else {*p = ch - '0';while ((ch = getchar()) >= '0' && ch <= '9') 
{*p = *p * 10 + ch - '0';}}}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int t[6000006][2], pr[6000005];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for(int i=0; i<s.length(); i++)
    if(s[i]!=t[i])
    ans++;
  cout << ans;
  return 0;
}



Measured memory_bytes: 3780
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n;
cin >>n;
long long d[n];
for(int i=0;i<n;i++){
cin >>d[i];
}
sort(d,d+n);
int m;
cin>>m;
long long t[m];
for(int i=0;i<m;i++){
cin >>t[i];
}
sort(t,t+m);
if(n<m){
cout <<"NO";
}
else{
int now=0;
for(int i=0;i<n;i++){
if(t[now]==d[i]){
now++;
}
}
if(now==m){
cout << " YES";
}
else{
cout <<"NO";
}
}
return 0;
}

Measured memory_bytes: 3328
#include<cstdio>
#include<iostream>
#include<vector>
#include<tuple>
#include<queue>
#include <set>
#include<algorithm>
#include<string.h>
#include<math.h>

using namespace std;

int main(int argc, char* argv[]){
  int n;
  scanf("%d",&n);
  if(n==1){
    puts("Hello World");
  }else{
    int a;
    int b;
    scanf("%d",&a);
    scanf("%d",&b);
    printf("%d\n",a+b);
    return 0;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    string s;
    cin >> s;
    int count = 0;
    for(int i=0; i<s.length(); i++){
        if(s[i] == 'x'){
            count += 1;
        }
    }
    if(count >= 8){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
}

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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

#define p(a, b) make_pair(a, b)

vector<int> T[100001];
int color[100001];
int cnt[2];
const int NONE = -1;
const int BLACK = 0;
const int WHITE = 1;

int main()
{
	int N, a, b, turn = 0;
	queue<pair<int, int> > qb, qw;

	cin >> N;
	rep(i, N - 1) {
		cin >> a >> b;
		T[a].push_back(b);
		T[b].push_back(a);
	}

	repc(i, 1, N) {
		if (i == 1) color[i] = BLACK;
		else if (i == N) color[i] = WHITE;
		else color[i] = NONE;
	}

	qb.push(p(1, 0));
	qw.push(p(N, 0));
	while (!qb.empty() || !qw.empty()) {
		while (!qb.empty() && qb.front().second == turn) {
			int current = qb.front().first; qb.pop();
			int len = T[current].size();

			rep(i, len) {
				int next = T[current][i];
				if (color[next] == NONE) {
					qb.push(p(next, turn + 1));
					color[next] = BLACK;
					cnt[BLACK]++;
				}
			}
		}
		while (!qw.empty() && qw.front().second == turn) {
			int current = qw.front().first; qw.pop();
			int len = T[current].size();

			rep(i, len) {
				int next = T[current][i];
				if (color[next] == NONE) {
					qw.push(p(next, turn + 1));
					color[next] = WHITE;
					cnt[WHITE]++;
				}
			}
		}
		turn++;
	}

	if (cnt[BLACK] > cnt[WHITE]) cout << "Fennec" << endl;
	else cout << "Snuke" << endl;

	return 0;
}


Measured memory_bytes: 6400
S = input()
ans = [0]*len(S)
R = 0
L = 0
first = 0
count = 0
for i in range(len(S)-1):
    if S[i] == "L" and S[i+1] == "R":
        count += 1
        if count % 2 == 1:
            if (R - first) % 2 == 0:
                ans[R] = count//2 + 1
                ans[L] = count//2
            else:
                ans[R] = count//2 
                ans[L] = count//2 + 1
        else:
            ans[R] = count//2
            ans[L] = count//2
        count = 0
        R = 0
        L = 0
        first = -1
    elif S[i] == "R" and S[i+1] == "L":
        R = i
        L = i+1
        count += 1
    else:
        count += 1
    if first == -1:
        first = i+1
count += 1
if count % 2 == 1:
    if (R - first) % 2 == 0:
        ans[R] = count//2 + 1
        ans[L] = count//2
    else:
        ans[R] = count//2 
        ans[L] = count//2 + 1
else:
    ans[R] = count//2
    ans[L] = count//2
print(" ".join(map(str, ans)))

Measured memory_bytes: 51312
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node
{
  int key;
  Node *right, *left, *parent;
};

Node *root,*NIL;

Node * treeMinimum(Node *x)
{
  while(x->left != NIL) x=x->left;
  return x;
}

Node * find(Node *u,int k)
{
  while(u!=NIL&&k!=u->key)
    {
      if(k<u->key) u=u->left;
      else u=u->right;
    }
  return u;
}

Node * treeSuccessor(Node *x)
{
  if(x->right != NIL) return treeMinimum(x->right);
  Node *y = x->parent;
  while(y!=NIL&&x==y->right)
    {
      x=y;
      y=y->parent;
    }
  return y;
}

void treeDelete(Node *z)
{
  Node *y;
  Node *x;

  if(z->left==NIL||z->right==NIL)
    y=z;
  else y=treeSuccessor(z);
  if(y->left!=NIL)
    {
      x=y->left;
    }
  else
    {
      x=y->right;
    }

  if(x!=NIL)
    {
      x->parent=y->parent;
    }

  if(y->parent==NIL)
    {
      root=x;
    }
  else
    {
      if(y==y->parent->left)
	{
	  y->parent->left=x;
	}
      else
	{
	  y->parent->right=x;
	}
    }
  if(y!=z)
    {
      z->key=y->key;
    }

  free(y);
}

void insert(int k)
{
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(struct Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  for(;x!=NIL;)
    {
      y=x;
      if(z->key < x->key)
	{
	  x=x->left;
	}
      else
	{
	  x=x->right;
	}
    }
  z->parent = y;
  if(y==NIL)
    {
      root=z;
    }
  else
    {
      if(z->key < y->key)
	{
	  y->left=z;
	}
      else
	{
	  y->right = z;
	}
    }
}

void inorder(Node *u)
{
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u)
{
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main()
{
  int n,i,x;
  string com;
  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      cin>>com;
      if(com[0]=='f')
	{
	  scanf("%d",&x);
	  Node *t = find(root,x);
	  if(t!=NIL) printf("yes\n");
	  else printf("no\n");
	}
      else if(com=="insert")
	{
	  scanf("%d",&x);
	  insert(x);
	}
      else if(com=="print")
	{
	  inorder(root);
	  printf("\n");
	  preorder(root);
	  printf("\n");
	}
      else if(com=="delete")
	{
	  scanf("%d",&x);
	  treeDelete(find(root,x));
	}
    }
  return 0;
}



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

using namespace std;

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back
#define mod 1000000007

const int N = 100005;

void solve() {
	int i, j, k, n, m, ans = 0, cnt = 0, sum = 0;
	cin >> n >> m;
	string s[n];
	for (i = 0; i < n; i++) {
		cin >> s[i];
	}
	int dp[n][m];
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			if (i == 0 && j == 0) continue;
			if (s[i][j] == '#') continue;
			if (i == 0) {
				dp[i][j] = dp[i][j - 1];
				continue;
			}
			if (j == 0) {
				dp[i][j] = dp[i - 1][j];
				continue;
			}
			dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
			dp[i][j] %= mod;
		}
	}
	cout << dp[n - 1][m - 1];
	return ;
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// int t; cin >> t; while (t--)
	solve();
	return 0;
}

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

int n;
int li[5005];

int main(){
  cin >> n;
  for(int i=1;i<=n;i++) cin >> li[i];
  sort(li+1,li+n+1);
  double ans = 0.0;
  double cur = 1.0;
  for(int i=n;i>=2;i--){
    cur*=2.0;
    ans+=li[i]/cur;
  }
  ans+=li[1]/cur;
  cout << ans << endl;
  return 0;
}

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


p = 10**9+7

ans = 0
s = sum(a)%p
ans = (s**2)%p
for i in range(n):
    ans -= (a[i]**2)%p
t = ans%p
if t%2==0:
    print(t//2)
else:
    print((t+p)//2)

Measured memory_bytes: 31528
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
int inf = 1e9;

int main() {
  int n, k; cin >> n >> k;
  vector<long long int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  vector<long long int> b(n+1);
  b[0] = 0;
  for(int i=1; i<=n; i++) {
    b[i] = b[i-1] + a[i-1];
  }
  vector<long long int> x;
  for(int i=0; i<=n; i++){
    for(int j=i+1; j<=n; j++) {
      x.push_back(b[j]-b[i]);
    }
  }
  sort(x.begin(), x.end());
  long long int ans = 0;
  for(int i=60; i>=0; i--) {
    vector<long long int> tmp(0, 0);
    tmp.clear();
    for(int j=0; j<x.size(); j++) {
      if(x[j]&(1LL << i)) tmp.push_back(x[j]);
    }
    if(tmp.size() >= k) {
      ans += (1LL << i);
      x = tmp;
    }
  }
  cout << ans << endl;
  return 0;
}


//EOF


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

int main(){
    int n;
    cin>>n;
    int arr[n];
    for (int i=0;i<n;i++){
        cin>>arr[i];
    }
    bool app = true;
    for (int i=0;i<n;i++){
        if (arr[i]%2==0){
            if (arr[i]%3==0 || arr[i]%5==0){
            }
            else{
                app = false;
            }
        }
    }
    if (app) cout<<"APPROVED";
    else cout<<"DENIED";
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		if(a>b){
			System.out.println(0);
		}else if(n==1){
			if(a==b){
				System.out.println(1);
			}else{
				System.out.println(0);
			}
		}else{
			System.out.println((b*(n-1)+a)-(a*(n-1)+b)+1);
		}
		return;
	}
}

Measured memory_bytes: 22864
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
    ll n;
    cin >> n;
    vector<ll> ret;
    for(ll i = 1; i*i <= n; i++){
        if(n%i == 0){
            ret.push_back(i);
            if(i*i != n)ret.push_back(n/i);
        }
    }
    if(ret.size() % 2 == 1)ret.push_back(ret.at(ret.size()-1));
    ll ans = inf;
    for(ll i = 0; i < ret.size(); i+=2){
        ll now = max(to_string(ret.at(i)).size(), to_string(ret.at(i+1)).size());
        ans = min(ans, now);
    }
    cout << ans;
}

Measured memory_bytes: 256
//https://ideone.com/x8zpRc
#include<queue>
#include<map>
#include <string>
#include<bits/stdc++.h>
#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);
//#define x real()
//#define y imag()
using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<30> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//#define var(x) ((x)<<1)
//#define nvar(x) ((x)^1)
const int N=100000,M=100000;

ll a,c,b,d,ans1,ans2,ans3;
 main()
{

//cout<<Pow((ll)1000000,(ll)110);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//    char input[15];
//    scanf("%s", &input);  array of char
//  gets(c+1);  array of char
//printf("%s, ",name[k[i]].c_str());  printf of string
//priority_queue<ll,vector<ll>,greater<ll>>y;
input;

cin>>a>>b>>c>>d;

ans1=b/c-(a-1)/c;

ans2=b/d-(a-1)/d;

ll k=c/__gcd(c,d)*d;

ans3=b/k-(a-1)/k;
cout<<(b-a+1)-ans1-ans2+ans3;
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int[] r = new int[9];
        for (int i = 0; i < n; i++) {
            if (a[i] < 400) {
                r[0]++;
            } else if (a[i] < 800) {
                r[1]++;
            } else if (a[i] < 1200) {
                r[2]++;
            } else if (a[i] < 1600) {
                r[3]++;
            } else if (a[i] < 2000) {
                r[4]++;
            } else if (a[i] < 2400) {
                r[5]++;
            } else if (a[i] < 2800) {
                r[6]++;
            } else if (a[i] < 3200) {
                r[7]++;
            } else {
                r[8]++;
            }
        }

        int count = 0;
        for (int i = 0 ; i < 8 ; i++) {
            if (r[i] > 0) {
                count++;
            }
        }
        if (count == 0) {
            System.out.print(1);
        } else {
            System.out.print(count);
        }
        System.out.print(" ");
        System.out.println(count + r[8]);
    }

}

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

int main() {
    int n;
    cin >> n;
    rep(i,n){
        int a;
        cin >> a;
        if (a%2==0&&(a%5!=0&&a%3!=0)){
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
}

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

using namespace std;
int main() {
	int a,b,c;
	cin >> a >> b >> c;
	vector<int> A{a+b,b+c,c+a};
	sort(A.begin(), A.end());
	cout << A[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>

int main(void)
{
	int a = 0, b = 0, c = 0,ans = 0;
	scanf("%d%d%d", &a, &b, &c);

	if (b < c)
	{
      if(a + b < c)
      {
		ans = b * 2 + a + 1;
      }
      else
      {
        ans = b + c;
      }
	}
	else
	{
		ans = b + c;
	}

	printf("%d", ans);
	return 0;
}

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

using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for (auto& s : S) {
        cin >> s;
    }
    vector<vector<vector<int> > > cnt(H);
    for (auto& line : cnt) {
        line = vector<vector<int>>(W);
        for (auto& cell : line) {
            cell = vector<int>(4);
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S.at(i).at(j) == '#') {
                cnt.at(i).at(j).at(0) = 0;
                cnt.at(i).at(j).at(1) = 0;
                continue;
            }
            if (i > 0 and S.at(i - 1).at(j) == '.') {
                cnt.at(i).at(j).at(0) = cnt.at(i - 1).at(j).at(0) + 1;
            } else {
                cnt.at(i).at(j).at(0) = 0;
            }
            if (j > 0 and S.at(i).at(j - 1) == '.') {
                cnt.at(i).at(j).at(1) = cnt.at(i).at(j - 1).at(1) + 1;
            } else {
                cnt.at(i).at(j).at(1) = 0;
            }
        }
    }
    for (int i = H - 1; i >= 0; i--) {
        for (int j = W - 1; j >= 0; j--) {
            if (S.at(i).at(j) == '#') {
                cnt.at(i).at(j).at(2) = 0;
                cnt.at(i).at(j).at(3) = 0;
                continue;
            }
            if (i < H - 1 and S.at(i + 1).at(j) == '.') {
                cnt.at(i).at(j).at(2) = cnt.at(i + 1).at(j).at(2) + 1;
            } else {
                cnt.at(i).at(j).at(2) = 0;
            }
            if (j < W - 1 and S.at(i).at(j + 1) == '.') {
                cnt.at(i).at(j).at(3) = cnt.at(i).at(j + 1).at(3) + 1;
            } else {
                cnt.at(i).at(j).at(3) = 0;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            auto cell = cnt.at(i).at(j);
            int v = accumulate(cell.begin(), cell.end(), 0);
            if (S.at(i).at(j) == '.') {
                v++;
            }
            ans = max(ans, v);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 223232
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}

	return gcd(b, a % b);
}

int main() {
	//入力
	ll N, X;
	cin >> N >> X;
	vector<ll> x(N);
	vector<ll> dist(N);
	for (ll i = 0; i < N; i++) {
		cin >> x[i];
		dist[i] = abs(X - x[i]);
	}

	int tmp;

	if (N == 1) {
		cout << dist[0];
	}
	else {
		int tmp;
		for (ll i = 0; i < N - 1; i++) {
			if (i == 0) {
				tmp = gcd(dist[i], dist[i + 1]);
			}
			else {
				tmp = gcd(tmp, dist[i + 1]);
			}
		}
		cout << tmp;
	}

	return 0;
}

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

int main() {
  vector<int> a(5),b(5);
  rep(i,0,5) {cin >> a[i]; b[i] = i;}
  sort(a.begin(), a.end());
  int ans = 1000;
  do {
    int k = 0;
    rep(i,0,5) {
      k += a[b[i]];
      if (i < 4) {
        while(k % 10 != 0) k++;
      }
    }
    ans = min(ans,k);
  } while(next_permutation(b.begin(), b.end()));
  cout << ans << endl;
  return 0;
}


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
ll inf = 1e18+7;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k; 
    ll h[n]; 
    rep(i,0,n) cin >> h[i]; 
    ll dp[100010];
    rep(i,0,100010) dp[i] = inf;
    dp[0] = 0;
    rep(i,0,n){
        rep(j,1,k+1){
            if(i+j>=n) continue;
            dp[i+j] = min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
//arc059_d.cpp
//Wed Jul  3 22:03:32 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	for (char i='a';i<='z';i++){
		int prevhit = -200000;
		for (int j=0;j<s.length();j++){
			if (s[j]==i){
				if (j-prevhit==1){
					cout << j << " " << j+1 << endl;
					return 0;
				}else if (j-prevhit==2){
					if (j-1>0){
						cout << j-1 << " " << j+1 << endl;
						return 0;
					}else if (j+2<=s.length()){
						cout << j << " " << j+2 << endl;
						return 0;
					}
				}
				prevhit = j;
			}
		}
	}

	cout << -1 << " " << -1 << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 512
import math
a, b, h, m = map(int, input().split())

# moda = h % 12
key = 360 / 720 * m
a_i = 360 / 12 * h + key  # ちょっとずつ動いている
b_i = 360 / 60 * m  # 分針はそのまま
kaku = abs(a_i - b_i)
# print(a_i, b_i, kaku, math.cos(math.radians(kaku)))
# if kaku == 90.0 or kaku == 270.0:
# print(math.sqrt(a ** 2 + b ** 2))

# if kaku == 180.0:
#     print(a + b)

# elif kaku == 0.0 or kaku == 360.0:
#    print('0')
# else:
ans = (a ** 2) + (b ** 2) - (2 * a * b * math.cos(math.radians(kaku)))
# kakuは %180しなくてよい
print(math.sqrt(ans))


Measured memory_bytes: 9504
#include<bits/stdc++.h>
using namespace std;
#define MAX 1000000007

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

	int n=s.size();
	int sum =0;
	for(int i=0;i<n;i++){
		sum+=(s[i]-'0');
	}

	if(sum%9)
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;   	 
}

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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }




signed main() {

	int N;
	cin >> N;

	cout << N*N*N << endl;
	return 0;
}


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

using ll = long long int;
using ull = unsigned long long int;
using P = pair<ll, ll>;
using P3 = pair<P,int>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9)+7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr int di8[] = {0, 1, 1, 1, 0, -1, -1, -1};
constexpr int dj8[] = {1, 1, 0, -1, -1, -1, 0, 1};
constexpr double EPS = 1e-9;


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    ll x = 1000;
    for(int i=1;i<n;i++){
        if(a[i-1] < a[i]){
            ll k = x/a[i-1];
            x += (a[i]-a[i-1])*k;
        }
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
    int n;
    int[] arr;
    void run() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        arr = new int[n];
        dfs(1, 0, 0);
    }

    void dfs(int i, int x, int usedMax) {
        if (i == n) {
            print(arr);
            return;
        }

        for (int j = 0; j <= usedMax + 1; j++) {
            int nx = x + j;
            arr[i] = nx;
            dfs(i + 1, x, Math.max(nx, usedMax));
        }
    }

    void print(int[] arr) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < n ;i++) {
            sb.append((char) ('a' + arr[i]));
        }
        System.out.println(sb.toString());
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


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

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

  if (N.at(N.size()-1)=='3') {
    cout << "bon";
    
  }
  else if (N.at(N.size()-1)=='0'||N.at(N.size()-1)=='1'||N.at(N.size()-1)=='6'||N.at(N.size()-1)=='8'){
    cout << "pon";}
  else {
    cout << "hon";}
}


Measured memory_bytes: 3624
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;

    int ans = 0;
    vector<array<int, 3>> dp;
    rep(k, K) {
        int M = k < N % K ? N / K + 1 : N / K;
        dp.assign(M + 1, { 0, 0, 0 });

        rep(i, M) {
            dp[i + 1][0] = max(dp[i][1], dp[i][2]) + (T[K * i + k] == 's' ? R : 0);
            dp[i + 1][1] = max(dp[i][2], dp[i][0]) + (T[K * i + k] == 'p' ? S : 0);
            dp[i + 1][2] = max(dp[i][0], dp[i][1]) + (T[K * i + k] == 'r' ? P : 0);
        }

        ans += max({ dp[M][0], dp[M][1], dp[M][2] });
    }

    write(ans);
}

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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
typedef long long ll;


int main(){
  int a,b,c;
  cin >> a >> b >> c;
  double S = a*b/2*sin(M_PI*c/180);
  printf("%.8lf\n",S);
  printf("%.8f\n",sqrt(a*a+b*b-2*a*b*cos(c*M_PI/180))+a+b);
  printf("%.5f\n",b*sin(c*M_PI/180));
}



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

struct data{
  int id;
  string str;
  data(int a,string b){id=a;str=b;}
};
struct edge{ int a,b,c; };

queue<data> A,B,C;
vector< edge > ans;
bool flg;
int cnt;

bool check(string s){
  int ac=0,bc=0;
  for(int i=0;i<(int)s.size();i++){
    if(s[i]=='o')ac++;
    else bc++;
  }
  return (ac>=bc);
}

void func(data d){
  int len=d.str.size();
  if(len==1)A.push(d);
  else B.push(d);
}

void solve(){
  int key=0;
  while(!C.empty()){
    
    if( key++ > 50000){ flg=true; return; }
    
    data d=C.front();C.pop();
    string s=d.str;
    int i;
    if(!check(s)){ flg=true; return; }
    
    if(d.str.size()<=2){ func(d); continue; }

    int O1=0,X1=0,O2=0,X2=0;;
    for(int i=0;i<(int)s.size();i++){
      if(s[i]=='o')O2++;
      else if(s[i]=='x')X2++;
    }
    
    for(i=0;i+1<(int)s.size();i++){
      if(s[i]=='o')O2--,O1++;
      else X2--,X1++;
      
      
      if(O2>=X2&&O1>=X1){
        ans.push_back( (edge){0,d.id,i} );
        string a=s.substr(0,i+1);
        string b=s.substr(i+1);
        data na=data(cnt++,a);
        data nb=data(cnt++,b);        
        C.push(na);
        C.push(nb);
        break;
      }
    }
    if(i+1<(int)s.size())continue;
    if(A.empty()){ C.push(d); continue; }
    data f=A.front();A.pop();
    if( d.str[0]=='x'){
      ans.push_back( (edge){ 1 , f.id , d.id } );
      cnt++;
      ans.push_back( (edge){ 0 , cnt , 1 } );
      B.push( (data){ cnt++, "ox" } );
      C.push( (data){ cnt++, s.substr(2)} );
    }else{
      ans.push_back( (edge){ 1 , d.id , f.id } );
      cnt++;
      ans.push_back( (edge){ 0 , cnt , (int)s.size()-2 } );
      B.push( (data){ cnt++, "xo" } );
      C.push( (data){ cnt++, s.substr(0, (int)s.size()-2 )} );
    }
  }
  if(!C.empty())flg=true;
}

int main(){
  int Tc;
  cin>>Tc;
  while(Tc--){
    cnt=1;
    while(!A.empty())A.pop();
    while(!B.empty())B.pop();
    while(!C.empty())C.pop();
    ans.clear();
    string st;
    cin>>st;
    if(st.size()==1){
      if(st=="o")cout<<0<<endl;
      else cout<<-1<<endl;
      continue;
    }else if(st.size()==2){
      if(st=="xx")cout<<-1<<endl;
      else cout<<0<<endl;
      continue;
    }
    
    C.push( data(0,st) );
    flg=false;
    solve();
    
    if(flg){
      cout<<-1<<endl;
    }else{
      cout<<ans.size()<<endl;
      for(int i=0;i<(int)ans.size();i++){
        edge e=ans[i];
        if(e.a==0)printf("split ");
        else printf("join ");
        printf("%d %d\n",e.b,e.c);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1280
///FUCKOUT
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

#include "bits/stdc++.h"
#include <ext/rope> //header with rope
using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
//#define endl '\n'

using namespace __gnu_cxx; //namespace with rope and some additional stuff

using ll = long long;
using db = long double;
using row = vector<int>;
using ii = pair<ll, ll>;

const int N = 2e5+5, M = 1e6 + 5, LG = 17, MOD = 1e9 + 7;
const int BLOCK = 225;
const int BLOCKN = N / BLOCK + 1;
const long double EPS = 1e-7;
using ull = unsigned long long;

int32_t main(){
#ifdef ONLINE_JUDGE
  ios_base::sync_with_stdio(0);
  cin.tie(0);
#endif // ONLINE_JUDGE
  int n, k, s;
  cin >> n >> k >> s;

  f(i,0,k)
  	cout<<s<<' ';

  f(i,0,n-k){
  	if(s==1000*1000*1000)cout<<1<<' ';
  	else
  		cout << 1000 * 1000 * 1000 << ' ';
  }



  return 0;
}


Measured memory_bytes: 1280
using System;
using System.Collections.Generic;

using System.Text;


namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] s = Console.ReadLine().Split(' ');

            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);

            int d = a / b;
            int r = a % b;
            double f = (double)a / (double)b;
            

            Console.WriteLine(d + " " + r + " " + f.ToString("f8"));


        }
    }
}    

Measured memory_bytes: 5644
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; cin>>n;
  vector<long long> a(n);
  int neg = 0;
  ll tot = 0;
  for (int i=0; i<n; i++) {
    cin>>a[i];
    if (a[i]<0) { neg++; a[i]=-a[i]; }
    tot += a[i];
  }
  if (neg%2==0) {
    cout<<tot<<endl;
  } else {
    sort(a.begin(), a.end());
    tot -= 2LL*a[0];
    cout<<tot<<endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> int size(const T &x) { return x.size(); }
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end();++it)
#define pb push_back
#define fs first
#define sc second
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;

int main() {
    cin.sync_with_stdio(false);
	ll a,b,c;
	cin >> a >> b >> c;
	ll mn = INF;
	mn = min(mn, a+b);
	mn = min(mn, a+c);
	mn = min(mn, b+c);
	cout << mn << endl;
    return 0;
}


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

a = list(map(int,input().split()))

b = {}

for i in a:
    if i in b:
        b[i] += 1
    else:
        b[i] = 1

c = []
for i in b:
    c.append(b[i])
c.sort()
c.reverse()

if len(c) <= k:
    print(0)
else:
    print(sum(c[k:]))

Measured memory_bytes: 32184
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int N;
    cin >> N;
    
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N - 1);
    for(int i = 0;i < N;i++){
        cin >> A[i];
        A[i]--;
    }
    for(int i = 0;i < N;i++){
        cin >> B[i];
    }
    for(int i = 0;i < N - 1;i++){
        cin >> C[i];
    }
    
    int ans = B[A[0]];
    int pre = A[0];
    
    for(int i = 1; i < N;i++){
        ans += B[A[i]];
        if(pre + 1 == A[i]){
            ans += C[A[i] - 1];
        }
        
        pre = A[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

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

double eps = 1e-12;

int main(){
    string s;
    cin >> s;
    map<string, int> mp;
    mp["SUN"] = 7;
    mp["MON"] = 6;
    mp["TUE"] = 5;
    mp["WED"] = 4;
    mp["THU"] = 3;
    mp["FRI"] = 2;
    mp["SAT"] = 1;
    cout << mp[s] << endl;
    return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
board = [list(input()) for _ in range(H)]
INF = float('inf')
dp = [[INF] * W for _ in range(H)]
if board[0][0] == '.':
    dp[0][0] = 0
else:
    dp[0][0] = 1
for i in range(H):
    for j in range(W):
        if i == 0 and j == 0:
            continue
        if board[i][j] == board[i-1][j]:
            dp[i][j] = min(dp[i][j], dp[i-1][j])
        else:
            dp[i][j] = min(dp[i][j], dp[i-1][j] + 1)
        if board[i][j] == board[i][j-1]:
            dp[i][j] = min(dp[i][j], dp[i][j-1])
        else:
            dp[i][j] = min(dp[i][j], dp[i][j-1] + 1)
if board[H-1][W-1] == '#':
    dp[H-1][W-1] += 1
print(dp[H-1][W-1] // 2)



Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node{
  int key;
  struct Node *right,*left,*parent;
};

typedef struct Node Node;
Node *root,*NIL;

Node *treeMinimum(Node *x){
  while(x->left!=NIL) x=x->left;
  return x;
}

Node *find(Node *u,int k){
  while(u!=NIL && k!=u->key){
    if(k < u->key) u=u->left;
    else u=u->right;
  }
  return u;
}

Node *treeSuccessor(Node *x){
  if(x->right!=NIL) return treeMinimum(x->right);
  Node *y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node *z){
  Node *y,*x;
  if(z->left==NIL || z->right==NIL) y=z;
  else y=treeSuccessor(z);
  if(y->left!=NIL) x=y->left;
  else x=y->right;

  if(x!=NIL) x->parent=y->parent;
  if(y->parent==NIL) root=x;
  else {
    if(y==y->parent->left) y->parent->left=x;
    else y->parent->right=x;
  }

  if(y!=z) z->key=y->key;
  free(y);
}

void insert(int k){
  Node *y=NIL;
  Node *x=root;
  Node *z;
  z=(Node *)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key) x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL) root=z;
  else {
    if(z->key < y->key) y->left=z;
    else y->right=z;
  }
}

void inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  char com[100];
  char print[10]="print";
  char inserts[10]="insert";
  char deletes[10]="delete";
  Node *t;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]=='f'){
      scanf("%d",&x);
      t=find(root,x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(strcmp(com,inserts)==0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strcmp(com,print)==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(strcmp(com,deletes)==0){
      scanf("%d",&x);
      treeDelete(find(root,x));
    }
  }
    
  return 0;
}

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

int main() {
  int N, A[100];
  int approved;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  for (int i = 0; i < N; i++) {
    if (A[i] % 2 == 0) {
      if (A[i] % 3 == 0 || A[i] % 5 == 0) {
        approved = 1;
      } else {
        approved = 0;
        break;
      }
    }
  }
  if (approved == 1) {
    printf("APPROVED\n");
  } else {
    printf("DENIED\n");
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str, T: str):
    if S == T[:-1]:
        print("Yes")
    else:
        print("No")
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9124
using System;
using System.Collections.Generic;
using System.Text;

namespace codeTester.contest190622
{
    class ProblemB
    {
        static List<int> values = new List<int>();
        static long answer = 0;

        public static void Main(string[] args)
        {
            Input();
            Logic();
            Output();
        }

        static void Input()
        {
            values = ReadSpaceSeparatedValues();
        }

        public static List<int> ReadSpaceSeparatedValues()
        {
            List<int> values = new List<int>();
            string[] inputs = Console.ReadLine().Split(' ');
            foreach (string input in inputs)
            {
                values.Add(int.Parse(input));
            }

            return values;
        }

        static void Logic()
        {
            int n = values[0];
            int l = values[1];
            long origTaste = n * (n - 1) / 2 + n * l;
            // i に L を足して 1 を引いた値の絶対値が最小なやつだから
            // i - 1 の値が、負かつ絶対値が N 以下ならば、i - 1 の絶対値番目のリンゴを食べて、味に変化なし
            // i - 1 の値が、負でないならば、1 つ目のリンゴを食べて、その分味が変化
            // i - 1 の値が、負かつ絶対値が N 以上ならば、n 番目のリンゴを食べて、その分味が変化
            int threshold = l - 1;
            if (threshold >= 0)
            {
                answer = origTaste - l;
                return;
            }
            if (Math.Abs(threshold) > n)
            {
                answer = origTaste - l - n + 1;
                return;
            }
            answer = origTaste;
        }

        static void Output()
        {
            Console.WriteLine(answer.ToString());
        }
    }
}


Measured memory_bytes: 11092
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws FileNotFoundException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new File("c:\\0509-input.txt"));

		while (true) {
			int n = scan.nextInt();
			int r = scan.nextInt();
			if (n == 0 && r == 0)
				break;

			int[] x1 = new int[n];
			int[] y1 = new int[n];
			int[] x2 = new int[n];
			int[] y2 = new int[n];
			for (int i = 0; i < n; i++) {
				x1[i] = scan.nextInt();
				y1[i] = scan.nextInt();
				x2[i] = scan.nextInt();
				y2[i] = scan.nextInt();
			}
			Rects rect = new Rects();
			for (int i = 0; i < n; i++) {
				rect.setRect(x1[i], y1[i], x2[i], y2[i]);
			}
			System.out.println(rect.area());
			if (r == 1)
				continue;
			long side = rect.side();

			rect = null;
			rect = new Rects();
			for (int i = 0; i < n; i++) {
				rect.setRect(y1[i], x1[i], y2[i], x2[i]);
			}
			side += rect.side();
			System.out.println(side);

			// rect.debug();
		}

		scan.close();
		System.exit(0);
	}
}

class Vbar {
	public int y1;
	public int y2;

	public Vbar(int _y1, int _y2) {
		y1 = _y1;
		y2 = _y2;
	}

	public long getLength() {
		return y2 - y1;
	}
}

class VbarList {
	List<Vbar> bar = new ArrayList<Vbar>();

	public int getSide() {
		return bar.size() * 2;
	}

	public int getLength() {
		int len = 0;
		for (int i = 0; i < bar.size(); i++)
			len += bar.get(i).getLength();
		return len;
	}

	public void setRect(int y1, int y2) {
		for (int i = 0; i < bar.size(); i++) {
			if (y2 < bar.get(i).y1) {
				bar.add(i, new Vbar(y1, y2));
				return;
			}
			if (y1 <= bar.get(i).y2) {
				bar.get(i).y1 = Math.min(bar.get(i).y1, y1);
				bar.get(i).y2 = Math.max(bar.get(i).y2, y2);
				this.margeRect(i);
				return;
			}
		}
		bar.add(new Vbar(y1, y2));
	}

	private void margeRect(int st) {
		int i = st + 1;
		while (i < bar.size()) {
			if (bar.get(st).y2 < bar.get(i).y1)
				break;
			bar.get(st).y2 = Math.max(bar.get(st).y2, bar.get(i).y2);
			bar.remove(i);
		}
	}

	public void debug(int x) {
		for (int i = 0; i < bar.size(); i++)
			System.out.println(x + ":" + i + " " + bar.get(i).y1 + "-" + bar.get(i).y2);
	}
}

class Rects {
	private VbarList[] vb = new VbarList[10000];

	Rects() {
		for (int x = 0; x < vb.length; x++)
			vb[x] = new VbarList();
	}

	public void debug() {
		for (int x = 0; x < vb.length; x++)
			vb[x].debug(x);
	}

	public long side() {
		long result = 0;
		for (int x = 0; x < vb.length; x++)
			result += vb[x].getSide();
		return result;
	}

	public long area() {
		long result = 0;
		for (int x = 0; x < vb.length; x++)
			result += vb[x].getLength();
		return result;
	}

	public void setRect(int x1, int y1, int x2, int y2) {
		for (int x = x1; x < x2; x++)
			vb[x].setRect(y1, y2);
	}

}

Measured memory_bytes: 69616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxn=1e6+5;
const int mod=1e9+7;
ll dp[50][1<<17];
int main() {
	int n,x,y,z;cin>>n>>x>>y>>z;
    dp[0][0]=1;ll ans=1;
    int forbiden=((1<<(x+y+z-1))+(1<<(y+z-1))+(1<<(z-1)));
    for(int i=1;i<=n;i++) {
    	ans=ans*10%mod;
    	for(int k=1;k<=10;k++) {
    		for(int mask=0;mask<(1<<17);mask++) {
    			int now=((mask<<k)+(1<<(k-1)))&((1<<17)-1);
    			if((now&forbiden)!=forbiden) 
    				(dp[i][now]+=dp[i-1][mask])%=mod;
    		}
    	}
    }
    for(int i=0;i<(1<<17);i++) 
    	(ans-=dp[n][i])%=mod;
    cout<<(ans+mod)%mod<<endl;
    return 0;
}

Measured memory_bytes: 44564
x0,y0,x1,y1=map(int,input().split())

#print(x0,y0,x1,y1)

dx=x1-x0
dy=y1-y0

x2=x1-dy
y2=y1+dx

x3=x2-dx
y3=y2-dy

print(x2,y2,x3,y3)

Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <limits>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdint>
#include <functional>
#include <sstream>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
using ss = stringstream;

const ll mod = 1000000000 + 7; //10^9
const ll llmax = pow(10, 18);

// bool is_integer(double x){
//     return floor(x) == x;
// }





/*逆元　あまりの割り算をするときにこいつをかける(a/b→a*modinv(b))*/
// mod. m での a の逆元 a^{-1} を計算する
// ll modinv(ll a,ll m){
//     long long b = m, u = 1, v = 0;
//     while (b) {
//         long long t = a / b;
//         a -= t * b; swap(a, b);
//         u -= t * v; swap(u, v);
//     }
//     u %= m;
//     if (u < 0) u += m;
//     return u;
// }



// bool IsPrime(ll num)
// {
//     if (num < 2) return false;
//     else if (num == 2) return true;
//     else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
 
//     double sqrtNum = sqrt(num);
//     for (int i = 3; i <= sqrtNum; i += 2)
//     {
//         if (num % i == 0)
//         {
            // 素数ではない
//             return false;
//         }
//     }
 
    // 素数である
//     return true;
// }
 
 /*階乗*/
// ll facctorialMethod(ll k){
//     ll sum = 1;
//     for (ll i = 1; i <= k; ++i)
//     {
//         sum *= i;
        //sum%=MOD;//あまりを出力せよ問題の時はこれもやる
//     }
//     return sum;
// }

int main() {
    ll N;
    cin >> N;
    if(N == 1){
        cout << 0 << endl;
        return 0;
    }
    ll a = 1, b = 1, ans = 1;
    for (ll i = 0; i < N; i++)
    {
        a = a * 8 % mod;
        ans = ans * 10 % mod;
        b = b * 9 % mod;
    }
    ans = (ans - b * 2 + a) % mod;
    ans = (ans + mod ) % mod;

    cout << ans << endl;
    
    
}


Measured memory_bytes: 3592
H, W, M = map(int, input().split())
HW = set(tuple(map(lambda x: int(x)-1, input().split())) for _ in range(M))

sum_h = [0]*H; sum_w = [0]*W
for h, w in HW:
    sum_h[h] += 1
    sum_w[w] += 1

h_num_ix = {}
for i in range(H):
    num = sum_h[i]
    if num == 0: continue
    if not num in h_num_ix: h_num_ix[num] = set()
    h_num_ix[num].add(i)

w_num_ix = {}
for i in range(W):
    num = sum_w[i]
    if num == 0: continue
    if not num in w_num_ix: w_num_ix[num] = set()
    w_num_ix[num].add(i)

max_h_num = max(h_num_ix)
max_w_num = max(w_num_ix)

max_num = max_h_num + max_w_num - 1
for h_ix in h_num_ix[max_h_num]:
    for w_ix in w_num_ix[max_w_num]:
        if (h_ix, w_ix) in HW: continue
        print(max_num + 1)
        exit()
print(max_num)


Measured memory_bytes: 102116
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
	string ans = "No";
	int N;
	cin >> N;
	vector<int> L(N);
	rep(i,N) cin >> L[i];
	sort(all(L));
	ll sum = 0;
	rep(i,N-1)sum+=L[i];
	if(sum>L[N-1]) ans = "Yes";
	cout << ans << endl;
}

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

string in, out;

void zero() { out += '0'; }
void one() { out += '1'; }
void backspace() { out.resize(out.empty() ? 0 : out.size() - 1); }

int main() {
	cin >> in;
	REP(i, 0, in.size()) {
		switch (in[i]) {
		case '0': zero(); break;
		case '1': one();  break;
		case 'B': backspace(); break;
		}
	}
	cout << out << endl;
	return 0;
}


Measured memory_bytes: 256