akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>

#define MAX_LEN (80)
#define OVERFLOW std::cout << "overflow" << std::endl;

class LargeInteger {
public:
  LargeInteger();
  LargeInteger(const std::string& val);
  ~LargeInteger();

  void operator=(const std::string& val);
  const LargeInteger& operator+(const LargeInteger& other);

  const std::string& GetVal() const;

  friend std::istream& operator >> (std::istream& is, LargeInteger& obj);
private:
  std::string m_val;
};

LargeInteger::LargeInteger()
{
  ;
}

LargeInteger::LargeInteger(const std::string& val) : m_val(val)
{
  ;
}

LargeInteger::~LargeInteger()
{
  ;
}

void LargeInteger::operator=(const std::string& val)
{
  m_val = val;
}

const LargeInteger& LargeInteger::operator+(const LargeInteger& other)
{
  std::string l = m_val;
  std::string s = other.GetVal();

  if (l.size() != s.size()) {
    if (l.size() < s.size()) std::swap(l, s);
    int diff = l.size() - s.size();
    std::string pad;
    for (int i = 0; i < diff; i++) pad.push_back('0');
    s = pad + s;
  }

  std::vector<int> sum_digits;

  int adv = 0;
  for (int i = l.size() - 1; i >= 0; i--) {
    int d_l = static_cast<int>(l.at(i) - '0');
    int d_s = static_cast<int>(s.at(i) - '0');
    int sum = d_l + d_s + adv;
    adv = sum >= 10 ? 1 : 0;
    sum_digits.push_back(sum % 10);
  }

  std::stringstream sstr;
  if (adv) sstr << 1;
  for (int i = sum_digits.size() - 1; i >= 0; i--) sstr << sum_digits.at(i);
  m_val = sstr.str();

  return *this;
}

const std::string& LargeInteger::GetVal() const
{
  return m_val;
}

std::istream& operator >> (std::istream& is, LargeInteger& obj)
{
  is >> obj.m_val;
  return is;
}

