akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int a, b, c;
		
		a = scanner.nextInt();
		b = scanner.nextInt();
		c = scanner.nextInt();
		
		scanner.close();
		
		int answer = b/a;
		
		if (answer > c) {
			answer = c;
		}
		
		System.out.println(answer);
	}

}

Measured memory_bytes: 22612
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 12
int h,w;
string c[N];

bool Rev_same(string a,string b){
    lol(i,a.size()){
	if(a[i]!=b[a.size()-1-i])return 0;
    }
    return 1;
}
bool Palindrome(string a){
    for(int i=0;i<a.size();i++){
	if(a[i]!=a[a.size()-1-i])return 0;
    }
    return 1;
}
bool Judge(int arr[]){
    //lol(i,h)cout<<arr[i]<<" ";cout<<endl;
    string m[N];
    lol(i,w)m[i]="";
    lol(i,h){
	lol(j,w)m[j].push_back(c[arr[i]][j]);
    }
    bool used[N];
    bool odd=(w%2==1);
    lol(i,w)used[i]=0;
    lol(k,w){
	if(used[k])continue;
	bool done=0;
	for(int i=k+1;i<w;i++){
	    if(Rev_same(m[k],m[i])){
		used[i]=1;
		done=1;
		break;
	    }
	}
	if(done==0){
	    if(odd==0)return 0;
	    if(Palindrome(m[k])==0)return 0;
	    odd=0;
	    used[k]=1;
	}
    }
    return 1;
}

int arr[N];
bool used[N];
bool dfs(){
    int cnt=0,first=mod;
    lol(i,h){
	cnt+=used[i];
	if(used[i]==0)first=min(i,first);
    }
    if(cnt==h){
	if(Judge(arr)==1)return 1;
	return 0;
    }
    if((h-cnt)%2==1){
	arr[h/2]=first;
	used[first]=1;
	if(dfs()==1)return 1;
	used[first]=0;
	if(h-cnt==1)return 0;
    }
    arr[cnt/2]=first;
    used[first]=1;
    for(int i=first+1;i<h;i++){
	if(used[i])continue;
	arr[h-1-cnt/2]=i;
	used[i]=1;
	if(dfs()==1)return 1;
	used[i]=0;
    }
    used[first]=0;
    return 0;
}

