akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

/*
cin.tie(0);
ios::sync_with_stdio(false);
*/

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

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int a,b,tmp;
  cin>>a>>b;
  tmp=b;
  while(tmp!=0){
    a*=10;
    tmp/=10;
  }
  a+=b;
  for(int i=0;i<1000;i++){
    if(i*i==a){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#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>;
using Graph = vector<vector<int>>;

int main() {
    string s;
    cin >> s;
    int n=s.size()-1;
    ll ans=0;
    for (int bit = 0; bit < (1<<n); ++bit) {
        ll sum = 0;
        ll pr = 0;
        for (int i = 0; i < n+1; ++i) {
            pr *= 10;
            //-'0'で数字から数値へ変換
            pr += s[i] - '0';
            if(i==n){
                sum += pr;
                break;
            }
            if (1 & (bit>>i)) {
                sum += pr;
                pr = 0;
            }
        }
        ans+=sum;
    }
    cout << ans << "\n";
    return 0;
}

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

import sys
import os


rectangle = 0
diamond = 0
parallelogram = 0

for s in sys.stdin:
    a, b, c = map(int, s.split(','))
    if a**2 + b**2 == c**2:
        rectangle += 1
    elif a == b:
        diamond += 1
    else:
        parallelogram += 1

print(rectangle)
print(diamond)

Measured memory_bytes: 7568
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;

int main() {
	string S;
	cin >> S;
	ll sum=0,ori=0;
	int i=0;
	ori = stoi(S);
	while(S[i]){
		sum+=S[i]-'0';
		i++;
	}
	if(ori%sum==0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e4;

const ll inf = 1e18;

int n, m;
ll a[maxn], b[maxn], c[maxn];
ll dist[maxn];

void relax(ll& x, ll y) {
    x=max(x,y);
}

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

    cin>>n>>m;
    for (int i=0; i<m; i++) {
	cin>>a[i]>>b[i]>>c[i];
    }

    ll best = -inf;

    for (int i=1; i<=n; i++) {
	dist[i] = -inf;
    }

    dist[1] = 0;


    for (int iter=0; iter<n+10; iter++) {
	for (int i=0; i<m; i++) {
	    int from=a[i]; int to=b[i]; ll wei = c[i];
	    if (dist[from] > -inf) {
		relax(dist[to], dist[from]+wei);
	    }
	}
	best=max(best, dist[n]);
    }


    {
	ll prev=dist[n];
	for (int i=0; i<m; i++) {
	    int from=a[i]; int to=b[i]; ll wei = c[i];
	    if (dist[from] > -inf) {
		relax(dist[to], dist[from]+wei);
	    }
	}
	if (dist[n]>prev) out("inf");
    }


    out(best);
  

    return 0;
}


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

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; }

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 998244353LL;

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

struct mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    bool operator <(const mint& r){return this->x<r.x;}
    bool operator ==(const mint& r){return this->x==r.x;}
    bool operator !=(const mint& r){return this->x!=r.x;}
    void operator++() {
        x++;
    }
    void operator--() {
        x--;
        if(x<0) x += mod;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

template <typename T>
vector<T> finv(map<ll,T> m){
  vector<T> ret(200005);
  ret[0] = (T)1/m[0];
  for(int i = 1; i < 200005; i++){
    for(auto x:m){
      if(x.second!=0&&x.first<=i&&x.first!=0){
        ret[i] = (ret[i] - x.second*ret[i-x.first]);
      }
    }
    ret[i] /= m[0];
  }
  rep(i,200005) {
      if(ret[i]<0) ret[i] += mod;
  }
  return ret;
}

int main(){
    ll N,K;
    cin>>N>>K;
    vector<mint> cnt(200005);
    rep(i,K){
        ll l,r;
        cin>>l>>r;
        ++cnt[l];
        --cnt[r+1];
    }
    rep(i,200005) cnt[i] = -cnt[i];
    ++cnt[0];
    --cnt[1];
    map<ll,mint> m;
    rep(i,200005){
        if(cnt[i]!=(mint)0) m[i] = cnt[i];
    }
    vector<mint> ans = finv(m);
    vector<mint> anss(200005);
    rep(i,200004) anss[i+1] = ans[i];
    rep(i,200005) ans[i] -= anss[i];
    cout<<ans[N-1]<<endl;
}

Measured memory_bytes: 8020
//MISHON69
//DATE:6/22/2020
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,q;
  cin>>n>>k>>q;
  map<int,int>m;
  for(int i=0;i<q;i++){
    int temp;
    cin>>temp;
    m[temp]++;
  }
  for(int i=1;i<=n;i++){
    if((q-m[i])<k)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
  }
}  


Measured memory_bytes: 8284
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF = pow(10, 8);
int main(){
  int n;cin>>n;
  vector<vector<int> > edge(n, vector<int>());
  for(int i=0;i<n;i++){
    int u, k;cin>>u>>k;u--;
    for(int j=0;j<k;j++){
      int v;cin>>v;edge[i].push_back(v-1);
    }
  }
  vector<int> dis(n, INF);
  dis[0]=0;
  queue<int> que;
  que.push(0);
  while(que.size()){
    int v = que.front();que.pop();
    for(int &u : edge[v]){
      if(dis[u]>dis[v]+1){
        dis[u]=dis[v]+1;
        que.push(u);
      }
    }
  }
  for(int i=0;i<n;i++){
    if(dis[i]==INF)cout<<i+1<<" "<<-1<<endl;
    else cout<<i+1<<" "<<dis[i]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3144
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通り実装したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int h = scanner.nextInt(), w = scanner.nextInt(), n = scanner.nextInt();
			Map<String, Integer> map = new HashMap<>();
			IntStream.range(0, n).forEach(i -> {
				int a = scanner.nextInt(), b = scanner.nextInt();
				IntStream.rangeClosed(0, 2).filter(j -> (a - j > 0) && (a - j <= h - 2)).forEach(
						j -> IntStream.rangeClosed(0, 2).filter(k -> (b - k > 0) && (b - k <= w - 2)).forEach(k -> {
							String key = (a - j) + "_" + (b - k);
							map.put(key, map.getOrDefault(key, 0) + 1);
						}));
			});
			long[] results = new long[10];
			map.entrySet().stream().forEach(entry -> results[entry.getValue()]++);
			results[0] = (h - 2L) * (w - 2L) - map.size();
			Arrays.stream(results).forEach(System.out::println);
		}
	}
}


Measured memory_bytes: 170932
sx,sy,tx,ty = map(int, input().split())
y = ty-sy
x = tx-sx
print('U'*y+'R'*x+'D'*y+'L'*x+'D'+'R'*(x+1)+'U'*(y+1)+'LU'+'L'*(x+1)+'D'*(y+1)+'R')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
vector<string>s;
bool visit[405][405];
int h,w;
ll nb=0,nw=0;
void dfs(int y,int x){
    visit[y][x]=true;
    if(s[y][x]=='#')nb++;
    else nw++;
    for(int i=0;i<4;i++){
        int nextx=x+dx[i];
        int nexty=y+dy[i];
        if(nextx<0 or nextx>=w or nexty<0 or nexty>=h){
            continue;
        }
        if(visit[nexty][nextx])continue;
        if(s[nexty][nextx]==s[y][x])continue;
        dfs(nexty,nextx);
    }
}
int main(void){
    cin>>h>>w;
    s.resize(h);
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    ll ans=0;
    for(int y=0;y<h;y++){
        for(int x=0;x<w;x++){
            if(s[y][x]=='.')continue;
            if(visit[y][x])continue;
            nb=0;
            nw=0;
            dfs(y,x);
            ans+=nb*nw;
        }
    }
    cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 15616
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int q = in.nextInt();
            int[] trueAns = new int[n];
            for (int i = 0; i < q; i++) {
                int player = in.nextInt() - 1;
                trueAns[player]++;
            }
            for (int i = 0; i < n; i++) {
                int score = k - (q - trueAns[i]);
                if (score > 0)
                    out.println("Yes");
                else
                    out.println("No");
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}

Measured memory_bytes: 35676
#include <iostream>
using namespace std;
 
bool is_just(int a, int b, int c, int Y)
{
  if (a*10000 + b*5000 + c*1000 == Y) {
    return true;
  }
  return false;
}
 
int main(){
  int N,Y;
  cin >> N >> Y;
  for (int i=N;i>=0;--i){
    for (int j=N-i;j>=0;--j){
      int k=N-i-j;
      if (is_just(i, j, k, Y)) {
          cout << i << " " << j << " " << k;
          return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1;
  return 0;
}

Measured memory_bytes: 256
# C - Candles
N,K = map(int, input().split())
x =  list(map(int, input().split()))

shortest = float("inf")
for i in range(N - K + 1):
    left = x[i]
    right = x[i + K - 1]
    left_first = abs(left) + abs(left - right)
    right_first =  abs(right) + abs(left - right)
    shortest = min(shortest, left_first, right_first)
print(shortest)

Measured memory_bytes: 14228
N,*L = map(int, open(0).read().split())
A = [0]*N
B = [0]*N
n = 10**10
flag = False
for i,(a,b) in enumerate(zip(*[iter(L)]*2)):
  A[i] = a
  B[i] = b
  if a!=b:
    flag = True
  if a>b:
    n = min(n,b)
print(sum(A)-n if flag else 0)

Measured memory_bytes: 7444
#include <stdio.h>
#define N 100000
int main(void){
    int n;
    int i=0,cnt=0;
    int a[N];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    i=0;
    while(a[i]!=2){
        if(cnt==n)break;
        i=a[i]-1;
        cnt++;
    }
        if(a[i]==2)printf("%d\n",cnt+1);
    else printf("-1\n");
    return 0;
}

Measured memory_bytes: 512
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
// using namespace __gnu_pbds;
// template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;



  #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

  #define ff first
  #define ss second
  #define pb push_back
  #define pf push_front
  #define mp make_pair
  #define in insert
  #define ld long double


  #define TRACE
  #ifdef TRACE
  #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
  template <typename Arg1>
  void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
  }
  template <typename Arg1, typename... Args>
  void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
  }
  #else
  #define trace(...) 1
  #endif
  template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
  template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
  template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
  typedef long long int ll;

  typedef vector<int> vi;
  typedef vector<ll> vl;
  typedef vector<vi> vvi;
  typedef vector<vl> vvl;
  typedef pair<int,int> pii;
  typedef pair<ll,ll> pll;
  typedef vector<pii> vpii;
  typedef vector<pll> vpll;
  #define int ll
  const ll mod =998244353;
  const ll MAX_NODES =200001;
  const ll MAX_LOG =50;
  const ll maxn = 400000+10;
  #define endl '\n'
  ll power(ll x, ll n) {
	ll res = 1;
	for (; n > 0; n >>= 1) {
	if (n & 1) res = (res * x) % mod;
	x = (x * x) % mod;
	}
	return res;
}
  int32_t main()
{

  IOS
  int n,s;
  cin>>n>>s;
  int a[n];
  for(int i = 0;i<n;i++)
  {
    cin>>a[i];
  }
  int ans = 0;
  
  vector<vl>dp(n+1,vector<int>(s+2,0));
  dp[0][0] = 1;
  for(int i = 0;i<n;i++)
  {   
    for(int j = 0;j<=s+1;j++)
    {
      dp[i+1][j]= dp[i][j];
    }
    dp[i+1][0]++;
    for(int j = a[i];j<=s+1;j++)
    {
      dp[i+1][j]+=dp[i][j-a[i]];
      dp[i+1][j]%=mod;
    }
    ans+=(dp[i+1][s]);
    ans%=mod;
  }
    
  
  cout<<ans<<endl;
  
  
  
 
  
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
int main(){
    int w,h;
    cin >> w >> h;
    long long p[w],q[h];
    long long ans = 0;
    rep(i,w){
        cin >> p[i];
        ans+=p[i];
    }
    rep(i,h){
        cin >> q[i];
        ans+=q[i];
    }
    sort(q,q+h);
    long long sumq[h+1];
    sumq[0]=0;
    rep(i,h) sumq[i+1]=sumq[i]+q[i];
    rep(i,w){
        auto itr = lower_bound(q,q+h,p[i]);
        int k = itr-q;
        ans+=(sumq[k]+(h-k)*p[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
from collections import Counter

n = int(input())
V = list(map(int, input().split()))

odd = []
even = []

for m in range(0,n, 2):
    odd.append(V[m])
for m in range(1,n, 2):
    even.append(V[m])

odd_c = Counter(odd)
even_c = Counter(even)

odd_c_sort = sorted(odd_c.items(), key = lambda x:x[1], reverse = True)
even_c_sort = sorted(even_c.items(), key = lambda x:x[1], reverse = True)

if len(odd_c_sort) == len(even_c_sort) == 1:
    if odd_c_sort[0][0] == even_c_sort[0][0]:
        ans = n/2
    else:
        ans = 0
elif len(odd_c_sort) == 1:
    if odd_c_sort[0][0] == even_c_sort[0][0]:
        ans = n/2 - even_c_sort[1][1]
    else:
        ans = n/2 - even_c_sort[0][1]
elif len(even_c_sort) == 1:
    if even_c_sort[0][0] == odd_c_sort[0][0]:
        ans = n/2 - odd_c_sort[1][1]
    else:
        ans = n/2 - odd_c_sort[0][1]
else:
    if odd_c_sort[0][0] != even_c_sort[0][0]:
        ans = n - odd_c_sort[0][1] - even_c_sort[0][1]
    else:
        ans = min((n - odd_c_sort[0][1] - even_c_sort[1][1]), (n - odd_c_sort[1][1] - even_c_sort[0][1]))

print(int(ans))

Measured memory_bytes: 21944
#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()
typedef long long ll;
const int INF (1<<30);

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  ll ans = 0LL;
  vector<int> x(5*N, 0);
  for (int i = 0; i < N; i++) {
    if (A[i] > N) continue;
    ans += x[2*N + A[i] - i];
    x[2*N - A[i] -i]++;
  }

  cout << ans << endl;

  return 0;
}


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

#define LLINF (1LL<<60)
typedef long long ll;

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

//C++14 (GCC 5.4.1)
int main() {
    int r,D;
    ll X;
    cin >>r>>D >> X;

    //-----------------------------------
    rep(i,10){
        X=X*r-D;
        cout << X <<endl;
    }
    return (0);
}

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


int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int n;
	cin >> n;
	int W;
	cin >> W;

	vector<int> w(n), v(n);

	for (int i = 0; i < n; ++i) cin >> w[i] >> v[i];

	vector<vector<ll>> dp(n, vector<ll>(W + 1));
	
	dp[0][w[0]] = v[0];

	for (int i = 1; i < n; ++i) {
		for (int j = 0; j <= W; ++j) {
			dp[i][j] = dp[i - 1][j];
			if (j - w[i] >= 0) {
				dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
			}
		}
	}

	cout << *max_element(dp[n - 1].begin(), dp[n - 1].end()) << "\n";

}



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

int main(void){
	int time;
	int h, m, s;
	cin >> time;
	h = time / 3600;
	m = (time - h * 3600) / 60;
	s = (time - h * 3600 - 60 * m);
	cout << h << ":" << m << ":" << s << "\n";
	return 0;
}

Measured memory_bytes: 1164
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

R = list(reversed(B))
flag = True
for i in range(N):
  if A[i] == R[i]:
    flag = False
    break
if flag:
  print('Yes')
  print(*R)
  exit()

l1 = B[N//2:]  + B[:N//2]
l2 = B[N//2+1:]  + B[:N//2+1]
flag1 = True
for i in range(N):
  if A[i] == l1[i]:
    flag1 = False
    break
flag2 = True
for i in range(N):
  if A[i] == l2[i]:
    flag2 = False
    break
if (flag1==False) and (flag2==False):
  print('No')
elif flag1 == True:
  print('Yes')
  print(*l1)
else:
  print('Yes')
  print(*l2)

Measured memory_bytes: 40088
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tlll tuple<ll, ll, ll>

int main() {
    int l, x;
    cin >> l >> x;
    cout << (l * 500 >= x ? "Yes" : "No") << endl;

}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
 
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define For(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
 
int main() {
    int n, m, l;
    cin >> n >> m >> l;
    vector<vector<int> > m1, m2;
    vector<vector<long> > ans;
    REP(i,n) {
        vector<int> mm;
        REP(j,m) {
            int k;
            cin >> k;
            mm.push_back(k);
        }
        m1.push_back(mm);
    }
     
    REP(i,m) {
        vector<int> mm;
        REP(j,l) {
            int k;
            cin >> k;
            mm.push_back(k);
        }
        m2.push_back(mm);
    }
     
    REP(i,n) {
        vector<long> mm;
        REP(j,l) {
            long s = 0;
            REP(k,m) {
                s += m1[i][k] * m2[k][j];
            }
            mm.push_back(s);
        }
        ans.push_back(mm);
    }
     
    REP(i,n) {
        REP(j,l-1) {
            cout << ans[i][j] << " ";
        }
        cout << ans[i][l-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 3200
#include <stdio.h>
#include<stdlib.h>

#define MAX 10000
#define NIL -1

struct Node {
  int parent;
  int left;
  int right;
};

struct Node T[MAX];
int n;
int D[MAX];
int H[MAX];

void setDepth(int u, int d){

  if(u == NIL) return;
  D[u] = d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right, d+1);  
}

int setHeight(int u){

  int h1 = 0, h2 = 0;
  if(T[u].left != NIL)
    h1 = setHeight(T[u].left) + 1;
  if(T[u].right != NIL)
    h2 = setHeight(T[u].right) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u){

  if(T[u].parent == NIL) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL){
    return T[T[u].parent].left;
  }
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL){
    return T[T[u].parent].right;
  }
  return NIL;
}

void print(int u){

  int deg = 0;
  
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));

  if(T[u].left != NIL) deg++;
  if(T[u].right != NIL) deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if(T[u].parent == NIL) printf("root\n");
  else if(T[u].left == NIL && T[u].right == NIL) printf("leaf\n");
  else printf("internal node\n");
}

int main(){

  int i;
  int v, l, r;
  int root = 0;

  scanf("%d", &n);

  for(i=0; i<n; i++) T[i].parent = NIL;
  
  for(i=0; i<n; i++){
    scanf("%d %d %d", &v, &l, &r);
    T[v].left = l;
    T[v].right = r;
    if(l != NIL) T[l].parent = v;
    if(r != NIL) T[r].parent = v;
  }

  for(i=0; i<n; i++)
    if(T[i].parent == NIL) root = i;

  setDepth(root, 0);
  setHeight(root);

  for(i=0; i<n; i++) print(i);

  return 0;
}



Measured memory_bytes: 2044
N, K, S = map(int, input().split())
if S == 10 ** 9:
    ans = [S] * K + [S - 1] * (N - K)
else:
    ans = [S] * K + [10 ** 9] * (N - K)

for i in range(N):
    if i != N - 1:
        print(ans[i], end = ' ')
    else:
        print(ans[i])

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

int main() { /* ここに書く */
  
  int X,Y,max,min;
  cin >> X >> Y;
  
  max = X * 4;
  min = X * 2;
  
  if(Y % 2 == 1){
    cout << "No" << endl;
  }
  else if(min > Y  || Y > max){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }

}

Measured memory_bytes: 3632
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.Queue

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val S = sc.next.dropWhile(_ != '*')
    println(S.count(_ == ')') - S.count(_ == '('))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 45044
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int N;
	while(~scanf("%d", &N)) {
		int a; int d;
		scanf("%d%d", &a, &d);
		int Q;
		scanf("%d", &Q);
		vector<int> x(Q), y(Q), z(Q);
		for(int i = 0; i < Q; ++ i)
			scanf("%d%d%d", &x[i], &y[i], &z[i]), -- y[i], -- z[i];
		int K;
		scanf("%d", &K), -- K;
		vi ops;
		for(int i = Q - 1; i >= 0; -- i) {
			if(!(y[i] <= K && K <= z[i])) continue;
			if(x[i] == 0) {
				K = z[i] - K + y[i];
			} else if(x[i] == 1) {
				ops.push_back(1);
			} else if(x[i] == 2) {
				ops.push_back(2);
			}
		}
		reverse(all(ops));
		int val = a + d * K;
		each(i, ops) {
			if(*i == 1) {
				++ val;
			} else {
				val /= 2;
			}
		}
		printf("%d\n", val);
	}
	return 0;
}

Measured memory_bytes: 3476
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
using ll = long long;

int main(){
    int N,M;cin>>N>>M;
    vector<vector<int>> graph(N, vector<int>(0));
    for(int i = 0;i < M;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    queue<pair<int,int>> q;
    vector<int> result(N,-1);
    q.push(pair<int,int>{0,0});
    while(q.size() > 0){
        pair<int,int> p = q.front();q.pop();
        int room = p.first;
        if(result[room] != -1)continue;
        result[room] = p.second;
        for(int i = 0;i < graph[room].size();i++){
            if(graph[room][i] == p.second)continue;
            if(result[graph[room][i]] != -1)continue;
            q.push(pair<int,int>{graph[room][i], room});
        }
    }
    bool f = false;
    for(int i = 0;i < N;i++){
        if(result[i] == -1){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    for(int i = 1;i < N;i++){
        cout<<result[i]+1<<endl;
    }


}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////
#define pll pair<ll,ll>

ll N;

ll prmc,prnum[753];
vector<ll> prm,pr;
ll i, j, ans;
int main(){
    scanf("%lld",&N);
    fornum(i,2,N+1){
        //printf("%lld", i);
        ll ii = i;
        fornum(j,0,prmc){
            while(ii%prm[j]==0){
                ii /= prm[j];
                prnum[++pr[j]]++;
            }
        }
        if(ii!=1){
            prm.push_back(ii);
            pr.push_back(1);
            prmc++;
        }
    }
    /*
    fornum(i,0,prmc){
        printf("%lld:%lld ", prm[i], pr[i]);
    }
    printf("\n");
    for (i = 2; prnum[i];i++){
        printf("%lld:%lld ", i, prnum[i]);
    }*/

        ans += prnum[74];
    if(prnum[2]>=2)
        ans += prnum[24] * (prnum[2] - 1);
    if(prnum[4]>=2)
        ans += prnum[14] * (prnum[4] - 1);
    if(prnum[4]>=2&&prnum[2]>=3)
        ans += prnum[4] * (prnum[4] - 1)/2*(prnum[2]-2);
    printf("%lld", ans);
    return 0;
}

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

using namespace std;

int n, k;
vector<long long> pre, suf;
long long total, pre_begin, pre_end;
const int MOD = 1000000007;

int main() {
  scanf("%d %d", &n, &k);
  long long sum = 0;
  for (int i = 0; i <= n; i++) {
    sum += i;
    if (i >= k - 1) {
      pre.push_back(sum);
    }
  }
  sum = 0;
  for (int i = 0; i <= n; i++) {
    sum += n - i;
    if (i >= k - 1) {
      suf.push_back(sum);
    }
  }
  for (int i = 0; i < pre.size(); i++) {
    total += suf[i] - pre[i] + 1;
  }
  printf("%d\n", total % MOD);
}


Measured memory_bytes: 7448
#include<stdio.h>

int main()
{
	int i,j,n, m, x, a[100],cost1,cost2;

	scanf("%d%d%d", &n, &m, &x);

	for (i = 0; i < m; i++)
		scanf("%d", &a[i]);

	cost1 = 0;
	cost2 = 0;

	for (i = x; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			if (a[j] == i)
				cost1++;
		}
	}

	for (i = x; i > 0; i--)
	{
		for (j = 0; j < m; j++)
		{
			if (a[j] == i)
				cost2++;
		}
	}

	if (cost1<cost2)
		printf("%d\n", cost1);
	else
		printf("%d\n", cost2);

	return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
from collections import defaultdict
d = defaultdict(int)
over = 0
for i in a:
    lv = i//400
    if lv < 3200//400 and not d[lv]:
        d[lv] = True
    if lv >= 3200//400:
        over += 1

syurui = sum(d.values())
print(max(1, syurui), syurui+over)

Measured memory_bytes: 3316
#include <iostream>

int main()
{
    using namespace std;

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    //Normalize init to 0
    tx = tx - sx;
    ty = ty - sy;

    //container for moves
    string sDirect("");
    //1st move must go R by tx,
    for (int i=0;i < tx;++i)
    {
        sDirect += string("R");
    }
    //then go U by ty
    for (int i=0;i < ty;++i)
    {
        sDirect += string("U");
    }

    if ((tx == 1) || (ty == 1))
    {
        //cannot go around
        //2nd move
        for (int i=0;i < tx;++i)
        {
            sDirect += string("L");
        }
        //then go U by ty
        for (int i=0;i < ty;++i)
        {
            sDirect += string("D");
        }

        //3rd move
        sDirect += string("L");
        for (int i=0;i < ty+1;++i)
        {
            sDirect += string("U");
        }
        for (int i=0;i < tx+1;++i)
        {
            sDirect += string("R");
        }        
        sDirect += string("D");
    }
    else
    {
        //Short cut available
        //2nd move
        sDirect += string("L");
        //Down for ty - 1
        //then go D by ty
        for (int i=0;i < ty - 1;++i)
        {
            sDirect += string("D");
        }
        //Left by tx - 1
        for (int i=0;i < tx - 1;++i)
        {
            sDirect += string("L");
        }
        sDirect += string("D");

        //3rd move
        sDirect += string("L");
        //go around
        sDirect += string("UU");
        //back to y = 0
        sDirect += string("R");
        if (tx <= ty)
        {
            for (int i=0;i < ty-1;++i)
            {
                sDirect += string("U");
            }
            //go by tx
            for (int i=0;i < tx;++i)
            {
                sDirect += string("R");
            }    
        }
        else
        {
            for (int i=0;i < tx-2;++i)
            {
                sDirect += string("R");
            }
            //go by tx
            for (int i=0;i < ty-1;++i)
            {
                sDirect += string("U");
            }  
            sDirect += string("RR");
        }
        

        sDirect += string("D");
    }    

    //4th move
    sDirect += string("R");
    //go around
    for (int i=0;i < ty+1;++i)
    {
        sDirect += string("D");
    }
    for (int i=0;i < tx+1;++i)
    {
        sDirect += string("L");
    }    
    sDirect += string("U");

    cout << sDirect << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,min,max,i,s;
  long long sum = 0;
  cin >> n;
  cin >> s;
  min = s;
  max = s;
  sum = s;
  for(i=0;i<n-1;i++){
    cin >> s;
    if(s>max) max=s;
    if(min>s) min=s;
    sum = sum+s;
  }
  cout << min << " " << max << " " << sum << endl;
  return 0;
}



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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()

ans = set()
def rec(i, S):
    if S in ans:
        return
    if i == N:
        ans.add(S)
        return
    # 今までに出現した文字は全部追加できる
    for c in S:
        rec(i+1, S+c)
    # 今までに出現した中で最大の文字の次も追加できる
    li = sorted(S)
    rec(i+1, S+chr(ord(li[-1])+1))
rec(1, 'a')
ans = sorted(ans)
[print(s) for s in ans]


Measured memory_bytes: 78812
n, k, q = [int(el) for el in input().split(' ')]

ans = [0]*q
for i in range(0, q):
	ans[i] = int(input())

A = [k-q]*n
for i in range(0, q):
	A[ans[i]-1] += 1

for i in range(0, n):
	if A[i] > 0:
		print("Yes")
	else:
		print("No")



Measured memory_bytes: 10552
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}
 
ll inv(ll base) {
    int g = MOD, r = base, x = 0, y = 1;
    while (r != 0) {
        int q = g / r;
        g %= r; swap(g, r);
        x -= q * y; swap(x, y);
    }
    return x < 0 ? x+MOD : x;
}
 
ll mul(ll A, ll B) {
	return (A*B)%MOD;
}
 
ll add(ll A, ll B) {
	return (A+B)%MOD;
}
 
ll dvd(ll A, ll B) {
    return mul(A, inv(B));
}
 
ll sub(ll A, ll B) {
    return (A-B+MOD)%MOD;
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
    int N; cin >> N; int P; cin >> P;
    string S; cin >> S;
    if (P == 5 || P == 2) {
        ll ans = 0;
        F0R(i, N) {
            if ((S[i] - '0') % P == 0) {
                ans += i+1;
            }
        }
        cout << ans << endl;
        return 0;
    }
 
    ll counts[P]; F0R(i, P) counts[i] = 0;
    counts[0] = 1;
    int cur = 0;
    MOD = P;
    F0R(i, N) {
        cur *= 10; cur += S[i] - '0'; cur %= MOD;
        int val = modExp(10, N-1-i) * cur; val %= MOD;
        counts[val]++;
    }
 
    ll ans = 0;
    F0R(i, P) ans += (counts[i] * (counts[i] - 1)) / 2;
 
    cout << ans << endl;
	
	return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int bitcount(int val)
{
  int ret = 0;
  while (val > 0) {
    ret += (1 & val);
    val >>= 1;
  }
  return ret;
}

int main()
{
  int n; scanf("%d", &n);
  vector<int> F(n);
  for (int i = 0; i < n; ++i) {
    int shift = 0;
    for (int j = 0; j < 10; ++j) {
      int b; scanf("%d", &b);
      shift = (shift << 1) | b;
    }
    F[i] = shift;
  }

  vector<vector<int> > P(n, vector<int>(11));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 11; ++j) {
      scanf("%d", &P[i][j]);
    }
  }

  int ans = -INF;
  for (int pat = 1; pat < 1024; ++pat) {
    int profit = 0;
    for (int j = 0; j < n; ++j) {
      int val = pat & F[j];
      int cnt = bitcount(val);
      profit += P[j][cnt];
    }
    ans = max(ans, profit);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
import java.io.*;

public class Main {
  
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s = r.readLine();
    s = r.readLine();
    String sl[] = s.split(" ");
    
    System.out.println(s.contains("Y") ? "Four" : "Three");
  }
}


Measured memory_bytes: 21588
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define pi pair<int,int>
#define fi first
#define se second

#define FOR(var, to)          for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)

#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)

#define MOD 1000000007
#define INF (1 << 30)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

static inline s64 rs64() {
  s64 a;
  scanf("%" SCNd64, &a);
  return a;
}

static inline void wi(int a) {
  printf("%d", a);
}

static inline void wu64(u64 a) {
  printf("%" PRIu64, a);
}

static inline void ws64(s64 a) {
  printf("%" PRId64, a);
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
    int a = ri();
    int b = ri();
    int c = ri();
    int x = ri();
    int y = ri();
    int res = min(min(x*a+y*b, c*2*max(x,y)), c*2*min(x,y)+((x>y)?a:b)*(max(x,y)-min(x,y)));
    cout << res << endl;
 return 0;
}


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

int main(){
    std::vector<int> vec(3);
    std::cin >> vec.at(0) >> vec.at(1) >> vec.at(2);

    std::sort(vec.begin(), vec.end());
    std::cout << vec.at(2) * 10 + vec.at(0) + vec.at(1) << std::endl;

    return 0;
}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,A,B=MI()
    ans=0
    rep=N//(A+B)
    ans+=rep*A
    res=N-rep*(A+B)
    ans+=min(res,A)
    print(ans)

main()


Measured memory_bytes: 38456
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

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

  ll n;
  cin>>n;
  
  ll sum=0;
  for(ll k=1;k<=n;k++){
    ll x=n/k;
    sum+=k*x*(x+1)/2;
  }
  
  cout<<sum<<endl;

  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdint>

using namespace std;

const int max_n = 100000;

int a[max_n];
int n;

int64_t max_area() {
	int pairs[2];
	int n_pairs = 0;

	int c = 0;
	int v = 0;
	for (int i = 0; i < n && n_pairs < 2; i++) {
		if (v == a[i]) {
			c++;
		}
		else {
			v = a[i];
			c = 1;
		}

		if (c == 2) {
			pairs[n_pairs] = v;
			n_pairs++;

			v = 0;
		}
	}

	if (n_pairs < 2) {
		return 0;
	}
	else {
		return (int64_t)pairs[0] * pairs[1];
	}
}

int main() {

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	sort(a, a + n, greater<int>());

	cout << max_area() << "\n";

	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){
  int L,R,d, i,ans;
	ans = 0;  
  scanf("%d""%d""%d", &L, &R, &d);
  
  			for(i=L;i<R+1; i++){
              	if(i % d == 0){
    				ans = ans + 1;
            	}
        	}
  		
  
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
N=1000ならN*Nで順番付けできそう
違うかな
BFSみたいな

1-2
2-1ならOK

1-2
2-3
3-2
ならOK

みたいな
先頭同士でペアが作れるかどうか

a<bでpair{a,b}を格納して、ペアになったらOKとか
TLEなんだが
N^3になるのか
マッチしたやつだけ再検査すればいいのかな
毎回入れなおしがきつい
*/
int main(){
  ll N; cin>>N;
  ll end=N*(N-1);
  end/=2;
  vector<queue<ll>> Q(N+1);
  queue<pair<ll,ll>> next_Q;
  for(ll i=1; i<=N; i++){
    for(ll j=1; j<N; j++){
      ll a; cin>>a;
      Q[i].emplace(a);
    }
  }
  ll day=1,cnt=0;
  //初期
  for(ll i=1; i<=N; i++){
    ll a=i, b=Q[i].front();
    if(a>b) swap(a,b);
    next_Q.push({a,b});
  }
  set<pair<ll,ll>> S;
  while(!next_Q.empty()){
//cout<<"day:"<<day<<" cnt:"<<cnt<<endl;
    ll Qsz=next_Q.size();
//cout<<"Qsz:"<<Qsz<<endl;    
    for(ll i=0; i<Qsz; i++){
      auto n=next_Q.front();
      ll n1=n.first, n2=n.second;
//cout<<"n1:"<<n1<<" n2:"<<n2<<endl;      
      next_Q.pop();
      auto IT=S.find({n1,n2});
      if(IT!=S.end()){
        Q[n1].pop();
        Q[n2].pop();
        S.erase(IT);
        cnt++;
        ll m1=Q[n1].front();
        if(m1>0){
          if(n1>m1) swap(n1,m1);
          next_Q.push({n1,m1});
        }
        ll m2=Q[n2].front();
        if(m2>0){
          if(n2>m2) swap(n2,m2);
          next_Q.push({n2,m2});
        }
      }
      else S.insert({n1,n2});
    }
    if(cnt==end) break;
    day++;
  }
  if(cnt==end) cout<<day<<endl;
  else cout<<-1<<endl;
}

Measured memory_bytes: 8960
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(), (v).end()

int main() {
  int h, n;
  cin >> h >> n;
  int inf = 1001001001;
  vector<vector<int>> dp(n + 5, vector<int>(h + 1, inf));
  dp[0][0] = 0;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    for(int j = 0; j <= h; j++) {
      int nj = max(j - a, 0);
      dp[i + 1][j] = min(dp[i][j], dp[i + 1][nj] + b);
    }
  }
  cout << dp[n][h] << endl;
}


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

int calc(int s, int d)
{
	int res = 0;
	if (s == d) return 0;
	if (s & 1){
		s += 1;
		res++;
	}
	if (d & 1){
		d -= 1;
		res++;
	}
	return res + calc(s / 2, d / 2);
}

int main()
{
	int n;
	scanf("%d", &n);
	while (n--){
		int s, d;
		scanf("%d %d", &s, &d);
		int res;
		if (s < 0 ^ d < 0){
			res = calc(0, abs(s)) + calc(0, abs(d));
			printf("%d\n", res);
			continue;
		}
		if (s < 0 && d < 0){
			swap(s, d);
			s = -s;
			d = -d;
		}
		res = calc(s, d);
		printf("%d\n", res);
	}
	
	return 0;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

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

    bool jdg=false;
    int cnt=0,next=1;

    rep(i,n){
        int a;
        cin>>a;

        if(a==next){
            jdg=true;
            cnt++;
            next++;
        }
    }

    if(jdg){
        cout<<n-cnt<<endl;
        return 0;
    }

    cout<<-1<<endl;
}


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

def solve(a, b, c, d, e, f)
  x = ((e*c-b*f)*1.0/(a*e-b*d)*1000).round/1000.0
  y = ((a*f-d*c)*1.0/(a*e-b*d)*1000).round/1000.0
  return x, y
end

while line = gets
  line.chomp!
  a, b, c, d, e, f = line.chomp.split(" ").map{|item| item.to_f}
  result = solve(a, b, c, d, e, f)
  puts "%.3f %.3f" % [result[0], result[1]]
end

Measured memory_bytes: 6156
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 100000007;
const int INF = 1 << 29;
const double EPS = 1e-9;


int main() {

	cin.tie(0);
  	ios::sync_with_stdio(false);

	lint X, Y, Z, K;
	cin >> X >> Y >> Z >> K;

	vector<lint> A(X), B(Y), C(Z), ans(K);
	FOR(i, 0, X)cin >> A[i];
	FOR(i, 0, Y)cin >> B[i];
	FOR(i, 0, Z)cin >> C[i];

	sort(A.begin(), A.end(), greater<lint>());
	sort(B.begin(), B.end(), greater<lint>());
	sort(C.begin(), C.end(), greater<lint>());


	FOR(a,0,X)FOR(b,0,Y)FOR(c,0,Z){
		if ((a + 1)*(b + 1)*(c+1)<=K) ans.emplace_back(A[a] + B[b] + C[c]);
	}

	sort(ans.begin(), ans.end(), greater<lint>());
	FOR(i, 0, K) cout << ans[i] << "\n";
	return 0;
}


Measured memory_bytes: 1960