akhauriyash/Code-Regression huggingface dataset:
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
#define F first
#define S second
#define MK make_pair
const ll E=1e17+7;
const ll MOD=1000000007;





int main(){
    string a,b;
    bool j=false;
    cin>>a>>b;
    ll s=a.size();
    for(int i=0;i<s && !j;i++){
        bool same=true;
        for(int t=0;t<s && same;t++){
            if(a[(i+t)%s]!=b[t]){same=false;}
        }
        if(same){j=true;}
    }
    if(j){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

void print_ans(bool flag){
    if(flag){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }   
}


int main(){
    int k, x;
    cin >> k >> x;
    print_ans(500*k >= x);
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

n, k = map(int, input().split())
ab = [list(map(lambda x:int(x)-1, input().split())) for _ in range(n-1)]

mod = 10**9+7

def dfs(K, graph, now, src):
    if src == -1:
        use_num_color = k-1
    else:
        use_num_color = k-2

    if len(graph[now])>k:
        return 0
    
    num_cases = 1
    for e in graph[now]:
        if e==src: continue
        num_cases *= use_num_color
        num_cases %= mod
        use_num_color -= 1

    for e in graph[now]:
        if e==src: continue
        num_cases *= dfs(K, graph, e, now)
        num_cases %= mod

    return num_cases

def make_graph(list):
    n = len(list)
    graph = [[] for _ in range(n+1)]
    for a, b in list:
        graph[a].append(b)
        graph[b].append(a)
    return graph

graph = make_graph(ab)
ans = k*dfs(k, graph, 0, -1)
ans %= mod
print(ans)

Measured memory_bytes: 101864
from sys import stdin
from itertools import permutations

n = int(stdin.readline().strip())
rank = dict([(val, i) for i, val in enumerate(sorted([int(''.join([str(v) for v in l])) for l in permutations(list(range(1, n+1)), n)])[::-1])])
p_rank = rank[int(''.join(stdin.readline().split()))]
q_rank = rank[int(''.join(stdin.readline().split()))]

print(abs(p_rank - q_rank))

Measured memory_bytes: 16512
#include <iostream>

using namespace std;

int main()
{
	int N, T;
	int ret = -1;

	cin >> N >> T;

	int* c = new int[N];
	int* t = new int[N];

	for (int i = 0; i < N; i++) cin >> c[i] >> t[i];

	for (int i = 0; i < N; i++) {
		if (t[i] > T) continue;
		if (ret == -1) ret = c[i];
		else if (c[i] < ret) ret = c[i];
	}

	if (ret == -1) cout << "TLE" << endl;
	else cout << ret << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;
  vector<ll> A;
  ll a;
  for(int i=1;i<=N;i++){
    cin >> a;
    A.push_back(a);
  }
  sort(A.begin(),A.end());
  ll cnt=A[0];
  ll ans=1;
  for(int i=1;i<N;i++){
    if(cnt*2<A[i]){
      ans=1;
      cnt+=A[i];
    }else{
      ans++;
      cnt+=A[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1400
fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    var a = 0
    var b = 0
    var ab = 0
    var count = 0
    repeat(n) {
        val s = readLine() ?: return
        val f = s.first()
        val l = s.last()
        if (f == 'B' && l == 'A') {
            ab++
        } else {
            if (f == 'B') {
                b++
            } else if (l == 'A') {
                a++
            }
        }
        0.until(s.length - 1).forEach {
            if (s[it] == 'A' && s[it + 1] == 'B') {
                count++
            }
        }
    }
    if (ab > 0) {
        count += (ab - 1)
        if (a > 0 || b > 0) {
            count += Math.min(a + 1, b + 1)
        }
    } else {
        count += Math.min(a, b)
    }

    println(count.toString())
}


Measured memory_bytes: 43176
n = int(input())
s = []
for i in range(n):#h:高さ
    s.append([int(m) for m in input().split()])

for i in range(n):
    if i == 0:
        if not(0 - s[i][0] <= s[i][1] <= 0 + s[i][0]) or not(0 - s[i][0] <= s[i][2] <= 0 + s[i][0]):
            print("No")
            exit()
        else:
            if (s[i][0] % 2 == 0 and (s[i][1] + s[i][2]) % 2 != 0) or (s[i][0] % 2 != 0 and (s[i][1] + s[i][2]) % 2 == 0):
                print("No")
                exit()
    else:
        if not(s[i - 1][1] - (s[i][0] - s[i - 1][0]) <= s[i][1] <= s[i - 1][1] + (s[i][0] - s[i - 1][0])) or not(s[i - 1][2] - (s[i][0] - s[i - 1][0]) <= s[i][2] <= s[i - 1][2] + (s[i][0] - s[i - 1][0])):
            print("No")
            exit()
        else:
            if (s[i][0] % 2 == 0 and (s[i][1] + s[i][2]) % 2 != 0) or (s[i][0] % 2 != 0 and (s[i][1] + s[i][2]) % 2 == 0):
                print("No")
                exit()

print("Yes")

Measured memory_bytes: 21156
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int n;
vector<int> g[200020];
int d[200020];
void dfs(int x, int p){
    for(auto y:g[x]){
        if(y==p) continue;
        d[y]=d[x]+1;
        dfs(y, x);
    }
}
int main()
{
    cin>>n;
    if(n==2){
        cout<<1<<" "<<2<<endl;
        return 0;
    }
    int cntl=0;
    for(int i=0; i<n-1; i++){
        int a, b; cin>>a>>b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i=0; i<n; i++){
        if(g[i].size()==1) cntl++;
    }
    if(cntl==n-1){
        for(int i=0; i<n; i++) cout<<i+1<<" ";
        cout<<endl;
        return 0;
    }
    dfs(0, -1);
    int cnt[2]={};
    int ans[200020];
    for(int i=0; i<n; i++) cnt[d[i]&1]++;
    if(cnt[0]<=n/3){
        int x=3;
        vector<int> v;
        for(int i=1; i<=n; i++) if(i%3!=0) v.push_back(i);
        int k=0;
        for(int i=0; i<n; i++){
            if(d[i]%2==0){
                ans[i]=x; x+=3;
            }else{
                if(k<v.size()){
                    ans[i]=v[k]; k++;
                }else{
                    ans[i]=x; x+=3;
                }
            }
        }
    }else if(cnt[1]<=n/3){
        int x=3;
        vector<int> v;
        for(int i=1; i<=n; i++) if(i%3!=0) v.push_back(i);
        int k=0;
        for(int i=0; i<n; i++){
            if(d[i]%2==1){
                ans[i]=x; x+=3;
            }else{
                if(k<v.size()){
                    ans[i]=v[k]; k++;
                }else{
                    ans[i]=x; x+=3;
                }
            }
        }
    }else{
        int x=1, y=2, z=3;
        for(int i=0; i<n; i++){
            if(d[i]%2==0){
                if(y<=n){
                    ans[i]=y; y+=3;
                }else{
                    ans[i]=z; z+=3;
                }
            }else{
                if(x<=n){
                    ans[i]=x; x+=3;
                }else{
                    ans[i]=z; z+=3;
                }
            }
        }
    }
    for(int i=0; i<n; i++){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
	return 0;
}


Measured memory_bytes: 19072
def Bingo():
    for a in bingo:
        if sum(a) == 0:
            return True
    for b in range(len(bingo)):
        if sum([bingo[i][b] for i in range(3)]) == 0:
            return True
    if bingo[0][0] + bingo[1][1] + bingo[2][2] == 0:
        return True
    if bingo[1][1] + bingo[2][0] + bingo[0][2] == 0:
        return True
    return False

bingo = [[int(i) for i in input().split()] for i in range(3)]
valid = False
N = int(input())
for a in range(N):
    num = int(input())
    for b in range(len(bingo)):
        if num in bingo[b]:
            bingo[b][bingo[b].index(num)] = 0
    if Bingo():
        valid = True
        break
if valid:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
struct node{
    int l, r;
};
const int N = 1e6 + 7;
string s[N];
int n;

vector<node>a;
vector<node>b;

bool cmp(node x, node y){
    return x.r < y.r;
}

bool cmp1(node x, node y){
    return x.l < y.l;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout .tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> s[i];
        int len = s[i].length();
        int l =0, r = 0;
        for(int j = 0; j < len; j++){
            if(s[i][j] == '(') l++;
            else if(l) l--;
            else r++;
        }
        if(l >= r) a.push_back({l, r});
        else b.push_back({l, r});
    }
    sort(a.begin(), a.end(), cmp);
    sort(b.begin(), b.end(), cmp1);
    int sum = 0, ok = 0;
    for(int i = 0; i < a.size(); i++){
        sum -= a[i].r;
        if(sum < 0){
            ok = 1;
            break;
        }
        sum += a[i].l;
    }
    int sum1 = 0;
    for(int i = 0; i < b.size(); i++){
        sum1 -= b[i].l;
        if(sum1 < 0){
            ok = 1;
            break;
        }
        sum1 += b[i].r;
    }
    if(ok){
       cout << "No\n";
    }else{
        if(sum == sum1){
            cout << "Yes\n";
        }else{
            cout << "No\n";
        }
    }

}

Measured memory_bytes: 42508
from functools import reduce 
from operator import add
n, a, b = map(int, input().split())

n_cond = 0

for i in range(1, n+1):
  i_str = str(i)

  if len(i_str) == 1:
    order_sum = i
    
  else:
    temp = list(map(int, i_str))
    order_sum = reduce(add, temp)
    
  if order_sum >= a and order_sum <= b:
    n_cond += i
print(n_cond)

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

minColor = min(A)
maxColor = max(A)

if minColor == maxColor:
    if minColor == N - 1:  # 各色の猫が1匹ずつ
        print('Yes')
    elif minColor * 2 <= N:  # 各色の猫が2匹以上
        print('Yes')
    else:
        print('No')
    exit()

if minColor + 1 != maxColor:
    print('No')
    exit()

minCnt = 0
maxCnt = 0

for a in A:
    if a == minColor:
        minCnt += 1
    elif a == maxColor:
        maxCnt += 1
    else:
        print('No')
        exit()

# minCnt : 1匹だけの色
# maxCnt : 2匹以上の色
# 全体でmaxColor個の色

if (maxColor - minCnt) * 2 <= maxCnt and maxColor >= minCnt + 1:
    print('Yes')
else:
    print('No')


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

int main(){
  int x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	var k int
	fmt.Scan(&s, &k)

	cs := []byte(s)
	for i := 0; i < len(s); i++ {
		c := int(s[i] - 'a')
		d := 26 - c
		if 0 < c && d <= k {
			k -= d
			cs[i] = 'a'
		}
	}

	if k > 0 {
		c := cs[len(cs)-1]
		cs[len(cs)-1] = byte('a' + (int(c-'a') + (k % 26)))
	}

	fmt.Println(string(cs))
}


Measured memory_bytes: 1664
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::suspicious_arithmetic_impl)]

// using Rust(1.42.0)
// My Library Repo is at "https://github.com/Loptall/prcn_lib"
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"

/*
    AtCoder Language Update 2020204 お疲れ様でした! 有難いです
*/

// Dep crates are...
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::{i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_integer::{binomial, gcd, lcm, Integer};
use permutohedron::Heap;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

// code...
fn main() {
    input! {
        n: usize,
        a: [usize; n]
    }

    let mut map = BTreeMap::new();
    let mut ans = 0usize;

    for (i, e) in a.iter().enumerate().map(|(i, &e)| (i as i64, e as i64)) {
        if map.contains_key(&(e + i + 1)) {
            *map.get_mut(&(e + i + 1)).unwrap() += 1;
        } else {
            map.insert(e + i + 1, 1);
        }
        if map.contains_key(&(i + 1 - e)) {
            ans += map[&(i + 1 - e)];
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 12008
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    string S; cin >> S;
    if (S[S.length()-1] == 's') cout << S << "es" << endl;
    else cout << S << "s" << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

//ここから編集
template<typename T>
struct LazySegmentTree{
  const int INF = numeric_limits<int>::max();
  int n0;
  vector<T> node, lazy;

  LazySegmentTree(vector<T> &v){
    int n = v.size();
    n0 = 1;
    while(n0 < n) n0 <<= 1;
    node.resize(2*n0-1);
    lazy.assign(2*n0-1, INF);
    for(int i=0; i<n; i++) node[i+n0-1] = v[i];
    for(int i=n0-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
  }

  void eval(int k, int p){
    if(lazy[k] == INF) return;
    
    if(k < n0-1){
      lazy[k*2+1] = lazy[k];
      lazy[k*2+2] = lazy[k];
    }
    node[k] = lazy[k] * p;
    lazy[k] = INF;
  }

  void update(int a, int b, T x, int k, ll l, ll r){
    eval(k, r-l);
    if(a <= l && r <= b){
      lazy[k] = x;
      eval(k, r-l);
    }else if(a < r && l < b) {
      update(a, b, x, k*2+1, l, (l+r)/2);
      update(a, b, x, k*2+2, (l+r)/2, r);
      node[k] = node[k*2+1] + node[k*2+2];
    }
  }

  void update(int l, int r, T x) { update(l, r, x, 0, 0, n0); }

  T query(int a, int b, int k, ll l, ll r){
    eval(k, r-l);
    if(r <= a || b <= l) return 0;
    else if(a <= l && r <= b){
      return node[k];
    }else{
      T vl = query(a, b, k*2+1, l, (l+r)/2);
      T vr = query(a, b, k*2+2, (l+r)/2, r);
      return vl+vr;
    }
  }
  T query(int l, int r) { return query(l, r, 0, 0, n0); }

  inline T operator[](int a) { return query(a, a + 1); }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(5);
  
  int N, Q; cin >> N >> Q;
  vector<ll> a(N, 0);
  LazySegmentTree<ll> seg(a);

  REP(i,Q){
    int q; cin >> q;
    if(q == 0){
      int s, t, x;
      cin >> s >> t >> x;
      seg.update(s, t+1, x);
    }else{
      int s, t; cin >> s >> t;
      cout << seg.query(s, t+1) << endl;
    }
    // for(int j=0; j<N; j++){
    //   cout << seg[j] << " ";
    // }
    // cout << endl;
  }

  return 0;
}


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

int main(){
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    for (int i = 0; i < N - 2;i++){
        if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C')
            ans++;
    }
        cout << ans << endl;
    return 0;
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << (a+b==c||b+c==a||c+a==b?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector<double>a(N);
  vector<string>b(N);
  for(int i=0;i<N;i++)
    cin>>a.at(i)>>b.at(i);
  double sum=0;
  for(int i=0;i<N;i++){
    if(b.at(i)=="JPY")
      sum+=a.at(i);
    else
      sum+=a.at(i)*380000;
  }
  cout<<sum<<endl;
 
}
  


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <cmath>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

vector<ll> rotateS(vector<ll> arg) {
  vector<ll> ans = arg;
  ll tmp = ans[0];
  ans[0] = ans[4];
  ans[4] = ans[5];
  ans[5] = ans[1];
  ans[1] = tmp;
  return ans;
}

vector<ll> rotateE(vector<ll> arg) {
  vector<ll> ans = arg;
  ll tmp = ans[0];
  ans[0] = ans[3];
  ans[3] = ans[5];
  ans[5] = ans[2];
  ans[2] = tmp;
  return ans;
}

void solve() {
  vector<ll> foo(6);
  vector<ll> bar(6);
  rep (i, 6) cin >> foo[i];
  rep (i, 6) cin >> bar[i];
  rep (k, 10) {
    rep (i, 10) {
      rep (j, 4) {
        if (foo == bar) {
          cout << "Yes" << endl;
          return;
        }
        bar = rotateS(bar);
      }
      bar = rotateE(bar);
    }
    bar = rotateS(bar);
  }
  cout << "No" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int a,b;
  cin >>a >>b;
  ostringstream ossA;
  ostringstream ossB;
  ossA << a;
  ossB<<b;
  string aa = "";
  string bb ="";
  rep(i,b)aa+=ossA.str();
  rep(i,a) bb+=ossB.str();

  if(a<b) cout<<aa<<endl;
  else cout<<bb<<endl;
  return 0;
}

Measured memory_bytes: 256
/*
 * ITP1_3C.c
 *
 *  Created on: 2016/05/28
 *      Author: TakaakiShogaki
 */

#include<stdio.h>

int main(){
	int x,y,k;

	scanf("%d %d",&x,&y);
	while(x!=0 || y!=0){
		if(x>y){
		 k=x;
		 x=y;
		 y=k;
		}
		printf("%d %d\n",x,y);
		scanf("%d %d",&x,&y);
	}
return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <climits>
#include <algorithm>
using namespace std;

// 入力
int n, W;
int weight[110], value[110];

// DPテーブル
int dp[110][10010];

int main() {
	cin >> n >> W;
	for (int i = 0; i < n; ++i) cin >> value[i] >> weight[i];

	// DP初期条件: dp[0][w] = 0
	for (int w = 0; w <= W; ++w) dp[0][w] = 0;

	// DPループ
	for (int i = 0; i < n; ++i) {
		for (int w = 0; w <= W; ++w) {
			if (w >= weight[i]) dp[i + 1][w] = max(dp[i][w - weight[i]] + value[i], dp[i][w]);
			else dp[i + 1][w] = dp[i][w];
		}
	}

	cout << dp[n][W] << endl;
return 0;
}


Measured memory_bytes: 7060
class Pair
  attr_accessor :first,:second
end

def make_pair(x,y)
  temp = Pair.new
  temp.first = x
  temp.second = y
  return temp
end

n, m = gets.chomp.split.map(&:to_i)
s = []
n.times do |i|
  a, b = gets.chomp.split.map(&:to_i)
  s.push(make_pair(a, b))
end
s = s.sort{|i, j| i.first <=> j.first}
c = 0
n.times do |i|
  if m >= s[i].second
    m -= s[i].second
    c += s[i].first * s[i].second
  else
    s[i].second.times do |j|
      if m > 0
        c += s[i].first
        m -= 1
      else
        break
      end
    end
  end
end
p c
exit

Measured memory_bytes: 13160
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555;
const double PI = acos(-1.0);

void solve()
{
	ll a, b;
	cin >> a >> b;
	ll gc = __gcd(a, b);
	vector<ll> v, sv;
	for(ll i = 1; i <= sqrt(gc); ++i){
		if(gc % i == 0){
			v.pb(i);
			if(gc / i != i) v.pb(gc / i);
		}
	}
	sort(all(v));
	int cnt = 0;
	for(int i = 0; i < sz(v); ++i){
		bool ok = 0;
		for(int j = 0; j < i; ++j){
			if(__gcd(v[i], v[j]) != 1) ok = 1;
		}
		cnt += !ok;
	}
	cout << cnt;
}
  
int main()
{
    Red;
    solve();
    return 0;
}

Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class ABC083BSomeSums {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt(), a = in.nextInt(), b = in.nextInt();
            int ans = 0;
            for (int i = 1; i <= n; i++) {
                int sum = 0, d = i;
                while (d > 0) {
                    sum += d % 10;
                    d /= 10;
                }
                if (a <= sum && sum <= b) {
                    ans += i;
                }
            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

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

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

int main() {
    int w, h, x, y, r; cin >> w >> h >> x >> y >> r;
    
    if((x-r<0) || (y-r<0) || (x+r>w) || (y+r>h)) cout << "No" << endl;
    else cout << "Yes" << endl;
    
    return 0;
}


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

using namespace std;
#define int long long
typedef pair <int, int> ii;

const int N = 1e5 + 5;
int n, m, d[N], tin[N], dfsTime;
vector <ii> adj[N];
bool mark[N];

void dfs(int u) {
	tin[u] = ++dfsTime;
	mark[u] = 1;
	for (ii p : adj[u]) {
		int v = p.first, w = p.second;
		if (!mark[v]) {
			d[v] = d[u] + w;
			dfs(v);
		} else if (tin[v] > tin[u]) {
			if (d[v] - d[u] != w) {
				cout << "No";
				exit(0);
			}
		}
	}
}

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

	cin >> n >> m;
	for (int i = 1; i <= m; ++i) {
		int l, r, x;
		cin >> l >> r >> x;
		adj[r].push_back({l, x});
		adj[l].push_back({r, -x});
	}
	for (int i = 1; i <= n; ++i) if (!mark[i])
		dfs(i);
	cout << "Yes";

	return 0;
}

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

#define ll long long int 
#define pii pair<int, int>
#define INF 1e8
#define fi first
#define se second
#define f(n) for(int i = 0; i < n; i++)
#define f2(n) for(int i = 1; i <= n; i++)
#define debug(x) if(on)cout << x << endl
#define on true
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pb push_back
#define mp make_pair


int target;
int n, m, k;
int v[15][15];
int algo[15];

int checa(int bitmask){

	int custo = 0;

	for(int i = 0; i <= m; i++)
		algo[i] = 0;

	for(int bit = 0; bit < n; bit++){
		if( (bitmask & (1<<bit)) != 0){
			for(int i = 1; i <= m; i++)
				algo[i] += v[bit][i];
		
			custo += v[bit][0];
		}
	}

	for(int i = 1; i <= m; i++)
		if(algo[i] < k)
			return INF;
	return custo;
}




int main(){

	
	cin >> n >> m >> k;

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


	int resp = INF;
	for(int bitmask = 0; bitmask < (1<<n); bitmask++){
		int val = checa(bitmask);
		if(val < resp)
			resp = val;

		
	}

	if(resp == INF){
		cout << "-1\n";
		return 0;
	}

	cout << resp << endl;

return 0;		
}


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

#define int long long
#define rep(i,a,n) for(int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort((c).begin(), (c).end(), greater<int>());
#define fi first
#define se second
  
typedef pair<int,int> P;
typedef vector<int> vi;

int H,W,N;
vector<P> ab;
int dx[3]={-2,-1,0};
int dy[3]={-2,-1,0};

signed main() {
    cin>>H>>W>>N;
    rep(i,0,N) {
        int A,B; cin>>A>>B;
        ab.pb(P(A,B));
    }

    vector<P> mp;
    rep(i,0,N) {
        int x=ab[i].fi-1;
        int y=ab[i].se-1;

        rep(j,0,3) {
            rep(k,0,3) {
                int nx=x+dx[j];
                int ny=y+dy[k];

                if(nx<0 or ny<0 or nx>=H-2 or ny>=W-2) continue;

                mp.pb(P(nx,ny));
            }
        }
    }

    sort(mp.begin(),mp.end());
    vi ctn(10,0);

    int ret=1;
    rep(i,1,mp.size()) {
        if(i>0 and mp[i]==mp[i-1]) {
            ret++;
            if(i==mp.size()-1) {
                ctn[ret]++;
                break;
            }
        }else{
            ctn[ret]++;
            if(i==mp.size()-1) {
                ctn[1]++;
            }
            ret=1;
        }
    }
    int sum0=(H-2)*(W-2);
    rep(i,1,10) {
        sum0-=ctn[i];
    }

    ctn[0]=sum0;
    rep(i,0,10) {
        cout<<ctn[i]<<endl;
    }
    return 0;
}







Measured memory_bytes: 20328
#define S scanf("%d",
b[99],c[99],s,x,y;main(k){for(S&k),S&k);k--;)for(S&y);y--;b[x]=k)S&x);for(S&k);k--;s+=b[x]-b[y]?0:!c[x]+++!c[y]++)S&x),S&y);s=!printf("%d\n",s);}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		long ans;
		if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
			ans = 0;
		} else {
			ans = Math.min(A * B, Math.min(B * C, C * A));
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 10064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,X,Y;cin >> n >> m >> X >> Y;
	vector<int> x(n);
	vector<int> y(m);
	rep(i,n) cin >> x[i];
	rep(i,m) cin >> y[i];
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	if(x[n-1]<y[0] && ((X<=x[n-1] && x[n-1]<Y) || (X<y[0] && Y>=y[0]))) cout << "No War" << endl;
	else cout << "War" << endl;
}

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

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

    vector<int> p(N);
    for(int i=0;i<N;i++){
        cin >> p[i];
    }

    sort(p.begin(), p.end());
    int ans = 0;
    for(int i=0;i<N-1;i++){
        ans += p[i];
    }
    ans += p[N-1]/2;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i, l, r) for(int i = (l); i < (r); ++i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
//-------
const int N = 1000;
int n, m;
int G[N][N];
int f[N][N];
vector<pii> a;
int col[N];
bool dfs(int u, int c, int & x, int & y) {
	bool ok = 1;
	col[u] = c;
	x += c == 0;
	y += c == 1;
	rep(i, 0, n) if(G[u][i]) {
		if(col[i] == -1)
			ok &= dfs(i, 1 - c, x, y);
		else if(col[i] == c)
			ok = 0;
	}
	return ok;
}
int main() {
	scanf("%d%d", &n, &m);
	memset(col, -1, sizeof(col));
	rep(i, 0, m) {
		int u, v;
		scanf("%d%d", &u, &v);
		u--, v--;
		G[u][v] = G[v][u] = 1;
	}
	rep(i, 0, n) rep(j, 0, n) if(i != j){
		G[i][j] = 1 - G[i][j];
	}
	bool ok = 1;
	rep(i, 0, n) if(col[i] == -1) {
		int x = 0, y = 0;
		ok &= dfs(i, 0, x, y);
		a.pb({min(x, y), max(x, y)});
	}
	if(!ok) puts("-1");
	else {
		f[0][0] = 1;
		rep(i, 0, sz(a)){
			auto & e = a[i];
			for(int i = N - 1; ~i; i--)
				for(int j = N - 1; ~j; j--) if(f[i][j]) {
					f[i + e.fi][j + e.se] = max(f[i + e.fi][j + e.se], f[i][j] + 1);
					f[i + e.se][j + e.fi] = max(f[i + e.se][j + e.fi], f[i][j] + 1);
				}
		}
		int ans = 1e9;
		rep(i, 0, N) rep(j, 0, N) if(f[i][j] == sz(a) + 1) {
			ans = min(ans, (i - 1) * i / 2 + (j - 1) * j / 2);
		}
		printf("%d\n", ans);
	}
	return 0;
}



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

int main(){
    int n;
    cin >> n;
    vector<int>p(n);
    rep(i,n) cin >> p.at(i);
    int k=0;
    rep(i,n){
      if(p.at(i)!=i+1){
        k++;
      }
    }
    if(k<=2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
let id x = x
let n = Scanf.scanf "%s\n" id
let a = (int_of_char n.[0]) - 48
let b = (int_of_char n.[1]) - 48
let c = (int_of_char n.[2]) - 48
let d = (int_of_char n.[3]) - 48
let oplist = [1;0]

let i2op i = if i = 1 then (+) else (-)
let i2c i = if i = 1 then '+' else '-'
  
let rec loop3 op1 op2 l =
  match l with
  | [] -> []
  | op3 :: rest ->
     if (i2op op3) ((i2op op2) ((i2op op1) a b) c) d = 7 then (op1,op2,op3) :: loop3 op1 op2 rest
       else loop3 op1 op2 rest

let rec loop2 op1 l =
  match l with
  | [] -> []
  | op2 :: rest -> (loop3 op1 op2 oplist) @ loop2 op1 rest
     
let rec loop1 l =
  match l with
  | [] -> []
  | op1 :: rest -> (loop2 op1 oplist) @ loop1 rest
    
let (op1,op2,op3) = List.hd (loop1 oplist)
let (op1,op2,op3) = (i2c op1,i2c op2,i2c op3)
  
let () =
  Printf.printf "%d%c%d%c%d%c%d=7\n" a op1 b op2 c op3 d

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

using namespace std;

int main() {
    int n,m,i;
    long long ans = 0;
    cin >> n >> m;
    vector<pair<long,long>> ab(n);

    for(i=0;i<n;i++) {
        cin >> ab[i].first >> ab[i].second;
    }
    sort(ab.begin(),ab.end());

    for(i=0;i<n;i++){
        if(ab[i].second < m){
            ans += ab[i].first * ab[i].second;
            m -= ab[i].second;
        }else{
            ans += ab[i].first * m;
            break;
        }
    }

    cout << ans << endl;
}

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    int N, L;
    cin >> N >> L;
    vector<string> a;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        a.push_back(s);
    }

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

    for (int i = 0; i < N; i++) {
        cout << a[i];
    }
    cout << endl;

    return 0;
}

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

#define test(t) while(t--)

#define ll  long long int

#define in  cin>>
#define out cout<<
#define en "\n"
#define sp " "

#define fast()  ios_base::sync_with_stdio(false);cin.tie(0);



using namespace std;

void solve()
{ string s,p;
  in s>>p;
  p.pop_back();
  if(s==p)
    out "Yes"<<en;
  else
    out "No"<<en;

}

int main(){ fast()
             //freopen("input.txt","r",stdin);
             //freopen("output.txt","w",stdout);
             ll t=1;
            //cin>>t;
            test(t){
            solve();
            }
return 0;}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N;
    cin >> N;
    set<ll> A;
    REP(i, N){
    	ll tmp;
    	cin >> tmp;
    	A.insert(tmp);
    }

    cout << ((int)A.size()==N ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 9600
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};
string Ans[2] = {"No", "Yes"};
string ANS[2] = {"NO", "YES"};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int Root(int x, vector<int> &root)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x], root);
}

void Merge(int v, int u, vector<int> &root, vector<int> &sz)
{
    v = Root(v, root), u = Root(u, root);
    if (v == u) return;
    if (sz[v] < sz[u])
    {
        sz[u] += sz[v];
        root[v] = u;
    }
    else
    {
        sz[v] += sz[u];
        root[u] = v;
    }
}

int ok(int x, int n)
{
    return 0 <= x && x < n;
}

void bfs(int v, vi &dist, vector<vi> &graph)
{
    fill(all(dist), -1);
    dist[v] = 0;
    vi q = {v};
    for (int i = 0; i < q.size(); i++)
    {
        for (auto u : graph[q[i]])
        {
            if (dist[u] == -1)
            {
                dist[u] = dist[q[i]] + 1;
                q.push_back(u);
            }
        }
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll a, b, c;
    cin >> a >> b >> c;
    cout << max(a, max(b, c)) * 9 + a + b + c;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(),v.end()

int main() {
  ll n,m,k;
  cin >> n >> m >> k;
  vector<ll> a(n),b(m),aa(n+1),bb(m+1),time(n+m+1);
  aa[0]=0;
  bb[0]=0;
  for(ll i=0;i<n;i++){
    cin >> a[i];
  }
  for(ll i=0;i<m;i++){
    cin >> b[i];
  }
  for(ll i=1;i<=n;i++){
    aa[i]=aa[i-1]+a[i-1];
  }
  for(ll i=1;i<=m;i++){
    bb[i]=bb[i-1]+b[i-1];
  }
  
  ll max=0;

  for(ll j=0;j<=m;j++){
    if(bb[j]<=k){
      if(j>max){max=j;}
    }else{break;}
  }
  
  ll maxmax=max;

for(ll i=1;i<=n;i++){
  if(aa[i]>k)break;
  	for(ll j=max;bb[j]>k-aa[i];j--){
          max--;
    }
  if(i+max>maxmax){
              maxmax=max+i;
            }
  }
  
  cout << maxmax << endl;

}




Measured memory_bytes: 12740
#include<bits/stdc++.h>
#define int long long int
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;
signed  main(){
  fast_cin();
  int n;
  double d;
  cin>>n>>d;
  int count=0;
  while(n--){
    int a,b;
    cin>>a>>b;
    double aa=sqrt(a*a+b*b);
    if(aa<=d){
      count++;
    }
  }
  cout<<count;
}

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

#define MAX 502

int ans[MAX][MAX];


int solve(int H, int W, int h, int w){
	long long int pos = (h - 1)*W;
	long long int go = W;
	int nega = H / h;
	int posi = H - nega;
	//a*(H-1)*W < b*W< a*H*W
	//a*posi>b*nega
	if (2*posi/nega>2*(h-1)+1){
		//a*posi/nega>b
		int a = 2;
		int K = a * (h - 1);
		K++;
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				if (i % (h) == h - 1){
					ans[i][j] = -K;
				}
				else{
					ans[i][j] = a;
				}
			}
		}
		return 0;
	}
	long long int mx = 1000000000 / (h - 1);
	if (mx * (h - 1) + 1 > 1000000000LL){
		mx--;
	}
	long long int a = mx;
	long long int b = a*(h - 1);
	b++;
	if (a*posi / nega>b){
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				if (i % (h) == h - 1){
					ans[i][j] = -b;
				}
				else{
					ans[i][j] = a;
				}
			}
		}
		return 0;
	}
}
int main(){
	int h;
	int w;
	int H;
	int W;
	cin >> H >> W >> h >> w;
	if (H%h == 0 && W%w == 0){
		puts("No");
		return 0;
	}
	if (H%h){
		int flag=solve(H, W, h, w);
		if (flag == 0){
			puts("Yes");
			for (int i = 0; i < H; i++){
				for (int j = 0; j < W; j++){
					if (j)printf(" ");
					printf("%d", ans[i][j]);
				}
				puts("");
			}
			return 0;
		}
	}
	if (W%w){
		int flag = solve(W, H, w, h);
		if (flag == 0){
			puts("Yes");
			for (int i = 0; i < H; i++){
				for (int j = 0; j < W; j++){
					if (j)printf(" ");
					printf("%d", ans[j][i]);
				}
				puts("");
			}
			return 0;
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 3840
#include<iostream>
using namespace std;
class Dice
{
public:
	enum face { top, front, right, left, rear, bottom };
private:
	int *label;
public:
	Dice()
	{
		label = new int[6];
		for (int i = 0; i < 6; i++)
			label[i] = 0;
	}
	Dice(int set[])
	{
		label = new int[6];
		for (int i = 0; i < 6; i++)
			label[i] = set[i];
	}
	~Dice()
	{
		delete[] label;
	}
	void rollNorth()
	{
		int tmp = label[top];
		label[top] = label[front];
		label[front] = label[bottom];
		label[bottom] = label[rear];
		label[rear] = tmp;
	}
	void rollSouth()
	{
		int tmp = label[top];
		label[top] = label[rear];
		label[rear] = label[bottom];
		label[bottom] = label[front];
		label[front] = tmp;
	}
	void rollEast()
	{
		int tmp = label[top];
		label[top] = label[left];
		label[left] = label[bottom];
		label[bottom] = label[right];
		label[right] = tmp;
	}
	void rollWest()
	{
		int tmp = label[top];
		label[top] = label[right];
		label[right] = label[bottom];
		label[bottom] = label[left];
		label[left] = tmp;
	}
	void clockwiseRotation()
	{
		int tmp = label[right];
		label[right] = label[rear];
		label[rear] = label[left];
		label[left] = label[front];
		label[front] = tmp;
	}
	void anticlockwiseRotation()
	{
		int tmp = label[right];
		label[right] = label[front];
		label[front] = label[left];
		label[left] = label[rear];
		label[rear] = tmp;
	}
	int *getLabel()
	{
		return label;
	}
	int getTop()
	{
		return label[top];
	}
	int getFront()
	{
		return label[front];
	}
	int getRight()
	{
		return label[right];
	}
	int getLeft()
	{
		return label[left];
	}
	int getRear()
	{
		return label[rear];
	}
	int getBottom()
	{
		return label[bottom];
	}
};
int main()
{
	int set1[6], set2[6];
	for (int i = 0; i < 6; i++)
		cin >> set1[i];
	for (int i = 0; i < 6; i++)
		cin >> set2[i];
	Dice D1(set1);
	Dice D2(set2);
	int top = D1.getTop();
	int front = D1.getFront();
	int right = D1.getRight();
	bool flag = true;
	if (D2.getLeft() == top)
		D2.rollEast();
	if (D2.getRight() == top)
		D2.rollWest();
	while (D2.getTop() != top)
		D2.rollNorth();
	int n = 0;
	while (D2.getFront() != front)
	{
		if (n > 3)
		{
			flag = false;
			break;
		}
		D2.clockwiseRotation();
		n++;
	}
	if (D2.getRight() != right)
		flag = false;
	if (flag)
		cout << "Yes\n";
	else
		cout << "No\n";
}


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

using namespace std;

int main()
{
    size_t N, M, K;    
    vector<size_t> A, B;

    // 読み込み
    cin >> N >> M >> K;
    A.resize(N);
    B.resize(M);
    for(int i = 0; i < N; ++i) { cin >> A[i];}
    for(int i = 0; i < M; ++i) { cin >> B[i];}

    // 累積和 a[i] = a_1 + .. + a_i (a[0] = 0)
    vector<size_t> a(N+1, 0), b(M+1, 0);
    for(int i = 1; i <= N; ++i) { a[i] = a[i-1] + A[i-1];}
    for(int i = 1; i <= M; ++i) { b[i] = b[i-1] + B[i-1];}

    // 最大数
    int max_n = 0;
    int n, m, nn;
    nn = N;
    for(m = 0; m <= M; ++m)
    {
        for(n = nn; n > 0; --n)
        {
            if( (a[n] + b[m]) <= K )
            {
                break;    
            }
        }
        nn = n;

        if(a[n] + b[m] > K)
        {
            continue;    
        }

        if((m + n) > max_n)
        {
            max_n = m + n;    
        }
    }

    cout << max_n << endl;

    return 0;    
}

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

#define ll long long
#define rep(i,N) for(ll i=0; i<N; i++)
const int mx = 2e5;

int main(void){
  ll N;
  cin >> N;
  ll A[N];
  
  rep(i,N){
    cin >> A[i];
    if(A[i]==0){
      cout << 0;
      return 0;
    }
  }
  
  ll ans = 1;
  rep(i,N){
    if(ans>500000000000000000){
      if(A[i]>1){
        cout << "-1";
        return 0;
      }
    }
    if(ans>1000000000 && A[i]>1000000000){
      cout << "-1";
      return 0;
    }
    ans *= A[i];
    if(ans>1000000000000000000){
      cout << "-1";
      return 0;
    }
  }
  
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 4376
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        do_(inp);
        inp.close();
    }
    public static void do_(Scanner inp) {
        String s = inp.next();
        if (s.equals("SUN")) System.out.println(7);
        if (s.equals("MON")) System.out.println(6);
        if (s.equals("TUE")) System.out.println(5);
        if (s.equals("WED")) System.out.println(4);
        if (s.equals("THU")) System.out.println(3);
        if (s.equals("FRI")) System.out.println(2);
        if (s.equals("SAT")) System.out.println(1);
    }
}


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

const int maxn = 105;
int a[maxn], b[maxn], n, ans = 0;

int main(){
	std::memset(b,0x3f,sizeof(b));
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		scanf("%d",&b[i]);
	}
	for(int i=1;i<=n;i++) a[i] = std::min(b[i],b[i-1]);
	for(int i=1;i<=n;i++) ans += a[i];
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256