int main(void)
{
  int set_num = 0;
  std::cin >> set_num;

  for (int i = 0; i < set_num; i++) {
    LargeInteger li_1, li_2;

    std::cin >> li_1;
    std::cin >> li_2;

    if (li_1.GetVal().size() > MAX_LEN || li_2.GetVal().size() > MAX_LEN) {
      OVERFLOW;
      continue;
    }

    LargeInteger li_sum = li_1 + li_2;
    if (li_sum.GetVal().size() > MAX_LEN) {
      OVERFLOW;
    }
    else {
      std::cout << li_sum.GetVal() << std::endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3080
n = int(input())
a = list(map(int,input().split()))
# print(abs(max(a)-min(a)))
max = min = a[0]
for i in range(0,n):
    if max < a[i]:
        max = a[i]
    if min > a[i]:
        min = a[i]
print(max-min)


Measured memory_bytes: 2940
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn = 100000 + 100;
int N, ans = 0, A[maxn];

void Init()
{
	scanf("%d", &N);
	for(int i = 1; i <= N; ++i)
	{
		scanf("%d", &A[i]);
		ans += abs(A[i] - A[i-1]);
	}
	ans += abs(A[N]);
}

void Solve()
{
	for(int i = 1; i <= N; ++i)
	{
		int tmp = ans;
		tmp -= abs(A[i]-A[i-1]) + abs(A[i]-A[i+1]);
		tmp += abs(A[i-1] - A[i+1]);
		printf("%d\n", tmp);
	}
}

int main()
{
	Init(), Solve();
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define fo(i,l,r) for(int i=l;i<=r;i++)
#define of(i,l,r) for(int i=l;i>=r;i--)
#define fe(i,u) for(int i=head[u];i;i=e[i].next)
#define el putchar('\n')
#define ta putchar('	')
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline void open(const char *s)
{
	#ifndef ONLINE_JUDGE
	char str[20];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
//	sprintf(str,"%s.out",s);
//	freopen(str,"w",stdout);
	#endif
}
inline int rd()
{
	static int x,f;
	x=0;f=1;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return f>0?x:-x;
}
const int N=100010;
int n,a[N],b[N],t1,t2,bel1[N],bel2[N],c1[N],c2[N],vs,vt;
bool vis[N];

int head[N<<1],tot=1;
struct edge{int v,f,next;}e[N*20];

inline void add(int u,int v,int f)
{
	e[++tot]=edge{v,f,head[u]};head[u]=tot;
	e[++tot]=edge{u,0,head[v]};head[v]=tot;
}
int d[N<<1],cur[N<<1];
inline bool bfs()
{
	fo(i,1,vt)d[i]=-1,cur[i]=0;
	static queue<int>q;while(!q.empty())q.pop();
	q.push(vs);d[vs]=0;cur[vs]=head[vs];
	while(!q.empty()){
		int u=q.front();q.pop();
		fe(i,u){
			int v=e[i].v,f=e[i].f;
			if(f&&!~d[v]){
				d[v]=d[u]+1;cur[v]=head[v];
				if(v==vt)return 1;
				q.push(v);
			}
		}
	}
	return 0;
}
int dfs(int u,int a)
{
	if(!a||u==vt)return a;
	int ans=0;
	for(int&i=cur[u];i;i=e[i].next){
		int v=e[i].v,f=e[i].f;
		if(f&&d[v]==d[u]+1){
			f=dfs(v,min(a,f));
			if(!f)continue;
			e[i].f-=f;e[i^1].f+=f;
			ans+=f;a-=f;if(!a)break;
		}
	}
	return ans;
}

int main()
{
	n=rd();
	fo(i,1,n)a[i]=rd()+1;
	fo(i,1,n)b[i]=rd()+1;
	fo(i,1,n)if(!vis[i]){
		if(a[i]==i)continue;
		++t1;
		for(int x=i;!vis[x];x=a[x]){
			vis[x]=1,bel1[x]=t1;
			if(b[x]==x)++c1[t1];
		}
	}
	memset(vis,0,N);
	fo(i,1,n)if(!vis[i]){
		if(b[i]==i)continue;
		++t2;
		for(int x=i;!vis[x];x=b[x]){
			vis[x]=1,bel2[x]=t2;
			if(a[x]==x)++c2[t2];
		}
	}
	vs=t1+t2+1;vt=vs+1;
	fo(i,1,t1)if(c1[i])add(vs,i,c1[i]);
	fo(i,1,t2)if(c2[i])add(i+t1,vt,c2[i]);
	fo(i,1,n)if(a[i]!=i&&b[i]!=i)add(bel2[i]+t1,bel1[i],1);
	fo(i,1,n)if(a[i]!=i&&b[i]!=i&&a[i]==b[i])add(bel1[i],bel2[i]+t1,1);
	int ans=n;
	fo(i,1,n)if(a[i]==i&&b[i]==i)--ans;
	while(bfs())ans-=dfs(vs,1e9);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 11008
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        if (s.equals("a") || s.equals("i") || s.equals("u") || s.equals("e") || s.equals("o"))
            System.out.println("vowel");
        else
            System.out.println("consonant");
    }
}

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

int main()
{
    int n, i, j, k;
    long long int sum=0;
    cin >> n;

    for(i=1; i<=n; i++)
    {
        for(j=1; j<=n; j++)
        {
            for(k=1; k<=n; k++)
            {
                sum=sum+__gcd(i, __gcd(j,k));
            }
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3636
import sys
import numpy as np
from numba import njit, void, i8
input = sys.stdin.buffer.readline

def main():
    R, C, K = map(int, input().split())

    L_INF = int(1e17)
    dp = np.full((R+1, C+1, 4), -L_INF, dtype=np.int64)
    cell = np.full((R+1, C+1), 0, dtype=np.int64)

    for i in range(K):
        x, y, c = map(int, input().split())
        cell[x-1][y-1] = c

    f(dp, cell, R, C)

    print(dp[R][C][3])

@njit(void(i8[:,:,:],i8[:,:],i8,i8))
def f(dp, cell, R, C):
    dp[0][1][0] = dp[1][0][0] = 0
    for i in range(1, R + 1):
        for j in range(1, C + 1):
            for k in range(4):
                if k > 0:
                    dp[i][j][k] = max(dp[i][j][k], dp[i][j][k-1])
                dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k])
                if k > 0:
                    dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k-1] + cell[i-1][j-1])
                if k == 1:
                    dp[i][j][k] = max(dp[i][j][1], dp[i-1][j][3] + cell[i-1][j-1])

if __name__ == "__main__":
    main()


Measured memory_bytes: 469260
import itertools
import math
N = int(input())
di = {}
for i in range(N):
    di[i+1] = int(input())

flag = False
next = 1
for i in range(N):
    if next == 2:
        flag = True
        break
    next = di[next]

    # print(next)
if flag:
    print(i)
else:
    print(-1)

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

int main() {
  double W,H,x,y; cin >> W >> H >> x >> y;
  double size = W * H / 2.0000000000;
  cout << size << ' ';
  if(x == W / 2 && y == H / 2){
    cout << '1' << endl;
  }else{
    cout << '0' << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main() {
    cin>>N>>K;
    if(N < 10){
        cout<<K + 100 * (10 - N)<<endl;
    }else{
        cout<<K<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
ll gcd(ll a, ll b); 
  
// To compute x raised to power y under modulo m 
ll power(ll x,ll y, ll m); 
  
// Function to find modular inverse of a under modulo m 
// Assumption: m is prime 
ll modInverse(ll a, ll m) 
{ 
    return power(a, m-2, m);  
} 
  
// To compute x^y under modulo m 
ll power(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
  
    return (y%2 == 0)? p : (x * p) % m; 
} 
  
// Function to return gcd of a and b 
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b%a, a); 
} 
int main()
{
	ll h,n,sum,i;
	cin>>h>>n;
	ll a[n];
	sum=0;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		sum=sum+a[i];
	}
	if(sum>=h)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
}

Measured memory_bytes: 1024
# debug
debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if debugFlag

# util functions
def find_posmin(arr)
  m = arr.max
  arr.each do |e_i|
    m = e_i if e_i > 0 and m > e_i
  end
  return m
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
crntArr = inputs[1]
if debugFlag
  p crntArr
end

m = 0
loop do
  m = find_posmin( crntArr )
  midx = crntArr.index(m)
  stopFlag = true
  crntArr.size.times do |i|
    next if midx == i
    crntArr[i] = crntArr[i] % m
    stopFlag = false if crntArr[i] != 0
  end
  break if stopFlag
end

puts m


Measured memory_bytes: 9484
#include<stdio.h>

void gcd(int, int);

int main(){
  int x, y;

  scanf("%d %d",&x, &y);

  gcd(x,y);

  return 0;
}

void gcd(int x, int y){
  int d;

  if(x < y){
    d = x;
    x = y;
    y = d;
  }

  while(y > 0){
    d = x % y;
    x = y;
    y = d;
  }
  printf("%d\n",x);
}



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

int main(){
    int N;
    cin >> N;
    int x[N];
    for(int i =0; i < N; i++){
        cin >> x[i];
    }
    int min = 1<<30;
    for(int av = 1; av <= 100; av++){
        int sum = 0;
        for(int i =0; i < N; i++){
            sum += (x[i] - av)*(x[i] - av);
        }
        if(sum < min) min = sum;
    }
    cout << min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,m;
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		int a;
		cin >> a;
		n -= a;
	}
	if(n < 0) n = -1;
	cout << n << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n; 
char s[maxn];
bool a[maxn], b[maxn];
void solve()
{
	for(int i = 3; i <= n; ++i)
		a[i] = b[i - 1] ^ a[i - 1] ^ a[i - 2];
	if(b[n] != (a[n - 1] ^ a[n] ^ a[1]))
		return;
	if(b[1] != (a[n] ^ a[1] ^ a[2]))
		return;
	for(int i = 1; i <= n; ++i)
		s[i] = a[i] ? 'W' : 'S';
	puts(s + 1);
	exit(0);
}
int main()
{
	scanf("%d%s", &n, s + 1);
	for(int i = 1; i <= n; ++i) 
		b[i] = s[i] == 'o' ? 0 : 1;
	solve();
	a[1] = 1;
	solve();
	a[2] = 1;
	solve();
	a[1] = 0;
	solve();
	puts("-1");
	return 0;
}
	

Measured memory_bytes: 640
val SEPARATOR = "####################"
val FLOORS = 1..3
val ROOMS  = 1..10
val DORMITORIES = 1..4

fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val allRooms = hashMapOf<String, Int>().withDefault { 0 }
    (1..n).forEach {
        val (b, f, r, v) = readLine()?.split(" ") ?: return
        val key = "$b $f $r"
        val counts = allRooms.getValue(key)
        allRooms.put(key, counts + v.toInt() )
    }
    val builder = StringBuilder()
    DORMITORIES.forEach { dormitoryNum ->
        FLOORS.forEach{ floorNum ->
            ROOMS.forEach{ roomNum ->
                val count = allRooms.getValue("$dormitoryNum $floorNum $roomNum")
                builder.append(" $count")
            }
            println(builder.toString())
            builder.setLength(0)
        }
        if (dormitoryNum != DORMITORIES.last) println(SEPARATOR)
    }
}


Measured memory_bytes: 32324
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;


struct SegmentTree {
  using T = pair<int, int>; // (max, idx)
  static T op(const T& x, const T& y) { return max(x, y); }
  static constexpr T e() { return {-1e9, -1}; }

  const int n;
  V<T> t;
  SegmentTree(int n) : n(n), t(2 * n, e()) {}
  T& operator[](int i) { return t[i + n]; }
  void build() { for (int i = n - 1; i; --i) t[i] = op(t[2 * i], t[2 * i + 1]); }
  T acc(int l, int r) const {
    T resl = e(), resr = e();
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) resl = op(resl, t[l++]);
      if (r & 1) resr = op(t[--r], resr);
    }
    return op(resl, resr);
  }
  void set(int i, const T& x) {
    t[i += n] = x;
    while (i >>= 1) t[i] = op(t[2 * i], t[2 * i + 1]);
  }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  V<> a(n); for (auto&& e : a) cin >> e;
  auto b = a;
  sort(rbegin(b), rend(b));
  int c = 0;
  while (c < n and b[c] > c) ++c;
  if (0 < c and c < n) {
    SegmentTree st(n);
    for (int i = 0; i < c; ++i) {
      st[i] = {c - max(i, a[i]), i};
    }
    for (int i = c; i < n; ++i) {
      st[i] = {min(i, a[i]) - c, i};
    }
    st.build();
    while (m--) {
      if (st.acc(0, n).first <= 0) break;
      int i = st.acc(0, c).second;
      int j = st.acc(c, n).second;
      swap(a[i], a[j]);
      st.set(i, {c - max(i, a[i]), i});
      st.set(j, {min(j, a[j]) - c, j});
      // cerr << "a(" << a.size() << ") = {"; for (const auto& e : a) cerr << e << ", "; cerr << "} (l." << __LINE__ << ")\n";
      // for (int i = 0; i < n; ++i) {
      //   cerr << st[i].first << " \n"[i == n - 1];
      // }
    }
  }
  lint res = 0;
  for (int i = 0; i < n; ++i) {
    res += abs(a[i] - i);
  }
  cout << res << '\n';
}


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

