akhauriyash/Code-Regression huggingface dataset:
use proconio::{fastout, input};

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[fastout]
fn main() {
    input! {
        v: [usize; 5],
        k: usize,
    }

    let mut ans = "Yay!";
    if v.iter().max().unwrap() - v.iter().min().unwrap() > k {
        ans = ":(";
    }
    println!("{}", ans);
}


Measured memory_bytes: 2176
S=input()
ACGT=['A','C','G','T']
ans=[0]
k=0
while k<len(S):
    num=0
    if S[k] in ACGT:
        num=1
        for i in range(1,len(S)-k):
            if S[k+i] in ACGT:
                num+=1
            else:
                break
        ans.append(num)
    else:
        num=1
    k+=num

print(max(ans))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 110;
int a[maxn];
int main() {
	int a,b,c;
	while (scanf("%d%d%d", &a,&b,&c) != EOF) {
		if ((c > a&&c < b) || (c<a&&c>b)) {
			cout << "Yes" << endl;
		}
		else
			cout << "No" << endl;
	}

	//system("pause");
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long;

char beating(char c) {
  if (c == 'r')
    return 'p';
  else if (c == 's')
    return 'r';
  else
    return 's';
}

int main() {
  int n, k;
  int r, s, p;
  string t;
  cin >> n >> k;
  cin >> r >> s >> p;
  cin >> t;
  ll ans = 0;
  string taka(n, '0');
  for (int i = 0; i < k; i++) {
    taka[i] = beating(t[i]);
  }
  for (int i = k; i < n; i++) {
    char will = beating(t[i]);
    if (will == taka[i - k]) {
      taka[i] = '-';
    } else {
      taka[i] = will;
    }
  }
  for (int i = 0; i < n; i++) {
    if (taka[i] == 'r')
      ans += r;
    else if (taka[i] == 's')
      ans += s;
    else if (taka[i] == 'p')
      ans += p;
  }
  cout << ans << endl;
}


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

int main() 
{
	int d,s,t;
	double a;
	cin>>d>>s>>t;
	a=d/s;
	if(t*s>=d)
	{
		cout<<"Yes";
		
	}
	else
	{
		cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 3620
import collections

N = int(input())
A =[]
for i in range(N):
    A.append(input())
    
ans =[]
c = collections.Counter(A)
m = c.most_common()
ma = m[0][1]

for i in range(len(m)):
    if m[i][1] == ma:
        ans.append(m[i][0])
ans.sort()

for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 47668
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
MOD = 10**9 + 7

dp = [[0] * (1 << n) for i in range(n+1)]
dp[0][0] = 1

for i in range(n):
    bit_state = (1 << i) - 1
    if bit_state == 0:
        for j in range(n):
            if not(bit_state & (1 << j)) and a[i][j] == 1:
                dp[i+1][bit_state|(1 << j)] += dp[i][bit_state]
                dp[i+1][bit_state|(1 << j)] %= MOD
        continue
    while bit_state < (1 << n):
        for j in range(n):
            if not(bit_state & (1 << j)) and a[i][j] == 1:
                dp[i+1][bit_state|(1 << j)] += dp[i][bit_state]
                dp[i+1][bit_state|(1 << j)] %= MOD
        x = bit_state & -bit_state
        y = bit_state + x
        bit_state = ((bit_state & ~y) // x >> 1) | y
print(dp[n][(1 << n) - 1])

Measured memory_bytes: 395032
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// const ll INF = 1e18;
//const ll MOD = 1e9+7;
//const double pi = 3.14159265358979;
using vl = vector<ll>;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()

ll N,M,Q;

vector<vl> v;
vl history;

void dfs(ll dep, ll x) {
    if (dep == N) {
        v.push_back(history);
    } else {
        for(ll i=x; i<=M; i++) {
            history[dep] = i;
            dfs(dep+1, i);
        }
    }
}

int Main() {
    cin >> N >> M >> Q;
    vl a(Q);
    vl b(Q);
    vl c(Q);
    vl d(Q);

    rep(i,Q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    
    history.resize(N);
    dfs(0,1);

    ll ans = 0;
    for (auto &e: v) {
        ll sum = 0;
        rep(i, Q) {
            if (e[b[i]-1]- e[a[i]-1] == c[i]) {
                sum += d[i];
            }
        }
        ans = max(ans, sum);
    }
    
    cout << ans << endl;
    
    return 0;
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std ;
int main ()
{
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if ((x+r<=W&&x+r>=0)&&(y+r<=H&&y+r>=0)&&x>0&&y>0)
        cout<<"Yes"<<endl ;
    else
        cout<<"No" <<endl ;
 return 0 ;
}



Measured memory_bytes: 3104
/*
Author: Hrujul Thumar
*/
#include <bits/stdc++.h>
#define int         long long
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define whilet()    int t; scanf("%d",&t); while(t--)
#define vp          vector<pair<int,int>,int>
#define pb          push_back
#define mii         map<int,int>
#define pii         pair<int,int>
#define msi         map<string,int>
#define psi         pair<string,int>
#define mpi         map<pair<int,int>,int>
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define ef          else if
#define MOD         1000000007
#define endl        '\n'
#define fastio       ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define pi          3.141592653589793238
const long long MAX_SIZE = 1000000000;
using namespace std;
int gcd(int a, int b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int power(int x,  int y, int p){
    int res = 1;      // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
            y = y>>1; // y = y/2
            x = (x*x) % p;
    }
    return res;
}

int mod_inv(int a,int m){
    a=a%m;
    return power(a,m-2,m)%MOD;
}

int lcm(int a, int b){
    return (a*b)/gcd(a, b);
}

bool mod(double a,double b) {
    return a/b - floor(a/b);}

int logb(int base, int x) {
    return (log(x) / log(base));
}
char ToLower(char c)
{
    if ((c >= 'A') && (c <= 'Z')) return (char)((int)c - 'A' + 'a');
    else return c;
}

int Vowel(char c)
{
    c = ToLower(c);
    return (c == 'a') || (c == 'o') || (c == 'i') || (c == 'y') || (c == 'u') || (c == 'e');
}
bool cmp(pair<int,int> &a,pair<int,int> &b)
{
    if(a.first!=b.first)
    return a.first<b.first;
    return a.second>b.second;
}
int countSetBits(int x)
{
    if(x==0)return 0;
    else return 1+countSetBits(x&(x-1));
}
int fact(int n);

int nCr(int n, int r)
{
    return fact(n) / (fact(r) * fact(n - r));
}

// Returns factorial of n
int fact(int n)
{
    int res = 1;
    for (int i = 2; i <= n; i++)
        res = res * i;
    return res;
}
int n;
bool in_range(int x,int y)
{
    if(x>=0 && x<=n-1 && y>=0 && y<=n-1)return true;

    return false;
}
bool palindrom(string s)
{
    int len=s.length();
    bool okay=true;
    for(int i=0;i<=len/2;i++)
    {
        if(s[i]!=s[len-i-1]){okay=false; break;}
    }
    return okay;
}
signed main()
{
    fastio;
    int t,d;
    cin>>t>>d;
    int ans=0;
    map<pair<int,int>,int> m;
    while(t--)
    {
        int x,y;

        cin>>x>>y;

        if((x*x+y*y)<=d*d)ans++;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c;
    cin >> a >> b >> c;
    Yes(a <= c && c <= b);
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

//別解：最短経路か判定する部分
//エッジがいずれかの頂点間の最短経路であるかいなかの調べ方を
//各エッジについて、全ての出発点と全ての到着点を調べ、その最短経路に使われるか調べる方法

class Edge{
	int from, to, cost;

	public Edge(int from, int to, int cost) {
		super();
		this.from = from;
		this.to = to;
		this.cost = cost;
	}
	
}

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), m = fs.nextInt();
		int g[][] = new int[n][n];
		int inf = Integer.MAX_VALUE/2;
		for(int i=0;i<n;i++)for(int j=0;j<n;j++) {
			if(i==j)g[i][j]=0;
			else g[i][j] = inf;
		}
		
		Edge[] es = new Edge[m];
		
		for(int i=0;i<m;i++) {
			int a = fs.nextInt()-1, b = fs.nextInt()-1, c = fs.nextInt();
			g[a][b] = g[b][a] = c;
			es[i] = new Edge(a,b,c);
		}
			
		for(int k=0;k<n;k++) {
			for(int i=0;i<n;i++) {
				for(int j=0;j<n;j++) {
					g[i][j] = Math.min(g[i][j], g[i][k]+g[k][j]);
				}
			}
		}
		
		int cnt = 0;
		for(Edge e : es) {
			int from = e.from, to = e.to, cost = e.cost;
			boolean ok = false;
			for(int i=0;i<n;i++) {
				for(int j=0;j<n;j++) {
					if(g[i][j]==g[i][from] + cost + g[to][j])ok = true;
					else if(g[i][j]==g[i][to] + cost + g[from][j])ok=true;
				}
			}
			if(!ok)cnt++;
		}
		System.out.println(cnt);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 23252
#include<iostream>
using namespace std;
#include<algorithm>
#define REP(i,a) for(int  i=0;i<a;i++)
int A[100000];
int main(){


	int a,b=0,c,n,j,k,x,y,p,N,M;	
	cin>>n;
	REP(i,n){
	cin>>x>>y>>b>>p;
	c=x*b+y*p;
	if(b>4&&p>1){
	c=c*0.8;
	}
	else {
		if(b<5) b=5;
		if(p<2) p=2;
		M=(x*b+y*p)*0.8;
		c=min(c,M);
	}
	cout<<c<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int b=0,c=1,d,e,f,g;
  string a;
  cin>>a;
  for(int i=0;i<a.size();i++){
    if(i==0) b+=a[i]-'0'-1;
    else b+=9;
    if(i!=0) if(a[i]!='9') c=0;
  }
  if(c) b++;
  cout<<b<<"\n";
  }


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

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

typedef long long ll;
typedef pair<int, int> point;

const int mod = 1e9 + 7;
int add(int x, int y) {
	x += y;
	if(x >= mod) return x - mod;
	return x;
}
int sub(int x, int y) {
	x -= y;
	if(x < 0) return x + mod;
	return x;
}
int mul(int x, int y) {
	return (ll) x * y % mod;
}

int n;

int sol = 0;

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

   int ls;
   int active = 0;

   cin >> n;

   REP(i, n) {
      int x; cin >> x;
      if(active == 0) {
         active = 1;
         sol ++;
      }
      else if(active == 1) {
         if(x > ls) {
            active = 2;
         }
         else if(x < ls) {
            active = 3;
         }
      }
      else if(active == 2) {
         if(x < ls) {
            active = 1;
            sol ++;
         }
      }
      else {
         if(x > ls) {
            active = 1;
            sol ++;
         }
      }
      ls = x;
   }

   cout << sol;
}


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

// const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

// 二項係数nCr
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, K;
  cin >> N >> K;
  COMinit();
  for (int i = 1; i <= K; i++)
  {
    ll ans = COM(N - K + 1, i) * COM(K - 1, i - 1) % MOD;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 12160
#include<bits/stdc++.h>
#define ll long long
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define MOD1 1000000007
#define MOD2 998244353
#define IOS std::ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define print(a) for(auto x : a)    cout<<x<<" "; cout<<"\n";
using namespace std;

int main(){

    IOS;
	int s, w;
  cin >> s >> w;
  if(w >= s)
    	cout<<"unsafe\n";
  else
    	cout<<"safe\n";
  
   
    return 0;
}

Measured memory_bytes: 3644
n = int(raw_input())

R = [0 for i in range(n)]

ans = 1 - 10**9
for i in range(n):
    R[i] = int(raw_input())
    if i == 0:
        min_R = R[0]
        continue
    if min_R < R[i]:
        if ans < R[i]-min_R:
            ans = R[i] - min_R
    elif min_R > R[i]:
        if ans < R[i]-min_R:
            ans = R[i] - min_R
        min_R = R[i]
    else:
        if ans < 0:
            ans = 0
        
print ans

Measured memory_bytes: 18888
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
#define INF 2147483647
#define MAXN 200010
using namespace std;
vector<int> map[MAXN];
int dis[MAXN];
int n,m,a,b;
void dijkstra(int u){
	for(int i = 0;i <= n;i++)dis[i] = INF;
	dis[u] = 0;
	priority_queue<int> q;
	q.push(u);
	while(!q.empty()){
		int now = q.top();
		q.pop();
		for(int i = 0;i < map[now].size();i++){
			int to = map[now][i];
			if(dis[to] > dis[now] + 1){
				dis[to] = dis[now] + 1;
				q.push(to);
			}
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i = 0;i < m;i++){
		scanf("%d%d",&a,&b);
		map[a].push_back(b);
		map[b].push_back(a);
	}
	dijkstra(1);
	for(int i = 2;i <= n ;i++)if(dis[i] == INF)return !printf("No");
	printf("Yes\n");
	for(int i = 2;i <= n;i++){
		for(int j = 0;j < map[i].size();j++){
			if(dis[i] == dis[map[i][j]] + 1){
				printf("%d\n",map[i][j]);
				break;
			}
		}
	}
}

Measured memory_bytes: 13852
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+7 , mz = 1e9+7;
int c[N],d[N];

int main(){
    int n,k;
    cin>>n>>k;
    if( k == 0 )    cout<<1LL*n*n<<endl;
    else{
        long long ans = 0;
        for(int i = k+1 ; i <= n ;i++){
            ans += (n/i)*(i-k);
            if( n%i>=k )    ans+=n%i-k+1;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;



int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	vector<int> sa(n);
	sa = a;
	sort(sa.begin(), sa.end());
	reverse(sa.begin(), sa.end());
	rep(i, n) {
		if (a[i] == sa[0])
		{
			cout << sa[1]<<endl;
			
		}
		else
			cout << sa[0]<<endl;
	}

}


Measured memory_bytes: 4828
N, Ma, Mb = map(int, input().split())
INF = 10**9+7
dp = [[[INF]*(401) for _ in range(401)] for __ in range(N+1)]
dp[0][0][0] = 0

for n in range(N):
    x, y, c = map(int, input().split())
    for a in range(401):
        for b in range(401):
            if dp[n][a][b] == INF:
                continue
            dp[n+1][a][b] = min(dp[n+1][a][b], dp[n][a][b])
            if a+x <= 400 and b+y <= 400:
                dp[n+1][a+x][b+y] = min(dp[n+1][a+x][b+y], dp[n][a][b]+c)

ans = INF
a, b = 0, 0
while True:
    a += Ma
    b += Mb
    if a > 400 or b > 400:
        break
    ans = min(ans, dp[N][a][b])
if ans == INF:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 61168
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> cost(m);
  vector<int> box(m,0);
  for(int i=0; i<m; ++i){
    int mi;
    cin >> cost[i] >> mi;
    for(int j=0; j<mi; ++j){
      int x;
      cin >> x;
      --x;
      box[i] += (1<<x);
    }
  }
  vector<int> dp((1<<n),INF);
  dp[0] = 0;
  for(int i=0; i<(1<<n); ++i) for(int j=0; j<m; ++j){
    dp[i|box[j]] = min(dp[i|box[j]], dp[i]+cost[j]);
  }
  if(dp[(1<<n)-1] == INF) cout << -1 << endl;
  else cout << dp[(1<<n)-1] << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >>n;
int num = n/1.08; 
int flag = 0;
for(int i = num -10;i<num + 10;i++){
int price = i*1.08;

if(price==n){
cout << i <<endl;
flag++;
break;
}
}  
if(flag==0){
cout <<":("<<endl;

}  
}

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

using namespace std;

int main() {
    int a, b, c;
    cin >> a >>b>>c;
    vector<int>res;
    res.push_back(a);
    res.push_back(b);
    res.push_back(c);
    for (int j=0; j<res.size()-1; j++) {
      for (int i=0; i<res.size()-1-j; i++) {
            if(res[i+1] < res[i]) {
                int tmp = res[i+1];
                res[i+1] = res[i];
                res[i] = tmp;
          }
    }
   }
   cout << res[0] << " " <<res[1] << " " << res[2] <<endl;

    return 0;
}



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

int main() {
  int N;
  cin >> N;
  
  int x;
  
for (int i = 0; i < N; i++) {
  int l, n = 0;
  cin >> l >> n;
  x += n - l + 1;
}
  cout << x << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<algorithm>
#define lson l, mid, i<<1
#define rson mid+1, r, i<<1|1
#define PII pair<int, int>
using namespace std;
typedef long long LL;
//const int MOD = 1e9+7;
const auto INF  = 0x3f3f3f3f;
const int N = 1e5+5;

int a[N];

int main() {
    int n;
    scanf("%d", &n);
    int minn = INF, maxx = 0;
    int sum = 0, t = 0;
    for(int i=1; i<=n; i++) {
        scanf("%d", &a[i]);
        minn = min(minn, a[i]);
        maxx = max(maxx, a[i]);
        if(a[i] == n-1) {
            t++;
        }
        if(a[i] == 1)
            sum++;
    }
    if(maxx - minn >= 2 || (sum > 1 && sum != n) || (t && (t != 2 && t != n))) {
        printf("No\n");
        return 0;
    }
    if(maxx == minn && (maxx != 1 && maxx != n-1 && (n/maxx) < 2)) {
        printf("No\n");
        return 0;
    }
    sum = 0;
    for(int i=1; i<=n; i++) {
        if(a[i] == minn)
            sum++;
    }
    if(maxx != minn && (n-sum)/(maxx-sum) < 2) {
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
}




Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#define fi first
#define se second
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<unsigned int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int main() {
	unsigned int n;
	unsigned int p[65005];
	while(true){
		cin>>n;
		if(n==0) break;
		vi j(n);
		unsigned int sum=0;
		for(int i=0;i<n;i++){
			cin>>p[i];
			sum+=p[i];
		}
		unsigned int ans=sum*n;
		for(int i=0;i<n-1;i++){
			cin>>j[i];
		}
		sort(j.begin(),j.end());
		reverse(j.begin(),j.end());
		vi l(n);
		l[0]=sum;
		for(int i=1;i<n;i++){
			l[i]=l[i-1]+j[i-1];
		}
		
		for(int i=0;i<n;i++){
			unsigned int x=n-i;
			unsigned int y=l[i];
			ans=max(ans,x*y);
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3644
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
#include <omp.h>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}



void solve(long long A, long long B){
    cout << max({A+A-1,B+A,B + B - 1}) << endl;
    return;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
int main(){
	int a;
  cin >> a;
  int b = a+a*a+a*a*a;
  cout << b << endl;
}


Measured memory_bytes: 3468
import collections

S1 = collections.deque()
S2 = collections.deque()
S3 = collections.deque()

for i, j in enumerate(input()):
    if j == '\\':
        S1.append(i)
    elif j == '/':
        if S1:
            left_edge = S1.pop()
            new_puddle = i - left_edge
            while True:
                if S2:
                    if S2[-1] > left_edge:
                        S2.pop()
                        new_puddle += S3.pop()
                    else:
                        break
                else:
                    break
            S2.append(left_edge)
            S3.append(new_puddle)
        else:
            pass


print(sum(S3))

print(len(S3), *S3)

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

int main() {
    int a,b,t;
    cin >> a >> b >> t;
    int count = 0;
    for(int i =1;i<=t;i++){
        if(i*a <= t){
            count += b;
        }
    }
    cout << count << endl;
    return 0;
}

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

typedef struct pp {
	char name[100];
	int t;
} P;

P Q[LEN];	//each ????´? has name[100]+t
int head,tail,n;

void enqueue(P x) {
	Q[tail] = x;	//????°????????¨?
	tail = (tail + 1)  % LEN;	//tail0->1,1->2,,,100004->0
}
P dequeue() {	//???????????????return 
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int min(int a, int b) {
	{return a<b ? a : b;}
}

int main() {
	int n,q;
	P haka;
  	scanf("%d %d", &n, &q);
	for (int i=1;i<n+1;i++) {
	scanf("%s %d", Q[i].name, &Q[i].t);
	}
	int time = 0;
	head = 1;
	tail = n+1;
	while (head != tail) {
		haka = dequeue();
		if (haka.t <= q) {
		time += haka.t;
		haka.t = 0;
		printf("%s %d\n", haka.name, time);
		}
		else { //???????????????
		time += q;
		haka.t -= q;
		enqueue(haka);
		}
	}
	return 0;
}
				





	

Measured memory_bytes: 12724
function Main(input) {
  var inputs = input.split(' ');
  var K = Number(inputs[0]);
  var S = Number(inputs[1]);
  var count = 0;
  for(var X = 0; X <= K; X++) {
    for(var Y = 0; Y <= K; Y++) {
      var Z = (S - X - Y);
      if(0 <= Z && Z <= K) {
        count++;
      }
    }
  }
  console.log(count);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <cstdio>

const int MAXN = 1e5 + 5;
int n, a[MAXN], cnt;
bool bad[MAXN];

int main() {
    int i;
    scanf("%d", &n);
    for (i = 1; i <= n; ++i) {
        scanf("%d", a + i);
        if (a[i] == i)
            bad[i] = true;
    }
    for (i = 1; i <= n; ++i) {
        if (bad[i]) {
            if (bad[i + 1])
                bad[i + 1] = false, ++cnt;
            else if (i != a[i - 1])
                    ++cnt;
            else {
                ++cnt;
            }

        }
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 640
H, W = map(int, input().split())
ch, cw =  map(int, input().split())
gh, gw =  map(int, input().split())

f = [[s=="." for s in input()] for h in range(H)]
ans = [[-1 for w in range(W)]for h in range(H)]

nextQ = [(ch-1)*1000 + cw-1]
ans[ch-1][cw-1] = 0
while len(nextQ)>0:
  Q = list(nextQ)
  nextQ = set()
  visited = set()
  while len(Q):
    nh = Q.pop(0)
    nw = nh%1000
    nh = nh//1000
    for dh in range(0-min(nh,2), 3):
      if nh+dh>=H:
        break
      for dw in range(0-min(nw,2), 3):
        if nw + dw>=W:
          break
        if dh==0 and dw==0:
          continue
        if dh*dw==0 and (abs(dh)==1 or abs(dw)==1):
          if ans[nh+dh][nw+dw]==-1:
            if f[nh+dh][nw+dw]:
              Q.append((nh+dh)*1000 + nw+dw)
              visited.add((nh+dh)*1000 + nw+dw)
              ans[nh+dh][nw+dw]=ans[nh][nw]
            else:
              ans[nh+dh][nw+dw]=-2
          elif ans[nh+dh][nw+dw]>ans[nh][nw]:
            Q.append((nh+dh)*1000 + nw+dw)
            visited.add((nh+dh)*1000 + nw+dw)
            ans[nh+dh][nw+dw]=ans[nh][nw]
        else:
          if ans[nh+dh][nw+dw]==-1:
            if f[nh+dh][nw+dw]:
              nextQ.add((nh+dh)*1000 + nw+dw)
              ans[nh+dh][nw+dw]=ans[nh][nw]+1
            else:
              ans[nh+dh][nw+dw]=-2
          elif ans[nh+dh][nw+dw]>ans[nh][nw]:
            nextQ.add((nh+dh)*1000 + nw+dw)
            ans[nh+dh][nw+dw]=ans[nh][nw]+1
  nextQ -= visited
print(ans[gh-1][gw-1])
      


Measured memory_bytes: 100268
import java.util.Scanner;

public class Main {
    private final static int B = 10;
    int h, w;
    int[][] graph = new int[B][B];
    int[][] as;
    public static void main(String[] args) {
        Main m = new Main();
        m.read();
        m.solve();
    }

    private void read() {
        Scanner sc = new Scanner(System.in);
        h = sc.nextInt();
        w = sc.nextInt();
        as = new int[h][w];
        for (int i = 0; i < B; i++) {
            for (int j = 0; j < B; j++) {
                graph[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                as[i][j] = sc.nextInt();
            }
        }
    }

    private void solve() {
        dp();
        long ret = 0L;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (as[i][j] == -1 || as[i][j] == 1)
                    continue;
                ret += graph[as[i][j]][1];
            }
        }
        System.out.println(ret);
    }

    private void dp() {
        for (int k = 0; k < B; k++) {
            for (int i = 0; i < B; i++) {
                for (int j = 0; j < B; j++) {
                    graph[i][j] = Math.min(graph[i][j],
                            graph[i][k] + graph[k][j]);
                }
            }
        }
    }
}


Measured memory_bytes: 47224
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<tuple<string,int,int>> a;
    
    for(int i = 1; i <= n;i++){
          string s;
          int p;
          cin >> s >> p;
          p *= -1;
          a.push_back(tie(s,p,i));
    }
    sort(a.begin(),a.end());
    for(int i = 0;i < n;i++){
          cout << get<2>(a[i]) << endl;
    }
}


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

#define mo 1000000007

using namespace std;

int fac[900030],inv[900030],Pow3[900030];

int power(int x,int m)
{
	int nowans=1;
	while(m)
	{
		if(m&1)nowans=1ll*nowans*x%mo;
		x=1ll*x*x%mo;
		m>>=1;
	}
	return nowans;
}

inline int C(int n,int m)
{
	if(n<m)return 0;
	return (int)(1ll*fac[n]*inv[m]%mo*inv[n-m]%mo);
}

int main()
{
	int n,m,k,N;
	scanf("%d%d%d",&n,&m,&k);
	N=n+m+k;
	Pow3[0]=1;
	for(int i=1;i<=N;i++)
		Pow3[i]=3ll*Pow3[i-1]%mo;
	fac[0]=1;
	for(int i=1;i<=N;i++)
		fac[i]=1ll*fac[i-1]*i%mo;
	inv[N]=power(fac[N],mo-2);
	for(int i=N;i;i--)
		inv[i-1]=1ll*inv[i]*i%mo;
	int ans=0,nowans=1;
	for(int l=n+1;l<=N+1;l++)
	{
		ans+=1ll*C(l-2,n-1)*nowans%mo*Pow3[N+1-l]%mo;
		if(ans>=mo)ans-=mo;
		nowans=nowans*2%mo;
		nowans-=(C(l-(n+1),m)+C(l-(n+1),k))%mo;
		if(nowans<0)nowans+=mo;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 10752
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
#define qw() freopen("x.txt","r",stdin);
using namespace std;
int main(void)
{
    int n;
    while(~scanf("%d",&n))
        printf("ABC%d\n",n);
    return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int Q; cin >> Q;
    while (Q--) {
        ll A,B; cin >> A >> B;
        if (A==B) {
            cout << 2*(A-1LL) << endl;
            continue;
        }
        if (A>B) swap(A,B);
        ll K = ll(sqrt(A*B));
        if(K*K==A*B) K--;
        ll ans = 2*K;
        if (K*(K+1)>=A*B) ans--;
        ans--;
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    string s;
    s="";
    long long n,x,i,j,k;
    cin>>n;
    while (n>0)
    {
    	x=n%26;
    	n=n/26;
    	s=char(x+96)+s;
    	
	}
//	cout<<s<<endl;
	for (i=(s.length()-1);i>0;i--)
	{
		if (int(s[i])==96)
		{
			s[i]='z';
			for (j=(i-1);j>=0;j--)
			{
				if (int(s[j])>=97)
				{
					s[j]=char(int(s[j])-1);
					break;
				}
			}
			for (k=j+1;k<i;k++)
			{
				s[k]='y';
			}
		}
	}
	//cout<<s<<endl;
	for (i=s.length()-1;i>=0;i--)
	{
		if (s[i]<'a')
		{
			i++;
			break;
		}
	}
	if (i==-1)
	{
		i=0;
	}
	s=s.substr(i,s.length()-i);
	cout<<s<<endl;
}

Measured memory_bytes: 3672
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n,k;cin>>n>>k;
  string s;cin>>s;
  s[k-1]+=0x20;
  cout<<s<<endl;
}
    

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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if(a * b > c * d) cout << a * b << endl;
  else if(a * b < c * d) cout << c * d << endl;
  else cout << a * b << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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


//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second) return a.second < b.second;
    else return a.first < b.first;
}
std::uint32_t euclidean_gcd(std::uint32_t a, std::uint32_t b){return b != 0 ? euclidean_gcd(b, a % b) : a;}


void solve(long long N, long long K, std::vector<long long> x){
    // x= 0;
    LL ans = 1LL<<60;
    if(N==1){cout<<abs(x[0])<<endl;return;}
    for(LL i=0; i + K-1 <N; i++){
        LL l = x[i];
        LL r = x[i+K-1];
        ans = min(ans,min(abs(l)+abs(r-l), abs(r)+abs(l-r)));
    }
    cout<<ans<<endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> x(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
    }
    solve(N, K, std::move(x));
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

main(){

int W, H, x, y, r, c;

scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

c = 1;

if(x-r < 0){
 c = 0;
}

if(y-r <0){
 c = 0;
}

if(x+r > W){
 c = 0;
}

if(y+r > H){
 c = 0;
}

if(c){
printf("Yes\n");
}

else{
printf("No\n");
}

return 0;
}


Measured memory_bytes: 2112
def p_c():
    N = int(input())
    B = list(map(int, input().split()))

    A = []
    A.append(B[0])

    for i in range(0, N - 2):
        A.append(min(B[i], B[i + 1]))

    A.append(B[-1])

    print(sum(A))


if __name__ == '__main__':
    p_c()


Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;

int main(void)
{
    ios::sync_with_stdio(false);
    int a,b,c;
    int ans1,ans2;
    ans1=ans2=0;
    while(~scanf("%d,%d,%d",&a,&b,&c)) {
        if(a*a + b*b == c*c) ans1++;
        if(a==b) ans2++;
    }
    cout << ans1 << endl;
    cout << ans2 << endl;

    return 0;
}

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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

#define REPISE (s,e) for(int i=s,i<e;i++)
#define REPJSE (s,e) for(int j=s,j<e;j++)

using namespace std;

int main ()
{
  long long H,W;

  cin >> H >> W;

  if (H == 1 || W == 1)
  {
    cout << 1 << endl;
    return 0;
  }

  cout << (H*W+1)/2 << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;
int N;
int K;

int main()
{
  int i;
  long long sum;

  cin >> N >> K;
  vector<long long> H(N);
  for (i=0; i<N; i++) {
    cin >> H[i];
  }
  sort(H.begin(), H.end());

  if (K>=N) {
    printf("0\n");
    return 0;
  }
  for (i=0, sum=0; i<N-K; i++) {
    sum += H[i];
  }
  cout << sum << "\n";
  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			int[] k = new int[N];
			for (int i = 0; i < N; ++i) {
				k[i] = sc.nextInt();
			}
			String s = sc.next();
			char[] ans = new char[s.length()];
			for (int i = 0; i < s.length(); ++i) {
				ans[i] = i2c(c2i(s.charAt(i)) + 52 - k[i % k.length]);
			}
			System.out.println(String.valueOf(ans));
		}
	}

	static int c2i(char c) {
		return 'a' <= c && c <= 'z' ? c - 'a' : c - 'A' + 26;
	}

	static char i2c(int i) {
		i %= 52;
		return (char) (i < 26 ? i + 'a' : i - 26 + 'A');
	}

}

Measured memory_bytes: 24856
#include<bits/stdc++.h>
using namespace std;
vector <vector <int  > > graph(100);
int ans[100]={0};
int n,m;
void rec(int i,int visi, vector <bool > visited)
{
    visi++;
    visited[i]=true;
    //cout<<i<<endl;
    if(visi==n)
    {
        ans[i]++;
        return;
    }
    for(int j=0;j<graph[i].size();j++)
        if(!visited[graph[i][j]])rec(graph[i][j],visi,visited);
}
int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    int out=0;
        vector <bool > visited(100,false);
        for(int i=1;i<=n;i++){ans[i]=0;visited[i]=false;}
        rec(1,0,visited);
        int flag=0;
        for(int i=1;i<=n;i++)if(ans[i]>0)flag=1;
        int temp=0;
        if(flag)
        for(int i=1;i<=n;i++)
        {
           // cout<<ans[i]<<" ";
            temp+=ans[i];
        }
        if(temp>out)out=temp;
        //cout<<endl;
    cout<<out<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a, b;
	scanf("%d",&a);
	scanf("%d",&b);
	if(a<b){
      		printf("a < b\n");
	}else if(a>b){
       		printf("a > b\n");
	}else if(a==b){
       		printf("a == b\n");
	}else{
	}
	return 0;
}

Measured memory_bytes: 580
loop {
	n = gets.to_i
	break if n == 0
	m = gets.to_i

	friend = (0..n-1).map{|i| 1 << i}
	m.times {
		i, j = gets.split.map &:to_i
		i -= 1
		j -= 1
		friend[i] |= (1 << j)
		friend[j] |= (1 << i)
	}

	k = (1..n-1).select{|i|
		friend[0][i] == 1
	}.map{|i|
		friend[i]
	}.inject(0, :|).to_s(2).count(?1)-1

	p k < 0 ? 0 : k
}

Measured memory_bytes: 6164
#include<stdio.h>
int main(){
  char s[10];
  scanf("%s",s);
  if(s[0] ==s[1] &&s[1] !=s[2] &&s[2] ==s[3])
    printf("Yes\n");
  else if(s[0] ==s[2] &&s[2] !=s[1] &&s[1] ==s[3])
    printf("Yes\n");
  else if(s[0] ==s[3] &&s[3] !=s[1] &&s[1] ==s[2])
    printf("Yes\n");
  else printf("No\n");
}

Measured memory_bytes: 128
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

#define YES_ cout<<"Yes"<<endl;return 0;
#define NO_ cout<<"No"<<endl;return 0;

int main(){
 

    int C[4][4];
    REP(i,3)
    REP(j,3){
        cin>>C[i][j];
    }
    // if(C[0][0]-C[0][1]!=C[1][0]-C[1][1]||C[1][0]-C[1][1]!=C[2][0]-C[2][1]){NO_;}
    // if(C[0][1]-C[0][2]!=C[1][1]-C[1][2]||C[1][1]-C[1][2]!=C[2][1]-C[2][2]){NO_;}
    // if(C[0][0]-C[1][0]!=C[1][0]-C[1][1]||C[1][0]-C[1][1]!=C[2][0]-C[2][1]){NO_;}
    REP(i,2){
        if(C[i][0]-C[i][1]!=C[i+1][0]-C[i+1][1]){NO_;}
        if(C[i][1]-C[i][2]!=C[i+1][1]-C[i+1][2]){NO_;}
        
        if(C[0][i]-C[1][i]!=C[0][i+1]-C[1][i+1]){NO_;}
        if(C[1][i]-C[2][i]!=C[1][i+1]-C[2][i+1]){NO_;}
        
    }


    // REP(i,3){
    //     if(C[i][0]-C[i][1]!=C[i][0]-C[i][1]||C[i][0]-C[i][1]!=C[i][0]-C[i][1]){NO_;}
    //     if(C[i][]-C[i][1]!=C[1][0]-C[1][1]||C[1][0]-C[1][1]!=C[2][0]-C[2][1]){NO_;}
        
    // }

    YES_;
}


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

using namespace std;
typedef pair<int, int> pii;
const int N = 1e5 + 10;

vector <pii> g[N];
int sz[N], n;

void dfs (int, int = -1);
int findCentroid (int, int);

int main() {
	cin >> n;
	for (int i = 1; i < n; i++) {
		int v, u, w;
		cin >> v >> u >> w;
		v--; u--;
		g[v].push_back({u, w});
		g[u].push_back({v, w});
	}
	dfs(0);

	long long ans = 0;
	for (int v = 0; v < n; v++)
		for (pii u: g[v]) {
			long long tmp = min(sz[v], sz[u.first]);
			tmp = min(tmp, n - tmp);
			ans += tmp * u.second;
		}

	int centroid = findCentroid(0, 0);
	dfs (centroid);
	pii mx = g[centroid][0];
	pii mn = g[centroid][0];
	for (pii u: g[centroid]) {
		if (sz[u.first] > sz[mx.first])
			mx = u;
		if (u.second < mn.second)
			mn = u;
	}

	if (sz[mx.first] >= (n + 1) / 2)
		cout << ans - mx.second << endl;
	else
		cout << ans - mn.second << endl;
}

void dfs (int v, int pv) {
	sz[v] = 1;
	for (pii u: g[v])
		if (u.first != pv) {
			dfs (u.first, v);
			sz[v] += sz[u.first];
		}
}

int findCentroid (int v, int pv) {
	for (pii u: g[v])
		if (u.first != pv && sz[u.first] > n / 2)
			return findCentroid(u.first, v);
	return v;
}

// SamMHD :: May27-2019 :: Another Centroid...

Measured memory_bytes: 11520
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	int y, m, d;
	sscanf(s.c_str(), "%d/%d/%d", &y, &m, &d);
	cout << (y > 2019 || (y == 2019 && m >= 5) ? "TBD" : "Heisei") << endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<long long> h(n + 2);
  for (int i = 1; i <= n; i++) {
    cin >> h[i];
  }
  vector<vector<long long>> dp(n + 2, vector<long long>(n + 3, 1LL << 55));
  dp[0][1] = 0;
  for (int i = 1; i <= n + 1; i++) for (int j = 1; j <= n + 2; j++) {
    for (int l = 0; l < i; l++) dp[i][j] = min(dp[i][j], dp[l][j - 1] + max(0LL, h[i] - h[l]));
  }
  long long ans = 1LL << 60;
  for (int i = n - k + 2; i <= n + 2; i++) {
    ans = min(ans, dp[n + 1][i]);
    //cerr << i << " " << dp[n + 1][i] << endl;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 1024
//By Bibi
///                 .-~~~~~~~~~-._       _.-~~~~~~~~~-.
///             __.'              ~.   .~              `.__
///           .'//                  \./                  \`.
///        .'//                     |                     \`.
///       .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-. \`.
///     .'//.-"                 `-.  |  .-'                 "-.\`.
///   .'//______.============-..   \ | /   ..-============.______\`.
/// .'______________________________\|/______________________________`.
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define dep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
typedef long long ll;
int read(){
	int sum=0,flag=1;
	char c;
	for(;c<'0'||c>'9';c=getchar())if(c=='-') flag=-1;
	for(;c>='0'&&c<='9';c=getchar())sum=(sum<<1)+(sum<<3)+c-'0';
	return sum*flag;
}
int n;
int a[10];
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read();
	a[1]=111;a[2]=222;a[3]=333;a[4]=444;a[5]=555;a[6]=666;a[7]=777;a[8]=888;a[9]=999;
	rep(i,1,9) if(a[i]>=n) {printf("%d\n",a[i] );return 0;}
	return 0;
}

Measured memory_bytes: 256