int main(){
    cin>>h>>w;
    lol(i,h){
	cin>>c[i];
	used[i]=0;
    }
    cout<<(dfs()?"YES":"NO")<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import math
from collections import defaultdict, deque
from copy import deepcopy
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N, W = MI()
    d = [[0 for i in range(W+1)] for j in range(N+1)]
    mylist = [LI() for i in range(N)]
    for i in range(N):
        vt, wt = mylist[i]
        for j in range(W+1):
            if wt > j:
                d[i+1][j] = d[i][j]
            else:
                d[i+1][j] = max(d[i][j], d[i+1][j-wt]+vt)
    print(d[N][W])
    
if __name__ == "__main__":
    main()


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

int main(int argc, void **arg)
{
    long long a, i;
    char s[5000 + 1];

    scanf("%lld", &a);
    scanf("%s", s);

    if( a >= 3200 ) {
        printf("%s\n", s);
    }
    else {
        printf("red\n");
    }

    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        String S=sc.next();
        int[] data=new int[S.length()];
        
        for(int i=0;i<S.length();i++){
            if(S.charAt(i)=='B'){
                data[i]=1;
            }else{
                data[i]=0;
            }
        }
        
        long ans=0L;
        int Wsum=0;
        
        for(int i=0;i<S.length();i++){
            if(data[i]==0){
                ans+=(i-Wsum);
                Wsum++;
            }
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 27236
#include<stdio.h>

int main()
{
    int A,B,C,K;
    int max1=0,max2=0,max3=0;
    scanf("%d %d %d",&A,&B,&C);
    scanf("%d",&K);
    if(A>=B){
        max1=A;
        max2=B;
    }else{
        max1=B;
        max2=A;
    }
    if(C>=max1){
        max3=max2;
        max2=max1;
        max1=C;
    }else if(C>=max2){
        max3=max2;
        max2=C;
    }
    for(int i=0;i<K;i++){
        max1=max1*2;
    }
    printf("%d",max1+max2+max3);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>

int main()
{
    std::string a;
    std::cin >> a;

    if ((a[0] == a[1] || a[2] == a[3]) && a[1] == a[2]) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}


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

int main(){
  int a,x,y;
  cin >> a >> x >> y;
  if(x>=y)
    cout << "delicious" << "\n";
  else{
    if(y>=x+a+1)
      cout << "dangerous" << "\n";
    else
      cout << "safe" << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
# abc099 B
a, b = gets.split.map(&:to_i)

tou = [1]

(2).upto(999) do |i|
  tou[i-1] = tou[i-2] + i
end
tou.each_cons(2) do |x,y|
  if y-x == b-a
    p x - a
    exit
  end
end


Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 1010
ll mem[2][N][N];
bool solve(bool x,ll a,ll b){
	if(~mem[x][a][b])return mem[x][a][b];
	if(a+b==1)return 1;
	bool res=0;
	if(x==1)res|=(solve(0,a,b)==0);
	if(a>=2)res|=(solve(x,a-2,b+1)==0);
	if(a>=1&&b>=1)res|=(solve(x^1,a,b-1)==0);
	if(b>=2)res|=(solve(x^1,a,b-1)==0);
	//cout<<"solve"<<x<<" "<<a<<" "<<b<<" "<<res<<endl;
	return mem[x][a][b]=res;
}

ll n;
vector<ll> g[N];
bool vis[N];
ll cnt;
void dfs(ll x){
	if(vis[x])return;
	cnt++;
	vis[x]=1;
	for(auto y:g[x])dfs(y);
}
int main(){
	cin>>n;
	ll x=0,a=0,b=0;
	rep(i,n)rep(j,n){
		char c; cin>>c;
		if(c=='Y'){
			g[i].push_back(j);
			if(i<j)x--;
		}
	}
	rep(i,n)vis[i]=0;
	rep(i,n){
		if(!vis[i]){
			cnt=0;
			dfs(i);
			x+=cnt*(cnt-1)/2;
			if(cnt%2==1)a++;
			if(cnt%2==0)b++;
		}
	}
	x%=2;
	rep(i,n+1)rep(j,n+1)rep(k,2)mem[k][i][j]=-1;
	cout<<(solve(x,a,b)?"Taro":"Hanako")<<endl;
}




Measured memory_bytes: 19008
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> l(n);
	rep(snip_i, n) cin >> l.at(snip_i);
	sort(l.begin(), l.end(), greater<int>());
	int temp = 0;
	rep2(i, 1, n){
		temp += l.at(i);
	}
	if(temp > l.at(0)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <random>
#define int long long
#define double long double
#define endl "\n" 
const int INF = (int) 1e18 + 7;
const int maxn = (int) 1e6 + 6;
//const md = (int) 1e9 + 7;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using namespace std;

signed main() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    int sum = 0;
    for(int i = 0; i < k; i++) {
        sum += v[i];
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 3632
n,k = map(int,input().split())
s = list(input())
a = []
switch = 0
tmp = 0
for i in range(n):
    if switch == 0:
        if s[i] == "1":
            tmp += 1
        else:
            a.append(tmp)
            tmp = 1
            switch = 1
    else:
        if s[i] == "0":
            tmp += 1
        else:
            a.append(tmp)
            tmp = 1
            switch = 0
a.append(tmp)

tmp = 0
if k*2 <= len(a):
    tmp = k
else:
    if len(a)%2 == 0:
        tmp = int(len(a)/2)
    else:
        tmp = len(a)//2 


ans = sum(a[0:tmp*2+1])
tmpans = sum(a[0:tmp*2+1])
i = 2
while i+tmp*2<=len(a):
    tmpans -= a[i-2]+a[i-1]
    if i+tmp*2 == len(a):
        tmpans += a[i+tmp*2-1]
    else:
        tmpans += a[i+tmp*2-1]+a[i+tmp*2] 
    ans = max(ans,tmpans)
    i+=2
print(ans)

Measured memory_bytes: 5168
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()

using namespace std;

void execute()
{
	int month, day;
	cin >> month >> day;
	cout << (month <= day ? month : month - 1) << endl;
	return;
}

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

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
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; 
	}
};

bool eq( Cube c1,Cube c2){
	for( int i = 0; i < 6; i++)
		if( c1.f[i] !=  c2.f[i] ) return false;
	return true;
}

bool equal( Cube c1, Cube c2 ){
	for(int i = 0; i < 6; i++){
		for(int j = 0; j < 4; j++){
			if( eq(c1,c2))return true;
			c1.roll_z();
		}
		if( i % 2 == 0) c1.roll_y();
		else c1.roll_x();
	}
	return false;
}

int main(){
	Cube c1,c2;
	for(int i = 0; i < 6; i++)cin >> c1.f[i];
	for(int i = 0; i < 6; i++)cin >> c2.f[i];

	if(equal(c1, c2) )cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<ll> A(N+2, 0), B(N);
    rep(i, N+1) cin >> A[i];
    rep(i, N) cin >> B[i];

    ll ans = 0;
    rep(i, N) {
        ans += min(A[i], B[i]);
        B[i] = max(0LL, B[i]-A[i]);

        ans += min(A[i+1], B[i]);
        A[i+1] = max(0LL, A[i+1]-B[i]);
    }

    cout << ans << endl;
}


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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}

void solve(){


}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();
	int n;cin>>n;
	vi l(n),r(n);
	vector<pii> x(n),y(n);
	int ans=0;
	set<pii> gg;
	rep(i,n) cin>>l[i]>>r[i],ans=max(ans,r[i]-l[i]+1),x[i]=mp(l[i],r[i]),y[i]=mp(r[i],l[i]),gg.insert({l[i],r[i]});
	sort(all(l));
	sort(all(r));
	sort(all(x));
	sort(all(y));
	if(l.back()<=r[0]){
		ans+=r[0]+1-l.back();
	}
	repD(i,n-1,1){
		gg.erase(mp(y[i].snd,y[i].fst));
		int lx=gg.rbegin()->fst;
		if(y[i].fst>=l.back()&&lx<=r[0]){
			ans=max(ans,y[i].fst+r[0]+2-l.back()-lx);
		}
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 7296
#include <cstdio>
#include <cctype>
#include <vector>
using namespace std;

#define si static inline
#define gcu getchar_unlocked
si int in() {
	int c, n = 0;
	//bool minus = false;
	//if ((c = gcu()) == '-') minus = true; else ungetc(c, stdin);
	while ((c = gcu()) >= '0' && c <= '9') n = 10 * n + (c - '0');
	return n; }
	//return minus ? -n : n; }
si void scan(char *s) {while (!isspace(*s++ = gcu()));}
#define pcu putchar_unlocked
#define svo si void out
template <typename T>
svo(T n) {
	static char buf[20];
	char *p = buf;
	//if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
svo(const char *s){while(*s)pcu(*s++);}
svo(char *s){while(*s)pcu(*s++);}
svo(char c){pcu(c);}
template <typename T>
//svo(vector<T> &v){for(T &x:v)out(' '),out(x);out('\n');}
svo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
template <typename head, typename... tail>
svo(head&& h, tail&&... t){out(h);out(move(t)...);}

struct union_find {
	struct node {int p, r = 0;};
	vector<node> nodes;

	union_find(int n) {
		nodes.resize(n);
		int i = 0;
		for (node &n: nodes)
			n.p = i++;
	}
	int find(int x) {
		int &p = nodes[x].p;
		if (p == x)
			return x;
		else {
			p = find(p);
			return p;
		}
	}
	void _union(int a, int b) {
		int ar = find(a), br = find(b);
		node &an = nodes[ar], &bn = nodes[br];
		if (an.r > bn.r)
			bn.p = ar;
		else if (an.r > bn.r)
			an.p = br;
		else if (ar != br) {
			bn.p = ar;
			an.r++;
		}
	}
	void read(int n) {
		int a;
		while(n--) {
			a = in();
			_union(a, in());
		}
	}
};

int main() {
	union_find u(in());
	u.read(in());
	int q = in();
	while (q--)
		out(u.find(in()) == u.find(in()) ? "yes" : "no", '\n');
}



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

typedef long long LL;

const int N=100000;

int n,cq,qx[N+9],qy[N+9],qv[N+9];
LL m;

void into(){
  scanf("%d%lld%d",&n,&m,&cq);
  for (int i=1;i<=cq;++i){
	scanf("%d%d%d",&qx[i],&qy[i],&qv[i]);
	++qx[i];++qy[i];
  }
}

int uni[N+9],vis[N+9];

int Query_uni(int k){return k==uni[k]?k:uni[k]=Query_uni(uni[k]);}

int ans;

void Get_ans(){
  if (m<n-1) return;
  for (int i=1;i<=n;++i) uni[i]=i;
  for (int i=1;i<=cq;++i){
	if (qv[i]) continue;
	int fx=Query_uni(qx[i]),fy=Query_uni(qy[i]);
	if (fx==fy) continue;
	uni[fx]=fy;
  }
  int flag=0;
  for (int i=1;i<=cq;++i){
	if (!qv[i]) continue;
	flag=1;
	if (Query_uni(qx[i])==Query_uni(qy[i])) return;
  }
  int cnt=0;
  for (int i=1;i<=n;++i){
	int fx=Query_uni(i);
	if (!vis[fx]) ++cnt,vis[fx]=1;
  }
  if (cnt==1||cnt==2) {ans=m==n-1&&!flag;return;}
  if (m<n&&flag) return;
  LL t=n-cnt+((LL)cnt*(cnt-1)>>1);
  ans=m<=t;
}

void work(){
  Get_ans();
}

void outo(){
  puts(ans?"Yes":"No");
}

int main(){
  into();
  work();
  outo();
  return 0;
}

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

    class Program
    {
        static void Main(string[] args)
        {
            long n;
            long m;
            long[,] vs;
            long[] xyz;

            long[] imp = Console.ReadLine().Split(' ').Select(t => long.Parse(t)).ToArray();
            n = imp[0];
            m = imp[1];
            vs = new long[n, 3];
            xyz = new long[n];

            for (int i = 0; i < n; i++)
            {
                long[] ar = Console.ReadLine().Split(' ').Select(t => long.Parse(t)).ToArray();
                vs[i, 0] = ar[0];
                vs[i, 1] = ar[1];
                vs[i, 2] = ar[2];
            }

            long ans = 0;
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    switch (i)
                    {
                        case 0:
                            xyz[j] = vs[j, 0] + vs[j, 1] + vs[j, 2];
                            break;
                        case 1:
                            xyz[j] = vs[j, 0] + vs[j, 1] - vs[j, 2];
                            break;
                        case 2:
                            xyz[j] = vs[j, 0] - vs[j, 1] + vs[j, 2];
                            break;
                        case 3:
                            xyz[j] = vs[j, 0] - vs[j, 1] - vs[j, 2];
                            break;
                        case 4:
                            xyz[j] = -vs[j, 0] + vs[j, 1] + vs[j, 2];
                            break;
                        case 5:
                            xyz[j] = -vs[j, 0] + vs[j, 1] - vs[j, 2];
                            break;
                        case 6:
                            xyz[j] = -vs[j, 0] - vs[j, 1] + vs[j, 2];
                            break;
                        case 7:
                            xyz[j] = -vs[j, 0] - vs[j, 1] - vs[j, 2];
                            break;
                    }
                }
                Array.Sort(xyz);
                Array.Reverse(xyz);
                long max = 0;
                for (int k = 0; k < m; k++)
                {
                    max += xyz[k];
                }
                if (ans < max) ans = max;
            }
            Console.WriteLine(ans);
        }
    }


Measured memory_bytes: 13524
#include <cstdio>
#include <cstring>
typedef long long ll;

int n,l,f[2][5005],Ans=1;
char s[5005];
const int p=1000000007,I2=(p+1)>>1;

int main()
{
    scanf("%d%s",&n,s+1),l=strlen(s+1),f[1][0]=1;
    for(int i=1;i<=l;++i)Ans=(ll)Ans*I2%p;
    for(int i=1;i<=n;++i)
    {
        memcpy(f[0],f[1],sizeof f[0]),memset(f[1],0,sizeof f[1]);
        for(int j=0;j<=i;++j)
        {
            if(j)f[1][j]=(f[0][j-1]<<1)%p;
            if(!j)f[1][0]=(f[1][0]+f[0][0])%p;
            f[1][j]=(f[1][j]+f[0][j+1])%p;
        }
    }
    printf("%d\n",int((ll)Ans*f[1][l]%p));
    return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int ans = INF;
	FOR(i, 1, n) {
		int a = i, b = n - i;
		int cnt = 0;
		while (a > 0) {
			cnt += a % 10;
			a /= 10;
		}
		while (b > 0) {
			cnt += b % 10;
			b /= 10;
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;

}


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

using namespace std;

int main(){
	int n;
	cin>>n;
	vector<int> in1(n) , in2(n) , in3(n) , dp1(n) , dp2(n) , dp3(n);
	for(int i = 0 ; i < n ; i++) cin>>in1[i]>>in2[i]>>in3[i];
	dp1[0] = in1[0] , dp2[0] = in2[0] , dp3[0] = in3[0];
	for(int i = 1 ; i < n ; i++) dp1[i] = max(dp2[i - 1] , dp3[i - 1]) + in1[i] , dp2[i] = max(dp1[i - 1] , dp3[i - 1]) + in2[i] , dp3[i] = max(dp1[i - 1] , dp2[i - 1]) + in3[i];
	cout<<max({dp1[n - 1] , dp2[n - 1] , dp3[n - 1]})<<endl;
}

Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n, res = 0;
    cin>>n;
    if(n & 1) {
        cout<<0<<endl;
        return 0;
    }
    int mom = 10;
    while(mom <= n) {
        res += n / mom;
        mom *= 5;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
N = int(input())
List = list(map(int, input().split()))
s = 1000000000000000000000
t = 0

for i in range(100):
  for j in range(N):
    t += (List[j]-i-1)**2

  if s>t:
    s = t
    t = 0
  else:
    t = 0

print(s)


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

int fx(int N){
  int c=0;
  while(N>0){
    c += N%10;
    N =N/10;
  }
  return c;
}

int main(){
  int n;
  cin >>n;
  int ans =n;

  for (int i=2;i<=n;i++){
    int a,b;
    a =i;
    b =n-i;
    if (a+b ==n){
      a =fx(i);
      b=fx(n-i);
      ans =min(ans,a+b);
    }   
    if (ans ==1)ans =10;
  }

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

Measured memory_bytes: 256
n = int(raw_input())
t = map(int, raw_input().split())
a = map(int, raw_input().split())
mi = [1 for i in range(n)]
ma = [10**9 for i in range(n)]
for i, e in enumerate(t):
    if i == 0:
        mi[i] = e
        ma[i] = e
    else:
        if e > t[i-1]:
            mi[i] = e
            ma[i] = e
        elif e == t[i-1]:
            ma[i] = e
        else:
            print 0
            exit()

a = a[::-1]
mi = mi[::-1]
ma = ma[::-1]

for i, e in enumerate(a):
    if i == 0:
        if mi[i] <= e <= ma[i]:
            mi[i] = e
            ma[i] = e
        else:
            print 0
            exit()
    else:
        if e > a[i-1]:
            if mi[i] <= e <= ma[i]:
                mi[i] = e
                ma[i] = e
            else:
                print 0
                exit()
        elif e == a[i-1]:
            if mi[i] <= e <= ma[i]:
                ma[i] = e
        else:
            print 0
            exit()
res = 1
for i in range(n):
    res *= ma[i] - mi[i] + 1
    res = res % (10**9+7)
print res % (10**9+7)


Measured memory_bytes: 14540
//ΔARC087C
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
map<int,int> M;
map<int,int>::iterator it;
int n;
int main()
{
	int i,x,y,ans;
	scanf("%d",&n);
	for(i=1;i<=n;i=i+1){
		scanf("%d",&x);
		M[x]++;
	}
	ans=0;
	for(it=M.begin();it!=M.end();it++){
		x=(*it).first;
		y=(*it).second;
		if(y>=x)
			ans+=y-x;
		else
			ans+=y;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int IINF = 2002002002;
constexpr ll LINF = 9009009009009009009LL;

//===




int main()
{
	int N; 
	cin >> N;
	Vi B(N - 1);
	for (int i = 0; i < N - 1; ++i) {
		cin >> B[i];
	}

	Vi A(N);
	A[0] = B[0];
	A[N - 1] = B[N - 2];
	for (int i = 1; i < N - 1; ++i) {
		A[i] = min(B[i - 1], B[i]);
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		ans += A[i];
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
//CODING ME ACCHHA KARNEKA HAI TERKO TO BAS PRACTICE KARTE REH
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define aisort sort(a,a+n)
#define adsort sort(a,a+n,greater<ll>())
#define PI 2 * acos(0)

typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef set<ll> Set;

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

//MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}
    
//PRIME
    bool isPrime(ll n) { if (n <= 1)  return false; if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false; return true; } 




int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,k,i,x,y;
    cin>>n>>k;
    map<ll,ll>mp;
    for(i=1;i<=n;i++)
    {
        mp[i]=0;
    }
    while(k--)
    {
        cin>>x;
        for(i=1;i<=x;i++)
        {
            cin>>y;
            mp[y]++;
        }
    }
    ll cnt=0;
    for(auto it:mp)
    {
        if(it.second==0)
        cnt++;
    }
    cout<<cnt;
}




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

int main()
{
    int n;
    cin >> n;
    int a[23], b[23], c[23];
    int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i]--;
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
        ans += b[i];
    }
    for(int i = 0; i < n - 1; i++) cin >> c[i];
    for(int i = 0; i < n - 1; i++) if(a[i] + 1 == a[i + 1]) ans += c[a[i]];
    cout << ans << endl;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

double calc(int n, int k) {
    double ans = 0;
    foreach (i; 1..n+1) {
        if (i >= k) {
            ans += 1.0 / n;
            continue;
        }

        // 得点が K 以上になるまで表を出す
        int score = i;
        double t = 1.0 / n;
        while (score < k) {
            score *= 2;
            t *= 0.5;
        }
        ans += t;
    }
    return ans;
}

void main() {
    int n, k; scan(n, k);
    writefln("%.9f", calc(n, k));
}


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

using namespace std;

int main() {
	int N, M, l = 0, r = 100000;
	cin >> N >> M;
	int L[100000], R[100000];
	for (int i = 0; i < M; i++) {
		cin >> L[i] >> R[i];
	}
	for (int i = 0; i < M; i++) {
		if (l < L[i]) l = L[i];
		if (r > R[i]) r = R[i];
	}
	int ans = r - l + 1;
	if (ans < 0){
		cout << "0" << endl;
	}
	else {
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
const double EPS = 1e-5;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

int main(){
    int n;
    cin >> n;
    vector<int> ans(n*n,0);
    vector<int> p(n*n,0);
    vector<int> used(n+1,0);
    queue<pii> work;
    queue<pii> ok;
    rep(i,n){
        int d;
        cin >> d;
        --d;
        p[d] = i + 1;
    }
    rep(i,n*n){
        if(p[i]>1){
            work.emplace(p[i]-1,p[i]);
        }
    }
    rep(i,n*n){
        if(p[i]){
            ans[i] = p[i];
            ++used[p[i]];
            if(used[p[i]]!=p[i]){
                cout << "No" << endl;
                return 0;
            }
            if(p[i]<n){
                ok.emplace(n-p[i],p[i]);
            }
        }else{
            if(work.size()){
                ans[i] = work.front().second;
                ++used[ans[i]];
                if(--work.front().first==0){
                    work.pop();
                }
            }else if(ok.size()){
                ans[i] = ok.front().second;
                ++used[ans[i]];
                if(--ok.front().first==0){
                    ok.pop();
                }
            }else{
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    rep(i,n*n){
        if(i)cout<<" ";
        cout << ans[i];
    }
	return 0;
}


Measured memory_bytes: 3072
N = int(input())
min = N
max_i = 0
max_j = 0
for i in range(1,1000000):
    if N % i == 0:
        j = N // i
        if abs(i - j) < min:
            min = abs(i - j)
            max_i = i
            max_j = j
for i in range(1000000,N // 1000000 + 1):
    if N % i == 0:
        j = N // i
        if abs(i - j) < min:
            min = abs(i - j)
            max_i = i
            max_j = j

print(max_i + max_j - 2)

Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            StringBuilder sb = new StringBuilder();
            sb.append(in.next());
            out.println(sb.toString().equals(sb.reverse().toString()) ? "Yes" : "No");
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

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

        public String next() {
            StringBuilder sb = new StringBuilder();

            int b = readByte();
            while (!isPrintableChar(b))
                b = readByte();

            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }

            return sb.toString();
        }

    }
}



Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
ll NUM = pow(10,9) + 7;

int main(){
	int h,w;
	cin >> h >> w;
	vector<vector<ll>> dp(h,vector<ll>(w));
	rep(i,h){
		rep(j,w){
			char c;
			cin >> c;
			if(i == 0){
				if(j == 0){
					dp[0][0] = 1;
				}else{
					if(c == '.'){
						dp[0][j] = dp[0][j-1];
					}else{
						dp[0][j] = 0;
					}
				}
			}else{
				if(j == 0){
					if(c == '.'){
						dp[i][j] = dp[i-1][0];
					}else{
						dp[i][j] = 0;
					}
				}else{
					if(c == '.'){
						dp[i][j] = (dp[i-1][j] + dp[i][j-1])%NUM;
					}else{
						dp[i][j] = 0;
					}
				}
			}
		}
	}
	cout << dp[h-1][w-1] << endl;
	return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int n; cin >> n;
    string digit = to_string(n);
    rep(i,3){
        if(digit[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3696
#include<iostream>

using namespace std;
  
int main(){

  int W,H,N;
  int fx,fy,tx,ty;
  int cnt=0;

  cin>>W>>H>>N;

  cin>>fx>>fy;
  for(int i=0;i<N-1;i++){
    cin>>tx>>ty;
    while(fx!=tx||fy!=ty){
      if(fx<tx&&fy<ty){
	fx++,fy++;
      }
      else if(fx>tx&&fy>ty){
	fx--,fy--;
      }
      else if(fx>tx){
	fx--;
      }
      else if(fx<tx){
	fx++;
      }
      else if(fy>ty){
	fy--;
      }
      else if(fy<ty){
	fy++;
      }
      else break;
      cnt++;
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>

using namespace std;
typedef long long llong;
const int MOD=1000000007;

int main(int argc, char**argv){
    int r, g, b;
    cin >> r >> g >> b;
    int x = 100*r + 10*g + b;
    if (x % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int main()
{
    map<char, int> a;
    string s;
    cin >> s;
    rep(i, 0, 4) a[s[i]]++;
    bool ans = true;
    if (a.size() != 2)
        ans = false;
    if (a[s[0]] != 2)
        ans = false;
    print(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;
ll gcd( ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
ll lcm( ll a, ll b ){
    return a * b / gcd(a,b);
}
ll lcm_n( vector<ll> numbers ) {
	ll l;
	l = numbers.at(0);
	for (ll i = 1; i < numbers.size(); i++) {
		l = lcm(l, numbers.at(i));
	}
	return l;
}
int main (void) {
    ll N, M, ans;
    scanf("%lld %lld", &N, &M);
    vector<ll> a(N),b(N);
    REP(ll,i,0,N){
        scanf("%lld", &a.at(i));
        b.at(i) = a.at(i) / 2;
    }
    ll lcm_b = lcm_n(b);
    ll lcm_a = lcm_n(a);
    REP(int,i,0,N){
      if ( lcm_b % a.at(i) == 0 ){
        printf("0\n");
        return 0;
      }
    }
    ans = M/lcm_b - M/lcm_a;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int D, G, P[10], C[10];
int dp[11][401010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> D >> G;
    rep(i, 0, D) cin >> P[i] >> C[i];

    G /= 100;
    rep(i, 0, D) C[i] /= 100;

    rep(i, 0, D + 1) rep(point, 0, 201010) dp[i][point] = inf;
    dp[0][0] = 0;

    rep(i, 0, D) rep(point, 0, 201010) {
        rep(j, 0, P[i]) chmin(dp[i + 1][point + (i + 1)*j], dp[i][point] + j);
        chmin(dp[i + 1][point + (i + 1)*P[i] + C[i]], dp[i][point] + P[i]);
    }

    int ans = inf;
    rep(point, G, 201010) chmin(ans, dp[D][point]);
    cout << ans << endl;
}

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

void solve(long long N, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C){
    long long sum = 0;
    REP(i, N) {
        if (A[i] == N - 1) sum += B[A[i]];
        else if (A[i]+1 == A[i+1]) sum += B[A[i]] + C[A[i]];
        else sum += B[A[i]];
    }
    cout << sum << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    cin >> N;
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++) {
        long long tmp;
        cin >> tmp;
        A[i] = tmp - 1;
    }
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++)
        cin >> B[i];
    std::vector<long long> C(N-1);
    for(int i = 0 ; i < N-1 ; i++)
        cin >> C[i];
    solve(N, std::move(A), std::move(B), std::move(C));
    return 0;
}


Measured memory_bytes: 256
import sys 
input = sys.stdin.readline

h, w = map(int, input().split())
s = [list(input().replace('\n', '')) for _ in range(h)]

import numpy as np


up = np.zeros((h, w))
down = np.zeros((h, w))
right = np.zeros((h, w))
left = np.zeros((h, w))

s = (np.array(s)==".").astype(np.int)

for i in range(h):
    down[-i-1] = (down[-i] + 1)*s[-i-1]
    up[i] = (up[i-1] + 1)*s[i]
    

for i in range(w):
    left[:,-i-1] = (left[:,-i] + 1)*s[:,-i-1]
    right[:,i] = (right[:,i-1] + 1)*s[:,i]
    
ans = np.max(up+down+left+right-3)
print(int(ans))

Measured memory_bytes: 266504
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int main()
 {
   string str;
   while(cin>>str)
   {
     int sum=0;
     if(str=="0") break;
     for(int i=0;i<str.length();i++) sum+=(str[i]-'0');
     cout<<sum<<endl;               
   }
   //while(1);
   return 0;
 }

 

Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

 ll h,n;
 cin>>h>>n;
 ll a[n];
 ll sum=0;
 for(ll i=0;i<n;i++)
 {
    cin>>a[i];
    sum+=a[i];
 }
 if(sum>=h)
    cout<<"Yes"<<endl;
 else
    cout<<"No"<<endl;

}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
//max_element


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

	char ch[11000] = {};
	for (int i = 0; i < S.length(); i++)
	{
		int a = S[i] - 'A';
		a = (a + N) % 26;
		ch[i] = a + 'A';
	}

	cout << ch << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    ll l,r;cin >> l >> r;
    vector<ll> m(2019,-INF);
    int cnt=0;
    for(int i=l;i<=r;i++){
        if(cnt>=2019) break;
        m[i%2019] = i;
        cnt++;
    }
    ll ans = INF;
    for(int i=0;i<m.size();i++){
        for(int j=i+1;j<m.size();j++){
            if(m[i]==-INF || m[j]==-INF) continue;
            ll t = (m[i]%2019 * m[j]%2019)%2019;
            //cout << t << endl;
            if(t<0) ans += 2019;
            ans = min(ans,t);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <map>
#include <fstream>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define INF 1e9 
typedef long long ll;
typedef long double ld;
int main(){
    string s;
    cin>>s;
    int size=s.size();
    char a=s[size-1];
    if(a=='s'){
        s+="es";
    }else{
        s+="s";
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3624
N, X = map(int,input().split())
lm = list(map(int,input().split()))
ln = [0]
for x in range(1,len(lm)+1):
    ln.append(ln[x-1]+lm[x-1])
s = 0
for x in range(len(ln)):
    if ln[x] <= X:
        s += 1
    else:
        break
print('{}'.format(s))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6;
const ll LINF = 1e18;
using namespace std;

#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (int i = (a); i < (b); i++)
#define rrrep(i, a, b) for (int i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl

ll n, cnt, ans, a, b, c, d, tmp, tmpp, m, h, w, x, y, sum, pos, k;
ld doua;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
bool fl;
struct edge
{
    int to, cost;
};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin >> s;
    rep(i, Size(s) / 2)
    {
        if (s[i] == 'g')
            ans++;
    }
    rrep(i, Size(s) / 2, Size(s))
    {
        if (s[i] == 'p')
            ans--;
    }
    Cout(max(ans, 0LL));
    return 0;
}


Measured memory_bytes: 512
# UnionFindで参考にしたページ
# http://www.geocities.jp/m_hiroi/light/pyalgo61.html


# 集合の代表を求める
def find(x):
    if link[x] < 0:
        return x
    else:
        # 経路の圧縮
        link[x] = find(link[x])
        return link[x]


# 併合
def union(x, y):
    s1 = find(x)
    s2 = find(y)
    if s1 != s2:
        if link[s1] >= link[s2]:
            # 小さいほうが個数が多い
            link[s2] += link[s1]
            link[s1] = s2
        else:
            link[s1] += link[s2]
            link[s2] = s1
        return True
    return False


N, M = map(int, input().split())
p = list(map(int, input().split()))
link = [-1 for _ in range(N + 1)]

for _ in range(M):
    x, y = map(int, input().split())
    union(x, y)

cnt = 0
for i in range(1, N + 1):
    if find(i) == find(p[i - 1]):
        cnt += 1
print(cnt)


Measured memory_bytes: 14324
n=int(input())
s=list(input())
A_to_Z=list("abcdefghijklmnopqrstuvwxyz")
p=10**9 +7
number=[]
ans=1
for i in A_to_Z:
  number.append(s.count(i)%p)
for i in number:
  ans= (ans*(i+1))%p
  ans= ans%p
print((ans-1)%p)

Measured memory_bytes: 3956
#include <stdio.h>
#define N 10000

int main( void ) {
  int i, j;
  int n;
  
  int map[ N + 1 ];

  map[ 0 ] = map[ 1 ] = 0;
  for( i = 2; i <= N; i++ )
    map[ i ] = 1;
  for( i = 2; i < N; i++ )
    for( j = i * 2; j < N; j += i )
      map[ j ] = 0;

  while( scanf( "%d", &n ) != EOF ) {
    int count = 0;

    for( i = 1; i <= n; i++ )
      if( map[ i ] && map[ n - i + 1 ] )
        count++;

    printf( "%d\n", count );
  }

  return( 0 );
}

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

int main(){
    int N, help=0;
    long long monster=0;
    cin >> N;
    int A[N+1], B[N+1];
    for(int i=0; i<N+1; i++) cin >> A[i];
    for(int i=0; i<N; i++) cin >> B[i];
    B[N] = 0;
    for(int i=0; i<N+1; i++){
        if(A[i] <= help + B[i]){
            monster += A[i];
            if(help <= A[i]){
                help = B[i] - A[i] + help;
            }else{
                help = B[i];
            }
        }else{
            monster += help + B[i];
            help = 0;
        }
    }
    cout << monster << endl;
}

Measured memory_bytes: 1024
toFloat :: Int -> Double
toFloat = fromRational . toRational

solve :: Double -> Double -> Double -> Double
solve i n k
  | i > n = 0
  | i >= k = n - i + 1
  | otherwise = (0.5 ^ (fromIntegral (ceiling (logBase 2 (k/i))))) + solve (i + 1) n k
 

main = do
    [n,k] <- map (toFloat.read) . words <$> getLine
    print $ (solve 1.0 n k) / n


Measured memory_bytes: 5112