int main(){
    string s;
    cin >> s;
    int n=s.size();
    int ans=0;
    reverse(s.begin(),s.end());
    s=s+"0";
    int c=0;
    rp(i,n+1){
        int d=s.at(i)-'0';
        if(c==1) d++;
        if(d==10){
            c=1;
            continue;
        }
        if(d<=4) {
            ans += d;
            c=0;
            continue;
        }
        if(d>=6){
            ans += 10-d;
            c=1;
            continue;
        }
        if(d==5){
            ans+=5;
            if(s.at(i+1)-'0'>=5){
                c=1;
            }
            else{
                c=0;
            }
        }
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 3332
#include <iostream>

using namespace std;

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    long long int n,sum=0;
    cin >> n;

   for(int i=1;i<=n;i++){
        if(i%3==0||i%5==0) continue;
        sum+=i;
   }
   cout<<sum;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int is_leap(int y){
  if(y % 400 == 0) return 366;
  else if(y % 100 == 0) return 365;
  else if(y % 4 == 0) return 366;
  return 365;
}
const int days[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll y,y2,d,d2,m,m2;
  while(cin >> y >> m >> d >> y2 >> m2 >> d2){
    if(y < 0 || m < 0 || d < 0 || y2 < 0|| m2 < 0|| d2 < 0) break;
    ll ans = 0;
    rep(i,m-1){
      ans -= days[i];
    }
    if(is_leap(y) == 366 && m > 2) --ans;
    ans -= d;
    while(y2 - y != 0){
      ans += is_leap(y);
      ++y;
    }
    rep(i,m2-1){
      ans += days[i];
    }
    if(is_leap(y2) == 366 && m2 > 2) ++ans;
    ans += d2;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3100
n = int(input())
a = sorted(map(int, input().split()), reverse=True)
x, y = a[0], a[-1]
v = []
for i in a[1:-1]:
    if i > 0:
        v.append((y, i))
        y -= i
    else:
        v.append((x, i))
        x -= i
v.append((x, y))
print(x - y)
for i in v:
    print(i[0], i[1])

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

int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    vector<int>N(10,0);
    N.at(a)=1;
    N.at(b)=1;
    N.at(c)=1;
    N.at(d)=1;
    if(N.at(1)+N.at(9)+N.at(7)+N.at(4)==4){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
return 0;}
/*compile
g++ code.cpp
./a.out
run*/

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> cnt(200100);
  rep(i, n) {
    int a;
    cin >> a;
    cnt[a]++;
  }
  sort(cnt.rbegin(), cnt.rend());
  int s = 0;
  rep(i, k) {
    s += cnt[i];
  }
  int ans = n - s;
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<cstdlib>
#include<queue>
#include<list>
#include<cctype>
const int INF=1e9;
using namespace std;

int main(){
    int a, b;
    cin>>a>>b;
    if((a+b)%3==0||a%3==0||b%3==0) cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
}



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

using namespace std;

typedef long long ll;

template<typename T> ostream& operator << (ostream& os, vector<T> v) {
  for (auto& i : v) os << i << " "; return os; 
}
template<typename T> istream& operator >> (istream& is, vector<T>& v) {
  for (auto& i : v) is >> i; return is;
}
template<typename K, typename V> ostream& operator << (ostream& os, unordered_map<K, V> m) {
  for (auto& i : m) os << i.first << ":" << i.second << endl; return os;
}

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int dx = tx - sx;
  int dy = ty - sy;
  for (int i=0; i<dx; i++) {
    cout << 'R';
  }
  for (int i=0; i<dy; i++) {
    cout << 'U';
  }
  for (int i=0; i<dx; i++) {
    cout << 'L';
  }
  for (int i=0; i<dy; i++) {
    cout << 'D';
  }
  cout << 'D';
  for (int i=0; i<dx+1; i++) {
    cout << 'R';
  }
  for (int i=0; i<dy+1; i++) {
    cout << 'U';
  }
  cout << "LU";
  for (int i=0; i<dx+1; i++) {
    cout << 'L';
  }
  for (int i=0; i<dy+1; i++) {
    cout << 'D';
  }
  cout << 'R';
  return 0;
}


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

using namespace std;

template<typename C>
class seg_tree {
  vector<C> tree;
  function<C(C, C)> key;
  C def;
  int p = 1;
public:
  seg_tree(int n, function<C(C, C)> _key, C _def) : key(_key), def(_def) {
    while (p < n) {
      p <<= 1;
    }
    tree.resize(p << 1, def);
  }

  seg_tree(const vector<C>& a, function<C(C, C)> _key, C _def) : key(_key), def(_def) {
    while (p < a.size()) {
      p <<= 1;
    }
    tree.resize(p << 1, def);
    for (int i = 0; i < a.size(); ++i) {
      tree[i ^ p] = a[i];
    }
    for (int i = p - 1; i; --i) {
      tree[i] = key(tree[i << 1], tree[i << 1 | 1]);
    }
  }

  C get(int l, int r) {
    C res = def;
    for (l ^= p, r ^= p; l <= r; l >>= 1, r >>= 1) {
      if (l & 1) {
        res = key(res, tree[l++]);
      }
      if ((r & 1) == 0) {
        res = key(res, tree[r--]);
      }
    }
    return res;
  }

  void update(int k, C x) {
    k ^= p;
    tree[k] = x;
    for (k >>= 1; k; k >>= 1) {
      tree[k] = key(tree[k << 1], tree[k << 1 | 1]);
    }
  }
};

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

  int n, m;
  cin >> n >> m;
  seg_tree<long long> dp(n, [](auto a, auto b) { return min(a, b); }, 1e18);
  dp.update(0, 0);
  vector<vector<pair<int, int>>> kek(n);
  for (int i = 0; i < m; ++i) {
    int l, r, c;
    cin >> l >> r >> c;
    --l, --r;
    kek[r].emplace_back(l, c);
  }
  for (int r = 1; r < n; ++r) {
    long long mn = 1e18;
    for (auto p : kek[r]) {
      int l = p.first, c = p.second;
      mn = min(mn, dp.get(l, r) + c);
    }
    dp.update(r, mn);
  }
  long long ans = dp.get(n - 1, n - 1);
  cout << (ans == 1e18 ? -1 : ans);

  return 0;
}

Measured memory_bytes: 7680
def getlist():
	return list(map(int, input().split()))

#受け取り
K = int(input())
A = getlist()
A = A[::-1]

#処理
ans = 0
dpM = [0] * (K)
dpm = [0] * (K)
dpM[0] = A[0] * 2 - 1
dpm[0] = A[0]
for i in range(1, K):
	if A[i] > dpM[i - 1]:
		ans = -1
		break
	elif A[i] >= dpm[i - 1]:
		dpM[i] = A[i] * 2 - 1
		dpm[i] = A[i]

	else:
		dpM[i] = A[i] * (dpM[i - 1] // A[i] + 1) - 1

		if dpm[i - 1] % A[i] == 0:
			dpm[i] = dpm[i - 1]
		else:
			dpm[i] = A[i] * (dpm[i - 1] // A[i] + 1)
	if dpm[i] > dpM[i]:
		ans = -1
		break

#出力
if ans == -1 or A[0] != 2:
	print(-1)
else:
	print(dpm[-1], dpM[-1])

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

public class Main{
	static int maxH=50;
	static int maxW=50;
	static int h;
	static int w;
	static int ans=0;
	static int[][] c=new int[maxH][maxW];
	static boolean[][] notUse=new boolean[maxH][maxW];//counted?
	
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		//input
		while(true){
			w=scan.nextInt();
			h=scan.nextInt();
			if(w==0 && h==0){
				break;
			}
			//starting setting
			ans=0;
			
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					c[i][j]=scan.nextInt();
					if(c[i][j]==1){
						notUse[i][j]=true;
					}
					else{
						notUse[i][j]=false;
					}
				}
			}
			
			//seeing from Upper Left
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					if(notUse[i][j]){
						counting(i,j);
					}
				}
			}
			System.out.println(ans);
		}
	}
	
	private static void counting(int i,int j){
		ArrayList<Integer> queH = new ArrayList<Integer>();
		ArrayList<Integer> queW = new ArrayList<Integer>();
		queH.add(i);
		queW.add(j);
		notUse[i][j]=false;
		
		while(queW.size()>0){
			int tempI=queH.get(0);
			int tempJ=queW.get(0);
			queH.remove(0);
			queW.remove(0);
			
			for(int I=-1;I<2;I++){
				for(int J=-1;J<2;J++){
					if(tempI+I<0 || h-1<tempI+I || tempJ+J<0 || w-1<tempJ+J){
						continue;
					}
					if(notUse[tempI+I][tempJ+J]){
						queH.add(tempI+I);
						queW.add(tempJ+J);
						notUse[tempI+I][tempJ+J]=false;
					}
				}
			}
		}
		ans++;
	}
}

Measured memory_bytes: 45932
def ipt(N=0,switch=0):
    if N == 0:
        return list(map(int,input().split()))
    else:
        if switch==0:
            return [list(map(int,input().split())) for _ in range(N)]
        else:
            return [int(input()) for _ in range(N)]

N=int(input())
T=ipt()
M=int(input())
PX=ipt(M)

for i in range(M):
    print(sum(T) + PX[i][1] - T[PX[i][0]-1])

Measured memory_bytes: 3064
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 11100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char in[6][10000];

int main(){
	int a,b;scanf("%d%d",&a,&b);printf("%d\n",a*b);
}

Measured memory_bytes: 1672
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<string> W(N);
    for (auto &x : W) cin >> x;

    for (int i = 1; i < N; i++) {
        if (W[i - 1][W[i - 1].length() - 1] != W[i][0]) {
            cout << "No" << endl;
            return 0;
        }
    }

    sort(W.begin(), W.end());

    for (int i = 1; i < N; i++) {
        if (W[i - 1] == W[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n,y;
	cin>>n>>y;
	for(int i=0;i<=n;i++) {
		for(int j=0;j<=n-i;j++) {
				if(i*10000+j*5000+(n-i-j)*1000==y) {
					cout<<i<<" "<<j<<" "<<n-i-j;
					return;
				}
			
		}
	}
	cout<<"-1 -1 -1";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    int N,M,i;
    int ac[100005];
    int wa[100005];    
    scanf("%d%d",&N,&M);
    for(i=1; i<=N; i++)
    {
        ac[i]=0;
        wa[i]=0;
    }
    int p;
    char S[3];
    int acnum=0,wanum=0;
    for(i=1; i<=M; i++)
    {
        scanf("%d%s",&p,S);
        if(ac[p]==0)
        {
            if(!strcmp(S,"WA"))
            {
                wa[p]++;

            }
            else if(!strcmp(S,"AC"))
            {
                ac[p]=1;
                acnum++;
            }
        }
    }
    for(i=1; i<=N; i++)
    {
        if(ac[i]==1)
        {
             wanum+=wa[i];
        }       
    }
    printf("%d %d",acnum,wanum);
    return 0;

}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define   PI    acos(-1)
#define mx 1005
int fx[]= {0,0,-1,1};
int fy[]= {1,-1,0,0};
ll  MOD=1000000007;
int dp[mx][mx];
string a[mx];
int main()
{
    ios::sync_with_stdio(0),cin.tie(0);

    ll h,w,i,j;
    cin>>h>>w;
    for(i=0; i<h; i++)
    {
        cin>>a[i];
    }
   dp[0][0]=1;
   for(j=1;j<w;j++){
    if(a[0][j]=='#')break;
    else dp[0][j]=1;
   }
   for(j=1;j<h;j++){
    if(a[j][0]=='#')break;
    else dp[j][0]=1;
   }
    for(i=1; i<h; i++)
    {
        for(j=1; j<w; j++)
        {
            if(a[i][j]=='.')
            {
                dp[i][j]=(dp[i][j-1]+dp[i-1][j])%MOD;
            }
        }
    }
    cout<<dp[h-1][w-1]<<endl;

    return 0;
}



Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
#define repb(i, n) for (int i = (n - 1); i >= 0; i--)
#define repb2(i, a, n) for (int i = (n - 1); i >= (a); i--)
#define all(x) x.begin(), x.end()
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
inline void fastio() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }
const int INF = 2e9 + 7;

struct arr {
    int x, y, h;
};

void co_elem(vector<int> &A, int N) {
    rep(i, N) {
        if (i < N - 1) {
            cosp(A[i]);
        } else {
            co(A[i]);
        }
    }
}

void insertionSort(vector<int> &A, int N) {
    rep2(i, 0, N) {
        int v = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        co_elem(A, N);
    }
}

int greatestCommonDivisor(int x, int y) {
    if (x < y)
        swap(x, y);
    while (y > 0) {
        int rem = x % y;
        x = y;
        y = rem;
    }
    return x;
}

bool isPrime(int x) {
    if (x == 2) {
        return true;
    }
    if (x < 2 || x % 2 == 0) {
        return false;
    }
    for (int i = 3; i <= sqrt(x); i += 2) {
        if (x % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    int N, x;
    cin >> N;
    int ans = 0;
    rep(i, N) {
        cin >> x;
        ans += isPrime(x);
    }
    co(ans);
    return 0;
}


Measured memory_bytes: 3068
// B - Contest with Drinks Easy
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const long double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using P = pair<lli, lli>;
// vector<P> vp;
// vp.emplace_back(a[i], b[i]);
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, m, p, x, w, ans = 0, count = 0;
  string s;
  cin >> n;
  vlli t(n), e;
  rep(i, 0, n)
  {
    cin >> t[i];
    ans += t[i];
  }
  count = ans;
  cin >> m;
  rep(i, 0, m)
  {
    cin >> p >> x;
    ans = count;
    // t[p - 1] = x;
    if (t[p - 1] - x > 0)
    {
      ans -= abs(t[p - 1] - x);
    }
    else
    {
      ans += abs(t[p - 1] - x);
    }
    e.pb(ans);
    cout << e[i] << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 500100
using namespace std;
int dp[N];
int n,la;
char s[N];
int main(){
	scanf("%d%s",&n,s);
	for(int i=2;i<n;i++){
		dp[i]=dp[i-1];
		if(s[i-2]=='1'&&s[i-1]=='0'&&s[i]=='1'){
			la=i;
			for(int j=i-2;s[j]!='0'&&j>=0;j--)
				dp[i]=max(dp[i],dp[j-1]+(i-j-1));
		}
		if(s[i]=='0') la=0;
		if(la) dp[i]=max(dp[i],dp[la-3]+(i-la+1));
	}
	printf("%d\n",dp[n-1]);
	return 0;
}

Measured memory_bytes: 2688
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  ll N,ans=0;
  cin>>N;
  vector<ll> A;
  REP(i,N){
    ll a;
    cin>>a;
    A.push_back(a);
  }
  SORT(A);
  
  ll Q=A[0],T=0,cnt=0;
  while(T<N){
    Q=A[T];
    cnt=0;
    while(T<N && A[T]==Q){
      cnt++;
      T++;
    }
    ans+=cnt%2;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1400
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

#define M 1111111
#define F 2222

#define INF 1000000000

int dp1[M];
int dp2[M];

int main(){
	
	vector<int> num;
	
	int sum=0;
	reps(i,1,M){
		sum = sum+(i+1)*i/2;
		if(sum>M)break;
		num.push_back(sum);
	}
	
	vector<int> numodd;
	rep(i,num.size()){
		if(num[i]%2==1)numodd.push_back(num[i]);
	}
	
	rep(i,M)dp1[i]=dp2[i]=INF;
	dp1[0]=dp2[0]=0;
	
	rep(i,M){
		rep(j,num.size()){
			if(i-num[j]>=0)dp1[i] = min(dp1[i] , dp1[i-num[j]]+1);
		}
	}
	rep(i,M){
		rep(j,numodd.size()){
			if(i-numodd[j]>=0)dp2[i] = min(dp2[i] , dp2[i-numodd[j]]+1);
		}
	}
	
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		printf("%d %d\n",dp1[n],dp2[n]);
	}
	
}

Measured memory_bytes: 9876
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	set<int> water;
	for (int i = 0; i < f / 100; i++) {
		for (int j = 0; j < f / 100; j++) {
			int n = a * i + b * j;
			if (n < f / 100) {
				water.insert(n);
			}
		}
	}
	set<int> suger;
	for (int i = 0; i < f; i++) {
		for (int j = 0; j < f; j++) {
			int n = c * i + d * j;
			if (n < f && 0 < n) {
				suger.insert(n);
			}
		}
	}
	int wat{ a }, sug{ 0 };
	for (auto itr = water.begin(); itr != water.end(); itr++) {
		for (auto itrr = suger.begin(); itrr != suger.end(); itrr++) {
			if (*itr * 100 + *itrr <= f && *itrr <= *itr * e) {
				if (sug * 1.0 / wat < *itrr * 1.0 / *itr) {
					wat = *itr;
					sug = *itrr;
				}
			}
		}
	}
	cout << wat * 100 + sug << " " << sug << endl;
}

Measured memory_bytes: 384
#include<iostream>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int n;
  while(cin >> n,n){
    int x,y;
    int t[21][21]={};
    rep(i,n){
      cin >> x >> y;
      t[x][y]=1;
    }
    int m,g;
    x=10; y=10;
    cin >> m;
    char d;
    rep(i,m){
      cin >> d >> g;
      rep(j,g){
        if(d=='N') y++;
        if(d=='E') x++;
        if(d=='S') y--;
        if(d=='W') x--;
        if(t[x][y]==1) t[x][y]=0;
      }
    }
    /*
    rep(i,20){
      rep(j,20) cout << t[i][j] << " ";
      cout << endl;
    }*/
    bool flag = true;
    rep(i,21) rep(j,21) if(t[i][j]==1) flag = false;
    if(flag==true) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 3040
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n, m = map(int, input().split())


class UnionFind:
    def __init__(self, n):
        self.p = [-1]*n
        self.r = [1]*n

    def find(self, x):
        if self.p[x] < 0:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def union(self, x, y):
        rx, ry = self.find(x), self.find(y)
        if rx != ry:
            if self.r[rx] > self.r[ry]:
                rx, ry = ry, rx
            if self.r[rx] == self.r[ry]:
                self.r[ry] += 1
            self.p[ry] += self.p[rx]
            self.p[rx] = ry

    def count_members(self, x):
        return -self.p[self.find(x)]


uf = UnionFind(n)
for _ in range(m):
    a, b = map(lambda x: int(x)-1, input().split())
    uf.union(a, b)

ans = 0
for i in range(n):
    x = uf.count_members(i)
    if ans < x:
        ans = x
print(ans)


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

int main(){
  string s;
  cin >> s;
  int ans = 0;
  
  if(s[0] == '1') ans++;
  if(s[1] == '1') ans++;
  if(s[2] == '1') ans++;
  
  cout << ans << endl;
  return 0;
}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  int x;
  cin >> x;
  if (x == 1) {
    cout << 0 << endl;

  } else {
    cout << 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 3628
/*input
2
*/
/*
       _==/          i     i          \==_
     /XX/            |\___/|            \XX\
   /XXXX\            |XXXXX|            /XXXX\
  |XXXXXX\_         _XXXXXXX_         _/XXXXXX|
 XXXXXXXXXXXxxxxxxxXXXXXXXXXXXxxxxxxxXXXXXXXXXXX
|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX|
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX|
 XXXXXX/^^^^"\XXXXXXXXXXXXXXXXXXXXX/^^^^^\XXXXXX
  |XXX|       \XXX/^^\XXXXX/^^\XXX/       |XXX|
    \XX\       \X/    \XXX/    \X/       /XX/
       "\       "      \X/      "      /"

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
//loops
#define f(i,s,n) for(ll i=(ll)s;i<(ll)n;i++)
#define rf(i,n,s) for(ll i=(ll)(n-1);i>=(ll)s;i--)
//reset
#define ms0(X) memset((X), 0, sizeof((X)))
#define ms1(X) memset((X), -1, sizeof((X)))
//IO
#define bio ios_base::sync_with_stdio;cin.tie(NULL)
//STL
#define pb push_back
#define pii pair<ll,ll>
#define vll vector<ll>
#define vpii vector<pii >
#define mll map<ll, ll>
#define mpii map<pii,ll> 
#define msll map<string, ll> 
#define sortv(v) sort(v.begin(),v.end())
#define F first
#define S second
//standard values
#define mod (ll)(1e9+7)
#define INF (ll)1e16
#define MAXN (ll)(1e5+5)
//comparator
bool cmp(pii a, pii b)
{
    return a.F < b.F;
}
ll exp(ll a,ll b){ll ans=1;while(b!=0){if(b%2==1)ans=ans*a;a=a*a;b/=2;}return ans;}
/********************************************************************************************************/
ll fnc(ll a, ll b) {
  if (b == 0)
  {
    return a;
  }
  return fnc(b, a%b);
}
ll gcd(ll a, ll b, ll c) {
  return fnc(fnc(a,b),c);
}
int main() 
{
  bio;
  ll k;
  cin>>k;
  ll sum = 0;
  f(i,1,k+1) {
    f(j,1,k+1) {
      f(K,1,k+1) {
        ll ans =gcd(i,j,K);
        sum += ans;
      }
    }
  }
  cout<<sum<<endl;

}

Measured memory_bytes: 3628
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] D1 = new int[N];
        int[] D2 = new int[N];
        for (int i = 0; i < N; i++) {
            D1[i] = sc.nextInt();
            D2[i] = sc.nextInt();
        }

        boolean ok = false;
        for (int i = 0; i < N-2; i++) {
            if (D1[i] == D2[i] && D1[i+1] == D2[i+1] && D1[i+2] == D2[i+2]) {
                ok = true;
                break;
            }
        }
        System.out.println(ok ? "Yes" : "No");
    }
}


Measured memory_bytes: 36000
#include<bits/stdc++.h>
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int a0[110][110], a1[110][110], n, m;
signed main() {
	while (cin >> n >> m, n) {
		for1(i, m)for1(j, m) { a0[i][j] = n * 1001; a1[i][j] = n * 1001; }
		for1(l0y3r, n) {
			int a, b, c, d; cin >> a >> b >> c >> d;
			a0[a][b] = c; a0[b][a] = c;
			a1[a][b] = d; a1[b][a] = d;
		}
		for1(k, m)for1(i, m)for1(j, m) {
			a0[i][j] = min(a0[i][j], a0[i][k] + a0[k][j]);
			a1[i][j] = min(a1[i][j], a1[i][k] + a1[k][j]);
		}
		cin >> n;
		for1(l0y3r, n) {
			int p, q, r; cin >> p >> q >> r;
			if (r)cout << a1[p][q] << endl;
			else cout << a0[p][q] << endl;
		}
	}
}


Measured memory_bytes: 3104
function Main(input) {
  input = input.replace(/\n/g, ' ');
  input = input.split(" ");
  var A = Number(input[0]);
  if(400<=A && A<=599){
    console.log(8);
  }else
  if(600<=A && A<=799){
    console.log(7);
  }else
  if(800<=A && A<=999){
    console.log(6);
  }else
  if(1000<=A && A<=1199){
    console.log(5);
  }else
  if(1200<=A && A<=1399){
    console.log(4);
  }else
  if(1400<=A && A<=1599){
    console.log(3);
  }else
  if(1600<=A && A<=1799){
    console.log(2);
  }else
  if(1800<=A && A<=1999){
    console.log(1);
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29748
#include <iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define MOD 1000000007



ll f(ll a){
    ll ans;
    if(a%2 == 0){
        ans = (((a/2)*(a+1))%MOD);
    }
    else{
        ans = (((a+1)/2)*(a))%MOD;
    }
    
    return ans;
}

int main(){
    ll n;
    cin >>n;
    ll k;cin >> k;
    ll tmp = 0;
    vector<ll> a(n);
    for(ll i=0;i<n;i++){
        cin >> a[i];
    }
    vector<ll> left_low(n);
    vector<ll> right_high(n);
    vector<ll> left_high(n);
    vector<ll> right_low(n);

    for(ll i=0;i<n;i++){
        left_high[i] = 0;
        left_low[i] = 0;
        right_low[i] = 0;
        right_high[i] = 0;
        for(ll j=0;j<i;j++){
            if(a[i] > a[j]){
                left_low[i]++;
            }
            else if(a[i] < a[j]){
                left_high[i] ++;
            }
        }
        for(ll j=i+1;j<n;j++){
            if(a[i] < a[j]){
                right_high[i] ++;
            }
            else if(a[i] > a[j]){
                right_low[i] ++;
            }
        }
    }
    ll ans=0;
    for(ll i=0;i<n;i++){
        ans = (ans +(right_low[i]*f(k)%MOD + (left_low[i]*f(k-1))%MOD)%MOD)%MOD;
    }
    cout << ans << endl;
    //cout << f(2) << endl;

    return 0;
}

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

const int kMAX_K = 10;

bool can[10];
int N, K;

int DFS(int index, string money) {
    if (index == to_string(N).size()) {
        int m = stoi(money);
        if (m >= N) return m;
    }
    if (index == to_string(N).size() + 1) {
        int m = stoi(money);
        if (m >= N) return m;
        else return 1 << 28;
    }

    int res = 1 << 28;
    for (int d = 0; d < 10; d++) {
        if ((index == 0 && d == 0) || !can[d]) continue;
        res = min(res, DFS(index + 1, money + to_string(d)));
    }
    return res;
}

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

    fill(can, can + 10, true);
    for (int i = 0; i < K; i++) {
        int d;
        cin >> d;
        can[d] = false;
    }

    cout << DFS(0, "") << endl;

    return 0;
}


Measured memory_bytes: 256
N=input()

#sum
if int(N)<10**1:
    sumnum=int(N[0])
elif int(N)<10**2:
    sumnum=int(N[0])+int(N[1])
elif int(N)<10**3:
    sumnum=int(N[0])+int(N[1])+int(N[2])
elif int(N)<10**4:
    sumnum=int(N[0])+int(N[1])+int(N[2])+int(N[3])
elif int(N)<10**5:
    sumnum=int(N[0])+int(N[1])+int(N[2])+int(N[3])+int(N[4])
elif int(N)<10**6:
    sumnum=int(N[0])+int(N[1])+int(N[2])+int(N[3])+int(N[4])+int(N[5])
elif int(N)<10**7:
    sumnum=int(N[0])+int(N[1])+int(N[2])+int(N[3])+int(N[4])+int(N[5])+int(N[6])
elif int(N)<10**8:
    sumnum=int(N[0])+int(N[1])+int(N[2])+int(N[3])+int(N[4])+int(N[5])+int(N[6])+int(N[7])
else:
    sumnum=int(N[0])+int(N[1])+int(N[2])+int(N[3])+int(N[4])+int(N[5])+int(N[6])+int(N[7])+int(N[8])

#hantei
if int(N)%sumnum==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3188